I understand all of the new code is in the new package
org.jgroups.blocks.scope. If that's the case, I suggest add and commit
your changes so you can experiment with them.
I also recall Galder needed to change some method from private to
protected, why don't you go ahead and do this too ?
Paul Ferraro wrote:
I've modified Bela's existing sample code to address the
issues Brian
and I discussed below. Here's a summary of the changes:
* Refactored pieces into separate classes with nicer names
* ScopedRpcDispatcher registers its scope with a ScopedUpHandler
* Added ScopeUpHandler deregistration on ScopedRpcDispatcher.stop().
* ScopedUpHandler accepts an optional default handler, which will be
triggered for non-message events or messages with no scope header
* ScopedUpHandler returns NoHandlerForScope object if message is
received for an unknown scope (e.g. its handler was not yet registered
or was already deregistered)
* Automatically adds RspFilter to RequestOptions that rejects
NoHandlerForScope responses, decorating any existing filter, if
necessary.
* Added ScopedMessageDispatcher analogue
So, usage would look like:
Channel c = new JChannel(...);
ScopedUpHandler h = new ScopedUpHandlerImpl();
ScopedRpcDispatcher d1 = new ScopedRpcDispatcher((short)1, h, c, null, null, target1);
ScopedRpcDispatcher d2 = new ScopedRpcDispatcher((short)2, h, c, null, null, target2);
// This must be set after all rpc dispatchers are created
c.setUpHandler(h);
c.connect(...);
This will also work in conjunction with a standard rpc dispatcher:
Channel c = new JChannel(...);
RpcDispatcher d = new RpcDispatcher(c, null, null, target);
ScopedUpHandler h = new ScopedUpHandlerImpl(d.getProtocolAdapter());
ScopedRpcDispatcher d1 = new ScopedRpcDispatcher((short)1, h, c, null, null, target1);
ScopedRpcDispatcher d2 = new ScopedRpcDispatcher((short)2, h, c, null, null, target2);
c.setUpHandler(h);
c.connect(...);
I've attached the changes in the form of a patch to JGRP-1177.
Comments are welcome.
Paul
--
Bela Ban
Lead JGroups / Clustering Team
JBoss