dermi.session.pastry
Class Session

java.lang.Object
  extended by dermi.session.pastry.Session
All Implemented Interfaces:
Session

public class Session
extends java.lang.Object
implements Session

The Session class establishes a simple contract to access publish/subscribe middleware. It mimics the delegation event model to smooth the transition from local to remote events for Java programmers

Version:
1.2
Author:
Carles Pairot , Pedro Garcia , Ruben Mondejar

Field Summary
 DermiConnection conn
           
 
Constructor Summary
Session()
           
 
Method Summary
 void addActiveObject(java.lang.String uid, ERemote ref)
           
 void addInterceptor(RemoteInterceptorListener sel, java.util.Hashtable evt)
          Add interceptor application to specified multicast group.
 void addRemoteAnycallEventListener(RemoteEventListener sel, java.util.Hashtable event)
          Add remote anycast event listener to specified multicast group.
 void anycall(java.util.Hashtable evt)
          Make a method call to any of the group members.
 void close()
          Closes the current session.
 boolean containsActiveObject(java.lang.String uid)
           
 void continueInterception(java.util.Hashtable evt, java.util.ArrayList interceptors)
          Invoked by interceptor skeleton to force the resuming of the interception process
 ActivatorClient getActivator()
           
 PriorityList getComponentHops(java.lang.String uid)
           
 Node getLocalNode()
          Gets an instance to the current local node
 NodeHandle getLocalNodeHandle()
          Gets an instance to the current local node handle
 Id getLocalNodeId()
          Gets an instance to the current local node id
 java.util.Collection getReplicaSet(Id id, int maxRank)
          Returns a set of suitable replica nodes for such Id
 java.util.Collection listActiveObjects()
           
 void open(java.util.Hashtable env)
          Opens a new session.
 void publish(java.util.Hashtable evt)
          Send event to multicast group.
 void publish(java.util.Hashtable event, java.io.Serializable obj)
          Send object event to multicast group.
 void publishDirect(java.util.Hashtable evt)
          Send event directly.
 void publishDirect(java.util.Hashtable event, java.io.Serializable obj)
          Send object directly.
 void removeActiveObject(java.lang.String uid)
           
 void removeInterceptor(java.util.Hashtable evt)
          Remove interceptor application from specified multicast group.
 void removeRemoteAnycallEventListener(RemoteEventListener sel, java.util.Hashtable event)
          Removes an anycall event listener
 void subscribe(RemoteEventListener sel, java.util.Hashtable event)
          Add remote event listener to specified multicast group.
 void subscribe(RemoteEventListener listener, java.lang.String subs)
          Add remote event listener to specified multicast group.
 void unsubscribe(RemoteEventListener sel, java.util.Hashtable event)
          Remove remote event listener from the specified multicast group.
 void unsubscribe(RemoteEventListener listener, java.lang.String subs)
          Remove remote event listener from the specified multicast group.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

conn

public DermiConnection conn
Constructor Detail

Session

public Session()
Method Detail

open

public void open(java.util.Hashtable env)
          throws SessionException
Opens a new session.

Specified by:
open in interface Session
Parameters:
env - environment connection properties
Throws:
SessionException - if any exception occurs

close

public void close()
           throws SessionException
Closes the current session.

Specified by:
close in interface Session
Throws:
SessionException

publish

public void publish(java.util.Hashtable evt)
             throws SessionException
Send event to multicast group.

Specified by:
publish in interface Session
Parameters:
evt - group subscription
Throws:
SessionException

publish

public void publish(java.util.Hashtable event,
                    java.io.Serializable obj)
             throws SessionException
Send object event to multicast group.

Specified by:
publish in interface Session
Parameters:
event - group subscription
obj - object to be sent
Throws:
SessionException

publishDirect

public void publishDirect(java.util.Hashtable evt)
                   throws SessionException
Send event directly.

Specified by:
publishDirect in interface Session
Parameters:
evt - group subscription
Throws:
SessionException

publishDirect

public void publishDirect(java.util.Hashtable event,
                          java.io.Serializable obj)
                   throws SessionException
Send object directly.

Specified by:
publishDirect in interface Session
Parameters:
event - group subscription
obj - object to be sent
Throws:
SessionException

addInterceptor

public void addInterceptor(RemoteInterceptorListener sel,
                           java.util.Hashtable evt)
                    throws SessionException
Add interceptor application to specified multicast group.

Specified by:
addInterceptor in interface Session
Parameters:
sel - the filter application to be called
evt - group subscription
Throws:
SessionException

removeInterceptor

public void removeInterceptor(java.util.Hashtable evt)
                       throws SessionException
