Class DescriptorUtils
java.lang.Object
de.iip_ecosphere.platform.services.spring.DescriptorUtils
Descriptor and artifact utility functions that may be used standalone.
- Author:
- Holger Eichelberger, SSE
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic voidaddEndpointArgs(List<String> cmdLine, Endpoint endpoint, int port, String host) Adds commandline args for a givenendpoint.static voidaddEndpointArgs(List<String> cmdLine, Endpoint endpoint, de.iip_ecosphere.platform.support.ServerAddress addr) Adds commandline args for a givenendpoint.static ClassLoadercreateClassLoader(File jarFile) Creates a class loader for a JAR file, in particular an executable Spring-packaged Jar file.createStandaloneCommandArgs(File jar, int brokerPort, String brokerHost, int adminPort, String serviceProtocol) Creates command line args for executing the (Spring) fat JAR in standalone/debugging manner requesting the spring web server to be executed on an ephemeral port by default.createStandaloneCommandArgs(File jar, int brokerPort, String brokerHost, int adminPort, String serviceProtocol, int springPort) Creates command line args for executing the (Spring) fat JAR in standalone/debugging manner.private static StringReturns the deployment descriptor file name to use.private static de.iip_ecosphere.platform.support.logging.LoggerReturns the logger.static YamlArtifactReads the YAML deployment descriptor fromfile.static YamlArtifactreadFromFile(File file) Reads the YAML deployment descriptor fromfile.static voidsetState(de.iip_ecosphere.platform.services.ServiceDescriptor service, de.iip_ecosphere.platform.services.environment.ServiceState state) Changes the service state and notifiesServicesAas.static voidsetStateSafe(de.iip_ecosphere.platform.services.ServiceDescriptor service, de.iip_ecosphere.platform.services.environment.ServiceState state) CallssetState(ServiceDescriptor, ServiceState)logging exceptions.static voidthrowExecutionException(String action, String message) Throws an execution exception for the given message and logs an error in the same step.static voidthrowExecutionException(String action, Throwable th) Throws an execution exception for the given throwable and logs an error in the same step.
-
Constructor Details
-
DescriptorUtils
public DescriptorUtils()
-
-
Method Details
-
setStateSafe
public static void setStateSafe(de.iip_ecosphere.platform.services.ServiceDescriptor service, de.iip_ecosphere.platform.services.environment.ServiceState state) CallssetState(ServiceDescriptor, ServiceState)logging exceptions.- Parameters:
service- the service to changestate- the new state
-
setState
public static void setState(de.iip_ecosphere.platform.services.ServiceDescriptor service, de.iip_ecosphere.platform.services.environment.ServiceState state) throws ExecutionException Changes the service state and notifiesServicesAas.- Parameters:
service- the servicestate- the new state- Throws:
ExecutionException- if changing the state fails
-
readFromFile
Reads the YAML deployment descriptor fromfile.- Parameters:
file- the file to read from- Returns:
- the parsed descriptor
- Throws:
ExecutionException- if reading fails for some reason
-
getDescriptorName
Returns the deployment descriptor file name to use.- Returns:
- the descriptor file name
-
readFromClasspath
Reads the YAML deployment descriptor fromfile.- Returns:
- the parsed descriptor
- Throws:
ExecutionException- if reading fails for some reason
-
throwExecutionException
Throws an execution exception for the given throwable and logs an error in the same step.- Parameters:
action- the actual action to logth- the throwable- Throws:
ExecutionException- the exception based onth
-
throwExecutionException
Throws an execution exception for the given message and logs an error in the same step.- Parameters:
action- the actual action to logmessage- the message for the exception- Throws:
ExecutionException- the exception based onmessage
-
addEndpointArgs
public static void addEndpointArgs(List<String> cmdLine, Endpoint endpoint, de.iip_ecosphere.platform.support.ServerAddress addr) Adds commandline args for a givenendpoint.- Parameters:
cmdLine- the command line arguments to modify as a side effectendpoint- the endpoint to turn into command line argumentsaddr- the address containing port number and host (for substitution in results delivered byendpoint)
-
addEndpointArgs
Adds commandline args for a givenendpoint.- Parameters:
cmdLine- the command line arguments to modify as a side effectendpoint- the endpoint to turn into command line argumentsport- the port number (for substitution in results delivered byendpoint)host- the host name (for substitution in results delivered byendpoint)
-
createStandaloneCommandArgs
public static List<String> createStandaloneCommandArgs(File jar, int brokerPort, String brokerHost, int adminPort, String serviceProtocol) throws IOException, ExecutionException Creates command line args for executing the (Spring) fat JAR in standalone/debugging manner requesting the spring web server to be executed on an ephemeral port by default.- Parameters:
jar- the JAR file to readbrokerPort- the port where the transport broker is runningbrokerHost- the host where the transport broker is running (usually "localhost")adminPort- the port where to run the AAS command server, for -1 an emphemeral port will be usedserviceProtocol- the protocol to run for the AAS command server (seeAasFactory)- Returns:
- the list of command line args to use
- Throws:
IOException- ifjarcannot be found or readingjarfailsExecutionException- if extracting process artifacts fails
-
createStandaloneCommandArgs
public static List<String> createStandaloneCommandArgs(File jar, int brokerPort, String brokerHost, int adminPort, String serviceProtocol, int springPort) throws IOException, ExecutionException Creates command line args for executing the (Spring) fat JAR in standalone/debugging manner.- Parameters:
jar- the JAR file to readbrokerPort- the port where the transport broker is runningbrokerHost- the host where the transport broker is running (usually "localhost")adminPort- the port where to run the AAS command server, for -1 an emphemeral port will be usedserviceProtocol- the protocol to run for the AAS command server (seeAasFactory)springPort- the port to run the spring application server on, usually 8080, if negative an ephemeral port will be used- Returns:
- the list of command line args to use
- Throws:
IOException- ifjarcannot be found or readingjarfailsExecutionException- if extracting process artifacts fails
-
createClassLoader
Creates a class loader for a JAR file, in particular an executable Spring-packaged Jar file.- Parameters:
jarFile- the jar file- Returns:
- the class loader
- Throws:
Exception- if the class loader cannot be constructed
-
getLogger
private static de.iip_ecosphere.platform.support.logging.Logger getLogger()Returns the logger.- Returns:
- the logger
-