Refactored FileWritingMessageHandlerFactoryBean

Brought FileWritingMessageHandlerFactoryBean into the hierarchy of AbstractSimpleMessageHandlerFactoryBean
This commit is contained in:
Oleg Zhurakousky
2011-10-18 15:58:05 -04:00
committed by Mark Fisher
parent 45da602837
commit 5a9a21bcee
5 changed files with 46 additions and 108 deletions

View File

@@ -27,10 +27,11 @@ import org.springframework.util.Assert;
/**
* @author Dave Syer
* @author Oleg Zhurakousky
*/
public abstract class AbstractSimpleMessageHandlerFactoryBean implements FactoryBean<MessageHandler>, BeanFactoryAware {
public abstract class AbstractSimpleMessageHandlerFactoryBean<M extends MessageHandler> implements FactoryBean<MessageHandler>, BeanFactoryAware {
private volatile MessageHandler handler;
private volatile M handler;
private volatile MessageChannel outputChannel;
@@ -63,7 +64,7 @@ public abstract class AbstractSimpleMessageHandlerFactoryBean implements Factory
return this.beanFactory;
}
public MessageHandler getObject() throws Exception {
public M getObject() throws Exception {
if (this.handler == null) {
this.handler = this.createHandlerInternal();
Assert.notNull(this.handler, "failed to create MessageHandler");
@@ -80,7 +81,7 @@ public abstract class AbstractSimpleMessageHandlerFactoryBean implements Factory
return this.handler;
}
protected final MessageHandler createHandlerInternal() {
protected final M createHandlerInternal() {
synchronized (this.initializationMonitor) {
if (this.initialized) {
// There was a problem when this method was called already
@@ -103,7 +104,7 @@ public abstract class AbstractSimpleMessageHandlerFactoryBean implements Factory
return handler;
}
protected abstract MessageHandler createHandler();
protected abstract M createHandler();
public Class<? extends MessageHandler> getObjectType() {
if (this.handler != null) {

View File

@@ -30,7 +30,7 @@ import org.springframework.util.StringUtils;
* @author Mark Fisher
* @author Alexander Peters
*/
abstract class AbstractStandardMessageHandlerFactoryBean extends AbstractSimpleMessageHandlerFactoryBean {
abstract class AbstractStandardMessageHandlerFactoryBean extends AbstractSimpleMessageHandlerFactoryBean<MessageHandler>{
private static final ExpressionParser expressionParser = new SpelExpressionParser(new SpelParserConfiguration(true,
true));

View File

@@ -37,7 +37,7 @@ import org.springframework.util.ReflectionUtils;
* @author Oleg Zhurakousky
* @since 2.0
*/
public class ExpressionControlBusFactoryBean extends AbstractSimpleMessageHandlerFactoryBean {
public class ExpressionControlBusFactoryBean extends AbstractSimpleMessageHandlerFactoryBean<MessageHandler> {
private volatile Long sendTimeout;