01: /*
02: * Copyright 2002-2007 the original author or authors.
03: *
04: * Licensed under the Apache License, Version 2.0 (the "License");
05: * you may not use this file except in compliance with the License.
06: * You may obtain a copy of the License at
07: *
08: * http://www.apache.org/licenses/LICENSE-2.0
09: *
10: * Unless required by applicable law or agreed to in writing, software
11: * distributed under the License is distributed on an "AS IS" BASIS,
12: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13: * See the License for the specific language governing permissions and
14: * limitations under the License.
15: */
16:
17: package org.springframework.jms.support.converter;
18:
19: import javax.jms.JMSException;
20: import javax.jms.Message;
21: import javax.jms.Session;
22:
23: /**
24: * Strategy interface that specifies a converter between Java objects and JMS messages.
25: *
26: * <p>Check out {@link SimpleMessageConverter} for a default implementation,
27: * converting between the 'standard' message payloads and JMS Message types.
28: *
29: * @author Mark Pollack
30: * @author Juergen Hoeller
31: * @since 1.1
32: * @see org.springframework.jms.core.JmsTemplate#setMessageConverter
33: * @see org.springframework.jms.listener.adapter.MessageListenerAdapter#setMessageConverter
34: * @see org.springframework.jms.remoting.JmsInvokerClientInterceptor#setMessageConverter
35: * @see org.springframework.jms.remoting.JmsInvokerServiceExporter#setMessageConverter
36: */
37: public interface MessageConverter {
38:
39: /**
40: * Convert a Java object to a JMS Message using the supplied session
41: * to create the message object.
42: * @param object the object to convert
43: * @param session the Session to use for creating a JMS Message
44: * @return the JMS Message
45: * @throws javax.jms.JMSException if thrown by JMS API methods
46: * @throws MessageConversionException in case of conversion failure
47: */
48: Message toMessage(Object object, Session session)
49: throws JMSException, MessageConversionException;
50:
51: /**
52: * Convert from a JMS Message to a Java object.
53: * @param message the message to convert
54: * @return the converted Java object
55: * @throws javax.jms.JMSException if thrown by JMS API methods
56: * @throws MessageConversionException in case of conversion failure
57: */
58: Object fromMessage(Message message) throws JMSException,
59: MessageConversionException;
60:
61: }
|