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 classes/interfaces inherited from class de.iip_ecosphere.platform.services.environment.Starter

    de.iip_ecosphere.platform.services.environment.Starter.Plugin
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    private static org.springframework.context.ConfigurableApplicationContext
     
    private static org.springframework.core.env.Environment
     
    static final String
     
    static final String
     
    static final String
     
    static final String
     
    private static int
     
    private org.springframework.boot.autoconfigure.web.ServerProperties
     

    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_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
    Constructor
    Description
    Starter(org.springframework.core.env.Environment env)
    Creates an instance.
  • Method Summary

    Modifier and Type
    Method
    Description
    static String[]
    Augments the command line arguments by spring cloud stream binder destination args containing the application id if Starter.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.MetricsExtractorRestClient
    Creates a metrics client based on the known Spring environment.
    static de.iip_ecosphere.platform.services.environment.metricsProvider.metricsAas.MetricsExtractorRestClient
    createMetricsClient(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 given artifact.
    protected static org.springframework.context.ConfigurableApplicationContext
    Returns the application context.
    protected org.springframework.core.env.Environment
    Returns the spring environment.
    void
    Initializes the services (if available), starts the AAS command server.
    static void
    main(Class<? extends Starter> cls, String[] args)
    Main function.
    static void
    parseExternConnections(String[] args, Consumer<String> externalBindingConsumer)
    Parses the external binder connections and turns them into external routing keys.
    void
    run(String... args)
     

    Methods inherited from class de.iip_ecosphere.platform.services.environment.Starter

    addAppEnvironment, addAppEnvironment, composeArgument, considerInstalledDependencies, enablesLocalTransport, expectAas, extractProcessArtifacts, findArtifact, getAppId, getApplicationSetupAsStream, getMappedService, getProtocolBuilder, getServiceCommandNetworkMgrKey, getServiceId, getServiceId, getServiceMapper, getServicePort, getServicePortName, getServiceProcessNetworkMgrKey, getSetup, inTest, loadOktoPlugins, main, mapService, mapService, mapService, normalizeServiceId, parse, registerAfterPluginInitializer, registerDefaultPlugins, registerPlugin, runPlugin, setAasNotificationMode, setCmdServerConfigurer, setLocalTransportSetupSupplier, setOnServiceAutostartAttachShutdownHook, setServiceAutostart, shutdown, start, startServer, transferArgsToEnvironment

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • OPT_SPRING_FUNCTION_DEF

      public static final String OPT_SPRING_FUNCTION_DEF
      See Also:
    • OPT_SPRING_BINDINGS_PREFIX

      public static final String OPT_SPRING_BINDINGS_PREFIX
      See Also:
    • OPT_SPRING_BINDER_POSTFIX

      public static final String OPT_SPRING_BINDER_POSTFIX
      See Also:
    • EXTERNAL_BINDER_NAME

      public static final String EXTERNAL_BINDER_NAME
      See Also:
    • ctx

      private static org.springframework.context.ConfigurableApplicationContext ctx
    • environment

      private static org.springframework.core.env.Environment environment
    • port

      private static int port
    • 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

      public void run(String... args) throws Exception
      Specified by:
      run in interface org.springframework.boot.CommandLineRunner
      Throws:
      Exception
    • initialize

      public void initialize()
      Initializes the services (if available), starts the AAS command server.
      See Also:
    • 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 after main(Class, String[]).
      Returns:
      the metrics REST client, may be null
    • getContext

      protected static org.springframework.context.ConfigurableApplicationContext getContext()
      Returns the application context. Only available after main(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 given artifact.
      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

      public static void parseExternConnections(String[] args, Consumer<String> externalBindingConsumer)
      Parses the external binder connections and turns them into external routing keys. [public for testing]
      Parameters:
      args - the command line arguments
      externalBindingConsumer - consumer for the external connections
    • augmentByAppId

      public static String[] augmentByAppId(String[] args)
      Augments the command line arguments by spring cloud stream binder destination args containing the application id if Starter.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 arguments
      appId - the application id, may be empty
      appYamlSupplier - provides access to the input stream (called if needed)
      Returns:
      the (augmented) command line arguments
    • main

      public static void main(Class<? extends Starter> cls, String[] args)
      Main function.
      Parameters:
      cls - the class to start
      args - command line arguments