Clover coverage report -
Coverage timestamp: Thu Jul 5 2007 20:02:32 EDT
file stats: LOC: 84   Methods: 2
NCLOC: 60   Classes: 1
 
 Source file Conditionals Statements Methods TOTAL
InactiveRegionAwareRpcDispatcher.java 31.8% 53.3% 100% 46.3%
coverage coverage
 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    * Extends {@link org.jgroups.blocks.RpcDispatcher} and adds the possibility that the marshaller may throw {@link org.jboss.cache.marshall.InactiveRegionException}s.
 12    *
 13    * @author <a href="mailto:manik@jboss.org">Manik Surtani</a>
 14    * @since 2.0.0
 15    */
 16    public class InactiveRegionAwareRpcDispatcher extends RpcDispatcher
 17    {
 18    /**
 19    * Only provide the flavour of the {@link RpcDispatcher} constructor that we care about.
 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    * Message contains MethodCall. Execute it against *this* object and return result.
 28    * Use MethodCall.invoke() to do this. Return result.
 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    }