From c0c8fa111bf4e7ed9c0ee5f88e534d1880d75a0c Mon Sep 17 00:00:00 2001 From: dsyer Date: Tue, 26 Aug 2008 07:02:39 +0000 Subject: [PATCH] OPEN - issue BATCH-777: Parametrise RetryCallback and related interfaces Rationalise JmsItemReader --- .../batch/item/jms/JmsItemReader.java | 34 +++++++++- .../batch/item/jms/MessageTypeAccessor.java | 68 ------------------- 2 files changed, 33 insertions(+), 69 deletions(-) delete mode 100644 spring-batch-infrastructure/src/main/java/org/springframework/batch/item/jms/MessageTypeAccessor.java diff --git a/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/jms/JmsItemReader.java b/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/jms/JmsItemReader.java index 72a8c3281..6957fc44b 100644 --- a/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/jms/JmsItemReader.java +++ b/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/jms/JmsItemReader.java @@ -18,7 +18,10 @@ package org.springframework.batch.item.jms; import javax.jms.Message; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; import org.springframework.batch.item.ItemReader; +import org.springframework.jms.core.JmsOperations; import org.springframework.jms.core.JmsTemplate; import org.springframework.util.Assert; @@ -33,8 +36,37 @@ import org.springframework.util.Assert; * @author Dave Syer * */ -public class JmsItemReader extends MessageTypeAccessor implements ItemReader { +public class JmsItemReader implements ItemReader { + protected Log logger = LogFactory.getLog(getClass()); + + protected Class itemType; + + protected JmsOperations jmsTemplate; + + /** + * Setter for jms template. + * + * @param jmsTemplate a {@link JmsOperations} instance + */ + public void setJmsTemplate(JmsOperations jmsTemplate) { + this.jmsTemplate = jmsTemplate; + } + + /** + * Set the expected type of incoming message payloads. Set this to + * {@link Message} to receive the raw underlying message. + * + * @param itemType the java class of the items to be delivered. Typically + * the same as the class parameter + * + * @throws IllegalStateException if the message payload is of the wrong + * type. + */ + public void setItemType(Class itemType) { + this.itemType = itemType; + } + @SuppressWarnings("unchecked") public T read() { if (itemType != null && itemType.isAssignableFrom(Message.class)) { diff --git a/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/jms/MessageTypeAccessor.java b/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/jms/MessageTypeAccessor.java deleted file mode 100644 index c78a90c2c..000000000 --- a/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/jms/MessageTypeAccessor.java +++ /dev/null @@ -1,68 +0,0 @@ -/* - * Copyright 2006-2007 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.springframework.batch.item.jms; - -import javax.jms.Message; - -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; -import org.springframework.jms.core.JmsOperations; - -/** - * Base class for JMS concerns. - * - * @author Dave Syer - * - */ -class MessageTypeAccessor { - - protected Log logger = LogFactory.getLog(getClass()); - - protected Class itemType; - - protected JmsOperations jmsTemplate; - - /** - * Setter for jms template. - * - * @param jmsTemplate a {@link JmsOperations} instance - */ - public void setJmsTemplate(JmsOperations jmsTemplate) { - this.jmsTemplate = jmsTemplate; - } - - /** - * Set the expected type of incoming message payloads. Set this to - * {@link Message} to receive the raw underlying message. - * - * @param itemType the java class of the items to be delivered. Typically - * the same as the class parameter - * - * @throws IllegalStateException if the message payload is of the wrong - * type. - */ - public void setItemType(Class itemType) { - this.itemType = itemType; - } - - public boolean isMessageType() { - return itemType != null && itemType.isAssignableFrom(Message.class); - } - - - -}