jxl.enclosure.peer
Class ModuleServer

java.lang.Object
  extended by java.rmi.server.RemoteObject
      extended by java.rmi.server.RemoteServer
          extended by java.rmi.server.UnicastRemoteObject
              extended by jxl.peermi.PeerRemoteObject
                  extended by jxl.enclosure.peer.ModuleServer
All Implemented Interfaces:
java.io.Serializable, java.rmi.Remote, ModuleServerInterface, PeerRemote

public class ModuleServer
extends PeerRemoteObject
implements ModuleServerInterface

The implementation of the module server.

Author:
Alex Lynch
See Also:
Serialized Form

Field Summary
static java.lang.String MODULE_SERVER_BINDING
          Name used to bind to PeerRegistry
 
Fields inherited from class java.rmi.server.RemoteObject
ref
 
Method Summary
 byte[] findModuleOf(java.lang.String[] classNames)
          Find a module containg a class whose name is className
 byte[] findUpdate(java.lang.String module, Version version)
          Find the newest version of module
static ModuleServer getInstance()
          Return a singleton instance of ModuleServer
 ObjectPair<byte[],Version> locate(java.lang.String[] classNames)
          Remote method, should not be called by a client
 ObjectPair<byte[],Version> update(java.lang.String module, Version version)
          Remote method, should not be called by a client
 
Methods inherited from class jxl.peermi.PeerRemoteObject
checkAlive, isAlive, toStub
 
Methods inherited from class java.rmi.server.UnicastRemoteObject
clone, exportObject, exportObject, exportObject, unexportObject
 
Methods inherited from class java.rmi.server.RemoteServer
getClientHost, getLog, setLog
 
Methods inherited from class java.rmi.server.RemoteObject
equals, getRef, hashCode, toString
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface jxl.peermi.PeerRemote
checkAlive
 

Field Detail

MODULE_SERVER_BINDING

public static final java.lang.String MODULE_SERVER_BINDING
Name used to bind to PeerRegistry

Method Detail

getInstance

public static ModuleServer getInstance()
                                throws java.rmi.RemoteException
Return a singleton instance of ModuleServer

Throws:
java.rmi.RemoteException

findUpdate

public byte[] findUpdate(java.lang.String module,
                         Version version)
                  throws java.lang.Exception
Find the newest version of module

Parameters:
module - the name of the module
version - The current version
Returns:
the byte[] data of the newest version of module or null if no version newer than version could be found.
Throws:
java.lang.Exception

findModuleOf

public byte[] findModuleOf(java.lang.String[] classNames)
                    throws java.lang.Exception
Find a module containg a class whose name is className

Parameters:
className - The name of the class to find.
Returns:
the byte[] data of the module with the highest version, or null if none could be found.
Throws:
java.lang.Exception

locate

public final ObjectPair<byte[],Version> locate(java.lang.String[] classNames)
                                        throws java.rmi.RemoteException
Remote method, should not be called by a client

Specified by:
locate in interface ModuleServerInterface
Returns:
An ObjectPair containing the byte[] data of the module and its Version, or null if it could not be found
Throws:
java.rmi.RemoteException

update

public final ObjectPair<byte[],Version> update(java.lang.String module,
                                               Version version)
                                        throws java.rmi.RemoteException
Remote method, should not be called by a client

Specified by:
update in interface ModuleServerInterface
Parameters:
module - The name of the module to find
version - The current version
Returns:
If a module newer than version was found, return a ObjectPair containing byte[] data of the module, and the Version of that module. If no such module was found, return null;
Throws:
java.rmi.RemoteException