cz.cuni.amis.pogamut.base.component
Interface ISharedComponent

All Superinterfaces:
IComponent
All Known Subinterfaces:
ISharedComponentController<COMPONENT>, ISharedWorldChangeEventInput, ISharedWorldView
All Known Implementing Classes:
AbstractSharedWorldView, BatchAwareSharedWorldView, EventDrivenSharedWorldView, SharedComponentController, UT2004BatchAwareSharedWorldView

@MXBean
public interface ISharedComponent
extends IComponent

Every agent consists of components. Typically the component are ordinary 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.


Method Summary
 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'.
 
Methods inherited from interface cz.cuni.amis.pogamut.base.component.IComponent
getComponentId
 

Method Detail

addComponentBus

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'.

The component is obliged to register to that bus a watch for the lifecycle state of various components inside the bus.

Parameters:
agentId -
bus -

removeComponentBus

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'.

Parameters:
agentId -
bus -