FileDocCategorySizeDatePackage
AppClientParsingDeployer.javaAPI DocJBoss 4.2.14222Fri Jul 13 20:53:48 BST 2007org.jboss.ejb3.deployers

AppClientParsingDeployer

public class AppClientParsingDeployer extends org.jboss.deployers.plugins.deployers.helpers.ObjectModelFactoryDeployer
Comment
author
Carlo de Wolf
version
$Revision: $

Fields Summary
private String
appClientXmlPath
Constructors Summary
public AppClientParsingDeployer()

   
    
   
      super(ApplicationClientDD.class);
   
Methods Summary
private booleanaccepts(org.jboss.deployers.spi.deployer.DeploymentUnit unit)
This method looks to the deployment for a META-INF/application-client.xml descriptor to identify a j2ee client jar.

      boolean accepts = false;

      // The jar must contain an META-INF/application-client.xml
      VirtualFile dd = unit.getMetaDataFile(appClientXmlPath);
      if (dd != null)
      {
         log.debug("Found application-client.xml file: " + unit.getName());
         try
         {
            Element root = DOMUtils.parse(dd.openStream());
            String namespaceURI = root.getNamespaceURI();
            // Accept the J2EE5 namespace
            accepts = "http://java.sun.com/xml/ns/javaee".equals(namespaceURI);
            if (accepts == false)
               log.debug("Ignore application-client.xml with namespace: " + namespaceURI);
         }
         catch (IOException ex)
         {
            DeploymentException.rethrowAsDeploymentException("Cannot parse " + appClientXmlPath, ex);
         }
      }

      if(accepts)
      {
         // in the cts there are apps with application-client with version 5
         // and jboss-client with version 4
         dd = unit.getMetaDataFile("jboss-client.xml");
         if (dd != null)
         {
            log.debug("Found jboss-client.xml file: " + unit.getName());
            try
            {
               Element root = DOMUtils.parse(dd.openStream());
               DocumentType doctype = root.getOwnerDocument().getDoctype();
               String publicId = (doctype != null ? doctype.getPublicId() : null);

               accepts = !"-//JBoss//DTD Application Client 4.0//EN".equals(publicId);
            }
            catch (IOException ex)
            {
               DeploymentException.rethrowAsDeploymentException("Cannot parse " + appClientXmlPath, ex);
            }
         }
      }

      return accepts;
   
public voiddeploy(org.jboss.deployers.spi.deployer.DeploymentUnit unit)

      if (accepts(unit))
         createMetaData(unit, appClientXmlPath, null);
   
protected org.jboss.xb.binding.ObjectModelFactorygetObjectModelFactory(org.jboss.ejb3.metamodel.ApplicationClientDD root)

      return new ApplicationClientDDObjectFactory();