Tuscany Core

org.apache.tuscany.core.builder
Interface ContextFactory<T extends Context>

All Known Implementing Classes:
EntryPointContextFactory, ExternalServiceContextFactory, SystemContextFactory, SystemEntryPointContextFactory, SystemExternalServiceContextFactory, SystemObjectContextFactory

public interface ContextFactory<T extends Context>

Implementations create Contexts based on an assembly configuration.

Context factories are "built" in two phases. ContextFactoryBuilders analyze an assembly, producing ContextFactorys for Components, EntryPoints, and ExternalServices. During this phase, WireFactorys for source- and target-side wires are produced for the ContextFactorys. �

The second build phase connects the source- and target-side WireFactories, thereby completing wire configuration.

At runtime, ContextFactorys are called to create new Contexts when a new implementation instance is required for a component, entry point, or external service. The Context is then responsible for instantiating and managing the actual implementation instance. When a Context creates a new instance, the previously configured WireFactorys are used to create wires to and from the instance. A wire is a collection of stateless invocation chains that are managed by the Context's ContextFactory.

Version:
$Rev: 385747 $ $Date: 2006-03-13 22:12:53 -0800 (Mon, 13 Mar 2006) $

Method Summary
 void addProperty(String propertyName, Object value)
          Adds a property to the context
 void addSourceWireFactories(String referenceName, Class referenceInterface, List<SourceWireFactory> factory, boolean multiplicity)
          Adds a set of source-side wire factories for the given reference.
 void addSourceWireFactory(String referenceName, SourceWireFactory factory)
          Adds a source-side wire factory for the given reference.
 void addTargetWireFactory(String serviceName, TargetWireFactory factory)
          Adds a target-side wire factory for the given service name.
 T createContext()
          Creates a Context based on configuration supplied by a logical model assembly
 String getName()
          Returns the name of the Context produced by the current factory
 Scope getScope()
          Returns the scope identifier associated with the type of contexts produced by the current factory
 List<SourceWireFactory> getSourceWireFactories()
          Returns a collection of source-side wire factories for references.
 Map<String,TargetWireFactory> getTargetWireFactories()
          Returns a collection of target-side wire factories keyed by service name
 TargetWireFactory getTargetWireFactory(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
 

Method Detail

createContext

T createContext()
                                throws ContextCreationException
Creates a Context based on configuration supplied by a logical model assembly

Returns:
a new instance context
Throws:
ContextCreationException - if an error occurs creating the context

getScope

Scope getScope()
Returns the scope identifier associated with the type of contexts produced by the current factory


getName

String getName()
Returns the name of the Context produced by the current factory


addProperty

void addProperty(String propertyName,
                 Object value)
Adds a property to the context


addTargetWireFactory

void addTargetWireFactory(String serviceName,
                          TargetWireFactory factory)
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


getTargetWireFactory

TargetWireFactory getTargetWireFactory(String serviceName)
Returns the target-side wire factory associated with the given service name


getTargetWireFactories

Map<String,TargetWireFactory> getTargetWireFactories()
Returns a collection of target-side wire factories keyed by service name


addSourceWireFactory

void addSourceWireFactory(String referenceName,
                          SourceWireFactory factory)
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.

Parameters:
referenceName -
factory -

addSourceWireFactories

void addSourceWireFactories(String referenceName,
                            Class referenceInterface,
                            List<SourceWireFactory> factory,
                            boolean multiplicity)
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.

Parameters:
referenceName -
referenceInterface -
factory -
multiplicity -

getSourceWireFactories

List<SourceWireFactory> getSourceWireFactories()
Returns a collection of source-side wire factories for references. There may 1..n wire factories per reference.


prepare

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

Parameters:
parent - the parent context

Tuscany Core

-