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 */ 017 018 package org.apache.geronimo.connector; 019 020 import java.util.Map; 021 022 import javax.resource.spi.ResourceAdapter; 023 import javax.resource.spi.ResourceAdapterAssociation; 024 import javax.resource.spi.XATerminator; 025 import javax.resource.spi.work.WorkManager; 026 027 import org.apache.geronimo.gbean.DynamicGBean; 028 import org.apache.geronimo.gbean.DynamicGBeanDelegate; 029 import org.apache.geronimo.gbean.GBeanInfo; 030 import org.apache.geronimo.gbean.GBeanInfoBuilder; 031 import org.apache.geronimo.gbean.GBeanLifecycle; 032 import org.apache.geronimo.j2ee.j2eeobjectnames.NameFactory; 033 import org.apache.geronimo.management.geronimo.JCAResourceAdapter; 034 import org.apache.geronimo.transaction.manager.RecoverableTransactionManager; 035 036 /** 037 * 038 * @version $Revision: 550546 $ 039 */ 040 public class ResourceAdapterWrapperGBean extends ResourceAdapterWrapper implements GBeanLifecycle, DynamicGBean, JCAResourceAdapter { 041 042 private final DynamicGBeanDelegate delegate; 043 private final String objectName; 044 045 public ResourceAdapterWrapperGBean() { 046 delegate=null; 047 objectName = null; 048 } 049 050 public ResourceAdapterWrapperGBean(String resourceAdapterClass, Map<String, String> messageListenerToActivationSpecMap, WorkManager workManager, XATerminator xaTerminator, RecoverableTransactionManager transactionManager, ClassLoader cl, String objectName) throws InstantiationException, IllegalAccessException, ClassNotFoundException { 051 super(objectName, resourceAdapterClass, messageListenerToActivationSpecMap, new GeronimoBootstrapContext (workManager, xaTerminator), transactionManager, cl); 052 delegate = new DynamicGBeanDelegate(); 053 delegate.addAll(resourceAdapter); 054 this.objectName = objectName; 055 } 056 057 public Object getAttribute(String name) throws Exception { 058 return delegate.getAttribute(name); 059 } 060 061 public void setAttribute(String name, Object value) throws Exception { 062 delegate.setAttribute(name, value); 063 } 064 065 public Object invoke(String name, Object[] arguments, String[] types) throws Exception { 066 //we have no dynamic operations 067 return null; 068 } 069 070 public String getObjectName() { 071 return objectName; 072 } 073 074 public boolean isStateManageable() { 075 return false; 076 } 077 078 public boolean isStatisticsProvider() { 079 return false; 080 } 081 082 public boolean isEventProvider() { 083 return false; 084 } 085 086 public static final GBeanInfo GBEAN_INFO; 087 088 static { 089 GBeanInfoBuilder infoBuilder = GBeanInfoBuilder.createStatic(ResourceAdapterWrapperGBean.class, NameFactory.JCA_RESOURCE_ADAPTER); 090 infoBuilder.addAttribute("resourceAdapterClass", String.class, true); 091 infoBuilder.addAttribute("classLoader", ClassLoader.class, false); 092 infoBuilder.addAttribute("objectName", String.class, false); 093 infoBuilder.addAttribute("messageListenerToActivationSpecMap", Map.class, true); 094 095 infoBuilder.addReference("WorkManager", WorkManager.class, NameFactory.JCA_WORK_MANAGER); 096 infoBuilder.addReference("XATerminator", XATerminator.class, NameFactory.JCA_WORK_MANAGER); 097 infoBuilder.addReference("TransactionManager", RecoverableTransactionManager.class, NameFactory.TRANSACTION_MANAGER); 098 099 infoBuilder.addOperation("registerResourceAdapterAssociation", new Class[]{ResourceAdapterAssociation.class}); 100 101 infoBuilder.addInterface(ResourceAdapter.class); 102 infoBuilder.addInterface(JCAResourceAdapter.class); 103 104 infoBuilder.setConstructor(new String[]{"resourceAdapterClass", "messageListenerToActivationSpecMap", "WorkManager", "XATerminator", "TransactionManager", "classLoader", "objectName"}); 105 106 GBEAN_INFO = infoBuilder.getBeanInfo(); 107 } 108 109 public static GBeanInfo getGBeanInfo() { 110 return GBEAN_INFO; 111 } 112 113 }