|
Eidola home | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--org.eidola.kernel.event.EventBroadcaster | +--org.eidola.kernel.Container
The general structural unit of an Eidola program.
Every container has a structure, which is the set of properties
which affect its semantic meaning. Containers notify listeners of changes
to their structure by broadcasting StructureChanged
events,
and keep a modification count of the structure, accessible through
getStructureVersion()
.
Some information about a container, such as its contents
or errors
, is derived from the fundamental
structure, and lives inside a Container.Compilation
. Compilations update
in a lazy manner designed to make user interfaces as responsive as possible.
When some structure change -- in this container or another -- requires a compilation,
the container broadcasts a CompileRequired
event. A separate thread then
takes responsibility for building the new Compilation. For more information on the
compile process, see Compiler
.
Structure:
Note on synchronization:
Containers are concurrent-read-safe, meaning that you can safely call
any of the
However, you must always synchronize on a container when
calling any of the
It is safe to use the |
Inner Class Summary | |
class |
Container.Compilation
Generates and holds potentially computationally expensive derived structures, and checks the lazy rules of the semantics. |
Field Summary | |
static ContainerPart |
CONTENTS
Part of a container. |
static boolean |
debugCompile
|
Fields inherited from class org.eidola.kernel.event.EventBroadcaster |
debugEvents |
Constructor Summary | |
Container()
Creates a new empty container. |
Method Summary | |
void |
broadcastEvent(Event event)
Broadcasts an event concerning changes in this container, incrementing appropriate modification counts. |
void |
compile()
Attachs a new, up-to-date Container.Compilation to this container. |
abstract void |
dump(int indent)
Does a debug dump of this container to System.out. |
void |
finalize()
|
Container.Compilation |
getCompilation()
Returns the last completed compilation. |
long |
getCompileVersion()
Returns a modification count for all changes requiring compilations. |
abstract Namespace |
getNamespace()
Returns the namespace in which this container lives. |
long |
getStructureVersion()
Returns a modification count for this container's structure. |
protected void |
handleContentEvent(ContainerEvent event)
Propagates events from contents and other members. |
protected void |
handleSelfEvent(ContainerEvent event)
Propagates events from this container. |
protected abstract Container.Compilation |
makeNewCompilation()
Creates a new Container.Compilation of an appropriate type for this container. |
Methods inherited from class org.eidola.kernel.event.EventBroadcaster |
addListener, removeListener, updateBroadcasters |
Methods inherited from class java.lang.Object |
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
public static final ContainerPart CONTENTS
StructureChanged
public static boolean debugCompile
Constructor Detail |
public Container()
Method Detail |
public void finalize()
finalize
in class Object
public abstract Namespace getNamespace()
public long getCompileVersion()
CompileRequired
s
this object has broadcast.public long getStructureVersion()
StructureChanged
s
this object has broadcast.public void broadcastEvent(Event event)
StructureChanged
increments the structure version, and a CompileRequired
increments the compile version.broadcastEvent
in class EventBroadcaster
event
- The event to broadcast.protected void handleSelfEvent(ContainerEvent event)
protected void handleContentEvent(ContainerEvent event)
CompileRequired
event when it receives a
a StructureChanged
event signaling that a content's owner or name
has changed.public void compile() throws CompileAbortedException
Container.Compilation
to this container.
See Compiler
for information about the compile process.
Compilation only happens if the container has changed since it was last
compiled, so redundant calls to this method are entirely fine.
When compilation is done, this method broadcasts a CompileCompleted
event for each CompileRequired
event the container has broadcast
since the last compilation.
CompileAbortedException
- If the container's structure is modified
during compilation. When this happens, calls to getCompilation()
return the old compilation, even if some or all of the compile cycle finished.
The proper response to this exception is to call compile() again later --
which is what generally happens, since the same structure change that caused
the abort will spawn another compilation!protected abstract Container.Compilation makeNewCompilation()
Container.Compilation
of an appropriate type for this container.
This method only exists because Java does not use runtime types to resolve
inner class names; in other words, there are no virtual inner classes.
Under normal circumstances, you will not need to call this method directly;
use compile()
instead. It is a good idea to synchronize on the
container when calling this method.public Container.Compilation getCompilation()
public abstract void dump(int indent)
|
Eidola home | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |