1 /***
2 *
3 * Copyright 2005 LogicBlaze, Inc.
4 *
5 * Licensed under the Apache License, Version 2.0 (the "License");
6 * you may not use this file except in compliance with the License.
7 * You may obtain a copy of the License at
8 *
9 * http://www.apache.org/licenses/LICENSE-2.0
10 *
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 * See the License for the specific language governing permissions and
15 * limitations under the License.
16 *
17 **/
18 package org.logicblaze.lingo.jms.impl;
19
20 import EDU.oswego.cs.dl.util.concurrent.FutureResult;
21 import edu.emory.mathcs.backport.java.util.concurrent.Callable;
22 import edu.emory.mathcs.backport.java.util.concurrent.FutureTask;
23
24 import org.logicblaze.lingo.jms.ReplyHandler;
25
26 import javax.jms.JMSException;
27 import javax.jms.Message;
28
29 /***
30 * A {@link FutureResult} which implements
31 * {@link org.logicblaze.lingo.jms.ReplyHandler} so that it can be used as a
32 * handler for a correlation ID
33 *
34 * @version $Revision$
35 */
36 public class FutureHandler extends FutureTask implements ReplyHandler {
37
38 private static final Callable EMPTY_CALLABLE = new Callable() {
39 public Object call() throws Exception {
40 return null;
41 }
42 };
43
44 public FutureHandler() {
45 super(EMPTY_CALLABLE);
46 }
47
48 public synchronized void set(Object result) {
49 super.set(result);
50 }
51
52 public boolean handle(Message message) throws JMSException {
53 set(message);
54 return true;
55 }
56 }