Class PlatformInstantiatorExecutor

java.lang.Object
de.iip_ecosphere.platform.configuration.PlatformInstantiatorExecutor

public class PlatformInstantiatorExecutor extends Object
Helper methods to execute the platform instantiator as an own process. This class must not have dependencies into critical libraries that may conflict, e.g., logging or Google Guava. Please set JVM system properties on the executor so that they can be passed to the respective execution.
Author:
Holger Eichelberger, SSE
  • Field Details

  • Constructor Details

    • PlatformInstantiatorExecutor

      public PlatformInstantiatorExecutor(File localRepo, Consumer<String> warn, Consumer<String> info, Consumer<Long> executionTimeConsumer)
      Creates an executor instance.
      Parameters:
      localRepo - the local Maven repository, may be null
      warn - a warning message consumer
      info - an information message consumer
      executionTimeConsumer - optional consumer for the (successful) process execution time, may be null for none
  • Method Details

    • instantiate

      public static void instantiate(PlatformInstantiator.InstantiationConfigurer configurer) throws ExecutionException
      Instantiates a platform as specified by the configurer running the instantiation in an own process. May also be a test execution.
      Parameters:
      configurer - the instantiation configurer
      Throws:
      ExecutionException - if the instantiation fails
    • createJvmArg

      public static String createJvmArg(String key, String value)
      Creates a JVM argument from key and value.
      Parameters:
      key - the key
      value - the value, may be null
      Returns:
      the JVM argument
    • setProperty

      public void setProperty(String key, String value)
      Sets a JVM system property for execution.
      Parameters:
      key - the key
      value - the value
    • executeAsProcess

      public void executeAsProcess(ClassLoader loader, String resourcesDir, String tracingLevel, String mvnArgs, String... args) throws ExecutionException
      Executes the platform instantiator directly within an own JVM. This may be required if there are significant library overlaps that can also not resolved by creating a dedicated classloader.
      Parameters:
      loader - the class loader to load the classpath resource file
      resourcesDir - the optional resources directory for the instantiation
      tracingLevel - the tracing level for the instantiation
      mvnArgs - optional maven arguments for the instantiation (may be null for none)
      args - the instantiator arguments
      Throws:
      ExecutionException
      See Also:
    • execute

      public void execute(ClassLoader loader, String resourcesDir, String tracingLevel, String mvnArgs, String... args) throws ExecutionException
      Executes the platform instantiator through an on class loader within this JVM. This may fail if there are significant library overlaps that can also not resolved by creating a dedicated classloader.
      Parameters:
      loader - the class loader to load the classpath resource file
      resourcesDir - the optional resources directory for the instantiation
      tracingLevel - the tracing level for the instantiation
      mvnArgs - optional maven arguments for the instantiation (may be null for none)
      args - the instantiator arguments
      Throws:
      ExecutionException
      See Also:
    • createEasyClasspath

      public List<String> createEasyClasspath(ClassLoader loader)
      Constructs/relocates the class path for EASy-Producer from the config.classpath file in configuration.configuration.
      Parameters:
      loader - the resource class loader
      Returns:
      the classpath, null if creating the classpath fails
    • createEasyClassLoader

      public ClassLoader createEasyClassLoader(ClassLoader parent)
      Creates a focused class loader for EASy-Producer. We assume that all dependencies are resolved.
      Parameters:
      parent - the parent class loader
      Returns:
      the class loader, may be null for none
      See Also: