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.PullPushAdapter; 9 import org.jgroups.blocks.RpcDispatcher; 10 11 import java.io.Serializable ; 12 13 19 public class InactiveRegionAwareRpcDispatcher extends RpcDispatcher 20 { 21 public InactiveRegionAwareRpcDispatcher(Channel channel, MessageListener l, MembershipListener l2, Object server_obj) 22 { 23 super(channel, l, l2, server_obj); 24 } 25 26 public InactiveRegionAwareRpcDispatcher(Channel channel, MessageListener l, MembershipListener l2, Object server_obj, boolean deadlock_detection) 27 { 28 super(channel, l, l2, server_obj, deadlock_detection); 29 } 30 31 public InactiveRegionAwareRpcDispatcher(Channel channel, MessageListener l, MembershipListener l2, Object server_obj, boolean deadlock_detection, boolean concurrent_processing) 32 { 33 super(channel, l, l2, server_obj, deadlock_detection, concurrent_processing); 34 } 35 36 public InactiveRegionAwareRpcDispatcher(PullPushAdapter adapter, Serializable id, MessageListener l, MembershipListener l2, Object server_obj) 37 { 38 super(adapter, id, l, l2, server_obj); 39 } 40 41 45 @Override 46 public Object handle(Message req) 47 { 48 Object body = null; 49 org.jgroups.blocks.MethodCall method_call; 50 51 if (server_obj == null) 52 { 53 if (log.isErrorEnabled()) log.error("no method handler is registered. Discarding request."); 54 return null; 55 } 56 57 if (req == null || req.getLength() == 0) 58 { 59 if (log.isErrorEnabled()) log.error("message or message buffer is null"); 60 return null; 61 } 62 63 try 64 { 65 body = req_marshaller != null ? req_marshaller.objectFromByteBuffer(req.getBuffer()) : req.getObject(); 66 } 67 catch (Throwable e) 68 { 69 if (e instanceof InactiveRegionException) 70 { 71 if (log.isTraceEnabled()) log.trace("Exception from marshaller: " + e.getMessage()); 72 return null; 73 } 74 75 if (log.isErrorEnabled()) log.error("exception marshalling object", e); 76 return e; 77 } 78 79 if (body == null || !(body instanceof MethodCall)) 80 { 81 if (log.isErrorEnabled()) log.error("message does not contain a MethodCall object"); 82 return null; 83 } 84 85 method_call = (MethodCall) body; 86 87 try 88 { 89 if (log.isTraceEnabled()) 90 log.trace("[sender=" + req.getSrc() + "], method_call: " + method_call); 91 92 return method_call.invoke(server_obj); 93 } 94 catch (Throwable x) 95 { 96 return x; 97 } 98 } 99 } 100 | Popular Tags |