KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > geronimo > connector > outbound > GenericConnectionManagerGBean


1 /**
2  * Licensed to the Apache Software Foundation (ASF) under one or more
3  * contributor license agreements. See the NOTICE file distributed with
4  * this work for additional information regarding copyright ownership.
5  * The ASF licenses this file to You under the Apache License, Version 2.0
6  * (the "License"); you may not use this file except in compliance with
7  * the License. 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 JavaDoc;
20 import javax.transaction.TransactionManager JavaDoc;
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: 476049 $
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 JavaDoc transactionManager,
48                                          String JavaDoc objectName,
49                                          ClassLoader JavaDoc classLoader,
50                                          Kernel kernel) {
51         super(transactionSupport, pooling, containerManagedSecurity, connectionTracker, transactionManager, objectName, classLoader);
52         this.kernel = kernel;
53     }
54
55     public ConnectionManager JavaDoc getConnectionManager() {
56         ConnectionManager JavaDoc unproxied = super.getConnectionManager();
57         ProxyManager pm = kernel.getProxyManager();
58         if(pm.isProxy(unproxied)) {
59             return unproxied;
60         } else {
61             return (ConnectionManager JavaDoc) 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 JavaDoc.class, false);
75         infoBuilder.addAttribute("classLoader", ClassLoader JavaDoc.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 JavaDoc.class, NameFactory.TRANSACTION_MANAGER);
80
81
82         infoBuilder.setConstructor(new String JavaDoc[]{
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