|
Tuscany Core | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.apache.tuscany.core.context.impl.AbstractLifecycle org.apache.tuscany.core.context.impl.AbstractContext org.apache.tuscany.core.context.impl.AbstractCompositeContext
public abstract class AbstractCompositeContext
The base implementation of a composite context
Nested Class Summary | |
---|---|
protected static class |
AbstractCompositeContext.NameToScope
|
Field Summary | |
---|---|
protected org.apache.tuscany.model.assembly.AssemblyContext |
assemblyContext
|
protected ConfigurationContext |
configurationContext
|
protected java.util.Map<java.lang.String,ContextFactory<Context>> |
configurations
|
static int |
DEFAULT_WAIT
|
protected EventContext |
eventContext
|
protected java.util.Map<org.apache.tuscany.model.assembly.Scope,ScopeContext> |
immutableScopeContexts
|
protected boolean |
initialized
|
protected java.util.concurrent.CountDownLatch |
initializeLatch
|
protected java.lang.Object |
lock
|
protected org.apache.tuscany.model.assembly.Module |
module
|
protected CompositeContext |
parentContext
|
protected java.util.Map<org.apache.tuscany.model.assembly.Scope,ScopeContext> |
scopeContexts
|
protected java.util.Map<java.lang.String,ScopeContext> |
scopeIndex
|
protected ScopeStrategy |
scopeStrategy
|
Fields inherited from class org.apache.tuscany.core.context.impl.AbstractLifecycle |
---|
lifecycleState, name |
Fields inherited from interface org.apache.tuscany.core.context.Lifecycle |
---|
CONFIG_ERROR, ERROR, INITIALIZED, INITIALIZING, RUNNING, STARTED, STOPPED, STOPPING, UNINITIALIZED |
Fields inherited from interface org.apache.tuscany.core.context.Lifecycle |
---|
CONFIG_ERROR, ERROR, INITIALIZED, INITIALIZING, RUNNING, STARTED, STOPPED, STOPPING, UNINITIALIZED |
Constructor Summary | |
---|---|
AbstractCompositeContext()
|
|
AbstractCompositeContext(java.lang.String name,
CompositeContext parent,
ScopeStrategy strategy,
EventContext ctx,
ConfigurationContext configCtx)
|
Method Summary | ||
---|---|---|
void |
build(org.apache.tuscany.model.assembly.AssemblyObject model)
Creates or updates a context factory based on configuration contained in the given model object. |
|
protected void |
buildTarget(ContextFactory<?> target)
Signals to target side of reference configurations to initialize |
|
protected void |
checkInit()
Blocks until the module context has been initialized |
|
void |
completeTargetChain(TargetWireFactory targetFactory,
java.lang.Class targetType,
ScopeContext targetScopeContext)
Finishes processing the target side wire chain. |
|
void |
connect(SourceWireFactory sourceFactory,
TargetWireFactory targetFactory,
java.lang.Class targetType,
boolean downScope,
ScopeContext targetScopeContext)
Connects wire configurations of the source proxy factory to corresponding ones in the target proxy to factory |
|
void |
fireEvent(int eventType,
java.lang.Object message)
|
|
org.apache.tuscany.model.assembly.Composite |
getComposite()
Returns the composite managed by this composite context |
|
Context |
getContext(java.lang.String componentName)
Returns the child context associated with a given name |
|
java.lang.Object |
getInstance(QualifiedName qName)
Returns the instance associated with the requested name, which may be in a atomic or composite form. |
|
CompositeContext |
getParent()
Returns the parent context, or null if the context does not have one |
|
java.util.Map<org.apache.tuscany.model.assembly.Scope,ScopeContext> |
getScopeContexts()
Returns an immutable collection of scopes keyed by type for the composite context |
|
java.lang.String |
getURI()
|
|
protected void |
initializeScopes()
|
|
protected void |
initializeWireFactories()
|
|
void |
publish(Event event)
|
|
protected void |
registerAutowireExternal(java.lang.Class<?> interfaze,
java.lang.String name,
ScopeContext scopeContext)
|
|
protected void |
registerAutowireInternal(java.lang.Class<?> interfaze,
java.lang.String name,
ScopeContext scopeContext)
|
|
protected void |
registerConfiguration(ContextFactory<Context> factory)
|
|
void |
registerModelObject(org.apache.tuscany.model.assembly.Extensible model)
Adds a runtime artifact represented by the model object to the composite context by merging it with existing artifacts. |
|
void |
registerModelObjects(java.util.List<? extends org.apache.tuscany.model.assembly.Extensible> models)
Adds runtime artifacts represented by the set of model objects to the composite context by merging them with existing artifacts. |
|
void |
removeContext(java.lang.String name)
|
|
|
resolveExternalInstance(java.lang.Class<T> instanceInterface)
Invoked by a parent context to return an autowire target in a child. |
|
|
resolveInstance(java.lang.Class<T> instanceInterface)
Invoked by child contexts to return an an autowire target. |
|
void |
setAssemblyContext(org.apache.tuscany.model.assembly.AssemblyContext assemblyContext)
TODO remove this method |
|
void |
setAutowireContext(AutowireContext context)
|
|
void |
setConfigurationContext(ConfigurationContext context)
|
|
void |
setEventContext(EventContext eventContext)
|
|
void |
setModule(org.apache.tuscany.model.assembly.Module module)
|
|
void |
setParent(CompositeContext parent)
Sets the parent context |
|
void |
setURI(java.lang.String uri)
|
|
void |
start()
Starts the Lifecycle. |
|
void |
stop()
Stops the Lifecycle. |
|
protected void |
wireSource(ContextFactory<Context> source)
Iterates through references and delegates to the configuration context to wire them to their targets |
Methods inherited from class org.apache.tuscany.core.context.impl.AbstractLifecycle |
---|
addListener, addListener, getLifecycleState, getListeners, getName, removeListener, setName, toString |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Methods inherited from interface org.apache.tuscany.core.context.EventPublisher |
---|
addListener, addListener, removeListener |
Methods inherited from interface org.apache.tuscany.core.context.Lifecycle |
---|
getLifecycleState, getName, setName |
Methods inherited from interface org.apache.tuscany.core.context.EventPublisher |
---|
addListener, addListener, removeListener |
Methods inherited from interface org.apache.tuscany.core.context.Lifecycle |
---|
getLifecycleState, getName, setName |
Field Detail |
---|
public static final int DEFAULT_WAIT
protected org.apache.tuscany.model.assembly.AssemblyContext assemblyContext
protected CompositeContext parentContext
protected ConfigurationContext configurationContext
protected org.apache.tuscany.model.assembly.Module module
protected java.util.Map<java.lang.String,ContextFactory<Context>> configurations
protected ScopeStrategy scopeStrategy
protected EventContext eventContext
protected java.util.Map<org.apache.tuscany.model.assembly.Scope,ScopeContext> scopeContexts
protected java.util.Map<org.apache.tuscany.model.assembly.Scope,ScopeContext> immutableScopeContexts
protected java.util.Map<java.lang.String,ScopeContext> scopeIndex
protected java.util.concurrent.CountDownLatch initializeLatch
protected final java.lang.Object lock
protected boolean initialized
Constructor Detail |
---|
public AbstractCompositeContext()
public AbstractCompositeContext(java.lang.String name, CompositeContext parent, ScopeStrategy strategy, EventContext ctx, ConfigurationContext configCtx)
Method Detail |
---|
public void setAssemblyContext(org.apache.tuscany.model.assembly.AssemblyContext assemblyContext)
CompositeContext
setAssemblyContext
in interface CompositeContext
public java.lang.String getURI()
getURI
in interface CompositeContext
public void setURI(java.lang.String uri)
setURI
in interface CompositeContext
public void start()
Lifecycle
start
in interface Lifecycle
public void stop()
Lifecycle
stop
in interface Lifecycle
public void setModule(org.apache.tuscany.model.assembly.Module module)
public void setEventContext(EventContext eventContext)
public void setConfigurationContext(ConfigurationContext context)
public CompositeContext getParent()
CompositeContext
getParent
in interface CompositeContext
public void setParent(CompositeContext parent)
CompositeContext
setParent
in interface CompositeContext
public void registerModelObjects(java.util.List<? extends org.apache.tuscany.model.assembly.Extensible> models) throws ConfigurationException
CompositeContext
Part
types.
registerModelObjects
in interface CompositeContext
ConfigurationException
Component
,
ModuleComponent
,
AtomicComponent
,
EntryPoint
,
ExternalService
public void registerModelObject(org.apache.tuscany.model.assembly.Extensible model) throws ConfigurationException
CompositeContext
Part
types.
registerModelObject
in interface CompositeContext
ConfigurationException
Component
,
ModuleComponent
,
AtomicComponent
,
EntryPoint
,
ExternalService
protected void registerConfiguration(ContextFactory<Context> factory) throws ConfigurationException
ConfigurationException
public void fireEvent(int eventType, java.lang.Object message) throws EventException
EventException
public void publish(Event event)
publish
in interface EventPublisher
publish
in class AbstractLifecycle
public Context getContext(java.lang.String componentName)
CompositeContext
getContext
in interface CompositeContext
public java.lang.Object getInstance(QualifiedName qName) throws TargetException
Context
getInstance
in interface Context
qName
- a qualified name of the requested instance
TargetException
- if an error occurs retrieving the instance or the requested component is not an entry
point.CompositeContext
,
EntryPoint
public java.util.Map<org.apache.tuscany.model.assembly.Scope,ScopeContext> getScopeContexts()
ScopeAwareContext
getScopeContexts
in interface ScopeAwareContext
protected void checkInit()
protected void initializeScopes()
protected void wireSource(ContextFactory<Context> source)
protected void buildTarget(ContextFactory<?> target)
protected void initializeWireFactories() throws WireFactoryInitException
WireFactoryInitException
public org.apache.tuscany.model.assembly.Composite getComposite()
CompositeContext
getComposite
in interface CompositeContext
public void setAutowireContext(AutowireContext context)
public <T> T resolveInstance(java.lang.Class<T> instanceInterface) throws AutowireResolutionException
AutowireContext
resolveInstance
in interface AutowireContext
instanceInterface
- the type of service being requested
AutowireResolutionException
- if an error occurs attempting to resolve an autowirepublic <T> T resolveExternalInstance(java.lang.Class<T> instanceInterface) throws AutowireResolutionException
AutowireContext
#resolveInstance(Class)
on P, which in turn could invoke the present method on B in order to resolve
a target.
resolveExternalInstance
in interface AutowireContext
instanceInterface
- the type of service being requested
AutowireResolutionException
- if an error occurs attempting to resolve an autowireprotected void registerAutowireInternal(java.lang.Class<?> interfaze, java.lang.String name, ScopeContext scopeContext)
protected void registerAutowireExternal(java.lang.Class<?> interfaze, java.lang.String name, ScopeContext scopeContext)
public void build(org.apache.tuscany.model.assembly.AssemblyObject model) throws BuilderConfigException
ContextFactoryBuilder
build
in interface ContextFactoryBuilder
model
- the logical configuration model node
BuilderConfigException
public void connect(SourceWireFactory sourceFactory, TargetWireFactory targetFactory, java.lang.Class targetType, boolean downScope, ScopeContext targetScopeContext) throws BuilderConfigException
WireBuilder
connect
in interface WireBuilder
sourceFactory
- the proxy factory used in constructing the source side of the wire chaintargetFactory
- the proxy factory used in constructing the target side of the wire chaintargetType
- the context type of the target. Used to determine if a paricular wire builder should construct
the wiredownScope
- true if the component containing the reference (source side) is of a lesser scope than the
target servicetargetScopeContext
- the scope context responsible for managing intance contexts of the target component
type
BuilderConfigException
- if an error occurs during the wire buildSource processpublic void completeTargetChain(TargetWireFactory targetFactory, java.lang.Class targetType, ScopeContext targetScopeContext) throws BuilderConfigException
WireBuilder
TargetInvoker
used by target-side proxies is usually set during this
phase.
completeTargetChain
in interface WireBuilder
targetFactory
- the target-side proxy factorytargetType
- the target context typetargetScopeContext
- the target scope
BuilderConfigException
- if an error occurs during the wire buildSource processpublic void removeContext(java.lang.String name)
removeContext
in interface CompositeContext
|
Tuscany Core | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |