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.mx.util.ObjectNameMatch; 27 28 import javax.management.Notification ; 29 import javax.management.ObjectName ; 30 import java.util.HashMap ; 31 import java.util.Iterator ; 32 33 37 public class DefaultManagedObjectFactoryMap 38 implements ManagedObjectFactoryMap 39 { 40 private static Logger log = Logger.getLogger(DefaultManagedObjectFactoryMap.class); 41 private HashMap factoryMap = new HashMap (); 42 private HashMap patternFactoryMap = new HashMap (); 43 44 54 public ManagedObjectFactory getFactory(Notification createEvent) 55 { 56 ManagedObjectFactory factory = null; 57 58 Object data = createEvent.getUserData(); 59 ObjectName senderName = null; 60 if (data instanceof ObjectName ) 61 { 62 senderName = (ObjectName ) data; 63 } 64 else if (data instanceof DeploymentInfo) 65 { 66 DeploymentInfo di = (DeploymentInfo) data; 67 senderName = di.deployer.getServiceName(); 68 } 69 factory = (ManagedObjectFactory) factoryMap.get(senderName); 70 if (factory == null) 71 { 72 Iterator iter = patternFactoryMap.keySet().iterator(); 74 while (iter.hasNext()) 75 { 76 ObjectName pattern = (ObjectName ) iter.next(); 77 if (ObjectNameMatch.match(pattern, senderName)) 78 factory = (ManagedObjectFactory) patternFactoryMap.get(pattern); 79 } 80 if (factory == null) 81 log.debug("Failed to find factory for event: " + createEvent); 82 } 83 return factory; 84 } 85 86 public void setSARDeployer(ObjectName name) 87 { 88 factoryMap.put(name, new ServiceModuleFactory()); 89 } 90 91 public void setEARDeployer(ObjectName name) 92 { 93 factoryMap.put(name, new EARModuleFactory()); 94 } 95 96 public void setEJBDeployer(ObjectName name) 97 { 98 factoryMap.put(name, new EJBModuleFactory()); 99 } 100 101 public void setRARDeployer(ObjectName name) 102 { 103 factoryMap.put(name, new RARModuleFactory()); 104 } 105 106 public void setCMDeployer(ObjectName name) 107 { 108 factoryMap.put(name, new JCAResourceFactory()); 109 } 110 111 public void setWARDeployer(ObjectName name) 112 { 113 factoryMap.put(name, new WebModuleFactory()); 114 } 115 116 public void setJavaMailResource(ObjectName name) 117 { 118 factoryMap.put(name, new JavaMailResourceFactory()); 119 } 120 121 public void setJMSResource(ObjectName name) 122 { 123 factoryMap.put(name, new JMSResourceFactory()); 124 } 125 126 public void setJNDIResource(ObjectName name) 127 { 128 factoryMap.put(name, new JNDIResourceFactory()); 129 } 130 131 public void setJTAResource(ObjectName name) 132 { 133 factoryMap.put(name, new JTAResourceFactory()); 134 } 135 136 public void setRMI_IIOPResource(ObjectName name) 137 { 138 factoryMap.put(name, new RMIIIOPResourceFactory()); 139 } 140 } 141 | Popular Tags |