org.caleigo.toolkit.tunnel
Class ProxyHandler

java.lang.Object
  extended byorg.caleigo.toolkit.tunnel.ProxyHandler
All Implemented Interfaces:
IMessageConsumer

public class ProxyHandler
extends java.lang.Object
implements IMessageConsumer

Version:
1.00
Author:
Mattias Hagstrand

Field Summary
protected  int mCurrentProxyID
           
protected  java.util.Hashtable mProxyObjects
           
protected  java.util.Hashtable mRemoteInvocationHandlers
           
protected  ITunnel mTunnel
           
 
Constructor Summary
ProxyHandler(ITunnel tunnel)
           
 
Method Summary
 boolean acceptsMessage(java.lang.Object message)
          Returns true if this IMessageConsumer accepts the message.
 java.lang.Object answerMessage(java.lang.Object message)
          Tells the IMessageConsumer to consume a message and returns a new message that will be delivered to the sender of the originial message.
 void consumeMessage(java.lang.Object message)
          Tells the IMessageConsumer to consume a message.
 java.lang.Object createProxy(java.lang.Class[] interfaceClasses, java.lang.Object handler)
          Creates a proxy for the provided interfaces.
 java.lang.Object createProxy(java.lang.Object obj)
          Creates a proxy for all interfaces that the provided object and its superclasses implement.
protected  java.lang.reflect.Method findMatchingMethod(java.lang.Class targetClass, java.lang.String methodName, java.lang.Object[] arguments)
           
 void finishProxy(java.lang.Object proxy)
           
protected  int generateProxyID()
           
 ITunnel getTunnel()
           
 void registerRemoteInvocationHandler(java.lang.Class interfaceClass, java.lang.Object handler)
          Register an object that handles remote invokations for the provided interface.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

mCurrentProxyID

protected int mCurrentProxyID

mTunnel

protected ITunnel mTunnel

mProxyObjects

protected java.util.Hashtable mProxyObjects

mRemoteInvocationHandlers

protected java.util.Hashtable mRemoteInvocationHandlers
Constructor Detail

ProxyHandler

public ProxyHandler(ITunnel tunnel)
Method Detail

createProxy

public java.lang.Object createProxy(java.lang.Object obj)
Creates a proxy for all interfaces that the provided object and its superclasses implement. Invocations on methods in the interfaces will be forwarded to the provided object.


createProxy

public java.lang.Object createProxy(java.lang.Class[] interfaceClasses,
                                    java.lang.Object handler)
Creates a proxy for the provided interfaces.

Parameters:
handler - object that will handle invocations on the created proxy. The handler is allowed to be null in which case invocation handlers must be registered for the interfaces.

finishProxy

public void finishProxy(java.lang.Object proxy)

registerRemoteInvocationHandler

public void registerRemoteInvocationHandler(java.lang.Class interfaceClass,
                                            java.lang.Object handler)
Register an object that handles remote invokations for the provided interface.


getTunnel

public ITunnel getTunnel()

acceptsMessage

public boolean acceptsMessage(java.lang.Object message)
Returns true if this IMessageConsumer accepts the message. This method is allways called before consumeMessage for any given message.

Specified by:
acceptsMessage in interface IMessageConsumer

consumeMessage

public void consumeMessage(java.lang.Object message)
Tells the IMessageConsumer to consume a message.

Specified by:
consumeMessage in interface IMessageConsumer

answerMessage

public java.lang.Object answerMessage(java.lang.Object message)
Tells the IMessageConsumer to consume a message and returns a new message that will be delivered to the sender of the originial message.

Specified by:
answerMessage in interface IMessageConsumer

generateProxyID

protected int generateProxyID()

findMatchingMethod

protected java.lang.reflect.Method findMatchingMethod(java.lang.Class targetClass,
                                                      java.lang.String methodName,
                                                      java.lang.Object[] arguments)


Copyright © 2005 Caleigo. All Rights Reserved.