001: /**
002: * Licensed to the Apache Software Foundation (ASF) under one or more
003: * contributor license agreements. See the NOTICE file distributed with
004: * this work for additional information regarding copyright ownership.
005: * The ASF licenses this file to You under the Apache License, Version 2.0
006: * (the "License"); you may not use this file except in compliance with
007: * the License. You may obtain a copy of the License at
008: *
009: * http://www.apache.org/licenses/LICENSE-2.0
010: *
011: * Unless required by applicable law or agreed to in writing, software
012: * distributed under the License is distributed on an "AS IS" BASIS,
013: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
014: * See the License for the specific language governing permissions and
015: * limitations under the License.
016: */package org.apache.geronimo.connector;
017:
018: import java.util.Map;
019:
020: import javax.resource.spi.ResourceAdapter;
021: import javax.resource.spi.ResourceAdapterAssociation;
022: import javax.resource.spi.XATerminator;
023: import javax.resource.spi.work.WorkManager;
024:
025: import org.apache.geronimo.gbean.DynamicGBean;
026: import org.apache.geronimo.gbean.DynamicGBeanDelegate;
027: import org.apache.geronimo.gbean.GBeanInfo;
028: import org.apache.geronimo.gbean.GBeanInfoBuilder;
029: import org.apache.geronimo.gbean.GBeanLifecycle;
030: import org.apache.geronimo.j2ee.j2eeobjectnames.NameFactory;
031: import org.apache.geronimo.management.geronimo.JCAResourceAdapter;
032: import org.apache.geronimo.transaction.manager.RecoverableTransactionManager;
033:
034: /**
035: *
036: * @version $Revision: 584764 $
037: */
038: public class ResourceAdapterWrapperGBean extends ResourceAdapterWrapper
039: implements GBeanLifecycle, DynamicGBean, JCAResourceAdapter {
040:
041: private final DynamicGBeanDelegate delegate;
042: private final String objectName;
043:
044: public ResourceAdapterWrapperGBean() {
045: delegate = null;
046: objectName = null;
047: }
048:
049: public ResourceAdapterWrapperGBean(String resourceAdapterClass,
050: Map<String, String> messageListenerToActivationSpecMap,
051: WorkManager workManager, XATerminator xaTerminator,
052: RecoverableTransactionManager transactionManager,
053: ClassLoader cl, String objectName)
054: throws InstantiationException, IllegalAccessException,
055: ClassNotFoundException {
056: super (
057: objectName,
058: resourceAdapterClass,
059: messageListenerToActivationSpecMap,
060: new GeronimoBootstrapContext(workManager, xaTerminator),
061: transactionManager, cl);
062: delegate = new DynamicGBeanDelegate();
063: delegate.addAll(resourceAdapter);
064: this .objectName = objectName;
065: }
066:
067: public Object getAttribute(String name) throws Exception {
068: return delegate.getAttribute(name);
069: }
070:
071: public void setAttribute(String name, Object value)
072: throws Exception {
073: delegate.setAttribute(name, value);
074: }
075:
076: public Object invoke(String name, Object[] arguments, String[] types)
077: throws Exception {
078: //we have no dynamic operations
079: return null;
080: }
081:
082: public String getObjectName() {
083: return objectName;
084: }
085:
086: public boolean isStateManageable() {
087: return false;
088: }
089:
090: public boolean isStatisticsProvider() {
091: return false;
092: }
093:
094: public boolean isEventProvider() {
095: return false;
096: }
097:
098: public static final GBeanInfo GBEAN_INFO;
099:
100: static {
101: GBeanInfoBuilder infoBuilder = GBeanInfoBuilder.createStatic(
102: ResourceAdapterWrapperGBean.class,
103: NameFactory.JCA_RESOURCE_ADAPTER);
104: infoBuilder.addAttribute("resourceAdapterClass", String.class,
105: true);
106: infoBuilder.addAttribute("classLoader", ClassLoader.class,
107: false);
108: infoBuilder.addAttribute("objectName", String.class, false);
109: infoBuilder.addAttribute("messageListenerToActivationSpecMap",
110: Map.class, true);
111:
112: infoBuilder.addReference("WorkManager", WorkManager.class,
113: NameFactory.JCA_WORK_MANAGER);
114: infoBuilder.addReference("XATerminator", XATerminator.class,
115: NameFactory.JCA_WORK_MANAGER);
116: infoBuilder.addReference("TransactionManager",
117: RecoverableTransactionManager.class,
118: NameFactory.JTA_RESOURCE);
119:
120: infoBuilder.addOperation("registerResourceAdapterAssociation",
121: new Class[] { ResourceAdapterAssociation.class });
122:
123: infoBuilder.addInterface(ResourceAdapter.class);
124: infoBuilder.addInterface(JCAResourceAdapter.class);
125:
126: infoBuilder.setConstructor(new String[] {
127: "resourceAdapterClass",
128: "messageListenerToActivationSpecMap", "WorkManager",
129: "XATerminator", "TransactionManager", "classLoader",
130: "objectName" });
131:
132: GBEAN_INFO = infoBuilder.getBeanInfo();
133: }
134:
135: public static GBeanInfo getGBeanInfo() {
136: return GBEAN_INFO;
137: }
138:
139: }
|