diff --git a/src/java/com/threerings/crowd/chat/client/ChatDirector.java b/src/java/com/threerings/crowd/chat/client/ChatDirector.java index f4e041d55..5beabc1a2 100644 --- a/src/java/com/threerings/crowd/chat/client/ChatDirector.java +++ b/src/java/com/threerings/crowd/chat/client/ChatDirector.java @@ -1,5 +1,5 @@ // -// $Id: ChatDirector.java,v 1.7 2001/10/01 22:14:55 mdb Exp $ +// $Id: ChatDirector.java,v 1.8 2001/10/02 02:07:50 mdb Exp $ package com.threerings.cocktail.party.chat; @@ -37,7 +37,7 @@ public class ChatDirector _ctx.getClient().addObserver(new ClientAdapter() { public void clientDidLogon (Client client) { - client.getInvocationManager().registerReceiver( + client.getInvocationDirector().registerReceiver( MODULE_NAME, ChatDirector.this); } }); @@ -84,7 +84,8 @@ public class ChatDirector } // dispatch a speak request on the active place object - int reqid = _ctx.getClient().getInvocationManager().nextInvocationId(); + int reqid = + _ctx.getClient().getInvocationDirector().nextInvocationId(); Object[] args = new Object[] { new Integer(reqid), message }; MessageEvent mevt = new MessageEvent( _place.getOid(), ChatService.SPEAK_REQUEST, args); @@ -160,7 +161,7 @@ public class ChatDirector } /** - * Called by the invocation manager when another client has requested + * Called by the invocation director when another client has requested * a tell message be delivered to this client. */ public void handleTellNotification (String source, String message) diff --git a/src/java/com/threerings/crowd/chat/client/ChatService.java b/src/java/com/threerings/crowd/chat/client/ChatService.java index d28d51a5b..c4b72daaf 100644 --- a/src/java/com/threerings/crowd/chat/client/ChatService.java +++ b/src/java/com/threerings/crowd/chat/client/ChatService.java @@ -1,10 +1,10 @@ // -// $Id: ChatService.java,v 1.4 2001/10/01 22:14:55 mdb Exp $ +// $Id: ChatService.java,v 1.5 2001/10/02 02:07:50 mdb Exp $ package com.threerings.cocktail.party.chat; import com.threerings.cocktail.cher.client.Client; -import com.threerings.cocktail.cher.client.InvocationManager; +import com.threerings.cocktail.cher.client.InvocationDirector; import com.threerings.cocktail.party.Log; /** @@ -33,10 +33,10 @@ public class ChatService implements ChatCodes public static int tell (Client client, String target, String message, ChatDirector rsptarget) { - InvocationManager invmgr = client.getInvocationManager(); + InvocationDirector invdir = client.getInvocationDirector(); Object[] args = new Object[] { target, message }; Log.info("Sending tell request [tgt=" + target + ", msg=" + message + "]."); - return invmgr.invoke(MODULE_NAME, TELL_REQUEST, args, rsptarget); + return invdir.invoke(MODULE_NAME, TELL_REQUEST, args, rsptarget); } } diff --git a/src/java/com/threerings/crowd/client/LocationService.java b/src/java/com/threerings/crowd/client/LocationService.java index 298e42a95..22cf58689 100644 --- a/src/java/com/threerings/crowd/client/LocationService.java +++ b/src/java/com/threerings/crowd/client/LocationService.java @@ -1,10 +1,10 @@ // -// $Id: LocationService.java,v 1.2 2001/10/01 22:14:55 mdb Exp $ +// $Id: LocationService.java,v 1.3 2001/10/02 02:07:50 mdb Exp $ package com.threerings.cocktail.party.client; import com.threerings.cocktail.cher.client.Client; -import com.threerings.cocktail.cher.client.InvocationManager; +import com.threerings.cocktail.cher.client.InvocationDirector; import com.threerings.cocktail.party.Log; /** @@ -24,9 +24,9 @@ public class LocationService implements LocationCodes public static void moveTo (Client client, int placeId, LocationDirector rsptarget) { - InvocationManager invmgr = client.getInvocationManager(); + InvocationDirector invdir = client.getInvocationDirector(); Object[] args = new Object[] { new Integer(placeId) }; - invmgr.invoke(MODULE_NAME, MOVE_TO_REQUEST, args, rsptarget); + invdir.invoke(MODULE_NAME, MOVE_TO_REQUEST, args, rsptarget); Log.info("Sent moveTo request [place=" + placeId + "]."); } } diff --git a/src/java/com/threerings/crowd/client/OccupantManager.java b/src/java/com/threerings/crowd/client/OccupantManager.java index a261bda04..c2ec64cfa 100644 --- a/src/java/com/threerings/crowd/client/OccupantManager.java +++ b/src/java/com/threerings/crowd/client/OccupantManager.java @@ -1,13 +1,13 @@ // -// $Id: OccupantManager.java,v 1.4 2001/10/01 22:14:55 mdb Exp $ +// $Id: OccupantManager.java,v 1.5 2001/10/02 02:07:50 mdb Exp $ package com.threerings.cocktail.party.client; import java.util.ArrayList; import java.util.Iterator; +import com.samskivert.util.HashIntMap; import com.threerings.cocktail.cher.dobj.*; -import com.threerings.cocktail.cher.util.IntMap; import com.threerings.cocktail.party.Log; import com.threerings.cocktail.party.data.OccupantInfo; @@ -177,5 +177,5 @@ public class OccupantManager protected ArrayList _observers = new ArrayList(); protected PlaceObject _place; - protected IntMap _ocache = new IntMap(); + protected HashIntMap _ocache = new HashIntMap(); } diff --git a/src/java/com/threerings/crowd/server/PlaceConfig.java b/src/java/com/threerings/crowd/server/PlaceConfig.java deleted file mode 100644 index 99510beb7..000000000 --- a/src/java/com/threerings/crowd/server/PlaceConfig.java +++ /dev/null @@ -1,24 +0,0 @@ -// -// $Id: PlaceConfig.java,v 1.1 2001/08/01 20:37:35 mdb Exp $ - -package com.threerings.cocktail.party.server; - -/** - * PlaceConfig acts as a central location and means for - * documenting the various standard configuration properties that can be - * provided to the place manager via its config properties object. - */ -public class PlaceConfig -{ - /** - * This configuration parameter specifies the classname of the place - * object derived class to be used when creating a new place. - */ - public static final String PLACEOBJ_CLASS = "pobj"; - - /** - * This configuration parameter specifies the classname of the place - * manager derived class to be used when creating a new place. - */ - public static final String PLACEMGR_CLASS = "pmgr"; -} diff --git a/src/java/com/threerings/crowd/server/PlaceManager.java b/src/java/com/threerings/crowd/server/PlaceManager.java index 817c2d2d1..f4d7ebacd 100644 --- a/src/java/com/threerings/crowd/server/PlaceManager.java +++ b/src/java/com/threerings/crowd/server/PlaceManager.java @@ -1,5 +1,5 @@ // -// $Id: PlaceManager.java,v 1.12 2001/08/21 22:34:20 mdb Exp $ +// $Id: PlaceManager.java,v 1.13 2001/10/02 02:07:50 mdb Exp $ package com.threerings.cocktail.party.server; @@ -25,28 +25,37 @@ import com.threerings.cocktail.party.data.*; * handles the place-related component of chatting. It also provides the * basis for place-based access control. * - *

