KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > geronimo > console > core > jms > JMSConnectionFactoryBean


1 /**
2  * Licensed to the Apache Software Foundation (ASF) under one or more
3  * contributor license agreements. See the NOTICE file distributed with
4  * this work for additional information regarding copyright ownership.
5  * The ASF licenses this file to You under the Apache License, Version 2.0
6  * (the "License"); you may not use this file except in compliance with
7  * the License. You may obtain a copy of the License at
8  *
9  * http://www.apache.org/licenses/LICENSE-2.0
10  *
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the License is distributed on an "AS IS" BASIS,
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  * See the License for the specific language governing permissions and
15  * limitations under the License.
16  */

17
18 package org.apache.geronimo.console.core.jms;
19
20 import javax.jms.ConnectionFactory JavaDoc;
21
22 import org.apache.commons.logging.Log;
23 import org.apache.commons.logging.LogFactory;
24 import org.apache.geronimo.connector.outbound.ManagedConnectionFactoryWrapper;
25 import org.apache.geronimo.connector.outbound.ConnectionFactorySource;
26 import org.apache.geronimo.gbean.GBeanInfo;
27 import org.apache.geronimo.gbean.GBeanInfoBuilder;
28 import org.apache.geronimo.gbean.GBeanLifecycle;
29
30 public class JMSConnectionFactoryBean implements GBeanLifecycle {
31
32     private static Log log = LogFactory.getLog(JMSConnectionFactoryBean.class);
33
34     private final ConnectionFactorySource managedConnectionFactoryWrapper;
35
36     private String JavaDoc connectionFactoryName = "jms/DefaultActiveMQConnectionFactory";
37
38     private ConnectionFactory JavaDoc connectionFactory;
39
40     public JMSConnectionFactoryBean(
41             ConnectionFactorySource managedConnectionFactoryWrapper) {
42         this.managedConnectionFactoryWrapper = managedConnectionFactoryWrapper;
43
44     }
45
46     public ConnectionFactory JavaDoc getConnectionFactory() {
47
48         return this.connectionFactory;
49     }
50
51     public synchronized void doStart() throws Exception JavaDoc {
52
53         connectionFactory = (ConnectionFactory JavaDoc) managedConnectionFactoryWrapper
54                 .$getResource();
55
56         log.debug("JMSConnection started");
57
58     }
59
60     public synchronized void doStop() {
61
62     }
63
64     public synchronized void doFail() {
65
66     }
67
68     public static final GBeanInfo GBEAN_INFO;
69
70     static {
71
72         GBeanInfoBuilder infoFactory = GBeanInfoBuilder.createStatic("JMS Connection Factory Bean", JMSConnectionFactoryBean.class);
73         infoFactory.addAttribute("connectionFactory", ConnectionFactory JavaDoc.class,
74                 false);
75
76         infoFactory.addReference("ManagedConnectionFactoryWrapper",
77                 ConnectionFactorySource.class);
78         infoFactory.addOperation("getConnectionFactory");
79
80         infoFactory
81                 .setConstructor(new String JavaDoc[] { "ManagedConnectionFactoryWrapper" });
82         GBEAN_INFO = infoFactory.getBeanInfo();
83     }
84
85     public static GBeanInfo getGBeanInfo() {
86         return GBEAN_INFO;
87     }
88 }
Popular Tags