diff --git a/src/main/java/com/threerings/presents/annotation/PeerInvoker.java b/src/main/java/com/threerings/presents/annotation/PeerInvoker.java new file mode 100644 index 000000000..c9df2153b --- /dev/null +++ b/src/main/java/com/threerings/presents/annotation/PeerInvoker.java @@ -0,0 +1,44 @@ +// +// $Id: MainInvoker.java 6407 2011-01-01 05:02:21Z dhoover $ +// +// Narya library - tools for developing networked games +// Copyright (C) 2002-2011 Three Rings Design, Inc., All Rights Reserved +// http://code.google.com/p/narya/ +// +// This library is free software; you can redistribute it and/or modify it +// under the terms of the GNU Lesser General Public License as published +// by the Free Software Foundation; either version 2.1 of the License, or +// (at your option) any later version. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + +package com.threerings.presents.annotation; + +import java.lang.annotation.ElementType; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; + +import com.google.inject.BindingAnnotation; + +import com.samskivert.util.Invoker; + +/** + * An annotation that identifies the peer {@link Invoker}. Code that requires the ability + * to post units for execution on the peer invoker thread can inject this queue like so: + * + * @Inject @PeerInvoker Invoker _invoker; + */ +@Retention(RetentionPolicy.RUNTIME) +@Target({ ElementType.FIELD, ElementType.PARAMETER }) +@BindingAnnotation +public @interface PeerInvoker +{ +} 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 b5f9c446d..3d9acb06f 100644 --- a/src/main/java/com/threerings/presents/peer/server/PeerManager.java +++ b/src/main/java/com/threerings/presents/peer/server/PeerManager.java @@ -59,7 +59,7 @@ import com.threerings.presents.peer.data.DObjectAddress; import com.threerings.util.Name; -import com.threerings.presents.annotation.MainInvoker; +import com.threerings.presents.annotation.PeerInvoker; import com.threerings.presents.client.Client; import com.threerings.presents.client.InvocationService; import com.threerings.presents.data.ClientObject; @@ -1611,7 +1611,7 @@ public abstract class PeerManager protected Stats _stats = new Stats(); // our service dependencies - @Inject protected @MainInvoker Invoker _invoker; + @Inject protected @PeerInvoker Invoker _invoker; @Inject protected ClientManager _clmgr; @Inject protected PresentsConnectionManager _conmgr; @Inject protected Injector _injector; diff --git a/src/main/java/com/threerings/presents/server/PresentsServer.java b/src/main/java/com/threerings/presents/server/PresentsServer.java index 97e5efac2..0b4aa300a 100644 --- a/src/main/java/com/threerings/presents/server/PresentsServer.java +++ b/src/main/java/com/threerings/presents/server/PresentsServer.java @@ -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.Key; import com.google.inject.Module; import com.google.inject.Singleton; @@ -36,6 +37,7 @@ import com.samskivert.util.SystemInfo; import com.threerings.presents.annotation.AuthInvoker; import com.threerings.presents.annotation.EventQueue; import com.threerings.presents.annotation.MainInvoker; +import com.threerings.presents.annotation.PeerInvoker; import com.threerings.presents.client.Client; import com.threerings.presents.dobj.AccessController; import com.threerings.presents.dobj.DObject; @@ -68,6 +70,7 @@ public class PresentsServer { @Override protected void configure () { bindInvokers(); + bindPeerInvoker(); bind(ConnectionManager.class).to(PresentsConnectionManager.class); bind(RunQueue.class).annotatedWith(EventQueue.class).to(PresentsDObjectMgr.class); bind(DObjectManager.class).to(PresentsDObjectMgr.class); @@ -82,6 +85,14 @@ public class PresentsServer bind(Invoker.class).annotatedWith(MainInvoker.class).to(PresentsInvoker.class); bind(Invoker.class).annotatedWith(AuthInvoker.class).to(PresentsAuthInvoker.class); } + + /** + * Binds just the peer invoker - we separate this from the others for legacy reasons. + */ + protected void bindPeerInvoker () { + bind(Invoker.class).annotatedWith(PeerInvoker.class).to( + Key.get(Invoker.class, MainInvoker.class)); + } } /**