}
protected void applyScoping(KernelControllerContext context) throws Throwable
{
KernelController controller = (KernelController)context.getController();
KernelMetaDataRepository repository = controller.getKernel().getMetaDataRepository();
ScopeKey scopeKey = getInstallScopeKey(context, controller, repository);
if (scopeKey != null)
{
scopeKey.freeze();
context.getScopeInfo().setInstallScope(scopeKey);
// todo - should this be done (repare the current context scope key)
// or where to store this 'deployment' key?
/*
ScopeKey contextScopeKey = context.getScope();
for (Scope s : scopes)
contextScopeKey.addScope(s);
*/
// find scoped controller
MutableMetaDataRepository mmdr = repository.getMetaDataRepository();
MetaDataRetrieval mdr = mmdr.getMetaDataRetrieval(scopeKey);
if (mdr == null)
{
mdr = new MemoryMetaDataLoader(scopeKey);
mmdr.addMetaDataRetrieval(mdr);