org.objectweb.kilim.model
Class RtComponent

java.lang.Object
  extended byorg.objectweb.kilim.model.RtComponentElement
      extended byorg.objectweb.kilim.model.RtComponent
All Implemented Interfaces:
Component, ComponentElement, ContainerElement, RuntimeElement, RuntimeSource

public class RtComponent
extends RtComponentElement
implements Component, RuntimeSource

Author:
horn

Field Summary
private  TemplateDescription containingTemplate
           
private  java.util.HashMap controllers
           
private  ComponentFactory factory
           
private  InstanciationMger instanciationMger
           
private  java.util.List interfaces
           
private  boolean isForkedComponent
           
private  boolean isInitialized
           
private  java.util.List nAryListeners
           
private  java.util.List plugTos
           
private  java.util.List slots
           
private  java.util.List subComponents
           
private  TemplateDescription template
           
 
Fields inherited from class org.objectweb.kilim.model.RtComponentElement
nbComponent, nbElement
 
Constructor Summary
RtComponent(Instance aInstance, Component aComponent, ComponentFactory aFactory)
          The public constructor for RtComponents.
 
Method Summary
 void addController(java.lang.String aName, java.lang.Object aController)
          This method is an extension introduced to ease the mapping with the FRACTAL model : a controller is a technical object internally used by the component (most controllers are used as instantiation managers or communication managers) according to its specific semantics.
 void addInterface(ComponentInterface aElement)
          adds a new interface in the component.
 void addInterfaceListener(RtCollectionPort aInterface)
          adds a new listener to the value source.
 void addPlugTo(ComponentSlot aSlot)
          This method is used to register slots in which the component is plugged to.
 void addSlot(ComponentSlot aSlot)
          adds a new slot to a component.
 void addSubComponent(Component aElement)
          adds a component as a subcomponent of the current component.
 boolean checkValue(java.util.Stack exclude)
          returns whether a value can be obtained without having to create new objects
 Component fork()
          creates a copy of the component as defined in the template.
 java.lang.Object getController(java.lang.String aName)
          This method is an extension introduced to ease the mapping with the FRACTAL model : a controller is a technical object internally used by the component (most controllers are used as instantiation managers or communication managers) according to its specific semantics.
 java.util.Iterator getControllers()
          This method is an extension introduced to ease the mapping with the FRACTAL model : a controller is a technical object internally used by the component (most controllers are used as instantiation managers or communication managers) according to its specific semantics.
 java.lang.Object getEventSourceValue()
          Method gets the EventSourceValue.
 Factory getFactory()
          returns the factory used to create the container.
 InstanciationMger getInstanciationMger()
          Method getInstanciationMger returns the instanciation manager to be used the component.
 InstanciationMger getInstanciationMgerFromConfiguration()
          sets the instanciation manager from the instanciation strategy defined in the class KilimConfiguration KilimConfiguration
 ComponentInterface getInterface(java.lang.String aName)
          returns an interface defined in the component
 java.util.Iterator getInterfaceListeners()
          returns as an interator the interface the interface listeners.
 java.util.Iterator getInterfaces()
          returns as an iterator the interfaces defined in the component.
 java.lang.String getLocalName()
          returns the local name of the component element.
 java.util.Iterator getPlugTos()
          returns as an iterator the slots the component is plugged into.
 ComponentSlot getSlot(java.lang.String aName)
          returns a slot from its local name.
 java.util.Iterator getSlots()
          returns as an iterator the slots declared in the component.
 Component getSubComponent(java.lang.String aName)
          returns a subcomponent from its local name This method is not recursive and only looks for direct sub component.
 java.util.Iterator getSubComponents()
          returns as an iterator the direct subcomponents (i.e.
 TemplateDescription getTemplate()
          returns the template describing the component.
 java.lang.Object getValue()
          Method getValue.
 boolean hasValue()
          returns whether the source has a value.
 boolean isComponent()
          returns true if the container is a component.
 boolean isEventSource()
          returns whether the source is an event source..
private  boolean isForkedComponent()
           
private  void isForkedComponent(boolean iFE)
           
 boolean isInitialized()
          returns true when the container is in the "initialized" state or not.
 boolean isSlot()
          returns true if the container is a slot.
 void plug(java.lang.String aName, Component aComponent)
          plugs a component in a slot defined in the current component.
 void release()
          releases a component by (1) removing it as a subcomponent of its containing component, (2) unpluging it from all slots it is plugged in, (3) removing its naming context from parent context and factory from parent factory.
 void removeController(java.lang.String aName)
          This method is an extension introduced to ease the mapping with the FRACTAL model : a controller is a technical object internally used by the component (most controllers are used as instantiation managers or communication managers) according to its specific semantics.
 void removeInterface(ComponentInterface aElement)
          removes the interface from a component.
 void removeInterfaceListener(RtCollectionPort aInterface)
          removes a listener from the value source.
 void removePlugTo(ComponentSlot aSlot)
          This method is used to unregister slots in which the component is plugged to.
 void removeSlot(java.lang.String aName)
          removes a slot from a component.
 void removeSubComponent(Component aElement)
          removes a component from the current component.
 void removeSubComponent(java.lang.String aName)
          removes the subcomponent from the current component.
 void setEventSourceValue(java.lang.Object aValue)
          sets the EventSourceValue.
 void setInitialized()
          sets the container in the"initialized" state.
 void setInstanciationMger(InstanciationMger aMger)
          sets the instanciation manager to be used for the component.
 void setTemplate(TemplateDescription aTemplate)
           
 java.lang.String toString()
           
 void unplug(java.lang.String aName, Component aComponent)
          unplugs a component from a slot defined in the current component.
 
Methods inherited from class org.objectweb.kilim.model.RtComponentElement
containsElement, getContainingComponent, getContainingElement, getElement, getElementDescription, getNbComponent, getNbElement, getQualifiedName, getTarget, getTemplateDefHierarchy, removeElement
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface org.objectweb.kilim.model.ComponentElement
getContainingComponent, getContainingElement, getElementDescription, getQualifiedName, getTemplateDefHierarchy
 
Methods inherited from interface org.objectweb.kilim.model.RuntimeSource
getTarget
 

Field Detail

isInitialized

private boolean isInitialized

isForkedComponent

private boolean isForkedComponent

factory

private ComponentFactory factory

template

private TemplateDescription template

containingTemplate

private TemplateDescription containingTemplate

instanciationMger

private InstanciationMger instanciationMger

subComponents

private java.util.List subComponents

interfaces

private java.util.List interfaces

slots

private java.util.List slots

plugTos

private java.util.List plugTos

nAryListeners

private java.util.List nAryListeners

controllers

private java.util.HashMap controllers
Constructor Detail

RtComponent

public RtComponent(Instance aInstance,
                   Component aComponent,
                   ComponentFactory aFactory)
            throws KilimException
The public constructor for RtComponents.

Parameters:
aInstance - : the template element corresponding to an instance
aComponent - : the containing component
aFactory - : the factoy used to create the component.
Throws:
KilimException - : generated when aInstance is null.
Method Detail

isComponent

public boolean isComponent()
Description copied from interface: ContainerElement
returns true if the container is a component.

Specified by:
isComponent in interface ContainerElement
Returns:
boolean
See Also:
ContainerElement.isComponent()

isSlot

public boolean isSlot()
Description copied from interface: ContainerElement
returns true if the container is a slot.

Specified by:
isSlot in interface ContainerElement
Returns:
boolean
See Also:
ContainerElement.isSlot()

getLocalName

public java.lang.String getLocalName()
Description copied from interface: ComponentElement
returns the local name of the component element.

Specified by:
getLocalName in interface ComponentElement
Returns:
String
See Also:
ComponentElement.getLocalName()

hasValue

public boolean hasValue()
                 throws KilimException
Description copied from interface: RuntimeSource
returns whether the source has a value. The behaviour depends on the nature of the source. It always returns false when invoked on tagged providers, for example.

Specified by:
hasValue in interface RuntimeSource
Returns:
boolean
Throws:
KilimException - :
See Also:
org.objectweb.kilim.model.RuntimeSource#checkValue()

checkValue

public boolean checkValue(java.util.Stack exclude)
                   throws KilimException
Description copied from interface: RuntimeSource
returns whether a value can be obtained without having to create new objects

Specified by:
checkValue in interface RuntimeSource
Parameters:
exclude - : the exclude stack contains objects beiing in the process of being built.
Returns:
boolean
Throws:
KilimException - :
See Also:
RuntimeSource.checkValue(Stack)

addInterface

public void addInterface(ComponentInterface aElement)
                  throws KilimException
adds a new interface in the component.

Specified by:
addInterface in interface ContainerElement
Parameters:
aElement - : the interface
Throws:
KilimException - : generated if aElement is null or if the local name of aElement clashes with the local name of another interface.

removeInterface

public void removeInterface(ComponentInterface aElement)
                     throws KilimException
removes the interface from a component.

Specified by:
removeInterface in interface ContainerElement
Parameters:
aElement - : the interface to be removed
Throws:
KilimException - : generated if aElement is null, if the component has no interface or if the interface is not defined in the component

getInterface

public ComponentInterface getInterface(java.lang.String aName)
returns an interface defined in the component

Specified by:
getInterface in interface ContainerElement
Parameters:
aName - : the local name of the interface.
Returns:
ComponentInterface

getInterfaces

public java.util.Iterator getInterfaces()
returns as an iterator the interfaces defined in the component.

Specified by:
getInterfaces in interface ContainerElement
Returns:
Iterator

getFactory

public Factory getFactory()
Description copied from interface: ContainerElement
returns the factory used to create the container. The result is a CompoonentFactory if the container is a component or a SlotFactory if the container is a slot.

Specified by:
getFactory in interface ContainerElement
Returns:
Factory
See Also:
ContainerElement.getFactory()

getTemplate

public TemplateDescription getTemplate()
Description copied from interface: Component
returns the template describing the component.

Specified by:
getTemplate in interface Component
Returns:
TemplateDescription
See Also:
Instance.getTemplate()

setTemplate

public void setTemplate(TemplateDescription aTemplate)
See Also:
org.objectweb.kilim.description.Instance#setTemplate(Template)

toString

public java.lang.String toString()
See Also:
Object.toString()

addSubComponent

public void addSubComponent(Component aElement)
                     throws KilimException
adds a component as a subcomponent of the current component.

Specified by:
addSubComponent in interface Component
Parameters:
aElement - : the subcomponent.
Throws:
KilimException - : generated if aElement is null or if it is already defined as a subcomponent in the component.

removeSubComponent

public void removeSubComponent(java.lang.String aName)
                        throws KilimException
removes the subcomponent from the current component.

Specified by:
removeSubComponent in interface Component
Parameters:
aName - : the name of the child component to be removed.
Throws:
KilimException - : generated if aName is null or is unknown (i.e. it is not a the name of a child component)

removeSubComponent

public void removeSubComponent(Component aElement)
                        throws KilimException
removes a component from the current component.

Specified by:
removeSubComponent in interface Component
Parameters:
aElement - : the component to be removed.
Throws:
KilimException - : generated if aElement is null, if the component does not contain any subcomponent, if aElement is not a subcomponent of the current component.

getSubComponent

public Component getSubComponent(java.lang.String aName)
returns a subcomponent from its local name This method is not recursive and only looks for direct sub component.

Specified by:
getSubComponent in interface Component
Parameters:
aName - : the local name of the subcomponent.
Returns:
Component

getSubComponents

public java.util.Iterator getSubComponents()
returns as an iterator the direct subcomponents (i.e. the sub component of the current component).

Specified by:
getSubComponents in interface Component
Returns:
Iterator

addSlot

public void addSlot(ComponentSlot aSlot)
             throws KilimException
adds a new slot to a component.

Parameters:
aSlot - : the slot to be added
Throws:
KilimException - : generated if aSlot is null.

removeSlot

public void removeSlot(java.lang.String aName)
                throws KilimException
removes a slot from a component.

Parameters:
aName - : the name of the slot to be removed.
Throws:
KilimException - : generated if aName is null, if the component does not contain slots or if it does not contain a slot whose name is aName

getSlot

public ComponentSlot getSlot(java.lang.String aName)
                      throws KilimException
returns a slot from its local name.

Specified by:
getSlot in interface Component
Parameters:
aName - : the local name of the slot.
Returns:
Slot
Throws:
KilimException - : generated if aName is null, if the component does not contain slots or if it does not contain a slot whose name is aName

getSlots

public java.util.Iterator getSlots()
returns as an iterator the slots declared in the component.

Specified by:
getSlots in interface Component
Returns:
Iterator

addPlugTo

public void addPlugTo(ComponentSlot aSlot)
               throws KilimException
This method is used to register slots in which the component is plugged to. This method is thus invoked internally by the plug method.

Parameters:
aSlot - : the slot to be register.
Throws:
KilimException - : generated if aSlot is null or if the component is already registered as a components' plugTo..

removePlugTo

public void removePlugTo(ComponentSlot aSlot)
                  throws KilimException
This method is used to unregister slots in which the component is plugged to. This method is thus invoked internally by the unplug method.

Parameters:
aSlot - : the slot to be removed.
Throws:
KilimException - : generated if aSlot is null or if the component is not plugged in aSlot.

getPlugTos

public java.util.Iterator getPlugTos()
Description copied from interface: Component
returns as an iterator the slots the component is plugged into. The type of each element is thus a subtype of ComponentSlot.

Specified by:
getPlugTos in interface Component
Returns:
Iterator: every member provided by the iterator implements the Component interface and more precisly is an instance of the RtComponent class.
See Also:
Component.getPlugTos()

plug

public void plug(java.lang.String aName,
                 Component aComponent)
          throws KilimException
plugs a component in a slot defined in the current component.

Specified by:
plug in interface Component
Parameters:
aName - : the local name of the slot.
aComponent - : the component to be plugged.
Throws:
KilimException - : generated if aName is null, if aName is not the local name of a slot defined in the component or if aComponent is null.

unplug

public void unplug(java.lang.String aName,
                   Component aComponent)
            throws KilimException
unplugs a component from a slot defined in the current component.

Specified by:
unplug in interface Component
Parameters:
aName - : the local name of the slot.
aComponent - : the component to be plugged.
Throws:
KilimException - : generated if aName is null, if aName is not the local name of a slot defined in the component or if aComponent is null.

getValue

public java.lang.Object getValue()
Description copied from interface: RuntimeSource
Method getValue.

Specified by:
getValue in interface RuntimeSource
Returns:
Object : the reference of the object provided by the source.
See Also:
org.objectweb.kilim.model.RuntimeSource#getValue(RuntimeContext)

setEventSourceValue

public void setEventSourceValue(java.lang.Object aValue)
                         throws KilimException
Description copied from interface: RuntimeSource
sets the EventSourceValue.

Specified by:
setEventSourceValue in interface RuntimeSource
Parameters:
aValue - :
Throws:
KilimException - : the exception is generated when the method is invoked on unbound references or on illegal elements.
See Also:
org.objectweb.kilim.model.RuntimeSource#setEventSource(Object)

getEventSourceValue

public java.lang.Object getEventSourceValue()
                                     throws KilimException
Description copied from interface: RuntimeSource
Method gets the EventSourceValue.

Specified by:
getEventSourceValue in interface RuntimeSource
Returns:
Object
Throws:
KilimException - : the exception is generated when the method is invoked on unbound references or on illegal elements.
See Also:
org.objectweb.kilim.model.RuntimeSource#getEventSource()

isEventSource

public boolean isEventSource()
Description copied from interface: RuntimeSource
returns whether the source is an event source..

Specified by:
isEventSource in interface RuntimeSource
Returns:
boolean : is true when the source is the current event source.
See Also:
RuntimeSource.isEventSource()

addInterfaceListener

public void addInterfaceListener(RtCollectionPort aInterface)
                          throws KilimException
Description copied from interface: RuntimeSource
adds a new listener to the value source.

Specified by:
addInterfaceListener in interface RuntimeSource
Parameters:
aInterface - : the collection port to be added to the list of listeners.
Throws:
KilimException - : the exception is generated when the method is invoked on unbound references or on illegal elements.
See Also:
org.objectweb.kilim.model.RuntimeSource#addInterfaceListener(MultipleValueInterface)

removeInterfaceListener

public void removeInterfaceListener(RtCollectionPort aInterface)
                             throws KilimException
Description copied from interface: RuntimeSource
removes a listener from the value source.

Specified by:
removeInterfaceListener in interface RuntimeSource
Parameters:
aInterface - : the collection port to be removed from the list of listeners.
Throws:
KilimException - : the exception is generated when the method is invoked on unbound references or on illegal elements.
See Also:
org.objectweb.kilim.model.RuntimeSource#removeInterfaceListener(MultipleValueInterface)

getInterfaceListeners

public java.util.Iterator getInterfaceListeners()
returns as an interator the interface the interface listeners.

Returns:
Iterator

fork

public Component fork()
               throws KilimException
creates a copy of the component as defined in the template. The method forks does not account for any operation performed at runtime (late binding, instanciation, ....).

Specified by:
fork in interface Component
Returns:
Component
Throws:
KilimException - : generated when invoked on a component having no factory (should not be a KilimException but an InternalException FHO !!!)

isInitialized

public boolean isInitialized()
Description copied from interface: ContainerElement
returns true when the container is in the "initialized" state or not.

Specified by:
isInitialized in interface ContainerElement
Returns:
boolean
See Also:
ContainerElement.isInitialized()

setInitialized

public void setInitialized()
Description copied from interface: ContainerElement
sets the container in the"initialized" state.

Specified by:
setInitialized in interface ContainerElement
See Also:
org.objectweb.kilim.model.Component#setInitialized(boolean)

isForkedComponent

private boolean isForkedComponent()

isForkedComponent

private void isForkedComponent(boolean iFE)

getInstanciationMgerFromConfiguration

public InstanciationMger getInstanciationMgerFromConfiguration()
                                                        throws KilimException
Description copied from interface: Component
sets the instanciation manager from the instanciation strategy defined in the class KilimConfiguration KilimConfiguration

Specified by:
getInstanciationMgerFromConfiguration in interface Component
Returns:
InstanciationMgerI
Throws:
KilimException - :
See Also:
Component.getInstanciationMgerFromConfiguration()

getInstanciationMger

public InstanciationMger getInstanciationMger()
Description copied from interface: Component
Method getInstanciationMger returns the instanciation manager to be used the component.

Specified by:
getInstanciationMger in interface Component
Returns:
InstanciationMger
See Also:
Component.getInstanciationMger()

setInstanciationMger

public void setInstanciationMger(InstanciationMger aMger)
                          throws KilimException
Description copied from interface: Component
sets the instanciation manager to be used for the component. It overrides the manager defined in the instanciation strategy.

Specified by:
setInstanciationMger in interface Component
Parameters:
aMger - : the instanciation manager to be used
Throws:
KilimException - :
See Also:
Component.setInstanciationMger(InstanciationMger)

release

public void release()
             throws KilimException
Description copied from interface: Component
releases a component by (1) removing it as a subcomponent of its containing component, (2) unpluging it from all slots it is plugged in, (3) removing its naming context from parent context and factory from parent factory. This method however does not unbind DIRECTLY bound ports (i.e. bound through a bindValue or a bindProvider method).

Specified by:
release in interface Component
Throws:
KilimException - :
See Also:
Component.release()

addController

public void addController(java.lang.String aName,
                          java.lang.Object aController)
                   throws KilimException
This method is an extension introduced to ease the mapping with the FRACTAL model : a controller is a technical object internally used by the component (most controllers are used as instantiation managers or communication managers) according to its specific semantics. Controllers are thus just stored in a table contained in the kilim component object. This method registers a new controller in the component.

Specified by:
addController in interface Component
Parameters:
aName - : the local name of the controller.
aController - : the controller.
Throws:
KilimException - : generated if aName or aController is null.

removeController

public void removeController(java.lang.String aName)
                      throws KilimException
This method is an extension introduced to ease the mapping with the FRACTAL model : a controller is a technical object internally used by the component (most controllers are used as instantiation managers or communication managers) according to its specific semantics. Controllers are thus just stored in a table contained in the kilim component object. This method removes a previously registered controller.

Specified by:
removeController in interface Component
Parameters:
aName - : the local name of the controller.
Throws:
KilimException - : generated if aName is null or if the controller is not defined in the component.

getController

public java.lang.Object getController(java.lang.String aName)
                               throws KilimException
This method is an extension introduced to ease the mapping with the FRACTAL model : a controller is a technical object internally used by the component (most controllers are used as instantiation managers or communication managers) according to its specific semantics. Controllers are thus just stored in a table contained in the kilim component object. This method returns the controller identified by its name.

Specified by:
getController in interface Component
Parameters:
aName - : the name of the controller
Returns:
Object
Throws:
KilimException - : generated if aName is null or if the controller is not defined in the component.

getControllers

public java.util.Iterator getControllers()
This method is an extension introduced to ease the mapping with the FRACTAL model : a controller is a technical object internally used by the component (most controllers are used as instantiation managers or communication managers) according to its specific semantics. Controllers are thus just stored in a table contained in the kilim component object. This method returns as an iterator the controllers defined in the component.

Specified by:
getControllers in interface Component
Returns:
Iterator