1 |
| package org.jboss.cache.marshall; |
2 |
| |
3 |
| import org.jgroups.Channel; |
4 |
| import org.jgroups.MembershipListener; |
5 |
| import org.jgroups.Message; |
6 |
| import org.jgroups.MessageListener; |
7 |
| import org.jgroups.blocks.MethodCall; |
8 |
| import org.jgroups.blocks.RpcDispatcher; |
9 |
| |
10 |
| |
11 |
| |
12 |
| |
13 |
| |
14 |
| |
15 |
| |
16 |
| public class InactiveRegionAwareRpcDispatcher extends RpcDispatcher |
17 |
| { |
18 |
| |
19 |
| |
20 |
| |
21 |
1097
| public InactiveRegionAwareRpcDispatcher(Channel channel, MessageListener l, MembershipListener l2, Object server_obj)
|
22 |
| { |
23 |
1097
| super(channel, l, l2, server_obj);
|
24 |
| } |
25 |
| |
26 |
| |
27 |
| |
28 |
| |
29 |
| |
30 |
163861
| @Override
|
31 |
| public Object handle(Message req) |
32 |
| { |
33 |
163861
| Object body = null;
|
34 |
163861
| org.jgroups.blocks.MethodCall method_call;
|
35 |
| |
36 |
163861
| if (server_obj == null)
|
37 |
| { |
38 |
0
| if (log.isErrorEnabled()) log.error("no method handler is registered. Discarding request.");
|
39 |
0
| return null;
|
40 |
| } |
41 |
| |
42 |
163861
| if (req == null || req.getLength() == 0)
|
43 |
| { |
44 |
0
| if (log.isErrorEnabled()) log.error("message or message buffer is null");
|
45 |
0
| return null;
|
46 |
| } |
47 |
| |
48 |
163861
| try
|
49 |
| { |
50 |
163861
| body = req_marshaller != null ? req_marshaller.objectFromByteBuffer(req.getBuffer()) : req.getObject();
|
51 |
| } |
52 |
| catch (Throwable e) |
53 |
| { |
54 |
56
| if (e instanceof InactiveRegionException)
|
55 |
| { |
56 |
0
| if (log.isTraceEnabled()) log.trace("Exception from marshaller: " + e.getMessage());
|
57 |
56
| return null;
|
58 |
| } |
59 |
| |
60 |
0
| if (log.isErrorEnabled()) log.error("exception marshalling object", e);
|
61 |
0
| return e;
|
62 |
| } |
63 |
| |
64 |
163805
| if (body == null || !(body instanceof MethodCall))
|
65 |
| { |
66 |
0
| if (log.isErrorEnabled()) log.error("message does not contain a MethodCall object");
|
67 |
0
| return null;
|
68 |
| } |
69 |
| |
70 |
163805
| method_call = (MethodCall) body;
|
71 |
| |
72 |
163805
| try
|
73 |
| { |
74 |
163805
| if (log.isTraceEnabled())
|
75 |
0
| log.trace("[sender=" + req.getSrc() + "], method_call: " + method_call);
|
76 |
| |
77 |
163805
| return method_call.invoke(server_obj);
|
78 |
| } |
79 |
| catch (Throwable x) |
80 |
| { |
81 |
30
| return x;
|
82 |
| } |
83 |
| } |
84 |
| } |