Switched providers to new dynamic dispatching.

git-svn-id: svn+ssh://src.earth.threerings.net/narya/trunk@6404 542714f4-19e9-0310-aa3c-eee0fc999fb1
This commit is contained in:
Michael Bayne
2011-01-01 01:31:20 +00:00
parent 5a67aa906b
commit f8c7241f9f
12 changed files with 53 additions and 17 deletions
@@ -30,6 +30,7 @@ import com.threerings.presents.server.InvocationManager;
import com.threerings.admin.client.AdminService;
import com.threerings.admin.data.AdminCodes;
import com.threerings.admin.data.AdminMarshaller;
/**
* Handles admin stuffs.
@@ -40,7 +41,7 @@ public class AdminManager
{
@Inject public AdminManager (InvocationManager invmgr)
{
invmgr.registerDispatcher(new AdminDispatcher(this), AdminCodes.ADMIN_GROUP);
invmgr.registerProvider(this, AdminMarshaller.class, AdminCodes.ADMIN_GROUP);
}
// from interface AdminProvider
@@ -50,6 +50,7 @@ import com.threerings.bureau.data.AgentObject;
import com.threerings.bureau.data.BureauAuthName;
import com.threerings.bureau.data.BureauCodes;
import com.threerings.bureau.data.BureauCredentials;
import com.threerings.bureau.data.BureauMarshaller;
import com.threerings.bureau.util.BureauLogRedirector;
import static com.threerings.bureau.Log.log;
@@ -102,7 +103,7 @@ public class BureauRegistry
@Inject public BureauRegistry (
InvocationManager invmgr, PresentsConnectionManager conmgr, ClientManager clmgr)
{
invmgr.registerDispatcher(new BureauDispatcher(new BureauProvider() {
invmgr.registerProvider(new BureauProvider() {
public void bureauInitialized (ClientObject client, String bureauId) {
BureauRegistry.this.bureauInitialized(client, bureauId);
}
@@ -118,7 +119,7 @@ public class BureauRegistry
public void agentDestroyed (ClientObject client, int agentId) {
BureauRegistry.this.agentDestroyed(client, agentId);
}
}), BureauCodes.BUREAU_GROUP);
}, BureauMarshaller.class, BureauCodes.BUREAU_GROUP);
conmgr.addChainedAuthenticator(new ServiceAuthenticator<BureauCredentials>(
BureauCredentials.class, BureauAuthName.class) {
@Override protected boolean areValid (BureauCredentials creds) {
@@ -53,6 +53,7 @@ import com.threerings.presents.peer.server.PeerManager;
import com.threerings.presents.peer.server.PeerManager.NodeRequest;
import com.threerings.presents.peer.server.NodeRequestsListener;
import com.threerings.crowd.chat.data.ChannelSpeakMarshaller;
import com.threerings.crowd.chat.data.ChatChannel;
import com.threerings.crowd.chat.data.ChatCodes;
import com.threerings.crowd.chat.data.UserMessage;
@@ -163,7 +164,7 @@ public abstract class ChatChannelManager
*/
@Inject protected ChatChannelManager (PresentsDObjectMgr omgr, InvocationManager invmgr)
{
invmgr.registerDispatcher(new ChannelSpeakDispatcher(this), CrowdCodes.CROWD_GROUP);
invmgr.registerProvider(this, ChannelSpeakMarshaller.class, CrowdCodes.CROWD_GROUP);
// create and start our idle channel closer; this will run as long as omgr is alive
omgr.newInterval(new Runnable() {
@@ -39,9 +39,10 @@ import com.threerings.presents.server.InvocationException;
import com.threerings.presents.server.InvocationManager;
import com.threerings.presents.server.InvocationProvider;
import com.threerings.crowd.chat.client.ChatService;
import com.threerings.crowd.chat.client.ChatService.TellListener;
import com.threerings.crowd.chat.client.ChatService;
import com.threerings.crowd.chat.data.ChatCodes;
import com.threerings.crowd.chat.data.ChatMarshaller;
import com.threerings.crowd.chat.data.SystemMessage;
import com.threerings.crowd.chat.data.UserMessage;
import com.threerings.crowd.data.BodyObject;
@@ -91,7 +92,7 @@ public class ChatProvider
@Inject public ChatProvider (InvocationManager invmgr)
{
// register a chat provider with the invocation manager
invmgr.registerDispatcher(new ChatDispatcher(this), CrowdCodes.CROWD_GROUP);
invmgr.registerProvider(this, ChatMarshaller.class, CrowdCodes.CROWD_GROUP);
}
/**
@@ -41,6 +41,7 @@ import com.threerings.crowd.chat.server.ChatProvider;
import com.threerings.crowd.data.BodyObject;
import com.threerings.crowd.peer.data.CrowdClientInfo;
import com.threerings.crowd.peer.data.CrowdNodeObject;
import com.threerings.crowd.peer.data.CrowdPeerMarshaller;
import com.threerings.crowd.server.BodyLocator;
/**
@@ -155,7 +156,7 @@ public abstract class CrowdPeerManager extends PeerManager
// register and initialize our invocation service
CrowdNodeObject cnobj = (CrowdNodeObject)_nodeobj;
cnobj.setCrowdPeerService(_invmgr.registerDispatcher(new CrowdPeerDispatcher(this)));
cnobj.setCrowdPeerService(_invmgr.registerProvider(this, CrowdPeerMarshaller.class));
// register ourselves as a chat forwarder
_chatprov.setChatForwarder(this);
@@ -27,6 +27,7 @@ import com.google.inject.Singleton;
import com.threerings.presents.data.ClientObject;
import com.threerings.presents.server.InvocationManager;
import com.threerings.crowd.data.BodyMarshaller;
import com.threerings.crowd.data.BodyObject;
import com.threerings.crowd.data.CrowdCodes;
import com.threerings.crowd.data.OccupantInfo;
@@ -45,7 +46,7 @@ public class BodyManager
*/
@Inject public BodyManager (InvocationManager invmgr)
{
invmgr.registerDispatcher(new BodyDispatcher(this), CrowdCodes.CROWD_GROUP);
invmgr.registerProvider(this, BodyMarshaller.class, CrowdCodes.CROWD_GROUP);
}
/**
@@ -35,6 +35,7 @@ import com.threerings.crowd.client.LocationService;
import com.threerings.crowd.data.BodyObject;
import com.threerings.crowd.data.CrowdCodes;
import com.threerings.crowd.data.LocationCodes;
import com.threerings.crowd.data.LocationMarshaller;
import com.threerings.crowd.data.Place;
import com.threerings.crowd.data.PlaceConfig;
@@ -49,7 +50,7 @@ public class LocationManager
{
@Inject public LocationManager (InvocationManager invmgr)
{
invmgr.registerDispatcher(new LocationDispatcher(this), CrowdCodes.CROWD_GROUP);
invmgr.registerProvider(this, LocationMarshaller.class, CrowdCodes.CROWD_GROUP);
}
// from interface LocationProvider
@@ -51,8 +51,10 @@ import com.threerings.presents.dobj.RootDObjectManager;
import com.threerings.presents.dobj.SetAdapter;
import com.threerings.presents.server.InvocationDispatcher;
import com.threerings.presents.server.InvocationManager;
import com.threerings.presents.server.InvocationProvider;
import com.threerings.crowd.chat.data.ChatCodes;
import com.threerings.crowd.chat.data.SpeakMarshaller;
import com.threerings.crowd.chat.server.SpeakDispatcher;
import com.threerings.crowd.chat.server.SpeakHandler;
import com.threerings.crowd.data.BodyObject;
@@ -265,7 +267,7 @@ public class PlaceManager
// we usually want to create and register a speaker service instance that clients can use
// to speak in this place
if (shouldCreateSpeakService()) {
plobj.setSpeakService(addDispatcher(new SpeakDispatcher(createSpeakHandler(plobj))));
plobj.setSpeakService(addProvider(createSpeakHandler(plobj), SpeakMarshaller.class));
}
// we'll need to hear about place object events
@@ -562,6 +564,18 @@ public class PlaceManager
cancelShutdowner();
}
/**
* Registers an invocation provider and notes the registration such that it will be
* automatically cleared when this manager shuts down.
*/
protected <T extends InvocationMarshaller> T addProvider (
InvocationProvider prov, Class<T> mclass)
{
T marsh = _invmgr.registerProvider(prov, mclass);
_marshallers.add(marsh);
return marsh;
}
/**
* Registers an invocation dispatcher and notes the registration such that it will be
* automatically cleared when this manager shuts down.
@@ -801,7 +815,7 @@ public class PlaceManager
/** A list of the delegates in use by this manager. */
protected List<PlaceManagerDelegate> _delegates;
/** A list of services registered with {@link #addDispatcher} which will be automatically
/** A list of services registered with {@link #addProvider} which will be automatically
* cleared when this manager shuts down. */
protected List<InvocationMarshaller> _marshallers = Lists.newArrayList();
@@ -25,6 +25,7 @@ import com.threerings.presents.data.InvocationMarshaller;
import com.threerings.presents.dobj.RootDObjectManager;
import com.threerings.presents.server.InvocationDispatcher;
import com.threerings.presents.server.InvocationManager;
import com.threerings.presents.server.InvocationProvider;
import com.threerings.crowd.data.OccupantInfo;
import com.threerings.crowd.data.PlaceConfig;
@@ -110,6 +111,16 @@ public class PlaceManagerDelegate
return _plmgr.where();
}
/**
* Registers an invocation provider and notes the registration such that it will be
* automatically cleared when our parent manager shuts down.
*/
protected <T extends InvocationMarshaller> T addProvider (
InvocationProvider prov, Class<T> mclass)
{
return _plmgr.addProvider(prov, mclass);
}
/**
* Registers an invocation dispatcher and notes the registration such that it will be
* automatically cleared when our parent manager shuts down.
@@ -72,6 +72,7 @@ import com.threerings.presents.peer.client.PeerService;
import com.threerings.presents.peer.data.ClientInfo;
import com.threerings.presents.peer.data.NodeObject;
import com.threerings.presents.peer.data.PeerAuthName;
import com.threerings.presents.peer.data.PeerMarshaller;
import com.threerings.presents.peer.net.PeerCreds;
import com.threerings.presents.peer.server.persist.NodeRecord;
import com.threerings.presents.peer.server.persist.NodeRepository;
@@ -319,7 +320,7 @@ public abstract class PeerManager
});
// set the invocation service
_nodeobj.setPeerService(_invmgr.registerDispatcher(new PeerDispatcher(this)));
_nodeobj.setPeerService(_invmgr.registerProvider(this, PeerMarshaller.class));
// register ourselves as a client observer
_clmgr.addClientObserver(this);
@@ -25,9 +25,10 @@ import java.util.HashMap;
import com.google.common.collect.Maps;
import com.threerings.presents.client.TimeBaseService.GotTimeBaseListener;
import com.threerings.presents.client.TimeBaseService;
import com.threerings.presents.data.ClientObject;
import com.threerings.presents.data.TimeBaseCodes;
import com.threerings.presents.data.TimeBaseMarshaller;
import com.threerings.presents.data.TimeBaseObject;
import com.threerings.presents.dobj.RootDObjectManager;
@@ -50,7 +51,7 @@ public class TimeBaseProvider
_omgr = omgr;
// register a provider instance
invmgr.registerDispatcher(new TimeBaseDispatcher(new TimeBaseProvider()), GLOBAL_GROUP);
invmgr.registerProvider(new TimeBaseProvider(), TimeBaseMarshaller.class, GLOBAL_GROUP);
}
/**
@@ -80,7 +81,8 @@ public class TimeBaseProvider
/**
* Processes a request from a client to fetch the oid of the specified time object.
*/
public void getTimeOid (ClientObject source, String timeBase, GotTimeBaseListener listener)
public void getTimeOid (ClientObject source, String timeBase,
TimeBaseService.GotTimeBaseListener listener)
throws InvocationException
{
// look up the time base object in question
@@ -23,6 +23,7 @@ package com.threerings.presents.server;
import com.google.inject.Injector;
import com.threerings.presents.data.TestMarshaller;
import com.threerings.presents.data.TestObject;
public class TestServer extends PresentsServer
@@ -36,8 +37,8 @@ public class TestServer extends PresentsServer
super.init(injector);
// register our test provider
_invmgr.registerDispatcher(
new TestDispatcher(injector.getInstance(TestManager.class)), "test");
_invmgr.registerProvider(injector.getInstance(TestManager.class),
TestMarshaller.class, "test");
// create a test object
testobj = _omgr.registerObject(new TestObject());