Class Broker
java.lang.Object
de.iip_ecosphere.platform.services.environment.services.Broker
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
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classBroker creator.static interfaceBroker type interface (extensible).static enumDefault broker types. -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate static Map<Broker.BrokerType, Broker.BrokerCreator> private de.iip_ecosphere.platform.support.Serverprivate static boolean -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic List<Broker.BrokerType> allTypes()Returns all known/registered types.static de.iip_ecosphere.platform.support.ServercreateInstance(Broker.BrokerType type, int port) Creates a server instance.static de.iip_ecosphere.platform.transport.connectors.TransportConnectorCreates a transport connector instance.static voidTries to extract the server configuration.static <R> RonCreator(Broker.BrokerType type, Function<Broker.BrokerCreator, R> func) Executes an operation on the associated broker creator and returns the result.static voidregisterType(Broker.BrokerType type, Broker.BrokerCreator creator) Registers atypewith it's creator.protected voidsetInstance(de.iip_ecosphere.platform.support.Server inst) Defines/overrides the current instance.voidStops the broker instance.static Broker.BrokerTypeReturns the object value ofvalue.
-
Field Details
-
serverConfigExtracted
private static boolean serverConfigExtracted -
creators
-
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
Registers atypewith it's creator. Call e.g. in constructor of type enum.- Parameters:
type- the type, may be null, ignored thencreator- the creator, may be null but then nothing will be created later
-
allTypes
Returns all known/registered types. There are not necessarily creators for these types.- Returns:
- the types as unmodifiable list
-
valueOf
Returns the object value ofvalue.- Parameters:
value- the value, may be null- Returns:
- the object value or null for unknown
-
onCreator
Executes an operation on the associated broker creator and returns the result.- Type Parameters:
R- the result type- Parameters:
type- the broker typefunc- the function to execute- Returns:
- the result or null if no broker creator/
funcare 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 typeport- 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
Tries to extract the server configuration.- Parameters:
type- the server type carrying the config location
-
stopInstance
public void stopInstance()Stops the broker instance.
-