public ScopeContainer getScopeContainer(RuntimeComponent runtimeComponent) {
if (!(runtimeComponent instanceof ScopedRuntimeComponent)) {
return null;
}
ScopedRuntimeComponent component = (ScopedRuntimeComponent)runtimeComponent;
if (component.getScopeContainer() != null) {
return component.getScopeContainer();
}
ImplementationProvider implementationProvider = component.getImplementationProvider();
if (implementationProvider instanceof ScopedImplementationProvider) {
ScopedImplementationProvider provider = (ScopedImplementationProvider)implementationProvider;
Scope scope = provider.getScope();
if (scope == null) {
scope = Scope.STATELESS;
} else if (scope.equals(Scope.INVALID)) {
return null;
}
ScopeContainerFactory factory = scopeCache.get(scope);
ScopeContainer container = factory.createScopeContainer(component);
component.setScopeContainer(container);
return container;
}
return null;
}