jason.core
Interface Service

All Known Subinterfaces:
Log
All Known Implementing Classes:
AbstractService, EmptyLog, LogImpl

public interface Service

Interface that describes a service plugged into the jason server.

1) A Service is initialized (init)

2) A Service is started

3) A Service is stopped

Look at the ServiceLoader and ServicesManager to see how a service is used.

For sendind an message please, use the ServiceContect

Since:
1.0
Author:
Alexandre Brillant
See Also:
AbstractService, ServiceContext, Runlevel, MessageHandler, ServiceVersion

Field Summary
static int ERROR_MESSAGE
           
static int INFORMATION_MESSAGE
           
static int VERBOSE_MESSAGE
           
static int WARNING_MESSAGE
           
 
Method Summary
 boolean getBooleanProperty(java.lang.String name)
           
 ServiceInfo getInfo()
           
 int getIntProperty(java.lang.String name)
           
 java.lang.String getName()
          This name should distinguish your service from another one.
 java.lang.Object getProperty(java.lang.String name)
           
 ServiceState getServiceState()
           
 java.lang.String getStringProperty(java.lang.String name)
           
 ServiceType getType()
          This is an important function for cooperation, it says what it the role of a service such as a Web service.
 ServiceVersion getVersion()
           
 void init(ServiceContext sc)
          initialize the service, reading properties from the ServiceContext
 boolean isEnabled()
          This method provides an indication for the JASon container for starting or not this service.
 boolean isOverride()
          Note that this value can avoid your service to be taken into account.
 boolean isPrivate()
          The AbstractService code will set this value to false by default
 boolean isVerbose()
           
 ServiceResponse manageRequest(ServiceRequest request)
          This method is useful for delegating a work to another service
 void restart()
          restart the service
 void start()
          start the service
 void stop()
          stop the service
 

Field Detail

INFORMATION_MESSAGE

public static final int INFORMATION_MESSAGE
See Also:
Constant Field Values

WARNING_MESSAGE

public static final int WARNING_MESSAGE
See Also:
Constant Field Values

ERROR_MESSAGE

public static final int ERROR_MESSAGE
See Also:
Constant Field Values

VERBOSE_MESSAGE

public static final int VERBOSE_MESSAGE
See Also:
Constant Field Values
Method Detail

getName

public java.lang.String getName()
This name should distinguish your service from another one. This is better for multiple service for the same service type to not introduce generic name like HTTP service or MAIL service here.

Returns:
the service name

getVersion

public ServiceVersion getVersion()
Returns:
the version of the service

getInfo

public ServiceInfo getInfo()
Returns:
information about the service (author,creation date...)

isVerbose

public boolean isVerbose()
Returns:
true if the service should write running information

isOverride

public boolean isOverride()
Note that this value can avoid your service to be taken into account. This is a rescue solution when you want to propose a service type, but you don't want your service to start if this service type is already managed. The strategy for using or not your service is based on the order, the last one is always the last supported one. It means that as sample you can replace the log service, or the scheduler service by your own service

Returns:
true if the service can be replaced by another service with the same type

init

public void init(ServiceContext sc)
initialize the service, reading properties from the ServiceContext


start

public void start()
start the service


stop

public void stop()
stop the service


restart

public void restart()
restart the service


getProperty

public java.lang.Object getProperty(java.lang.String name)
Returns:
a Service property

getStringProperty

public java.lang.String getStringProperty(java.lang.String name)
Returns:
a Service property as a string

getIntProperty

public int getIntProperty(java.lang.String name)
Returns:
a Service property as an integer

getBooleanProperty

public boolean getBooleanProperty(java.lang.String name)
Returns:
a Service property as a boolean

isPrivate

public boolean isPrivate()
The AbstractService code will set this value to false by default

Returns:
true if you don't want this service cooperate with other service

getType

public ServiceType getType()
This is an important function for cooperation, it says what it the role of a service such as a Web service. Defining a service type will help the JASon container to tied services


isEnabled

public boolean isEnabled()
This method provides an indication for the JASon container for starting or not this service. Normally this method should return true


manageRequest

public ServiceResponse manageRequest(ServiceRequest request)
                              throws ServiceException
This method is useful for delegating a work to another service

Parameters:
request - A request for the service
Returns:
a response about the resut
Throws:
ServiceException - when the request is not managed

getServiceState

public ServiceState getServiceState()
Returns:
the current service state