|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
public interface Agent
The Agent is a controller for actors. The agent is responsible for creating new actors,
and it will coordinate the execution of messages. It also provides a number of helper methods
for message implementations.
In order to acquire an Agent, you must create an instance of an implementation. Currently the
only implementation is DefaultAgent.
| Method Summary | ||
|---|---|---|
void |
awaitAll(AsyncResult... asyncResults)
Waits until all given AsyncResults are available. |
|
void |
awaitAllUntilError(AsyncResult... asyncResults)
Waits until all given AsyncResults are available, and throws the WrappedException of the first AsyncResult that failed, if one failed. |
|
AsyncResult |
awaitAny(AsyncResult... asyncResults)
Waits until one of the given AsyncResults is available. |
|
|
create(Class<T> actorOrBeanClass)
Creates a new instance of the given Bean or Actor. |
|
|
create(Class<T> actorOrBeanClass,
Props props)
Creates a new instance of the given Bean or Actor and sets its properties. |
|
void |
shutdown()
Tries to shut down the agent with all its threads. |
|
| Method Detail |
|---|
<T> T create(Class<T> actorOrBeanClass)
Bean or Actor.
Create supports the following annotations:
T - the type of the class to createactorOrBeanClass - the class to create
WrappedException - if the object's constructor threw an exception
ConfigurationException - if the class is not configured correctly, or not a Bean
<T> T create(Class<T> actorOrBeanClass,
Props props)
Bean or Actor and sets its properties.
Create supports the following annotations:
The second argument allows specifying values for the instance's properties.
The value of the Props must be compatible with the class of the property. If the
property is a primitive (like int), specify the wrapper type (Number sub-classes,
for example Integer). create also supports type conversion for all numeric
type, as well as between Character and Integer.
For those properties that are not given, the method will take the defined
DefaultValue, if specified, or the type's default value (null for references,
0 for number primitives, false for boolean).
T - the type of the class to createactorOrBeanClass - the class to createprops - the values for the instance's properties. Null for no initial properties.
WrappedException - if the object's constructor threw an exception
ConfigurationException - if the class is not configured correctly, or not a Bean
IllegalArgumentException - if there was an error in the Props (unknown property,
value can not be converted) or the given class was nullvoid awaitAll(AsyncResult... asyncResults)
awaitAll can be invoked from all threads, including those that do not process a message.
asyncResults - the list of AsyncResult instances to wait for
IllegalArgumentException - if one of the arguments was null or the array was nullawaitAllUntilError(AsyncResult...),
awaitAny(AsyncResult...)void awaitAllUntilError(AsyncResult... asyncResults)
awaitAll can be invoked from all threads, including those that do not process a message.
asyncResults - the list of AsyncResult instances to wait for
IllegalArgumentException - if one of the arguments was null or the array was null
WrappedException - if one of the AsyncResults threw an exception, this
WrappedException contains the first one from the list.awaitAll(AsyncResult...)AsyncResult awaitAny(AsyncResult... asyncResults)
awaitAny can be invoked from all threads, including those that do not process a message.
asyncResults - the list of AsyncResult instances to wait for
IllegalArgumentException - if one of the arguments was nullawaitAll(AsyncResult...)void shutdown()
This call is useful if you want to terminate your Java application. Without it, the Agent's
non-daemon threads may keep the application from terminating. A safer alternative to
shutdown may be calling System.exit(int), as there is no guarantee
that shutdown can terminate all threads.
A agent and its actors must not be used after calling this method. The behaviour would be undefined.
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||