Package org.zkoss.lang.reflect
Class FusionInvoker
java.lang.Object
org.zkoss.lang.reflect.FusionInvoker
- All Implemented Interfaces:
Serializable,InvocationHandler
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:
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() {...}
}
Then, you could fuse them together as follows:
Object obj = FusionInvoker.newInstance(new Object[] {new A(), new B()});
Thus, the fused proxy object, obj, could be used as if
it implements IA and IB:
IA ia = (IA) obj;
ia.f();
IB ib = (IB) obj;
ib.g();
- Since:
- 3.5.2
- Author:
- RyanWu
- See Also:
-
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedFusionInvoker(Object[] targets) UsenewInstance(Object[])instead. -
Method Summary
Modifier and TypeMethodDescriptionstatic ObjectnewInstance(Object[] targets) Creates an object that contains the all interfaces by wrapping giving object, targets.static ObjectnewInstance(Object target1, Object target2) Use for only two object, seenewInstance(Object[]).
-
Constructor Details
-
FusionInvoker
UsenewInstance(Object[])instead.
-
-
Method Details
-
newInstance
Use for only two object, seenewInstance(Object[]). -
newInstance
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
- Specified by:
invokein interfaceInvocationHandler- Throws:
Throwable
-