Created a ResultListenerList that maps the InvocationService.ResultListener
interface to a list of listeners. Also made RootDObjectManager a RunQueue so that we can pass around references to the interface rather than requiring a PresentsDObjectMgr. git-svn-id: svn+ssh://src.earth.threerings.net/narya/trunk@4789 542714f4-19e9-0310-aa3c-eee0fc999fb1
This commit is contained in:
@@ -21,34 +21,34 @@
|
|||||||
|
|
||||||
package com.threerings.presents.dobj;
|
package com.threerings.presents.dobj;
|
||||||
|
|
||||||
|
import com.samskivert.util.RunQueue;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The root distributed object manager extends the basic distributed
|
* The root distributed object manager extends the basic distributed object manager interface with
|
||||||
* object manager interface with methods that can only be guaranteed to
|
* methods that can only be guaranteed to work in the virtual machine that is hosting the
|
||||||
* work in the virtual machine that is hosting the distributed objects in
|
* distributed objects in question. VMs that operate proxies of objects can only implement the
|
||||||
* question. VMs that operate proxies of objects can only implement the
|
|
||||||
* basic distributed object manager interface.
|
* basic distributed object manager interface.
|
||||||
*/
|
*/
|
||||||
public interface RootDObjectManager extends DObjectManager
|
public interface RootDObjectManager extends DObjectManager, RunQueue
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* Looks up and returns the requested distributed object in the dobj
|
* Looks up and returns the requested distributed object in the dobj table, returning null if
|
||||||
* table, returning null if no object exists with that oid.
|
* no object exists with that oid.
|
||||||
*/
|
*/
|
||||||
public DObject getObject (int oid);
|
public DObject getObject (int oid);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Registers a distributed object instance of the supplied class with the
|
* Registers a distributed object instance of the supplied class with the system and assigns it
|
||||||
* system and assigns it an oid. When the call returns the object will be
|
* an oid. When the call returns the object will be registered with the system and its oid will
|
||||||
* registered with the system and its oid will have been assigned.
|
* have been assigned.
|
||||||
*
|
*
|
||||||
* @return the registered object for the caller's convenience.
|
* @return the registered object for the caller's convenience.
|
||||||
*/
|
*/
|
||||||
public <T extends DObject> T registerObject (T object);
|
public <T extends DObject> T registerObject (T object);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Requests that the specified object be destroyed. Once destroyed an
|
* Requests that the specified object be destroyed. Once destroyed an object is removed from
|
||||||
* object is removed from the runtime system and may no longer have
|
* the runtime system and may no longer have events dispatched on it.
|
||||||
* events dispatched on it.
|
|
||||||
*
|
*
|
||||||
* @param oid The object id of the distributed object to be destroyed.
|
* @param oid The object id of the distributed object to be destroyed.
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -0,0 +1,50 @@
|
|||||||
|
//
|
||||||
|
// $Id$
|
||||||
|
//
|
||||||
|
// Narya library - tools for developing networked games
|
||||||
|
// Copyright (C) 2002-2007 Three Rings Design, Inc., All Rights Reserved
|
||||||
|
// http://www.threerings.net/code/narya/
|
||||||
|
//
|
||||||
|
// This library is free software; you can redistribute it and/or modify it
|
||||||
|
// under the terms of the GNU Lesser General Public License as published
|
||||||
|
// by the Free Software Foundation; either version 2.1 of the License, or
|
||||||
|
// (at your option) any later version.
|
||||||
|
//
|
||||||
|
// This library is distributed in the hope that it will be useful,
|
||||||
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||||
|
// Lesser General Public License for more details.
|
||||||
|
//
|
||||||
|
// You should have received a copy of the GNU Lesser General Public
|
||||||
|
// License along with this library; if not, write to the Free Software
|
||||||
|
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||||
|
|
||||||
|
package com.threerings.presents.util;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
|
||||||
|
import com.threerings.presents.client.InvocationService;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Maintains a list of result listeners, dispatching the eventual actual result or failure to them
|
||||||
|
* all as if they were a single listener.
|
||||||
|
*/
|
||||||
|
public class ResultListenerList extends ArrayList<InvocationService.ResultListener>
|
||||||
|
implements InvocationService.ResultListener
|
||||||
|
{
|
||||||
|
// from InvocationService.ResultListener
|
||||||
|
public void requestProcessed (Object result)
|
||||||
|
{
|
||||||
|
for (InvocationService.ResultListener listener : this) {
|
||||||
|
listener.requestProcessed(result);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// from InvocationService.ResultListener
|
||||||
|
public void requestFailed (String cause)
|
||||||
|
{
|
||||||
|
for (InvocationService.ResultListener listener : this) {
|
||||||
|
listener.requestFailed(cause);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user