001    /**
002     *
003     * Copyright 2005 The Apache Software Foundation
004     *
005     *  Licensed under the Apache License, Version 2.0 (the "License");
006     *  you may not use this file except in compliance with the License.
007     *  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 javax.resource.spi.endpoint.MessageEndpointFactory;
021    
022    import org.apache.geronimo.gbean.GBeanInfo;
023    import org.apache.geronimo.gbean.GBeanInfoBuilder;
024    import org.apache.geronimo.gbean.DynamicGBean;
025    import org.apache.geronimo.gbean.DynamicGBeanDelegate;
026    import org.apache.geronimo.j2ee.j2eeobjectnames.NameFactory;
027    import org.apache.geronimo.transaction.manager.ResourceManager;
028    
029    /**
030     * 
031     * @version $Revision: 356022 $
032     */
033    public class ActivationSpecWrapperGBean extends ActivationSpecWrapper implements DynamicGBean {
034    
035        private final DynamicGBeanDelegate delegate;
036    
037        public ActivationSpecWrapperGBean() {
038            delegate = null;
039        }
040    
041        public ActivationSpecWrapperGBean(final String activationSpecClass, final String containerId, final ResourceAdapterWrapper resourceAdapterWrapper, final ClassLoader cl) throws IllegalAccessException, InstantiationException, ClassNotFoundException {
042            super(activationSpecClass, containerId, resourceAdapterWrapper, cl);
043            delegate = new DynamicGBeanDelegate();
044            delegate.addAll(activationSpec);
045        }
046    
047        //DynamicGBean implementation
048    
049        /**
050         * Delegating DynamicGBean getAttribute method.
051         *
052         * @param name of attribute.
053         * @return attribute value.
054         * @throws Exception
055         */
056        public Object getAttribute(final String name) throws Exception {
057            return delegate.getAttribute(name);
058        }
059    
060        /**
061         * Delegating DynamicGBean setAttribute method.
062         *
063         * @param name  of attribute.
064         * @param value of attribute to be set.
065         * @throws Exception
066         */
067        public void setAttribute(final String name, final Object value) throws Exception {
068            delegate.setAttribute(name, value);
069        }
070    
071        /**
072         * no-op DynamicGBean method
073         *
074         * @param name
075         * @param arguments
076         * @param types
077         * @return nothing, there are no operations.
078         * @throws Exception
079         */
080        public Object invoke(final String name, final Object[] arguments, final String[] types) throws Exception {
081            //we have no dynamic operations.
082            return null;
083        }
084    
085        public static final GBeanInfo GBEAN_INFO;
086    
087        static {
088            GBeanInfoBuilder infoBuilder = GBeanInfoBuilder.createStatic(ActivationSpecWrapperGBean.class, NameFactory.JCA_ACTIVATION_SPEC);
089            infoBuilder.addAttribute("activationSpecClass", String.class, true);
090            infoBuilder.addAttribute("containerId", String.class, true);
091            infoBuilder.addAttribute("classLoader", ClassLoader.class, false);
092    
093            infoBuilder.addReference("ResourceAdapterWrapper", ResourceAdapterWrapper.class, NameFactory.RESOURCE_ADAPTER);
094    
095            infoBuilder.addOperation("activate", new Class[]{MessageEndpointFactory.class});
096            infoBuilder.addOperation("deactivate", new Class[]{MessageEndpointFactory.class});
097    
098            infoBuilder.addInterface(ResourceManager.class);
099    
100            infoBuilder.setConstructor(new String[]{
101                "activationSpecClass",
102                "containerId",
103                "ResourceAdapterWrapper",
104                "classLoader"});
105    
106            GBEAN_INFO = infoBuilder.getBeanInfo();
107        }
108    
109        public static GBeanInfo getGBeanInfo() {
110            return GBEAN_INFO;
111        }
112    
113    }