diff --git a/src/java/com/threerings/crowd/server/CrowdServer.java b/src/java/com/threerings/crowd/server/CrowdServer.java index c70857f8f..b25d06ed0 100644 --- a/src/java/com/threerings/crowd/server/CrowdServer.java +++ b/src/java/com/threerings/crowd/server/CrowdServer.java @@ -1,5 +1,5 @@ // -// $Id: CrowdServer.java,v 1.8 2001/10/11 04:07:51 mdb Exp $ +// $Id: CrowdServer.java,v 1.9 2001/12/04 01:02:59 mdb Exp $ package com.threerings.crowd.server; @@ -41,7 +41,7 @@ public class CrowdServer extends PresentsServer clmgr.setClientObjectClass(BodyObject.class); // create our place registry - plreg = new PlaceRegistry(config); + plreg = new PlaceRegistry(config, invmgr, omgr); // register our invocation service providers registerProviders(config.getValue(PROVIDERS_KEY, (String[])null)); diff --git a/src/java/com/threerings/crowd/server/LocationProvider.java b/src/java/com/threerings/crowd/server/LocationProvider.java index b9295a8c2..74c430d7c 100644 --- a/src/java/com/threerings/crowd/server/LocationProvider.java +++ b/src/java/com/threerings/crowd/server/LocationProvider.java @@ -1,16 +1,18 @@ // -// $Id: LocationProvider.java,v 1.10 2001/10/11 04:07:51 mdb Exp $ +// $Id: LocationProvider.java,v 1.11 2001/12/04 01:02:59 mdb Exp $ package com.threerings.crowd.server; import com.threerings.presents.dobj.DObject; +import com.threerings.presents.dobj.RootDObjectManager; + +import com.threerings.presents.server.InvocationManager; import com.threerings.presents.server.InvocationProvider; import com.threerings.presents.server.ServiceFailedException; import com.threerings.crowd.Log; import com.threerings.crowd.client.LocationCodes; import com.threerings.crowd.data.*; -import com.threerings.crowd.server.CrowdServer; /** * This class provides the server end of the location services. @@ -18,6 +20,22 @@ import com.threerings.crowd.server.CrowdServer; public class LocationProvider extends InvocationProvider implements LocationCodes { + /** + * Constructs a location provider and registers it with the invocation + * manager to handle location services. This is done automatically by + * the {@link PlaceRegistry}. + */ + public static void init ( + InvocationManager invmgr, RootDObjectManager omgr, PlaceRegistry plreg) + { + // we'll need these later + _omgr = omgr; + _plreg = plreg; + + // register a location provider instance + invmgr.registerProvider(MODULE_NAME, new LocationProvider()); + } + /** * Processes a request from a client to move to a new place. */ @@ -52,7 +70,7 @@ public class LocationProvider int bodoid = source.getOid(); // make sure the place in question actually exists - PlaceManager pmgr = CrowdServer.plreg.getPlaceManager(placeId); + PlaceManager pmgr = _plreg.getPlaceManager(placeId); if (pmgr == null) { Log.info("Requested to move to non-existent place " + "[source=" + source + ", place=" + placeId + "]."); @@ -78,7 +96,7 @@ public class LocationProvider // remove them from the occupant list of the previous location try { PlaceObject pold = (PlaceObject) - CrowdServer.omgr.getObject(source.location); + _omgr.getObject(source.location); if (pold != null) { Object key = new Integer(bodoid); // remove their occupant info (which is keyed on oid) @@ -120,4 +138,10 @@ public class LocationProvider return pmgr.getConfig(); } + + /** The distributed object manager with which we interoperate. */ + protected static RootDObjectManager _omgr; + + /** The place registry with which we interoperate. */ + protected static PlaceRegistry _plreg; } diff --git a/src/java/com/threerings/crowd/server/PlaceRegistry.java b/src/java/com/threerings/crowd/server/PlaceRegistry.java index 906d52593..82795de71 100644 --- a/src/java/com/threerings/crowd/server/PlaceRegistry.java +++ b/src/java/com/threerings/crowd/server/PlaceRegistry.java @@ -1,5 +1,5 @@ // -// $Id: PlaceRegistry.java,v 1.16 2001/11/07 10:47:55 mdb Exp $ +// $Id: PlaceRegistry.java,v 1.17 2001/12/04 01:02:59 mdb Exp $ package com.threerings.crowd.server; @@ -11,10 +11,13 @@ import com.samskivert.util.Tuple; import com.samskivert.util.Queue; import com.threerings.presents.dobj.DObject; +import com.threerings.presents.dobj.RootDObjectManager; import com.threerings.presents.dobj.ObjectAccessException; import com.threerings.presents.dobj.Subscriber; +import com.threerings.presents.server.InvocationManager; import com.threerings.crowd.Log; +import com.threerings.crowd.client.LocationCodes; import com.threerings.crowd.data.PlaceConfig; import com.threerings.crowd.data.PlaceObject; @@ -46,8 +49,14 @@ public class PlaceRegistry * Creates and initializes the place registry; called by the server * during its initialization phase. */ - public PlaceRegistry (Config config) + public PlaceRegistry (Config config, InvocationManager invmgr, + RootDObjectManager omgr) { + // we'll need this later + _omgr = omgr; + + // register the location provider + LocationProvider.init(invmgr, omgr, this); } /** @@ -88,7 +97,7 @@ public class PlaceRegistry _createq.append(new Tuple(pmgr, observer)); // and request to create the place object - CrowdServer.omgr.createObject(pmgr.getPlaceObjectClass(), this); + _omgr.createObject(pmgr.getPlaceObjectClass(), this); return pmgr; @@ -215,6 +224,9 @@ public class PlaceRegistry } } + /** The distributed object manager with which we operate. */ + protected RootDObjectManager _omgr; + /** A queue of place managers waiting for their place objects. */ protected Queue _createq = new Queue();