1 17 package org.apache.geronimo.connector.outbound; 18 19 import org.apache.geronimo.j2ee.management.impl.InvalidObjectNameException; 20 import org.apache.geronimo.kernel.ObjectNameUtil; 21 import org.apache.geronimo.management.geronimo.JCAConnectionFactory; 22 import org.apache.geronimo.management.geronimo.JCAManagedConnectionFactory; 23 24 import javax.management.ObjectName ; 25 import java.util.Hashtable ; 26 27 30 public class JCAConnectionFactoryImpl implements JCAConnectionFactory { 31 private final String objectName; 32 private final JCAManagedConnectionFactory managedConnectionFactory; 33 34 public JCAConnectionFactoryImpl(String objectName, JCAManagedConnectionFactory managedConnectionFactory) { 35 ObjectName myObjectName = ObjectNameUtil.getObjectName(objectName); 37 verifyObjectName(myObjectName); 38 39 this.objectName = objectName; 40 this.managedConnectionFactory = managedConnectionFactory; 41 } 42 43 public String getManagedConnectionFactory() { 44 return managedConnectionFactory.getObjectName(); 45 } 46 47 public JCAManagedConnectionFactory getManagedConnectionFactoryInstance() { 48 return managedConnectionFactory; 49 } 50 51 public String getObjectName() { 52 return objectName; 53 } 54 55 public boolean isStateManageable() { 56 return false; 57 } 58 59 public boolean isStatisticsProvider() { 60 return false; 61 } 62 63 public boolean isEventProvider() { 64 return false; 65 } 66 67 72 private void verifyObjectName(ObjectName objectName) { 73 if (objectName.isPattern()) { 74 throw new InvalidObjectNameException("ObjectName can not be a pattern", objectName); 75 } 76 Hashtable keyPropertyList = objectName.getKeyPropertyList(); 77 if (!"JCAConnectionFactory".equals(keyPropertyList.get("j2eeType"))) { 78 throw new InvalidObjectNameException("JCAConnectionFactory object name j2eeType property must be 'JCAConnectionFactory'", objectName); 79 } 80 if (!keyPropertyList.containsKey("name")) { 81 throw new InvalidObjectNameException("JCAConnectionFactory object must contain a name property", objectName); 82 } 83 if (!keyPropertyList.containsKey("J2EEServer")) { 84 throw new InvalidObjectNameException("JCAConnectionFactory object name must contain a J2EEServer property", objectName); 85 } 86 if (!keyPropertyList.containsKey("JCAResource")) { 87 throw new InvalidObjectNameException("JCAResource object name must contain a JCAResource property", objectName); 88 } 89 } 93 } 94 | Popular Tags |