Class ClasspathJavaCommandBuilder
- java.lang.Object
-
- org.springframework.cloud.deployer.spi.local.JavaCommandBuilder
-
- de.iip_ecosphere.platform.services.spring.ClasspathJavaCommandBuilder
-
- All Implemented Interfaces:
org.springframework.cloud.deployer.spi.local.CommandBuilder
public class ClasspathJavaCommandBuilder extends org.springframework.cloud.deployer.spi.local.JavaCommandBuilderA command builder that excepts classpath-based Spring service starting for ZIP service artifacts as well as JAR service artifacts. Unfortunately, the Spring deployers cannot easily be extended through regular mechanisms, so we hook in via reflection (ugly). Unfortunately, the local deployer does not even pass on the work directory, so we have to "guess" it. The work folder in turn is needed as the services JVM will be started within and we need the JAR files of the application unpacked there.- Author:
- Holger Eichelberger, SSE
-
-
Field Summary
Fields Modifier and Type Field Description private java.lang.StringcurDeployerIdstatic java.lang.StringPROP_ZIP_CLASSPATHprivate org.springframework.cloud.deployer.spi.local.LocalDeployerPropertiesproperties
-
Constructor Summary
Constructors Constructor Description ClasspathJavaCommandBuilder(org.springframework.cloud.deployer.spi.local.LocalDeployerProperties properties)Creates the command builder.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description private java.lang.Stringadd(java.lang.String classpath, org.springframework.cloud.deployer.spi.core.AppDeploymentRequest request, java.io.File workDir, boolean asWildcard)Adds shared libraries to the classpath.protected voidaddJavaExecutionOptions(java.util.List<java.lang.String> commands, org.springframework.cloud.deployer.spi.core.AppDeploymentRequest request)java.lang.ProcessBuilderbuildExecutionCommand(org.springframework.cloud.deployer.spi.core.AppDeploymentRequest request, java.util.Map<java.lang.String,java.lang.String> appInstanceEnv, java.lang.String deployerId, java.util.Optional<java.lang.Integer> appInstanceNumber, org.springframework.cloud.deployer.spi.local.LocalDeployerProperties localDeployerProperties, java.util.Optional<org.springframework.cloud.deployer.spi.local.DebugAddress> debugAddressOption)private booleancheckCpFile(java.io.File cpFile, org.springframework.cloud.deployer.spi.core.AppDeploymentRequest request, java.io.File workDir)Checks/rewrites a classpath file.private static voidcleanWorkdirs(org.springframework.cloud.deployer.spi.local.LocalDeployerProperties properties)Tries to clean up workdirs created by the local deployer that are left over from the last time, e.g., after issuing CTRL+C.private booleancopySharedLibs(java.io.File sharedLibs, java.io.File target)Copy shared JAR-files (non-recursive).private java.io.FilefindWorkingDirectory()Guess the working directory.private static org.slf4j.LoggergetLogger()Returns the logger of this class.(package private) static voidinstallInto(org.springframework.cloud.deployer.spi.app.AppDeployer deployer)Installs an instance of this builder intodeployer.-
Methods inherited from class org.springframework.cloud.deployer.spi.local.JavaCommandBuilder
addJavaOptions, bindDeploymentProperties, getBaseUrl, getPortSuggestion
-
-
-
-
Field Detail
-
PROP_ZIP_CLASSPATH
public static final java.lang.String PROP_ZIP_CLASSPATH
- See Also:
- Constant Field Values
-
properties
private final org.springframework.cloud.deployer.spi.local.LocalDeployerProperties properties
-
curDeployerId
private java.lang.String curDeployerId
-
-
Method Detail
-
buildExecutionCommand
public java.lang.ProcessBuilder buildExecutionCommand(org.springframework.cloud.deployer.spi.core.AppDeploymentRequest request, java.util.Map<java.lang.String,java.lang.String> appInstanceEnv, java.lang.String deployerId, java.util.Optional<java.lang.Integer> appInstanceNumber, org.springframework.cloud.deployer.spi.local.LocalDeployerProperties localDeployerProperties, java.util.Optional<org.springframework.cloud.deployer.spi.local.DebugAddress> debugAddressOption)- Specified by:
buildExecutionCommandin interfaceorg.springframework.cloud.deployer.spi.local.CommandBuilder- Overrides:
buildExecutionCommandin classorg.springframework.cloud.deployer.spi.local.JavaCommandBuilder
-
findWorkingDirectory
private java.io.File findWorkingDirectory()
Guess the working directory. Start with the root from properties, find folders that contain only of numbers and containcurDeployerIdas sub-folder. Then sort according to the creation timestamp (we may also take the folder name as it is a timestamp) and return the contained folder withcurDeployerId.- Returns:
- returns the working directory or as last resort a temporary one where the execution probably will fail
-
getLogger
private static org.slf4j.Logger getLogger()
Returns the logger of this class.- Returns:
- the logger
-
copySharedLibs
private boolean copySharedLibs(java.io.File sharedLibs, java.io.File target)Copy shared JAR-files (non-recursive).- Parameters:
sharedLibs- the shared libs foldertarget- the target folder- Returns:
trueif JAR-files were copied,falseelse
-
add
private java.lang.String add(java.lang.String classpath, org.springframework.cloud.deployer.spi.core.AppDeploymentRequest request, java.io.File workDir, boolean asWildcard)Adds shared libraries to the classpath.- Parameters:
classpath- the base classpathrequest- the deployment requestworkDir- the work directoryasWildcard- adds shared libraries as wildcard or by individual files to the classpath- Returns:
- the modified classpath
-
checkCpFile
private boolean checkCpFile(java.io.File cpFile, org.springframework.cloud.deployer.spi.core.AppDeploymentRequest request, java.io.File workDir)Checks/rewrites a classpath file.- Parameters:
cpFile- the (existing) file to checkrequest- the deployment request objectworkDir- the work directory- Returns:
trueif the file was modified without problems,falseif the wildcard classpath shall be used
-
addJavaExecutionOptions
protected void addJavaExecutionOptions(java.util.List<java.lang.String> commands, org.springframework.cloud.deployer.spi.core.AppDeploymentRequest request)- Overrides:
addJavaExecutionOptionsin classorg.springframework.cloud.deployer.spi.local.JavaCommandBuilder
-
cleanWorkdirs
private static void cleanWorkdirs(org.springframework.cloud.deployer.spi.local.LocalDeployerProperties properties)
Tries to clean up workdirs created by the local deployer that are left over from the last time, e.g., after issuing CTRL+C. We recommend setting up a dedicated workdir, e.g., a folder within temp.- Parameters:
properties- the local deployer properties
-
installInto
static void installInto(org.springframework.cloud.deployer.spi.app.AppDeployer deployer)
Installs an instance of this builder intodeployer.- Parameters:
deployer- the deployer instance, may be null
-
-