A while ago, I put on my todo list: "look into changing InvocationService to

use JVM generated proxies, nix marshaller/dispatcher."

The idea was to use Proxy.newProxyInstance to magically create (at runtime)
proxies for FooService interfaces instead of generating a bunch of boilerplate
code. I figured something similar could be done for FooDispatcher on the server
side.

However, we also generate C++ and ActionScript marshallers, and those aren't
ever going away (AS might support some sort of dynamic magic to do what we
need, but C++ sure don't). So I decided to leave the marshaller side of things
as is.

I did revamp the dispatcher side of things to eliminate the need for
FooDispatcher on the server. This turned out not to even require the use of
something so magical as java.lang.reflect.Proxy, because in this case we're
just reading in method ids over the network (and arguments), and calling the
appropriate method. Such mundane activities are easily accomplished with the
regular reflection API.

The existing dispatcher stuff still works as well, of course, and though the
conversion from the old style to the new style is pretty simple:

< invmgr.registerDispatcher(new FooDispatcher(fooprov))
> invmgr.registerProvider(fooprov, FooMarshaller.class)

there's no burning need to convert things over. Fortunately, there's no
(compatibility) impact on client projects to converting Narya and Vilya, so
I'll be doing that shortly. There will be a miniscule performance impact, but I
think the cost of a single reflective method call, given that all of its
arguments were read and unmarshalled from the network, will be a good distance
south of immaterial.


git-svn-id: svn+ssh://src.earth.threerings.net/narya/trunk@6403 542714f4-19e9-0310-aa3c-eee0fc999fb1
This commit is contained in:
Michael Bayne
2011-01-01 01:29:26 +00:00
parent 1db66920d2
commit 5a67aa906b
2 changed files with 152 additions and 7 deletions
@@ -30,6 +30,7 @@ import static com.threerings.presents.Log.log;
* Provides the base class via which invocation service requests are dispatched.
*/
public abstract class InvocationDispatcher<T extends InvocationMarshaller>
implements InvocationManager.Dispatcher
{
/** The invocation provider for whom we're dispatching. */
public InvocationProvider provider;
@@ -40,6 +41,11 @@ public abstract class InvocationDispatcher<T extends InvocationMarshaller>
*/
public abstract T createMarshaller ();
// from interface InvocationManager.Dispatcher
public InvocationProvider getProvider () {
return provider;
}
/**
* Dispatches the specified method to our provider.
*/