1
1
/*
2
- * Copyright 2002-2012 the original author or authors.
2
+ * Copyright 2002-2013 the original author or authors.
3
3
*
4
4
* Licensed under the Apache License, Version 2.0 (the "License");
5
5
* you may not use this file except in compliance with the License.
29
29
import org .apache .commons .logging .Log ;
30
30
import org .apache .commons .logging .LogFactory ;
31
31
32
+ import org .springframework .beans .factory .BeanNameAware ;
32
33
import org .springframework .transaction .jta .SimpleTransactionFactory ;
33
34
import org .springframework .transaction .jta .TransactionFactory ;
34
35
35
36
/**
36
- * Abstract base implementation of the JCA 1.5/1.6
37
+ * Abstract base implementation of the JCA 1.5/1.6/1.7
37
38
* {@link javax.resource.spi.endpoint.MessageEndpointFactory} interface,
38
39
* providing transaction management capabilities as well as ClassLoader
39
40
* exposure for endpoint invocations.
42
43
* @since 2.5
43
44
* @see #setTransactionManager
44
45
*/
45
- public abstract class AbstractMessageEndpointFactory implements MessageEndpointFactory {
46
+ public abstract class AbstractMessageEndpointFactory implements MessageEndpointFactory , BeanNameAware {
46
47
47
48
/** Logger available to subclasses */
48
49
protected final Log logger = LogFactory .getLog (getClass ());
@@ -53,6 +54,8 @@ public abstract class AbstractMessageEndpointFactory implements MessageEndpointF
53
54
54
55
private int transactionTimeout = -1 ;
55
56
57
+ private String beanName ;
58
+
56
59
57
60
/**
58
61
* Set the the XA transaction manager to use for wrapping endpoint
@@ -116,6 +119,24 @@ public void setTransactionTimeout(int transactionTimeout) {
116
119
this .transactionTimeout = transactionTimeout ;
117
120
}
118
121
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
+ }
119
140
120
141
/**
121
142
* This implementation returns {@code true} if a transaction manager
@@ -157,8 +178,7 @@ public MessageEndpoint createEndpoint(XAResource xaResource, long timeout) throw
157
178
* @return the actual endpoint instance (never {@code null})
158
179
* @throws UnavailableException if no endpoint is available at present
159
180
*/
160
- protected abstract AbstractMessageEndpoint createEndpointInternal ()
161
- throws UnavailableException ;
181
+ protected abstract AbstractMessageEndpoint createEndpointInternal () throws UnavailableException ;
162
182
163
183
164
184
/**
0 commit comments