java.lang.Object
de.iip_ecosphere.platform.services.environment.services.Broker

public class Broker extends Object
Represents a broker process. We rely on a common application configuration and ignore that spring cloud streams cannot/shall not start up for the broker (no option to disable).
Author:
Holger Eichelberger, SSE
  • Field Details

    • serverConfigExtracted

      private static boolean serverConfigExtracted
    • creators

      private static Map<Broker.BrokerType,Broker.BrokerCreator> creators
    • brokerTypes

      private static List<Class<?>> brokerTypes
    • instance

      private de.iip_ecosphere.platform.support.Server instance
  • Constructor Details

    • Broker

      public Broker()
      Creates a broker instance and attaches a shutdown hook.
  • Method Details

    • registerType

      public static void registerType(Broker.BrokerType type, Broker.BrokerCreator creator)
      Registers a type with it's creator. Call e.g. in constructor of type enum.
      Parameters:
      type - the type, may be null, ignored then
      creator - the creator, may be null but then nothing will be created later
    • allTypes

      public static List<Broker.BrokerType> allTypes()
      Returns all known/registered types. There are not necessarily creators for these types.
      Returns:
      the types as unmodifiable list
    • valueOf

      public static Broker.BrokerType valueOf(String value)
      Returns the object value of value.
      Parameters:
      value - the value, may be null
      Returns:
      the object value or null for unknown
    • onCreator

      public static <R> R onCreator(Broker.BrokerType type, Function<Broker.BrokerCreator,R> func)
      Executes an operation on the associated broker creator and returns the result.
      Type Parameters:
      R - the result type
      Parameters:
      type - the broker type
      func - the function to execute
      Returns:
      the result or null if no broker creator/func are present
    • setInstance

      protected void setInstance(de.iip_ecosphere.platform.support.Server inst)
      Defines/overrides the current instance.
      Parameters:
      inst - the instance
    • createInstance

      public static de.iip_ecosphere.platform.support.Server createInstance(Broker.BrokerType type, int port)
      Creates a server instance.
      Parameters:
      type - the server type
      port - the port number
      Returns:
      the server instance
    • createTransportConnector

      public static de.iip_ecosphere.platform.transport.connectors.TransportConnector createTransportConnector(Broker.BrokerType type)
      Creates a transport connector instance.
      Parameters:
      type - the server type
      Returns:
      the transport connector instance
    • extractServerConfig

      public static void extractServerConfig(Broker.BrokerType type)
      Tries to extract the server configuration.
      Parameters:
      type - the server type carrying the config location
    • stopInstance

      public void stopInstance()
      Stops the broker instance.