Provide a means by which a place manager can check, early in the
initialization process, whether or not it actually wants to be created, and allow it to abort the whole deal if it doesn't. git-svn-id: svn+ssh://src.earth.threerings.net/narya/trunk@1777 542714f4-19e9-0310-aa3c-eee0fc999fb1
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
//
|
||||
// $Id: PlaceManager.java,v 1.36 2002/09/20 04:53:14 mdb Exp $
|
||||
// $Id: PlaceManager.java,v 1.37 2002/10/06 00:44:58 mdb Exp $
|
||||
|
||||
package com.threerings.crowd.server;
|
||||
|
||||
@@ -171,6 +171,22 @@ public class PlaceManager
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Provides an opportunity for place managers to ratify the creation
|
||||
* of a place based on whatever criterion they may require (based on
|
||||
* information available to the manager at this post-init() but
|
||||
* pre-startup() phase of initialization).
|
||||
*
|
||||
* @return If a permissions check is to fail, the manager should
|
||||
* return a translatable string explaining the failure.
|
||||
* <code>null</code> should be returned if initialization is to be
|
||||
* allowed to proceed.
|
||||
*/
|
||||
public String checkPermissions ()
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Called by the place manager after the place object has been
|
||||
* successfully created.
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
//
|
||||
// $Id: PlaceRegistry.java,v 1.21 2002/08/14 19:07:49 mdb Exp $
|
||||
// $Id: PlaceRegistry.java,v 1.22 2002/10/06 00:44:58 mdb Exp $
|
||||
|
||||
package com.threerings.crowd.server;
|
||||
|
||||
@@ -10,9 +10,10 @@ 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.RootDObjectManager;
|
||||
import com.threerings.presents.dobj.Subscriber;
|
||||
import com.threerings.presents.server.InvocationException;
|
||||
import com.threerings.presents.server.InvocationManager;
|
||||
|
||||
import com.threerings.crowd.Log;
|
||||
@@ -81,10 +82,14 @@ public class PlaceRegistry
|
||||
*
|
||||
* @exception InstantiationException thrown if an error occurs trying
|
||||
* to instantiate and initialize the place manager.
|
||||
* @exception InvocationException thrown if the place manager returns
|
||||
* failure from the call to {@link PlaceManager#checkPermissions}. The
|
||||
* error string returned by that call will be provided as in the
|
||||
* exception.
|
||||
*/
|
||||
public PlaceManager createPlace (
|
||||
PlaceConfig config, CreationObserver observer)
|
||||
throws InstantiationException
|
||||
throws InstantiationException, InvocationException
|
||||
{
|
||||
try {
|
||||
// load up the manager class
|
||||
@@ -94,6 +99,13 @@ public class PlaceRegistry
|
||||
// let the pmgr know about us and its configuration
|
||||
pmgr.init(this, _invmgr, _omgr, config);
|
||||
|
||||
// give the manager an opportunity to abort the whole process
|
||||
// if it fails any permissions checks
|
||||
String errmsg = pmgr.checkPermissions();
|
||||
if (errmsg != null) {
|
||||
throw new InvocationException(errmsg);
|
||||
}
|
||||
|
||||
// stick the manager on the creation queue because we know
|
||||
// we'll get our calls to objectAvailable()/requestFailed() in
|
||||
// the order that we call createObject()
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
//
|
||||
// $Id: SceneRegistry.java,v 1.16 2002/08/14 19:07:57 mdb Exp $
|
||||
// $Id: SceneRegistry.java,v 1.17 2002/10/06 00:44:58 mdb Exp $
|
||||
|
||||
package com.threerings.whirled.server;
|
||||
|
||||
@@ -209,9 +209,9 @@ public class SceneRegistry
|
||||
// will call back to the scene registry and let us know that
|
||||
// we can turn the penders loose
|
||||
|
||||
} catch (InstantiationException ie) {
|
||||
} catch (Exception e) {
|
||||
// so close, but no cigar
|
||||
processFailedResolution(model.sceneId, ie);
|
||||
processFailedResolution(model.sceneId, e);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user