org.clazzes.remoting.beans
Class BeanInvocationHandler

java.lang.Object
  extended by org.clazzes.remoting.beans.BeanInvocationHandler
All Implemented Interfaces:
Initializable, InvocationHandler

public class BeanInvocationHandler
extends java.lang.Object
implements InvocationHandler, Initializable

This ServerInvocationHandler delegates remote calls to a bean by intelligently discovering the service interface.

Author:
wglas

Constructor Summary
BeanInvocationHandler()
           
 
Method Summary
 BeanCallAuthManager getBeanCallAuthManager()
           
 java.util.List<java.lang.Class<?>> getCallbackInterfaces()
           
 ReturnCallbackHandler getReturnCallbackHandler()
           
 java.lang.Class<?> getServiceInterface()
           
 java.lang.Object getTarget()
           
 void initialize()
          Initialize the internal state of this bean.
 java.lang.Object invoke(InvocationContext ctx, java.lang.Object arg, java.util.Map<java.lang.String,java.lang.Object> metadata)
           
 boolean isInitialized()
           
 void setBeanCallAuthManager(BeanCallAuthManager beanCallAuthManager)
           
 void setCallbackInterfaces(java.util.List<java.lang.Class<?>> callbackInterfaces)
           
 void setReturnCallbackHandler(ReturnCallbackHandler returnCallbackHandler)
           
 void setServiceInterface(java.lang.Class<?> serviceInterface)
           
 void setTarget(java.lang.Object target)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

BeanInvocationHandler

public BeanInvocationHandler()
Method Detail

isInitialized

public boolean isInitialized()
Specified by:
isInitialized in interface Initializable
Returns:
Whether this bean needs to be initialized using Initializable.initialize().

initialize

public void initialize()
                throws java.lang.Exception
Description copied from interface: Initializable
Initialize the internal state of this bean.

Specified by:
initialize in interface Initializable
Throws:
java.lang.Exception - Upon errors.

invoke

public java.lang.Object invoke(InvocationContext ctx,
                               java.lang.Object arg,
                               java.util.Map<java.lang.String,java.lang.Object> metadata)
                        throws java.lang.Throwable
Specified by:
invoke in interface InvocationHandler
Parameters:
ctx - The context under which the call has been issued.
arg - The argument of the call.
metadata - The metadata accompanying the remote call, which is passed to the invocation handler. Metadata may be used to communicate authorization information such as user/password or a session Id.
Returns:
The result of the operation.
Throws:
java.lang.Throwable - Any exception raised by the call. This exception will be reported back to the invoker as the root cause of an InvocationTargetException.

getTarget

public java.lang.Object getTarget()
Returns:
The target bean on which to invoke remote invocations.

setTarget

public void setTarget(java.lang.Object target)
Parameters:
target - The target bean to set.

getServiceInterface

public java.lang.Class<?> getServiceInterface()
Returns:
the serviceInterface. If the service interface is not set, the first interface of the target will be used.

setServiceInterface

public void setServiceInterface(java.lang.Class<?> serviceInterface)
                         throws java.io.InvalidClassException
Parameters:
serviceInterface - the serviceInterface to set.
Throws:
java.io.InvalidClassException - If the parameter is a class rather than an interface.

getCallbackInterfaces

public java.util.List<java.lang.Class<?>> getCallbackInterfaces()
Returns:
the callbackInterfaces

setCallbackInterfaces

public void setCallbackInterfaces(java.util.List<java.lang.Class<?>> callbackInterfaces)
Parameters:
callbackInterfaces - the callbackInterfaces to set

getReturnCallbackHandler

public ReturnCallbackHandler getReturnCallbackHandler()
Returns:
the returnCallbackHandler

setReturnCallbackHandler

public void setReturnCallbackHandler(ReturnCallbackHandler returnCallbackHandler)
Parameters:
returnCallbackHandler - the returnCallbackHandler to set

getBeanCallAuthManager

public BeanCallAuthManager getBeanCallAuthManager()
Returns:
the beanCallAuthManager

setBeanCallAuthManager

public void setBeanCallAuthManager(BeanCallAuthManager beanCallAuthManager)
Parameters:
beanCallAuthManager - the beanCallAuthManager to set


Copyright © 2010. All Rights Reserved.