1 22 package org.jboss.deployment; 23 24 import org.jboss.deployers.plugins.deployers.helpers.AttachmentLocator; 25 import org.jboss.deployers.plugins.deployers.helpers.ObjectModelFactoryDeployer; 26 import org.jboss.deployers.spi.DeploymentException; 27 import org.jboss.deployers.spi.deployer.DeploymentUnit; 28 import org.jboss.metadata.ApplicationMetaData; 29 import org.jboss.xb.binding.ObjectModelFactory; 30 import org.jboss.virtual.VirtualFile; 31 import org.jboss.virtual.VFS; 32 import org.jboss.system.server.ServerConfig; 33 34 41 public class JBossEjbParsingDeployer extends ObjectModelFactoryDeployer<ApplicationMetaData> 42 { 43 private String jbossXmlPath = "jboss.xml"; 44 45 public JBossEjbParsingDeployer() 46 { 47 super(ApplicationMetaData.class); 48 setRelativeOrder(PARSER_DEPLOYER+1); 49 } 50 51 57 public String getWebXmlPath() 58 { 59 return jbossXmlPath; 60 } 61 68 public void setWebXmlPath(String jbossXmlPath) 69 { 70 this.jbossXmlPath = jbossXmlPath; 71 } 72 73 78 @Override 79 protected boolean allowsReparse() 80 { 81 return true; 82 } 83 84 88 @Override 89 protected ObjectModelFactory getObjectModelFactory(ApplicationMetaData root) 90 { 91 return new JBossEjbObjectFactory(root); 92 } 93 94 98 @Override 99 public void deploy(DeploymentUnit unit) throws DeploymentException 100 { 101 VirtualFile ejbjar = unit.getMetaDataFile("ejb-jar.xml"); 104 if (ejbjar == null) 105 { 106 return; 107 } 108 109 log.debug("deploy, unit: "+unit); 110 createMetaData(unit, jbossXmlPath, null); 111 112 ApplicationMetaData metaData = getMetaData(unit, ApplicationMetaData.class.getName()); 113 if( metaData == null ) 114 return; 115 116 J2eeApplicationMetaData earMetaData = AttachmentLocator.search(unit, J2eeApplicationMetaData.class); 118 if( earMetaData != null ) 119 { 120 if( metaData.getSecurityDomain() == null ) 122 metaData.setSecurityDomain(earMetaData.getSecurityDomain()); 123 metaData.mergeSecurityRoles(earMetaData.getSecurityRoles()); 124 } 125 126 } 127 128 protected ApplicationMetaData parse(DeploymentUnit unit, 129 String name, 130 ApplicationMetaData root) 131 throws Exception 132 { 133 if(root.getEjbVersion() > 2) 135 return null; 136 137 String configPath = System.getProperty(ServerConfig.SERVER_CONFIG_URL); 138 java.net.URL configUrl = new java.net.URL (configPath); 139 VirtualFile stdJBoss = VFS.getVirtualFile(configUrl, "standardjboss.xml"); 140 if(stdJBoss == null) 141 { 142 throw new DeploymentException("standardjboss.xml not found in config dir: " + configPath); 143 } 144 145 ApplicationMetaData result = parse(unit, stdJBoss, root); 146 147 VirtualFile file = unit.getMetaDataFile(name); 149 if (file == null) 150 return null; 151 152 result = parse(unit, file, root); 153 init(unit, result, file); 154 return result; 155 } 156 } 157 | Popular Tags |