Revamped distributed object creation. There was no particular reason to create
distributed objects by reflection since we don't allow clients to create objects, furthermore we needn't do it asynchronously. The object creation methods were moved into the server-side only interface and made "immediate", so the caller creates a derived instance of DObject and registers it with the system instead of creating it with a Subscriber callback. git-svn-id: svn+ssh://src.earth.threerings.net/narya/trunk@4342 542714f4-19e9-0310-aa3c-eee0fc999fb1
This commit is contained in:
@@ -31,35 +31,18 @@ import com.threerings.presents.dobj.*;
|
||||
* Tests the oid list reference tracking code.
|
||||
*/
|
||||
public class RefTest extends TestCase
|
||||
implements Subscriber<TestObject>, EventListener
|
||||
implements EventListener
|
||||
{
|
||||
public static Test suite ()
|
||||
{
|
||||
return new RefTest();
|
||||
}
|
||||
|
||||
public RefTest ()
|
||||
{
|
||||
super(RefTest.class.getName());
|
||||
}
|
||||
|
||||
public void objectAvailable (TestObject object)
|
||||
{
|
||||
// add ourselves as an event listener to our subscribed object
|
||||
object.addListener(this);
|
||||
|
||||
// keep references to our test objects
|
||||
if (_objone == null) {
|
||||
_objone = object;
|
||||
|
||||
} else {
|
||||
_objtwo = object;
|
||||
// now that we have both objects, set up the references
|
||||
_objone.addToList(_objtwo.getOid());
|
||||
_objtwo.addToList(_objone.getOid());
|
||||
}
|
||||
}
|
||||
|
||||
public void requestFailed (int oid, ObjectAccessException cause)
|
||||
{
|
||||
fail("Ack. Unable to create object [cause=" + cause + "].");
|
||||
}
|
||||
|
||||
public void eventReceived (DEvent event)
|
||||
{
|
||||
// Log.info("Got event: " + event);
|
||||
@@ -93,18 +76,19 @@ public class RefTest extends TestCase
|
||||
public void runTest ()
|
||||
{
|
||||
// create two test objects
|
||||
_omgr.createObject(TestObject.class, this);
|
||||
_omgr.createObject(TestObject.class, this);
|
||||
_objone = _omgr.registerObject(new TestObject());
|
||||
_objone.addListener(this);
|
||||
_objtwo = _omgr.registerObject(new TestObject());
|
||||
_objtwo.addListener(this);
|
||||
|
||||
// now that we have both objects, set up the references
|
||||
_objone.addToList(_objtwo.getOid());
|
||||
_objtwo.addToList(_objone.getOid());
|
||||
|
||||
// and run the object manager
|
||||
_omgr.run();
|
||||
}
|
||||
|
||||
public static Test suite ()
|
||||
{
|
||||
return new RefTest();
|
||||
}
|
||||
|
||||
protected TestObject _objone;
|
||||
protected TestObject _objtwo;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user