Apache Tuscany SCA Kernel Sub-Project

org.apache.tuscany.spi.model
Class ComponentDefinition<I extends Implementation<?>>

java.lang.Object
  extended by org.apache.tuscany.spi.model.ModelObject
      extended by org.apache.tuscany.spi.model.ComponentDefinition<I>

public class ComponentDefinition<I extends Implementation<?>>
extends ModelObject

Represents a component.

A component is a configured instance of an implementation. The services provided and consumed and the available configuration properties are defined by the implementation (represented by its componentType).

Every component has a name which uniquely identifies it within the scope of the composite that contains it; the name must be different from the names of all other components, services and references immediately contained in the composite (directly or through an <include> element).

A component may define a PropertyValue that overrides the default value of a Property defined in the componentType.

It may also define a ReferenceTarget for a ReferenceDefinition defined in the componentType. The ReferenceTarget must resolve to another component or a reference in the enclosing composite.

Components may specify an initialization level that will determine the order in which it will be eagerly initialized relative to other components from the enclosing composite that are in the same scope. This can be used to define a startup sequence for components that are otherwise independent. Any initialization required to resolve references between components will override this initialization order.

Version:
$Rev: 430937 $ $Date: 2006-08-11 18:17:56 -0700 (Fri, 11 Aug 2006) $

Constructor Summary
ComponentDefinition(I implementation)
          Constructor specifying the implementation of this component.
ComponentDefinition(String name, I implementation)
          Constructor specifying the component's name and implementation.
 
Method Summary
 void add(PropertyValue<?> value)
          Add a property value configuration to this component.
 void add(ReferenceTarget target)
          Add a reference target configuration to this component.
 I getImplementation()
          Returns the Implementation of this component.
 Integer getInitLevel()
          Returns the initialization level of this component.
 String getName()
          Returns the name of this component.
 Map<String,PropertyValue<?>> getPropertyValues()
          Returns a live Map of property values configured by this component definition.
 Map<String,ReferenceTarget> getReferenceTargets()
          Returns a live Map of the targets configured by this component definition.
 void setInitLevel(Integer initLevel)
          Sets the initialization level of this component.
 void setName(String name)
          Sets the name of this component.
 
Methods inherited from class org.apache.tuscany.spi.model.ModelObject
getExtensions
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ComponentDefinition

public ComponentDefinition(String name,
                           I implementation)
Constructor specifying the component's name and implementation.

Parameters:
name - the name of this component
implementation - the implementation of this component

ComponentDefinition

public ComponentDefinition(I implementation)
Constructor specifying the implementation of this component.

Parameters:
implementation - the implementation of this component
Method Detail

getImplementation

public I getImplementation()
Returns the Implementation of this component.

Returns:
the implementation of this component

getName

public String getName()
Returns the name of this component.

Returns:
the name of this component

setName

public void setName(String name)
Sets the name of this component.

Parameters:
name - the name of this component

getInitLevel

public Integer getInitLevel()
Returns the initialization level of this component.

Returns:
the initialization level of this component

setInitLevel

public void setInitLevel(Integer initLevel)
Sets the initialization level of this component. If set to null then the level from the componentType is used. If set to zero or a negative value then the component will not be eagerly initialized.

Parameters:
initLevel - the initialization level of this component

getReferenceTargets

public Map<String,ReferenceTarget> getReferenceTargets()
Returns a live Map of the targets configured by this component definition.

Returns:
the reference targets configured by this component

add

public void add(ReferenceTarget target)
Add a reference target configuration to this component. Any existing configuration for the reference named in the target is replaced.

Parameters:
target - the target to add

getPropertyValues

public Map<String,PropertyValue<?>> getPropertyValues()
Returns a live Map of property values configured by this component definition.

Returns:
the property values configured by this component

add

public void add(PropertyValue<?> value)
Add a property value configuration to this component. Any existing configuration for the property names in the property value is replaced.

Parameters:
value - the property value to add

Apache Tuscany SCA Kernel Sub-Project

-