摘要:
IoC是一个很大的概念,可以用不同的方式实现。其主要形式有两种: ◇ 依赖查找:容器提供回调接口和上下文条件给组件。EJB和Apache Avalon 都使用这种方式。这样一来,组件就必须使用容器提供的API来查找资源和协作对象,仅有的控制反转只体现在那些回调方法上(也就是上面所说的 类型1):容器
阅读全文
posted @ 2018-09-05 10:14
Borter
阅读(180)
推荐(0)
摘要:
现有的框架实际上使用以下三种基本技术的框架执行服务和部件间的绑定: 类型1 (基于接口): 可服务的对象需要实现一个专门的接口,该接口提供了一个对象,可以从用这个对象查找依赖(其它服务)。早期的容器Excalibur使用这种模式。 类型2 (基于setter): 通过JavaBean的属性(sett
阅读全文
posted @ 2018-09-05 10:12
Borter
阅读(132)
推荐(0)
摘要:
IoC最大的好处是什么?因为把对象生成放在了XML里定义,所以当我们需要换一个实现子类将会变成很简单(一般这样的对象都是实现于某种接口的),只要修改XML就可以了,这样我们甚至可以实现对象的热插拨(有点象USB接口和SCSI硬盘了)。 IoC最大的缺点是什么?(1)生成一个对象的步骤变复杂了(事实上
阅读全文
posted @ 2018-09-05 10:10
Borter
阅读(465)
推荐(0)
摘要:
IOC关注服务(或应用程序部件)是如何定义的以及他们应该如何定位他们依赖的其它服务。通常,通过一个容器或定位框架来获得定义和定位的分离,容器或定位框架负责: 保存可用服务的集合 提供一种方式将各种部件与它们依赖的服务绑定在一起 为应用程序代码提供一种方式来请求已配置的对象(例如,一个所有依赖都满足的
阅读全文
posted @ 2018-09-05 10:10
Borter
阅读(169)
推荐(0)
摘要:
IoC就是IoC,不是什么技术,与GoF一样,是一种 设计模式。 Interface Driven Design接口驱动,接口驱动有很多好处,可以提供不同灵活的子类实现,增加代码稳定和健壮性等等,但是接口一定是需要实现的,也就是如下语句迟早要执行:AInterface a = new AInterf
阅读全文
posted @ 2018-09-05 10:09
Borter
阅读(1243)
推荐(0)
摘要:
早在2004年,Martin Fowler就提出了“哪些方面的控制被反转了?”这个问题。他总结出是依赖对象的获得被反转了。基于这个结论,他为控制反转创造了一个更好的名字:依赖注入。许多非凡的应用(比HelloWorld.java更加优美,更加复杂)都是由两个或是更多的类通过彼此的合作来实现业务逻辑,
阅读全文
posted @ 2018-09-05 10:08
Borter
阅读(147)
推荐(0)
摘要:
一:这里先说一下DI(Dependency Injection)依赖注入有种表现形式:一种是CI(Constructor Injection)构造方法注入,另一种是SI(Set Injection) set 注入。这篇随笔讲的是第一种构造方法注入(Constructor Injection). 其实
阅读全文
posted @ 2018-09-05 10:07
Borter
阅读(503)
推荐(0)
摘要:
IOC 是什么? Ioc—Inversion of Control,即“控制反转”,不是什么技术,而是一种设计思想。在Java开发中,Ioc意味着将你设计好的对象交给容器控制,而不是传统的在你的对象内部直接控制。如何理解好Ioc呢?理解好Ioc的关键是要明确“谁控制谁,控制什么,为何是反转(有反转就
阅读全文
posted @ 2018-09-05 10:04
Borter
阅读(454)
推荐(0)
摘要:
学习整理 饱汉模式(懒汉模式) 优点:懒加载启动快,资源占用小,使用时才实例化,无锁。 缺点:非线程安全。 饱汉模式(懒汉模式)--线程安全 优点:同上,但加锁了。 缺点:synchronized 为独占排他锁,并发性能差。即使在创建成功以后,获取实例仍然是串行化操作。 饱汉模式(懒汉模式)--双重
阅读全文
posted @ 2018-09-05 09:44
Borter
阅读(247)
推荐(0)
摘要:
AOP AOP(Aspect Oriented Programming),即面向切面编程,可以说是OOP(Object Oriented Programming,面向对象编程)的补充和完善。OOP引入封装、继承、多态等概念来建立一种对象层次结构,用于模拟公共行为的一个集合。不过OOP允许开发者定义纵
阅读全文
posted @ 2018-09-05 09:40
Borter
阅读(1557)
推荐(0)
摘要:
AOP称为面向切面编程,在程序开发中主要用来解决一些系统层面上的问题,比如日志,事务,权限等待,Struts2的拦截器设计就是基于AOP的思想,是个比较经典的例子。 一 AOP的基本概念 (1)Aspect(切面):通常是一个类,里面可以定义切入点和通知 (2)JointPoint(连接点):程序执
阅读全文
posted @ 2018-09-05 09:35
Borter
阅读(1018)
推荐(0)
摘要:
ioc:控制反转(Inversion of Control,英文缩写为IoC)把创建对象的权利交给框架,是框架的重要特征,并非面向对象编程的专用术语。它包括依赖注入(Dependency Injection,简称DI)和依赖查找(Dependency Lookup)。 优点:因为把对象生成放在了XM
阅读全文
posted @ 2018-09-05 09:34
Borter
阅读(427)
推荐(1)
摘要:
This example demonstrates how to set a clipping area using a shape. The example sets an oval for the clipping area and then draws and image. Only thos
阅读全文
posted @ 2018-09-02 22:02
Borter
阅读(158)
推荐(0)
摘要:
This example demonstrates how to convert between a color value in RGB (three integer values in the range 0 to 255 representing red, green, and blue) a
阅读全文
posted @ 2018-09-02 22:02
Borter
阅读(144)
推荐(0)
摘要:
To draw on the screen, it is first necessary to subclass a JComponent and override its paint() method. The paint() method is automatically called by t
阅读全文
posted @ 2018-09-02 22:01
Borter
阅读(158)
推荐(0)
摘要:
This is the simplest application to animate an array of images.
阅读全文
posted @ 2018-09-02 22:00
Borter
阅读(113)
推荐(0)
摘要:
// See e575 The Quintessential Drawing Program public void paint(Graphics g) { // Retrieve the graphics context; this object is used to paint shapes Graphics2D g2d = (Graphics2D)g;...
阅读全文
posted @ 2018-09-02 22:00
Borter
阅读(145)
推荐(0)
摘要:
The print dialog allows the user to change the default printer settings such as the default printer, number of copies, range of pages, etc.
阅读全文
posted @ 2018-09-02 21:58
Borter
阅读(142)
推荐(0)
摘要:
PrinterJob pjob = PrinterJob.getPrinterJob(); PageFormat pf = pjob.defaultPage(); if (portrait) { pf.setOrientation(PageFormat.PORTRAIT); } else { pf.setOrientation(...
阅读全文
posted @ 2018-09-02 21:58
Borter
阅读(337)
推荐(0)
摘要:
A Book object is used when printing pages with different page formats. This example prints the first page in landscape and five more pages in portrait
阅读全文
posted @ 2018-09-02 21:57
Borter
阅读(240)
推荐(0)
摘要:
Note that (0, 0) of the Graphics object is at the top-left of the actual page, which is outside the printable area.
阅读全文
posted @ 2018-09-02 21:56
Borter
阅读(272)
推荐(0)
摘要:
Note that (0, 0) of the Graphics object is at the top-left of the actual page, outside the printable area. In this example, the Graphics object is tra
阅读全文
posted @ 2018-09-02 21:55
Borter
阅读(226)
推荐(0)
摘要:
The page format dialog allows the user to change the default page format values such as the orientation and paper size.
阅读全文
posted @ 2018-09-02 21:55
Borter
阅读(294)
推荐(0)
摘要:
Images in accelerated memory are much faster to draw on the screen. This example demonstrates how to take an image and make an accelerated copy of it
阅读全文
posted @ 2018-09-02 21:54
Borter
阅读(191)
推荐(0)
摘要:
This example demonstrates a 3x3 kernel that sharpens an image.
阅读全文
posted @ 2018-09-02 21:53
Borter
阅读(250)
推荐(0)
摘要:
ColorSpace cs = ColorSpace.getInstance(ColorSpace.CS_GRAY); ColorConvertOp op = new ColorConvertOp(cs, null); bufferedImage = op.filter(bufferedImage, null); Related Examples
阅读全文
posted @ 2018-09-02 21:53
Borter
阅读(254)
推荐(0)
摘要:
This example demonstrates how to convert a byte array of pixel values that are indices to a color table into a BufferedImage. In particular, the examp
阅读全文
posted @ 2018-09-02 21:52
Borter
阅读(195)
推荐(0)
摘要:
// Get a pixel int rgb = bufferedImage.getRGB(x, y); // Get all the pixels int w = bufferedImage.getWidth(null); int h = bufferedImage.getHeight(null); int[] rgbs = new ...
阅读全文
posted @ 2018-09-02 21:51
Borter
阅读(273)
推荐(0)
摘要:
This example demonstrates how to convert a byte array of pixel values that are indices to a color table into an Image. In particular, the example gene
阅读全文
posted @ 2018-09-02 21:51
Borter
阅读(142)
推荐(0)
摘要:
An Image object cannot be converted to a BufferedImage object. The closest equivalent is to create a buffered image and then draw the image on the buf
阅读全文
posted @ 2018-09-02 21:50
Borter
阅读(154)
推荐(0)
摘要:
This example demonstrates a 3x3 kernel that blurs an image.
阅读全文
posted @ 2018-09-02 21:50
Borter
阅读(185)
推荐(0)
摘要:
// This method returns true if the specified image has transparent pixels public static boolean hasAlpha(Image image) { // If buffered image, the color model is readily available ...
阅读全文
posted @ 2018-09-02 21:49
Borter
阅读(172)
推荐(0)
摘要:
// This method returns the color model of an image public static ColorModel getColorModel(Image image) { // If buffered image, the color model is readily available if (image instan...
阅读全文
posted @ 2018-09-02 21:48
Borter
阅读(158)
推荐(0)
摘要:
A IndexColorModel is used to represent the color table of a GIF image.
阅读全文
posted @ 2018-09-02 21:48
Borter
阅读(124)
推荐(0)
摘要:
Images in accelerated memory are much faster to draw on the screen. However, accelerated memory is typically limited and it is usually necessary for a
阅读全文
posted @ 2018-09-02 21:48
Borter
阅读(130)
推荐(0)
摘要:
// To create a buffered image, see e666 创建缓冲图像 // Flip the image vertically AffineTransform tx = AffineTransform.getScaleInstance(1, -1); tx.translate(0, -image.getHeight(null)); ...
阅读全文
posted @ 2018-09-02 21:47
Borter
阅读(154)
推荐(0)