|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectcom.threerings.bureau.server.BureauRegistry
public class BureauRegistry
Abstracts the launching and termination of external processes (bureaus) that host instances of server-side code (agents).
| Nested Class Summary | |
|---|---|
protected static class |
BureauRegistry.AgentData
|
protected static class |
BureauRegistry.AgentState
|
protected static class |
BureauRegistry.Bureau
Models a bureau, including the process handle, all running agents and their states. |
static interface |
BureauRegistry.CommandGenerator
Defines how to generate a command to launch a bureau in a local process. |
protected static class |
BureauRegistry.FoundAgent
Models the results of searching for an agent. |
static interface |
BureauRegistry.Launcher
Defines how a bureau is launched. |
protected static class |
BureauRegistry.LauncherEntry
|
protected class |
BureauRegistry.LauncherUnit
Invoker unit to launch a bureau's process, then assign the result on the main thread. |
| Field Summary | |
|---|---|
protected Map<String,BureauRegistry.Bureau> |
_bureaus
|
protected Invoker |
_invoker
|
protected Map<String,BureauRegistry.LauncherEntry> |
_launchers
|
protected RootDObjectManager |
_omgr
|
| Constructor Summary | |
|---|---|
BureauRegistry(InvocationManager invmgr,
PresentsConnectionManager conmgr,
ClientManager clmgr)
Creates an uninitialized registry. |
|
| Method Summary | |
|---|---|
protected void |
agentCreated(ClientObject client,
int agentId)
Callback for when the bureau client acknowledges the creation of an agent. |
protected void |
agentCreationFailed(ClientObject client,
int agentId)
Callback for when the bureau client acknowledges the failure to create an agent. |
protected void |
agentDestroyed(ClientObject client,
int agentId)
Callback for when the bureau client acknowledges the destruction of an agent. |
protected void |
bureauError(ClientObject caller,
String message)
|
protected void |
bureauInitialized(ClientObject client,
String bureauId)
Callback for when the bureau client acknowledges starting up. |
String |
checkToken(BureauCredentials creds)
Check the credentials to make sure this is one of our bureaus. |
protected void |
clientDestroyed(BureauRegistry.Bureau bureau)
Callback for when a client is destroyed. |
void |
destroyAgent(AgentObject agent)
Destroys a previously started agent using the data in the given object. |
protected String |
generateToken(String bureauId)
Create a hard-to-guess token that the bureau can use to authenticate itself when it tries to log in. |
protected Class<? extends BureauClientResolver> |
getClientResolverClass()
Returns the class used to resolve bureau client data. |
Exception |
getLaunchError(AgentObject agentObj)
If this agent's bureau encountered an error on launch, return it. |
protected Class<? extends BureauSession> |
getSessionClass()
Returns the class used to handle bureau sessions. |
protected void |
handleLaunchError(BureauRegistry.Bureau bureau,
Exception error,
String cause)
Called when something goes wrong with launching a bureau. |
protected void |
launchTimeoutExpired(BureauRegistry.Bureau bureau)
Called by the launcher unit timeout time after launching. |
PresentsSession |
lookupClient(String bureauId)
Returns the active session for a bureau of the given id. |
protected BureauRegistry.FoundAgent |
resolve(ClientObject client,
int agentId,
String resolver)
Does lots of null checks and lookups and resolves the given information into FoundAgent. |
protected void |
sessionDidEnd(PresentsSession client,
String id)
|
protected void |
sessionDidStart(PresentsSession client,
String id)
|
void |
setCommandGenerator(String bureauType,
BureauRegistry.CommandGenerator cmdGenerator)
Registers a command generator for a given type. |
void |
setCommandGenerator(String bureauType,
BureauRegistry.CommandGenerator cmdGenerator,
int timeout)
Registers a command generator for a given type. |
void |
setLauncher(String bureauType,
BureauRegistry.Launcher launcher)
Registers a launcher for a given type. |
void |
setLauncher(String bureauType,
BureauRegistry.Launcher launcher,
int timeout)
Registers a launcher for a given type. |
void |
startAgent(AgentObject agent)
Starts a new agent using the data in the given object, creating a new bureau if necessary. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
protected Map<String,BureauRegistry.LauncherEntry> _launchers
protected Map<String,BureauRegistry.Bureau> _bureaus
@Inject protected RootDObjectManager _omgr
@Inject protected Invoker _invoker
| Constructor Detail |
|---|
@Inject
public BureauRegistry(InvocationManager invmgr,
PresentsConnectionManager conmgr,
ClientManager clmgr)
| Method Detail |
|---|
public String checkToken(BureauCredentials creds)
public void setCommandGenerator(String bureauType,
BureauRegistry.CommandGenerator cmdGenerator)
bureauType is used to determine the CommandGenerator
instance to call. The registry will wait indefinitely for the bureau to connect back.
bureauType - the type of bureau that will be launchedcmdGenerator - the generator to be used for bureaus of bureauType
public void setCommandGenerator(String bureauType,
BureauRegistry.CommandGenerator cmdGenerator,
int timeout)
bureauType is used to determine the CommandGenerator
instance to call. If the launched bureau does not connect within the given number of
milliseconds, it will be logged as an error and future attempts to launch the bureau
will try launching the command again.
bureauType - the type of bureau that will be launchedcmdGenerator - the generator to be used for bureaus of bureauTypetimeout - milliseconds to wait for the bureau or 0 to wait forever
public void setLauncher(String bureauType,
BureauRegistry.Launcher launcher)
bureauType is used to determine the Launcher
instance to call. The registry will wait indefinitely for the launched bureau
to connect back.
bureauType - the type of bureau that will be launchedlauncher - the launcher to be used for bureaus of bureauType
public void setLauncher(String bureauType,
BureauRegistry.Launcher launcher,
int timeout)
bureauType is used to determine the Launcher
instance to call. If the launched bureau does not connect within the given number of
milliseconds, it will be logged as an error and future attempts to launch the bureau
will invoke the launch method again.
bureauType - the type of bureau that will be launchedlauncher - the launcher to be used for bureaus of bureauTypetimeout - milliseconds to wait for the bureau or 0 to wait foreverpublic void startAgent(AgentObject agent)
public void destroyAgent(AgentObject agent)
public PresentsSession lookupClient(String bureauId)
public Exception getLaunchError(AgentObject agentObj)
protected void sessionDidStart(PresentsSession client,
String id)
protected void sessionDidEnd(PresentsSession client,
String id)
protected void bureauInitialized(ClientObject client,
String bureauId)
protected void bureauError(ClientObject caller,
String message)
protected void agentCreated(ClientObject client,
int agentId)
protected void agentCreationFailed(ClientObject client,
int agentId)
protected void agentDestroyed(ClientObject client,
int agentId)
protected void clientDestroyed(BureauRegistry.Bureau bureau)
protected BureauRegistry.FoundAgent resolve(ClientObject client,
int agentId,
String resolver)
protected String generateToken(String bureauId)
protected void launchTimeoutExpired(BureauRegistry.Bureau bureau)
bureau - bureau whose launch occurred
protected void handleLaunchError(BureauRegistry.Bureau bureau,
Exception error,
String cause)
protected Class<? extends BureauSession> getSessionClass()
protected Class<? extends BureauClientResolver> getClientResolverClass()
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||