1 Reply Latest reply on Jul 28, 2005 11:53 PM by Scott Stark

    additionaldata, I don't get it

    Andrew Oliver Master

      How does the additionaldata tag work?

      I have:

       <pack name="Base" required="yes">
       <description>The base files</description>
       <file src="README.txt" targetdir="$INSTALL_PATH"/>
       <file src="license/jbmail.license" targetdir="$INSTALL_PATH"/>
       <fileset dir="build/deploy/dev"
       <include name="mail.ear/**"/>
       <additionaldata key="jboss-service.xml" value="mail.ear/mail.sar/META-INF/jboss-service.xml.vm" />
       <!--file src="script.bat" targetdir="$INSTALL_PATH"/-->
       <!--parsable targetfile="$INSTALL_PATH/script.bat"/--> <!-- The file will be parsed -->
      yet the .vm file has no effect (it is supposed to omit a section if smtp is not enabled)...
      I have the jboss listeners and crap and the JBoss izpack:
       <listener installer="SummaryLoggerInstallerListener"/>
       <jar src="src/GRAPHICAL/templates.jar" />
       <jar src="lib/velocity.jar" />
       <jar src="lib/commons-collections.jar" />
       <jar src="lib/logkit.jar" />


      1. Any clues on how that works? (additionaldata)
      2. Where can I find the jboss install package/friends? (additionaldata in particular)

        • 1. Re: additionaldata, I don't get it
          Scott Stark Master

          additionaldata only applies to filesets. See the jboss-izpack module that contains the project source/build for the jboss-listeners.jar. Only the PackageListener.afterFile event callback applies templates if there is associated additional data:

           * JBoss, Home of Professional Open Source
           * Distributable under LGPL license.
           * See terms of license at gnu.org.
          package org.jboss.install;
          import java.io.File;
          import java.io.BufferedWriter;
          import java.io.FileWriter;
          import java.util.List;
          import java.util.Map;
          import com.izforge.izpack.event.InstallerListener;
          import com.izforge.izpack.installer.AutomatedInstallData;
          import com.izforge.izpack.Pack;
          import com.izforge.izpack.PackFile;
          import com.izforge.izpack.util.AbstractUIProgressHandler;
          import com.izforge.izpack.util.Debug;
          import org.apache.velocity.app.VelocityEngine;
          import org.apache.velocity.VelocityContext;
           * An InstallerListener that performs transforms of files marked with
           * additional data in the afterFile event.
           * @author Scott.Stark@jboss.org
           * @version $Revision:$
          public class PackageListener
           implements InstallerListener
           private AutomatedInstallData installData;
           private List activeDependencies;
           private String installDir;
           private VelocityEngine ve;
           public PackageListener()
           File log = new File("install.log");
           System.out.println("PackageListener, install.log="+log.getAbsolutePath());
           * Object the selected packs and add the service dependencies.
           * @param data
           * @param id
           * @param handler
           * @throws Exception
           public void beforePacks(AutomatedInstallData data,
           Integer id, AbstractUIProgressHandler handler)
           throws Exception
           installData = data;
           StringBuffer tmp = new StringBuffer("beforePacks, selectedPacks:\n");
           List selectedPacks = (List) data.selectedPacks;
           for(int n = 0; n < selectedPacks.size(); n ++)
           Pack p = (Pack) selectedPacks.get(n);
           tmp.append("depends: ");
           tmp.append(", variables: "+installData.getVariables());
           installDir = installData.getInstallPath();
           // Initialise velocity engine
           ve = new VelocityEngine();
           ve.setProperty("resource.loader", "class");
           Debug.trace("Initialized VelocityEngine");
           public void beforePack(Pack pack, Integer n, AbstractUIProgressHandler handler)
           throws Exception
           Debug.trace("beforePack, pack="+pack.name);
           activeDependencies = pack.getDependencies();
           public boolean isFileListener()
           return true;
           public void beforeDir(File file, PackFile packFile)
           throws Exception
           Debug.trace("beforeDir, file="+file+", packFile="+packFile.sourcePath);
           public void afterDir(File file, PackFile packFile)
           throws Exception
           Debug.trace("afterDir, file="+file+", packFile="+packFile.sourcePath);
           public void beforeFile(File file, PackFile packFile)
           throws Exception
           Debug.trace("beforeFile, file="+file+", packFile="+packFile.sourcePath);
           public void afterFile(File file, PackFile packFile)
           throws Exception
           Map data = packFile.getAdditionals();
           Debug.trace("afterFile, file="+file+", sourcePath="+packFile.sourcePath
           +", targetPath="+packFile.getTargetPath()+", data="+data);
           if( data != null )
           String template = (String) data.get(file.getName());
           if( template != null )
           Debug.trace("Saw template:"+template);
           String filePath = file.toURI().getPath();
           String templatePath = filePath + ".vm";
           if( templatePath.endsWith(template) == true )
           templatePath = "templates/" + template;
           applyTemplate(templatePath, file, packFile, data);
           public void afterPack(Pack pack, Integer n,
           AbstractUIProgressHandler abstractUIProgressHandler)
           throws Exception
           Debug.trace("afterPack, pack="+pack.name);
           public void afterPacks(AutomatedInstallData automatedInstallData,
           AbstractUIProgressHandler handler)
           throws Exception
           private void applyTemplate(String template, File file, PackFile packFile, Map data)
           Debug.trace("applyTemplate, template="+template);
           VelocityContext vc = new VelocityContext(installData.getVariables());
           vc.put("template-error", "");
           Debug.trace("VC.secureJmxConsole = "+vc.get("secureJmxConsole"));
           BufferedWriter out = new BufferedWriter(new FileWriter(file));
           boolean success = ve.mergeTemplate(template, vc, out);
           Debug.trace("Applied template: "+template+", success="+success);
           catch(Throwable e)
           Debug.error("Failed to apply: "+template);

          The jboss-izpack module can be checkes out from cvs.forge.jboss.com
          cvs -z4 -d :ext:starksm@cvs.forge.jboss.com:/cvsroot/jboss co -d -P jboss-izpack