Type the marshaller and associated registry methods so that we don't have to
downcast every time we register an invocation service provider. git-svn-id: svn+ssh://src.earth.threerings.net/narya/trunk@5201 542714f4-19e9-0310-aa3c-eee0fc999fb1
This commit is contained in:
@@ -33,7 +33,6 @@ import com.threerings.presents.data.ClientObject;
|
|||||||
import com.threerings.presents.data.InvocationMarshaller.ListenerMarshaller;
|
import com.threerings.presents.data.InvocationMarshaller.ListenerMarshaller;
|
||||||
|
|
||||||
import com.threerings.presents.dobj.DEvent;
|
import com.threerings.presents.dobj.DEvent;
|
||||||
import com.threerings.presents.dobj.DObject;
|
|
||||||
import com.threerings.presents.dobj.DObjectManager;
|
import com.threerings.presents.dobj.DObjectManager;
|
||||||
import com.threerings.presents.dobj.DSet;
|
import com.threerings.presents.dobj.DSet;
|
||||||
import com.threerings.presents.dobj.EventListener;
|
import com.threerings.presents.dobj.EventListener;
|
||||||
|
|||||||
@@ -24,7 +24,6 @@ package com.threerings.presents.data;
|
|||||||
import com.threerings.presents.client.Client;
|
import com.threerings.presents.client.Client;
|
||||||
import com.threerings.presents.client.TimeBaseService;
|
import com.threerings.presents.client.TimeBaseService;
|
||||||
import com.threerings.presents.dobj.InvocationResponseEvent;
|
import com.threerings.presents.dobj.InvocationResponseEvent;
|
||||||
import com.threerings.presents.net.Transport;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Provides the implementation of the {@link TimeBaseService} interface
|
* Provides the implementation of the {@link TimeBaseService} interface
|
||||||
|
|||||||
@@ -23,7 +23,6 @@ package com.threerings.presents.peer.data;
|
|||||||
|
|
||||||
import com.threerings.presents.client.Client;
|
import com.threerings.presents.client.Client;
|
||||||
import com.threerings.presents.data.InvocationMarshaller;
|
import com.threerings.presents.data.InvocationMarshaller;
|
||||||
import com.threerings.presents.net.Transport;
|
|
||||||
import com.threerings.presents.peer.client.PeerService;
|
import com.threerings.presents.peer.client.PeerService;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -22,7 +22,6 @@
|
|||||||
package com.threerings.presents.peer.server;
|
package com.threerings.presents.peer.server;
|
||||||
|
|
||||||
import com.threerings.presents.data.ClientObject;
|
import com.threerings.presents.data.ClientObject;
|
||||||
import com.threerings.presents.data.InvocationMarshaller;
|
|
||||||
import com.threerings.presents.peer.data.NodeObject;
|
import com.threerings.presents.peer.data.NodeObject;
|
||||||
import com.threerings.presents.peer.data.PeerMarshaller;
|
import com.threerings.presents.peer.data.PeerMarshaller;
|
||||||
import com.threerings.presents.server.InvocationDispatcher;
|
import com.threerings.presents.server.InvocationDispatcher;
|
||||||
@@ -31,7 +30,7 @@ import com.threerings.presents.server.InvocationException;
|
|||||||
/**
|
/**
|
||||||
* Dispatches requests to the {@link PeerProvider}.
|
* Dispatches requests to the {@link PeerProvider}.
|
||||||
*/
|
*/
|
||||||
public class PeerDispatcher extends InvocationDispatcher
|
public class PeerDispatcher extends InvocationDispatcher<PeerMarshaller>
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* Creates a dispatcher that may be registered to dispatch invocation
|
* Creates a dispatcher that may be registered to dispatch invocation
|
||||||
@@ -43,7 +42,7 @@ public class PeerDispatcher extends InvocationDispatcher
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override // documentation inherited
|
@Override // documentation inherited
|
||||||
public InvocationMarshaller createMarshaller ()
|
public PeerMarshaller createMarshaller ()
|
||||||
{
|
{
|
||||||
return new PeerMarshaller();
|
return new PeerMarshaller();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -29,25 +29,23 @@ import com.threerings.presents.data.InvocationMarshaller;
|
|||||||
import static com.threerings.presents.Log.log;
|
import static com.threerings.presents.Log.log;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Provides the base class via which invocation service requests are
|
* Provides the base class via which invocation service requests are dispatched.
|
||||||
* dispatched.
|
|
||||||
*/
|
*/
|
||||||
public abstract class InvocationDispatcher
|
public abstract class InvocationDispatcher<T extends InvocationMarshaller>
|
||||||
{
|
{
|
||||||
/** The invocation provider for whom we're dispatching. */
|
/** The invocation provider for whom we're dispatching. */
|
||||||
public InvocationProvider provider;
|
public InvocationProvider provider;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates an instance of the appropriate {@link InvocationMarshaller}
|
* Creates an instance of the appropriate {@link InvocationMarshaller} derived class for use
|
||||||
* derived class for use with this dispatcher.
|
* with this dispatcher.
|
||||||
*/
|
*/
|
||||||
public abstract InvocationMarshaller createMarshaller ();
|
public abstract T createMarshaller ();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Dispatches the specified method to our provider.
|
* Dispatches the specified method to our provider.
|
||||||
*/
|
*/
|
||||||
public void dispatchRequest (
|
public void dispatchRequest (ClientObject source, int methodId, Object[] args)
|
||||||
ClientObject source, int methodId, Object[] args)
|
|
||||||
throws InvocationException
|
throws InvocationException
|
||||||
{
|
{
|
||||||
log.warning("Requested to dispatch unknown method " +
|
log.warning("Requested to dispatch unknown method " +
|
||||||
|
|||||||
@@ -102,7 +102,7 @@ public class InvocationManager
|
|||||||
*
|
*
|
||||||
* @param dispatcher the dispatcher to be registered.
|
* @param dispatcher the dispatcher to be registered.
|
||||||
*/
|
*/
|
||||||
public InvocationMarshaller registerDispatcher (InvocationDispatcher dispatcher)
|
public <T extends InvocationMarshaller> T registerDispatcher (InvocationDispatcher<T> dispatcher)
|
||||||
{
|
{
|
||||||
return registerDispatcher(dispatcher, null);
|
return registerDispatcher(dispatcher, null);
|
||||||
}
|
}
|
||||||
@@ -110,8 +110,8 @@ public class InvocationManager
|
|||||||
/**
|
/**
|
||||||
* @Deprecated use {@link #registerDispatcher(InvocationDispatcher)}.
|
* @Deprecated use {@link #registerDispatcher(InvocationDispatcher)}.
|
||||||
*/
|
*/
|
||||||
public InvocationMarshaller registerDispatcher (
|
public <T extends InvocationMarshaller> T registerDispatcher (
|
||||||
InvocationDispatcher dispatcher, boolean bootstrap)
|
InvocationDispatcher<T> dispatcher, boolean bootstrap)
|
||||||
{
|
{
|
||||||
return registerDispatcher(dispatcher, null);
|
return registerDispatcher(dispatcher, null);
|
||||||
}
|
}
|
||||||
@@ -126,13 +126,14 @@ public class InvocationManager
|
|||||||
* groups. You must collect shared dispatchers into as fine grained a set of groups as
|
* groups. You must collect shared dispatchers into as fine grained a set of groups as
|
||||||
* necessary and have different types of clients specify the list of groups they need.
|
* necessary and have different types of clients specify the list of groups they need.
|
||||||
*/
|
*/
|
||||||
public InvocationMarshaller registerDispatcher (InvocationDispatcher dispatcher, String group)
|
public <T extends InvocationMarshaller> T registerDispatcher (
|
||||||
|
InvocationDispatcher<T> dispatcher, String group)
|
||||||
{
|
{
|
||||||
// get the next invocation code
|
// get the next invocation code
|
||||||
int invCode = nextInvCode();
|
int invCode = nextInvCode();
|
||||||
|
|
||||||
// create the marshaller and initialize it
|
// create the marshaller and initialize it
|
||||||
InvocationMarshaller marsh = dispatcher.createMarshaller();
|
T marsh = dispatcher.createMarshaller();
|
||||||
marsh.init(_invoid, invCode);
|
marsh.init(_invoid, invCode);
|
||||||
|
|
||||||
// register the dispatcher
|
// register the dispatcher
|
||||||
|
|||||||
@@ -29,7 +29,7 @@ import com.threerings.presents.data.TimeBaseMarshaller;
|
|||||||
/**
|
/**
|
||||||
* Dispatches requests to the {@link TimeBaseProvider}.
|
* Dispatches requests to the {@link TimeBaseProvider}.
|
||||||
*/
|
*/
|
||||||
public class TimeBaseDispatcher extends InvocationDispatcher
|
public class TimeBaseDispatcher extends InvocationDispatcher<TimeBaseMarshaller>
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* Creates a dispatcher that may be registered to dispatch invocation
|
* Creates a dispatcher that may be registered to dispatch invocation
|
||||||
@@ -41,7 +41,7 @@ public class TimeBaseDispatcher extends InvocationDispatcher
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override // documentation inherited
|
@Override // documentation inherited
|
||||||
public InvocationMarshaller createMarshaller ()
|
public TimeBaseMarshaller createMarshaller ()
|
||||||
{
|
{
|
||||||
return new TimeBaseMarshaller();
|
return new TimeBaseMarshaller();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -7,7 +7,7 @@ import $import;
|
|||||||
/**
|
/**
|
||||||
* Dispatches requests to the {@link ${name}Provider}.
|
* Dispatches requests to the {@link ${name}Provider}.
|
||||||
*/
|
*/
|
||||||
public class ${name}Dispatcher extends InvocationDispatcher
|
public class ${name}Dispatcher extends InvocationDispatcher<${name}Marshaller>
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* Creates a dispatcher that may be registered to dispatch invocation
|
* Creates a dispatcher that may be registered to dispatch invocation
|
||||||
@@ -19,7 +19,7 @@ public class ${name}Dispatcher extends InvocationDispatcher
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override // documentation inherited
|
@Override // documentation inherited
|
||||||
public InvocationMarshaller createMarshaller ()
|
public ${name}Marshaller createMarshaller ()
|
||||||
{
|
{
|
||||||
return new ${name}Marshaller();
|
return new ${name}Marshaller();
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user