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:
@@ -28,7 +28,7 @@ import com.threerings.bureau.util.BureauContext;
|
||||
import com.threerings.presents.dobj.DObjectManager;
|
||||
import com.samskivert.util.Config;
|
||||
|
||||
/**
|
||||
/**
|
||||
* Represents a client embedded in a bureau.
|
||||
*/
|
||||
public abstract class BureauClient extends Client
|
||||
@@ -53,7 +53,7 @@ public abstract class BureauClient extends Client
|
||||
|
||||
protected BureauContext createContext ()
|
||||
{
|
||||
return new BureauContext () {
|
||||
return new BureauContext() {
|
||||
public BureauDirector getBureauDirector () {
|
||||
return _director;
|
||||
}
|
||||
|
||||
@@ -51,7 +51,7 @@ public abstract class BureauDirector extends BasicDirector
|
||||
|
||||
log.info("Subscribing to object " + agentId);
|
||||
|
||||
SafeSubscriber<AgentObject> subscriber =
|
||||
SafeSubscriber<AgentObject> subscriber =
|
||||
new SafeSubscriber<AgentObject>(agentId, delegator);
|
||||
_subscribers.put(agentId, subscriber);
|
||||
subscriber.subscribe(_ctx.getDObjectManager());
|
||||
@@ -67,19 +67,16 @@ public abstract class BureauDirector extends BasicDirector
|
||||
|
||||
if (agent == null) {
|
||||
log.warning("Lost an agent, id " + agentId);
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
try {
|
||||
agent.stop();
|
||||
}
|
||||
catch (Throwable t) {
|
||||
} catch (Throwable t) {
|
||||
log.warning("Stopping an agent caused an exception", t);
|
||||
}
|
||||
SafeSubscriber<AgentObject> subscriber = _subscribers.remove(agentId);
|
||||
if (subscriber == null) {
|
||||
log.warning("Lost a subscriber for agent " + agent);
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
subscriber.unsubscribe(_ctx.getDObjectManager());
|
||||
}
|
||||
_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)
|
||||
{
|
||||
@@ -100,13 +98,12 @@ public abstract class BureauDirector extends BasicDirector
|
||||
agent = createAgent(agentObject);
|
||||
agent.init(agentObject);
|
||||
agent.start();
|
||||
}
|
||||
catch (Throwable t) {
|
||||
} catch (Throwable t) {
|
||||
log.warning("Could not create agent [obj=" + agentObject + "]", t);
|
||||
_bureauService.agentCreationFailed(_ctx.getClient(), oid);
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
_agents.put(oid, agent);
|
||||
_bureauService.agentCreated(_ctx.getClient(), oid);
|
||||
}
|
||||
@@ -127,9 +124,8 @@ public abstract class BureauDirector extends BasicDirector
|
||||
// Require the bureau services
|
||||
client.addServiceGroup(BureauCodes.BUREAU_GROUP);
|
||||
|
||||
// Set up our decoder so we can receive method calls
|
||||
// from the server
|
||||
BureauReceiver receiver = new BureauReceiver () {
|
||||
// Set up our decoder so we can receive method calls from the server
|
||||
BureauReceiver receiver = new BureauReceiver() {
|
||||
public void createAgent (int 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
|
||||
* <code>agentObject</code>'s type and/or properties to determine what kind of Agent to
|
||||
* 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
|
||||
* create.
|
||||
* @param agentObj the distributed and 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 BureauService _bureauService;
|
||||
protected IntMap<Agent> _agents = IntMaps.newHashIntMap();
|
||||
protected IntMap<SafeSubscriber<AgentObject>> _subscribers =
|
||||
protected IntMap<SafeSubscriber<AgentObject>> _subscribers =
|
||||
IntMaps.newHashIntMap();
|
||||
}
|
||||
|
||||
@@ -29,7 +29,7 @@ import com.threerings.presents.client.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 service that the agent has been created using {@link BureauService#agentCreated}.
|
||||
* @param client the client receiving the request
|
||||
@@ -38,11 +38,11 @@ public interface BureauReceiver extends InvocationReceiver
|
||||
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
|
||||
* the service that the agent has been created using {@link BureauService#agentDestroyed}.
|
||||
* @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
|
||||
*/
|
||||
void destroyAgent (int agentId);
|
||||
|
||||
@@ -24,7 +24,7 @@ package com.threerings.bureau.client;
|
||||
import com.threerings.presents.client.Client;
|
||||
import com.threerings.presents.client.InvocationService;
|
||||
|
||||
/**
|
||||
/**
|
||||
* Interface for the bureau to communicate with the server.
|
||||
*/
|
||||
public interface BureauService extends InvocationService
|
||||
|
||||
@@ -23,6 +23,9 @@ package com.threerings.bureau.data;
|
||||
|
||||
import com.threerings.presents.dobj.DObject;
|
||||
|
||||
/**
|
||||
* Contains information for configuring and communicating with an agent.
|
||||
*/
|
||||
public class AgentObject extends DObject
|
||||
{
|
||||
// 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. */
|
||||
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. */
|
||||
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). */
|
||||
public int clientOid;
|
||||
|
||||
|
||||
@@ -29,11 +29,11 @@ import com.threerings.util.Name;
|
||||
*/
|
||||
public class BureauCredentials extends Credentials
|
||||
{
|
||||
public static String PREFIX = "@@bureau:";
|
||||
public static String SUFFIX = "@@";
|
||||
public static final String PREFIX = "@@bureau:";
|
||||
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.
|
||||
*/
|
||||
public String sessionToken;
|
||||
|
||||
@@ -31,7 +31,7 @@ public class BureauAuthenticator extends ChainedAuthenticator
|
||||
|
||||
@Override // from Authenticator
|
||||
protected void processAuthentication (
|
||||
AuthingConnection conn,
|
||||
AuthingConnection conn,
|
||||
AuthResponse rsp)
|
||||
{
|
||||
AuthRequest req = conn.getAuthRequest();
|
||||
@@ -42,7 +42,7 @@ public class BureauAuthenticator extends ChainedAuthenticator
|
||||
rsp.getData().code = AuthResponseData.SUCCESS;
|
||||
|
||||
} else {
|
||||
log.warning("Received invalid bureau auth request [creds=" +
|
||||
log.warning("Received invalid bureau auth request [creds=" +
|
||||
creds + "], problem: " + problem);
|
||||
rsp.getData().code = AuthCodes.SERVER_ERROR;
|
||||
}
|
||||
|
||||
@@ -32,20 +32,20 @@ public interface BureauProvider extends InvocationProvider
|
||||
/**
|
||||
* 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.
|
||||
*/
|
||||
public void agentCreationFailed (ClientObject caller, int arg1);
|
||||
void agentCreationFailed (ClientObject caller, int arg1);
|
||||
|
||||
/**
|
||||
* 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.
|
||||
*/
|
||||
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
|
||||
{
|
||||
/**
|
||||
* 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
|
||||
* 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
|
||||
* with the assocated bureau type.
|
||||
*/
|
||||
public static interface Launcher
|
||||
@@ -168,7 +168,7 @@ public class BureauRegistry
|
||||
}
|
||||
|
||||
if (!bureau.token.equals(creds.sessionToken)) {
|
||||
return "Bureau " + creds.bureauId +
|
||||
return "Bureau " + creds.bureauId +
|
||||
" 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>
|
||||
*/
|
||||
public void setCommandGenerator (
|
||||
String bureauType,
|
||||
String bureauType,
|
||||
final CommandGenerator cmdGenerator)
|
||||
{
|
||||
setLauncher(bureauType, new Launcher () {
|
||||
public void launchBureau (String bureauId, String token)
|
||||
public void launchBureau (String bureauId, String token)
|
||||
throws IOException {
|
||||
ProcessBuilder builder = new ProcessBuilder(
|
||||
cmdGenerator.createCommand(bureauId, token));
|
||||
@@ -338,7 +338,7 @@ public class BureauRegistry
|
||||
}
|
||||
if (bureau.client != null) {
|
||||
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.client = client;
|
||||
@@ -353,7 +353,7 @@ public class BureauRegistry
|
||||
}
|
||||
if (bureau.client == null) {
|
||||
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.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.
|
||||
*/
|
||||
protected String generateToken (String bureauId)
|
||||
{
|
||||
String tokenSource = bureauId + "@" +
|
||||
String tokenSource = bureauId + "@" +
|
||||
System.currentTimeMillis() + "r" + Math.random();
|
||||
return StringUtil.md5hex(tokenSource);
|
||||
}
|
||||
@@ -581,7 +581,7 @@ public class BureauRegistry
|
||||
{
|
||||
LauncherUnit (Bureau bureau)
|
||||
{
|
||||
super("LauncherUnit for " + bureau + ": " +
|
||||
super("LauncherUnit for " + bureau + ": " +
|
||||
StringUtil.toString(bureau.launcher));
|
||||
_bureau = bureau;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user