1 22 package org.jboss.ejb3; 23 24 import java.util.Map ; 25 import javax.management.ObjectName ; 26 import org.jboss.deployment.DeploymentInfo; 27 import org.jboss.system.ServiceMBeanSupport; 28 import org.jboss.logging.Logger; 29 30 36 public class Ejb3Module extends ServiceMBeanSupport implements Ejb3ModuleMBean 37 { 38 public final static String BASE_EJB3_JMX_NAME = "jboss.j2ee:service=EJB3"; 39 private static final Logger log = Logger.getLogger(Ejb3Module.class); 40 41 private Ejb3JmxDeployment deployment; 42 private DeploymentInfo di; 43 44 public Ejb3Module(DeploymentInfo di) 45 { 46 DeploymentScope deploymentScope = null; 47 if (di.parent != null) 48 { 49 if (di.parent.shortName.endsWith(".ear") || di.parent.shortName.endsWith(".ear/")) 50 { 51 synchronized(di.parent.context) 52 { 53 deploymentScope = (DeploymentScope)di.parent.context.get("EJB3_EAR_METADATA"); 54 if (deploymentScope == null) 55 { 56 deploymentScope = new JmxDeploymentScopeImpl(di.parent.shortName); 57 di.parent.context.put("EJB3_EAR_METADATA", deploymentScope); 58 } 59 } 60 } 61 } 62 deployment = new Ejb3JmxDeployment(di, deploymentScope); 63 if (deploymentScope != null) 64 { 65 deploymentScope.register(deployment); 66 } 67 this.di = di; 68 } 69 70 protected void createService() throws Exception 71 { 72 super.createService(); 73 ClassLoader old = Thread.currentThread().getContextClassLoader(); 74 try 75 { 76 Thread.currentThread().setContextClassLoader(di.ucl); 77 deployment.create(); 78 } 79 finally 80 { 81 Thread.currentThread().setContextClassLoader(old); 82 } 83 } 84 85 protected void startService() throws Exception 86 { 87 ClassLoader old = Thread.currentThread().getContextClassLoader(); 88 try 89 { 90 Thread.currentThread().setContextClassLoader(di.ucl); 91 deployment.start(); 92 } 93 finally 94 { 95 Thread.currentThread().setContextClassLoader(old); 96 } 97 super.startService(); 98 99 } 100 101 protected void stopService() throws Exception 102 { 103 ClassLoader old = Thread.currentThread().getContextClassLoader(); 104 try 105 { 106 Thread.currentThread().setContextClassLoader(di.ucl); 107 deployment.stop(); 108 } 109 finally 110 { 111 Thread.currentThread().setContextClassLoader(old); 112 } 113 super.stopService(); 114 } 115 116 protected void destroyService() throws Exception 117 { 118 ClassLoader old = Thread.currentThread().getContextClassLoader(); 119 try 120 { 121 Thread.currentThread().setContextClassLoader(di.ucl); 122 deployment.destroy(); 123 } 124 finally 125 { 126 Thread.currentThread().setContextClassLoader(old); 127 } 128 super.destroyService(); 129 } 130 131 public Container getContainer(ObjectName name) 132 { 133 return deployment.getContainer(name); 134 } 135 136 public Map getContainers() 137 { 138 return deployment.getEjbContainers(); 139 } 140 } 141 | Popular Tags |