KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > springframework > jms > core > ProducerCallback


1 /*
2  * Copyright 2002-2006 the original author or authors.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
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.core;
18
19 import javax.jms.JMSException JavaDoc;
20 import javax.jms.MessageProducer JavaDoc;
21 import javax.jms.Session JavaDoc;
22
23 /**
24  * Callback for sending a message to a JMS destination.
25  *
26  * <p>To be used with the {@link JmsTemplate#execute(ProducerCallback)}
27  * method, often implemented as an anonymous inner class.
28  *
29  * <p>The typical implementation will perform multiple operations on the
30  * supplied JMS {@link Session} and {@link MessageProducer}. When used with
31  * a 1.0.2 provider, you need to downcast to the appropriate domain
32  * implementation, either {@link javax.jms.QueueSender} or
33  * {@link javax.jms.TopicPublisher}, to actually send a message.
34  *
35  * @author Mark Pollack
36  * @since 1.1
37  * @see JmsTemplate#execute(ProducerCallback)
38  */

39 public interface ProducerCallback {
40
41     /**
42      * Perform operations on the given {@link Session} and {@link MessageProducer}.
43      * <p>The message producer is not associated with any destination.
44      * @param session the JMS <code>Session</code> object to use
45      * @param producer the JMS <code>MessageProducer</code> object to use
46      * @return a result object from working with the <code>Session</code>, if any (can be <code>null</code>)
47      * @throws javax.jms.JMSException if thrown by JMS API methods
48      */

49     Object JavaDoc doInJms(Session JavaDoc session, MessageProducer JavaDoc producer) throws JMSException JavaDoc;
50
51 }
52
Popular Tags