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 package org.apache.activemq.spring;
018
019 import javax.annotation.PostConstruct;
020 import org.springframework.beans.factory.BeanNameAware;
021
022 /**
023 * A <a href="http://www.springframework.org/">Spring</a> enhanced XA connection
024 * factory which will automatically use the Spring bean name as the clientIDPrefix property
025 * so that connections created have client IDs related to your Spring.xml file for
026 * easier comprehension from <a href="http://activemq.apache.org/jmx.html">JMX</a>.
027 *
028 * @org.apache.xbean.XBean element="xaConnectionFactory"
029 *
030 *
031 */
032 public class ActiveMQXAConnectionFactory extends org.apache.activemq.ActiveMQXAConnectionFactory implements BeanNameAware {
033
034 private String beanName;
035 private boolean useBeanNameAsClientIdPrefix;
036
037 /**
038 *
039 * @throws Exception
040 * @org.apache.xbean.InitMethod
041 */
042 @PostConstruct
043 public void afterPropertiesSet() throws Exception {
044 if (isUseBeanNameAsClientIdPrefix() && getClientIDPrefix() == null) {
045 setClientIDPrefix(getBeanName());
046 }
047 }
048
049 public String getBeanName() {
050 return beanName;
051 }
052
053 public void setBeanName(String beanName) {
054 this.beanName = beanName;
055 }
056
057 public boolean isUseBeanNameAsClientIdPrefix() {
058 return useBeanNameAsClientIdPrefix;
059 }
060
061 public void setUseBeanNameAsClientIdPrefix(boolean useBeanNameAsClientIdPrefix) {
062 this.useBeanNameAsClientIdPrefix = useBeanNameAsClientIdPrefix;
063 }
064 }