Merge the ServerInvoker stuff into PresentsInvoker because the PresentsInvoker

is only ever used by the PresentsServer. Also determined that we need to
explicitly let Guice know that CrowdServer provides the PresentsServer
"interface" and so on down the line.

I also think that each concrete class needs to be marked as @Singleton though I
need to confirm that. Based on how annotations work, that's how it would be
easiest to implement, so we'll assume they're not doing extra work on the
backend to make our life easier.


git-svn-id: svn+ssh://src.earth.threerings.net/narya/trunk@5154 542714f4-19e9-0310-aa3c-eee0fc999fb1
This commit is contained in:
Michael Bayne
2008-06-07 18:39:19 +00:00
parent 3aefc93838
commit c568204bbb
5 changed files with 45 additions and 36 deletions
@@ -25,6 +25,7 @@ import com.google.inject.AbstractModule;
import com.google.inject.Guice;
import com.google.inject.Inject;
import com.google.inject.Injector;
import com.google.inject.Singleton;
import com.samskivert.util.Invoker;
import com.samskivert.util.RunQueue;
@@ -34,6 +35,8 @@ import com.threerings.presents.annotation.EventQueue;
import com.threerings.presents.annotation.MainInvoker;
import com.threerings.presents.client.Client;
import com.threerings.presents.dobj.AccessController;
import com.threerings.presents.dobj.DObjectManager;
import com.threerings.presents.dobj.RootDObjectManager;
import com.threerings.presents.server.net.ConnectionManager;
import static com.threerings.presents.Log.log;
@@ -46,14 +49,17 @@ import static com.threerings.presents.Log.log;
* available in the <code>PresentsServer</code> class. These will be configured when the singleton
* instance is initialized.
*/
@Singleton
public class PresentsServer
{
/** Configures dependencies needed by the Presents services. */
public static class Module extends AbstractModule
{
@Override protected void configure () {
bind(Invoker.class).annotatedWith(MainInvoker.class).to(ServerInvoker.class);
bind(Invoker.class).annotatedWith(MainInvoker.class).to(PresentsInvoker.class);
bind(RunQueue.class).annotatedWith(EventQueue.class).to(PresentsDObjectMgr.class);
bind(DObjectManager.class).to(PresentsDObjectMgr.class);
bind(RootDObjectManager.class).to(PresentsDObjectMgr.class);
}
}
@@ -257,20 +263,6 @@ public class PresentsServer
{
}
/** Integrates the main invoker thread with the distributed object thread so that they can
* coordinate the shutdown process to ensure that all (barring infinite loops) invoker units
* and distributed object events are processed before the server shuts down. */
protected static class ServerInvoker extends PresentsInvoker
{
@Inject public ServerInvoker (PresentsDObjectMgr omgr, ReportManager repmgr) {
super(omgr, repmgr);
}
@Override protected void didShutdown () {
_server.invokerDidShutdown();
}
@Inject protected PresentsServer _server;
}
/** The manager of distributed objects. */
@Inject protected PresentsDObjectMgr _omgr;