com.codemonster.surinam.export.lifecycle
Class ServiceAdapter

java.lang.Object
  extended by com.codemonster.surinam.export.lifecycle.ServiceAdapter
All Implemented Interfaces:
ServiceClient, LifecycleAware, ManagedService
Direct Known Subclasses:
PlaceholderProviderImplementation, SimpleServiceWrapper

public class ServiceAdapter
extends Object
implements LifecycleAware, ManagedService, ServiceClient

User: Samuel Provencher Date: Jun 6, 2006 Time: 8:24:01 PM

This Adapter class is here simply to provide a convenient implementation for those who might only want to implement a subset of the lifecycle methods and safely ignore the others (the default implementations are used).

Additionally, this adapter will provide some housekeeping code for managing the impl's availability state.


Field Summary
 ServiceFinder serviceFinder
          Injection makes it easy for services to find other services.
 
Constructor Summary
ServiceAdapter()
           
 
Method Summary
 void destroy()
          Dummy implementation for subclasses that don't need the method.
 ServiceAvailability getServiceAvailability()
          This is a standard accessor to acquire a service implementation's availability status.
 ManagedService getServiceObject()
          Since this implementation does not live as a pooled instance, we simply return a reference to itself.
 String getVersion()
          A managed implementation will have a version associated with it.
 VersionedProviderImplementationName getVersionedProviderImplementationName()
          We want to make it easy to get the versioned key if you already have the impl object.
 void initialize()
          Dummy implementation for subclasses that don't need the method.
 boolean isServiceEnabled()
          This asks the specific boolean question (because we will ask it a lot), whether or not the impl is 'Service Enabled' which means it is ready to handle requests.
 void releaseServiceObject(ManagedService service)
          This is a lifecycle management method that provides an implementation the opportunity to perform some action when invocation pooling is being used.
 void setServiceAvailability(ServiceAvailability availability)
          This is a request for the organization implementation to set its availability to the given state.
 void setServiceFinder(ServiceFinder serviceFinder)
           
 String toString()
          Just a quick implementation for subclasses to override.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

serviceFinder

public ServiceFinder serviceFinder
Injection makes it easy for services to find other services.

Constructor Detail

ServiceAdapter

public ServiceAdapter()
Method Detail

getVersionedProviderImplementationName

public VersionedProviderImplementationName getVersionedProviderImplementationName()
We want to make it easy to get the versioned key if you already have the impl object. This will also remove the need for a lot of duplication in the calling code.

Specified by:
getVersionedProviderImplementationName in interface ManagedService
Returns:
Returns an object that represents a provider implementation name.

getVersion

public String getVersion()
Description copied from interface: ManagedService
A managed implementation will have a version associated with it. The implementation class can use any mechanism they see fit but we want to be able to acquire the implementation's version identifier at runtime. This, along with the fully-qualified class name should serve to indentify this implementation class. Implementation versions are strings because there is no suggestion that must be a number.

Specified by:
getVersion in interface ManagedService
Returns:
Returns the version number of the implementation class.

releaseServiceObject

public void releaseServiceObject(ManagedService service)
This is a lifecycle management method that provides an implementation the opportunity to perform some action when invocation pooling is being used.

Parameters:
service - This object is the service implementation object that needs to be put back into the pool.

getServiceObject

public ManagedService getServiceObject()
Since this implementation does not live as a pooled instance, we simply return a reference to itself. This should allow this ManagedObject to be swapped out with a ManagedObjectPool without anyone being the wiser.

Returns:
Returns a reference to a service object, which is itself by default for non-pooled implementations.

getServiceAvailability

public ServiceAvailability getServiceAvailability()
This is a standard accessor to acquire a service implementation's availability status.

Specified by:
getServiceAvailability in interface ManagedService
Returns:
Returns the actual ServiceAvailability state.

setServiceAvailability

public void setServiceAvailability(ServiceAvailability availability)
This is a request for the organization implementation to set its availability to the given state. Administrative commands are only requests to the service to change its state, there is no guarantee that this will happen.

Specified by:
setServiceAvailability in interface ManagedService
Parameters:
availability - Set the availability of this service implementation.

isServiceEnabled

public boolean isServiceEnabled()
This asks the specific boolean question (because we will ask it a lot), whether or not the impl is 'Service Enabled' which means it is ready to handle requests.

Specified by:
isServiceEnabled in interface ManagedService
Returns:
Returns the boolean answer to the question, availabilityState == ServiceAvailability.AVAILABLE.

toString

public String toString()
Just a quick implementation for subclasses to override.

Specified by:
toString in interface ManagedService
Overrides:
toString in class Object
Returns:
Returns a string representation of the object.

initialize

public void initialize()
Dummy implementation for subclasses that don't need the method. However, if you do need it, you should override this method to handle the callback.

Specified by:
initialize in interface LifecycleAware

destroy

public void destroy()
Dummy implementation for subclasses that don't need the method. However, if you do need it, you should override this method to handle the callback.

Specified by:
destroy in interface LifecycleAware

setServiceFinder

public void setServiceFinder(ServiceFinder serviceFinder)
Specified by:
setServiceFinder in interface ServiceClient


Copyright © 2010. All Rights Reserved.