Class VelocityInstantiator
- java.lang.Object
-
- net.ssehub.easy.instantiation.velocity.VelocityInstantiator
-
- All Implemented Interfaces:
IRegistration,IVilType
public class VelocityInstantiator extends java.lang.Object implements IVilType, IRegistration
A VIL instantiator for velocity.- Author:
- Holger Eichelberger, Sascha El-Sharkawy
-
-
Field Summary
Fields Modifier and Type Field Description private static booleanregistered
-
Constructor Summary
Constructors Constructor Description VelocityInstantiator()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description protected voidactivate(org.osgi.service.component.ComponentContext context)Private method to activate plugin.private static org.apache.velocity.VelocityContextcreateContext(Configuration config, Map<?,?> nameMapping)Creates the velocity context.private static org.apache.velocity.app.VelocityEnginecreateEngine()Creates the velocity engine with local configuration.protected voiddeactivate(org.osgi.service.component.ComponentContext context)Private method to to de-activate plugin.private static FileArtifactinstantiate(FileArtifact template, org.apache.velocity.app.VelocityEngine engine, org.apache.velocity.VelocityContext context)Instantiate a single file artifact.static voidregister()Registers the Java artifacts and instantiators.static Set<FileArtifact>velocity(Path template, Configuration config)Instantiates a single file artifact using the givenconfiguration.static Set<FileArtifact>velocity(Path template, Configuration config, Map<?,?> nameMapping)Instantiates a single file artifact using the givenconfiguration.static Set<FileArtifact>velocity(Collection<FileArtifact> templates, Configuration config)Instantiates a collection of file artifacts using the givenconfiguration.static Set<FileArtifact>velocity(Collection<FileArtifact> templates, Configuration config, Map<?,?> nameMapping)Instantiates a collection of file artifacts using the givenconfiguration.
-
-
-
Method Detail
-
register
public static final void register()
Registers the Java artifacts and instantiators.
-
activate
protected void activate(org.osgi.service.component.ComponentContext context)
Private method to activate plugin.- Parameters:
context- Context.
-
deactivate
protected void deactivate(org.osgi.service.component.ComponentContext context)
Private method to to de-activate plugin.- Parameters:
context- Context.
-
velocity
public static Set<FileArtifact> velocity(Collection<FileArtifact> templates, Configuration config) throws VilException
Instantiates a collection of file artifacts using the givenconfiguration.- Parameters:
templates- the templates to be instantiatedconfig- the configuration to be considered- Returns:
- the modified artifacts
- Throws:
VilException- In case that instantiation fails
-
velocity
public static Set<FileArtifact> velocity(Collection<FileArtifact> templates, Configuration config, Map<?,?> nameMapping) throws VilException
Instantiates a collection of file artifacts using the givenconfiguration.- Parameters:
templates- the templates to be instantiatedconfig- the configuration to be considerednameMapping- an optional mapping from IVML names to names used in the target artifact(s)- Returns:
- the modified artifacts
- Throws:
VilException- in case that instantiation fails
-
createEngine
private static org.apache.velocity.app.VelocityEngine createEngine()
Creates the velocity engine with local configuration.- Returns:
- the actual velocity engine instance
-
velocity
public static Set<FileArtifact> velocity(Path template, Configuration config) throws VilException
Instantiates a single file artifact using the givenconfiguration.- Parameters:
template- the template to be instantiatedconfig- the configuration to be considered- Returns:
- the modified artifact
- Throws:
VilException- in case that instantiation fails
-
velocity
public static Set<FileArtifact> velocity(Path template, Configuration config, Map<?,?> nameMapping) throws VilException
Instantiates a single file artifact using the givenconfiguration.- Parameters:
template- the template to be instantiatedconfig- the configuration to be considerednameMapping- an optional mapping from IVML names to names used in the target artifact(s)- Returns:
- the modified artifact
- Throws:
VilException- in case that instantiation fails
-
createContext
private static final org.apache.velocity.VelocityContext createContext(Configuration config, Map<?,?> nameMapping)
Creates the velocity context.- Parameters:
config- the configuration to create the context fromnameMapping- an optional mapping from IVML names to names used in the target artifact(s)- Returns:
- the velocity context
-
instantiate
private static final FileArtifact instantiate(FileArtifact template, org.apache.velocity.app.VelocityEngine engine, org.apache.velocity.VelocityContext context) throws VilException
Instantiate a single file artifact.- Parameters:
template- the template to instantiateengine- the engine for instantiationcontext- the velocity context- Returns:
- the created file artifact
- Throws:
VilException- in case of problems
-
-