FileDocCategorySizeDatePackage
DeploymentMetaData.javaAPI DocJBoss 4.2.15558Fri Jul 13 20:52:34 BST 2007org.jboss.deployment.spi

DeploymentMetaData

public class DeploymentMetaData extends Object
MetaData to the JBoss deployment plan.
author
Thomas.Diesler@jboss.org
since
09-Apr-2004

Fields Summary
private static Logger
log
public static final String
ENTRY_NAME
The entry name in the deployment plan archive
private String
deploymentName
private List
entryList
Constructors Summary
public DeploymentMetaData(String deploymentName)


     
   
      this.deploymentName = deploymentName;
   
public DeploymentMetaData(org.dom4j.Document document)

      init(document);
   
Methods Summary
public java.lang.StringaddEntry(java.lang.String archiveName, java.lang.String descriptorName)
Add an entry and return an id for that entry

      entryList.add(new Entry(archiveName, descriptorName));

      String entryId = "entry_";
      int count = entryList.size();
      if (count < 100)
         entryId += "0";
      if (count < 10)
         entryId += "0";

      return entryId + count;
   
public java.lang.StringgetDeploymentName()

      return deploymentName;
   
public org.dom4j.DocumentgetDocument()

      Document document = DocumentHelper.createDocument();
      Element root = document.addElement("jboss-deployment-plan");

      root.addElement("deployment-name").addText(deploymentName);

      root.addComment("Note, deployment-entry elements are not used by the DeploymentManager");
      root.addComment("The DeploymentManager relies on the the entry nameing convention");

      Iterator it = entryList.iterator();
      while (it.hasNext())
      {
         Entry entry = (Entry)it.next();
         Element element = root.addElement("deployment-entry");
         element.addElement("archive-name").addText(entry.archiveName);
         element.addElement("descriptor-name").addText(entry.descriptorName);
      }

      return document;
   
public java.util.ListgetEntryList()

      return new ArrayList(entryList);
   
public booleanhasEntry(java.lang.String archiveName, java.lang.String descriptorName)

      return entryList.contains(new Entry(archiveName, descriptorName));
   
private voidinit(org.dom4j.Document document)

      Element root = document.getRootElement();
      deploymentName = root.elementTextTrim("deployment-name");
      Iterator it = root.elementIterator("deployment-entry");
      while (it.hasNext())
      {
         Element element = (Element)it.next();
         String archiveName = element.elementTextTrim("archive-name");
         String descriptorName = element.elementTextTrim("descriptor-name");
         addEntry(archiveName, descriptorName);
      }
   
public voidsetDeploymentName(java.lang.String deploymentName)

      this.deploymentName = deploymentName;
   
public java.lang.StringtoXMLString()

      try
      {
         OutputFormat format = OutputFormat.createPrettyPrint();
         StringWriter strWriter = new StringWriter(1024);
         XMLWriter metaWriter = new XMLWriter(strWriter, format);
         metaWriter.write(getDocument());
         metaWriter.close();
         return strWriter.toString();
      }
      catch (IOException e)
      {
         log.error("Cannot get XML string", e);
         return null;
      }