com.kedwards.swt
Class UnicastServiceBackend

java.lang.Object
  |
  +--java.rmi.server.RemoteObject
        |
        +--java.rmi.server.RemoteServer
              |
              +--java.rmi.server.UnicastRemoteObject
                    |
                    +--com.kedwards.swt.UnicastServiceBackend
All Implemented Interfaces:
Checkpointed, java.rmi.Remote, RemoteAdmin, java.io.Serializable, ServiceBackend

public abstract class UnicastServiceBackend
extends java.rmi.server.UnicastRemoteObject
implements ServiceBackend, RemoteAdmin, Checkpointed

UnicastServiceBackend.java

This is the most common implementation of ServiceBackend--one that uses the simple RMI UnicastRemoteObject class to handle remoteness and communication with its proxy.

See http://www.kedwards.com/jini

No warranty expressed or implied; use at your own risk; for educational purposes only.

Author:
Keith Edwards
See Also:
Serialized Form

Fields inherited from class java.rmi.server.RemoteObject
ref
 
Constructor Summary
UnicastServiceBackend()
           
 
Method Summary
 java.lang.Object getAdmin()
          Returns an administrative object for the service.
 void getCheckpointData(TaggedPersistentData data)
          Subclasses should override this to add any data they need to be checkpointed to the data object.
 net.jini.core.entry.Entry[] getInitialAttributes()
          Return the set of entries that will initially be associated with this service.
 java.lang.String[] getInitialGroups()
          Return the set of groups that this service should initially discover.
 net.jini.core.discovery.LookupLocator[] getInitialLocators()
          Return the set of locators that this service should initially discover.
abstract  java.lang.Object getProxy()
          Subclasses should override this method to return the proxy for their service.
 net.jini.core.lookup.ServiceID getServiceID()
          Returns the service ID, once it is known.
 java.lang.String getServiceName()
          Unless overridden by a subclass, this returns the de-packaged name of the class.
 ServiceWrapper getServiceWrapper()
          Gets the current service wrapper.
abstract  void initialize()
          Called the first time the service is ever run.
abstract  void postInitialize()
          Called as soon as a ServiceID is available
abstract  void preInitialize()
          Called as soon as the wrapper is set.
 void setCheckpointData(TaggedPersistentData data)
          Subclasses should override this to retrieve any data that they need to set their state, after a restoration.
 void setServiceID(net.jini.core.lookup.ServiceID serviceID)
          Final because subclasses should do their initialization in postInitialize
 void setServiceWrapper(ServiceWrapper wrapper)
          Final because subclasses should do their initialization in preInitialize
abstract  void shutdown()
          Called when the service must be terminated
 
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, toStub
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

UnicastServiceBackend

public UnicastServiceBackend()
                      throws java.rmi.RemoteException
Method Detail

setServiceWrapper

public final void setServiceWrapper(ServiceWrapper wrapper)
Final because subclasses should do their initialization in preInitialize
Specified by:
setServiceWrapper in interface ServiceBackend

getCheckpointData

public void getCheckpointData(TaggedPersistentData data)
                       throws java.io.IOException
Subclasses should override this to add any data they need to be checkpointed to the data object.
Specified by:
getCheckpointData in interface Checkpointed
Parameters:
data - The persistent data to which the service should write any data it wishes to be checkpointed.

setCheckpointData

public void setCheckpointData(TaggedPersistentData data)
                       throws java.io.IOException,
                              java.lang.ClassNotFoundException
Subclasses should override this to retrieve any data that they need to set their state, after a restoration.
Specified by:
setCheckpointData in interface Checkpointed
Parameters:
data - The persistent data from which the service should recover its state.

getServiceName

public java.lang.String getServiceName()
Unless overridden by a subclass, this returns the de-packaged name of the class.
Specified by:
getServiceName in interface ServiceBackend
Following copied from interface: com.kedwards.swt.ServiceBackend
Returns:
The name of the service.

getServiceWrapper

public ServiceWrapper getServiceWrapper()
Description copied from interface: ServiceBackend
Gets the current service wrapper.
Specified by:
getServiceWrapper in interface ServiceBackend

getAdmin

public java.lang.Object getAdmin()
                          throws java.rmi.RemoteException
Returns an administrative object for the service. Default implementation returns a basic admin stub
Specified by:
getAdmin in interface ServiceBackend
Following copied from interface: com.kedwards.swt.ServiceBackend
Returns:
An admin object for the service.

getProxy

public abstract java.lang.Object getProxy()
                                   throws java.rmi.RemoteException
Subclasses should override this method to return the proxy for their service.
Specified by:
getProxy in interface ServiceBackend
Following copied from interface: com.kedwards.swt.ServiceBackend
Returns:
The service's proxy.

preInitialize

public abstract void preInitialize()
                            throws java.lang.Exception
Called as soon as the wrapper is set.
Specified by:
preInitialize in interface ServiceBackend

initialize

public abstract void initialize()
                         throws java.lang.Exception
Called the first time the service is ever run.
Specified by:
initialize in interface ServiceBackend

postInitialize

public abstract void postInitialize()
                             throws java.lang.Exception
Called as soon as a ServiceID is available
Specified by:
postInitialize in interface ServiceBackend

shutdown

public abstract void shutdown()
Called when the service must be terminated
Specified by:
shutdown in interface ServiceBackend

getInitialLocators

public net.jini.core.discovery.LookupLocator[] getInitialLocators()
Return the set of locators that this service should initially discover. By default this returns an empty list. Subclasses can override to specify different locators.
Specified by:
getInitialLocators in interface ServiceBackend

getInitialGroups

public java.lang.String[] getInitialGroups()
Return the set of groups that this service should initially discover. By default this returns the public group. Subclasses can override to specify different groups.
Specified by:
getInitialGroups in interface ServiceBackend

getInitialAttributes

public net.jini.core.entry.Entry[] getInitialAttributes()
Return the set of entries that will initially be associated with this service. By default this returns an empty list. Subclasses can override to specify different groups.
Specified by:
getInitialAttributes in interface ServiceBackend

setServiceID

public final void setServiceID(net.jini.core.lookup.ServiceID serviceID)
Final because subclasses should do their initialization in postInitialize
Specified by:
setServiceID in interface ServiceBackend

getServiceID

public net.jini.core.lookup.ServiceID getServiceID()
                                            throws NoServiceIDException
Returns the service ID, once it is known.