Class AbstractNonPrivilegedService

java.lang.Object
de.aristaflow.adept2.base.service.AbstractADEPT2Service
de.aristaflow.adept2.base.service.AbstractNonPrivilegedService
All Implemented Interfaces:
ADEPT2Service, LogService, ServiceThreadHandling
Direct Known Subclasses:
AbstractEventManager

@ConfigurationDescription(properties={@Property(name="ServiceAuthUserName",defaultValue="${arflow:confVar.SystemUserName}",description="The user name with which this service authenticates at the global security manager."),,,}) public abstract class AbstractNonPrivilegedService extends AbstractADEPT2Service
An abstract class providing the basic means for authenticating and managing a ClientSessionFactory. This can only be used for services that are created after the global security manager is available.
  • Constructor Details

    • AbstractNonPrivilegedService

      protected AbstractNonPrivilegedService(Configuration conf, Registry registry, Class<?> cls) throws ConfigurationException
      Creates an ADEPT2 service with the designated registry, a logger for this and assuming that there are no other services required.
      Parameters:
      conf - The configuration providing the logon credentials for this service.
      registry - The registry to be used for accessing services by this service. This is provided as parameter to the constructor when creating a service.
      cls - The class specifying the name of the logger of this service.
      Throws:
      ConfigurationException - If the password for this authenticated service cannot be parsed from the configuration, a ConfigurationException will be thrown.
    • AbstractNonPrivilegedService

      protected AbstractNonPrivilegedService(Configuration conf, Registry registry, String[] startupRequiredServices, String[] runtimeRequiredServices, Class<?> cls) throws ConfigurationException
      Creates an ADEPT2 service with the designated registry, a logger for this and the designated required services.
      Parameters:
      conf - The configuration providing the logon credentials for this service.
      registry - The registry to be used for accessing services by this service. This is provided as parameter to the constructor when creating a service.
      startupRequiredServices - The service type names of services required at startup time (in init(URI[], URI[]) and AbstractADEPT2Service.start()).
      runtimeRequiredServices - The service type names of services required at runtime (after startup time).
      cls - The class specifying the name of the logger of this service.
      Throws:
      ConfigurationException - If the password for this authenticated service cannot be parsed from the configuration, a ConfigurationException will be thrown.
  • Method Details

    • init

      public void init(URI[] localExportedUris, URI[] globalExportedUris) throws AbortServiceException
      Copies the designated URI array and stores it internally and authenticates to the system and sets the session factory.
      This method can be called any time in overriding init-methods.
      Specified by:
      init in interface ADEPT2Service
      Overrides:
      init in class AbstractADEPT2Service
      Parameters:
      localExportedUris - The URIs with which this service is exported locally or a local URI or an empty array for internal services.
      globalExportedUris - The URIs with which this service is published globally or null in case the service is not published.
      Throws:
      AbortServiceException - If authenticating at the security manager fails, an AbortServiceException will be thrown.
    • simpleInit

      protected void simpleInit(URI[] localExportedUris, URI[] globalExportedUris) throws AbortServiceException
      Initialises this service but does not explicitly authenticate. This needs to be done at a later time. The late authentication is required for the registries when the security manager is not set yet.
      Parameters:
      localExportedUris - The URIs with which this service is exported locally or a local URI or an empty array for internal services.
      globalExportedUris - The URIs with which this service is published globally or null in case the service is not published.
      Throws:
      AbortServiceException - If the initialisation of the superclass fails, an AbortServiceException will be thrown.
    • getSecurityManager

      protected SecurityManager getSecurityManager()
      Returns the security manager that will be used for authentication. This implementation will simply return the security manager provided by the registry. This may be overridden in subclasses.
      Returns:
      the security manager that will be used for authentication
    • authenticateService

      protected void authenticateService() throws AuthenticationException, AbortServiceException
      (Re-)Authenticates this service using the security manager provided by getSecurityManager().
      Throws:
      AuthenticationException - If the provided credentials are incorrect, an AuthenticationException will be thrown.
      AbortServiceException - If the authentication at the security manager fails an AbortServiceException will be thrown.
      ConfigurationException - If the password cannot be parsed, a ConfigurationException will be thrown.
    • getSessionFactory

      protected ClientSessionFactory getSessionFactory()
      Returns the client session factory assigned to this service.
      Returns:
      The client session factory assigned to this service.
    • createSession

      protected SessionToken createSession()
      Creates a new session token using the client session factory assigned to this service.
      Returns:
      A new session token using the client session factory assigned to this service.
    • awaitActiveSessions

      protected void awaitActiveSessions(boolean emergency)
      Awaits the termination of active sessions. This allows subclasses to separate waiting for the termination from shutting down this abstract service.
      Parameters:
      emergency - Whether the active sessions should only be awaited for a specific time.
    • shutdown

      public void shutdown(boolean emergency)
      Awaits the termination of the active sessions and nulls the session factory.
      Specified by:
      shutdown in interface ADEPT2Service
      Overrides:
      shutdown in class AbstractADEPT2Service
      Parameters:
      emergency - Whether the shutdown will be an emergency shutdown.