org.licas.module.s_module

## Class SM_Auto

- java.lang.Object
- - java.lang.Thread
  - - org.licas.module.LicasModule
    - - org.licas.module.FrameworkModule
      - - org.licas.module.s_module.SM_Service
        - - org.licas.module.s_module.SM_Data
          - - org.licas.module.s_module.SM_Auto

- All Implemented Interfaces:
    java.lang.Runnable, ServiceDef
  Direct Known Subclasses:
    SM_Script, SM_Server

      public class SM_Auto
      extends SM_Data

  This class provides functionality for a service to run an autonomic behaviour loop. The methods are in a separate `CM_Auto` class.
  Author:
    Kieran Greer

- - ### Nested Class Summary

    - ### Nested classes/interfaces inherited from class java.lang.Thread

      `java.lang.Thread.State, java.lang.Thread.UncaughtExceptionHandler`

  - ### Field Summary

    - ### Fields inherited from class org.licas.module.s_module.SM_Data

      `dataQueue`

    - ### Fields inherited from class org.licas.module.s_module.SM_Service

      `cm, commID`

    - ### Fields inherited from class org.licas.module.FrameworkModule

      `passwordHandler, service, serviceType`

    - ### Fields inherited from class org.licas.module.LicasModule

      `jarFile, syncOn, uuid`

    - ### Fields inherited from class java.lang.Thread

      `MAX_PRIORITY, MIN_PRIORITY, NORM_PRIORITY`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `SM_Auto(Service service, PasswordHandler pHandler)` Creates a new instance of SM_Auto.

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `void` | `evaluateBehaviour()` Main method to execute the behaviour and evaluate the result, where the input message used is the first message on the autonomic manager's message queue.
    `MessageInfo` | `evaluateBehaviour(MessageInfo inputMessage)` Evaluate a behaviour message by calling `behaviourAction` and return the reply.
    `AutoEngine` | `getAutoEngine()` Get the auto engine.
    `java.lang.Object` | `invokeBehaviour(MessageInfo messageInfo)` This can be used to execute a single invocation of the service's `evaluateBehaviour` method.
    `void` | `setAutonomicManager(AutonomicManager autoMan)` Set the autonomic manager, which is usually set later.

    - ### Methods inherited from class org.licas.module.s_module.SM_Data

      `dataFromService, dataToService, getAllData, getDataQueue, getDataRandomID, getServiceIDs, resetValues, setAllData`

    - ### Methods inherited from class org.licas.module.s_module.SM_Service

      `getCommID, getServerPassword, setCommID, setControlModule, setDataModule`

    - ### Methods inherited from class org.licas.module.FrameworkModule

      `canAccess, canAccessTemp, getPasswordHandler, getPasswordHandler, getServicePassword, getServiceType, isAdminKey, setServiceDetails, setServiceType`

    - ### Methods inherited from class org.licas.module.LicasModule

      `getJarFile, getUUID, loadObject, setJarFile, setUUID, threadAliveState`

    - ### Methods inherited from class java.lang.Thread

      `activeCount, checkAccess, clone, countStackFrames, currentThread, destroy, dumpStack, enumerate, getAllStackTraces, getContextClassLoader, getDefaultUncaughtExceptionHandler, getId, getName, getPriority, getStackTrace, getState, getThreadGroup, getUncaughtExceptionHandler, holdsLock, interrupt, interrupted, isAlive, isDaemon, isInterrupted, join, join, join, resume, run, setContextClassLoader, setDaemon, setDefaultUncaughtExceptionHandler, setName, setPriority, setUncaughtExceptionHandler, sleep, sleep, start, stop, stop, suspend, toString, yield`

    - ### Methods inherited from class java.lang.Object

      `equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait`

    - ### Methods inherited from interface org.licas.def.ServiceDef

      `getUUID, setJarFile, setUUID`

- - ### Constructor Detail

    - #### SM_Auto

          public SM_Auto(Service service,
                         PasswordHandler pHandler)
                  throws java.lang.Exception

      Creates a new instance of SM_Auto.
      Parameters:
        `service` - the parent service.
        `pHandler` - the parent password handler.
      Throws:
        `java.lang.Exception` - any error.

  - ### Method Detail

    - #### setAutonomicManager

          public void setAutonomicManager(AutonomicManager autoMan)
                                   throws java.lang.Exception

      Set the autonomic manager, which is usually set later.
      Parameters:
        `autoMan` - the autonomic manager.
      Throws:
        `java.lang.Exception` - any error.

    - #### evaluateBehaviour

          public void evaluateBehaviour()
                                 throws ServiceException,
                                        java.lang.Exception

      Main method to execute the behaviour and evaluate the result, where the input message used is the first message on the autonomic manager's message queue. If the autonomic manager is missing for some reason, the second evaluateBehaviour method is called with a `null` parameter. This default version will probably work for general cases. It is based on retrieving the next message on the message queue, performing an action on that, and then monitoring the result by sending the reply through the `AutonomicManager` control loop. The control loop is empty by default, but all of these classes have been added to integrate the process with the normal running of the system. Any derived class can override this method or related parts, to change the behaviour and evaluation control loop.
      Throws:
        `ServiceException` - probably for password or service not found.
        `java.lang.Exception` - any error.

    - #### invokeBehaviour

          public java.lang.Object invokeBehaviour(MessageInfo messageInfo)
                                           throws ServiceException,
                                                  java.lang.Exception

      This can be used to execute a single invocation of the service's `evaluateBehaviour` method. This is correct if the service is waiting to be invoked and is not running on a thread. This version runs each invocation in a separate thread and also passes the message reply through the autonomic manager.
      Parameters:
        `messageInfo` - the message with data to evaluate. This is only the values related to the evaluation result, not the whole set of service values.
      Returns:
        the evaluation reply. This is the `evaluateBehaviour` `MessageInfo` reply object. If this is not one of the basic types, a parser needs to be added to parse the complex object to/from XML.
      Throws:
        `ServiceException` - if this service's main thread is currently running.
        `java.lang.Exception` - any other error.

    - #### evaluateBehaviour

          public MessageInfo evaluateBehaviour(MessageInfo inputMessage)
                                        throws ServiceException,
                                               java.lang.Exception

      Evaluate a behaviour message by calling `behaviourAction` and return the reply.
      Parameters:
        `inputMessage` - the data message to evaluate. This can be `null`, depending on your requirements, where the message queue is not accessed here.
      Returns:
        the evaluation reply.
      Throws:
        `ServiceException` - probably for password or service not found.
        `java.lang.Exception` - and error.

    - #### getAutoEngine

          public AutoEngine getAutoEngine()

      Get the auto engine.
      Returns:
        the value of autoEngine.