gcsImplementations.spreadGcs
Class SpreadGcsMessageListener

java.lang.Object
  extended by gcs.GcsMessageListener
      extended by gcsImplementations.spreadGcs.SpreadGcsMessageListener
All Implemented Interfaces:
GcsAdvancedMessageListener, spread.AdvancedMessageListener

public class SpreadGcsMessageListener
extends GcsMessageListener
implements spread.AdvancedMessageListener

Spread back-end implementation of the GcsMessageListener.

Author:
tkob
See Also:
GcsMessageListener

Field Summary
 
Fields inherited from class gcs.GcsMessageListener
active, mySessionReference, newMessages, quitting
 
Constructor Summary
SpreadGcsMessageListener(ProfileEntity mySessionReference)
           
 
Method Summary
protected  void activateListener()
          Sets up the listener from the connection.
protected  void deactivateListener()
          Removes the listener from the connection.
 java.util.List<GcsMessage> getNewMessages()
          Used for retrieving new messages.
 boolean isActive()
          Used to check the state of the GcsMessageListener.
 void membershipMessageReceived(GcsMessage message)
          Invoked if an object implementing the GcsAdvancedMessageListener listener and registered to a GcsConnection with GcsConnection.add(GcsAdvancedMessageListener) receives a membership message.
 void membershipMessageReceived(spread.SpreadMessage arg0)
           
 void regularMessageReceived(GcsMessage message)
          Invoked if an object implementing the GcsAdvancedMessageListener listener and registered to a GcsConnection with GcsConnection.add(GcsAdvancedMessageListener) receives a regular message.
 void regularMessageReceived(spread.SpreadMessage arg0)
           
 void stopListener()
          Deactivates the listener and causes the GcsMessageListener.getNewMessages() to continue when it is blocked.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SpreadGcsMessageListener

public SpreadGcsMessageListener(ProfileEntity mySessionReference)
Method Detail

activateListener

protected void activateListener()
                         throws GcsException
Description copied from class: GcsMessageListener
Sets up the listener from the connection.

Specified by:
activateListener in class GcsMessageListener
Throws:
GcsException - if the listener can not be set up

deactivateListener

protected void deactivateListener()
                           throws GcsException
Description copied from class: GcsMessageListener
Removes the listener from the connection.

Specified by:
deactivateListener in class GcsMessageListener
Throws:
GcsException

membershipMessageReceived

public void membershipMessageReceived(spread.SpreadMessage arg0)
Specified by:
membershipMessageReceived in interface spread.AdvancedMessageListener

regularMessageReceived

public void regularMessageReceived(spread.SpreadMessage arg0)
Specified by:
regularMessageReceived in interface spread.AdvancedMessageListener

membershipMessageReceived

public void membershipMessageReceived(GcsMessage message)
                               throws GcsException
Description copied from interface: GcsAdvancedMessageListener
Invoked if an object implementing the GcsAdvancedMessageListener listener and registered to a GcsConnection with GcsConnection.add(GcsAdvancedMessageListener) receives a membership message.

Specified by:
membershipMessageReceived in interface GcsAdvancedMessageListener
Parameters:
message - the message which has been received
Throws:
GcsException

regularMessageReceived

public void regularMessageReceived(GcsMessage message)
                            throws GcsException
Description copied from interface: GcsAdvancedMessageListener
Invoked if an object implementing the GcsAdvancedMessageListener listener and registered to a GcsConnection with GcsConnection.add(GcsAdvancedMessageListener) receives a regular message.

Specified by:
regularMessageReceived in interface GcsAdvancedMessageListener
Parameters:
message - the message which has been received
Throws:
GcsException

getNewMessages

public java.util.List<GcsMessage> getNewMessages()
                                          throws GcsException
Description copied from class: GcsMessageListener
Used for retrieving new messages. It returns when at least one message is avaliable or the GcsMessageListener.stopListener() is called.

Specified by:
getNewMessages in class GcsMessageListener
Returns:
list of new messages
Throws:
GcsException - if problem were encountered during reception of the messages

stopListener

public void stopListener()
                  throws GcsException
Description copied from class: GcsMessageListener
Deactivates the listener and causes the GcsMessageListener.getNewMessages() to continue when it is blocked.

Specified by:
stopListener in class GcsMessageListener
Throws:
GcsException - if listener could not be deactivated

isActive

public boolean isActive()
Description copied from class: GcsMessageListener
Used to check the state of the GcsMessageListener.

Specified by:
isActive in class GcsMessageListener
Returns:
true if the listener is set up, false otherwise