Modified location services such that the registry and the provider are

supplied with the managers they need at initialization time and such that
the location provider is automatically registered by the place registry
rather than requiring you to put a line in a config file which was a silly
idea in the first place.


git-svn-id: svn+ssh://src.earth.threerings.net/narya/trunk@729 542714f4-19e9-0310-aa3c-eee0fc999fb1
This commit is contained in:
Michael Bayne
2001-12-04 01:02:59 +00:00
parent 5d2f302218
commit 69b4f7fa86
3 changed files with 45 additions and 9 deletions
@@ -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));
@@ -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;
}
@@ -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();