Class Starter
java.lang.Object
de.iip_ecosphere.platform.services.environment.Starter
de.iip_ecosphere.platform.services.environment.spring.Starter
- All Implemented Interfaces:
org.springframework.boot.CommandLineRunner
@ComponentScan(basePackageClasses=MetricsProvider.class)
@EnableScheduling
@Import(MetricsProvider.class)
@Component
public abstract class Starter
extends de.iip_ecosphere.platform.services.environment.Starter
implements org.springframework.boot.CommandLineRunner
A specialized starter for Spring Cloud Stream in including the metrics provider.
- Author:
- Holger Eichelberger, SSE
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprivate static classRepresents a service that shall be mapped.Nested classes/interfaces inherited from class de.iip_ecosphere.platform.services.environment.Starter
de.iip_ecosphere.platform.services.environment.Starter.Plugin -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate static org.springframework.context.ConfigurableApplicationContextprivate static final Stringprivate static org.springframework.core.env.Environmentprivate static intstatic final Stringstatic final Stringstatic final Stringstatic final Stringprivate static intprivate org.springframework.boot.autoconfigure.web.ServerPropertiesprivate static List<Starter.ServiceForMapping> Fields inherited from class de.iip_ecosphere.platform.services.environment.Starter
ARG_AAS_NOTIFICATION, DFLT_LOCAL_TRANSPORT_SETUP_SUPPLIER, IIP_APP_NOAAS, IIP_APP_PREFIX, IIP_TEST, IIP_TEST_PLUGIN, IIP_TEST_PREFIX, PARAM_IIP_APP_ID, PARAM_IIP_APP_PLUGINS, PARAM_IIP_APP_PLUGINS_NO_PLUGINS, PARAM_IIP_ENFORCE_START_SEQUENCE, PARAM_IIP_PORT, PARAM_IIP_PROTOCOL, PARAM_IIP_START_SERVER, PARAM_IIP_START_SERVER_ONLY, PARAM_IIP_TEST_AAS_PORT, PARAM_IIP_TEST_AASREG_PORT, PARAM_IIP_TEST_SERVICE_AUTOSTART, PARAM_IIP_TEST_SM_PORT, PARAM_IIP_TEST_SMREG_PORT, PARAM_IIP_TEST_TRANSPORT_PORT, PARAM_IIP_TRANSPORT_GLOBAL, PROPERTY_JAVA8 -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic String[]augmentByAppId(String[] args) Augments the command line arguments by spring cloud stream binder destination args containing the application id ifStarter.getAppId()is given.static String[]augmentByAppId(String[] args, String appId, Supplier<InputStream> appYamlSupplier) Augments the command line arguments by spring cloud stream binder destination args containing the application id if given.static de.iip_ecosphere.platform.services.environment.metricsProvider.metricsAas.MetricsExtractorRestClientCreates a metrics client based on the known Spring environment.static de.iip_ecosphere.platform.services.environment.metricsProvider.metricsAas.MetricsExtractorRestClientcreateMetricsClient(org.springframework.core.env.Environment environment) Creates a metrics client.protected abstract List<de.iip_ecosphere.platform.services.environment.Service> createServices(de.iip_ecosphere.platform.services.environment.YamlArtifact artifact) Creates the relevant services from the givenartifact.private static voidInautostart mode, determine an enforced service startup sequence.protected static org.springframework.context.ConfigurableApplicationContextReturns the application context.protected org.springframework.core.env.EnvironmentReturns the spring environment.voidInitializes the services (if available), starts the AAS command server.static voidMain function.static voidmapService(de.iip_ecosphere.platform.services.environment.Service service) Maps a service through the default mapper and the default metrics client.static voidmapService(de.iip_ecosphere.platform.services.environment.Service service, Runnable after) Maps a service through the default mapper and the default metrics client.static voidparseExternConnections(String[] args, Consumer<String> externalBindingConsumer) Parses the external binder connections and turns them into external routing keys.voidprivate static voidStarts data for mapped services, delayedServiceState.RUNNING.Methods inherited from class de.iip_ecosphere.platform.services.environment.Starter
addAppEnvironment, addAppEnvironment, autostartService, composeArgument, considerInstalledDependencies, enablesLocalTransport, enforceStartSequence, expectAas, extractProcessArtifacts, findArtifact, getAppId, getApplicationSetupAsStream, getMappedService, getProtocolBuilder, getServiceAutostart, getServiceCommandNetworkMgrKey, getServiceId, getServiceId, getServiceMapper, getServicePort, getServicePortName, getServiceProcessNetworkMgrKey, getSetup, inTest, loadOktoPlugins, main, mapService, mapService, normalizeServiceId, parse, registerAfterPluginInitializer, registerDefaultPlugins, registerPlugin, runPlugin, setAasNotificationMode, setCmdServerConfigurer, setLocalTransportSetupSupplier, setOnServiceAutostartAttachShutdownHook, setServiceAutostart, shutdown, start, startDataForMappedServices, startServer, transferArgsToEnvironment
-
Field Details
-
OPT_SPRING_FUNCTION_DEF
- See Also:
-
OPT_SPRING_BINDINGS_PREFIX
- See Also:
-
OPT_SPRING_BINDER_POSTFIX
- See Also:
-
EXTERNAL_BINDER_NAME
- See Also:
-
DEPLOYMENT_DESC
- See Also:
-
ctx
private static org.springframework.context.ConfigurableApplicationContext ctx -
environment
private static org.springframework.core.env.Environment environment -
port
private static int port -
startupSequence
-
expectedServiceCount
private static int expectedServiceCount -
serverProperties
@Autowired private org.springframework.boot.autoconfigure.web.ServerProperties serverProperties
-
-
Constructor Details
-
Starter
@Autowired public Starter(org.springframework.core.env.Environment env) Creates an instance.- Parameters:
env- the Spring environment
-
-
Method Details
-
run
- Specified by:
runin interfaceorg.springframework.boot.CommandLineRunner- Throws:
Exception
-
initialize
public void initialize()Initializes the services (if available), starts the AAS command server.- See Also:
-
determineStartupSequence
private static void determineStartupSequence()Inautostart mode, determine an enforced service startup sequence. RequiresStarter.parse(String...)to be executed before. -
createMetricsClient
public static de.iip_ecosphere.platform.services.environment.metricsProvider.metricsAas.MetricsExtractorRestClient createMetricsClient(org.springframework.core.env.Environment environment) Creates a metrics client.- Parameters:
environment- the Spring environment- Returns:
- the metrics REST client, may be null
-
createMetricsClient
public static de.iip_ecosphere.platform.services.environment.metricsProvider.metricsAas.MetricsExtractorRestClient createMetricsClient()Creates a metrics client based on the known Spring environment. Only available aftermain(Class, String[]).- Returns:
- the metrics REST client, may be null
-
getContext
protected static org.springframework.context.ConfigurableApplicationContext getContext()Returns the application context. Only available aftermain(Class, String[]).- Returns:
- the context, may be null
-
createServices
protected abstract List<de.iip_ecosphere.platform.services.environment.Service> createServices(de.iip_ecosphere.platform.services.environment.YamlArtifact artifact) Creates the relevant services from the givenartifact.- Parameters:
artifact- the artifact- Returns:
- the services (may be empty or null for none)
-
getEnvironment
protected org.springframework.core.env.Environment getEnvironment()Returns the spring environment.- Returns:
- the spring environment
-
parseExternConnections
Parses the external binder connections and turns them into external routing keys. [public for testing]- Parameters:
args- the command line argumentsexternalBindingConsumer- consumer for the external connections
-
augmentByAppId
Augments the command line arguments by spring cloud stream binder destination args containing the application id ifStarter.getAppId()is given.- Parameters:
args- the command line arguments- Returns:
- the (augmented) command line arguments
-
augmentByAppId
public static String[] augmentByAppId(String[] args, String appId, Supplier<InputStream> appYamlSupplier) Augments the command line arguments by spring cloud stream binder destination args containing the application id if given. [public for testing]- Parameters:
args- the command line argumentsappId- the application id, may be emptyappYamlSupplier- provides access to the input stream (called if needed)- Returns:
- the (augmented) command line arguments
-
main
Main function.- Parameters:
cls- the class to startargs- command line arguments
-
mapService
public static void mapService(de.iip_ecosphere.platform.services.environment.Service service) Maps a service through the default mapper and the default metrics client. [Convenience method for generation] By default, do autostart.- Parameters:
service- the service to be mapped (may be null, no mapping will happen then)- See Also:
-
mapService
public static void mapService(de.iip_ecosphere.platform.services.environment.Service service, Runnable after) Maps a service through the default mapper and the default metrics client. [Convenience method for generation] By default, do autostart.- Parameters:
service- the service to be mapped (may be null, no mapping will happen then)after- code to be executed after mapping, may be null- See Also:
-
startDataForMappedServices
private static void startDataForMappedServices()Starts data for mapped services, delayedServiceState.RUNNING.
-