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