|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.apache.tuscany.sca.core.scope.AbstractScopeContainer<KEY>
public abstract class AbstractScopeContainer<KEY>
Implements functionality common to scope contexts.
Field Summary | |
---|---|
protected RuntimeComponent |
component
|
protected int |
lifecycleState
|
protected Scope |
scope
|
protected java.util.Map<KEY,InstanceWrapper<?>> |
wrappers
|
Fields inherited from interface org.apache.tuscany.sca.core.scope.ScopeContainer |
---|
CONFIG_ERROR, ERROR, INITIALIZED, INITIALIZING, RUNNING, STOPPED, STOPPING, UNINITIALIZED |
Constructor Summary | |
---|---|
AbstractScopeContainer(Scope scope,
RuntimeComponent component)
|
Method Summary | |
---|---|
void |
addWrapperReference(KEY existingContextId,
KEY newContextId)
Allows a component to be registered against more than one context id. |
protected void |
checkInit()
|
protected InstanceWrapper |
createInstanceWrapper()
Creates a new physical instance of a component, wrapped in an InstanceWrapper. |
InstanceWrapper |
getAssociatedWrapper(KEY contextId)
Returns an implementation instance associated with the current scope context. |
RuntimeComponent |
getComponent()
|
int |
getLifecycleState()
Returns the lifecycle state |
Scope |
getScope()
Returns the Scope that this container supports. |
InstanceWrapper |
getWrapper(KEY contextId)
Returns an instance wrapper associated with the current scope context, creating one if necessary |
protected boolean |
isEagerInit()
|
void |
onEvent(Event event)
Accepts and event and acts on it |
void |
registerWrapper(InstanceWrapper wrapper,
KEY contextId)
Register an existing instance against a context id. |
void |
remove(KEY contextId)
Default implementation of remove which does nothing |
void |
returnWrapper(InstanceWrapper wrapper,
KEY contextId)
Return a wrapper after use (for example, after invoking the instance). |
void |
setComponent(RuntimeComponent component)
|
protected void |
setLifecycleState(int lifecycleState)
Set the current state of the Lifecycle. |
void |
start()
Starts the Lifecycle. |
void |
startContext(KEY contextId)
Start a new context with the supplied ID. |
void |
stop()
Stops the Lifecycle. |
void |
stopContext(KEY contextId)
Stop the context with the supplied ID. |
java.lang.String |
toString()
|
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
protected java.util.Map<KEY,InstanceWrapper<?>> wrappers
protected final Scope scope
protected RuntimeComponent component
protected volatile int lifecycleState
Constructor Detail |
---|
public AbstractScopeContainer(Scope scope, RuntimeComponent component)
Method Detail |
---|
protected void checkInit()
protected InstanceWrapper createInstanceWrapper() throws TargetResolutionException
component
- the component whose instance should be created
TargetResolutionException
- if there was a problem creating the
instancepublic InstanceWrapper getAssociatedWrapper(KEY contextId) throws TargetResolutionException
ScopeContainer
TargetNotFoundException
is thrown.
getAssociatedWrapper
in interface ScopeContainer<KEY>
contextId
- the id for the scope context
TargetResolutionException
- if there was a problem instantiating the target instancepublic Scope getScope()
ScopeContainer
getScope
in interface ScopeContainer<KEY>
public InstanceWrapper getWrapper(KEY contextId) throws TargetResolutionException
ScopeContainer
getWrapper
in interface ScopeContainer<KEY>
contextId
- the id for the scope context
TargetResolutionException
- if there was a problem instantiating the target instancepublic void addWrapperReference(KEY existingContextId, KEY newContextId) throws TargetResolutionException
ScopeContainer
addWrapperReference
in interface ScopeContainer<KEY>
existingContextId
- an id that identifies an existing component instancenewContextId
- a new id against which this component will also be registered
TargetResolutionException
public void registerWrapper(InstanceWrapper wrapper, KEY contextId) throws TargetResolutionException
ScopeContainer
registerWrapper
in interface ScopeContainer<KEY>
wrapper
- the instance wrapper for the instance to be registeredcontextId
- the id for the scope context
TargetResolutionException
public void onEvent(Event event)
RuntimeEventListener
onEvent
in interface RuntimeEventListener
event
- The event to act onprotected boolean isEagerInit()
public void returnWrapper(InstanceWrapper wrapper, KEY contextId) throws TargetDestructionException
ScopeContainer
returnWrapper
in interface ScopeContainer<KEY>
wrapper
- the wrapper for the target instance being returnedcontextId
- the id for the scope context
TargetDestructionException
- if there was a problem returning the target instancepublic void remove(KEY contextId) throws TargetDestructionException
remove
in interface ScopeContainer<KEY>
contextId
- the identifier of the context to remove.
TargetDestructionException
public void start()
ScopeContainer
start
in interface ScopeContainer<KEY>
public void startContext(KEY contextId)
ScopeContainer
startContext
in interface ScopeContainer<KEY>
contextId
- an ID that uniquely identifies the context.public void stop()
ScopeContainer
stop
in interface ScopeContainer<KEY>
public void stopContext(KEY contextId)
ScopeContainer
stopContext
in interface ScopeContainer<KEY>
contextId
- an ID that uniquely identifies the context.public java.lang.String toString()
toString
in class java.lang.Object
public RuntimeComponent getComponent()
public void setComponent(RuntimeComponent component)
public int getLifecycleState()
ScopeContainer
getLifecycleState
in interface ScopeContainer<KEY>
ScopeContainer.UNINITIALIZED
,
ScopeContainer.INITIALIZING
,
ScopeContainer.INITIALIZED
,
ScopeContainer.RUNNING
,
ScopeContainer.STOPPING
,
ScopeContainer.STOPPED
protected void setLifecycleState(int lifecycleState)
lifecycleState
- the new state
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |