Skip to content

Commit e146e53

Browse files
committed
Added support for the JCA 1.7 getActivationName() method
Issue: SPR-11067
1 parent bedb8e9 commit e146e53

File tree

2 files changed

+36
-7
lines changed

2 files changed

+36
-7
lines changed

spring-jms/src/main/java/org/springframework/jms/listener/endpoint/JmsMessageEndpointManager.java

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2012 the original author or authors.
2+
* Copyright 2002-2013 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -19,6 +19,7 @@
1919
import javax.jms.MessageListener;
2020
import javax.resource.ResourceException;
2121

22+
import org.springframework.beans.factory.BeanNameAware;
2223
import org.springframework.jca.endpoint.GenericMessageEndpointManager;
2324
import org.springframework.jms.support.destination.DestinationResolver;
2425

@@ -45,7 +46,7 @@
4546
* @see JmsActivationSpecFactory
4647
* @see JmsMessageEndpointFactory
4748
*/
48-
public class JmsMessageEndpointManager extends GenericMessageEndpointManager {
49+
public class JmsMessageEndpointManager extends GenericMessageEndpointManager implements BeanNameAware {
4950

5051
private final JmsMessageEndpointFactory endpointFactory = new JmsMessageEndpointFactory();
5152

@@ -127,6 +128,14 @@ public void setActivationSpecConfig(JmsActivationSpecConfig activationSpecConfig
127128
this.activationSpecConfig = activationSpecConfig;
128129
}
129130

131+
/**
132+
* Set the name of this message endpoint. Populated with the bean name
133+
* automatically when defined within Spring's bean factory.
134+
*/
135+
@Override
136+
public void setBeanName(String beanName) {
137+
this.endpointFactory.setBeanName(beanName);
138+
}
130139

131140
@Override
132141
public void afterPropertiesSet() throws ResourceException {

spring-tx/src/main/java/org/springframework/jca/endpoint/AbstractMessageEndpointFactory.java

Lines changed: 25 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2012 the original author or authors.
2+
* Copyright 2002-2013 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -29,11 +29,12 @@
2929
import org.apache.commons.logging.Log;
3030
import org.apache.commons.logging.LogFactory;
3131

32+
import org.springframework.beans.factory.BeanNameAware;
3233
import org.springframework.transaction.jta.SimpleTransactionFactory;
3334
import org.springframework.transaction.jta.TransactionFactory;
3435

3536
/**
36-
* Abstract base implementation of the JCA 1.5/1.6
37+
* Abstract base implementation of the JCA 1.5/1.6/1.7
3738
* {@link javax.resource.spi.endpoint.MessageEndpointFactory} interface,
3839
* providing transaction management capabilities as well as ClassLoader
3940
* exposure for endpoint invocations.
@@ -42,7 +43,7 @@
4243
* @since 2.5
4344
* @see #setTransactionManager
4445
*/
45-
public abstract class AbstractMessageEndpointFactory implements MessageEndpointFactory {
46+
public abstract class AbstractMessageEndpointFactory implements MessageEndpointFactory, BeanNameAware {
4647

4748
/** Logger available to subclasses */
4849
protected final Log logger = LogFactory.getLog(getClass());
@@ -53,6 +54,8 @@ public abstract class AbstractMessageEndpointFactory implements MessageEndpointF
5354

5455
private int transactionTimeout = -1;
5556

57+
private String beanName;
58+
5659

5760
/**
5861
* Set the the XA transaction manager to use for wrapping endpoint
@@ -116,6 +119,24 @@ public void setTransactionTimeout(int transactionTimeout) {
116119
this.transactionTimeout = transactionTimeout;
117120
}
118121

122+
/**
123+
* Set the name of this message endpoint. Populated with the bean name
124+
* automatically when defined within Spring's bean factory.
125+
*/
126+
@Override
127+
public void setBeanName(String beanName) {
128+
this.beanName = beanName;
129+
}
130+
131+
132+
/**
133+
* Implementation of the JCA 1.7 {@code #getActivationName()} method,
134+
* returning the bean name as set on this MessageEndpointFactory.
135+
* @see #setBeanName
136+
*/
137+
public String getActivationName() {
138+
return this.beanName;
139+
}
119140

120141
/**
121142
* This implementation returns {@code true} if a transaction manager
@@ -157,8 +178,7 @@ public MessageEndpoint createEndpoint(XAResource xaResource, long timeout) throw
157178
* @return the actual endpoint instance (never {@code null})
158179
* @throws UnavailableException if no endpoint is available at present
159180
*/
160-
protected abstract AbstractMessageEndpoint createEndpointInternal()
161-
throws UnavailableException;
181+
protected abstract AbstractMessageEndpoint createEndpointInternal() throws UnavailableException;
162182

163183

164184
/**

0 commit comments

Comments
 (0)