net.sf.composite.specialize.specializers
Class Jdk13ProxySpecializer
java.lang.Object
net.sf.composite.specialize.specializers.BaseSpecializer
net.sf.composite.specialize.specializers.Jdk13ProxySpecializer
- All Implemented Interfaces:
- Specializer
public class Jdk13ProxySpecializer
- extends BaseSpecializer
- implements Specializer
A composite specializer that is implemented using JDK 1.3 proxies. This
specializer requires that the composite to be specialized has a public
no-argument constructor. It also requires that the specialized type be an
interface, and any methods that are to be executed on the composite are
expressed in a separate interface (i.e. they cannot be specified in the
implementation class only). Finally, component access methods must be
specified in an interface. The SimpleComposite
,
RegistryComposite
etc. interfaces can be used for
this purpose.
The main benefit of this specializer is that it does not require the
composite to implement all the interfaces to which it may be specialized. The
main drawback is that the use of JDK proxies is much slower than regular
method calls (such as you would get when using the
CloningSpecializer
.
- Since:
- Mar 11, 2005
- Author:
- Matt Sgarlata
Method Summary |
protected java.lang.reflect.InvocationHandler |
createInvocationHandler(java.lang.Object composite)
|
protected java.lang.Object |
createNewComposite(java.lang.Object composite)
|
protected boolean |
isSpecializableImpl(java.lang.Object composite,
java.lang.Class specializedType)
Implementation template method. |
protected java.lang.Object |
specializeImpl(java.lang.Object composite,
java.lang.Class specializedType)
|
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Jdk13ProxySpecializer
public Jdk13ProxySpecializer()
isSpecializableImpl
protected boolean isSpecializableImpl(java.lang.Object composite,
java.lang.Class specializedType)
throws java.lang.Exception
- Description copied from class:
BaseSpecializer
- Implementation template method.
- Specified by:
isSpecializableImpl
in class BaseSpecializer
- Returns:
- boolean
- Throws:
java.lang.Exception
createNewComposite
protected java.lang.Object createNewComposite(java.lang.Object composite)
throws java.lang.Exception
- Throws:
java.lang.Exception
createInvocationHandler
protected java.lang.reflect.InvocationHandler createInvocationHandler(java.lang.Object composite)
throws java.lang.Exception
- Throws:
java.lang.Exception
specializeImpl
protected java.lang.Object specializeImpl(java.lang.Object composite,
java.lang.Class specializedType)
throws java.lang.Exception
- Specified by:
specializeImpl
in class BaseSpecializer
- Throws:
java.lang.Exception
Copyright © 2005-2008.