SPR-5507 GenericMessageEndpointManager now implements SmartLifecycle instead of ApplicationListener.

This commit is contained in:
Mark Fisher 2009-11-10 12:59:50 +00:00
parent a15a9600b7
commit d5fd22c8fe
1 changed files with 9 additions and 15 deletions

View File

@ -23,10 +23,7 @@ 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.SmartLifecycle;
import org.springframework.context.ApplicationListener;
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
@ -147,8 +144,7 @@ import org.springframework.context.event.ContextRefreshedEvent;
* @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 public class GenericMessageEndpointManager implements SmartLifecycle, InitializingBean, DisposableBean {
implements ApplicationListener<ApplicationEvent>, Lifecycle, InitializingBean, DisposableBean {
private ResourceAdapter resourceAdapter; private ResourceAdapter resourceAdapter;
@ -222,6 +218,13 @@ public class GenericMessageEndpointManager
this.autoStartup = autoStartup; this.autoStartup = autoStartup;
} }
/**
* Return the value for the 'autoStartup' property. If "true", this
* endpoint manager will start upon a ContextRefreshedEvent.
*/
public boolean isAutoStartup() {
return this.autoStartup;
}
/** /**
* Prepares the message endpoint, and automatically activates it * Prepares the message endpoint, and automatically activates it
@ -248,15 +251,6 @@ public class GenericMessageEndpointManager
} }
} }
/**
* Start upon a ContextRefreshedEvent if the 'autoStartup' property value is "true".
*/
public void onApplicationEvent(ApplicationEvent event) {
if (event instanceof ContextRefreshedEvent && this.autoStartup) {
start();
}
}
/** /**
* Activates the configured message endpoint. * Activates the configured message endpoint.
*/ */