diff --git a/src/main/java/com/threerings/admin/server/AdminManager.java b/src/main/java/com/threerings/admin/server/AdminManager.java index aabc4a55b..3f332965a 100644 --- a/src/main/java/com/threerings/admin/server/AdminManager.java +++ b/src/main/java/com/threerings/admin/server/AdminManager.java @@ -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 diff --git a/src/main/java/com/threerings/bureau/server/BureauRegistry.java b/src/main/java/com/threerings/bureau/server/BureauRegistry.java index b58024e27..2fe947b7f 100644 --- a/src/main/java/com/threerings/bureau/server/BureauRegistry.java +++ b/src/main/java/com/threerings/bureau/server/BureauRegistry.java @@ -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.class, BureauAuthName.class) { @Override protected boolean areValid (BureauCredentials creds) { diff --git a/src/main/java/com/threerings/crowd/chat/server/ChatChannelManager.java b/src/main/java/com/threerings/crowd/chat/server/ChatChannelManager.java index a9860d4fb..14442f8d4 100644 --- a/src/main/java/com/threerings/crowd/chat/server/ChatChannelManager.java +++ b/src/main/java/com/threerings/crowd/chat/server/ChatChannelManager.java @@ -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() { diff --git a/src/main/java/com/threerings/crowd/chat/server/ChatProvider.java b/src/main/java/com/threerings/crowd/chat/server/ChatProvider.java index 6cdc4ca30..472667625 100644 --- a/src/main/java/com/threerings/crowd/chat/server/ChatProvider.java +++ b/src/main/java/com/threerings/crowd/chat/server/ChatProvider.java @@ -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); } /** diff --git a/src/main/java/com/threerings/crowd/peer/server/CrowdPeerManager.java b/src/main/java/com/threerings/crowd/peer/server/CrowdPeerManager.java index b33aa5d84..80d82cffc 100644 --- a/src/main/java/com/threerings/crowd/peer/server/CrowdPeerManager.java +++ b/src/main/java/com/threerings/crowd/peer/server/CrowdPeerManager.java @@ -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); diff --git a/src/main/java/com/threerings/crowd/server/BodyManager.java b/src/main/java/com/threerings/crowd/server/BodyManager.java index e55e7a07c..7380c391a 100644 --- a/src/main/java/com/threerings/crowd/server/BodyManager.java +++ b/src/main/java/com/threerings/crowd/server/BodyManager.java @@ -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); } /** diff --git a/src/main/java/com/threerings/crowd/server/LocationManager.java b/src/main/java/com/threerings/crowd/server/LocationManager.java index 115556606..72ff133aa 100644 --- a/src/main/java/com/threerings/crowd/server/LocationManager.java +++ b/src/main/java/com/threerings/crowd/server/LocationManager.java @@ -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 diff --git a/src/main/java/com/threerings/crowd/server/PlaceManager.java b/src/main/java/com/threerings/crowd/server/PlaceManager.java index a3d1802ad..50de7187a 100644 --- a/src/main/java/com/threerings/crowd/server/PlaceManager.java +++ b/src/main/java/com/threerings/crowd/server/PlaceManager.java @@ -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 addProvider ( + InvocationProvider prov, Class 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 _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 _marshallers = Lists.newArrayList(); diff --git a/src/main/java/com/threerings/crowd/server/PlaceManagerDelegate.java b/src/main/java/com/threerings/crowd/server/PlaceManagerDelegate.java index 7540d13e0..b70dbd764 100644 --- a/src/main/java/com/threerings/crowd/server/PlaceManagerDelegate.java +++ b/src/main/java/com/threerings/crowd/server/PlaceManagerDelegate.java @@ -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 addProvider ( + InvocationProvider prov, Class 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. diff --git a/src/main/java/com/threerings/presents/peer/server/PeerManager.java b/src/main/java/com/threerings/presents/peer/server/PeerManager.java index 041949e24..642812e80 100644 --- a/src/main/java/com/threerings/presents/peer/server/PeerManager.java +++ b/src/main/java/com/threerings/presents/peer/server/PeerManager.java @@ -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); diff --git a/src/main/java/com/threerings/presents/server/TimeBaseProvider.java b/src/main/java/com/threerings/presents/server/TimeBaseProvider.java index 9f34d7f57..42d8ea7c6 100644 --- a/src/main/java/com/threerings/presents/server/TimeBaseProvider.java +++ b/src/main/java/com/threerings/presents/server/TimeBaseProvider.java @@ -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 diff --git a/src/test/java/com/threerings/presents/server/TestServer.java b/src/test/java/com/threerings/presents/server/TestServer.java index 935f5df84..b42476755 100644 --- a/src/test/java/com/threerings/presents/server/TestServer.java +++ b/src/test/java/com/threerings/presents/server/TestServer.java @@ -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());