org.jboss.messaging.core.distributed.util
Class RpcServer

java.lang.Object
  extended byorg.jboss.messaging.core.distributed.util.RpcServer

public class RpcServer
extends java.lang.Object

An RpcServer is installed as "server object" with a RpcDispatcher instance.

The RpcServer allows dynamic registration of other server objects, under different "categories". For each category, the RpcServer allows registration of one or more equivalent server delegate objects, on which methods will be serially invoked when a remote method call is received from the group.

Version:
$Revision: 461 $
Author:
Ovidiu Feodorov

Field Summary
protected  java.lang.String name
           
protected  java.util.Map servers
           
 
Constructor Summary
RpcServer()
           
RpcServer(java.lang.String name)
           
 
Method Summary
 java.util.Set get(java.io.Serializable category)
           
 java.util.Collection invoke(java.io.Serializable category, java.lang.String methodName, java.lang.Object[] args, java.lang.String[] signature)
          Generic detyped interface to be accessed remotely.
 boolean register(java.io.Serializable category, ServerFacade subordinate)
          Registers a server delegate object with the RpcServer, under the specified category.
 boolean registerUnique(java.io.Serializable category, ServerFacade subordinate)
          Registers a unique server delegate object with the RpcServer, under the specified category.
static java.lang.String subordinateToString(java.io.Serializable category, java.io.Serializable subordinateID, Address address)
          Helper method that returns a human readable label for a server delegate, to be used in logs.
 java.lang.String toString()
           
 boolean unregister(java.io.Serializable category)
          Unregister the whole category.
 boolean unregister(java.io.Serializable category, ServerFacade subordinate)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

servers

protected java.util.Map servers

name

protected java.lang.String name
Constructor Detail

RpcServer

public RpcServer()

RpcServer

public RpcServer(java.lang.String name)
Method Detail

invoke

public java.util.Collection invoke(java.io.Serializable category,
                                   java.lang.String methodName,
                                   java.lang.Object[] args,
                                   java.lang.String[] signature)
                            throws java.lang.Exception
Generic detyped interface to be accessed remotely.

Parameters:
category - - the category of equivalent server delegates to invoke the method on.
methodName - - the name of the method to be invoked by reflection on the registered serverObjects.
args - - the method's arguments.
signature - - the method's signature. The array contains fully qualified class names.
Returns:
a Collection containing SubordinateServerResponse instances. It always returns a Collection, an empty collection in the case that no servers were found, never null.
Throws:
java.lang.ClassNotFoundException - if a fully qualified name specified in the method's signature cannot be used to load a valid class.
java.lang.NoSuchMethodException - if no method with the specified name or with the specified signature can be identified by reflection on the server object.
java.lang.IllegalAccessException
java.lang.IllegalArgumentException
java.lang.reflect.InvocationTargetException - if the underlying method throws an exception.
java.lang.Exception

register

public boolean register(java.io.Serializable category,
                        ServerFacade subordinate)
Registers a server delegate object with the RpcServer, under the specified category.

Note that more than one "equivalent" server objects can be registered under the same category. However, no equal (as per the "equal()" method semantics) are allowed to be registered under the same category. If an unique server delegate was already registered under the category, the call fails (returns false).

Parameters:
category - - the server category.
subordinate - - the server delegate object to be registered.
Returns:
true if the server was sucessfully registered or false if an "equal" object was already registered under the specified server ID. The method returns false if an unique server delegate was already registered under the category.
Throws:
java.lang.NullPointerException - if trying to register a null instance.

registerUnique

public boolean registerUnique(java.io.Serializable category,
                              ServerFacade subordinate)
Registers a unique server delegate object with the RpcServer, under the specified category.

If a server delegate is already registered under this category, the call should fail (return false).

Parameters:
category - - the server category.
subordinate - - the server delegate object to be registered.
Returns:
true if the server was sucessfully registered or false if a server delegate was already registered under the category.
Throws:
java.lang.NullPointerException - if trying to register a null instance.

unregister

public boolean unregister(java.io.Serializable category,
                          ServerFacade subordinate)
Returns:
true if the server delegate was sucessfully unregistered or false if the specified server delegate was not found under the specified category.

unregister

public boolean unregister(java.io.Serializable category)
Unregister the whole category.

Returns:
true if the category was sucessfully unregistered or false if the specified category was not found.

get

public java.util.Set get(java.io.Serializable category)
Parameters:
category - - the server category.
Returns:
a Set of equivalent server subordinates, or an empty Set if no servers were registered under that ID. If the server delegate was registered as unique, an one-element Set is returned.

toString

public java.lang.String toString()

subordinateToString

public static java.lang.String subordinateToString(java.io.Serializable category,
                                                   java.io.Serializable subordinateID,
                                                   Address address)
Helper method that returns a human readable label for a server delegate, to be used in logs.



Copyright © 2006 JBoss Inc. All Rights Reserved.