Package net.ssehub.easy.standalone.cmd
Class InstantiationCommands
java.lang.Object
net.ssehub.easy.standalone.cmd.InstantiationCommands
Static commands for instantiating projects via the command line or by a build tool. Files/Folders
to be passed in through this interface shall be absolute! This class considers
Before calling any of the methods here, EASy must be loaded via calling
ProjectNameMapper.Before calling any of the methods here, EASy must be loaded via calling
LowlevelCommands.startEASy().- Author:
- El-Sharkawy
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprivate static classListener to collectVilExceptions during script execution. -
Constructor Summary
ConstructorsModifierConstructorDescriptionprivateShould prevent instantiation of this utility class. -
Method Summary
Modifier and TypeMethodDescriptionprivate static booleancheckIsNestedFile(File possibleParent, File maybeChild) Checks whethermaybeChildis nested inside ofpossibleParent.private static net.ssehub.easy.producer.core.mgmt.VilArgumentProvidercreateArgumentProvider(Map<String, Object> arguments) Creates an argument provider and registers it withVilArgumentProviderif necessary.private static voidcreatePLPsAndInstantiate(File projectSource, File projectTarget, net.ssehub.easy.varModel.model.Project ivmlProject, net.ssehub.easy.instantiation.core.model.buildlangModel.Script buildScript, Map<String, Object> arguments) Creates two (temporary)PLPInfos, links them (sets prede-/successor), and instantiates the successor.private static voidcreateTargetFolder(File projectSource, File projectTarget) CreatesprojectTargetif it does not exist.static voidinstantiate(File projectSource, File projectTarget) Instantiates the projectprojectTarget, while using source files (and IVML/VIL information) provided byprojectSource.static voidinstantiate(File projectSource, File projectTarget, File ivmlFile, File scriptFile) UsesprojectSourceto instantiateprojectTarget.static voidinstantiate(File projectSource, File projectTarget, File ivmlFile, File scriptFile, Map<String, Object> arguments) UsesprojectSourceto instantiateprojectTarget.static voidInstantiates the projectprojectTarget, while using source files (and IVML/VIL information) provided byprojectSource.static voidinstantiate(File projectSource, File projectTarget, ModelLoadDefinition ivmlDefinition, ModelLoadDefinition vilDefinition) UsesprojectSourceto instantiateprojectTarget.static voidinstantiate(File projectSource, File projectTarget, ModelLoadDefinition ivmlDefinition, ModelLoadDefinition vilDefinition, Map<String, Object> arguments) UsesprojectSourceto instantiateprojectTarget.private static voidInstantiates the projectprojectTarget, while using source files (and IVML/VIL information) provided byprojectSource.static voidinstantiateSelf(File project) Instantiates the given project.static voidinstantiateSelf(File project, File ivmlFile) Instantiates the given project.static voidinstantiateSelf(File project, File ivmlFile, File buildScriptFile) Instantiates the given project.static voidInstantiates the given project.static voidInstantiates the given project.static voidinstantiateSelf(File project, Map<String, Object> arguments) Instantiates the given project.
-
Constructor Details
-
InstantiationCommands
private InstantiationCommands()Should prevent instantiation of this utility class.
-
-
Method Details
-
instantiateSelf
public static void instantiateSelf(File project) throws net.ssehub.easy.producer.core.persistence.PersistenceException, net.ssehub.easy.instantiation.core.model.common.VilException Instantiates the given project. The project must:- be a valid EASy project with the usual configuration files and folders.
- contain a frozen configuration
- contain VIL script which can be applied to itself
- Parameters:
project- The toplevel absolute folder of the project (must have a valid EASy structure)- Throws:
net.ssehub.easy.producer.core.persistence.PersistenceException- Will be thrown if the project could not be loaded, e.g. if the project has no valid EASy structure.net.ssehub.easy.instantiation.core.model.common.VilException- In case that artifact operations or script execution fails
-
instantiateSelf
public static void instantiateSelf(File project, Map<String, Object> arguments) throws net.ssehub.easy.producer.core.persistence.PersistenceException, net.ssehub.easy.instantiation.core.model.common.VilExceptionInstantiates the given project. The project must:- be a valid EASy project with the usual configuration files and folders.
- contain a frozen configuration
- contain VIL script which can be applied to itself
- Parameters:
project- The toplevel absolute folder of the project (must have a valid EASy structure)arguments- a name-element mapping specifying the top-level parameter of a VIL instantiation (may be null)- Throws:
net.ssehub.easy.producer.core.persistence.PersistenceException- Will be thrown if the project could not be loaded, e.g. if the project has no valid EASy structure.net.ssehub.easy.instantiation.core.model.common.VilException- In case that artifact operations or script execution fails
-
instantiateSelf
public static void instantiateSelf(File project, File ivmlFile) throws net.ssehub.easy.basics.modelManagement.ModelManagementException, net.ssehub.easy.instantiation.core.model.common.VilException, net.ssehub.easy.producer.core.persistence.PersistenceException Instantiates the given project. The project must:- contain VIL script which can be applied to itself, which uses the usual EASy naming convention for VIL scripts in Version 0.
instantiateSelf(File, File, Map)with null as arguments.- Parameters:
project- The toplevel absolute folder of the projectivmlFile- A frozen configuration, which should be used for instantiation.- Throws:
net.ssehub.easy.basics.modelManagement.ModelManagementException- In case that the available information may be come inconsistent due to this updatenet.ssehub.easy.instantiation.core.model.common.VilException- In case that artifact operations or script execution failsnet.ssehub.easy.producer.core.persistence.PersistenceException- Will be thrown if at least one of the IVML or VIL files could not be loaded.
-
instantiateSelf
public static void instantiateSelf(File project, File ivmlFile, Map<String, Object> arguments) throws net.ssehub.easy.basics.modelManagement.ModelManagementException, net.ssehub.easy.instantiation.core.model.common.VilException, net.ssehub.easy.producer.core.persistence.PersistenceExceptionInstantiates the given project. The project must:- contain VIL script which can be applied to itself, which uses the usual EASy naming convention for VIL scripts in Version 0.
- Parameters:
project- The toplevel absolute folder of the projectivmlFile- A frozen configuration, which should be used for instantiation.arguments- a name-element mapping specifying the top-level parameter of a VIL instantiation (may be null)- Throws:
net.ssehub.easy.basics.modelManagement.ModelManagementException- In case that the available information may be come inconsistent due to this updatenet.ssehub.easy.instantiation.core.model.common.VilException- In case that artifact operations or script execution failsnet.ssehub.easy.producer.core.persistence.PersistenceException- Will be thrown if at least one of the IVML or VIL files could not be loaded.
-
instantiateSelf
public static void instantiateSelf(File project, File ivmlFile, File buildScriptFile) throws net.ssehub.easy.basics.modelManagement.ModelManagementException, net.ssehub.easy.instantiation.core.model.common.VilException, net.ssehub.easy.producer.core.persistence.PersistenceException Instantiates the given project.
It's not necessary that the project has a valid EASy structure. This method is a convenience wrapper forinstantiateSelf(File, File, File, Map)with null as arguments.- Parameters:
project- The toplevel absolute folder of the projectivmlFile- A frozen configuration, which should be used for instantiation.buildScriptFile- The main build script (starting point) which should be used for instantiation.- Throws:
net.ssehub.easy.basics.modelManagement.ModelManagementException- In case that the available information may become inconsistent due to this updatenet.ssehub.easy.instantiation.core.model.common.VilException- In case that artifact operations or script execution failsnet.ssehub.easy.producer.core.persistence.PersistenceException- Will be thrown if at least one of the IVML or VIL files could not be loaded.
-
instantiateSelf
public static void instantiateSelf(File project, File ivmlFile, File buildScriptFile, Map<String, Object> arguments) throws net.ssehub.easy.basics.modelManagement.ModelManagementException, net.ssehub.easy.instantiation.core.model.common.VilException, net.ssehub.easy.producer.core.persistence.PersistenceExceptionInstantiates the given project.
It's not necessary that the project has a valid EASy structure.- Parameters:
project- The toplevel absolute folder of the projectivmlFile- A frozen configuration, which should be used for instantiation.buildScriptFile- The main build script (starting point) which should be used for instantiation.arguments- a name-element mapping specifying the top-level parameter of a VIL instantiation (may be null)- Throws:
net.ssehub.easy.basics.modelManagement.ModelManagementException- In case that the available information may become inconsistent due to this updatenet.ssehub.easy.instantiation.core.model.common.VilException- In case that artifact operations or script execution failsnet.ssehub.easy.producer.core.persistence.PersistenceException- Will be thrown if at least one of the IVML or VIL files could not be loaded.
-
createArgumentProvider
private static net.ssehub.easy.producer.core.mgmt.VilArgumentProvider createArgumentProvider(Map<String, Object> arguments) Creates an argument provider and registers it withVilArgumentProviderif necessary.- Parameters:
arguments- the arguments to be passed to VIL (may be null)- Returns:
- the argument provider if one was created and registered, null else
-
instantiate
public static void instantiate(File projectSource, File projectTarget) throws net.ssehub.easy.producer.core.persistence.PersistenceException, net.ssehub.easy.instantiation.core.model.common.VilException, IOException Instantiates the projectprojectTarget, while using source files (and IVML/VIL information) provided byprojectSource. The following conditions must be hold:- Both projects must exist and have a valid EASy project structure with the usual configuration files, IDs, and folders.
projectTargetmust contain a contain a frozen configuration.projectTargetmust contain VIL script.projectSourcemust contain a infrastructure, which cen be instantiated, e.g. annotated source files.
projectTargetdoes not exist, this method will create the folder. In this case, 2.) and 3.) must be included inprojectSource. This method is a convenience wrapper forinstantiate(File, File, Map)with null as arguments.- Parameters:
projectSource- The toplevel absolute folder of an EASy project (must have a valid EASy structure), which serves as a basis for instantiation.projectTarget- The toplevel absolute folder of an EASy project (must have a valid EASy structure), which should be instantiated.- Throws:
net.ssehub.easy.producer.core.persistence.PersistenceException- Will be thrown if one of the projects could not be loaded, e.g. if the project has no valid EASy structure.net.ssehub.easy.instantiation.core.model.common.VilException- In case that artifact operations or script execution failsIOException- If source or destination is invalid, or if an IO error occurs during copying
-
instantiate
public static void instantiate(File projectSource, File projectTarget, Map<String, Object> arguments) throws net.ssehub.easy.producer.core.persistence.PersistenceException, net.ssehub.easy.instantiation.core.model.common.VilException, IOExceptionInstantiates the projectprojectTarget, while using source files (and IVML/VIL information) provided byprojectSource. The following conditions must be hold:- Both projects must exist and have a valid EASy project structure with the usual configuration files, IDs, and folders.
projectTargetmust contain a contain a frozen configuration.projectTargetmust contain VIL script.projectSourcemust contain a infrastructure, which cen be instantiated, e.g. annotated source files.
projectTargetdoes not exist, this method will create the folder. In this case, 2.) and 3.) must be included inprojectSource.- Parameters:
projectSource- The toplevel absolute folder of an EASy project (must have a valid EASy structure), which serves as a basis for instantiation.projectTarget- The toplevel absolute folder of an EASy project (must have a valid EASy structure), which should be instantiated.arguments- a name-element mapping specifying the top-level parameter of a VIL instantiation (may be null)- Throws:
net.ssehub.easy.producer.core.persistence.PersistenceException- Will be thrown if one of the projects could not be loaded, e.g. if the project has no valid EASy structure.net.ssehub.easy.instantiation.core.model.common.VilException- In case that artifact operations or script execution failsIOException- If source or destination is invalid, or if an IO error occurs during copying
-
instantiateEASyProjects
private static void instantiateEASyProjects(File projectSource, File projectTarget, Map<String, Object> arguments) throws net.ssehub.easy.producer.core.persistence.PersistenceException, net.ssehub.easy.instantiation.core.model.common.VilExceptionInstantiates the projectprojectTarget, while using source files (and IVML/VIL information) provided byprojectSource. The following conditions must be hold:- Both projects must exist and have a valid EASy project structure with the usual configuration files, IDs, and folders.
projectTargetmust contain a contain a frozen configuration.projectTargetmust contain VIL script.projectSourcemust contain a infrastructure, which can be instantiated, e.g. annotated source files.
- Parameters:
projectSource- The toplevel absolute folder of an EASy project (must have a valid EASy structure), which serves as a basis for instantiation.projectTarget- The toplevel absolute folder of an EASy project (must have a valid EASy structure), which should be instantiated.arguments- a name-element mapping specifying the top-level parameter of a VIL instantiation (may be null)- Throws:
net.ssehub.easy.producer.core.persistence.PersistenceException- Will be thrown if one of the projects could not be loaded, e.g. if the project has no valid EASy structure.net.ssehub.easy.instantiation.core.model.common.VilException- In case that artifact operations or script execution fails
-
instantiate
public static void instantiate(File projectSource, File projectTarget, File ivmlFile, File scriptFile) throws net.ssehub.easy.basics.modelManagement.ModelManagementException, SecurityException, net.ssehub.easy.producer.core.persistence.PersistenceException, net.ssehub.easy.instantiation.core.model.common.VilException, IOException UsesprojectSourceto instantiateprojectTarget. The folderprojectTargetwill be created, if it does not exist. This method is a convenience wrapper forinstantiate(File, File, File, File, Map)with null as arguments.- Parameters:
projectSource- An absolute folder/project, which contains the product line infrastructure, i.e. files to instantiate.projectTarget- An absolute folder/project where the files should be instantiated in. The folder will be created if it does not exist.ivmlFile- The model definition including its frozen configuration, which should be used for instantiation. (Must be inside either ofprojectSourceorprojectTarget).scriptFile- The main build script (starting point) which should be used for instantiation. (Must be inside either ofprojectSourceorprojectTarget).- Throws:
SecurityException- IfprojectTargetdoes not exist, a security manager exists, and itsmethod does not permitSecurityManager.checkWrite(java.lang.String)projectTargetdirectory to be creatednet.ssehub.easy.basics.modelManagement.ModelManagementException- In case that the available information may become inconsistent due to this updatenet.ssehub.easy.instantiation.core.model.common.VilException- In case that artifact operations or script execution failsnet.ssehub.easy.producer.core.persistence.PersistenceException- Will be thrown if at least one of the IVML or VIL files could not be loaded.IOException- If source or destination is invalid, or if an IO error occurs during copying
-
instantiate
public static void instantiate(File projectSource, File projectTarget, File ivmlFile, File scriptFile, Map<String, Object> arguments) throws net.ssehub.easy.basics.modelManagement.ModelManagementException, SecurityException, net.ssehub.easy.producer.core.persistence.PersistenceException, net.ssehub.easy.instantiation.core.model.common.VilException, IOExceptionUsesprojectSourceto instantiateprojectTarget. The folderprojectTargetwill be created, if it does not exist.- Parameters:
projectSource- An absolute folder/project, which contains the product line infrastructure, i.e. files to instantiate.projectTarget- An absolute folder/project where the files should be instantiated in. The folder will be created if it does not exist.ivmlFile- The model definition including its frozen configuration, which should be used for instantiation. (Must be inside either ofprojectSourceorprojectTarget).scriptFile- The main build script (starting point) which should be used for instantiation. (Must be inside either ofprojectSourceorprojectTarget).arguments- a name-element mapping specifying the top-level parameter of a VIL instantiation (may be null)- Throws:
SecurityException- IfprojectTargetdoes not exist, a security manager exists, and itsmethod does not permitSecurityManager.checkWrite(java.lang.String)projectTargetdirectory to be creatednet.ssehub.easy.basics.modelManagement.ModelManagementException- In case that the available information may become inconsistent due to this updatenet.ssehub.easy.instantiation.core.model.common.VilException- In case that artifact operations or script execution failsnet.ssehub.easy.producer.core.persistence.PersistenceException- Will be thrown if at least one of the IVML or VIL files could not be loaded.IOException- If source or destination is invalid, or if an IO error occurs during copying
-
createPLPsAndInstantiate
private static void createPLPsAndInstantiate(File projectSource, File projectTarget, net.ssehub.easy.varModel.model.Project ivmlProject, net.ssehub.easy.instantiation.core.model.buildlangModel.Script buildScript, Map<String, Object> arguments) throws net.ssehub.easy.instantiation.core.model.common.VilExceptionCreates two (temporary)PLPInfos, links them (sets prede-/successor), and instantiates the successor.- Parameters:
projectSource- An absolute folder/project, which contains the product line infrastructure, i.e. files to instantiate.projectTarget- An existing absolute folder/project where the files should be instantiated in.ivmlProject- A loaded configuration, which should be used for instantiation (Must not benull).buildScript- A loaded build script, which should be used for instantiation (Must not benull).arguments- a name-element mapping specifying the top-level parameter of a VIL instantiation (may be null)- Throws:
net.ssehub.easy.instantiation.core.model.common.VilException- In case that artifact operations or script execution fails
-
instantiate
public static void instantiate(File projectSource, File projectTarget, ModelLoadDefinition ivmlDefinition, ModelLoadDefinition vilDefinition) throws net.ssehub.easy.producer.core.persistence.PersistenceException, IOException, net.ssehub.easy.basics.modelManagement.ModelManagementException, net.ssehub.easy.instantiation.core.model.common.VilException UsesprojectSourceto instantiateprojectTarget. The folderprojectTargetwill be created, if it does not exist. This method is a convenience wrapper forinstantiate(File, File, ModelLoadDefinition, ModelLoadDefinition, Map)with null as arguments.- Parameters:
projectSource- An absolute folder/project, which contains the product line infrastructure, i.e. files to instantiate.projectTarget- An absolute folder/project where the files should be instantiated in. The folder will be created if it does not exist.ivmlDefinition- A (model name, version) pair for specifying whichProjectshould be used for instantantion. TheProjectmust be located inside ofprojectTargetorprojectSource. This method first tries to load theProjectfrom theprojectTargetbefore it tries to load theProjectfrom theprojectSource.vilDefinition- A (model name, version) pair for specifying whichScriptshould be used for instantantion. TheScriptmust be located inside ofprojectTargetorprojectSource. This method first tries to load theScriptfrom theprojectTargetbefore it tries to load theScriptfrom theprojectSource.- Throws:
net.ssehub.easy.producer.core.persistence.PersistenceException- Will be thrown if at least one of the IVML or VIL files could not be loaded.IOException- If source or destination is invalid, or if an IO error occurs during copyingnet.ssehub.easy.basics.modelManagement.ModelManagementException- In case that the available information may become inconsistent due to this updatenet.ssehub.easy.instantiation.core.model.common.VilException- In case that artifact operations or script execution fails
-
instantiate
public static void instantiate(File projectSource, File projectTarget, ModelLoadDefinition ivmlDefinition, ModelLoadDefinition vilDefinition, Map<String, Object> arguments) throws net.ssehub.easy.producer.core.persistence.PersistenceException, IOException, net.ssehub.easy.basics.modelManagement.ModelManagementException, net.ssehub.easy.instantiation.core.model.common.VilExceptionUsesprojectSourceto instantiateprojectTarget. The folderprojectTargetwill be created, if it does not exist.- Parameters:
projectSource- An absolute folder/project, which contains the product line infrastructure, i.e. files to instantiate.projectTarget- An absolute folder/project where the files should be instantiated in. The folder will be created if it does not exist.ivmlDefinition- A (model name, version) pair for specifying whichProjectshould be used for instantantion. TheProjectmust be located inside ofprojectTargetorprojectSource. This method first tries to load theProjectfrom theprojectTargetbefore it tries to load theProjectfrom theprojectSource.vilDefinition- A (model name, version) pair for specifying whichScriptshould be used for instantantion. TheScriptmust be located inside ofprojectTargetorprojectSource. This method first tries to load theScriptfrom theprojectTargetbefore it tries to load theScriptfrom theprojectSource.arguments- a name-element mapping specifying the top-level parameter of a VIL instantiation (may be null)- Throws:
net.ssehub.easy.producer.core.persistence.PersistenceException- Will be thrown if at least one of the IVML or VIL files could not be loaded.IOException- If source or destination is invalid, or if an IO error occurs during copyingnet.ssehub.easy.basics.modelManagement.ModelManagementException- In case that the available information may become inconsistent due to this updatenet.ssehub.easy.instantiation.core.model.common.VilException- In case that artifact operations or script execution fails
-
checkIsNestedFile
Checks whethermaybeChildis nested inside ofpossibleParent.- Parameters:
possibleParent- A folder which may containmaybeChild.maybeChild- A file or folder which should be located inside ofpossibleParent.- Returns:
trueifmaybeChildis nested inside ofpossibleParent,falseotherwise.- See Also:
-
createTargetFolder
private static void createTargetFolder(File projectSource, File projectTarget) throws net.ssehub.easy.producer.core.persistence.PersistenceException, IOException CreatesprojectTargetif it does not exist. Copies also all configuration files, i.e. the EASy folder fromprojectSourcetoprojectTarget.- Parameters:
projectSource- A EASy project which contains a EASy folder with IVML/VIL files.projectTarget- The folder which shall be created.- Throws:
net.ssehub.easy.producer.core.persistence.PersistenceException- Will be thrown if the folder could not be created.IOException- If source or destination is invalid, or if an IO error occurs during copying
-