edu.uci.isr.yancees.client.rmi
Class YanceesRMIClient

java.lang.Object
  extended by edu.uci.isr.yancees.client.rmi.YanceesRMIClient
All Implemented Interfaces:
YanceesInterface

public class YanceesRMIClient
extends java.lang.Object
implements YanceesInterface

Author:
Roberto Silveira Silva Filho [rsilvafi@ics.uci.edu] This is the API used by remote clients to interact with the YANCEES server using RMI. It hides from the end users, the code necessary to connect to the remote server, the RMI name resolution and so on. This API does not support client-side plug-ins. It works as a direct connection between client and server, allowing a faster interaction in this case. Client-side plug-ins are supported in another API,
See Also:
YanceesClient.java

Nested Class Summary
 class YanceesRMIClient.SubscriberMediator
          The subscriber mediator receives notifications from the plug-ins and forward them to their specific subscribers.
 
Constructor Summary
YanceesRMIClient(java.lang.String address)
          Creates a client implementation and automatically connects to the address provided
YanceesRMIClient(java.lang.String hostname, java.lang.String instanceName)
          Creates a client implementation and automatically connects to the address provided using the specified instance name.
 
Method Summary
 ProtocolPluginInterface connectToNewProtocol(java.lang.String protocolId, SubscriberInterface si)
          Connects to a new instance of a protocol plug-in.
 ProtocolPluginInterface connectToSharedProtocol(java.lang.String protocolId, SubscriberInterface si)
          Connects to an existing protocol instance.
protected  void connectToYancees(java.lang.String fullRMIReference)
          Connects to an YANCEES instance using a fully qualifying address
protected  void connectToYancees(java.lang.String hostname, java.lang.String instanceName)
          Connects to Yancees in a given hostname and instance name.
 void disconnectFromProtocol(java.lang.String protocolId, SubscriberInterface si)
          Terminates unshared protocol instances, or shared protocol instances if no more clients are connected to them.
 RemoteSubscriberInterface getRemoteInterfaceFor(SubscriberInterface si)
           
 void publish(EventInterface evt)
           
 void resumeYancees()
           
 void shutdownYancees()
           
 void subscribe(SubscriptionInterface msg, SubscriberInterface si)
           
 void suspendYancees()
           
 void unsubscribe(SubscriberInterface si)
           
 void unsubscribe(SubscriberInterface si, MessageInterface sub)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

YanceesRMIClient

public YanceesRMIClient(java.lang.String hostname,
                        java.lang.String instanceName)
                 throws YanceesException
Creates a client implementation and automatically connects to the address provided using the specified instance name. For example: 192.168.0.3/yancees3 where 192.168.0.3 is the hostname and yancees3 is the instance name.

Parameters:
hostname - is the name of the host having the RMI registry where the YANCEES interface is registered.
instanceName - is the name of the yancees instance as it is registered with the rmiregistry. This allows multiple copies of yancees to be executed in the same host, for example.
Throws:
YanceesException

YanceesRMIClient

public YanceesRMIClient(java.lang.String address)
                 throws YanceesException
Creates a client implementation and automatically connects to the address provided

Parameters:
address - is the hostname or the full address where YANCEEES remote implementation is published.
Throws:
YanceesException
Method Detail

connectToYancees

protected void connectToYancees(java.lang.String fullRMIReference)
                         throws YanceesException
Connects to an YANCEES instance using a fully qualifying address

Parameters:
fullRMIReference - is the full qualifying address
Throws:
YanceesException

connectToYancees

protected void connectToYancees(java.lang.String hostname,
                                java.lang.String instanceName)
                         throws YanceesException
Connects to Yancees in a given hostname and instance name. The name is composed and used to form a RMI URL.

Parameters:
hostname - is the name of the host where the instance is running
instanceName - is the name as registered in the local rmiregistry
Throws:
YanceesException

connectToSharedProtocol

public ProtocolPluginInterface connectToSharedProtocol(java.lang.String protocolId,
                                                       SubscriberInterface si)
                                                throws YanceesException
Description copied from interface: YanceesInterface
Connects to an existing protocol instance. If there is no instance available, YANCEES instantiates a new protocol plug-in. Subsequent calls to this method, for that specific protocol, will return the shared plug-in instance.

Specified by:
connectToSharedProtocol in interface YanceesInterface
Parameters:
protocolId - is the name of the protocol as registered in the configuration file and as available in the protocol factory
si - is the subscriber interface that can be used to receive events from the plug-in
Returns:
a reference to the plug-in
Throws:
YanceesException - is thrown in case of errors in the creation of the protocol plug-in

connectToNewProtocol

public ProtocolPluginInterface connectToNewProtocol(java.lang.String protocolId,
                                                    SubscriberInterface si)
                                             throws YanceesException
Description copied from interface: YanceesInterface
Connects to a new instance of a protocol plug-in. Each time this method is invoked, a new instance is created.

Specified by:
connectToNewProtocol in interface YanceesInterface
Parameters:
protocolId - is the name of the protocol as registered in the configuration file and as available in the protocol factory
si - is the subscriber interface that can be used to receive events from the plug-in
Returns:
a reference to the plug-in
Throws:
YanceesException - is thrown in case of errors in the creation of the protocol plug-in

disconnectFromProtocol

public void disconnectFromProtocol(java.lang.String protocolId,
                                   SubscriberInterface si)
                            throws YanceesException
Description copied from interface: YanceesInterface
Terminates unshared protocol instances, or shared protocol instances if no more clients are connected to them.

Specified by:
disconnectFromProtocol in interface YanceesInterface
Parameters:
protocolId - is the name of the protocol as registered in the configuration file and as available in the protocol factory
si - is the subscriber interface that can be used to receive events from the plug-in
Throws:
YanceesException - is thrown in case of errors in the creation of the protocol plug-in

publish

public void publish(EventInterface evt)
             throws YanceesException
Specified by:
publish in interface YanceesInterface
Throws:
YanceesException

resumeYancees

public void resumeYancees()
                   throws YanceesException
Specified by:
resumeYancees in interface YanceesInterface
Throws:
YanceesException

shutdownYancees

public void shutdownYancees()
                     throws YanceesException
Specified by:
shutdownYancees in interface YanceesInterface
Throws:
YanceesException

subscribe

public void subscribe(SubscriptionInterface msg,
                      SubscriberInterface si)
               throws YanceesException
Specified by:
subscribe in interface YanceesInterface
Throws:
YanceesException

suspendYancees

public void suspendYancees()
                    throws YanceesException
Specified by:
suspendYancees in interface YanceesInterface
Throws:
YanceesException

unsubscribe

public void unsubscribe(SubscriberInterface si,
                        MessageInterface sub)
                 throws YanceesException
Specified by:
unsubscribe in interface YanceesInterface
Throws:
YanceesException

unsubscribe

public void unsubscribe(SubscriberInterface si)
                 throws YanceesException
Specified by:
unsubscribe in interface YanceesInterface
Throws:
YanceesException

getRemoteInterfaceFor

public RemoteSubscriberInterface getRemoteInterfaceFor(SubscriberInterface si)
Parameters:
si - an existing subscriber
Returns:
a remoteInterface, able to receive remote notifications, for the equivalent local subscriber. It returns null if the mediator for this interface does not exist