Tuscany Core

org.apache.tuscany.core.system.config
Class SystemContextFactory

java.lang.Object
  extended by org.apache.tuscany.core.system.config.SystemContextFactory
All Implemented Interfaces:
ContextFactory<Context>, ContextResolver

public class SystemContextFactory
extends java.lang.Object
implements ContextFactory<Context>, ContextResolver

A ContextFactory that handles system component implementation types, which may be either simple, leaf types or an composites.

For composite types, this factory delegates to an ObjectFactory to create an instance of the composite implementation and perform injection of configuration and references. Once an composite instance is created, the factory will register the composite's children. This process may be done recursively in a lazy fashion, descending down an composite hierarchy as a child composite is instantiated.

Version:
$Rev: 406532 $ $Date: 2006-05-15 00:23:43 -0400 (Mon, 15 May 2006) $

Constructor Summary
SystemContextFactory(java.lang.String name, java.lang.reflect.Constructor ctr, org.apache.tuscany.model.assembly.Scope scope)
          Creates the runtime configuration
SystemContextFactory(java.lang.String name, org.apache.tuscany.model.assembly.Module module, java.lang.reflect.Constructor ctr, org.apache.tuscany.model.assembly.Scope scope)
          Creates the runtime configuration
 
Method Summary
 void addProperty(java.lang.String propertyName, java.lang.Object value)
          Adds a property to the context
 void addSourceWireFactories(java.lang.String referenceName, java.lang.Class referenceInterface, java.util.List<SourceWireFactory> factory, boolean multiplicity)
          Adds a set of source-side wire factories for the given reference.
 void addSourceWireFactory(java.lang.String referenceName, SourceWireFactory factory)
          Adds a source-side wire factory for the given reference.
 void addTargetWireFactory(java.lang.String serviceName, TargetWireFactory factory)
          Adds a target-side wire factory for the given service name.
 Context createContext()
          Creates a Context based on configuration supplied by a logical model assembly
 CompositeContext getCurrentContext()
          Returns the current composite context
 java.lang.String getName()
          Returns the name of the Context produced by the current factory
 org.apache.tuscany.model.assembly.Scope getScope()
          Returns the scope identifier associated with the type of contexts produced by the current factory
 java.util.List<SourceWireFactory> getSourceWireFactories()
          Returns a collection of source-side wire factories for references.
 java.util.Map<java.lang.String,TargetWireFactory> getTargetWireFactories()
          Returns a collection of target-side wire factories keyed by service name
 TargetWireFactory getTargetWireFactory(java.lang.String serviceName)
          Returns the target-side wire factory associated with the given service name
 void prepare(CompositeContext parent)
          Called to signal to the configuration that its parent context has been activated and that it shoud perform any required initialization steps
 void setDestroyInvoker(EventInvoker invoker)
           
 void setEagerInit(boolean val)
           
 void setInitInvoker(EventInvoker invoker)
           
 void setSetters(java.util.List<Injector> setters)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SystemContextFactory

public SystemContextFactory(java.lang.String name,
                            java.lang.reflect.Constructor ctr,
                            org.apache.tuscany.model.assembly.Scope scope)
Creates the runtime configuration

Parameters:
name - the SCDL name of the component the context refers to
ctr - the implementation type constructor
scope - the scope of the component implementation type

SystemContextFactory

public SystemContextFactory(java.lang.String name,
                            org.apache.tuscany.model.assembly.Module module,
                            java.lang.reflect.Constructor ctr,
                            org.apache.tuscany.model.assembly.Scope scope)
Creates the runtime configuration

Parameters:
name - the SCDL name of the component the context refers to
module - if this factory produces aggregagtes, the logical model associated with its children; otherwise null
ctr - the implementation type constructor
scope - the scope of the component implementation type
Method Detail

getName

public java.lang.String getName()
Description copied from interface: ContextFactory
Returns the name of the Context produced by the current factory

Specified by:
getName in interface ContextFactory<Context>

addProperty

public void addProperty(java.lang.String propertyName,
                        java.lang.Object value)
Description copied from interface: ContextFactory
Adds a property to the context

Specified by:
addProperty in interface ContextFactory<Context>

getScope

public org.apache.tuscany.model.assembly.Scope getScope()
Description copied from interface: ContextFactory
Returns the scope identifier associated with the type of contexts produced by the current factory

Specified by:
getScope in interface ContextFactory<Context>

createContext

public Context createContext()
                      throws ContextCreationException
Description copied from interface: ContextFactory
Creates a Context based on configuration supplied by a logical model assembly

Specified by:
createContext in interface ContextFactory<Context>
Returns:
a new instance context
Throws:
ContextCreationException - if an error occurs creating the context

addTargetWireFactory

public void addTargetWireFactory(java.lang.String serviceName,
                                 TargetWireFactory factory)
Description copied from interface: ContextFactory
Adds a target-side wire factory for the given service name. Target-side wire factories contain the invocation chains associated with the destination service of a wire and are responsible for generating proxies

Specified by:
addTargetWireFactory in interface ContextFactory<Context>

getTargetWireFactory

public TargetWireFactory getTargetWireFactory(java.lang.String serviceName)
Description copied from interface: ContextFactory
Returns the target-side wire factory associated with the given service name

Specified by:
getTargetWireFactory in interface ContextFactory<Context>

getTargetWireFactories

public java.util.Map<java.lang.String,TargetWireFactory> getTargetWireFactories()
Description copied from interface: ContextFactory
Returns a collection of target-side wire factories keyed by service name

Specified by:
getTargetWireFactories in interface ContextFactory<Context>

addSourceWireFactory

public void addSourceWireFactory(java.lang.String referenceName,
                                 SourceWireFactory factory)
Description copied from interface: ContextFactory
Adds a source-side wire factory for the given reference. Source-side wire factories contain the invocation chains for a reference in the implementation associated with the instance context created by this configuration. Source-side wire factories also produce proxies that are injected on a reference in a component implementation.

Specified by:
addSourceWireFactory in interface ContextFactory<Context>

addSourceWireFactories

public void addSourceWireFactories(java.lang.String referenceName,
                                   java.lang.Class referenceInterface,
                                   java.util.List<SourceWireFactory> factory,
                                   boolean multiplicity)
Description copied from interface: ContextFactory
Adds a set of source-side wire factories for the given reference. Source-side wire factories contain the invocation chains for a reference in the implementation associated with the instance context created by this configuration. Source-side wire factories also produce proxies that are injected on a reference in a component implementation.

Specified by:
addSourceWireFactories in interface ContextFactory<Context>

getSourceWireFactories

public java.util.List<SourceWireFactory> getSourceWireFactories()
Description copied from interface: ContextFactory
Returns a collection of source-side wire factories for references. There may 1..n wire factories per reference.

Specified by:
getSourceWireFactories in interface ContextFactory<Context>

setSetters

public void setSetters(java.util.List<Injector> setters)

setEagerInit

public void setEagerInit(boolean val)

setInitInvoker

public void setInitInvoker(EventInvoker invoker)

setDestroyInvoker

public void setDestroyInvoker(EventInvoker invoker)

prepare

public void prepare(CompositeContext parent)
Description copied from interface: ContextFactory
Called to signal to the configuration that its parent context has been activated and that it shoud perform any required initialization steps

Specified by:
prepare in interface ContextFactory<Context>
Parameters:
parent - the parent context

getCurrentContext

public CompositeContext getCurrentContext()
Description copied from interface: ContextResolver
Returns the current composite context

Specified by:
getCurrentContext in interface ContextResolver

Tuscany Core

-