io.sarl.sre.janus.capacities
Capacity InternalEventBusCapacity
All Superinterfaces:
Capacity
All Known Implementing Classes:
InternalEventBusSkill
capacity InternalEventBusCapacity
implements Capacity
Capacity that provides an event bus to notify the different components of an agent.

This capacity is provided by the SRE kernel, not SARL.
Maven Group Identifier:
io.sarl.sre.janus
Maven Artifact Identifier:
janus.kernel
Property Summary
Modifier and type Property and description
InformedEventListener associatedEventBusListener
Replies the event listener linked to the owner of this capacity.
EventBus eventBus
Replies the backend event bus.
Action Summary
Modifier and type Action and description
abstract void fireEvent(Event)
Fire the given event into the agent context, and do not wait for the termination of the event handlers.
abstract void fireEvent(Event,Object)
Fire the given event into the agent context, and do not wait for the termination of the event handlers.
abstract void fireEventAndWait(Event,boolean)
Fire the given event into the agent context, and wait for the execution of all the event handlers.
abstract void fireEventAndWait(Event,boolean,boolean,Object)
Fire the given event into the agent context, and wait for the execution of all the event handlers.
abstract boolean fireEventAndWaitWithEventGathering(Event,boolean,OutParameter<T>,Procedure0,BooleanSupplier)
Fire the given event into the agent context, and wait for the execution of all the event handlers.
abstract InformedEventListener getAssociatedEventBusListener
Replies the event listener linked to the owner of this capacity.
abstract EventBus getEventBus
Replies the backend event bus.
abstract T getEventBus(Class<T>)
Replies the backend event bus.
abstract ConcurrentCollection<T> getRegisteredEventBusListeners(Class<T>)
Replies the registered listeners.
abstract void registerEventBusListener(Object,[Function1<Param,Result>],[Procedure1<Param>])
Register the given object on the event bus for receiving any event.
abstract void unregisterEventBusListener(Class<T>,[Function1<Param,Result>])
Unregister the listeners of the given type on the event bus for receiving any event.
abstract void unregisterEventBusListener(Object,[Procedure1<Param>])
Unregister the given object on the event bus for receiving any event.
Property Details
associatedEventBusListener
val associatedEventBusListener : InformedEventListener
Replies the event listener linked to the owner of this capacity.

This property is an alias for the action: getAssociatedEventBusListener

Returns:
the event listener of the owner of this skill.
eventBus
val eventBus : EventBus
Replies the backend event bus.

This property is an alias for the action: getEventBus

Returns:
the event bus instance.
Action Details
fireEvent(Event)
def fireEvent(Event)
Fire the given event into the agent context, and do not wait for the termination of the event handlers.

This function does not set the event's source if it is not already set.

Any exception thrown by an event handler is catch by the associated thread.

This function considers the agent's state for determining of the event should be fired or not. In other words, the given event may be fired or buffered depending on the event buffering flag.
Parameters:
event - the event to fire.
fireEvent(Event,Object)
def fireEvent(Event,Object)
Fire the given event into the agent context, and do not wait for the termination of the event handlers.

This function does not set the event's source if it is not already set.

Any exception thrown by an event handler is catch by the associated thread.

This function considers the agent's state for determining of the event should be fired or not. In other words, the given event may be fired or buffered depending on the event buffering flag.
Parameters:
event - the event to fire.
listener - the sole receiver of the event. If null, all the listeners on the event bus will receive the event. If not null, only the given listener will receive the event.
Since:
0.12
fireEventAndWait(Event,boolean)
def fireEventAndWait(Event,boolean)
Fire the given event into the agent context, and wait for the execution of all the event handlers.

This function does not set the event's source if it is not already set.

All the exceptions thrown by the event handlers are gathered and fired into a single exception after all the event handlers have been executed or failed.

The events that are received during the execution of this function treated in the normal way, i.e. associated event handlers are run.

This function considers the agent's state for determining of the event should be fired or not. In other words, the given event may be fired or buffered depending on the event buffering flag.
Parameters:
event - the event to fire.
thrownExceptions - indicates if any exception, which occurs into the event handler should be thrown outside this function. If true, an exception is thrown outside and should be catch. If false, the exceptions are logging out to the agent's logger, and never thrown outside this function.
Since:
0.12
fireEventAndWait(Event,boolean,boolean,Object)
def fireEventAndWait(Event,boolean,boolean,Object)
Fire the given event into the agent context, and wait for the execution of all the event handlers.

