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.JavaCommandBuilder
A 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 -
Constructor Summary
ConstructorsConstructorDescriptionClasspathJavaCommandBuilder(org.springframework.cloud.deployer.spi.local.LocalDeployerProperties properties) Creates the command builder. -
Method Summary
Modifier and TypeMethodDescriptionprivate Stringadd(String classpath, org.springframework.cloud.deployer.spi.core.AppDeploymentRequest request, File workDir, boolean asWildcard) Adds shared libraries to the classpath.protected voidaddJavaExecutionOptions(List<String> commands, org.springframework.cloud.deployer.spi.core.AppDeploymentRequest request) buildExecutionCommand(org.springframework.cloud.deployer.spi.core.AppDeploymentRequest request, Map<String, String> appInstanceEnv, String deployerId, Optional<Integer> appInstanceNumber, org.springframework.cloud.deployer.spi.local.LocalDeployerProperties localDeployerProperties, Optional<org.springframework.cloud.deployer.spi.local.DebugAddress> debugAddressOption) private booleancheckCpFile(File cpFile, org.springframework.cloud.deployer.spi.core.AppDeploymentRequest request, 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(File sharedLibs, File target) Copy shared JAR-files (non-recursive).private FileGuess the working directory.private static de.iip_ecosphere.platform.support.logging.LoggerReturns 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, getPortSuggestionMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.springframework.cloud.deployer.spi.local.CommandBuilder
getJdwpOptions
-
Field Details
-
PROP_ZIP_CLASSPATH
- See Also:
-
properties
private final org.springframework.cloud.deployer.spi.local.LocalDeployerProperties properties -
curDeployerId
-
-
Constructor Details
-
ClasspathJavaCommandBuilder
public ClasspathJavaCommandBuilder(org.springframework.cloud.deployer.spi.local.LocalDeployerProperties properties) Creates the command builder.- Parameters:
properties- the local properties as setup of the local deployer
-
-
Method Details
-
buildExecutionCommand
public ProcessBuilder buildExecutionCommand(org.springframework.cloud.deployer.spi.core.AppDeploymentRequest request, Map<String, String> appInstanceEnv, String deployerId, Optional<Integer> appInstanceNumber, org.springframework.cloud.deployer.spi.local.LocalDeployerProperties localDeployerProperties, 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
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 de.iip_ecosphere.platform.support.logging.Logger getLogger()Returns the logger of this class.- Returns:
- the logger
-
add
private String add(String classpath, org.springframework.cloud.deployer.spi.core.AppDeploymentRequest request, 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(File cpFile, org.springframework.cloud.deployer.spi.core.AppDeploymentRequest request, 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(List<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
-