org.systemsbiology.gaggle.geese.common
Class RmiGaggleConnector

java.lang.Object
  extended by org.systemsbiology.gaggle.geese.common.RmiGaggleConnector

public class RmiGaggleConnector
extends java.lang.Object

Handles connecting and disconnecting from the Gaggle Boss and exporting the Goose as an RMI remote object. Listeners can be registered which will be notified of connect and disconnect events. TODO: better exception handling.


Constructor Summary
RmiGaggleConnector(Goose goose)
           
 
Method Summary
 void addListener(GaggleConnectionListener listener)
          listeners will be notified on connect and disconnect.
 void connectToGaggle()
          connect to the Gaggle Boss, performing RMI exportObject if necessary.
 void disconnectFromGaggle(boolean printStackTrace)
          remove this goose from the Boss and unexport.
 boolean getAutoStartBoss()
           
 Boss getBoss()
           
 boolean isConnected()
           
 void removeListener(GaggleConnectionListener listener)
           
 void setAutoStartBoss(boolean autoStartBoss)
          Determines whether we should try and start a boss if a boss cannot be found; true by default.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

RmiGaggleConnector

public RmiGaggleConnector(Goose goose)
Parameters:
goose - a non-null goose
Method Detail

connectToGaggle

public void connectToGaggle()
                     throws java.lang.Exception
connect to the Gaggle Boss, performing RMI exportObject if necessary.

Throws:
java.lang.Exception - if connection cannot be performed

disconnectFromGaggle

public void disconnectFromGaggle(boolean printStackTrace)
remove this goose from the Boss and unexport. You can suppress the stack trace if you are calling from a shutdown hook and the boss is not running.

Parameters:
printStackTrace - allows a stack trace to be printed if the call fails

addListener

public void addListener(GaggleConnectionListener listener)
listeners will be notified on connect and disconnect.

Parameters:
listener - The listener to add

removeListener

public void removeListener(GaggleConnectionListener listener)

isConnected

public boolean isConnected()

setAutoStartBoss

public void setAutoStartBoss(boolean autoStartBoss)
Determines whether we should try and start a boss if a boss cannot be found; true by default.

Parameters:
autoStartBoss - whether to try and start a boss if no boss is found

getAutoStartBoss

public boolean getAutoStartBoss()

getBoss

public Boss getBoss()
Returns:
Boss if connected or null otherwise.