org.jdesktop.wonderland.client
Class BaseClientPlugin

java.lang.Object
  extended by org.jdesktop.wonderland.client.BaseClientPlugin
All Implemented Interfaces:
ClientPlugin, PrimaryServerListener

public abstract class BaseClientPlugin
extends java.lang.Object
implements ClientPlugin, PrimaryServerListener

A default implementation of client plugin that listens for the primary server.

In addition to the normal intialize() and cleanup() methods, this base class provides two other methods, activate() and deactivate(). These methods are called when the ServerSessionManager associated with this plugin becomes the primary session manager. This is used for federation, to properly make changes to shared resources as the user moves from server to server.

The activate() and deactivate() methods should be used to make any changes to the core of Wonderland, such as adding menus or data flavor listeners.

Author:
Jonathan Kaplan

Constructor Summary
BaseClientPlugin()
           
 
Method Summary
protected  void activate()
          Override this method to modify any of Wonderland core when this module's session becomes the primary session.
 void cleanup()
          Cleans up the registrations made in initialize
protected  void deactivate()
          Override this method to undo any changes made in the activate() method.
protected  ServerSessionManager getSessionManager()
          Get the session manager associated with this plugin.
 void initialize(ServerSessionManager sessionManager)
          Initialize the client plugin.
protected  boolean isPrimary()
          Determine if the session mananager associated with this plugin is the primary session manager.
 void primaryServer(ServerSessionManager sessionManager)
          Notification that the primary server has changed.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

BaseClientPlugin

public BaseClientPlugin()
Method Detail

initialize

public void initialize(ServerSessionManager sessionManager)
Initialize the client plugin. This implementation registers as a PrimaryServerListener to track changes for the activate and deactivate methods.

Subclasses overriding this method should be aware that the activate() method will be called immediately from this method. If there is any setup needed before the activate() method is called, the call to super.intialize() should happen after that.

Specified by:
initialize in interface ClientPlugin
Parameters:
sessionManager - the ServerSessionManager this plugin is associated with

cleanup

public void cleanup()
Cleans up the registrations made in initialize

Specified by:
cleanup in interface ClientPlugin

primaryServer

public void primaryServer(ServerSessionManager sessionManager)
Notification that the primary server has changed.

Specified by:
primaryServer in interface PrimaryServerListener
Parameters:
sessionManager - the new primary session manager

activate

protected void activate()
Override this method to modify any of Wonderland core when this module's session becomes the primary session. For example, this can be used to add menus to the main window or to activate other types of listeners with the system.


deactivate

protected void deactivate()
Override this method to undo any changes made in the activate() method. This method is guaranteed to only be called after activate() has been called.

Note that other listener's activate() method may be called before deactivate, so clients should check when making changes to shared resources to verify that their value is actually the current one.


getSessionManager

protected ServerSessionManager getSessionManager()
Get the session manager associated with this plugin.

Returns:
the session manager associated with this plugin

isPrimary

protected boolean isPrimary()
Determine if the session mananager associated with this plugin is the primary session manager.

Returns:
true if the session manager associated with this plugin is the primary session manager


Open Wonderland - http://openwonderland.org