Modify PresentsClient and ClientResolver creation so that we can inject
dependencies into both. Moved the legacy statics into CrowdServer so that at least Presents can be pure (we should probably eventually move them into BangServer and PiracyServer and fix everything else). Added some useful manager references to PlaceManager delegate (_omgr, _invmgr) that handle the majority of their service needs. git-svn-id: svn+ssh://src.earth.threerings.net/narya/trunk@5170 542714f4-19e9-0310-aa3c-eee0fc999fb1
This commit is contained in:
@@ -27,16 +27,20 @@ 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.threerings.util.Name;
|
||||
|
||||
import com.threerings.presents.dobj.RootDObjectManager;
|
||||
import com.threerings.presents.net.AuthRequest;
|
||||
import com.threerings.presents.server.ClientFactory;
|
||||
import com.threerings.presents.server.ClientManager;
|
||||
import com.threerings.presents.server.ClientResolver;
|
||||
import com.threerings.presents.server.InvocationManager;
|
||||
import com.threerings.presents.server.PresentsClient;
|
||||
import com.threerings.presents.server.PresentsDObjectMgr;
|
||||
import com.threerings.presents.server.PresentsServer;
|
||||
import com.threerings.presents.server.net.ConnectionManager;
|
||||
|
||||
import com.threerings.crowd.chat.server.ChatProvider;
|
||||
import com.threerings.crowd.data.BodyObject;
|
||||
@@ -58,18 +62,33 @@ public class CrowdServer extends PresentsServer
|
||||
}
|
||||
}
|
||||
|
||||
/** The place registry. */
|
||||
/** OBSOLETE! Don't use me. */
|
||||
public static PlaceRegistry plreg;
|
||||
|
||||
/** Our chat provider. */
|
||||
/** OBSOLETE! Don't use me. */
|
||||
public static ChatProvider chatprov;
|
||||
|
||||
/** Our body manager. */
|
||||
/** OBSOLETE! Don't use me. */
|
||||
public static BodyManager bodyman;
|
||||
|
||||
/** Our location manager. */
|
||||
/** OBSOLETE! Don't use me. */
|
||||
public static LocationManager locman;
|
||||
|
||||
/** OBSOLETE! Don't use me. */
|
||||
public static ConnectionManager conmgr;
|
||||
|
||||
/** OBSOLETE! Don't use me. */
|
||||
public static ClientManager clmgr;
|
||||
|
||||
/** OBSOLETE! Don't use me. */
|
||||
public static PresentsDObjectMgr omgr;
|
||||
|
||||
/** OBSOLETE! Don't use me. */
|
||||
public static InvocationManager invmgr;
|
||||
|
||||
/** OBSOLETE! Don't use me. */
|
||||
public static Invoker invoker;
|
||||
|
||||
/**
|
||||
* Initializes all of the server services and prepares for operation.
|
||||
*/
|
||||
@@ -79,18 +98,23 @@ public class CrowdServer extends PresentsServer
|
||||
super.init(injector);
|
||||
|
||||
// LEGACY: set up our legacy static references
|
||||
conmgr = _conmgr;
|
||||
clmgr = _clmgr;
|
||||
omgr = _omgr;
|
||||
invmgr = _invmgr;
|
||||
invoker = _invoker;
|
||||
plreg = _plreg;
|
||||
chatprov = _chatprov;
|
||||
bodyman = _bodyman;
|
||||
locman = _locman;
|
||||
|
||||
// configure the client manager to use our bits
|
||||
clmgr.setClientFactory(new ClientFactory() {
|
||||
public PresentsClient createClient (AuthRequest areq) {
|
||||
return new CrowdClient();
|
||||
_clmgr.setClientFactory(new ClientFactory() {
|
||||
public Class<? extends PresentsClient> getClientClass (AuthRequest areq) {
|
||||
return CrowdClient.class;
|
||||
}
|
||||
public ClientResolver createClientResolver (Name username) {
|
||||
return new CrowdClientResolver();
|
||||
public Class<? extends ClientResolver> getClientResolverClass (Name username) {
|
||||
return CrowdClientResolver.class;
|
||||
}
|
||||
});
|
||||
|
||||
@@ -111,21 +135,11 @@ public class CrowdServer extends PresentsServer
|
||||
return new BodyLocator() {
|
||||
public BodyObject get (Name visibleName) {
|
||||
// by default visibleName is username
|
||||
return (BodyObject)clmgr.getClientObject(visibleName);
|
||||
return (BodyObject)_clmgr.getClientObject(visibleName);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* Enumerates the body objects for all active users on the server. This should only be called
|
||||
* from the dobjmgr thread. The caller had best be certain they know what they're doing, since
|
||||
* this should only be necessary for use in rather special circumstances.
|
||||
*/
|
||||
public static Iterator enumerateBodies ()
|
||||
{
|
||||
return clmgr.enumerateClientObjects();
|
||||
}
|
||||
|
||||
/**
|
||||
* Looks up the {@link BodyObject} for the user with the specified visible name, returns null
|
||||
* if they are not online. This should only be called from the dobjmgr thread.
|
||||
|
||||
@@ -194,7 +194,7 @@ public class PlaceManager
|
||||
if (_delegates == null) {
|
||||
_delegates = Lists.newArrayList();
|
||||
}
|
||||
delegate.setPlaceManager(this);
|
||||
delegate.init(this, _omgr, _invmgr);
|
||||
_delegates.add(delegate);
|
||||
}
|
||||
|
||||
|
||||
@@ -21,6 +21,9 @@
|
||||
|
||||
package com.threerings.crowd.server;
|
||||
|
||||
import com.threerings.presents.dobj.RootDObjectManager;
|
||||
import com.threerings.presents.server.InvocationManager;
|
||||
|
||||
import com.threerings.crowd.data.OccupantInfo;
|
||||
import com.threerings.crowd.data.PlaceConfig;
|
||||
import com.threerings.crowd.data.PlaceObject;
|
||||
@@ -41,9 +44,11 @@ public class PlaceManagerDelegate
|
||||
* Called by the place manager when this delegate is registered with it. This will happen
|
||||
* before any calls to {@link #didInit}, etc.
|
||||
*/
|
||||
public void setPlaceManager (PlaceManager plmgr)
|
||||
public void init (PlaceManager plmgr, RootDObjectManager omgr, InvocationManager invmgr)
|
||||
{
|
||||
_plmgr = plmgr;
|
||||
_omgr = omgr;
|
||||
_invmgr = invmgr;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -105,4 +110,10 @@ public class PlaceManagerDelegate
|
||||
|
||||
/** A reference to the manager for which we are delegating. */
|
||||
protected PlaceManager _plmgr;
|
||||
|
||||
/** A reference to our distributed object manager. */
|
||||
protected RootDObjectManager _omgr;
|
||||
|
||||
/** A reference to our invocation manager. */
|
||||
protected InvocationManager _invmgr;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user