|
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.pfsw.extender.DelegatingInvocationHandler<TDelegate>
org.pfsw.extender.ExtendedObject<TDelegate>
public class ExtendedObject<TDelegate>
This is the core of the extendible objects framework. This handler is responsible for holding extensions and mix-ins and to dispatch method calls to the correct receiver.
Constructor Summary | |
---|---|
ExtendedObject(TDelegate object)
|
Method Summary | ||
---|---|---|
protected boolean |
containsMethod(java.lang.reflect.Method[] methods,
java.lang.reflect.Method method)
Returns true if the given method array contains the specified method. |
|
protected java.lang.Object |
findTargetOf(java.lang.reflect.Method method)
|
|
java.lang.Object |
getExtension(java.lang.String name)
Returns the extension object for the given name or null if not available. |
|
protected java.util.Map<java.lang.String,java.lang.Object> |
getExtensions()
|
|
|
getImplementor(java.lang.Class<I> interfaceClass)
Returns the implementing object of the given interface or null if none is found. |
|
|
getMixin(java.lang.Class<I> interfaceClass)
|
|
protected java.util.Map<java.lang.Class,java.lang.Object> |
getMixins()
|
|
protected boolean |
implementsMethod(java.lang.Class interfaceOrClass,
java.lang.reflect.Method method)
Returns true if the given class is no interface and is implementing the given method itself, that is not inheriting it. |
|
java.lang.Object |
invoke(java.lang.Object proxy,
java.lang.reflect.Method method,
java.lang.Object[] args)
Executes the given method with the specified args against the internal delegate. |
|
protected boolean |
isSameMethod(java.lang.reflect.Method method1,
java.lang.reflect.Method method2)
Returns true if the two given methods are the same except that they do not have to be declared by the same class or interface. |
|
void |
onExtensionsDo(ExtensionProcessor processor)
The given processor will be called on all extensions registered in this extended object until the processor returns false or all extensions have been iterated through. |
|
void |
onMixinsDo(MixinProcessor processor)
The given processor will be called on all mixins registered in this extended object until the processor returns false or all mixins have been iterated through. |
|
java.lang.Object |
removeExtension(java.lang.String name)
Remove and return the extension object for the given name or return null if not available. |
|
|
removeMixin(java.lang.Class<I> interfaceClass)
Removes the mix-in implementation for the given interface and returns it. |
|
void |
setExtension(java.lang.String name,
java.lang.Object extension)
Attach the given extension to the object this invocation handler stands for. |
|
|
setMixin(java.lang.reflect.Proxy proxy,
java.lang.Class<I> interfaceClass,
T implementation)
Sets the implementation instance for the specified interface. |
|
protected boolean |
understandsMethod(java.lang.Class interfaceOrClass,
java.lang.reflect.Method method)
Returns true if the given interface or class is understanding the given method, either by declaring it itself or by inheritance. |
|
protected boolean |
understandsMethod(java.lang.Object object,
java.lang.reflect.Method method)
|
Methods inherited from class org.pfsw.extender.DelegatingInvocationHandler |
---|
getDelegate, setDelegate |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public ExtendedObject(TDelegate object)
Method Detail |
---|
public java.lang.Object invoke(java.lang.Object proxy, java.lang.reflect.Method method, java.lang.Object[] args) throws java.lang.Throwable
DelegatingInvocationHandler
invoke
in interface java.lang.reflect.InvocationHandler
invoke
in class DelegatingInvocationHandler<TDelegate>
java.lang.Throwable
public void setExtension(java.lang.String name, java.lang.Object extension)
name
- The name of the extension (must not be null)extension
- Any object that must be attached (must not be null)public java.lang.Object getExtension(java.lang.String name)
public java.lang.Object removeExtension(java.lang.String name)
public <I,T extends I> void setMixin(java.lang.reflect.Proxy proxy, java.lang.Class<I> interfaceClass, T implementation)
The given proxy object will be set to all fields of the implementation object that are annotated by @Self.
If any of the given parameters is null, nothing will be set at all.
public <I> I getMixin(java.lang.Class<I> interfaceClass)
public <I> I removeMixin(java.lang.Class<I> interfaceClass)
public <I> I getImplementor(java.lang.Class<I> interfaceClass)
public void onExtensionsDo(ExtensionProcessor processor)
processor
- The processor that will be called per extension (must not be null).public void onMixinsDo(MixinProcessor processor)
processor
- The processor that will be called per mixin (must not be null).protected java.lang.Object findTargetOf(java.lang.reflect.Method method)
protected boolean understandsMethod(java.lang.Object object, java.lang.reflect.Method method)
protected boolean understandsMethod(java.lang.Class interfaceOrClass, java.lang.reflect.Method method)
protected boolean implementsMethod(java.lang.Class interfaceOrClass, java.lang.reflect.Method method)
protected boolean containsMethod(java.lang.reflect.Method[] methods, java.lang.reflect.Method method)
protected boolean isSameMethod(java.lang.reflect.Method method1, java.lang.reflect.Method method2)
protected java.util.Map<java.lang.String,java.lang.Object> getExtensions()
protected java.util.Map<java.lang.Class,java.lang.Object> getMixins()
|
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |