jason.core
Class ProcessableService

java.lang.Object
  |
  +--jason.core.AbstractService
        |
        +--jason.core.ThreadableService
              |
              +--jason.core.TaskableService
                    |
                    +--jason.core.SocketService
                          |
                          +--jason.core.ProcessableService
All Implemented Interfaces:
java.io.Serializable, Service, ServiceDataListener
Direct Known Subclasses:
HTTPService

public abstract class ProcessableService
extends SocketService

Created Sat Jun 1 20:57:22 2002

This service is able to work with several processes. This kind of service is only for Socket service type. When is manages a socket, it can send the socket request to another process rather than another thread. By default this service will detect a service conflict from multiple instance and merge this instances into one service.

See Also:
Serialized Form

Field Summary
 
Fields inherited from class jason.core.SocketService
port, serverSocket, traceRequest
 
Fields inherited from class jason.core.ThreadableService
activeThread
 
Fields inherited from class jason.core.AbstractService
INITIALIZED, name, NOSTATE, serviceContext, STARTED, STOPPED
 
Fields inherited from interface jason.core.Service
ERROR_MESSAGE, INFORMATION_MESSAGE, VERBOSE_MESSAGE, WARNING_MESSAGE
 
Constructor Summary
ProcessableService()
           
 
Method Summary
protected  void fireSocketAccept(java.net.Socket host)
          This method will dispatch any request between another processes
protected abstract  byte[] getHostRequestFromInputStream(java.io.InputStream in)
          This method returns an array of bytes with the full user request, this is needed for load balancing between several process.
protected abstract  Task getTaskForSocket(java.net.Socket host)
           
protected  void notifyBadPort()
          We contact another service from the current service port by including a first 1 caracter and we need to find a new port
protected  void setLoadBalancingMax(int max)
          Reset the max value for loadbalancing support.
 
Methods inherited from class jason.core.SocketService
beforeRun, fireConflictDetected, getSocketTimeout, notifyData, notifyInitReady, run, setBacklog, setSocketTimeout, setTraceRequest, start
 
Methods inherited from class jason.core.TaskableService
notifyTask
 
Methods inherited from class jason.core.ThreadableService
actionForStart, enableServiceForThread, getThreadLoopDelay, isThreadLoopMode, isThreadStarted, isWaiting, notifyThreadRunning, runThread, setPriority, setThreadLoopDelay, setThreadLoopMode, threadNotify, threadWait
 
Methods inherited from class jason.core.AbstractService
checkForContext, fireCriticalErrorDetected, getBooleanProperty, getInfo, getIntProperty, getName, getPropertiesName, getProperty, getServiceContext, getServiceState, getState, getStringProperty, getType, getVersion, hasServiceContext, init, isAutoStop, isEnabled, isInitialized, isOverride, isPersistent, isPrivate, isProcessable, isStarted, isStopped, isTest, isThreadable, isVerbose, manageRequest, manageRequestForType, notifyStartReady, notifyStopReady, postStop, restart, sendCustomMessage, sendErrorMessage, sendInformationMessage, sendInnerError, sendWarningMessage, setAutoStop, setEnabled, setName, setPersistent, setPrivate, setProperty, setServiceContext, setTest, setType, setVerbose, setVersion, stop
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ProcessableService

public ProcessableService()
Method Detail

setLoadBalancingMax

protected void setLoadBalancingMax(int max)
Reset the max value for loadbalancing support. By default, the service will accept until 50 processes load balancing


fireSocketAccept

protected void fireSocketAccept(java.net.Socket host)
This method will dispatch any request between another processes

Overrides:
fireSocketAccept in class SocketService

getHostRequestFromInputStream

protected abstract byte[] getHostRequestFromInputStream(java.io.InputStream in)
                                                 throws java.io.IOException
This method returns an array of bytes with the full user request, this is needed for load balancing between several process. By default this method tries to read until two '\n' or the end of the stream. If your protocol doesn't limit the scope of the request with the same method, please override this method.

Parameters:
in - InputStream from the user request
Returns:
the request if a byte array
java.io.IOException

notifyBadPort

protected void notifyBadPort()
We contact another service from the current service port by including a first 1 caracter and we need to find a new port

Overrides:
notifyBadPort in class SocketService

getTaskForSocket

protected abstract Task getTaskForSocket(java.net.Socket host)
                                  throws ServiceException
Specified by:
getTaskForSocket in class SocketService
Returns:
a task for a user socker
ServiceException