Remove interceptor application from specified multicast group.

Specified by:
removeInterceptor in interface Session
Parameters:
evt - group subscription
Throws:
SessionException

anycall

public void anycall(java.util.Hashtable evt)
             throws SessionException
Make a method call to any of the group members. Only one object will execute the method (which one does so depends on arbitrary criteria)

Specified by:
anycall in interface Session
Parameters:
evt - hashtable containing group id, method to be invoked, params, ...
Throws:
SessionException - If something goes wrong ;-)

addRemoteAnycallEventListener

public void addRemoteAnycallEventListener(RemoteEventListener sel,
                                          java.util.Hashtable event)
                                   throws SessionException
Add remote anycast event listener to specified multicast group. The listener will be called every time an event is received in this group.

Specified by:
addRemoteAnycallEventListener in interface Session
Parameters:
sel - the remote anycast event listener application to be called
event - group subscription
Throws:
SessionException

subscribe

public void subscribe(RemoteEventListener sel,
                      java.util.Hashtable event)
               throws SessionException
Add remote event listener to specified multicast group. The listener will be called every time an event is received in this group.

Specified by:
subscribe in interface Session
Parameters:
sel - the remote event listener application to be called
event - group subscription
Throws:
SessionException
See Also:
RemoteEventListener

subscribe

public void subscribe(RemoteEventListener listener,
                      java.lang.String subs)
               throws SessionException
Add remote event listener to specified multicast group. The listener will be called every time an event is received in this group

Specified by:
subscribe in interface Session
Parameters:
listener - the remote event listener application to be called
subs - group subscription
Throws:
SessionException
See Also:
RemoteEventListener

getReplicaSet

public java.util.Collection getReplicaSet(Id id,
                                          int maxRank)
Returns a set of suitable replica nodes for such Id

Specified by:
getReplicaSet in interface Session
Parameters:
id - Id Which id to replicate
maxRank - int Maximum number of replicas
Returns:
Collection Set of replicas

unsubscribe

public void unsubscribe(RemoteEventListener sel,
                        java.util.Hashtable event)
                 throws SessionException
Remove remote event listener from the specified multicast group.

Specified by:
unsubscribe in interface Session
Parameters:
event - group subscription
sel - RemoteEventListener The listener of remote events
Throws:
SessionException

unsubscribe

public void unsubscribe(RemoteEventListener listener,
                        java.lang.String subs)
                 throws SessionException
Remove remote event listener from the specified multicast group.

Specified by:
unsubscribe in interface Session
Parameters:
listener - listener to unsubscribe
subs - group subscription
Throws:
SessionException

removeRemoteAnycallEventListener

public void removeRemoteAnycallEventListener(RemoteEventListener sel,
                                             java.util.Hashtable event)
                                      throws SessionException
Removes an anycall event listener

Specified by:
removeRemoteAnycallEventListener in interface Session
Parameters:
sel - RemoteAnycallEventListener The listener
event - Hashtable Event subscription data
Throws:
SessionException - If something goes wrong ;-)

getLocalNodeHandle

public NodeHandle getLocalNodeHandle()
Gets an instance to the current local node handle

Specified by:
getLocalNodeHandle in interface Session
Returns:
NodeHandle The local node handle

getLocalNode

public Node getLocalNode()
Gets an instance to the current local node

Specified by:
getLocalNode in interface Session
Returns:
Node The local node

getLocalNodeId

public Id getLocalNodeId()
Gets an instance to the current local node id

Specified by:
getLocalNodeId in interface Session
Returns:
Node The local node id

continueInterception

public void continueInterception(java.util.Hashtable evt,
                                 java.util.ArrayList interceptors)
Invoked by interceptor skeleton to force the resuming of the interception process

Specified by:
continueInterception in interface Session
Parameters:
evt - Hashtable Event data
interceptors - ArrayList Remaining interceptors

getActivator

public ActivatorClient getActivator()
Specified by:
getActivator in interface Session

addActiveObject

public void addActiveObject(java.lang.String uid,
                            ERemote ref)
Specified by:
addActiveObject in interface Session

removeActiveObject

public void removeActiveObject(java.lang.String uid)
Specified by:
removeActiveObject in interface Session

listActiveObjects

public java.util.Collection listActiveObjects()
Specified by:
listActiveObjects in interface Session

containsActiveObject

public boolean containsActiveObject(java.lang.String uid)
Specified by:
containsActiveObject in interface Session

getComponentHops

public PriorityList getComponentHops(java.lang.String uid)
Specified by:
getComponentHops in interface Session