Class Component<S extends Service,​C>

  • Type Parameters:
    C - Type of the configuration class
    S - Type of the service required by this component

    public abstract class Component<S extends Service,​C>
    extends Object
    Extended by packaged service components to gain access to useful functionality in the service.
    Author:
    gideon
    • Constructor Detail

      • Component

        protected Component​(S service)
        Create a component associated with the given service.
        Parameters:
        service - The service of which this component is a part of.
    • Method Detail

      • start

        public abstract void start​(C config)
                            throws ComponentException
        Start the component. Implementations need to do anything here they need done before the component's functionality is available.
        Parameters:
        config - The component's configuration.
        Throws:
        ComponentException - Thrown if there is a problem starting the component
      • stop

        public void stop()
                  throws ComponentException
        Stop the component. Implementations can override this to release resources, close connections or do other kinds of cleanup.
        Throws:
        ComponentException - Throw if there is a proble stopping the component
      • getName

        public abstract String getName()
        Get the name of the component. This is unique and is used to find the component's configuration in the service config.
        Returns:
        The component's name.
      • requiresConfig

        public boolean requiresConfig()
        Call to determine if the component requires configuration. By default this is true, but if a component does not require any configuration, it can be overriden to return false which will cause the system not to try to locate it's configuration.
      • service

        protected final S service()
        Access the service that owns this component. Utility method to get access to functionality required by the component.
        Returns:
        The service