jason.core
Class ServiceContainer

java.lang.Object
  |
  +--jason.core.ServiceContainer
All Implemented Interfaces:
ServiceContextListener

public class ServiceContainer
extends java.lang.Object
implements ServiceContextListener

Created Wed Mar 27 11:02:31 2002

This is a ServiceContainer. This class prepares a Service for running

See Also:
ServicesManager

Field Summary
static int INITIALIZED
           
static int NOSTATE
           
static int STARTED
           
static java.lang.String STATE_FILE_NAME
           
static int STOPPED
           
 
Constructor Summary
ServiceContainer(ServicesManager sm, java.lang.ClassLoader clLo, java.lang.String name, java.lang.String cl, boolean test)
          Manager a new service
ServiceContainer(ServicesManager sm, Service s, java.lang.String name, java.lang.String cl, boolean test)
           
 
Method Summary
 void addServiceContextListener(ServiceContextListener listener)
           
 boolean checkForUpdate()
          Check if the service must be reloaded
 java.lang.String getAuthor()
           
 java.lang.ClassLoader getClassLoader()
           
 java.io.File getFilePath()
           
 MessageHandler getMessageHandler()
           
 java.lang.String getName()
           
 java.lang.Object getPrivateObject()
           
 java.util.Enumeration getPropertiesName()
           
 java.lang.Object getProperty(java.lang.String name)
           
 Service getService()
           
 ServiceBuilder getServiceContainerBuilder()
           
 ServiceContext getServiceContext()
           
 ServicesManager getServicesManager()
           
 int getState()
           
 java.lang.String getStringProperty(java.lang.String name)
           
 java.lang.String getVersion()
           
 java.io.File getWorkingDirectory()
           
 ServiceContext initService()
          Reset the service context
 boolean isProcessable()
           
 boolean isStopped()
           
 boolean isTest()
           
 boolean isThreadable()
           
 boolean isVerbose()
           
 boolean isWorkingDirectoryTemporary()
           
 void notifyInit()
           
 void notifyStart()
           
 void notifyStop()
           
 void removeServiceContextListener(ServiceContextListener listener)
           
 void setAuthor(java.lang.String author)
           
 void setFilePath(java.io.File f)
          Set the file path for the service
 void setProcessable(boolean processable)
          Determine if the current process can be handled in a new process with a load balancing mecanism
 void setProperty(java.lang.String name, java.lang.Object value)
          Set a property for the service
 void setServiceContainerBuilder(ServiceBuilder builder)
          Builder for this service container
 void setThreadable(boolean threadable)
          Determine if the current service can be handled in a new thread each time with a thread pooling mecanism
 void setVersion(java.lang.String version)
           
 void setWorkingDirectory(java.io.File wd)
          Update the working directory
 void setWorkingDirectoryTemporary(boolean temporary)
          Make the working directory a temporary directory, so this is clean each time the service is runned
 void stop()
          Stop the service
 java.lang.String toString()
           
 void update()
          Update from file
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

NOSTATE

public static final int NOSTATE
See Also:
Constant Field Values

INITIALIZED

public static final int INITIALIZED
See Also:
Constant Field Values

STOPPED

public static final int STOPPED
See Also:
Constant Field Values

STARTED

public static final int STARTED
See Also:
Constant Field Values

STATE_FILE_NAME

public static final java.lang.String STATE_FILE_NAME
See Also:
Constant Field Values
Constructor Detail

ServiceContainer

public ServiceContainer(ServicesManager sm,
                        java.lang.ClassLoader clLo,
                        java.lang.String name,
                        java.lang.String cl,
                        boolean test)
                 throws JasonException
Manager a new service

Parameters:
sm - the original ServicesManager
clLo - the ClassLoader for the service
name - a service name
cl - a service class name, this class must implement the jason.core.Service interface
test - Decide to active or not the test state

ServiceContainer

public ServiceContainer(ServicesManager sm,
                        Service s,
                        java.lang.String name,
                        java.lang.String cl,
                        boolean test)
                 throws JasonException
Method Detail

setWorkingDirectory

public void setWorkingDirectory(java.io.File wd)
Update the working directory


getWorkingDirectory

public java.io.File getWorkingDirectory()
Returns:
the working directory

setWorkingDirectoryTemporary

public void setWorkingDirectoryTemporary(boolean temporary)
Make the working directory a temporary directory, so this is clean each time the service is runned


isWorkingDirectoryTemporary

public boolean isWorkingDirectoryTemporary()
Returns:
true if the working directory is temporary

setFilePath

public void setFilePath(java.io.File f)
Set the file path for the service


getFilePath

public java.io.File getFilePath()

setServiceContainerBuilder

public void setServiceContainerBuilder(ServiceBuilder builder)
Builder for this service container


getServiceContainerBuilder

public ServiceBuilder getServiceContainerBuilder()
Returns:
the Builder for this service container

checkForUpdate

public boolean checkForUpdate()
Check if the service must be reloaded


update

public void update()
Update from file


getMessageHandler

public MessageHandler getMessageHandler()

isVerbose

public boolean isVerbose()

isTest

public boolean isTest()

getName

public java.lang.String getName()
Returns:
the name of the service

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object

getServicesManager

public ServicesManager getServicesManager()

getPrivateObject

public java.lang.Object getPrivateObject()

stop

public void stop()
          throws JasonException
Stop the service

JasonException

getState

public int getState()
Returns:
the current service state : NOSTATE, INITIALIZED, STOPPED or STARTED

getClassLoader

public java.lang.ClassLoader getClassLoader()
Returns:
the classloader for the service

initService

public ServiceContext initService()
Reset the service context


addServiceContextListener

public void addServiceContextListener(ServiceContextListener listener)

removeServiceContextListener

public void removeServiceContextListener(ServiceContextListener listener)

notifyInit

public void notifyInit()
Specified by:
notifyInit in interface ServiceContextListener

notifyStart

public void notifyStart()
Specified by:
notifyStart in interface ServiceContextListener

notifyStop

public void notifyStop()
Specified by:
notifyStop in interface ServiceContextListener

isStopped

public boolean isStopped()
Returns:
is the sub service is stopped

getService

public Service getService()
Returns:
the current service

getServiceContext

public ServiceContext getServiceContext()
Returns:
the current service context

setProperty

public void setProperty(java.lang.String name,
                        java.lang.Object value)
Set a property for the service


getStringProperty

public java.lang.String getStringProperty(java.lang.String name)
Returns:
a property value for the service as String

getProperty

public java.lang.Object getProperty(java.lang.String name)

getPropertiesName

public java.util.Enumeration getPropertiesName()
Returns:
a enumeration of all properties name

setAuthor

public void setAuthor(java.lang.String author)

getAuthor

public java.lang.String getAuthor()

setVersion

public void setVersion(java.lang.String version)

getVersion

public java.lang.String getVersion()

setThreadable

public void setThreadable(boolean threadable)
Determine if the current service can be handled in a new thread each time with a thread pooling mecanism


isThreadable

public boolean isThreadable()

setProcessable

public void setProcessable(boolean processable)
Determine if the current process can be handled in a new process with a load balancing mecanism


isProcessable

public boolean isProcessable()