1 22 package org.jboss.ejb3.deployers; 23 24 import java.io.IOException ; 25 26 import org.jboss.deployers.plugins.deployers.helpers.ObjectModelFactoryDeployer; 27 import org.jboss.deployers.spi.DeploymentException; 28 import org.jboss.deployers.spi.deployer.DeploymentUnit; 29 import org.jboss.ejb3.metamodel.ApplicationClientDD; 30 import org.jboss.ejb3.metamodel.ApplicationClientDDObjectFactory; 31 import org.jboss.util.xml.DOMUtils; 32 import org.jboss.virtual.VirtualFile; 33 import org.jboss.xb.binding.ObjectModelFactory; 34 import org.w3c.dom.Element ; 35 36 42 public class AppClientParsingDeployer extends ObjectModelFactoryDeployer<ApplicationClientDD> 43 { 44 private String appClientXmlPath = "application-client.xml"; 45 46 public AppClientParsingDeployer() 47 { 48 super(ApplicationClientDD.class); 49 } 50 51 @Override 52 protected ObjectModelFactory getObjectModelFactory(ApplicationClientDD root) 53 { 54 return new ApplicationClientDDObjectFactory(); 55 } 56 57 @Override 58 public void deploy(DeploymentUnit unit) throws DeploymentException 59 { 60 if (accepts(unit)) 61 createMetaData(unit, appClientXmlPath, null); 62 } 63 64 68 private boolean accepts(DeploymentUnit unit) throws DeploymentException 69 { 70 boolean accepts = false; 71 72 VirtualFile dd = unit.getMetaDataFile(appClientXmlPath); 74 if (dd != null) 75 { 76 log.debug("Found application-client.xml file: " + unit.getName()); 77 try 78 { 79 Element root = DOMUtils.parse(dd.openStream()); 80 String namespaceURI = root.getNamespaceURI(); 81 accepts = "http://java.sun.com/xml/ns/javaee".equals(namespaceURI); 83 if (accepts == false) 84 log.debug("Ignore application-client.xml with namespace: " + namespaceURI); 85 } 86 catch (IOException ex) 87 { 88 DeploymentException.rethrowAsDeploymentException("Cannot parse " + appClientXmlPath, ex); 89 } 90 } 91 92 return accepts; 93 } 94 } 95 | Popular Tags |