From 0c28d31357481aa0fa91653bb3327f22b3acb4af Mon Sep 17 00:00:00 2001 From: Andrzej Kapolka Date: Wed, 5 Jan 2011 01:32:13 +0000 Subject: [PATCH] Initializing the invocation director reference on deserialization doesn't work well in standalone mode. We need a way to install a director on registration. git-svn-id: svn+ssh://src.earth.threerings.net/narya/trunk@6413 542714f4-19e9-0310-aa3c-eee0fc999fb1 --- .../presents/data/InvocationMarshaller.java | 3 ++- .../presents/server/InvocationManager.java | 19 +++++++++++++++++-- 2 files changed, 19 insertions(+), 3 deletions(-) diff --git a/src/main/java/com/threerings/presents/data/InvocationMarshaller.java b/src/main/java/com/threerings/presents/data/InvocationMarshaller.java index 999ff1eff..995523be2 100644 --- a/src/main/java/com/threerings/presents/data/InvocationMarshaller.java +++ b/src/main/java/com/threerings/presents/data/InvocationMarshaller.java @@ -214,10 +214,11 @@ public class InvocationMarshaller * to operate in the wide world. This is called by the invocation manager when an invocation * provider is registered and should not be called otherwise. */ - public void init (int invOid, int invCode) + public void init (int invOid, int invCode, InvocationDirector invDir) { _invOid = invOid; _invCode = invCode; + _invdir = invDir; } /** diff --git a/src/main/java/com/threerings/presents/server/InvocationManager.java b/src/main/java/com/threerings/presents/server/InvocationManager.java index 94e490420..c6df43305 100644 --- a/src/main/java/com/threerings/presents/server/InvocationManager.java +++ b/src/main/java/com/threerings/presents/server/InvocationManager.java @@ -42,6 +42,7 @@ import com.samskivert.util.StringUtil; import com.threerings.io.Streamable; +import com.threerings.presents.client.InvocationDirector; import com.threerings.presents.data.ClientObject; import com.threerings.presents.data.InvocationCodes; import com.threerings.presents.data.InvocationMarshaller; @@ -93,6 +94,17 @@ public class InvocationManager log.debug("Created invocation service object", "oid", _invoid); } + /** + * Sets the invocation director to install in created marshallers. This is used in standalone + * mode, where marshallers are not streamed (usually, the director reference is set on + * unstreaming). + */ + public void setInvocationDirector (InvocationDirector invdir) + { + // TODO: change references in existing marshallers? + _invdir = invdir; + } + /** * Returns the object id of the invocation services object. */ @@ -172,7 +184,7 @@ public class InvocationManager T marsh; try { marsh = mclass.newInstance(); - marsh.init(_invoid, invCode); + marsh.init(_invoid, invCode, _invdir); } catch (IllegalAccessException ie) { throw new RuntimeException(ie); } catch (InstantiationException ie) { @@ -272,7 +284,7 @@ public class InvocationManager // create the marshaller and initialize it T marsh = dispatcher.createMarshaller(); - marsh.init(_invoid, invCode); + marsh.init(_invoid, invCode, _invdir); // register the dispatcher _dispatchers.put(invCode, dispatcher); @@ -438,6 +450,9 @@ public class InvocationManager /** Used to generate monotonically increasing provider ids. */ protected int _invCode; + /** The invocation director reference to install in created marshallers (if any). */ + protected InvocationDirector _invdir; + /** The distributed object manager we're working with. */ protected PresentsDObjectMgr _omgr;