Apache Tuscany SCA Kernel Sub-Project

org.apache.tuscany.spi.extension
Class CompositeComponentExtension

java.lang.Object
  extended by org.apache.tuscany.spi.AbstractLifecycle
      extended by org.apache.tuscany.spi.component.AbstractSCAObject
          extended by org.apache.tuscany.spi.extension.CompositeComponentExtension
All Implemented Interfaces:
EventListener, Component, CompositeComponent, SCAObject, EventPublisher, RuntimeEventListener, Lifecycle

public abstract class CompositeComponentExtension
extends AbstractSCAObject
implements CompositeComponent

An extension point for composite components, which new types may extend

Version:
$$Rev: 452225 $$ $$Date: 2006-10-02 14:32:18 -0700 (Mon, 02 Oct 2006) $$

Field Summary
protected  Map<Class,Service> autowireExternal
           
protected  Map<Class,SCAObject> autowireInternal
           
protected  Map<String,SCAObject> children
           
protected  Connector connector
           
protected  Map<String,Document> propertyValues
           
protected  List<Reference> references
           
protected  List<Service> services
           
protected  Map<Class,Service> systemAutowireExternal
           
protected  Map<Class,SCAObject> systemAutowireInternal
           
protected  Map<String,SCAObject> systemChildren
           
protected  List<Reference> systemReferences
           
protected  List<Service> systemServices
           
 
Fields inherited from class org.apache.tuscany.spi.component.AbstractSCAObject
listeners, parent, TRUE_FILTER
 
Fields inherited from class org.apache.tuscany.spi.AbstractLifecycle
lifecycleState
 
Fields inherited from interface org.apache.tuscany.spi.Lifecycle
CONFIG_ERROR, ERROR, INITIALIZED, INITIALIZING, RUNNING, STOPPED, STOPPING, UNINITIALIZED
 
Constructor Summary
protected CompositeComponentExtension(String name, CompositeComponent parent, Connector connector, Map<String,Document> propertyValues)
           
 
Method Summary
 void addInboundWire(InboundWire wire)
          Adds a target-side wire.
 void addOutboundWire(OutboundWire wire)
          Adds a source-side wire for the given reference.
 void addOutboundWires(Class<?> multiplicityClass, List<OutboundWire> wires)
          Adds a set of source-side multiplicity wires for the given reference.
 TargetInvoker createAsyncTargetInvoker(InboundWire wire, Operation operation)
          Callback to create a TargetInvoker which dispatches to a service offered by the component
 SCAObject getChild(String name)
          Returns the child associated with a given name
 List<SCAObject> getChildren()
          Returns the children contained by the composite
 InboundWire getInboundWire(String serviceName)
          Returns the target-side wire associated with the given service name
 Map<String,InboundWire> getInboundWires()
          Returns a map of inbound wires for a service.
 Map<String,List<OutboundWire>> getOutboundWires()
          Returns a map of source-side wires for references.
 Document getPropertyValue(String name)
          Returns the value of a Property of this composite.
 List<Reference> getReferences()
          Returns the references contained by the composite
 Scope getScope()
          Returns the artifact scope
 Service getService(String name)
          Returns the service associated with the given name
 Object getServiceInstance()
          Returns an instance associated with the default service
 Object getServiceInstance(String name)
          Returns a service associated with the given name
 List<Class<?>> getServiceInterfaces()
          Returns the service interfaces implemented by the component
 List<Service> getServices()
          Returns the services contained by the composite
 SCAObject getSystemChild(String name)
          Returns the system child associated with a given name
 List<SCAObject> getSystemChildren()
          Returns the system children contained by the composite
 List<Reference> getSystemReferences()
          Returns the system references contained by the composite
 Service getSystemService(String name)
          Returns the system service associated with the given name
 Object getSystemServiceInstance(String name)
          Returns a system service associated with the given name
 List<Service> getSystemServices()
          Returns the system services contained by the composite
<T> T
locateService(Class<T> serviceInterface, String name)
          Returns the service instance for associated with the child registered for the given name
