|
1 |
| |
|
2 |
| |
|
3 |
| |
|
4 |
| |
|
5 |
| |
|
6 |
| |
|
7 |
| |
|
8 |
| |
|
9 |
| |
|
10 |
| |
|
11 |
| |
|
12 |
| |
|
13 |
| |
|
14 |
| |
|
15 |
| |
|
16 |
| package org.codehaus.wadi.group.impl; |
|
17 |
| |
|
18 |
| import java.io.Serializable; |
|
19 |
| import java.lang.reflect.Method; |
|
20 |
| import org.codehaus.wadi.group.Dispatcher; |
|
21 |
| import org.codehaus.wadi.group.Envelope; |
|
22 |
| |
|
23 |
| |
|
24 |
| |
|
25 |
| |
|
26 |
| |
|
27 |
| class PayloadMsgDispatcher extends AbstractMsgMethodDispatcher { |
|
28 |
| private final ThreadLocal _singleton = new ThreadLocal() { |
|
29 |
0
| protected Object initialValue() {
|
|
30 |
0
| return new Object[1];
|
|
31 |
| } |
|
32 |
| }; |
|
33 |
| |
|
34 |
0
| public PayloadMsgDispatcher(Dispatcher dispatcher, Object target, Method method, Class type) {
|
|
35 |
0
| super(dispatcher, target, method, type);
|
|
36 |
| } |
|
37 |
| |
|
38 |
0
| public void dispatch(Envelope envelope) throws Exception {
|
|
39 |
0
| Object[] singleton = (Object[]) _singleton.get();
|
|
40 |
0
| singleton[0] = envelope.getPayload();
|
|
41 |
0
| Object response = invoke(singleton);
|
|
42 |
0
| _dispatcher.reply(envelope, (Serializable) response);
|
|
43 |
| } |
|
44 |
| |
|
45 |
0
| public String toString() {
|
|
46 |
0
| return "<PayloadMsgDispatcher: " + _method + " dispatched on: " + _target + ">";
|
|
47 |
| } |
|
48 |
| } |