If we're going to do this, I guess we're going to do it properly. Nixed the

notion of a global group (though we implicitly define one in InvocationCodes)
added a mechanism for directors (which generally handle the client side of
invocation services) to register their interest in bootstrap service groups so
that the whole goddamned complex business can happen magically behind the
scenes.

If you instantiate a director, it will automatically register interest in the
service group it needs and everything will work. If you don't use the director
code, you don't get the services and you can safely exclude all of that code
from your client even though the services are still in use on the server (and
presumably used by some other types of clients).

This is going to break all the builds, which I'll soon fix. Then I'll go write
all this in ActionScript. Yay!


git-svn-id: svn+ssh://src.earth.threerings.net/narya/trunk@4552 542714f4-19e9-0310-aa3c-eee0fc999fb1
This commit is contained in:
Michael Bayne
2007-02-11 01:17:30 +00:00
parent 9afcc526a0
commit ebc99935d5
25 changed files with 406 additions and 358 deletions
@@ -62,9 +62,6 @@ import java.util.HashMap;
public class InvocationManager
implements EventListener
{
/** Defines the name of the global bootstrap group. */
public static final String GLOBAL_BOOTSTRAP_GROUP = "global";
/** A mapping from bootstrap group to lists of services that are to be provided to clients at
* boot time. Don't mess with these lists! */
public HashMap<String,StreamableArrayList<InvocationMarshaller>> bootlists =
@@ -100,13 +97,10 @@ public class InvocationManager
* send requests to the provider for whom the dispatcher is proxying.
*
* @param dispatcher the dispatcher to be registered.
* @param bootstrap if true, the service instance will be added to the list of invocation
* service objects provided to the client in the bootstrap data.
*/
public InvocationMarshaller registerDispatcher (
InvocationDispatcher dispatcher, boolean bootstrap)
public InvocationMarshaller registerDispatcher (InvocationDispatcher dispatcher)
{
return registerDispatcher(dispatcher, bootstrap ? GLOBAL_BOOTSTRAP_GROUP : null);
return registerDispatcher(dispatcher, null);
}
/**
@@ -140,8 +134,7 @@ public class InvocationManager
list.add(marsh);
}
_recentRegServices.put(Integer.valueOf(invCode),
marsh.getClass().getName());
_recentRegServices.put(Integer.valueOf(invCode), marsh.getClass().getName());
// Log.info("Registered service [marsh=" + marsh + "].");
return marsh;
@@ -292,8 +285,7 @@ public class InvocationManager
/** The distributed object manager with which we're working. */
protected RootDObjectManager _omgr;
/** The object id of the object on which we receive invocation service
* requests. */
/** The object id of the object on which we receive invocation service requests. */
protected int _invoid = -1;
/** Used to generate monotonically increasing provider ids. */
@@ -303,7 +295,7 @@ public class InvocationManager
protected HashIntMap<InvocationDispatcher> _dispatchers =
new HashIntMap<InvocationDispatcher>();
/** The text that is appended to the procedure name when automatically
* generating a failure response. */
/** The text that is appended to the procedure name when automatically generating a failure
* response. */
protected static final String FAILED_SUFFIX = "Failed";
}
@@ -651,13 +651,9 @@ public class PresentsClient
// fill in the list of bootstrap services
data.services = new StreamableArrayList<InvocationMarshaller>();
StreamableArrayList<InvocationMarshaller> list =
PresentsServer.invmgr.bootlists.get(InvocationManager.GLOBAL_BOOTSTRAP_GROUP);
if (list != null) {
data.services.addAll(list);
}
for (String group : _areq.getBootGroups()) {
list = PresentsServer.invmgr.bootlists.get(group);
StreamableArrayList<InvocationMarshaller> list =
PresentsServer.invmgr.bootlists.get(group);
if (list != null) {
data.services.addAll(list);
}
@@ -34,17 +34,16 @@ import com.threerings.presents.data.TimeBaseObject;
import com.threerings.presents.dobj.RootDObjectManager;
/**
* Provides the server-side of the time base services. The time base
* services provide a means by which delta times can be sent over the
* network which are expanded based on a shared base time into full time
* stamps.
* Provides the server-side of the time base services. The time base services provide a means by
* which delta times can be sent over the network which are expanded based on a shared base time
* into full time stamps.
*/
public class TimeBaseProvider
implements InvocationProvider, TimeBaseCodes
{
/**
* Registers the time provider with the appropriate managers. Called
* by the presents server at startup.
* Registers the time provider with the appropriate managers. Called by the presents server at
* startup.
*/
public static void init (InvocationManager invmgr, RootDObjectManager omgr)
{
@@ -53,13 +52,12 @@ public class TimeBaseProvider
_omgr = omgr;
// register a provider instance
invmgr.registerDispatcher(
new TimeBaseDispatcher(new TimeBaseProvider()), true);
invmgr.registerDispatcher(new TimeBaseDispatcher(new TimeBaseProvider()), GLOBAL_GROUP);
}
/**
* Creates a time base object which can subsequently be fetched by the
* client and used to send delta times.
* Creates a time base object which can subsequently be fetched by the client and used to send
* delta times.
*
* @param timeBase the name of the time base to create.
*
@@ -73,8 +71,8 @@ public class TimeBaseProvider
}
/**
* Returns the named timebase object, or null if no time base object
* has been created with that name.
* Returns the named timebase object, or null if no time base object has been created with that
* name.
*/
public static TimeBaseObject getTimeBase (String timeBase)
{
@@ -82,11 +80,9 @@ public class TimeBaseProvider
}
/**
* Processes a request from a client to fetch the oid of the specified
* time object.
* Processes a request from a client to fetch the oid of the specified time object.
*/
public void getTimeOid (
ClientObject source, String timeBase, GotTimeBaseListener listener)
public void getTimeOid (ClientObject source, String timeBase, GotTimeBaseListener listener)
throws InvocationException
{
// look up the time base object in question