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