Class DescriptorUtils

java.lang.Object
de.iip_ecosphere.platform.services.spring.DescriptorUtils

public class DescriptorUtils extends Object
Descriptor and artifact utility functions that may be used standalone.
Author:
Holger Eichelberger, SSE
  • 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)
      Parameters:
      service - the service to change
      state - 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 notifies ServicesAas.
      Parameters:
      service - the service
      state - the new state
      Throws:
      ExecutionException - if changing the state fails
    • readFromFile

      public static YamlArtifact readFromFile(File file) throws ExecutionException
      Reads the YAML deployment descriptor from file.
      Parameters:
      file - the file to read from
      Returns:
      the parsed descriptor
      Throws:
      ExecutionException - if reading fails for some reason
    • getDescriptorName

      private static String getDescriptorName()
      Returns the deployment descriptor file name to use.
      Returns:
      the descriptor file name
    • readFromClasspath

      public static YamlArtifact readFromClasspath() throws ExecutionException
      Reads the YAML deployment descriptor from file.
      Returns:
      the parsed descriptor
      Throws:
      ExecutionException - if reading fails for some reason
    • throwExecutionException

      public static void throwExecutionException(String action, Throwable th) throws ExecutionException
      Throws an execution exception for the given throwable and logs an error in the same step.
      Parameters:
      action - the actual action to log
      th - the throwable
      Throws:
      ExecutionException - the exception based on th
    • throwExecutionException

      public static void throwExecutionException(String action, String message) throws ExecutionException
      Throws an execution exception for the given message and logs an error in the same step.
      Parameters:
      action - the actual action to log
      message - the message for the exception
      Throws:
      ExecutionException - the exception based on message
    • addEndpointArgs

      public static void addEndpointArgs(List<String> cmdLine, Endpoint endpoint, de.iip_ecosphere.platform.support.ServerAddress addr)
      Adds commandline args for a given endpoint.
      Parameters:
      cmdLine - the command line arguments to modify as a side effect
      endpoint - the endpoint to turn into command line arguments
      addr - the address containing port number and host (for substitution in results delivered by endpoint)
    • addEndpointArgs

      public static void addEndpointArgs(List<String> cmdLine, Endpoint endpoint, int port, String host)
      Adds commandline args for a given endpoint.
      Parameters:
      cmdLine - the command line arguments to modify as a side effect
      endpoint - the endpoint to turn into command line arguments
      port - the port number (for substitution in results delivered by endpoint)
      host - the host name (for substitution in results delivered by endpoint)
    • 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 read
      brokerPort - the port where the transport broker is running
      brokerHost - 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 used
      serviceProtocol - the protocol to run for the AAS command server (see AasFactory)
      Returns:
      the list of command line args to use
      Throws:
      IOException - if jar cannot be found or reading jar fails
      ExecutionException - 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 read
      brokerPort - the port where the transport broker is running
      brokerHost - 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 used
      serviceProtocol - the protocol to run for the AAS command server (see AasFactory)
      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 - if jar cannot be found or reading jar fails
      ExecutionException - if extracting process artifacts fails
    • createClassLoader

      public static ClassLoader createClassLoader(File jarFile) throws Exception
      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