things.thinger.service.actor
Class ActorServiceBase

java.lang.Object
  extended by things.thinger.service.actor.ActorServiceBase

public abstract class ActorServiceBase
extends java.lang.Object

The actor service base.

Version:
1.0

Version History

EPG - Initial - 12 MAY 07
 
Author:
Erich P. Gatejen

Field Summary
 ActorMessage currentMessage
          Current message.
protected  Logger logger
          Usable local logger.
protected  SystemInterface si
          The System Interface
 
Constructor Summary
ActorServiceBase()
           
 
Method Summary
 void ADDPARAMETER(java.lang.String name, java.lang.String value)
          Add a parameter to the response.
 void FAIL(java.lang.String message)
          Respond that the message was FAILED.
 void FAULT(java.lang.String message)
          General a fault.
 void FAULT(java.lang.String message, java.lang.Throwable t)
          General a fault.
 java.lang.String getOptionalParameter(java.lang.String parameterName)
           
 java.lang.String getRequiredParameter(java.lang.String parameterName)
          Get required parameter from message.
protected  void init_service(SystemInterface si, ActorServiceContextInterface context)
          Init the Service.
abstract  void init()
          Init the Service.
 void OK()
          Respond that the message was OK.
 void OK(java.lang.String message)
          Respond that the message was OK with a message.
protected  boolean process_message(ActorMessage message)
          Process a message.
abstract  void process_unnumbered()
          Process an unnumbered message.
abstract  void process()
          Process a message.
 void PUNT(java.lang.String message)
          Respond that the message was FAILED.
abstract  void quit()
          Quit the Service.
 void sendLog(java.lang.String logEntry)
          Send the sendLog entry.
 boolean typeIs(java.lang.String type)
          Is the current message this type?
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

logger

protected Logger logger
Usable local logger.


si

protected SystemInterface si
The System Interface


currentMessage

public ActorMessage currentMessage
Current message. A subclass can assume this is valid in their implementation of the process() method.

Constructor Detail

ActorServiceBase

public ActorServiceBase()
Method Detail

init_service

protected void init_service(SystemInterface si,
                            ActorServiceContextInterface context)
                     throws java.lang.Throwable
Init the Service. This will be called by the service Thread.

Parameters:
si - a system interface.
context - the context.
Throws:
java.lang.Throwable

process_message

protected boolean process_message(ActorMessage message)
                           throws java.lang.Throwable
Process a message. This will be called by the service Thread.

Parameters:
message - the message
Returns:
true if the process indicates a quit condition.
Throws:
java.lang.Throwable

init

public abstract void init()
                   throws java.lang.Throwable
Init the Service.

Throws:
java.lang.Throwable

quit

public abstract void quit()
                   throws java.lang.Throwable
Quit the Service.

Throws:
java.lang.Throwable

process

public abstract void process()
                      throws java.lang.Throwable
Process a message. The message is available in currentMessage.

Throws:
java.lang.Throwable

process_unnumbered

public abstract void process_unnumbered()
                                 throws java.lang.Throwable
Process an unnumbered message. No critical processing should occur with these messages,

Throws:
java.lang.Throwable

getRequiredParameter

public java.lang.String getRequiredParameter(java.lang.String parameterName)
                                      throws java.lang.Throwable
Get required parameter from message. Throws an ActorPuntException if it isn't there and sets the disposition to failed.

Parameters:
parameterName - The name of the parameter.
Throws:
java.lang.Exception
java.lang.Throwable
See Also:
Throwable

getOptionalParameter

public java.lang.String getOptionalParameter(java.lang.String parameterName)

sendLog

public void sendLog(java.lang.String logEntry)
             throws java.lang.Throwable
Send the sendLog entry.

Parameters:
logEntry - The log entry to send.
Throws:
java.lang.Throwable

OK

public void OK()
        throws java.lang.Throwable
Respond that the message was OK. It'll set the disposition to ok.

Throws:
java.lang.Throwable

ADDPARAMETER

public void ADDPARAMETER(java.lang.String name,
                         java.lang.String value)
                  throws java.lang.Throwable
Add a parameter to the response.

Parameters:
name - The name of the parameter.
value - The value of the parameter.
Throws:
java.lang.Throwable

OK

public void OK(java.lang.String message)
        throws java.lang.Throwable
Respond that the message was OK with a message. It'll set the disposition as ok, with the PARAMETER_RESPONSE being the message passed.

Parameters:
message - text message
Throws:
java.lang.Throwable

FAIL

public void FAIL(java.lang.String message)
          throws java.lang.Throwable
Respond that the message was FAILED. It'll set the disposition appropriately, with the PARAMETER_RESPONSE being the message passed. This will not throw an exception.

Parameters:
message - The response message.
Throws:
java.lang.Throwable

PUNT

public void PUNT(java.lang.String message)
          throws java.lang.Throwable
Respond that the message was FAILED. It'll set the disposition appropriately, with the PARAMETER_RESPONSE being the message passed. This will then throw an PuntException.

Parameters:
message - The response message.
Throws:
java.lang.Throwable

FAULT

public void FAULT(java.lang.String message)
           throws java.lang.Throwable
General a fault. This will certainly teardown the service. An attempt may be made to send a QUIT to the client. This will then throw an ActorFaultException.

Parameters:
message - The error message.
Throws:
java.lang.Throwable - It will always be a fault.

FAULT

public void FAULT(java.lang.String message,
                  java.lang.Throwable t)
           throws java.lang.Throwable
General a fault. This will certainly teardown the service. An attempt may be made to send a QUIT to the client. This will then throw an ActorFaultException.

Parameters:
message - The error message.
t - An exception for the chain.
Throws:
java.lang.Throwable - It will always be a fault.

typeIs

public boolean typeIs(java.lang.String type)
Is the current message this type?

Parameters:
type - The type.
Returns:
true if it is, otherwise false.


Things.