org.zkoss.lang.reflect
Class FusionInvoker

java.lang.Object
  extended by 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. Like the dynamic proxy pattern, this fusion invocation handler is used to wrap two or more instance into one object.

This invocation handler assumes the object being wrapped has all methods of these instance (aka, targets), and it might invoke the correspond methods

It happens when you need to provide a proxy object form two or more instance.

Example:

 <code>class A {
   public void f() {...}
 }
 class B {
   public void f2() {...}
 }
 interface IA {
   public void f();
 }
 interface IB {
   public void f2();
 }
 </code>
 then, you could create a proxy object:
 <code> Object obj = FusionInvoker.newInstance(new Object[] {A, B });
 </code>
 then use the proxy object anywhere.
 <code>
  IA ia = (IA) obj;
  ia.f();
  IB ib = (IB) obj;
  ib.f2();
  </code>
 

Since:
3.5.2
Author:
RyanWu
See Also:
Serialized Form

Constructor Summary
protected FusionInvoker(java.lang.Object[] targets)
          Use newInstance(Object[]) instead.
 
Method Summary
 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, see newInstance(Object[]).
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

FusionInvoker

protected FusionInvoker(java.lang.Object[] targets)
Use newInstance(Object[]) instead.

Method Detail

newInstance

public static java.lang.Object newInstance(java.lang.Object target1,
                                           java.lang.Object target2)
Use for only two object, see newInstance(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 interface java.lang.reflect.InvocationHandler
Throws:
java.lang.Throwable


Copyright © 2005-2009 Potix Corporation. All Rights Reserved. SourceForge.net Logo