org.licas.module

## Class ServiceModule

- java.lang.Object
- - java.lang.Thread
  - - org.licas.module.LicasModule
    - - org.licas.module.FrameworkModule
      - - org.licas.module.ServiceModule

- All Implemented Interfaces:
    java.lang.Runnable, ServiceDef
  Direct Known Subclasses:
    HeuristicModule, HttpListener, Link, Service, ServiceWrapper

      public class ServiceModule
      extends FrameworkModule

  Base class for utility modules, similar to utility services, that can be added as child services to another `Service`. This class extends the `FrameworkModule` with some additional methods to help with thread execution in a full service extending this module. The threading can be ignored, or it can be useful for the behaviours.
  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
    Modifier and Type | Field and Description
    --- | ---
    `protected boolean` | `shutDown` True if shutdown the service thread

    - ### 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
    `ServiceModule()` Creates a new instance of ServiceModule.
    `ServiceModule(java.lang.String password, java.lang.String adminKey)` Creates a new instance of ServiceModule.

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `boolean` | `getShutDown()` Return the value indicating if this running thread should be shut down.
    `boolean` | `interrupt(java.lang.String adminKey)` You must call this method to interrupt the thread.
    `protected void` | `setShutDown(boolean thisShutDown)` Set the shut down variable to value passed in.
    `void` | `setShutDown(boolean thisShutDown, java.lang.String adminKey)` Set the shut down variable to value passed in.

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

      `canAccess, canAccessTemp, getPasswordHandler, getPasswordHandler, getServerPassword, 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`

- - ### Field Detail

    - #### shutDown

          protected boolean shutDown

      True if shutdown the service thread

  - ### Constructor Detail

    - #### ServiceModule

          public ServiceModule()
                        throws java.lang.Exception

      Creates a new instance of ServiceModule.
      Throws:
        `java.lang.Exception` - any error.

    - #### ServiceModule

          public ServiceModule(java.lang.String password,
                               java.lang.String adminKey)
                        throws java.lang.Exception

      Creates a new instance of ServiceModule.
      Parameters:
        `password` - password to initialise the password handler with.
        `adminKey` - admin key to initialise the password handler with.
      Throws:
        `java.lang.Exception` - any error.

  - ### Method Detail

    - #### interrupt

          public boolean interrupt(java.lang.String adminKey)

      You must call this method to interrupt the thread. This also interrupts all nested services.
      Parameters:
        `adminKey` - the key to identify unique loading of the service.
      Returns:
        true if the service is stopped.

    - #### setShutDown

          protected void setShutDown(boolean thisShutDown)

      Set the shut down variable to value passed in.
      Parameters:
        `thisShutDown` - true if shut down, false if keep running.

    - #### setShutDown

          public void setShutDown(boolean thisShutDown,
                                  java.lang.String adminKey)

      Set the shut down variable to value passed in.
      Parameters:
        `adminKey` - the service key of this service.
        `thisShutDown` - true if shut down, false if keep running.

    - #### getShutDown

          public boolean getShutDown()

      Return the value indicating if this running thread should be shut down.
      Returns:
        the value of shutDown.