KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > activemq > spring > ActiveMQXAConnectionFactory


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 package org.apache.activemq.spring;
18
19 import org.springframework.beans.factory.BeanNameAware;
20 import org.springframework.beans.factory.InitializingBean;
21
22 /**
23  * A <a HREF="http://www.springframework.org/">Spring</a> enhanced XA connection
24  * factory which will automatically use the Spring bean name as the clientIDPrefix property
25  * so that connections created have client IDs related to your Spring.xml file for
26  * easier comprehension from <a HREF="http://activemq.apache.org/jmx.html">JMX</a>.
27  *
28  * @org.apache.xbean.XBean element="xaConnectionFactory"
29  *
30  * @version $Revision: $
31  */

32 public class ActiveMQXAConnectionFactory extends org.apache.activemq.ActiveMQXAConnectionFactory implements InitializingBean, BeanNameAware {
33
34     private String JavaDoc beanName;
35     private boolean useBeanNameAsClientIdPrefix;
36     
37     public void afterPropertiesSet() throws Exception JavaDoc {
38         if (isUseBeanNameAsClientIdPrefix() && getClientIDPrefix() == null) {
39             setClientIDPrefix(getBeanName());
40         }
41     }
42
43     public String JavaDoc getBeanName() {
44         return beanName;
45     }
46     
47     public void setBeanName(String JavaDoc beanName) {
48         this.beanName = beanName;
49     }
50
51     public boolean isUseBeanNameAsClientIdPrefix() {
52         return useBeanNameAsClientIdPrefix;
53     }
54
55     public void setUseBeanNameAsClientIdPrefix(boolean useBeanNameAsClientIdPrefix) {
56         this.useBeanNameAsClientIdPrefix = useBeanNameAsClientIdPrefix;
57     }
58 }
59
Popular Tags