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.console.core.jms;
019    
020    import javax.jms.ConnectionFactory;
021    
022    import org.apache.commons.logging.Log;
023    import org.apache.commons.logging.LogFactory;
024    import org.apache.geronimo.connector.outbound.ManagedConnectionFactoryWrapper;
025    import org.apache.geronimo.connector.outbound.ConnectionFactorySource;
026    import org.apache.geronimo.gbean.GBeanInfo;
027    import org.apache.geronimo.gbean.GBeanInfoBuilder;
028    import org.apache.geronimo.gbean.GBeanLifecycle;
029    
030    public class JMSConnectionFactoryBean implements GBeanLifecycle {
031    
032        private static Log log = LogFactory.getLog(JMSConnectionFactoryBean.class);
033    
034        private final ConnectionFactorySource managedConnectionFactoryWrapper;
035    
036        private String connectionFactoryName = "jms/DefaultActiveMQConnectionFactory";
037    
038        private ConnectionFactory connectionFactory;
039    
040        public JMSConnectionFactoryBean(
041                ConnectionFactorySource managedConnectionFactoryWrapper) {
042            this.managedConnectionFactoryWrapper = managedConnectionFactoryWrapper;
043    
044        }
045    
046        public ConnectionFactory getConnectionFactory() {
047    
048            return this.connectionFactory;
049        }
050    
051        public synchronized void doStart() throws Exception {
052    
053            connectionFactory = (ConnectionFactory) managedConnectionFactoryWrapper
054                    .$getResource();
055    
056            log.debug("JMSConnection started");
057    
058        }
059    
060        public synchronized void doStop() {
061    
062        }
063    
064        public synchronized void doFail() {
065    
066        }
067    
068        public static final GBeanInfo GBEAN_INFO;
069    
070        static {
071    
072            GBeanInfoBuilder infoFactory = GBeanInfoBuilder.createStatic("JMS Connection Factory Bean", JMSConnectionFactoryBean.class);
073            infoFactory.addAttribute("connectionFactory", ConnectionFactory.class,
074                    false);
075    
076            infoFactory.addReference("ManagedConnectionFactoryWrapper",
077                    ConnectionFactorySource.class);
078            infoFactory.addOperation("getConnectionFactory");
079    
080            infoFactory
081                    .setConstructor(new String[] { "ManagedConnectionFactoryWrapper" });
082            GBEAN_INFO = infoFactory.getBeanInfo();
083        }
084    
085        public static GBeanInfo getGBeanInfo() {
086            return GBEAN_INFO;
087        }
088    }