Controller controller = context.getController();
if (controller instanceof AbstractKernelController == false)
throw new IllegalArgumentException("Can only handle AbstractKernelController: " + controller);
AbstractKernelController kernelController = (AbstractKernelController)controller;
KernelMetaDataRepository repository = kernelController.getKernel().getMetaDataRepository();
MutableMetaDataRepository mmdr = repository.getMetaDataRepository();
AbstractController abstractController = ScopeHierarchyBuilder.buildControllerHierarchy(kernelController, mmdr, scopeKey);
if (abstractController instanceof ScopedKernelController == false)
throw new IllegalArgumentException("Should be ScopedKernelController instance: " + abstractController);
ScopedKernelController scopedController = (ScopedKernelController)abstractController;