<T> T
locateSystemService(Class<T> serviceInterface, String name)
          Returns the system service instance for associated with the child registered for the given name
 void onEvent(Event event)
           
 void prepare()
          Called to signal that the composite should perform and required steps prior to registration with its parent such as wiring of its children
 void register(SCAObject child)
          Registers a child of this composite.
protected  void registerAutowire(AtomicComponent component)
           
protected  void registerAutowire(CompositeComponent component)
           
protected  void registerAutowire(Reference reference)
           
protected  void registerAutowire(Service service)
           
protected  void registerAutowireExternal(Class<?> interfaze, Service service)
           
protected  void registerAutowireInternal(Class<?> interfaze, SCAObject object)
           
<S,I extends S>
void
registerJavaObject(String name, Class<S> service, I instance)
          Register a simple Java Object as a system component.
<T> T
resolveExternalInstance(Class<T> instanceInterface)
          Invoked by a parent component to return an autowire target in a child.
<T> T
resolveInstance(Class<T> instanceInterface)
          Invoked by child components to return an an autowire target.
<T> T
resolveSystemExternalInstance(Class<T> instanceInterface)
          Invoked by a parent component to return a system autowire target in a child.
<T> T
resolveSystemInstance(Class<T> instanceInterface)
          Invoked by system child components to return an an autowire target.
 
Methods inherited from class org.apache.tuscany.spi.component.AbstractSCAObject
addListener, addListener, getExtensions, getListeners, getName, getParent, isSystem, publish, removeListener, toString
 
Methods inherited from class org.apache.tuscany.spi.AbstractLifecycle
getLifecycleState, setLifecycleState, start, stop
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface org.apache.tuscany.spi.component.CompositeComponent
setScopeContainer
 
Methods inherited from interface org.apache.tuscany.spi.component.Component
createTargetInvoker
 
Methods inherited from interface org.apache.tuscany.spi.component.SCAObject
getExtensions, getName, getParent, isSystem
 
Methods inherited from interface org.apache.tuscany.spi.event.EventPublisher
addListener, addListener, publish, removeListener
 
Methods inherited from interface org.apache.tuscany.spi.Lifecycle
getLifecycleState, start, stop
 

Field Detail

children

protected final Map<String,SCAObject> children

services

protected final List<Service> services

references

protected final List<Reference> references

propertyValues

protected final Map<String,Document> propertyValues

connector

protected final Connector connector

systemChildren

protected final Map<String,SCAObject> systemChildren

systemServices

protected final List<Service> systemServices

systemReferences

protected final List<Reference> systemReferences

autowireInternal

protected final Map<Class,SCAObject> autowireInternal

autowireExternal

protected final Map<Class,Service> autowireExternal

systemAutowireInternal

protected final Map<Class,SCAObject> systemAutowireInternal

systemAutowireExternal

protected final Map<Class,Service> systemAutowireExternal
Constructor Detail

CompositeComponentExtension

protected CompositeComponentExtension(String name,
                                      CompositeComponent parent,
                                      Connector connector,
                                      Map<String,Document> propertyValues)
Method Detail

getScope

public Scope getScope()
Description copied from interface: SCAObject
Returns the artifact scope

Specified by:
getScope in interface SCAObject

onEvent

public void onEvent(Event event)
Specified by:
onEvent in interface RuntimeEventListener

registerJavaObject

public <S,I extends S> void registerJavaObject(String name,
                                               Class<S> service,
                                               I instance)
                        throws ObjectRegistrationException
Description copied from interface: CompositeComponent
Register a simple Java Object as a system component. This is primarily intended for use by bootstrap code to create the initial configuration components.

Specified by:
registerJavaObject in interface CompositeComponent
Parameters:
name - the name of the resulting component
service - the service interface the component should expose
instance - the Object that will become the component's implementation
Throws:
ObjectRegistrationException

getPropertyValue

public Document getPropertyValue(String name)
Description copied from interface: CompositeComponent
Returns the value of a Property of this composite.

Specified by:
getPropertyValue in interface CompositeComponent
Parameters:
name - the name of the Property
Returns:
its value, or null if there is not such property or if it has no defined value

getChild

public SCAObject getChild(String name)
Description copied from interface: CompositeComponent
Returns the child associated with a given name

Specified by:
getChild in interface CompositeComponent

getSystemChild

public SCAObject getSystemChild(String name)
Description copied from interface: CompositeComponent
Returns the system child associated with a given name

Specified by:
getSystemChild in interface CompositeComponent

getSystemChildren

public List<SCAObject> getSystemChildren()
Description copied from interface: CompositeComponent
Returns the system children contained by the composite

Specified by:
getSystemChildren in interface CompositeComponent

getSystemServices

public List<Service> getSystemServices()
Description copied from interface: CompositeComponent
Returns the system services contained by the composite

Specified by:
getSystemServices in interface CompositeComponent

getSystemReferences

public List<Reference> getSystemReferences()
Description copied from interface: CompositeComponent
Returns the system references contained by the composite

Specified by:
getSystemReferences in interface CompositeComponent

getChildren

public List<SCAObject> getChildren()
Description copied from interface: CompositeComponent
Returns the children contained by the composite

Specified by:
getChildren in interface CompositeComponent

getServices

public List<Service> getServices()
Description copied from interface: CompositeComponent
Returns the services contained by the composite

Specified by:
getServices in interface CompositeComponent

getReferences

public List<Reference> getReferences()
Description copied from interface: CompositeComponent
Returns the references contained by the composite

Specified by:
getReferences in interface CompositeComponent

register

public void register(SCAObject child)
Description copied from interface: CompositeComponent
Registers a child of this composite.

Specified by:
register in interface CompositeComponent
Parameters:
child - the context to add as a child

addOutboundWire

public void addOutboundWire(OutboundWire wire)
Description copied from interface: Component
Adds a source-side wire for the given reference. Source-side wires contain the invocation chains for a reference in the implementation associated with the instance wrapper created by this configuration.

Specified by:
addOutboundWire in interface Component

addOutboundWires

public void addOutboundWires(Class<?> multiplicityClass,
                             List<OutboundWire> wires)
Description copied from interface: Component
Adds a set of source-side multiplicity wires for the given reference. Source-side wires contain the invocation chains for a reference in the implementation associated with the instance wrapper created by this configuration.

Specified by:
addOutboundWires in interface Component

getOutboundWires

public Map<String,List<OutboundWire>> getOutboundWires()
Description copied from interface: Component
Returns a map of source-side wires for references. There may be 1..n wires per reference.

Specified by:
getOutboundWires in interface Component

addInboundWire

public void addInboundWire(InboundWire wire)
Description copied from interface: Component
Adds a target-side wire. Target-side wire factories contain the invocation chains associated with the destination service of a wire

Specified by:
addInboundWire in interface Component

getInboundWire

public InboundWire getInboundWire(String serviceName)
Description copied from interface: Component
Returns the target-side wire associated with the given service name

Specified by:
getInboundWire in interface Component

getInboundWires

public Map<String,InboundWire> getInboundWires()
Description copied from interface: Component
Returns a map of inbound wires for a service.

Specified by:
getInboundWires in interface Component

createAsyncTargetInvoker

public TargetInvoker createAsyncTargetInvoker(InboundWire wire,
                                              Operation operation)
Description copied from interface: Component
Callback to create a TargetInvoker which dispatches to a service offered by the component

Specified by:
createAsyncTargetInvoker in interface Component
operation - the operation to invoke

getService

public Service getService(String name)
Description copied from interface: CompositeComponent
Returns the service associated with the given name

Specified by:
getService in interface CompositeComponent

getServiceInstance

public Object getServiceInstance()
                          throws TargetException
Description copied from interface: SCAObject
Returns an instance associated with the default service

Specified by:
getServiceInstance in interface SCAObject
Throws:
TargetException - if an error occurs retrieving the instance

getSystemService

public Service getSystemService(String name)
Description copied from interface: CompositeComponent
Returns the system service associated with the given name

Specified by:
getSystemService in interface CompositeComponent

locateService

public <T> T locateService(Class<T> serviceInterface,
                           String name)
Description copied from interface: CompositeComponent
Returns the service instance for associated with the child registered for the given name

Specified by:
locateService in interface CompositeComponent

locateSystemService

public <T> T locateSystemService(Class<T> serviceInterface,
                                 String name)
Description copied from interface: CompositeComponent
Returns the system service instance for associated with the child registered for the given name

Specified by:
locateSystemService in interface CompositeComponent

getServiceInstance

public Object getServiceInstance(String name)
                          throws TargetException
Description copied from interface: Component
Returns a service associated with the given name

Specified by:
getServiceInstance in interface Component
Throws:
TargetException - if an error occurs retrieving the service instance

getSystemServiceInstance

public Object getSystemServiceInstance(String name)
                                throws TargetException
Description copied from interface: CompositeComponent
Returns a system service associated with the given name

Specified by:
getSystemServiceInstance in interface CompositeComponent
Throws:
TargetException - if an error occurs retrieving the service instance

getServiceInterfaces

public List<Class<?>> getServiceInterfaces()
Description copied from interface: Component
Returns the service interfaces implemented by the component

Specified by:
getServiceInterfaces in interface Component

resolveInstance

public <T> T resolveInstance(Class<T> instanceInterface)
                  throws AutowireResolutionException
Description copied from interface: CompositeComponent
Invoked by child components to return an an autowire target. Resolved targets may be services or components in the parent or its ancestors, or references in a sibling component

Specified by:
resolveInstance in interface CompositeComponent
Parameters:
instanceInterface - the type of service being requested
Returns:
a reference to the requested service or null if none can be found
Throws:
AutowireResolutionException - if an error occurs attempting to resolve an autowire

resolveSystemInstance

public <T> T resolveSystemInstance(Class<T> instanceInterface)
                        throws AutowireResolutionException
Description copied from interface: CompositeComponent
Invoked by system child components to return an an autowire target. Resolved targets may be system services or components in the parent or its ancestors, or references in a sibling component

Specified by:
resolveSystemInstance in interface CompositeComponent
Parameters:
instanceInterface - the type of service being requested
Returns:
a reference to the requested service or null if none can be found
Throws:
AutowireResolutionException - if an error occurs attempting to resolve an autowire

resolveExternalInstance

public <T> T resolveExternalInstance(Class<T> instanceInterface)
                          throws AutowireResolutionException
Description copied from interface: CompositeComponent
Invoked by a parent component to return an autowire target in a child. Resolved targets must be services. For example, given a parent P and two siblings, A and B, A would request an autowire by invoking #resolveInstance(Class) on P, which in turn could invoke the present method on B in order to resolve a target.

Specified by:
resolveExternalInstance in interface CompositeComponent
Parameters:
instanceInterface - the type of service being requested
Returns:
a reference to the requested service or null if none can be found
Throws:
AutowireResolutionException - if an error occurs attempting to resolve an autowire

resolveSystemExternalInstance

public <T> T resolveSystemExternalInstance(Class<T> instanceInterface)
                                throws AutowireResolutionException
Description copied from interface: CompositeComponent
Invoked by a parent component to return a system autowire target in a child. Resolved targets must be system services. For example, given a parent P and two siblings, A and B, A would request an autowire by invoking #resolveInstance(Class) on P, which in turn could invoke the present method on B in order to resolve a target.

Specified by:
resolveSystemExternalInstance in interface CompositeComponent
Parameters:
instanceInterface - the type of service being requested
Returns:
a reference to the requested service or null if none can be found
Throws:
AutowireResolutionException - if an error occurs attempting to resolve an autowire

prepare

public void prepare()
Description copied from interface: SCAObject
Called to signal that the composite should perform and required steps prior to registration with its parent such as wiring of its children

Specified by:
prepare in interface SCAObject
Overrides:
prepare in class AbstractSCAObject

registerAutowireExternal

protected void registerAutowireExternal(Class<?> interfaze,
                                        Service service)

registerAutowireInternal

protected void registerAutowireInternal(Class<?> interfaze,
                                        SCAObject object)

registerAutowire

protected void registerAutowire(CompositeComponent component)

registerAutowire

protected void registerAutowire(AtomicComponent component)

registerAutowire

protected void registerAutowire(Reference reference)

registerAutowire

protected void registerAutowire(Service service)

Apache Tuscany SCA Kernel Sub-Project

-