Class PlatformInstantiator.InstantiationConfigurer

java.lang.Object
de.iip_ecosphere.platform.configuration.PlatformInstantiator.InstantiationConfigurer
Direct Known Subclasses:
PlatformInstantiator.NonCleaningInstantiationConfigurer
Enclosing class:
PlatformInstantiator

public static class PlatformInstantiator.InstantiationConfigurer extends Object
Configures the instantiation. Default is for command line execution, but the configurer allows for adjusting the execution to jUnit testing.
Author:
Holger Eichelberger, SSE
  • Field Details

    • ivmlModelName

      private String ivmlModelName
    • outputFolder

      private File outputFolder
    • modelFolder

      private File modelFolder
    • metaModelFolder

      private File metaModelFolder
    • startRuleName

      private String startRuleName
    • properties

      private Map<String,String> properties
    • emitReasonerWarnings

      private boolean emitReasonerWarnings
  • Constructor Details

    • InstantiationConfigurer

      public InstantiationConfigurer(String ivmlModelName, File modelFolder, File outputFolder)
      Creates a configurer instance.
      Parameters:
      ivmlModelName - the name of the IVML model representing the topmost platform configuration
      modelFolder - the folder where the model is located (ignored if null)
      outputFolder - the output folder for code generation
    • InstantiationConfigurer

      public InstantiationConfigurer(String[] args)
      Creates a configurer instance from command line arguments delivered by toArgs(boolean).
      Parameters:
      args - the command line arguments
  • Method Details

    • getLastArgsIndex

      protected int getLastArgsIndex(String[] args)
      Returns the last command line argument index consumed by this configurer.
      Parameters:
      args - the command line arguments
      Returns:
      the index
    • fromArg

      protected File fromArg(String file)
      Turns a textual file name into a file object.
      Parameters:
      file - the file name
      Returns:
      the file, may be null if file was null or "-"
    • toArg

      protected String toArg(File file)
      Turns a file name into a textual file specification.
      Parameters:
      file - the file
      Returns:
      the file specification, may be "-" if file was null
    • getMainClass

      public String getMainClass()
      Returns the qualified name of the class containing a main method for execution through PlatformInstantiatorExecutor.
      Returns:
      the class name of PlatformInstantiator
    • inTesting

      public boolean inTesting()
      Returns whether this configurer is currently used for testing.
      Returns:
      false for production (the default), true for testing
    • toArgs

      public String[] toArgs(boolean all)
      Turns this configurer into command line arguments.
      Parameters:
      all - true add all arguments for passong on setup between configurers, false only command line arguments for execution
      Returns:
      the arguments
    • isEmitReasonerWarnings

      protected boolean isEmitReasonerWarnings()
      Returns whether reasoning warnings shall be emitted.
      Returns:
      true for warnings, false else
    • emitReasonerWarnings

      public PlatformInstantiator.InstantiationConfigurer emitReasonerWarnings()
      Enables emitting reasoner warnings.
      Returns:
      this (builder style)
    • setStartRuleName

      public PlatformInstantiator.InstantiationConfigurer setStartRuleName(String startRuleName)
      Optionally sets the start rule name. The default name is "main".
      Parameters:
      startRuleName - the start rule name
      Returns:
      this (builder style)
    • setIvmlMetaModelFolder

      public PlatformInstantiator.InstantiationConfigurer setIvmlMetaModelFolder(File metaModelFolder)
      Changes the meta model folder.
      Parameters:
      metaModelFolder - the meta model folder (ignored if null or does not exist)
      Returns:
      the meta model folder
    • configure

      public void configure(ConfigurationSetup setup)
      Configures the platform instantiation via the given ConfigurationSetup.
      Parameters:
      setup - the setup instance
    • getStartRuleName

      public String getStartRuleName()
      Returns the VIL start rule name. [public for testing]
      Returns:
      the VIL start rule name
    • getIvmlModelName

      public String getIvmlModelName()
      Returns the IVML model name. [testing]
      Returns:
      the model name
    • getOutputFolder

      public File getOutputFolder()
      Returns the VIL output folder. [testing]
      Returns:
      the output folder
    • getModelFolder

      public File getModelFolder()
      Returns the model folder. [testing]
      Returns:
      the model folder
    • getMetaModelFolder

      public File getMetaModelFolder()
      Returns the meta model folder. [testing]
      Returns:
      the meta model folder
    • cleanOutputFolder

      protected boolean cleanOutputFolder()
      Returns whether the output folder shall be cleaned before code generation.
      Returns:
      true for clean, false else
    • obtainLifecycleDescriptor

      public ConfigurationLifecycleDescriptor obtainLifecycleDescriptor()
      Obtains the lifecycle descriptor.
      Returns:
      the descriptor
    • validateConfiguration

      protected void validateConfiguration(net.ssehub.easy.varModel.confModel.Configuration conf) throws ExecutionException
      Validates the configuration after reasoning. May terminate the program or throw an exception.
      Parameters:
      conf - the configuration
      Throws:
      ExecutionException - if the validation fails
    • validateReasoningResult

      protected void validateReasoningResult(net.ssehub.easy.reasoning.core.reasoner.ReasoningResult res) throws ExecutionException
      Validates the reasoning result. May terminate the program or throw an exception.
      Parameters:
      res - the reasoning result
      Throws:
      ExecutionException - if reasoning fails
    • handleExecutionException

      protected void handleExecutionException(ExecutionException ex) throws ExecutionException
      Handles an instantiation exception.
      Parameters:
      ex - the exception
      Throws:
      ExecutionException - may re-throw the exception
    • setProperty

      Sets a JVM system property for execution.
      Parameters:
      key - the key
      value - the value
    • getProperties

      public Map<String,String> getProperties()
      Returns the properties.
      Returns:
      the properties