org.openrdf.util.rmirouting
Interface ChannelIface

All Superinterfaces:
Remote
All Known Implementing Classes:
ChannelIfaceImpl

public interface ChannelIface
extends Remote

This is the main interface through which we route the method invocations. Here I give a short description of the lifecycle of a typical remote instance that implements it and also will try clarify the usage of the methods by showing when and why they are invoked. Lets begin with the usual initial use case - when a server needs to expose an object implementing some, well known by the client, interfaces for a remote usage. So what we need to do is to create a proxy that handles the method invokation requests made by a client at server side. Once passed to the cleint, this server proxy should be wraped there in a way so that all the method invokation requests to be received back here in the server then processed by the 'real' target and the result received back to the client. In such a scheme the actual communincation between the client stub and the server proxy is made through an remote instance implementing ChannelIface. The tricky part is to construct the client wraper in a way to be undistinguisheable from the server side object. To ease the situation a bit we need to restrict the objects that can be exposed to only those which implements some set of interfaces that are well known to both sides involved in such a routing scheme. So to archieve this, we use the java.reflect.Proxy to build a dynamic proxy at client side, by passing a set of interfaces we need also an wraper thet impelemnts java.reflect.InvocationHandler. Once created, such a client proxy will behave as an object that implpements all those interfaces mentioned at create time and also the real invokation will be passed to its method invoke. In that way we can easylypass these requests to the server trough our interface. As you can imagine we use the invoke method to pass a method invocation request from the client to serever. The method getInterfaces is when we build a client side wraper to get a set of intefaces we need to apply to such a wraper Once the remote wraper is 'garabge collected' we use gotFinalized to notify the server side part of the routing scheme that the last remote instance is not used anymore and we can safely remove the remote instance from the RMI object table. Just to mention that all the instances of ChannelIfaceImpl are kept on the server in a table so to be resoved to the real instances they wrap, when such a need occur. as an example ot such case is a when we receive as an argument of a method being invoked a, previously created by this server, proxy.

See Also:
ChannelIfaceImpl, ChannelIfaceInvocation

Method Summary
 void batch(Object[] jobs)
          batch is used to send several method invocation requests in a single remote call.
 String[] getInterfaces()
          getInterfaces return all the interfaces implemented by the wraped instance as an array of strings.
 void gotFinalized()
          gotFinalized should be invoked through the finalize when the client garbage collector clears the remote wraper of a serfer stub.
 Object invoke(Object method, Object[] args)
          Method invoke is used to send/receive a method invokation request from a client to the object server.
 

Method Detail

invoke

public Object invoke(Object method,
                     Object[] args)
              throws RemoteException
Method invoke is used to send/receive a method invokation request from a client to the object server. The actual method being invoked is desribed in method argument and is identified by its name followed by the names of the classes of the expected arguments (as they appear in the declaration).

Parameters:
method - the method description
args - the real arguments to be used
Returns:
what value the invoked method returns or null if it is a void.
Throws:
RemoteException - which wraps as a cause what an Exception, the invoked method throws.

getInterfaces

public String[] getInterfaces()
                       throws RemoteException
getInterfaces return all the interfaces implemented by the wraped instance as an array of strings. It goes down through the class hierarchy to the Object class and collect all the implemented interfaces by eny of the mentioned classes in the subclass chain.

Returns:
an String[] with the names of the implemented interfaces by the wraped instance.
Throws:
RemoteException - in a case of unexpected contition

gotFinalized

public void gotFinalized()
                  throws RemoteException
gotFinalized should be invoked through the finalize when the client garbage collector clears the remote wraper of a serfer stub. In This way we can remove the stub from our Object table and release it for CG in server side

Throws:
RemoteException - in a case of unexpected contition

batch

public void batch(Object[] jobs)
           throws RemoteException
batch is used to send several method invocation requests in a single remote call. It can batch only void methods which arguments are either java.io.Serializable or native (e.g. byte, long, etc.)

Parameters:
jobs -
Throws:
RemoteException - which wraps as a cause what an Exception, any of the invoked methods throws.


Copyright © 2002-2006 Aduna BV, GNU LGPL License applies.