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.WebMetaData; 29 import org.jboss.metadata.web.JBossWebMetaDataObjectFactory; 30 import org.jboss.xb.binding.ObjectModelFactory; 31 32 39 public class JBossWebAppParsingDeployer extends ObjectModelFactoryDeployer<WebMetaData> 40 { 41 private String webXmlPath = "jboss-web.xml"; 42 43 public JBossWebAppParsingDeployer() 44 { 45 super(WebMetaData.class); 46 setRelativeOrder(PARSER_DEPLOYER+1); 47 } 48 49 55 public String getWebXmlPath() 56 { 57 return webXmlPath; 58 } 59 66 public void setWebXmlPath(String webXmlPath) 67 { 68 this.webXmlPath = webXmlPath; 69 } 70 71 76 @Override 77 protected boolean allowsReparse() 78 { 79 return true; 80 } 81 82 86 @Override 87 protected ObjectModelFactory getObjectModelFactory(WebMetaData root) 88 { 89 return new JBossWebMetaDataObjectFactory(root); 90 } 91 92 96 @Override 97 public void deploy(DeploymentUnit unit) throws DeploymentException 98 { 99 log.debug("deploy, unit: "+unit); 100 createMetaData(unit, webXmlPath, null); 101 WebMetaData metaData = getMetaData(unit, WebMetaData.class.getName()); 102 if( metaData == null ) 103 return; 104 105 J2eeApplicationMetaData earMetaData = AttachmentLocator.search(unit, J2eeApplicationMetaData.class); 107 if( earMetaData != null ) 108 { 109 String path = unit.getRelativePath(); 110 J2eeModuleMetaData webModule = earMetaData.getModule(path); 111 if( webModule != null ) 112 { 113 String contextRoot = metaData.getContextRoot(); 115 if( contextRoot == null ) 116 { 117 contextRoot = webModule.getWebContext(); 118 metaData.setContextRoot(contextRoot); 119 } 120 121 metaData.setAltDDPath(webModule.getAlternativeDD()); 123 } 124 125 if( metaData.getSecurityDomain() == null ) 127 metaData.setSecurityDomain(earMetaData.getSecurityDomain()); 128 metaData.mergeSecurityRoles(earMetaData.getSecurityRoles()); 129 } 130 } 131 } 132 | Popular Tags |