Class PlatformInstantiatorExecutor
java.lang.Object
de.iip_ecosphere.platform.configuration.PlatformInstantiatorExecutor
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 Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptioncreateEasyClassLoader(ClassLoader parent) Creates a focused class loader for EASy-Producer.createEasyClasspath(ClassLoader loader) Constructs/relocates the class path for EASy-Producer from theconfig.classpathfile in configuration.configuration.static StringcreateJvmArg(String key, String value) Creates a JVM argument fromkeyandvalue.voidexecute(ClassLoader loader, String resourcesDir, String tracingLevel, String mvnArgs, String... args) Executes the platform instantiator through an on class loader within this JVM.voidexecuteAsProcess(ClassLoader loader, String resourcesDir, String tracingLevel, String mvnArgs, String... args) Executes the platform instantiator directly within an own JVM.static voidInstantiates a platform as specified by theconfigurerrunning the instantiation in an own process.voidsetProperty(String key, String value) Sets a JVM system property for execution.
-
Field Details
-
SYSOUT_CONSUMER
-
localRepo
-
warn
-
info
-
executionTimeConsumer
-
mainCls
-
inTesting
private boolean inTesting -
properties
-
-
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 nullwarn- a warning message consumerinfo- an information message consumerexecutionTimeConsumer- 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 theconfigurerrunning the instantiation in an own process. May also be a test execution.- Parameters:
configurer- the instantiation configurer- Throws:
ExecutionException- if the instantiation fails
-
createJvmArg
Creates a JVM argument fromkeyandvalue.- Parameters:
key- the keyvalue- the value, may be null- Returns:
- the JVM argument
-
setProperty
Sets a JVM system property for execution.- Parameters:
key- the keyvalue- 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 fileresourcesDir- the optional resources directory for the instantiationtracingLevel- the tracing level for the instantiationmvnArgs- 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 fileresourcesDir- the optional resources directory for the instantiationtracingLevel- the tracing level for the instantiationmvnArgs- optional maven arguments for the instantiation (may be null for none)args- the instantiator arguments- Throws:
ExecutionException- See Also:
-
createEasyClasspath
Constructs/relocates the class path for EASy-Producer from theconfig.classpathfile in configuration.configuration.- Parameters:
loader- the resource class loader- Returns:
- the classpath, null if creating the classpath fails
-
createEasyClassLoader
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:
-