1 17 package org.apache.geronimo.connector.deployment; 18 19 import java.util.Hashtable ; 20 import javax.management.ObjectName ; 21 22 import org.apache.geronimo.gbean.GBeanInfo; 23 import org.apache.geronimo.gbean.GBeanInfoBuilder; 24 import org.apache.geronimo.j2ee.management.J2EEServer; 25 import org.apache.geronimo.j2ee.management.impl.InvalidObjectNameException; 26 import org.apache.geronimo.kernel.jmx.JMXUtil; 27 28 31 public class JCAConnectionFactoryImpl { 32 private final J2EEServer server; 33 private final String managedConnectionFactory; 34 35 public JCAConnectionFactoryImpl(String objectName, J2EEServer server, String managedConnectionFactory) { 36 ObjectName myObjectName = JMXUtil.getObjectName(objectName); 37 verifyObjectName(myObjectName); 38 39 this.server = server; 40 this.managedConnectionFactory = managedConnectionFactory; 41 } 42 43 public String getServer() { 44 return server.getObjectName(); 45 } 46 47 public String getManagedConnectionFactory() { 48 return managedConnectionFactory; 49 } 50 51 56 private void verifyObjectName(ObjectName objectName) { 57 if (objectName.isPattern()) { 58 throw new InvalidObjectNameException("ObjectName can not be a pattern", objectName); 59 } 60 Hashtable keyPropertyList = objectName.getKeyPropertyList(); 61 if (!"JCAConnectionFactory".equals(keyPropertyList.get("j2eeType"))) { 62 throw new InvalidObjectNameException("JCAConnectionFactory object name j2eeType property must be 'JCAConnectionFactory'", objectName); 63 } 64 if (!keyPropertyList.containsKey("name")) { 65 throw new InvalidObjectNameException("JCAConnectionFactory object must contain a name property", objectName); 66 } 67 if (!keyPropertyList.containsKey("J2EEServer")) { 68 throw new InvalidObjectNameException("JCAConnectionFactory object name must contain a J2EEServer property", objectName); 69 } 70 if (!keyPropertyList.containsKey("JCAResource")) { 71 throw new InvalidObjectNameException("JCAResource object name must contain a JCAResource property", objectName); 72 } 73 } 77 78 public static final GBeanInfo GBEAN_INFO; 79 80 static { 81 GBeanInfoBuilder infoFactory = new GBeanInfoBuilder(JCAConnectionFactoryImpl.class); 82 infoFactory.addReference("J2EEServer", J2EEServer.class); 83 84 infoFactory.addAttribute("objectName", String .class, false); 85 infoFactory.addAttribute("server", String .class, false); 86 infoFactory.addAttribute("managedConnectionFactory", String .class, true); 87 88 infoFactory.setConstructor(new String []{"objectName", "J2EEServer", "managedConnectionFactory"}); 89 90 GBEAN_INFO = infoFactory.getBeanInfo(); 91 } 92 93 public static GBeanInfo getGBeanInfo() { 94 return GBEAN_INFO; 95 } 96 } 97 | Popular Tags |