1 22 package org.jboss.ejb3.deployers; 23 24 import org.jboss.ejb3.DeploymentScope; 25 import org.jboss.ejb3.Ejb3Deployment; 26 import org.jboss.deployers.spi.structure.DeploymentContext; 27 import org.jboss.deployers.spi.deployer.DeploymentUnit; 28 29 import java.util.ArrayList ; 30 import java.util.Collection ; 31 import java.util.concurrent.ConcurrentHashMap ; 32 33 39 public class JBoss5DeploymentScope implements DeploymentScope 40 { 41 private ConcurrentHashMap <String , Ejb3Deployment> deployments; 42 private String shortName; 43 private String baseName; 44 45 public JBoss5DeploymentScope(DeploymentContext parent) 46 { 47 this.shortName = parent.getRoot().getPathName(); 49 if( shortName.length() == 0 ) 50 { 51 shortName = parent.getName(); 52 if (shortName.endsWith("!/")) 54 { 55 this.shortName = shortName.substring(0, shortName.length() - 2); 56 } 57 } 58 int x = shortName.lastIndexOf('/'); 60 this.shortName = shortName.substring(x + 1); 61 62 baseName = shortName; 63 int idx = shortName.lastIndexOf('.'); 64 if( idx > 0 ) 65 baseName = shortName.substring(0, idx); 66 deployments = (ConcurrentHashMap <String , Ejb3Deployment>)parent.getDeploymentUnit().getAttachment("EJB_DEPLOYMENTS"); 67 if (deployments == null) 68 { 69 deployments = new ConcurrentHashMap <String , Ejb3Deployment>(); 70 parent.getDeploymentUnit().addAttachment("EJB_DEPLOYMENTS", deployments); 71 } 72 } 73 74 public Collection <Ejb3Deployment> getEjbDeployments() 75 { 76 return deployments.values(); 77 } 78 79 public void register(Ejb3Deployment deployment) 80 { 81 deployments.put(deployment.getDeploymentUnit().getShortName(), deployment); 82 } 83 84 public void unregister(Ejb3Deployment deployment) 85 { 86 deployments.remove(deployment.getDeploymentUnit().getShortName()); 87 } 88 89 public Ejb3Deployment findRelativeDeployment(String relativeName) 90 { 91 if (relativeName.startsWith("../")) 92 { 93 relativeName = relativeName.substring(3); 94 } 95 return deployments.get(relativeName); 96 } 97 98 public String getShortName() 99 { 100 return shortName; 101 } 102 103 public String getBaseName() 104 { 105 return baseName; 106 } 107 108 } 109 | Popular Tags |