KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > geronimo > connector > ResourceAdapterWrapperGBean


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
18 package org.apache.geronimo.connector;
19
20 import org.apache.geronimo.gbean.DynamicGBean;
21 import org.apache.geronimo.gbean.DynamicGBeanDelegate;
22 import org.apache.geronimo.gbean.GBeanInfo;
23 import org.apache.geronimo.gbean.GBeanInfoBuilder;
24 import org.apache.geronimo.gbean.GBeanLifecycle;
25 import org.apache.geronimo.j2ee.j2eeobjectnames.NameFactory;
26 import org.apache.geronimo.management.geronimo.JCAResourceAdapter;
27
28 import javax.resource.spi.ResourceAdapter JavaDoc;
29 import javax.resource.spi.ResourceAdapterAssociation JavaDoc;
30 import javax.resource.spi.XATerminator JavaDoc;
31 import javax.resource.spi.work.WorkManager JavaDoc;
32
33 /**
34  *
35  * @version $Revision: 486195 $
36  */

37 public class ResourceAdapterWrapperGBean extends ResourceAdapterWrapper implements GBeanLifecycle, DynamicGBean, JCAResourceAdapter {
38
39     private final DynamicGBeanDelegate delegate;
40     private final String JavaDoc objectName;
41
42     public ResourceAdapterWrapperGBean() {
43         delegate=null;
44         objectName = null;
45     }
46
47     public ResourceAdapterWrapperGBean(String JavaDoc resourceAdapterClass, WorkManager JavaDoc workManager, XATerminator JavaDoc xaTerminator, ClassLoader JavaDoc cl, String JavaDoc objectName) throws InstantiationException JavaDoc, IllegalAccessException JavaDoc, ClassNotFoundException JavaDoc {
48         super(resourceAdapterClass, new GeronimoBootstrapContext (workManager, xaTerminator), cl);
49         delegate = new DynamicGBeanDelegate();
50         delegate.addAll(resourceAdapter);
51         this.objectName = objectName;
52     }
53
54     public Object JavaDoc getAttribute(String JavaDoc name) throws Exception JavaDoc {
55         return delegate.getAttribute(name);
56     }
57
58     public void setAttribute(String JavaDoc name, Object JavaDoc value) throws Exception JavaDoc {
59         delegate.setAttribute(name, value);
60     }
61
62     public Object JavaDoc invoke(String JavaDoc name, Object JavaDoc[] arguments, String JavaDoc[] types) throws Exception JavaDoc {
63         //we have no dynamic operations
64
return null;
65     }
66
67     public String JavaDoc getObjectName() {
68         return objectName;
69     }
70
71     public boolean isStateManageable() {
72         return false;
73     }
74
75     public boolean isStatisticsProvider() {
76         return false;
77     }
78
79     public boolean isEventProvider() {
80         return false;
81     }
82
83     public static final GBeanInfo GBEAN_INFO;
84
85     static {
86         GBeanInfoBuilder infoBuilder = GBeanInfoBuilder.createStatic(ResourceAdapterWrapperGBean.class, NameFactory.JCA_RESOURCE_ADAPTER);
87         infoBuilder.addAttribute("resourceAdapterClass", String JavaDoc.class, true);
88         infoBuilder.addAttribute("classLoader", ClassLoader JavaDoc.class, false);
89         infoBuilder.addAttribute("objectName", String JavaDoc.class, false);
90
91         infoBuilder.addReference("WorkManager", WorkManager JavaDoc.class, NameFactory.JCA_WORK_MANAGER);
92         infoBuilder.addReference("XATerminator", XATerminator JavaDoc.class, NameFactory.JCA_WORK_MANAGER);
93
94         infoBuilder.addOperation("registerResourceAdapterAssociation", new Class JavaDoc[]{ResourceAdapterAssociation JavaDoc.class});
95
96         infoBuilder.addInterface(ResourceAdapter.class);
97         infoBuilder.addInterface(JCAResourceAdapter.class);
98
99         infoBuilder.setConstructor(new String JavaDoc[]{"resourceAdapterClass", "WorkManager", "XATerminator", "classLoader", "objectName"});
100
101         GBEAN_INFO = infoBuilder.getBeanInfo();
102     }
103
104     public static GBeanInfo getGBeanInfo() {
105         return GBEAN_INFO;
106     }
107
108 }
109
Popular Tags