SPR-4716 GenericMessageEndpointManager now "auto-starts" upon receiving a ContextRefreshedEvent rather than within afterPropertiesSet().
git-svn-id: https://src.springframework.org/svn/spring-framework/trunk@2276 50f2f4bb-b051-0410-bef5-90022cba6387
This commit is contained in:
parent
8f3bf2c779
commit
b47eebe3c5
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright 2002-2007 the original author or authors.
|
* Copyright 2002-2009 the original author or authors.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
|
|
@ -23,7 +23,10 @@ import javax.resource.spi.endpoint.MessageEndpointFactory;
|
||||||
|
|
||||||
import org.springframework.beans.factory.DisposableBean;
|
import org.springframework.beans.factory.DisposableBean;
|
||||||
import org.springframework.beans.factory.InitializingBean;
|
import org.springframework.beans.factory.InitializingBean;
|
||||||
|
import org.springframework.context.ApplicationEvent;
|
||||||
|
import org.springframework.context.ApplicationListener;
|
||||||
import org.springframework.context.Lifecycle;
|
import org.springframework.context.Lifecycle;
|
||||||
|
import org.springframework.context.event.ContextRefreshedEvent;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Generic bean that manages JCA 1.5 message endpoints within a Spring
|
* Generic bean that manages JCA 1.5 message endpoints within a Spring
|
||||||
|
|
@ -144,7 +147,8 @@ import org.springframework.context.Lifecycle;
|
||||||
* @see javax.resource.spi.endpoint.MessageEndpointFactory
|
* @see javax.resource.spi.endpoint.MessageEndpointFactory
|
||||||
* @see javax.resource.spi.ActivationSpec
|
* @see javax.resource.spi.ActivationSpec
|
||||||
*/
|
*/
|
||||||
public class GenericMessageEndpointManager implements InitializingBean, Lifecycle, DisposableBean {
|
public class GenericMessageEndpointManager
|
||||||
|
implements ApplicationListener<ApplicationEvent>, Lifecycle, InitializingBean, DisposableBean {
|
||||||
|
|
||||||
private ResourceAdapter resourceAdapter;
|
private ResourceAdapter resourceAdapter;
|
||||||
|
|
||||||
|
|
@ -209,8 +213,8 @@ public class GenericMessageEndpointManager implements InitializingBean, Lifecycl
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set whether to auto-start the endpoint activation along with
|
* Set whether to auto-start the endpoint activation after this endpoint
|
||||||
* this endpoint manager's initialization.
|
* manager has been initialized and the context has been refreshed.
|
||||||
* <p>Default is "true". Turn this flag off to defer the endpoint
|
* <p>Default is "true". Turn this flag off to defer the endpoint
|
||||||
* activation until an explicit {#start()} call.
|
* activation until an explicit {#start()} call.
|
||||||
*/
|
*/
|
||||||
|
|
@ -242,8 +246,13 @@ public class GenericMessageEndpointManager implements InitializingBean, Lifecycl
|
||||||
throw new IllegalArgumentException("ActivationSpec [" + activationSpec +
|
throw new IllegalArgumentException("ActivationSpec [" + activationSpec +
|
||||||
"] is associated with a different ResourceAdapter: " + activationSpec.getResourceAdapter());
|
"] is associated with a different ResourceAdapter: " + activationSpec.getResourceAdapter());
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (this.autoStartup) {
|
/**
|
||||||
|
* Start upon a ContextRefreshedEvent if the 'autoStartup' property value is "true".
|
||||||
|
*/
|
||||||
|
public void onApplicationEvent(ApplicationEvent event) {
|
||||||
|
if (event instanceof ContextRefreshedEvent && this.autoStartup) {
|
||||||
start();
|
start();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue