|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Object | +--one.world.core.Component
The superclass of all components. Components implement services and export as well as import event handlers. Components are always instantiated within a specified environment and can be linked against components in the same environment as well as other environments.
Note that events passed between components cannot reference components.
| Inner Class Summary | |
static class |
Component.HandlerReference
The record for an exported handler that is linked to an imported event handler. |
class |
Component.Importer
The manager for imported event handlers. |
| Constructor Summary | |
Component(Environment env)
Create a new component. |
|
| Method Summary | |
protected EventHandler |
declareExported(ExportedDescriptor descriptor,
EventHandler handler)
Declare the specified exported event handler. |
protected Component.Importer |
declareImported(ImportedDescriptor descriptor)
Declare the specified imported event handler. |
boolean |
equals(Object o)
Determine whether this component equals the specified object. |
List |
eventHandlers()
Get a list of the names of the event handlers for this component. |
abstract ComponentDescriptor |
getDescriptor()
Get the component descriptor for this component. |
EventHandlerDescriptor |
getDescriptor(String name)
Get the event handler descriptor for the event handler with the specified name. |
Environment |
getEnvironment()
Get the environment for this component. |
List |
getLinkedHandlers(String name)
Get a list of event handlers currently linked to the imported event handler with the specified name. |
int |
getLinkedNumber(String name)
Get the number of event handlers currently linked to the imported event handler with the specified name. |
protected Timer |
getTimer()
Get the timer for this component's environment. |
boolean |
hasEventHandler(String name)
Determine whether this component has an event handler with the specified name. |
int |
hashCode()
Get a hash code for this component. |
boolean |
isFullyLinked()
Determine whether this component is fully linked. |
boolean |
isLinked(String name)
Determine whether the specified imported event handler is linked. |
boolean |
isSealed()
Determine whether this component is sealed. |
void |
link(String imported,
String exported,
Component component)
Link the specified event handler imported by this component with the specified event handler exported by the specified component. |
void |
link(String imported,
String exported,
Component component,
boolean forced)
Link the specified event handler imported by this component with the specified event handler exported by the specified component. |
protected void |
run(Runnable r)
Execute the specified runnable in a new thread. |
void |
seal()
Seal this component. |
protected Object |
unbox(Box box)
Unbox the specified box. |
protected void |
undeclare(String name)
Undeclare the event handler with the specified name. |
void |
unlink(String imported,
String exported,
Component component)
Unlink the specified event handler exported by the specified component from the event handler imported by this component. |
protected EventHandler |
wrap(EventHandler handler)
Wrap the specified event handler. |
| Methods inherited from class java.lang.Object |
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
public Component(Environment env)
env - The environment for this component.NullPointerException - Signals that env is null.IllegalArgumentException - Signals that the specified environment is
multi-threaded, even though components of this
class are not thread safe, or that the protection
domain for this component is not the environment's
protection domain.IllegalStateException - Signals that the specified environment is being
or has been destroyed, or that the system has
shut down.| Method Detail |
public final boolean equals(Object o)
equals in class Objectpublic final int hashCode()
hashCode in class Objectpublic abstract ComponentDescriptor getDescriptor()
public final Environment getEnvironment()
protected final Component.Importer declareImported(ImportedDescriptor descriptor)
Actual components, that is, concrete implementations of this class, use this method to declare an imported event handler. The specified descriptor must be a valid event handler descriptor and should be statically allocated within the actual component, yet not be visible outside that class.
While the returned event handler implements the queued event
handler interface, not all of the linked event handlers need to
be queued event handlers. If not all of the linked event handlers
are queued event handlers, invoking the
handleFirst() or handleForced() methods
results in an illegal state exception.
The returned event handler throws a NotLinkedException
on invocation of its event handling methods if this event handler
has not been linked against an exported event handler.
Furthermore, the returned event handler may also throw the following runtime exceptions on invocation of its event handling methods:
NoBufferSpaceException if the event is being sent
to an environment whose event queue is full.NotActiveException if the event is being sent to
an environment that is not currently active.IllegalStateException if the event is being
sent to an environment that has no loaded code (for example,
because it has been unloaded).descriptor - The descriptor for the imported event handler.NullPointerException - Signals that descriptor is
null.IllegalArgumentException - Signals that descriptor is
invalid or that this component already has
an event handler with the specified name.IllegalStateException - Signals that this method has been invoked
on a sealed component.undeclare(java.lang.String)
protected final EventHandler declareExported(ExportedDescriptor descriptor,
EventHandler handler)
Actual components, that is, concrete implementations of this class, use this method to declare an exported event handler. The specified descriptor must be a valid event handler descriptor and should be statically allocated within the actual component, yet not be visible outside that class.
descriptor - The descriptor for the exported event handler.handler - The actual exported event handler.handler.NullPointerException - Signals that descriptor or
handler is null.IllegalArgumentException - Signals that descriptor is
invalid or that this component already has
an event handler with the specified name.IllegalStateException - Signals that this method has been invoked on
a sealed component.undeclare(java.lang.String)protected final void undeclare(String name)
name - The name of the event handler to undeclare.NullPointerException - Signals that name is null.IllegalArgumentException - Signals that this component has no imported or
exported event handler with the specified name.IllegalStateException - Signals that this method has been invoked on a
sealed component.declareImported(one.world.core.ImportedDescriptor),
declareExported(one.world.core.ExportedDescriptor, one.world.core.EventHandler)public final List eventHandlers()
public final boolean hasEventHandler(String name)
true if this component has an event handler
with the specified name.public final EventHandlerDescriptor getDescriptor(String name)
name - The name of the event handler.NullPointerException - Signals that name is null.IllegalArgumentException - Signals that this component does not have
an event handler with the specified name.
public final void link(String imported,
String exported,
Component component)
imported - The name of the event handler imported by this
component.exported - The name of the event handler exported by
component.component - The component exporting event handler
exported.LinkingException - Signals that an event handler does not exist,
that an environment is not being linked
against a component within the same
environment, that an event handler is not
imported/exported when an exported/imported
event handler is required, that
imported has already been linked
and cannot be linked again, or that this
component is sealed.
public final void link(String imported,
String exported,
Component component,
boolean forced)
If the component exporting the exported event handler is in a
different concurrency domain than this component, all invocations
to the exported event handler must go through the animator for
the exported event handler's concurrency domain. If
forced is true, invocations to the
exported event handler always go through an animator, even if
both the imported and exported event handlers are in the same
concurrency domain.
Note that if either the imported event handler or the exported
event handler specify that they need to be forcibly linked,
invocations to the exported event handler will always go through
an animator, even if this method is invoked with
false for forced.
imported - The name of the event handler imported by this
component.exported - The name of the event handler exported by
component.component - The component exporting event handler
exported.forced - Flag to indicate whether the exported event
handler should forcibly be accessed through
the corresponding animator.LinkingException - Signals that an event handler does not exist,
that an environment is not being linked
against a component within the same
environment, that an event handler is not
imported/exported when an exported/imported
event handler is required, that
imported has already been linked
and cannot be linked again, or that this
component is sealed.EventHandlerDescriptor.linkForced
public final void unlink(String imported,
String exported,
Component component)
imported - The name of the event handler imported by this
component.exported - The name of the event handler exported by
component.component - The component exporting event handler
exported.LinkingException - Signals that an event handler does not exist,
that an event handler is not imported/exported
when an exported/imported event handler is
required, that imported has
not been linked against exported,
or that this component is sealed.public final boolean isSealed()
true if this component is sealed.seal()public final void seal()
LinkingException - Signals that this component is not fully linked.public final boolean isLinked(String name)
name - The name of the imported event handler.true if the imported event handler is
linked.IllegalArgumentException - Signals that this component does not have an
event handler with the specified name or that the
specified event handler is exported.public final boolean isFullyLinked()
true if this component is fully linked.public final int getLinkedNumber(String name)
name - The name of the imported event handler.NullPointerException - Signals that name is null.IllegalArgumentException - Signals that this component does not have an event
handler with the specified name or that the the
event handler with the specified name is exported.public final List getLinkedHandlers(String name)
name - The name of the imported event handler.NullPointerException - Signals that name is null.IllegalArgumentException - Signals that this component does not have an event
handler with the specified name or that the the
event handler with the specified name is exported.Component.HandlerReferenceprotected final EventHandler wrap(EventHandler handler)
handler - The event handler to be wrapped.protected final Timer getTimer()
protected final void run(Runnable r)
r - The runnable.NullPointerException - Signals that r is null.SecurityException - Signals that the caller does not have permission to
spawn new threads.
protected final Object unbox(Box box)
throws IOException,
ClassNotFoundException
box - The box to unbox.IOException - Signals an exceptional condition while deserializing
the embedded object.ClassNotFoundException - Signals that a class necessary for instantiating the
embedded object could not be found.
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||