Implemented object destruction; wired up some missing stuff; created a

test server to make some testing easier; various other cleanups.


git-svn-id: svn+ssh://src.earth.threerings.net/narya/trunk@188 542714f4-19e9-0310-aa3c-eee0fc999fb1
This commit is contained in:
Michael Bayne
2001-08-07 20:38:58 +00:00
parent b3e7f12f08
commit 782e9501d6
15 changed files with 340 additions and 54 deletions
@@ -1,5 +1,5 @@
//
// $Id: DObject.java,v 1.19 2001/08/04 00:39:44 mdb Exp $
// $Id: DObject.java,v 1.20 2001/08/07 20:38:58 mdb Exp $
package com.threerings.cocktail.cher.dobj;
@@ -233,6 +233,16 @@ public class DObject
}
}
/**
* Requests that this distributed object be destroyed. It does so by
* queueing up an object destroyed event which the server will
* validate and process.
*/
public void destroy ()
{
_mgr.postEvent(new ObjectDestroyedEvent(_oid));
}
/**
* Checks to ensure that the specified subscriber has access to this
* object. This will be called before satisfying a subscription
@@ -1,5 +1,5 @@
//
// $Id: DObjectManager.java,v 1.7 2001/08/02 04:49:08 mdb Exp $
// $Id: DObjectManager.java,v 1.8 2001/08/07 20:38:58 mdb Exp $
package com.threerings.cocktail.cher.dobj;
@@ -59,6 +59,15 @@ public interface DObjectManager
*/
public void unsubscribeFromObject (int oid, Subscriber target);
/**
* Requests that the specified object be destroyed. Once destroyed an
* object is removed from the runtime system and may no longer have
* events dispatched on it.
*
* @param oid The object id of the distributed object to be destroyed.
*/
public void destroyObject (int oid);
/**
* Posts a distributed object event into the system. Instead of
* requesting the modification of a distributed object attribute by
@@ -0,0 +1,63 @@
//
// $Id: ObjectDestroyedEvent.java,v 1.1 2001/08/07 20:38:58 mdb Exp $
package com.threerings.cocktail.cher.dobj;
import java.io.DataInputStream;
import java.io.DataOutputStream;
import java.io.IOException;
import java.lang.reflect.Method;
/**
* An object destroyed event is dispatched when an object has been removed
* from the distributed object system. It can also be constructed to
* request an attribute change on an object and posted to the dobjmgr.
*
* @see DObjectManager#postEvent
*/
public class ObjectDestroyedEvent extends TypedEvent
{
/** The typed object code for this event. */
public static final short TYPE = TYPE_BASE + 7;
/**
* Constructs a new object destroyed event for the specified
* distributed object.
*
* @param targetOid the object id of the object that will be destroyed.
*/
public ObjectDestroyedEvent (int targetOid)
{
super(targetOid);
}
/**
* Constructs a blank instance of this event in preparation for
* unserialization from the network.
*/
public ObjectDestroyedEvent ()
{
}
/**
* Applies this attribute change to the object.
*/
public boolean applyToObject (DObject target)
throws ObjectAccessException
{
// nothing to do in preparation for destruction, the omgr will
// have to recognize this type of event and do the right thing
return true;
}
public short getType ()
{
return TYPE;
}
protected void toString (StringBuffer buf)
{
buf.append("DESTROY:");
super.toString(buf);
}
}
@@ -1,5 +1,5 @@
//
// $Id: DObjectFactory.java,v 1.6 2001/08/03 02:11:40 mdb Exp $
// $Id: DObjectFactory.java,v 1.7 2001/08/07 20:38:58 mdb Exp $
package com.threerings.cocktail.cher.dobj.io;
@@ -49,7 +49,7 @@ public class DObjectFactory
Class clazz = Class.forName(in.readUTF());
DObject dobj = (DObject)clazz.newInstance();
dobj.setOid(in.readInt()); // read and set the oid
Log.info("Unmarshalling object: " + dobj);
// Log.info("Unmarshalling object: " + dobj);
// look up the marshaller for that class
Marshaller marsh = getMarshaller(clazz);