Skip to content

Commit d96bea9

Browse files
committedNov 6, 2009
SPR-4716 GenericMessageEndpointManager now "auto-starts" upon receiving a ContextRefreshedEvent rather than within afterPropertiesSet().
1 parent d415d36 commit d96bea9

File tree

1 file changed

+14
-5
lines changed

1 file changed

+14
-5
lines changed
 

‎org.springframework.transaction/src/main/java/org/springframework/jca/endpoint/GenericMessageEndpointManager.java

+14-5
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2007 the original author or authors.
2+
* Copyright 2002-2009 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.
@@ -23,7 +23,10 @@
2323

2424
import org.springframework.beans.factory.DisposableBean;
2525
import org.springframework.beans.factory.InitializingBean;
26+
import org.springframework.context.ApplicationEvent;
27+
import org.springframework.context.ApplicationListener;
2628
import org.springframework.context.Lifecycle;
29+
import org.springframework.context.event.ContextRefreshedEvent;
2730

2831
/**
2932
* Generic bean that manages JCA 1.5 message endpoints within a Spring
@@ -144,7 +147,8 @@
144147
* @see javax.resource.spi.endpoint.MessageEndpointFactory
145148
* @see javax.resource.spi.ActivationSpec
146149
*/
147-
public class GenericMessageEndpointManager implements InitializingBean, Lifecycle, DisposableBean {
150+
public class GenericMessageEndpointManager
151+
implements ApplicationListener<ApplicationEvent>, Lifecycle, InitializingBean, DisposableBean {
148152

149153
private ResourceAdapter resourceAdapter;
150154

@@ -209,8 +213,8 @@ public ActivationSpec getActivationSpec() {
209213
}
210214

211215
/**
212-
* Set whether to auto-start the endpoint activation along with
213-
* this endpoint manager's initialization.
216+
* Set whether to auto-start the endpoint activation after this endpoint
217+
* manager has been initialized and the context has been refreshed.
214218
* <p>Default is "true". Turn this flag off to defer the endpoint
215219
* activation until an explicit {#start()} call.
216220
*/
@@ -242,8 +246,13 @@ else if (activationSpec.getResourceAdapter() != getResourceAdapter()) {
242246
throw new IllegalArgumentException("ActivationSpec [" + activationSpec +
243247
"] is associated with a different ResourceAdapter: " + activationSpec.getResourceAdapter());
244248
}
249+
}
245250

246-
if (this.autoStartup) {
251+
/**
252+
* Start upon a ContextRefreshedEvent if the 'autoStartup' property value is "true".
253+
*/
254+
public void onApplicationEvent(ApplicationEvent event) {
255+
if (event instanceof ContextRefreshedEvent && this.autoStartup) {
247256
start();
248257
}
249258
}

0 commit comments

Comments
 (0)