Style fixes and import pruning. Beware, CheckStyle is (finally) coming to town.

git-svn-id: svn+ssh://src.earth.threerings.net/narya/trunk@5240 542714f4-19e9-0310-aa3c-eee0fc999fb1
This commit is contained in:
Michael Bayne
2008-07-18 18:32:59 +00:00
parent 45f0f9d8b7
commit e41dda3018
37 changed files with 103 additions and 110 deletions
@@ -38,11 +38,11 @@ public interface AdminService extends InvocationService
* Delivers a successful response to a {@link #getConfigInfo} * Delivers a successful response to a {@link #getConfigInfo}
* request. * request.
*/ */
public void gotConfigInfo (String[] keys, int[] oids); void gotConfigInfo (String[] keys, int[] oids);
} }
/** /**
* Requests the list of config objects. * Requests the list of config objects.
*/ */
public void getConfigInfo (Client client, ConfigInfoListener listener); void getConfigInfo (Client client, ConfigInfoListener listener);
} }
@@ -78,13 +78,13 @@ public class AsStringFieldEditor extends FieldEditor
} else if (_field.getType().equals(int[].class)) { } else if (_field.getType().equals(int[].class)) {
return StringUtil.parseIntArray(_value.getText()); return StringUtil.parseIntArray(_value.getText());
} else if (_field.getType().equals(float[].class)) { } else if (_field.getType().equals(float[].class)) {
return StringUtil.parseFloatArray(_value.getText()); return StringUtil.parseFloatArray(_value.getText());
} else if (_field.getType().equals(long[].class)) { } else if (_field.getType().equals(long[].class)) {
return StringUtil.parseLongArray(_value.getText()); return StringUtil.parseLongArray(_value.getText());
} else if (_field.getType().equals(Boolean.TYPE)) { } else if (_field.getType().equals(Boolean.TYPE)) {
return new Boolean(_value.getText().equalsIgnoreCase("true")); return new Boolean(_value.getText().equalsIgnoreCase("true"));
@@ -35,7 +35,7 @@ import com.threerings.presents.dobj.DObject;
import com.threerings.presents.util.PresentsContext; import com.threerings.presents.util.PresentsContext;
/** /**
* Provides "editing" of boolean fields * Provides "editing" of boolean fields.
*/ */
public class BooleanFieldEditor extends FieldEditor public class BooleanFieldEditor extends FieldEditor
{ {
@@ -58,7 +58,7 @@ public class ConfigEditorPanel extends JPanel
_defaultPane = defaultPane; _defaultPane = defaultPane;
setLayout(new VGroupLayout(VGroupLayout.STRETCH, VGroupLayout.STRETCH, setLayout(new VGroupLayout(VGroupLayout.STRETCH, VGroupLayout.STRETCH,
5, VGroupLayout.CENTER)); VGroupLayout.DEFAULT_GAP, VGroupLayout.CENTER));
// create our objects tabbed pane // create our objects tabbed pane
add(_oeditors = new JTabbedPane(JTabbedPane.LEFT)); add(_oeditors = new JTabbedPane(JTabbedPane.LEFT));
@@ -39,9 +39,9 @@ import static com.threerings.admin.Log.log;
*/ */
public class ConfigObjectManager implements AdminService.ConfigInfoListener public class ConfigObjectManager implements AdminService.ConfigInfoListener
{ {
public ConfigObjectManager(Client client) public ConfigObjectManager (Client client)
{ {
_serverconfig = new HashMap<String,ConfigObject>(); _serverconfig = new HashMap<String, ConfigObject>();
_client = client; _client = client;
_client.addClientObserver(new ClientAdapter() { _client.addClientObserver(new ClientAdapter() {
public void clientWillLogon (Client client) { public void clientWillLogon (Client client) {
@@ -62,7 +62,7 @@ public class ConfigObjectManager implements AdminService.ConfigInfoListener
} }
/** /**
* Returns the ConfigObject identified by the given key * Returns the ConfigObject identified by the given key.
*/ */
public ConfigObject getServerConfig (String key) public ConfigObject getServerConfig (String key)
{ {
@@ -87,16 +87,16 @@ public class ConfigObjectManager implements AdminService.ConfigInfoListener
/** /**
* Convenience: generate a getConfigInfo request to the AdminService from the external class, * Convenience: generate a getConfigInfo request to the AdminService from the external class,
* instead from within the anonymous inner class * instead from within the anonymous inner class.
*/ */
protected void getConfigInfo() protected void getConfigInfo ()
{ {
_service.getConfigInfo(_client, this); _service.getConfigInfo(_client, this);
} }
/** /**
* This class takes care of the details of subscribing to and placing an individual * This class takes care of the details of subscribing to and placing an individual
* ConfigObject that the server knows about into a HashMap * ConfigObject that the server knows about into a HashMap.
*/ */
protected class ConfigObjectSubscriber implements Subscriber<ConfigObject> protected class ConfigObjectSubscriber implements Subscriber<ConfigObject>
{ {
@@ -133,28 +133,28 @@ public class ConfigObjectManager implements AdminService.ConfigInfoListener
_serverconfig.remove(_key); _serverconfig.remove(_key);
} }
/** The object that we are tracking */ /** The object that we are tracking. */
protected ConfigObject _cobj; protected ConfigObject _cobj;
/** The name of the config object that we are subscribing to */ /** The name of the config object to which we are subscribing. */
protected String _key; protected String _key;
/** The oid of the object that we're tracking */ /** The oid of the object that we're tracking. */
protected int _oid; protected int _oid;
} }
/** An array of handlers that each subscribe to a single ConfigObject */ /** An array of handlers that each subscribe to a single ConfigObject. */
protected ConfigObjectSubscriber[] _csubscribers; protected ConfigObjectSubscriber[] _csubscribers;
/** Our local copy of the server-side runtime configuration */ /** Our local copy of the server-side runtime configuration. */
protected HashMap<String,ConfigObject> _serverconfig; protected HashMap<String, ConfigObject> _serverconfig;
/** Our distributed object manager */ /** Our distributed object manager. */
protected DObjectManager _dobjmgr; protected DObjectManager _dobjmgr;
/** Our admin service that we're using to fetch data */ /** Our admin service that we're using to fetch data. */
protected AdminService _service; protected AdminService _service;
/** Our client object */ /** Our client object. */
protected Client _client; protected Client _client;
} }
@@ -125,7 +125,7 @@ public class DSetEditor extends JPanel
public Dimension getPreferredSize () public Dimension getPreferredSize ()
{ {
Dimension d = super.getPreferredSize(); Dimension d = super.getPreferredSize();
d.height = Math.min(d.height, 200); d.height = Math.min(d.height, MIN_HEIGHT);
return d; return d;
} }
@@ -193,8 +193,8 @@ public class DSetEditor extends JPanel
// documentation inherited from interface ActionListener // documentation inherited from interface ActionListener
public void actionPerformed (ActionEvent event) public void actionPerformed (ActionEvent event)
{ {
CommandEvent ce = (CommandEvent) event; CommandEvent ce = (CommandEvent)event;
_setter.updateSet(_setName, (DSet.Entry) ce.getArgument()); _setter.updateSet(_setName, (DSet.Entry)ce.getArgument());
} }
protected void refreshData () protected void refreshData ()
@@ -223,4 +223,7 @@ public class DSetEditor extends JPanel
/** The table used to edit. */ /** The table used to edit. */
protected ObjectEditorTable _table; protected ObjectEditorTable _table;
/** The minimum height for our editor UI. */
protected static final int MIN_HEIGHT = 200;
} }
@@ -105,8 +105,7 @@ public abstract class FieldEditor extends JPanel
try { try {
_object.changeAttribute(_field.getName(), value); _object.changeAttribute(_field.getName(), value);
} catch (ObjectAccessException oae) { } catch (ObjectAccessException oae) {
log.warning("Failed to update field " + _field.getName() + log.warning("Failed to update field " + _field.getName() + ": " + oae);
": "+ oae);
} }
} }
} }
@@ -30,7 +30,6 @@ import com.samskivert.swing.ScrollablePanel;
import com.samskivert.swing.VGroupLayout; import com.samskivert.swing.VGroupLayout;
import com.samskivert.swing.util.SwingUtil; import com.samskivert.swing.util.SwingUtil;
import com.threerings.presents.dobj.DObject;
import com.threerings.presents.dobj.ObjectAccessException; import com.threerings.presents.dobj.ObjectAccessException;
import com.threerings.presents.dobj.Subscriber; import com.threerings.presents.dobj.Subscriber;
import com.threerings.presents.util.PresentsContext; import com.threerings.presents.util.PresentsContext;
@@ -60,8 +59,8 @@ public class ObjectEditorPanel extends ScrollablePanel
public ObjectEditorPanel (PresentsContext ctx, String key, int oid) public ObjectEditorPanel (PresentsContext ctx, String key, int oid)
{ {
super(new VGroupLayout(VGroupLayout.NONE, VGroupLayout.STRETCH, super(new VGroupLayout(VGroupLayout.NONE, VGroupLayout.STRETCH,
5, VGroupLayout.TOP)); VGroupLayout.DEFAULT_GAP, VGroupLayout.TOP));
setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5)); setBorder(BorderFactory.createEmptyBorder(BORDER, BORDER, BORDER, BORDER));
// keep this business around // keep this business around
_ctx = ctx; _ctx = ctx;
@@ -127,4 +126,6 @@ public class ObjectEditorPanel extends ScrollablePanel
protected String _key; protected String _key;
protected SafeSubscriber<ConfigObject> _safesub; protected SafeSubscriber<ConfigObject> _safesub;
protected ConfigObject _object; protected ConfigObject _object;
protected static final int BORDER = 5;
} }
@@ -48,13 +48,13 @@ public class PulldownFieldEditor extends FieldEditor
/** /**
* Construct a pulldown choice. * Construct a pulldown choice.
*/ */
public Choice (String displayName, Object value) public Choice (String displayName, Object val)
{ {
if (displayName == null) { if (displayName == null) {
throw new NullPointerException("displayName cannot be null."); throw new NullPointerException("displayName cannot be null.");
} }
_name = displayName; _name = displayName;
this.value = value; value = val;
} }
// documentation inherited // documentation inherited
@@ -117,14 +117,14 @@ public class PulldownFieldEditor extends FieldEditor
if (obj == null) { if (obj == null) {
return null; return null;
} }
return ((Choice) obj).value; return ((Choice)obj).value;
} }
// documentation inherited // documentation inherited
protected void displayValue (Object value) protected void displayValue (Object value)
{ {
for (int ii = _value.getItemCount() - 1; ii >= 0; ii--) { for (int ii = _value.getItemCount() - 1; ii >= 0; ii--) {
Choice choice = (Choice) _value.getItemAt(ii); Choice choice = (Choice)_value.getItemAt(ii);
if (ObjectUtil.equals(value, choice.value)) { if (ObjectUtil.equals(value, choice.value)) {
_value.setSelectedIndex(ii); _value.setSelectedIndex(ii);
return; return;
@@ -33,7 +33,6 @@ import com.samskivert.util.StringUtil;
import com.threerings.io.ObjectInputStream; import com.threerings.io.ObjectInputStream;
import com.threerings.io.ObjectOutputStream; import com.threerings.io.ObjectOutputStream;
import com.threerings.io.Streamable; import com.threerings.io.Streamable;
import com.threerings.presents.dobj.AccessController;
import com.threerings.presents.dobj.AttributeChangeListener; import com.threerings.presents.dobj.AttributeChangeListener;
import com.threerings.presents.dobj.AttributeChangedEvent; import com.threerings.presents.dobj.AttributeChangedEvent;
import com.threerings.presents.dobj.DObject; import com.threerings.presents.dobj.DObject;
@@ -79,7 +78,7 @@ public abstract class ConfigRegistry
/** /**
* Creates a ConfigRegistry. * Creates a ConfigRegistry.
* *
* @param transitioning if true, serialized Streamable instances stored in the registry will * @param transitioning if true, serialized Streamable instances stored in the registry will
* be written back out immediately to allow them to be transitioned to new class names. * be written back out immediately to allow them to be transitioned to new class names.
*/ */
@@ -143,9 +142,9 @@ public abstract class ConfigRegistry
{ {
public DObject object; public DObject object;
public ObjectRecord (DObject object) public ObjectRecord (DObject obj)
{ {
this.object = object; object = obj;
} }
public void init () public void init ()
@@ -238,7 +237,7 @@ public abstract class ConfigRegistry
} else if (value instanceof String[]) { } else if (value instanceof String[]) {
setValue(key, (String[])value); setValue(key, (String[])value);
} else if (value instanceof long[]) { } else if (value instanceof long[]) {
setValue(key, (long[]) value); setValue(key, (long[])value);
} else { } else {
log.info("Unable to flush config obj change [cobj=" + object.getClass().getName() + log.info("Unable to flush config obj change [cobj=" + object.getClass().getName() +
", key=" + key + ", type=" + value.getClass().getName() + ", key=" + key + ", type=" + value.getClass().getName() +
@@ -310,7 +309,7 @@ public abstract class ConfigRegistry
Object deserializedValue = oin.readObject(); Object deserializedValue = oin.readObject();
field.set(object, deserializedValue); field.set(object, deserializedValue);
if (_transitioning) { if (_transitioning) {
// Use serialize rather than serializeAttribute so we don't get // Use serialize rather than serializeAttribute so we don't get
// ObjectAccessExceptions // ObjectAccessExceptions
serialize(key, nameToKey(key), deserializedValue); serialize(key, nameToKey(key), deserializedValue);
} }
@@ -404,8 +403,8 @@ public abstract class ConfigRegistry
} }
/** A mapping from identifying key to config object. */ /** A mapping from identifying key to config object. */
protected HashMap<String,ObjectRecord> _configs = new HashMap<String,ObjectRecord>(); protected HashMap<String, ObjectRecord> _configs = new HashMap<String, ObjectRecord>();
/** If we need to transition serialized Streamables to a new class format in init.. */ /** If we need to transition serialized Streamables to a new class format in init.. */
protected boolean _transitioning; protected boolean _transitioning;
} }
@@ -59,10 +59,10 @@ public class DatabaseConfigRegistry extends ConfigRegistry
{ {
this(ctx, invoker, false); this(ctx, invoker, false);
} }
/** /**
* Creates a configuration registry and prepares it for operation. * Creates a configuration registry and prepares it for operation.
* *
* @param ctx will provide access to our database. * @param ctx will provide access to our database.
* @param invoker this will be used to perform all database activity (except first time * @param invoker this will be used to perform all database activity (except first time
* initialization) so as to avoid blocking the distributed object thread. * initialization) so as to avoid blocking the distributed object thread.
@@ -40,6 +40,7 @@ public class PrefsConfigRegistry extends ConfigRegistry
return new PrefsObjectRecord(path, object); return new PrefsObjectRecord(path, object);
} }
/** Stores preferences using the Java preferences system. */
protected class PrefsObjectRecord extends ObjectRecord protected class PrefsObjectRecord extends ObjectRecord
{ {
public PrefsConfig config; public PrefsConfig config;
@@ -28,6 +28,9 @@ import com.samskivert.jdbc.depot.annotation.Entity;
import com.samskivert.jdbc.depot.annotation.Id; import com.samskivert.jdbc.depot.annotation.Id;
import com.samskivert.jdbc.depot.expression.ColumnExp; import com.samskivert.jdbc.depot.expression.ColumnExp;
/**
* Stores information about a configuration entry in the database.
*/
@Entity(name="CONFIG") @Entity(name="CONFIG")
public class ConfigRecord extends PersistentRecord public class ConfigRecord extends PersistentRecord
{ {
@@ -45,7 +45,7 @@ public class ConfigRepository extends DepotRepository
/** /**
* Loads up the configuration data for the specified object. * Loads up the configuration data for the specified object.
* *
* @return a map containing field/value pairs for all stored configuration data. * @return a map containing field/value pairs for all stored configuration data.
*/ */
public HashMap<String,String> loadConfig (String node, String object) public HashMap<String,String> loadConfig (String node, String object)
@@ -28,7 +28,7 @@ import com.threerings.bureau.util.BureauContext;
import com.threerings.presents.dobj.DObjectManager; import com.threerings.presents.dobj.DObjectManager;
import com.samskivert.util.Config; import com.samskivert.util.Config;
/** /**
* Represents a client embedded in a bureau. * Represents a client embedded in a bureau.
*/ */
public abstract class BureauClient extends Client public abstract class BureauClient extends Client
@@ -53,7 +53,7 @@ public abstract class BureauClient extends Client
protected BureauContext createContext () protected BureauContext createContext ()
{ {
return new BureauContext () { return new BureauContext() {
public BureauDirector getBureauDirector () { public BureauDirector getBureauDirector () {
return _director; return _director;
} }
@@ -51,7 +51,7 @@ public abstract class BureauDirector extends BasicDirector
log.info("Subscribing to object " + agentId); log.info("Subscribing to object " + agentId);
SafeSubscriber<AgentObject> subscriber = SafeSubscriber<AgentObject> subscriber =
new SafeSubscriber<AgentObject>(agentId, delegator); new SafeSubscriber<AgentObject>(agentId, delegator);
_subscribers.put(agentId, subscriber); _subscribers.put(agentId, subscriber);
subscriber.subscribe(_ctx.getDObjectManager()); subscriber.subscribe(_ctx.getDObjectManager());
@@ -67,19 +67,16 @@ public abstract class BureauDirector extends BasicDirector
if (agent == null) { if (agent == null) {
log.warning("Lost an agent, id " + agentId); log.warning("Lost an agent, id " + agentId);
} } else {
else {
try { try {
agent.stop(); agent.stop();
} } catch (Throwable t) {
catch (Throwable t) {
log.warning("Stopping an agent caused an exception", t); log.warning("Stopping an agent caused an exception", t);
} }
SafeSubscriber<AgentObject> subscriber = _subscribers.remove(agentId); SafeSubscriber<AgentObject> subscriber = _subscribers.remove(agentId);
if (subscriber == null) { if (subscriber == null) {
log.warning("Lost a subscriber for agent " + agent); log.warning("Lost a subscriber for agent " + agent);
} } else {
else {
subscriber.unsubscribe(_ctx.getDObjectManager()); subscriber.unsubscribe(_ctx.getDObjectManager());
} }
_bureauService.agentDestroyed(_ctx.getClient(), agentId); _bureauService.agentDestroyed(_ctx.getClient(), agentId);
@@ -87,7 +84,8 @@ public abstract class BureauDirector extends BasicDirector
} }
/** /**
* Callback for when the a request to subscribe to an object finishes and the object is available. * Callback for when the a request to subscribe to an object finishes and the object is
* available.
*/ */
protected synchronized void objectAvailable (AgentObject agentObject) protected synchronized void objectAvailable (AgentObject agentObject)
{ {
@@ -100,13 +98,12 @@ public abstract class BureauDirector extends BasicDirector
agent = createAgent(agentObject); agent = createAgent(agentObject);
agent.init(agentObject); agent.init(agentObject);
agent.start(); agent.start();
} } catch (Throwable t) {
catch (Throwable t) {
log.warning("Could not create agent [obj=" + agentObject + "]", t); log.warning("Could not create agent [obj=" + agentObject + "]", t);
_bureauService.agentCreationFailed(_ctx.getClient(), oid); _bureauService.agentCreationFailed(_ctx.getClient(), oid);
return; return;
} }
_agents.put(oid, agent); _agents.put(oid, agent);
_bureauService.agentCreated(_ctx.getClient(), oid); _bureauService.agentCreated(_ctx.getClient(), oid);
} }
@@ -127,9 +124,8 @@ public abstract class BureauDirector extends BasicDirector
// Require the bureau services // Require the bureau services
client.addServiceGroup(BureauCodes.BUREAU_GROUP); client.addServiceGroup(BureauCodes.BUREAU_GROUP);
// Set up our decoder so we can receive method calls // Set up our decoder so we can receive method calls from the server
// from the server BureauReceiver receiver = new BureauReceiver() {
BureauReceiver receiver = new BureauReceiver () {
public void createAgent (int agentId) { public void createAgent (int agentId) {
BureauDirector.this.createAgent(agentId); BureauDirector.this.createAgent(agentId);
} }
@@ -151,8 +147,8 @@ public abstract class BureauDirector extends BasicDirector
} }
/** /**
* Called when it is time to create an Agent. Subclasses should read the * Called when it is time to create an Agent. Subclasses should read the
* <code>agentObject</code>'s type and/or properties to determine what kind of Agent to * <code>agentObject</code>'s type and/or properties to determine what kind of Agent to
* create. * create.
* @param agentObj the distributed and object * @param agentObj the distributed and object
* @return a new Agent that will govern the distributed object * @return a new Agent that will govern the distributed object
@@ -162,6 +158,6 @@ public abstract class BureauDirector extends BasicDirector
protected BureauContext _ctx; protected BureauContext _ctx;
protected BureauService _bureauService; protected BureauService _bureauService;
protected IntMap<Agent> _agents = IntMaps.newHashIntMap(); protected IntMap<Agent> _agents = IntMaps.newHashIntMap();
protected IntMap<SafeSubscriber<AgentObject>> _subscribers = protected IntMap<SafeSubscriber<AgentObject>> _subscribers =
IntMaps.newHashIntMap(); IntMaps.newHashIntMap();
} }
@@ -29,7 +29,7 @@ import com.threerings.presents.client.InvocationReceiver;
public interface BureauReceiver extends InvocationReceiver public interface BureauReceiver extends InvocationReceiver
{ {
/** /**
* Creates a new agent. Implementors should create a new {@link Agent} and give it access to * Creates a new agent. Implementors should create a new {@link Agent} and give it access to
* the {@link AgentObject} referred to by the <code>agentId</code> parameter and must notify * the {@link AgentObject} referred to by the <code>agentId</code> parameter and must notify
* the service that the agent has been created using {@link BureauService#agentCreated}. * the service that the agent has been created using {@link BureauService#agentCreated}.
* @param client the client receiving the request * @param client the client receiving the request
@@ -38,11 +38,11 @@ public interface BureauReceiver extends InvocationReceiver
void createAgent (int agentId); void createAgent (int agentId);
/** /**
* Destroys a previously created agent. Implementors should destroy the agent that was created * Destroys a previously created agent. Implementors should destroy the agent that was created
* by the call to <code>createAgent</code> with the same agent id and must notify * by the call to <code>createAgent</code> with the same agent id and must notify
* the service that the agent has been created using {@link BureauService#agentDestroyed}. * the service that the agent has been created using {@link BureauService#agentDestroyed}.
* @param client the client receiving the request * @param client the client receiving the request
* @param agentId the id of the <code>AgentObject</code> whose <code>Agent</code> * @param agentId the id of the <code>AgentObject</code> whose <code>Agent</code>
* should be destroyed * should be destroyed
*/ */
void destroyAgent (int agentId); void destroyAgent (int agentId);
@@ -24,7 +24,7 @@ package com.threerings.bureau.client;
import com.threerings.presents.client.Client; import com.threerings.presents.client.Client;
import com.threerings.presents.client.InvocationService; import com.threerings.presents.client.InvocationService;
/** /**
* Interface for the bureau to communicate with the server. * Interface for the bureau to communicate with the server.
*/ */
public interface BureauService extends InvocationService public interface BureauService extends InvocationService
@@ -23,6 +23,9 @@ package com.threerings.bureau.data;
import com.threerings.presents.dobj.DObject; import com.threerings.presents.dobj.DObject;
/**
* Contains information for configuring and communicating with an agent.
*/
public class AgentObject extends DObject public class AgentObject extends DObject
{ {
// AUTO-GENERATED: FIELDS START // AUTO-GENERATED: FIELDS START
@@ -55,11 +58,11 @@ public class AgentObject extends DObject
* some other description that the bureau can use to load and execute the agent's code. */ * some other description that the bureau can use to load and execute the agent's code. */
public String code; public String code;
/** The main class within the code to use when launching an agent. Whther this value is /** The main class within the code to use when launching an agent. Whther this value is
* used depends on the type of bureau and will be resolve in the bureau client. */ * used depends on the type of bureau and will be resolve in the bureau client. */
public String className; public String className;
/** The id of the client running this agent (only set after the agent is assigned to a /** The id of the client running this agent (only set after the agent is assigned to a
* bureau and run). */ * bureau and run). */
public int clientOid; public int clientOid;
@@ -29,11 +29,11 @@ import com.threerings.util.Name;
*/ */
public class BureauCredentials extends Credentials public class BureauCredentials extends Credentials
{ {
public static String PREFIX = "@@bureau:"; public static final String PREFIX = "@@bureau:";
public static String SUFFIX = "@@"; public static final String SUFFIX = "@@";
/** /**
* The token to pass to the server when logging in. This is usually just passed to the bureau * The token to pass to the server when logging in. This is usually just passed to the bureau
* on the command line to guard against outside connections being established. * on the command line to guard against outside connections being established.
*/ */
public String sessionToken; public String sessionToken;
@@ -31,7 +31,7 @@ public class BureauAuthenticator extends ChainedAuthenticator
@Override // from Authenticator @Override // from Authenticator
protected void processAuthentication ( protected void processAuthentication (
AuthingConnection conn, AuthingConnection conn,
AuthResponse rsp) AuthResponse rsp)
{ {
AuthRequest req = conn.getAuthRequest(); AuthRequest req = conn.getAuthRequest();
@@ -42,7 +42,7 @@ public class BureauAuthenticator extends ChainedAuthenticator
rsp.getData().code = AuthResponseData.SUCCESS; rsp.getData().code = AuthResponseData.SUCCESS;
} else { } else {
log.warning("Received invalid bureau auth request [creds=" + log.warning("Received invalid bureau auth request [creds=" +
creds + "], problem: " + problem); creds + "], problem: " + problem);
rsp.getData().code = AuthCodes.SERVER_ERROR; rsp.getData().code = AuthCodes.SERVER_ERROR;
} }
@@ -32,20 +32,20 @@ public interface BureauProvider extends InvocationProvider
/** /**
* Handles a {@link BureauService#agentCreated} request. * Handles a {@link BureauService#agentCreated} request.
*/ */
public void agentCreated (ClientObject caller, int arg1); void agentCreated (ClientObject caller, int arg1);
/** /**
* Handles a {@link BureauService#agentCreationFailed} request. * Handles a {@link BureauService#agentCreationFailed} request.
*/ */
public void agentCreationFailed (ClientObject caller, int arg1); void agentCreationFailed (ClientObject caller, int arg1);
/** /**
* Handles a {@link BureauService#agentDestroyed} request. * Handles a {@link BureauService#agentDestroyed} request.
*/ */
public void agentDestroyed (ClientObject caller, int arg1); void agentDestroyed (ClientObject caller, int arg1);
/** /**
* Handles a {@link BureauService#bureauInitialized} request. * Handles a {@link BureauService#bureauInitialized} request.
*/ */
public void bureauInitialized (ClientObject caller, String arg1); void bureauInitialized (ClientObject caller, String arg1);
} }
@@ -57,8 +57,8 @@ import static com.threerings.bureau.Log.log;
public class BureauRegistry public class BureauRegistry
{ {
/** /**
* Defines how a bureau is launched. Instances are associated to bureau types by the server on * Defines how a bureau is launched. Instances are associated to bureau types by the server on
* startup. The instances are used whenever the registry needs to launch a bureau for an agent * startup. The instances are used whenever the registry needs to launch a bureau for an agent
* with the assocated bureau type. * with the assocated bureau type.
*/ */
public static interface Launcher public static interface Launcher
@@ -168,7 +168,7 @@ public class BureauRegistry
} }
if (!bureau.token.equals(creds.sessionToken)) { if (!bureau.token.equals(creds.sessionToken)) {
return "Bureau " + creds.bureauId + return "Bureau " + creds.bureauId +
" does not match credentials token"; " does not match credentials token";
} }
@@ -183,11 +183,11 @@ public class BureauRegistry
* @param cmdGenerator the generator to be used for bureaus of <code>bureauType</code> * @param cmdGenerator the generator to be used for bureaus of <code>bureauType</code>
*/ */
public void setCommandGenerator ( public void setCommandGenerator (
String bureauType, String bureauType,
final CommandGenerator cmdGenerator) final CommandGenerator cmdGenerator)
{ {
setLauncher(bureauType, new Launcher () { setLauncher(bureauType, new Launcher () {
public void launchBureau (String bureauId, String token) public void launchBureau (String bureauId, String token)
throws IOException { throws IOException {
ProcessBuilder builder = new ProcessBuilder( ProcessBuilder builder = new ProcessBuilder(
cmdGenerator.createCommand(bureauId, token)); cmdGenerator.createCommand(bureauId, token));
@@ -338,7 +338,7 @@ public class BureauRegistry
} }
if (bureau.client != null) { if (bureau.client != null) {
log.warning( log.warning(
"Multiple sessions for the same bureau", "id", id, "client", client, "bureau", "Multiple sessions for the same bureau", "id", id, "client", client, "bureau",
bureau); bureau);
} }
bureau.client = client; bureau.client = client;
@@ -353,7 +353,7 @@ public class BureauRegistry
} }
if (bureau.client == null) { if (bureau.client == null) {
log.warning( log.warning(
"Multiple logouts from the same bureau", "id", id, "client", client, "bureau", "Multiple logouts from the same bureau", "id", id, "client", client, "bureau",
bureau); bureau);
} }
bureau.client = null; bureau.client = null;
@@ -564,12 +564,12 @@ public class BureauRegistry
} }
/** /**
* Create a hard-to-guess token that the bureau can use to authenticate itself when it tries * Create a hard-to-guess token that the bureau can use to authenticate itself when it tries
* to log in. * to log in.
*/ */
protected String generateToken (String bureauId) protected String generateToken (String bureauId)
{ {
String tokenSource = bureauId + "@" + String tokenSource = bureauId + "@" +
System.currentTimeMillis() + "r" + Math.random(); System.currentTimeMillis() + "r" + Math.random();
return StringUtil.md5hex(tokenSource); return StringUtil.md5hex(tokenSource);
} }
@@ -581,7 +581,7 @@ public class BureauRegistry
{ {
LauncherUnit (Bureau bureau) LauncherUnit (Bureau bureau)
{ {
super("LauncherUnit for " + bureau + ": " + super("LauncherUnit for " + bureau + ": " +
StringUtil.toString(bureau.launcher)); StringUtil.toString(bureau.launcher));
_bureau = bureau; _bureau = bureau;
} }
@@ -44,7 +44,6 @@ import com.threerings.crowd.data.CrowdCodes;
import com.threerings.crowd.data.OccupantInfo; import com.threerings.crowd.data.OccupantInfo;
import com.threerings.crowd.data.PlaceObject; import com.threerings.crowd.data.PlaceObject;
import com.threerings.crowd.server.BodyLocator; import com.threerings.crowd.server.BodyLocator;
import com.threerings.crowd.server.CrowdServer;
import com.threerings.crowd.server.PlaceRegistry; import com.threerings.crowd.server.PlaceRegistry;
import com.threerings.crowd.chat.client.ChatService.TellListener; import com.threerings.crowd.chat.client.ChatService.TellListener;
@@ -32,5 +32,5 @@ public interface SpeakProvider extends InvocationProvider
/** /**
* Handles a {@link SpeakService#speak} request. * Handles a {@link SpeakService#speak} request.
*/ */
public void speak (ClientObject caller, String arg1, byte arg2); void speak (ClientObject caller, String arg1, byte arg2);
} }
@@ -35,7 +35,6 @@ import com.threerings.crowd.data.OccupantInfo;
import com.threerings.crowd.data.PlaceObject; import com.threerings.crowd.data.PlaceObject;
import com.threerings.crowd.util.CrowdContext; import com.threerings.crowd.util.CrowdContext;
/** /**
* The occupant director listens for occupants of places to enter and * The occupant director listens for occupants of places to enter and
* exit, and dispatches notices to interested parties about these events. * exit, and dispatches notices to interested parties about these events.
@@ -36,11 +36,11 @@ public interface CrowdPeerProvider extends InvocationProvider
/** /**
* Handles a {@link CrowdPeerService#deliverBroadcast} request. * Handles a {@link CrowdPeerService#deliverBroadcast} request.
*/ */
public void deliverBroadcast (ClientObject caller, Name arg1, String arg2, String arg3, boolean arg4); void deliverBroadcast (ClientObject caller, Name arg1, String arg2, String arg3, boolean arg4);
/** /**
* Handles a {@link CrowdPeerService#deliverTell} request. * Handles a {@link CrowdPeerService#deliverTell} request.
*/ */
public void deliverTell (ClientObject caller, UserMessage arg1, Name arg2, ChatService.TellListener arg3) void deliverTell (ClientObject caller, UserMessage arg1, Name arg2, ChatService.TellListener arg3)
throws InvocationException; throws InvocationException;
} }
@@ -32,5 +32,5 @@ public interface BodyProvider extends InvocationProvider
/** /**
* Handles a {@link BodyService#setIdle} request. * Handles a {@link BodyService#setIdle} request.
*/ */
public void setIdle (ClientObject caller, boolean arg1); void setIdle (ClientObject caller, boolean arg1);
} }
@@ -25,22 +25,16 @@ import com.google.inject.Guice;
import com.google.inject.Inject; import com.google.inject.Inject;
import com.google.inject.Injector; import com.google.inject.Injector;
import com.google.inject.Singleton; import com.google.inject.Singleton;
import com.samskivert.util.Invoker;
import com.threerings.util.Name; import com.threerings.util.Name;
import com.threerings.presents.net.AuthRequest; import com.threerings.presents.net.AuthRequest;
import com.threerings.presents.server.ClientFactory; import com.threerings.presents.server.ClientFactory;
import com.threerings.presents.server.ClientManager;
import com.threerings.presents.server.ClientResolver; import com.threerings.presents.server.ClientResolver;
import com.threerings.presents.server.InvocationManager;
import com.threerings.presents.server.PresentsClient; import com.threerings.presents.server.PresentsClient;
import com.threerings.presents.server.PresentsDObjectMgr;
import com.threerings.presents.server.PresentsServer; import com.threerings.presents.server.PresentsServer;
import com.threerings.presents.server.net.ConnectionManager;
import com.threerings.crowd.chat.server.ChatProvider; import com.threerings.crowd.chat.server.ChatProvider;
import com.threerings.crowd.data.BodyObject;
import static com.threerings.crowd.Log.log; import static com.threerings.crowd.Log.log;
@@ -34,11 +34,11 @@ public interface LocationProvider extends InvocationProvider
/** /**
* Handles a {@link LocationService#leavePlace} request. * Handles a {@link LocationService#leavePlace} request.
*/ */
public void leavePlace (ClientObject caller); void leavePlace (ClientObject caller);
/** /**
* Handles a {@link LocationService#moveTo} request. * Handles a {@link LocationService#moveTo} request.
*/ */
public void moveTo (ClientObject caller, int arg1, LocationService.MoveListener arg2) void moveTo (ClientObject caller, int arg1, LocationService.MoveListener arg2)
throws InvocationException; throws InvocationException;
} }
@@ -21,7 +21,6 @@
package com.threerings.crowd.server; package com.threerings.crowd.server;
import java.util.Iterator;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
@@ -36,7 +36,6 @@ import com.google.inject.Injector;
import com.samskivert.jdbc.RepositoryUnit; import com.samskivert.jdbc.RepositoryUnit;
import com.samskivert.jdbc.WriteOnlyUnit; import com.samskivert.jdbc.WriteOnlyUnit;
import com.samskivert.jdbc.depot.PersistenceContext;
import com.samskivert.util.ArrayIntSet; import com.samskivert.util.ArrayIntSet;
import com.samskivert.util.ChainedResultListener; import com.samskivert.util.ChainedResultListener;
import com.samskivert.util.Interval; import com.samskivert.util.Interval;
@@ -33,10 +33,10 @@ public interface PeerProvider extends InvocationProvider
/** /**
* Handles a {@link PeerService#invokeAction} request. * Handles a {@link PeerService#invokeAction} request.
*/ */
public void invokeAction (ClientObject caller, byte[] arg1); void invokeAction (ClientObject caller, byte[] arg1);
/** /**
* Handles a {@link PeerService#ratifyLockAction} request. * Handles a {@link PeerService#ratifyLockAction} request.
*/ */
public void ratifyLockAction (ClientObject caller, NodeObject.Lock arg1, boolean arg2); void ratifyLockAction (ClientObject caller, NodeObject.Lock arg1, boolean arg2);
} }
@@ -38,7 +38,6 @@ import com.samskivert.util.StringUtil;
import com.threerings.presents.client.InvocationDecoder; import com.threerings.presents.client.InvocationDecoder;
import com.threerings.presents.data.ClientObject; import com.threerings.presents.data.ClientObject;
import com.threerings.presents.net.Transport;
import com.threerings.presents.server.InvocationSender; import com.threerings.presents.server.InvocationSender;
/** /**
@@ -39,7 +39,6 @@ import com.threerings.presents.client.InvocationService;
import com.threerings.presents.data.ClientObject; import com.threerings.presents.data.ClientObject;
import com.threerings.presents.data.InvocationMarshaller; import com.threerings.presents.data.InvocationMarshaller;
import com.threerings.presents.dobj.InvocationResponseEvent; import com.threerings.presents.dobj.InvocationResponseEvent;
import com.threerings.presents.net.Transport;
import com.threerings.presents.server.InvocationDispatcher; import com.threerings.presents.server.InvocationDispatcher;
import com.threerings.presents.server.InvocationException; import com.threerings.presents.server.InvocationException;
import com.threerings.presents.server.InvocationProvider; import com.threerings.presents.server.InvocationProvider;
@@ -16,7 +16,7 @@ public interface ${name}Provider extends InvocationProvider
/** /**
* Handles a {@link ${name}Service#$m.method.name} request. * Handles a {@link ${name}Service#$m.method.name} request.
*/ */
public void $m.method.name (ClientObject caller#if ($m.hasArgs(true)), #end$m.getArgList(true))#if ($m.listenerArgs.size() > 0) void $m.method.name (ClientObject caller#if ($m.hasArgs(true)), #end$m.getArgList(true))#if ($m.listenerArgs.size() > 0)
throws InvocationException#end; throws InvocationException#end;
#end #end
@@ -145,4 +145,4 @@ public class DependencyGraph<T>
this.children = new ArrayList<DependencyNode<T>>(); this.children = new ArrayList<DependencyNode<T>>();
} }
} }
} }