com.sas.services.deployment.servicewrapper
Class AbstractServiceWrapper

java.lang.Object
  |
  +--com.sas.services.deployment.servicewrapper.AbstractServiceWrapper
All Implemented Interfaces:
ServiceWrapperInterface,
Direct Known Subclasses:
ServiceWrapperImpl

public abstract class AbstractServiceWrapper
extends Object
implements ServiceWrapperInterface, org.tanukisoftware.wrapper.WrapperListener

Provides integration with the Java Service Wrapper provided by Tanuki Software by registering its WrapperListener implementation with the WrapperManager.

Our class is controlled by the native Wrapper by registering it with the Tanuki Software WrapperManager. The WrapperManager is the middle-man between us and the native Wrapper.

All service wrapper implementations should extend this class and fully implement the ServiceWrapperInterface. In this way the implementation does not have to be concerned with the semantics of the native wrapper. An example follows:


 import com.sas.services.InitializationException;
 import com.sas.services.ServiceException;
 
 ...

 public class xxxxImpl extends AbstractServiceWrapper {

     private xxxxImpl(String[] args) {
         super(args);
     }

     public static void main(String[] args) {
         new xxxxImpl(args);
     }

     public void init(String[] args) throws
        InitializationException, ServiceException {
         ....
     }
 
     public void destroy() throws
        ServiceException, RemoteException {
         ....
     }
 
 }
             
 

Since:
1.1.3

Field Summary
static int LOG_LEVEL_DEBUG
           
static int LOG_LEVEL_ERROR
           
static int LOG_LEVEL_FATAL
           
static int LOG_LEVEL_INFO
           
static int LOG_LEVEL_STATUS
           
static int LOG_LEVEL_WARN
           
 
Constructor Summary
protected AbstractServiceWrapper(String[] args)
          AbstractServiceWrapper constructor.
 
Method Summary
 void controlEvent(int event)
          The native wrapper will trap the following system control signals: WrapperManager.WRAPPER_CTRL_C_EVENT, WrapperManager.WRAPPER_CTRL_CLOSE_EVENT, WrapperManager.WRAPPER_CTRL_LOGOFF_EVENT, WrapperManager.WRAPPER_CTRL_SHUTDOWN_EVENT.
abstract  void destroy()
          Destroy a Foundation Services deployment.
abstract  void init(String[] args)
          Initialize a Foundation Services deployment.
protected  void log(int level, String s)
          Log a message to the service wrapper log.
 Integer start(String[] args)
          The start method is called when the WrapperManager is signaled by the native wrapper code that it can start its application.
 int stop(int exitCode)
          Called when the application is shutting down.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

LOG_LEVEL_DEBUG

public static final int LOG_LEVEL_DEBUG

LOG_LEVEL_ERROR

public static final int LOG_LEVEL_ERROR

LOG_LEVEL_FATAL

public static final int LOG_LEVEL_FATAL

LOG_LEVEL_INFO

public static final int LOG_LEVEL_INFO

LOG_LEVEL_STATUS

public static final int LOG_LEVEL_STATUS

LOG_LEVEL_WARN

public static final int LOG_LEVEL_WARN
Constructor Detail

AbstractServiceWrapper

protected AbstractServiceWrapper(String[] args)
AbstractServiceWrapper constructor.
Parameters:
args - Main program arguments.
Method Detail

init

public abstract void init(String[] args)
                   throws InitializationException,
                          ServiceException
Initialize a Foundation Services deployment.
Specified by:
init in interface ServiceWrapperInterface
Parameters:
args - Main program arguments.
Throws:
InitializationException - if problems initializing foundation services.
ServiceException - if problems deploying foundation services.

destroy

public abstract void destroy()
                      throws ServiceException,
                             RemoteException
Destroy a Foundation Services deployment.
Specified by:
destroy in interface ServiceWrapperInterface
Throws:
ServiceException - if problems destroying foundation services.
RemoteException - if a network failure occurs.

log

protected void log(int level,
                   String s)
Log a message to the service wrapper log.
Parameters:
level - logging priority level.
s - message to log.

start

public Integer start(String[] args)
The start method is called when the WrapperManager is signaled by the native wrapper code that it can start its application. This method call is expected to return, so a new thread should be launched if necessary.
Specified by:
start in interface org.tanukisoftware.wrapper.WrapperListener
Parameters:
args - List of arguments used to initialize the application.
Returns:
Any error code if the application should exit on completion of the start method. If there were no problems then this method should return null.

stop

public int stop(int exitCode)
Called when the application is shutting down. The Wrapper assumes that this method will return fairly quickly. If the shutdown code could potentially take a long time, then WrapperManager.stopping() should be called to extend the timeout period. If for some reason, the stop method can not return, then it must call WrapperManager.stopped() to avoid warning messages from the Wrapper.
Specified by:
stop in interface org.tanukisoftware.wrapper.WrapperListener
Parameters:
exitCode - The suggested exit code that will be returned to the OS when the JVM exits.
Returns:
The exit code to actually return to the OS. In most cases, this should just be the value of exitCode, however the user code has the option of changing the exit code if there are any problems during shutdown.

controlEvent

public void controlEvent(int event)
The native wrapper will trap the following system control signals: WrapperManager.WRAPPER_CTRL_C_EVENT, WrapperManager.WRAPPER_CTRL_CLOSE_EVENT, WrapperManager.WRAPPER_CTRL_LOGOFF_EVENT, WrapperManager.WRAPPER_CTRL_SHUTDOWN_EVENT. Since the native wrapper will call WrapperManager.stop(), we do not need to perform any action here.
Specified by:
controlEvent in interface org.tanukisoftware.wrapper.WrapperListener
Parameters:
event - The system control signal.




Copyright © 2006 SAS Institute Inc. All Rights Reserved.
javadoc generated Fri, 10 Feb 2006 17:28:53