1 17 package org.apache.geronimo.connector.outbound; 18 19 import javax.resource.spi.ConnectionManager ; 20 import javax.transaction.TransactionManager ; 21 22 import org.apache.geronimo.connector.outbound.connectionmanagerconfig.PoolingSupport; 23 import org.apache.geronimo.connector.outbound.connectionmanagerconfig.TransactionSupport; 24 import org.apache.geronimo.connector.outbound.connectiontracking.ConnectionTracker; 25 import org.apache.geronimo.gbean.GBeanInfo; 26 import org.apache.geronimo.gbean.GBeanInfoBuilder; 27 import org.apache.geronimo.gbean.GBeanLifecycle; 28 import org.apache.geronimo.j2ee.j2eeobjectnames.NameFactory; 29 import org.apache.geronimo.kernel.Kernel; 30 import org.apache.geronimo.kernel.proxy.ProxyManager; 31 32 35 public class GenericConnectionManagerGBean extends GenericConnectionManager implements GBeanLifecycle { 36 private final Kernel kernel; 37 38 public GenericConnectionManagerGBean() { 39 super(); 40 kernel = null; 41 } 42 43 public GenericConnectionManagerGBean(TransactionSupport transactionSupport, 44 PoolingSupport pooling, 45 boolean containerManagedSecurity, 46 ConnectionTracker connectionTracker, 47 TransactionManager transactionManager, 48 String objectName, 49 ClassLoader classLoader, 50 Kernel kernel) { 51 super(transactionSupport, pooling, containerManagedSecurity, connectionTracker, transactionManager, objectName, classLoader); 52 this.kernel = kernel; 53 } 54 55 public ConnectionManager getConnectionManager() { 56 ConnectionManager unproxied = super.getConnectionManager(); 57 ProxyManager pm = kernel.getProxyManager(); 58 if(pm.isProxy(unproxied)) { 59 return unproxied; 60 } else { 61 return (ConnectionManager ) pm.createProxy(kernel.getAbstractNameFor(unproxied), unproxied.getClass().getClassLoader()); 62 } 63 } 64 65 public static final GBeanInfo GBEAN_INFO; 66 67 static { 68 GBeanInfoBuilder infoBuilder = GBeanInfoBuilder.createStatic(GenericConnectionManagerGBean.class, AbstractConnectionManagerGBean.GBEAN_INFO); 69 70 infoBuilder.addAttribute("transactionSupport", TransactionSupport.class, true); 71 infoBuilder.addAttribute("pooling", PoolingSupport.class, true); 72 infoBuilder.addAttribute("containerManagedSecurity", Boolean.TYPE, true); 73 74 infoBuilder.addAttribute("objectName", String .class, false); 75 infoBuilder.addAttribute("classLoader", ClassLoader .class, false); 76 infoBuilder.addAttribute("kernel", Kernel.class, false); 77 78 infoBuilder.addReference("ConnectionTracker", ConnectionTracker.class, NameFactory.JCA_CONNECTION_TRACKER); 79 infoBuilder.addReference("TransactionManager", TransactionManager .class, NameFactory.TRANSACTION_MANAGER); 80 81 82 infoBuilder.setConstructor(new String []{ 83 "transactionSupport", 84 "pooling", 85 "containerManagedSecurity", 86 "ConnectionTracker", 87 "TransactionManager", 88 "objectName", 89 "classLoader", 90 "kernel" 91 }); 92 93 GBEAN_INFO = infoBuilder.getBeanInfo(); 94 } 95 96 public static GBeanInfo getGBeanInfo() { 97 return GBEAN_INFO; 98 } 99 100 } 101 | Popular Tags |