Class 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 Detail

      • registered

        private static boolean registered
    • Constructor Detail

      • VelocityInstantiator

        public VelocityInstantiator()
    • 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 given configuration.
        Parameters:
        templates - the templates to be instantiated
        config - 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 given configuration.
        Parameters:
        templates - the templates to be instantiated
        config - the configuration to be considered
        nameMapping - 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 given configuration.
        Parameters:
        template - the template to be instantiated
        config - 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 given configuration.
        Parameters:
        template - the template to be instantiated
        config - the configuration to be considered
        nameMapping - 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 from
        nameMapping - 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 instantiate
        engine - the engine for instantiation
        context - the velocity context
        Returns:
        the created file artifact
        Throws:
        VilException - in case of problems