Class AbstractService<S extends ServiceManager>

java.lang.Object
com.jme3.network.service.AbstractService<S>
All Implemented Interfaces:
Service<S>
Direct Known Subclasses:
AbstractClientService, AbstractHostedService

public abstract class AbstractService<S extends ServiceManager> extends Object implements Service<S>
Base class providing some default Service interface implementations as well as a few convenience methods such as getServiceManager() and getService(type). Subclasses must at least override the onInitialize() method to handle service initialization.
  • Constructor Summary

    Constructors
    Modifier
    Constructor
    Description
    protected
     
  • Method Summary

    Modifier and Type
    Method
    Description
    protected <T extends Service<S>>
    T
    getService(Class<T> type)
    Retrieves the first sibling service of the specified type.
    protected S
    Returns the ServiceManager that was passed to initialize() during service initialization.
    final void
    initialize(S serviceManager)
    Initializes this service by keeping a reference to the service manager and calling onInitialize().
    protected abstract void
    onInitialize(S serviceManager)
    Called during initialize() for the subclass to perform implementation specific initialization.
    void
    Default implementation does nothing.
    void
    Default implementation does nothing.
    void
    terminate(S serviceManager)
    Default implementation does nothing.
     

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
  • Constructor Details

    • AbstractService

      protected AbstractService()
  • Method Details

    • getServiceManager

      protected S getServiceManager()
      Returns the ServiceManager that was passed to initialize() during service initialization.
    • getService

      protected <T extends Service<S>> T getService(Class<T> type)
      Retrieves the first sibling service of the specified type.
    • initialize

      public final void initialize(S serviceManager)
      Initializes this service by keeping a reference to the service manager and calling onInitialize().
      Specified by:
      initialize in interface Service<S extends ServiceManager>
    • onInitialize

      protected abstract void onInitialize(S serviceManager)
      Called during initialize() for the subclass to perform implementation specific initialization.
    • start

      public void start()
      Default implementation does nothing. Implementations can override this to perform custom startup behavior.
      Specified by:
      start in interface Service<S extends ServiceManager>
    • stop

      public void stop()
      Default implementation does nothing. Implementations can override this to perform custom stop behavior.
      Specified by:
      stop in interface Service<S extends ServiceManager>
    • terminate

      public void terminate(S serviceManager)
      Default implementation does nothing. Implementations can override this to perform custom termination behavior.
      Specified by:
      terminate in interface Service<S extends ServiceManager>
    • toString

      public String toString()
      Overrides:
      toString in class Object