@MXBean public interface ISharedComponent extends IComponent
IComponent
. But there are times
when is feasible that more agents shares the same instance of one component. That means such component must behave
differently in terms of starting/stopping itself when it comes to lifecycle management of the component. Thus ISharedComponent
was created.
Every implementor of ISharedComponent
must be prepared to be used by multiple agent instances. That is, it must be carefully designed
to be thread-safe. Moreover it should run if any of its users (agents) is running. That is the component must start together with
the start of the first user-agent and stop itself with the stop of the last user-agent (i.e., when the last running agent is going to be
stopped).
Again, the component itself does not need to know anything apart the ILifecycleBus
the user-agent is using, therefore there is only
a single simple method ISharedComponent#addLifecycleBus(ILifecycleBus)
that informs the ISharedComponent
that is has become
used by another agent.
Modifier and Type | Method and Description |
---|---|
void |
addComponentBus(IAgentId agentId,
ILifecycleBus bus,
ComponentDependencies dependencies)
Informs the component that it is part of another
ILifecycleBus , i.e., it has become used by new agent with 'agentId'. |
void |
removeComponentBus(IAgentId agentId,
ILifecycleBus bus)
Informs the component that it ceased to be the part of the
ILifecycleBus , i.e., it has stopped to be used by agent with 'agentId'. |
getComponentId
void addComponentBus(IAgentId agentId, ILifecycleBus bus, ComponentDependencies dependencies)
ILifecycleBus
, i.e., it has become used by new agent with 'agentId'.
The component is obliged to register to that bus a watch for the lifecycle state of various components inside the bus.
agentId
- bus
- void removeComponentBus(IAgentId agentId, ILifecycleBus bus)
ILifecycleBus
, i.e., it has stopped to be used by agent with 'agentId'.agentId
- bus
- Copyright © 2012 AMIS research group, Faculty of Mathematics and Physics, Charles University in Prague, Czech Republic. All Rights Reserved.