8a4c46badc
changed to Presents and Party changed to Crowd. Whee! git-svn-id: svn+ssh://src.earth.threerings.net/narya/trunk@431 542714f4-19e9-0310-aa3c-eee0fc999fb1
60 lines
1.6 KiB
Java
60 lines
1.6 KiB
Java
//
|
|
// $Id: DOMTest.java,v 1.2 2001/10/11 04:07:53 mdb Exp $
|
|
|
|
package com.threerings.presents.server.test;
|
|
|
|
import com.threerings.presents.Log;
|
|
import com.threerings.presents.dobj.*;
|
|
import com.threerings.presents.server.*;
|
|
|
|
/**
|
|
* A simple test case for the dobjmgr.
|
|
*/
|
|
public class DOMTest implements Subscriber
|
|
{
|
|
public void objectAvailable (DObject object)
|
|
{
|
|
Log.info("Object available: " + object);
|
|
// set some values
|
|
TestObject to = (TestObject)object;
|
|
to.setFoo(25);
|
|
to.setBar("howdy");
|
|
}
|
|
|
|
public void requestFailed (int oid, ObjectAccessException cause)
|
|
{
|
|
Log.info("Request failed: " + cause);
|
|
omgr.shutdown();
|
|
}
|
|
|
|
public boolean handleEvent (DEvent event, DObject target)
|
|
{
|
|
Log.info("Got event [event=" + event + ", target=" + target + "].");
|
|
|
|
// if this is the second event, request a shutdown
|
|
AttributeChangedEvent ace = (AttributeChangedEvent)event;
|
|
if (ace.getName().equals(TestObject.BAR)) {
|
|
omgr.shutdown();
|
|
}
|
|
|
|
return true;
|
|
}
|
|
|
|
public static PresentsDObjectMgr omgr = new PresentsDObjectMgr();
|
|
|
|
public static void main (String[] args)
|
|
{
|
|
// create our subscriber who will do things
|
|
DOMTest sub = new DOMTest();
|
|
|
|
// request that a new TestObject be created
|
|
omgr.createObject(TestObject.class, sub, true);
|
|
|
|
// or for fun you can try this bogus create request
|
|
// omgr.createObject(Integer.class, sub, true);
|
|
|
|
// and run the object manager
|
|
omgr.run();
|
|
}
|
|
}
|