org.licas.service

## Class DefaultServiceFactory

- java.lang.Object
- - org.licas.service.ServiceFactory
  - - org.licas.service.DefaultServiceFactory

-     public class DefaultServiceFactory
      extends ServiceFactory

  The default service factory for the licas services.
  Author:
    Kieran Greer

- - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `protected static LicasConfig` | `licasConfig` The config handler that stores the service class names.

    - ### Fields inherited from class org.licas.service.ServiceFactory

      `defaultJars, serviceModules`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `DefaultServiceFactory()` Create a new instance of LiasServiceFactory.
    `DefaultServiceFactory(java.lang.String factoryKey)` Create a new instance of DefaultServiceFactory.

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `void` | `addServiceClass(java.lang.String serviceFunction, org.ai_heuristic.model.FactoryInfo factoryInfo)` Add a particular class to be loaded for the specified service type and function.
    `ServiceDef` | `createDefaultService(java.lang.String serviceUuid, java.lang.String serviceType, org.licas_xml.abs.Element adminXml, PasswordHandler passwordHandler)` Create a new default service or module.
    `java.lang.String` | `getDefaultServiceClassname(java.lang.String serviceType)` Get the class name for a specified service type.
    `java.util.ArrayList<ServiceModuleInfo>` | `getDefaultServiceInfo()` Get a list of the default services that can be loaded.
    `java.util.ArrayList<ServiceModuleInfo>` | `getDefaultServiceInfo(java.lang.String categoryType)` Get a list of the default services that can be loaded for the category type.
    `java.lang.String` | `getServiceClass(java.lang.String serviceType)` Return the stored service class for the specified service type.
    `ServiceGuiDef` | `getServiceGui(java.lang.String serviceType)` Return the initialised GUI interface for the specified service.
    `void` | `removeServiceClass(java.lang.String serviceFunction, org.ai_heuristic.model.FactoryInfo factoryInfo)` Remove class info for the specified service type and function.

    - ### Methods inherited from class org.licas.service.ServiceFactory

      `addServiceModule, getBehaviourViewDescr, getBehaviourViewTypes, getDefaultQueryEngineTypes, getInstance, isGlobalService, setServiceFactory`

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

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

- - ### Field Detail

    - #### licasConfig

          protected static LicasConfig licasConfig

      The config handler that stores the service class names.

  - ### Constructor Detail

    - #### DefaultServiceFactory

          public DefaultServiceFactory()

      Create a new instance of LiasServiceFactory. This constructor does not initialise the service factory properly and should be used only to create an instance of the object for type checking.

    - #### DefaultServiceFactory

          public DefaultServiceFactory(java.lang.String factoryKey)

      Create a new instance of DefaultServiceFactory. You need to create an instance with a password key for it to be initialised properly.
      Parameters:
        `factoryKey` - the key to protect dynamic changes.

  - ### Method Detail

    - #### addServiceClass

          public void addServiceClass(java.lang.String serviceFunction,
                                      org.ai_heuristic.model.FactoryInfo factoryInfo)

      Add a particular class to be loaded for the specified service type and function. This will automatically overwrite any existing saved class name.
      Specified by:
        `addServiceClass` in class `ServiceFactory`
      Parameters:
        `serviceFunction` - the function of the service.
        `factoryInfo` - the info object for the interface.

    - #### removeServiceClass

          public void removeServiceClass(java.lang.String serviceFunction,
                                         org.ai_heuristic.model.FactoryInfo factoryInfo)

      Remove class info for the specified service type and function.
      Specified by:
        `removeServiceClass` in class `ServiceFactory`
      Parameters:
        `serviceFunction` - the function of the service.
        `factoryInfo` - the info object for the interface.

    - #### getServiceGui

          public ServiceGuiDef getServiceGui(java.lang.String serviceType)
                                      throws java.lang.Exception

      Return the initialised GUI interface for the specified service.
      Specified by:
        `getServiceGui` in class `ServiceFactory`
      Parameters:
        `serviceType` - the type of service.
      Returns:
        return a GUI interface that is compatible with the service methods.
      Throws:
        `java.lang.Exception` - any error.

    - #### getDefaultServiceInfo

          public java.util.ArrayList<ServiceModuleInfo> getDefaultServiceInfo()

      Get a list of the default services that can be loaded.
      Specified by:
        `getDefaultServiceInfo` in class `ServiceFactory`
      Returns:
        the list of default services that can be loaded.

    - #### getDefaultServiceInfo

          public java.util.ArrayList<ServiceModuleInfo> getDefaultServiceInfo(java.lang.String categoryType)

      Get a list of the default services that can be loaded for the category type. Also add related default parsers.
      Specified by:
        `getDefaultServiceInfo` in class `ServiceFactory`
      Parameters:
        `categoryType` - the type of category to retrieve default services for. `ServiceConst`.`ALLCATEGORIES` means all services. If the licas config file has overwritten an entry, then return that instead.
      Returns:
        the list of default services that can be loaded.

    - #### getDefaultServiceClassname

          public java.lang.String getDefaultServiceClassname(java.lang.String serviceType)

      Get the class name for a specified service type.
      Specified by:
        `getDefaultServiceClassname` in class `ServiceFactory`
      Parameters:
        `serviceType` - the service type.
      Returns:
        the default service class or null if it does not exist.

    - #### createDefaultService

          public ServiceDef createDefaultService(java.lang.String serviceUuid,
                                                 java.lang.String serviceType,
                                                 org.licas_xml.abs.Element adminXml,
                                                 PasswordHandler passwordHandler)
                                          throws java.lang.Exception

      Create a new default service or module. This must be a recognised module from its service type, for this service factory.
      Specified by:
        `createDefaultService` in class `ServiceFactory`
      Parameters:
        `serviceUuid` - the uuid for the new default service to add.
        `serviceType` - the type of service to create. Note that a uuid is not set.
        `adminXml` - the admin info or description of the new service.
        `passwordHandler` - the password handler for the service that calls this method.
      Returns:
        the service or module if it can be created, null otherwise.
      Throws:
        `java.lang.Exception` - any error.

    - #### getServiceClass

          public java.lang.String getServiceClass(java.lang.String serviceType)
                                           throws java.lang.Exception

      Return the stored service class for the specified service type. This is only for the known default service types, not any types added by a user. For the Linker service the most commonly used class is returned. The LinkConfig class can be passed the linking method to return a more accurate result.
      Specified by:
        `getServiceClass` in class `ServiceFactory`
      Parameters:
        `serviceType` - the type of service.
      Returns:
        the service class stored for that type, or null if it is missing.
      Throws:
        `java.lang.Exception` - any error.