A derived class is expected to achieve its functionality via the - * callback functions: - * - *

- * protected void didStartup ()
- * protected void willShutdown ()
- * protected void didShutdown ()
- * 
- * - * as well as through additions to handleEvent. + *

A derived class is expected to handle initialization, cleanup and + * operational functionality via the calldown functions {@link + * #didStartup}, {@link #willShutdown}, and {@link #didShutdown} as well + * as through additions to {@link #handleEvent}. */ public class PlaceManager implements Subscriber { /** * Called by the place registry after creating this place manager. - * Initialization is followed by startup which will happen when the - * place object to be managed is available. */ - public void init (PlaceRegistry registry, Properties config) + public void setPlaceRegistry (PlaceRegistry registry) { _registry = registry; - _config = config; + } + + /** + * A place manager derived class is likely to have a corresponding + * derived class of {@link PlaceObject} that it will be managing. + * Derived classes should override this method and return the class + * object for the place object derived class they desire to use. The + * place registry will use this method to create the proper place + * object during the place creation process. + * + * @return the class of the class, derived from {@link PlaceObject}, + * that this manager wishes to manage. + * + * @see PlaceRegistry#createPlace + */ + protected Class getPlaceObjectClass () + { + return PlaceObject.class; } /** @@ -81,6 +90,18 @@ public class PlaceManager implements Subscriber { } + // not called at present but will eventually be part of the shutdown + // and cleanup process + protected void willShutdown () + { + } + + // not called at present but will eventually be part of the shutdown + // and cleanup process + protected void didShutdown () + { + } + /** * When the manager starts up, it configures its place object occupant * info set by setting the type of occupant info objects it will @@ -273,9 +294,6 @@ public class PlaceManager implements Subscriber /** A reference to the place registry with which we're registered. */ protected PlaceRegistry _registry; - /** The configuration provided for this place manager. */ - protected Properties _config; - /** Message handlers are used to process message events. */ protected HashMap _msghandlers; } diff --git a/src/java/com/threerings/crowd/server/PlaceRegistry.java b/src/java/com/threerings/crowd/server/PlaceRegistry.java index ca474723b..165903755 100644 --- a/src/java/com/threerings/crowd/server/PlaceRegistry.java +++ b/src/java/com/threerings/crowd/server/PlaceRegistry.java @@ -1,16 +1,15 @@ // -// $Id: PlaceRegistry.java,v 1.8 2001/08/21 19:38:06 mdb Exp $ +// $Id: PlaceRegistry.java,v 1.9 2001/10/02 02:07:50 mdb Exp $ package com.threerings.cocktail.party.server; -import java.util.Enumeration; -import java.util.Properties; +import java.util.Iterator; import com.samskivert.util.Config; +import com.samskivert.util.HashIntMap; import com.samskivert.util.Queue; import com.threerings.cocktail.cher.dobj.*; -import com.threerings.cocktail.cher.util.IntMap; import com.threerings.cocktail.party.Log; import com.threerings.cocktail.party.data.PlaceObject; @@ -32,57 +31,13 @@ public class PlaceRegistry implements Subscriber } /** - * Creates and registers a new place along with a manager to manage - * that place. The place object class and place manager class are - * determined from the configuration information provided in the - * supplied properties instance. + * Creates and registers a new place manager along with the place + * object to be managed. The registry takes care of tracking the + * creation of the object and informing the manager when it is + * created. * - * @param config the configuration information for this place manager. - * - * @return a reference to the place manager that will manage the new - * place object or null if an error occurred creating the place or - * place manager. - * - * @exception InstantiationException thrown if an error occurs trying - * to instantiate and initialize the place manager. - * - * @see PlaceConfig#PLACEOBJ_CLASS - * @see PlaceConfig#PLACEMGR_CLASS - */ - public PlaceManager createPlace (Properties config) - throws InstantiationException - { - String pobjcl = config.getProperty(PlaceConfig.PLACEOBJ_CLASS); - if (pobjcl == null) { - throw new InstantiationException( - "No place object classname specified in place config."); - } - - String pmgrcl = config.getProperty(PlaceConfig.PLACEMGR_CLASS); - if (pobjcl == null) { - throw new InstantiationException( - "No place manager classname specified in place config."); - } - - try { - return createPlace(Class.forName(pobjcl), - Class.forName(pmgrcl), config); - } catch (Exception e) { - throw new InstantiationException( - "Error instantiating class: " + e); - } - } - - /** - * Creates and registers a new place along with a manager to manage - * that place. The registry takes care of tracking the creation of the - * object and informing the manager when it is created. - * - * @param pobjClass the PlaceObject derived class that - * should be instantiated to create the place object. - * @param pmgrClass the PlaceManager derived class that - * should be instantiated to manage the place. - * @param config the configuration information for this place manager. + * @param pmgrClass the {@link PlaceManager} derived class that should + * be instantiated to manage the place. * * @return a reference to the place manager that will manage the new * place object. @@ -90,21 +45,23 @@ public class PlaceRegistry implements Subscriber * @exception InstantiationException thrown if an error occurs trying * to instantiate and initialize the place manager. */ - public PlaceManager createPlace (Class pobjClass, Class pmgrClass, - Properties config) + public PlaceManager createPlace (Class pmgrClass) throws InstantiationException { try { // create a place manager for this place PlaceManager pmgr = (PlaceManager)pmgrClass.newInstance(); // let the pmgr know about us - pmgr.init(this, config); + pmgr.setPlaceRegistry(this); + // stick the manager on the creation queue because we know // we'll get our calls to objectAvailable()/requestFailed() in // the order that we call createObject() _createq.append(pmgr); + // and request to create the place object - PartyServer.omgr.createObject(pobjClass, this, false); + PartyServer.omgr.createObject( + pmgr.getPlaceObjectClass(), this, false); return pmgr; @@ -128,20 +85,25 @@ public class PlaceRegistry implements Subscriber * should only be accessed on the dobjmgr thread and shouldn't be kept * around across event dispatches. */ - public Enumeration getPlaces () + public Iterator getPlaces () { - final Enumeration enum = _pmgrs.elements(); - return new Enumeration() { - public boolean hasMoreElements () + final Iterator enum = _pmgrs.elements(); + return new Iterator() { + public boolean hasNext () { - return enum.hasMoreElements(); + return enum.hasNext(); } - public Object nextElement () + public Object next () { - PlaceManager plmgr = (PlaceManager)enum.nextElement(); + PlaceManager plmgr = (PlaceManager)enum.next(); return (plmgr == null) ? null : plmgr.getPlaceObject(); } + + public void remove () + { + throw new UnsupportedOperationException(); + } }; } @@ -150,7 +112,7 @@ public class PlaceRegistry implements Subscriber * This should only be accessed on the dobjmgr thread and shouldn't be * kept around across event dispatches. */ - public Enumeration getPlaceManagers () + public Iterator getPlaceManagers () { return _pmgrs.elements(); } @@ -213,5 +175,5 @@ public class PlaceRegistry implements Subscriber } protected Queue _createq = new Queue(); - protected IntMap _pmgrs = new IntMap(); + protected HashIntMap _pmgrs = new HashIntMap(); }