1 /** 2 * 3 * Copyright 2005 The Apache Software Foundation 4 * 5 * Licensed under the Apache License, Version 2.0 (the "License"); 6 * you may not use this file except in compliance with the License. 7 * You may obtain a copy of the License at 8 * 9 * http://www.apache.org/licenses/LICENSE-2.0 10 * 11 * Unless required by applicable law or agreed to in writing, software 12 * distributed under the License is distributed on an "AS IS" BASIS, 13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 * See the License for the specific language governing permissions and 15 * limitations under the License. 16 */ 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 /** 33 * @version $Revision: 430508 $ 34 */ 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 }