fulmine.model.container
Class AbstractDynamicContainer

java.lang.Object
  extended by fulmine.AbstractLifeCycle
      extended by fulmine.model.component.AbstractComponent
          extended by fulmine.model.container.AbstractContainer
              extended by fulmine.model.container.AbstractEventProcessingContainer
                  extended by fulmine.model.container.AbstractDynamicContainer
All Implemented Interfaces:
IEvent, IEventFrame, IEventSource, IAddressable, IDescriptor, IDestroyable, ILifeCycle, IComponent, IContainer, IRemoteSubscribable, IWireState, Cloneable
Direct Known Subclasses:
Record

public abstract class AbstractDynamicContainer
extends AbstractEventProcessingContainer

Base class for dynamic containers.

This implementation is thread safe. A dynamic container is a container with a variable field population; fields can be added and removed arbitrarily during the container's life-cycle.

A dynamic container maintains a field that is the IContainerDefinitionField to describe the field population for the container. This definition is sent in the wire frame as the first field. This allows receiving context instances to correctly construct the field population of the dynamic container. This is a key difference between a static and dynamic container structure.

This raises the following events:

Author:
Ramon Servadei

Nested Class Summary
protected  class AbstractDynamicContainer.ReaderTask
          The reader task executed by the FieldReader when reading messages
 
Nested classes/interfaces inherited from interface fulmine.model.container.IContainer
IContainer.DataState
 
Field Summary
 
Fields inherited from class fulmine.model.container.AbstractEventProcessingContainer
events
 
Constructor Summary
AbstractDynamicContainer(String nativeContextIdentity, String identity, IType type, IDomain domain, IFrameworkContext hostContext, boolean local)
          Standard constructor.
 
Method Summary
protected  void afterAdd(IField field)
          Called after the field is added and the copy-on-write operation has completed.
protected  void afterRemove(IField field, IField removed)
          Called after the field is removed and the copy-on-write operation has completed.
protected  IContainerDefinitionField getDefinition()
          Get the definition for this container.
protected  Collection<IField> getFieldsToWrite(boolean completeState)
          Get the fields to write to a frame.
 boolean isDynamic()
          Identify if the container is dynamic or static.
protected  AbstractDynamicContainer.ReaderTask newReaderTask()
          Get the reader task to use during the AbstractContainer.doReadState(IOperationScope, byte[], int, int) method.
 
Methods inherited from class fulmine.model.container.AbstractEventProcessingContainer
addEvent, clone, doCommitEvents, doComponentDestroy, doStateChangeOp, getChangedFields, getLog
 
Methods inherited from class fulmine.model.container.AbstractContainer
add, beforeAdd, beforeRemove, beginFrame, contains, doPostAddListener, doPostRemoveListener, doReadState, doStart, doWriteState, endFrame, equals, flushFrame, get, getBooleanField, getComponentIdentities, getContext, getDataState, getDoubleField, getFields, getFloatField, getFrameIdentifier, getIntegerField, getLongField, getNativeContextIdentity, getRemoteSubscriptionCount, getStringField, hashCode, isEmpty, isEventFrameThread, isFrameActive, isLocal, isRemote, lockFrame, logNotTheEventFrameThread, markForRemoteSubscription, remove, setState, size, toDetailedString, toString, unmarkForRemoteSubscription
 
Methods inherited from class fulmine.model.component.AbstractComponent
addListener, checkClone, createIdentityString, doDestroy, getAddress, getAddressable, getDomain, getDrivingFrame, getEventSourceGroupId, getFrame, getIdentity, getIdentityString, getListeners, getSource, getTriggerEvent, getType, isClone, readState, removeListener, removeListeners, setDrivingFrame, setFrame, setTriggerEvent, toIdentityString, writeState
 
Methods inherited from class fulmine.AbstractLifeCycle
checkActive, destroy, finalize, isActive, start
 
Methods inherited from class java.lang.Object
getClass, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface fulmine.model.container.IContainer
destroy, getType, isClone, start
 
Methods inherited from interface fulmine.protocol.wire.IWireState
readState, writeState
 
Methods inherited from interface fulmine.event.IEventSource
addListener, getEventSourceGroupId, getListeners, removeListener, removeListeners
 
Methods inherited from interface fulmine.IDescriptor
toIdentityString
 
Methods inherited from interface fulmine.ILifeCycle
isActive
 
Methods inherited from interface fulmine.IAddressable
getAddress, getDomain, getIdentity
 
Methods inherited from interface fulmine.event.IEvent
getDrivingFrame, getFrame, getSource, getTriggerEvent, setTriggerEvent
 
Methods inherited from interface fulmine.IDescriptor
toIdentityString
 
Methods inherited from interface fulmine.IAddressable
getAddress, getDomain, getIdentity
 

Constructor Detail

AbstractDynamicContainer

public AbstractDynamicContainer(String nativeContextIdentity,
                                String identity,
                                IType type,
                                IDomain domain,
                                IFrameworkContext hostContext,
                                boolean local)
Standard constructor. A ContainerDefinitionField is constructed and added as a field of this. The constructor calls the AbstractLifeCycle.start() method.

Parameters:
nativeContextIdentity - the name of the context this container is native to - the name of its local context
identity - the identity of the container
type - the type of the container
domain - the domain for the container
hostContext - the context hosting this container instance
local - true the container is local to this context
Method Detail

afterAdd

protected final void afterAdd(IField field)
Description copied from class: AbstractContainer
Called after the field is added and the copy-on-write operation has completed. This is called whilst holding the monitor lock for adding/removing fields.

Overrides:
afterAdd in class AbstractEventProcessingContainer
Parameters:
field - the field to add

afterRemove

protected final void afterRemove(IField field,
                                 IField removed)
Description copied from class: AbstractContainer
Called after the field is removed and the copy-on-write operation has completed. This is called whilst holding the monitor lock for adding/removing fields.

Overrides:
afterRemove in class AbstractContainer
Parameters:
field - the field to remove
removed - the field that has been removed - if null then the field was not removed (possibly because it was not in the fields)

isDynamic

public final boolean isDynamic()
Description copied from interface: IContainer
Identify if the container is dynamic or static. Static container types have an immutable IField population. Dynamic containers have a variable (mutable) population.

Specified by:
isDynamic in interface IContainer
Overrides:
isDynamic in class AbstractContainer
Returns:
true if the definition is dynamic

getDefinition

protected final IContainerDefinitionField getDefinition()
Description copied from class: AbstractContainer
Get the definition for this container. This effectively provides the 'type' for the this container.

Overrides:
getDefinition in class AbstractContainer
Returns:
the IContainerDefinitionField that defines the IField objects (fields) of this container.

newReaderTask

protected final AbstractDynamicContainer.ReaderTask newReaderTask()
Description copied from class: AbstractContainer
Get the reader task to use during the AbstractContainer.doReadState(IOperationScope, byte[], int, int) method. The reader task is executed for each field spec found during the read state operation. The task implementation is responsible for constructing/reading the IField expressed in the field spec.

Overrides:
newReaderTask in class AbstractContainer
Returns:
the AbstractContainer.ReaderTask to invoke for each field spec found during the read state operation.

getFieldsToWrite

protected final Collection<IField> getFieldsToWrite(boolean completeState)
Description copied from class: AbstractContainer
Get the fields to write to a frame. This occurs whilst the event frame is locked. This method allows sub-classes to inspect and mutate the #changedFields field prior to being written to a frame.

Overrides:
getFieldsToWrite in class AbstractEventProcessingContainer
Returns:
the fields to write into a frame


Copyright © 2007-2009. All Rights Reserved.