This function does not set the event's source if it is not already set.

All the exceptions thrown by the event handlers are gathered and fired into a single exception after all the event handlers have been executed or failed.

The events that are received during the execution of this function treated in the normal way, i.e. associated event handlers are run.

This function considers the agent's state for determining of the event should be fired or not. In other words, the given event may be fired or buffered depending on the event buffering flag.
Parameters:
event - the event to fire.
thrownExceptions - indicates if any exception, which occurs into the event handler should be thrown outside this function. If true, an exception is thrown outside and should be catch. If false, the exceptions are logging out to the agent's logger, and never thrown outside this function.
forceEventHandlerExecution - indicates if the event handler execution must be forced even if the event gathering feature is activated. Give a true value with caution.
listener - the sole receiver of the event. If null, all the listeners on the event bus will receive the event. If not null, only the given listener will receive the event.
Since:
0.12
fireEventAndWaitWithEventGathering(Event,boolean,OutParameter<T>,Procedure0,BooleanSupplier)
def fireEventAndWaitWithEventGathering(Event,boolean,OutParameter<T>,Procedure0,BooleanSupplier) : boolean
Fire the given event into the agent context, and wait for the execution of all the event handlers.

This function does not set the event's source if it is not already set.

All the exceptions thrown by the event handlers are gathered and fired into a single exception after all the event handlers have been executed or failed.

The events that are received during the execution of this function are gathered and replied.

This function does not considered the agent's state for determining of the event should be fired. In other words, the given event is always fired, whatever the agent's state or if the event buffering was turned on.

The event buffering is turned off at the return of this function.
Parameters:
event - the event to fire.
thrownExceptions - indicates if any exception, which occurs into the event handler should be thrown outside this function. If true, an exception is thrown outside and should be catch. If false, the exceptions are logging out to the agent's logger, and never thrown outside this function.
bufferedEvents - the events that were received during the execution of this function. These events are not fired into the agent context yet. The pairs are composed by the event, and the optional listener that is supposed to receive the event.
beforeEventFiringHandler - that is invoked just before the firing of the event. If null, it is ignore.
beforeReturnHandler - this is invoked just before the function return and the event buffering is turn off.
Returns:
the value returned by beforeReturn or true if beforeReturn is null .
Since:
0.12
getAssociatedEventBusListener
def getAssociatedEventBusListener : InformedEventListener
Replies the event listener linked to the owner of this capacity.
Returns:
the event listener of the owner of this skill.
getEventBus
def getEventBus : EventBus
Replies the backend event bus.
Returns:
the event bus instance.
getEventBus(Class<T>)
def getEventBus(Class<T>) : T

with T extends EventBus

Replies the backend event bus.
Parameters:
type - the expected type of the event bus.
Returns:
the event bus instance.
Since:
0.10
getRegisteredEventBusListeners(Class<T>)
def getRegisteredEventBusListeners(Class<T>) : ConcurrentCollection<T>

with T

Replies the registered listeners.
Parameters:
<T> - the type of the listeners.
type - the type of the listeners.
Returns:
the registered listeners.
registerEventBusListener(Object,[Function1<Param,Result>],[Procedure1<Param>])
def registerEventBusListener(Object,[Function1<Param,Result>],[Procedure1<Param>])
Register the given object on the event bus for receiving any event.

If the filter is provided, it will be used for determining if the given behavior accepts a specific event. If the filter function replies true for a specific event as argument, the event is fired in the behavior context. If the filter function replies false, the event is not fired in the behavior context.
Parameters:
listener - the listener on the SARL events.
filter - the filter function.
callback - function which is invoked just after the first registration of the object. It could be null.
Since:
0.5
unregisterEventBusListener(Class<T>,[Function1<Param,Result>])
def unregisterEventBusListener(Class<T>,[Function1<Param,Result>])
Unregister the listeners of the given type on the event bus for receiving any event.
Parameters:
listenerType - the type of the listeners on the SARL events.
callback - function which is invoked just before the object is unregistered. The callback functions replies true if it should be called on the next removed object. If it replies false, it will be not called anymore.
Since:
0.7
unregisterEventBusListener(Object,[Procedure1<Param>])
def unregisterEventBusListener(Object,[Procedure1<Param>])
Unregister the given object on the event bus for receiving any event.
Parameters:
listener - the listener on the SARL events.
callback - function which is invoked just before the object is unregistered.
Since:
0.5