|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectfulmine.AbstractLifeCycle
fulmine.model.component.AbstractComponent
fulmine.model.container.AbstractContainer
public abstract class AbstractContainer
The base class for containers.
This implementation is thread safe. The the add(IField) and
remove(IField) methods perform copy-on-write operations. The
Collection for the fields uses the 'cheap
read-write lock'
This implementation can read and write itself from and to a wire frame.
However, when writing, it writes a complete image of itself (i.e. all its
internal IField objects are written, regardless of any changes that
have occurred). Sub-classes may override this to in a more efficient
mechanism that only writes changed internal fields (deltas).
| Nested Class Summary | |
|---|---|
protected class |
AbstractContainer.ReaderTask
The reader task executed by the FieldReader when reading messages |
| Nested classes/interfaces inherited from interface fulmine.model.container.IContainer |
|---|
IContainer.DataState |
| Constructor Summary | |
|---|---|
AbstractContainer(String nativeContextIdentity,
String identity,
IType type,
IDomain domain,
IFrameworkContext hostContext,
boolean local)
Standard constructor. |
|
| Method Summary | ||
|---|---|---|
void |
add(IField field)
Add the field to this container. |
|
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 void |
beforeAdd(IField field)
Called before the field is added. |
|
protected void |
beforeRemove(IField field)
Called before the field is removed. |
|
void |
beginFrame(IEventFrameExecution frame)
An event frame life-cycle control method to start an event frame. |
|
Object |
clone()
Clone this. |
|
boolean |
contains(String key)
Determines if there is an IField instance with an identity equal
to the key argument. |
|
protected void |
doCommitEvents()
Perform the operation to commit all events |
|
protected void |
doComponentDestroy()
The destroy method that is invoked on a non-cloned version of this. |
|
protected void |
doPostAddListener(IEventListener listener)
Hook to allow sub-classes to perform any post processing after an IEventListener has been added via
AbstractComponent.addListener(IEventListener) |
|
protected void |
doPostRemoveListener(IEventListener listener)
Hook to allow sub-classes to perform any post processing after an IEventListener has been removed via
AbstractComponent.removeListener(IEventListener) |
|
protected boolean |
doReadState(IOperationScope scope,
byte[] buffer,
int start,
int numberOfBytes)
Update the component state from the wire format state in the buffer. |
|
protected void |
doStart()
Overridden in subclasses to perform custom logic on activation. |
|
protected void |
doStateChangeOp(IContainer.DataState oldState)
Perform the operation when the dataState changes. |
|
protected boolean |
doWriteState(IOperationScope scope,
IWireIdentity wireId,
byte[][] headerBuffer,
int[] headerBufferPosition,
byte[][] dataBuffer,
int[] dataBufferPosition,
boolean completeState)
Write the component state in its wire form to the buffer. |
|
void |
endFrame()
An event frame life-cycle control method to commit all events within an event frame. |
|
boolean |
equals(Object obj)
|
|
void |
flushFrame()
A convenience method to perform the event frame life-cycle methods at once. |
|
|
get(String identity)
Find the field in the container with the identity equal to the string argument. |
|
BooleanField |
getBooleanField(String identity)
Get the BooleanField identified by the identity |
|
String[] |
getComponentIdentities()
Get all the identities of the fields in this container. |
|
IFrameworkContext |
getContext()
Get the host context for the container instance. |
|
IContainer.DataState |
getDataState()
Get the container's data state. |
|
protected IContainerDefinitionField |
getDefinition()
Get the definition for this container. |
|
DoubleField |
getDoubleField(String identity)
Get the DoubleField identified by the identity |
|
protected Map<String,IField> |
getFields()
|
|
protected Collection<IField> |
getFieldsToWrite(boolean completeState)
Get the fields to write to a frame. |
|
FloatField |
getFloatField(String identity)
Get the FloatField identified by the identity |
|
protected ThreadLocal<IEventFrameExecution> |
getFrameIdentifier()
|
|
IntegerField |
getIntegerField(String identity)
Get the IntegerField identified by the identity |
|
protected AsyncLog |
getLog()
Get the log to use for the object hierarchy |
|
LongField |
getLongField(String identity)
Get the LongField identified by the identity |
|
String |
getNativeContextIdentity()
Get the identity of the context this container is native to; this is its local context identity. |
|
int |
getRemoteSubscriptionCount()
Get the number of remote subscriptions this. |
|
StringField |
getStringField(String identity)
Get the StringField identified by the identity |
|
int |
hashCode()
|
|
boolean |
isDynamic()
Identify if the container is dynamic or static. |
|
boolean |
isEmpty()
Determines if this container empty. |
|
protected boolean |
isEventFrameThread()
Is the executing thread the event frame thread. |
|
boolean |
isFrameActive()
Identifies if an event frame is currently active. |
|
boolean |
isLocal()
Is the container local to the host context returned by IContainer.getContext() |
|
boolean |
isRemote()
|
|
protected void |
lockFrame()
Lock the event frame. |
|
protected void |
logNotTheEventFrameThread()
Logs an exception and the current event frame thread. |
|
int |
markForRemoteSubscription()
Mark this for remote subscription. |
|
protected AbstractContainer.ReaderTask |
newReaderTask()
Get the reader task to use during the doReadState(IOperationScope, byte[], int, int) method. |
|
|
remove(T field)
Remove the field from this container. |
|
void |
setState(IContainer.DataState stateCode)
Set the container state. |
|
int |
size()
Determine the number of IField instances held in this container |
|
String |
toDetailedString()
Provides a formatted string describing this object in detail. |
|
String |
toString()
|
|
int |
unmarkForRemoteSubscription()
Unmark this from remote subscriptions. |
|
| Methods inherited from class fulmine.model.component.AbstractComponent |
|---|
addEvent, 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 |
|---|
addEvent, 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 |
| Methods inherited from interface fulmine.event.IEventFrame |
|---|
addEvent |
| Constructor Detail |
|---|
public AbstractContainer(String nativeContextIdentity,
String identity,
IType type,
IDomain domain,
IFrameworkContext hostContext,
boolean local)
LIVE. If a EventThread is constructing this then the container
is a remote container.
nativeContextIdentity - the name of the context this container is native to - the name
of its local contextidentity - the identity of the containertype - the type of the containerdomain - the domain for the containerhostContext - the context hosting this container instancelocal - true the container is local to this contextContainerFactory| Method Detail |
|---|
protected AsyncLog getLog()
AbstractLifeCycle
getLog in class AbstractComponentprotected final void doStart()
AbstractLifeCycleRuntimeException or subclass
thereof. When this method is called, the AbstractLifeCycle.isActive() method will
return true.
doStart in class AbstractComponentprotected void doComponentDestroy()
AbstractComponent
doComponentDestroy in class AbstractComponentpublic final boolean isRemote()
public final IFrameworkContext getContext()
IContainer
getContext in interface IContainerIFrameworkContext hosting this instanceIContainer.isLocal(),
IContainer.getNativeContextIdentity()public final String getNativeContextIdentity()
IContainerIContainer.getContext(). If this
container is a remote container, this will return the remote context
identity.
Note: this is more for informational purposes, the true mechanism for
determining whether a container is local to the host context or not is by
checking IContainer.isLocal().
getNativeContextIdentity in interface IContainerIContainer.isLocal(),
IContainer.getContext()public final void add(IField field)
IContainerIEvent events raised by the
field will reach this container via its IEventFrame interface.
add in interface IContainerfield - the field to add to this container.protected void beforeAdd(IField field)
field - the field to addprotected void afterAdd(IField field)
field - the field to addpublic final <T extends IField> T remove(T field)
IContainer
remove in interface IContainerfield - the field to remove from this container.
protected void beforeRemove(IField field)
field - the field to remove
protected void afterRemove(IField field,
IField removed)
field - the field to removeremoved - the field that has been removed - if null then
the field was not removed (possibly because it was not in the
fields)public final boolean isEmpty()
IContainer
isEmpty in interface IContainertrue if there are no fields in this container.public final boolean contains(String key)
IContainerIField instance with an identity equal
to the key argument.
contains in interface IContainerkey - the identity of a field to find in this container.
true if there is an IField with this
identity held in this.public final int size()
IContainerIField instances held in this container
size in interface IContainerIField instances held in this containerpublic final <T extends IField> T get(String identity)
IContainer
get in interface IContaineridentity - the string identity of the field to find
null if not found.public final String[] getComponentIdentities()
IContainer
getComponentIdentities in interface IContainerIField
objects in this container.public final void beginFrame(IEventFrameExecution frame)
IEventFrameIEventFrame.endFrame() and #end().
If an event frame is already active in another thread, this method blocks until the other frame ends.
beginFrame in interface IEventFrameframe - the frame identifierpublic final void endFrame()
IEventFrameIEventFrame.beginFrame(IEventFrameExecution)).
endFrame in interface IEventFramepublic final void flushFrame()
IEventFrame
flushFrame in interface IEventFramepublic final boolean isFrameActive()
IEventFrame
isFrameActive in interface IEventFrametrue if an event frame is currently active (started)public final void setState(IContainer.DataState stateCode)
IContainer
setState in interface IContainerstateCode - the new business state.for a description of the states.protected void doStateChangeOp(IContainer.DataState oldState)
dataState changes.
oldState - the old statepublic final IContainer.DataState getDataState()
IContainer
getDataState in interface IContainerDataState for a description of the states.public boolean isDynamic()
IContainerIField population. Dynamic containers have a
variable (mutable) population.
isDynamic in interface IContainertrue if the definition is dynamicpublic final boolean isLocal()
IContainerIContainer.getContext()
isLocal in interface IContainertrue if the container is localpublic int markForRemoteSubscription()
IRemoteSubscribable
markForRemoteSubscription in interface IRemoteSubscribablepublic int unmarkForRemoteSubscription()
IRemoteSubscribable
unmarkForRemoteSubscription in interface IRemoteSubscribablepublic int getRemoteSubscriptionCount()
IRemoteSubscribable
getRemoteSubscriptionCount in interface IRemoteSubscribablepublic BooleanField getBooleanField(String identity)
BooleanField identified by the identity
getBooleanField in interface IContaineridentity - the identity of the field to get
BooleanField for the identity
ClassCastException - if the field is not of this typepublic StringField getStringField(String identity)
StringField identified by the identity
getStringField in interface IContaineridentity - the identity of the field to get
StringField for the identity
ClassCastException - if the field is not of this typepublic IntegerField getIntegerField(String identity)
IntegerField identified by the identity
getIntegerField in interface IContaineridentity - the identity of the field to get
IntegerField for the identity
ClassCastException - if the field is not of this typepublic LongField getLongField(String identity)
LongField identified by the identity
getLongField in interface IContaineridentity - the identity of the field to get
LongField for the identity
ClassCastException - if the field is not of this typepublic FloatField getFloatField(String identity)
FloatField identified by the identity
getFloatField in interface IContaineridentity - the identity of the field to get
FloatField for the identity
ClassCastException - if the field is not of this typepublic DoubleField getDoubleField(String identity)
DoubleField identified by the identity
getDoubleField in interface IContaineridentity - the identity of the field to get
DoubleField for the identity
ClassCastException - if the field is not of this typeprotected final void doPostAddListener(IEventListener listener)
AbstractComponentIEventListener has been added via
AbstractComponent.addListener(IEventListener)
doPostAddListener in class AbstractComponentlistener - the listener that has been addedprotected final void doPostRemoveListener(IEventListener listener)
AbstractComponentIEventListener has been removed via
AbstractComponent.removeListener(IEventListener)
doPostRemoveListener in class AbstractComponentlistener - the listener that has been removedprotected final void lockFrame()
eventFrameThread to the
current thread. If there already is an event frame thread, this method
loops until the frame is unlocked.
unlockFrame()protected IContainerDefinitionField getDefinition()
IContainerDefinitionField that defines the
IField objects (fields) of this container.
protected boolean doReadState(IOperationScope scope,
byte[] buffer,
int start,
int numberOfBytes)
throws Exception
AbstractComponentAbstractComponent.readState(IOperationScope, byte[], int, int) method.
doReadState in class AbstractComponentExceptionIWireState.readState(IOperationScope, byte[], int, int)protected AbstractContainer.ReaderTask newReaderTask()
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.
AbstractContainer.ReaderTask to invoke for each field spec found during
the read state operation.
protected boolean doWriteState(IOperationScope scope,
IWireIdentity wireId,
byte[][] headerBuffer,
int[] headerBufferPosition,
byte[][] dataBuffer,
int[] dataBufferPosition,
boolean completeState)
throws Exception
AbstractComponentAbstractComponent.writeState(IOperationScope, IWireIdentity, byte[][], int[], byte[][], int[], boolean)
method.
doWriteState in class AbstractComponentExceptionIWireState.writeState(IOperationScope, IWireIdentity, byte[][],
int[], byte[][], int[], boolean),
for a discussion of the byte[][] usageprotected Collection<IField> getFieldsToWrite(boolean completeState)
#changedFields field prior to being written to a frame.
completeState -
protected final boolean isEventFrameThread()
true if the executing thread is the event frame
thread.protected void logNotTheEventFrameThread()
public String toDetailedString()
IDescriptorObject.toString()
method.
toDetailedString in interface IDescriptortoDetailedString in class AbstractComponentprotected ThreadLocal<IEventFrameExecution> getFrameIdentifier()
IEventFrameExecution
of the current event frame. This is bound to the thread executing
the event frame.protected Map<String,IField> getFields()
IField objects this container holds, indexed by their
String identity. Uses the 'cheap read-write lock'
public Object clone()
throws CloneNotSupportedException
IEvent
clone in interface IEventclone in class AbstractComponentCloneNotSupportedExceptionObject#clone)_public final String toString()
toString in class AbstractComponentpublic final int hashCode()
hashCode in class AbstractComponentpublic final boolean equals(Object obj)
equals in class AbstractComponentprotected void doCommitEvents()
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||