Package org.zkoss.lang.reflect
Class FusionInvoker
- java.lang.Object
-
- org.zkoss.lang.reflect.FusionInvoker
-
- All Implemented Interfaces:
java.io.Serializable
,java.lang.reflect.InvocationHandler
public class FusionInvoker extends java.lang.Object implements java.lang.reflect.InvocationHandler, java.io.Serializable
The fusion invocation handler. It is used to fuse two or more instance into one object. It is usefully if you want to have a single object to represent two more other instances.Example:
Then, you could fuse them together as follows:public interface IA { public void f(); } public interface IB { public void g(); } public class A implements IA { public void f() {...} } public class B implements IB { public void g() {...} }
Thus, the fused proxy object,Object obj = FusionInvoker.newInstance(new Object[] {new A(), new B()});
obj
, could be used as if it implementsIA
andIB
:IA ia = (IA) obj; ia.f(); IB ib = (IB) obj; ib.g();
- Since:
- 3.5.2
- Author:
- RyanWu
- See Also:
- Serialized Form
-
-
Constructor Summary
Constructors Modifier Constructor Description protected
FusionInvoker(java.lang.Object[] targets)
UsenewInstance(Object[])
instead.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description java.lang.Object
invoke(java.lang.Object proxy, java.lang.reflect.Method method, java.lang.Object[] args)
static java.lang.Object
newInstance(java.lang.Object[] targets)
Creates an object that contains the all interfaces by wrapping giving object, targets.static java.lang.Object
newInstance(java.lang.Object target1, java.lang.Object target2)
Use for only two object, seenewInstance(Object[])
.
-
-
-
Constructor Detail
-
FusionInvoker
protected FusionInvoker(java.lang.Object[] targets)
UsenewInstance(Object[])
instead.
-
-
Method Detail
-
newInstance
public static java.lang.Object newInstance(java.lang.Object target1, java.lang.Object target2)
Use for only two object, seenewInstance(Object[])
.
-
newInstance
public static java.lang.Object newInstance(java.lang.Object[] targets)
Creates an object that contains the all interfaces by wrapping giving object, targets.Usage shortcut: FusionInvoker.newInstance(new Object[] { Object a, Object b });
- Parameters:
targets
- the objects need to wrapped
-
invoke
public java.lang.Object invoke(java.lang.Object proxy, java.lang.reflect.Method method, java.lang.Object[] args) throws java.lang.Throwable
- Specified by:
invoke
in interfacejava.lang.reflect.InvocationHandler
- Throws:
java.lang.Throwable
-
-