Interface Service<T>

All Superinterfaces:
Component<ServiceDescriptor,ServerEnvironment>

public interface Service<T> extends Component<ServiceDescriptor,ServerEnvironment>
FirstSpirit service interface. Implementing classes must have a no-arg constructor.
The lifecycle of a service instance doesn't necessarily end with the stop call. Therefore it is necessary to ensure all instances passed by to this service (e.g. during init) must be cleaned up during stop and needs to be requested again during next init and start
Since:
4.1
  • Method Summary

    Modifier and Type
    Method
    Description
    @Nullable Class<? extends ServiceProxy<T>>
    A service proxy is an optional, client-side service implementation.
    @NotNull Class<? extends T>
    Returns the service server / communication interface.
    boolean
    Returns whether the service is running.
    void
    Starts the service.
    Attention: If it is necessary to use instances provided by the environment (e.g.
    void
    Stops the service.

    Methods inherited from interface de.espirit.firstspirit.module.Component

    init, installed, uninstalling, updated
  • Method Details

    • start

      void start()
      Starts the service.
      Attention: If it is necessary to use instances provided by the environment (e.g. specialistbroker) which is passed by in Component.init(ComponentDescriptor, ServerEnvironment), it is recommended to request these instances in this start method or later on demand. These instances will become invalid after stop() and need to be requested again during next start()
      Since:
      4.1
    • stop

      void stop()
      Stops the service. This method should be used to clean up instances and references to request them again during start().
      e.g. the broker provided by the environment during Component.init(ComponentDescriptor, ServerEnvironment) will become invalid after stop.
      Since:
      4.1
    • isRunning

      boolean isRunning()
      Returns whether the service is running.
      Returns:
      true if the service is running.
      Since:
      4.1
    • getServiceInterface

      @NotNull @NotNull Class<? extends T> getServiceInterface()
      Returns the service server / communication interface. Only methods of this interface are accessible, so Service instances must also implement this interface.
      If no proxy class is specified this interface must be used to request the service instance.
      Returns:
      service interface class, never null.
      Since:
      4.1
      See Also:
    • getProxyClass

      @Nullable @Nullable Class<? extends ServiceProxy<T>> getProxyClass()
      A service proxy is an optional, client-side service implementation. It will be instantiated, initialized and returned by Connection.getService(String). The proxy class must have a no-arg constructor and must implement the ServiceProxy interface, but does not have to implement the communication interface itself.
      It is recommended that the proxy class implements an interface because the proxy instance will be requested with this interface. For the following usecases it is useful to specify a proxy class:
      1) Caching:
      To avoid unnecessary client / server communication via the communication interface. In this case the proxy class normally implements the communication interface itself and that is used to request the service.
      2) Serialization or slim interface for external use:
      If you want to provide a slim interface for external usage but need more functions in the internal communication interface or you want to provide an interface with signatures containing non serializable objects it is necessary to define an interface which is implemented by this proxy class which is different to the communication interface. In this case the proxy class should not implement the communication interface.
      Returns:
      service proxy class or null if no proxy is provided.
      Since:
      4.1