More custom classloader support. We now have a proof-of-concept working so

it's unlikely that the rabbit hole will surprise us with further depth.


git-svn-id: svn+ssh://src.earth.threerings.net/narya/trunk@3269 542714f4-19e9-0310-aa3c-eee0fc999fb1
This commit is contained in:
Michael Bayne
2004-12-10 02:54:26 +00:00
parent c92a922678
commit a6d7764e29
5 changed files with 87 additions and 30 deletions
@@ -1,5 +1,5 @@
//
// $Id: LocationProvider.java,v 1.23 2004/08/27 02:12:34 mdb Exp $
// $Id$
//
// Narya library - tools for developing networked games
// Copyright (C) 2002-2004 Three Rings Design, Inc., All Rights Reserved
@@ -28,14 +28,15 @@ import com.threerings.presents.data.ClientObject;
import com.threerings.presents.server.InvocationException;
import com.threerings.presents.server.InvocationManager;
import com.threerings.presents.server.InvocationProvider;
import com.threerings.presents.server.PresentsClient;
import com.threerings.crowd.Log;
import com.threerings.crowd.client.LocationService;
import com.threerings.crowd.data.BodyObject;
import com.threerings.crowd.data.LocationCodes;
import com.threerings.crowd.data.PlaceConfig;
import com.threerings.crowd.data.PlaceObject;
import com.threerings.crowd.server.CrowdServer;
/**
* This class provides the server end of the location services.
@@ -115,6 +116,16 @@ public class LocationProvider
throw new InvocationException(MOVE_IN_PROGRESS);
}
// configure the client accordingly if they're moving to a place
// that uses a custom class loader
PresentsClient client = CrowdServer.clmgr.getClient(source.username);
if (client != null) {
client.setClassLoader(_plreg.getClassLoader(pmgr.getConfig()));
} else {
Log.warning("No client for moveTo class loader fiddling? " +
"[who=" + source.username + "].");
}
try {
PlaceObject place = pmgr.getPlaceObject();
@@ -81,6 +81,22 @@ public class PlaceRegistry
_invmgr = invmgr;
}
/**
* By overriding this method, it is possible to customize the place
* registry to cause it to load the classes associated with a
* particular place via a custom class loader. That loader may enforce
* restricted privileges or obtain the classes from some special
* source.
*
* @return the class loader to use when instantiating the {@link
* PlaceManager} associated with the supplied {@link
* PlaceConfig}. This method <em>must not</em> return null.
*/
public ClassLoader getClassLoader (PlaceConfig config)
{
return getClass().getClassLoader();
}
/**
* Creates and registers a new place manager along with the place
* object to be managed. The registry takes care of tracking the
@@ -264,22 +280,6 @@ public class PlaceRegistry
}
}
/**
* By overriding this method, it is possible to customize the place
* registry to cause it to load the classes associated with a
* particular place via a custom class loader. That loader may enforce
* restricted privileges or obtain the classes from some special
* source.
*
* @return the class loader to use when instantiating the {@link
* PlaceManager} associated with the supplied {@link
* PlaceConfig}. This method <em>must not</em> return null.
*/
protected ClassLoader getClassLoader (PlaceConfig config)
{
return getClass().getClassLoader();
}
/** The invocation manager with which we operate. */
protected InvocationManager _invmgr;