Allow external parties to call applyToDelegates().

git-svn-id: svn+ssh://src.earth.threerings.net/narya/trunk@4838 542714f4-19e9-0310-aa3c-eee0fc999fb1
This commit is contained in:
Michael Bayne
2007-10-02 23:29:02 +00:00
parent 13c2173829
commit d4562ff806
@@ -96,6 +96,14 @@ public class PlaceManager
public void handleEvent (MessageEvent event, PlaceManager pmgr);
}
/**
* Used to call methods on this place manager's delegates.
*/
public static interface DelegateOp
{
public void apply (PlaceManagerDelegate delegate);
}
/**
* Returns a reference to our place configuration object.
*/
@@ -178,22 +186,6 @@ public class PlaceManager
didInit();
}
/**
* Called after this place manager has been initialized with its configuration information but
* before it has been started up with its place object reference. Derived classes can override
* this function and perform any basic initialization that they desire. They should of course
* be sure to call <code>super.didInit()</code>.
*/
protected void didInit ()
{
// initialize our delegates
applyToDelegates(new DelegateOp() {
public void apply (PlaceManagerDelegate delegate) {
delegate.didInit(_config);
}
});
}
/**
* Adds the supplied delegate to the list for this manager.
*/
@@ -205,6 +197,19 @@ public class PlaceManager
_delegates.add(delegate);
}
/**
* Applies the supplied operation to this manager's registered delegates.
*/
public void applyToDelegates (DelegateOp op)
{
if (_delegates != null) {
int dcount = _delegates.size();
for (int i = 0; i < dcount; i++) {
op.apply(_delegates.get(i));
}
}
}
/**
* 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
@@ -437,6 +442,22 @@ public class PlaceManager
return PlaceObject.class;
}
/**
* Called after this place manager has been initialized with its configuration information but
* before it has been started up with its place object reference. Derived classes can override
* this function and perform any basic initialization that they desire. They should of course
* be sure to call <code>super.didInit()</code>.
*/
protected void didInit ()
{
// initialize our delegates
applyToDelegates(new DelegateOp() {
public void apply (PlaceManagerDelegate delegate) {
delegate.didInit(_config);
}
});
}
/**
* Called if the permissions check failed, to give place managers a chance to do any cleanup
* that might be necessary due to their early initialization or permissions checking code.
@@ -648,27 +669,6 @@ public class PlaceManager
buf.append(", config=").append(_config);
}
/**
* Used to call methods in delegates.
*/
protected static interface DelegateOp
{
public void apply (PlaceManagerDelegate delegate);
}
/**
* Applies the supplied operation to the registered delegates.
*/
protected void applyToDelegates (DelegateOp op)
{
if (_delegates != null) {
int dcount = _delegates.size();
for (int i = 0; i < dcount; i++) {
op.apply(_delegates.get(i));
}
}
}
/** Listens for occupant updates. */
protected SetAdapter _bodyUpdater = new SetAdapter() {
public void entryUpdated (EntryUpdatedEvent event) {