1 22 package org.jboss.management.j2ee.factory; 23 24 import org.jboss.deployment.DeploymentInfo; 25 import org.jboss.logging.Logger; 26 import org.jboss.management.j2ee.ResourceAdapter; 27 import org.jboss.management.j2ee.ResourceAdapterModule; 28 import org.jboss.resource.metadata.ConnectorMetaData; 29 30 import javax.management.MBeanServer ; 31 import javax.management.ObjectName ; 32 import java.util.HashMap ; 33 34 40 public class RARModuleFactory 41 implements ManagedObjectFactory 42 { 43 private static Logger log = Logger.getLogger(RARModuleFactory.class); 44 private static HashMap moduleServiceToMgmtMap = new HashMap (); 45 private HashMap deploymentToModuleNameMap = new HashMap (); 46 47 static ObjectName getResourceAdapterName(ObjectName rarService) 48 { 49 ObjectName jsr77Name = (ObjectName ) moduleServiceToMgmtMap.get(rarService); 50 return jsr77Name; 51 } 52 53 59 public ObjectName create(MBeanServer mbeanServer, Object data) 60 { 61 if ((data instanceof DeploymentInfo) == false) 62 return null; 63 64 DeploymentInfo di = (DeploymentInfo) data; 65 ConnectorMetaData metaData = (ConnectorMetaData) di.metaData; 66 67 String rarName = di.shortName; 69 ObjectName rarService = di.deployedObject; 70 ObjectName jsr77ModuleName = ResourceAdapterModule.create(mbeanServer, 71 (di.parent == null ? null : di.parent.shortName), 72 rarName, 73 di.localUrl); 74 deploymentToModuleNameMap.put(di, jsr77ModuleName); 75 log.debug("Created module: " + jsr77ModuleName); 76 77 ObjectName jsr77RAName = ResourceAdapter.create(mbeanServer, 79 metaData.getDescription().getDisplayName(), jsr77ModuleName, rarService); 80 moduleServiceToMgmtMap.put(rarService, jsr77RAName); 82 83 return jsr77ModuleName; 84 } 85 86 92 public void destroy(MBeanServer mbeanServer, Object data) 93 { 94 if ((data instanceof DeploymentInfo) == false) 95 return; 96 97 DeploymentInfo di = (DeploymentInfo) data; 98 ConnectorMetaData metaData = (ConnectorMetaData) di.metaData; 99 ObjectName jsr77Name = (ObjectName ) deploymentToModuleNameMap.get(di); 100 101 ResourceAdapter.destroy(mbeanServer, metaData.getDescription().getDisplayName()); 102 log.debug("Destroy module: " + jsr77Name); 103 if (jsr77Name != null) 104 { 105 ResourceAdapterModule.destroy(mbeanServer, jsr77Name); 106 } 107 } 108 109 } 110 | Popular Tags |