public Object getTarget() { return delegate.getTarget(); }
public Map<String, Object> getBeansWithAnnotation(final Class<? extends Annotation> annotationType) throws BeansException { Set<ControllerContext> controllerContexts = kernelController.filter(kernelController.getContextsByState(ControllerState.INSTALLED), new ContextFilter() { public boolean accepts(ControllerContext context) { Set<AnnotationMetaData> annotationMetaDataSet = ((KernelControllerContext) context).getBeanMetaData().getAnnotations(); for (AnnotationMetaData annotationMetaData : annotationMetaDataSet) { if (annotationType.isAssignableFrom(annotationMetaData.getAnnotationInstance().annotationType())) { return true; } } return false; } }); Map<String, Object> returnedObjects = new HashMap<String, Object>(); for (ControllerContext controllerContext : controllerContexts) { returnedObjects.put((String) controllerContext.getName(), controllerContext.getTarget()); } return returnedObjects; }
/** * Add optional dependency. * * @param controller the controller * @param lookup the lookup context */ protected void addOptionalDependency(Controller controller, ControllerContext lookup) { OptionalDependencyItem dependency = new OptionalDependencyItem(context.getName(), lookup.getName(), lookup.getState()); context.getDependencyInfo().addIDependOn(dependency); lookup.getDependencyInfo().addDependsOnMe(dependency); }
public void install(ControllerContext context) throws Throwable { boolean trace = log.isTraceEnabled(); if (context == null) throw new IllegalArgumentException("Null context"); Object name = context.getName(); if (name == null) throw new IllegalArgumentException("Null name " + context.toShortString()); install(context, trace); }
/** * Whether we should advance the context<p> * <p/> * This method must be invoked with the write lock taken * * @param context the context * @return true when we should advance the context */ protected boolean advance(ControllerContext context) { ControllerMode mode = context.getMode(); // Never advance for disabled if (ControllerMode.DISABLED.equals(mode)) return false; return stateModel.isBeforeState(context.getState(), context.getRequiredState()); }
public Object getValue(TypeInfo info, ClassLoader cl) throws Throwable { Controller controller = context.getController(); ControllerContext context = controller.getContext(getUnderlyingValue(), ControllerState.INSTANTIATED); if (context == null) throw new Error("Could not deference this " + this); // TODO - add progression, see BeanMetaData, InjectionMetaData return context.getTarget(); }
List<ControllerState> states) if (context.getState().equals(ControllerState.ERROR)) contextsInError.put(context.getName().toString(), getRootCause(context.getError())); else String name = context.getName().toString(); Set<MissingDependency> dependencies = new HashSet<MissingDependency>(); DependencyInfo dependsInfo = context.getDependencyInfo(); for (DependencyItem item : dependsInfo.getIDependOn(null)) else actualState = other.getState(); actualStateString = actualState.getStateString();
public Object internalExecute(ControllerContext context) { // todo - change to actual id when impl return context.getName(); } }
Object name = context.getName(); Set<Object> aliases = context.getAliases(); if (aliases != null && aliases.isEmpty() == false) ControllerMode mode = context.getMode(); context.setRequiredState(mode.getRequiredState()); log.trace("Installing " + context.toShortString()); context.setController(this); DependencyInfo dependencies = context.getDependencyInfo(); if (trace) throw context.getError();
Object name = context.getName(); ControllerState fromState = context.getState(); Controller fromController = context.getController(); throw new Error("INTERNAL ERROR: context not found in previous state " + fromState.getStateString() + " context=" + context.toShortString(), new Exception("STACKTRACE")); DependencyInfo dependencies = context.getDependencyInfo(); if (dependencies != null) if (stateModel.isBeforeState(dependent.getState(), whenRequired) == false) DependencyInfo info = dependency.getDependencyInfo(); if (info != null) log.error("Error unresolving dependencies for " + fromState.getStateString() + ": " + context.toShortString(), error); errorContexts.put(context.getName(), context); context.setError(error); fromState = context.getState(); if (ControllerState.ERROR.equals(fromState)) return; ControllerState toState = context.getController().getStates().getPreviousState(fromState); if (toState == null) context.setState(ControllerState.ERROR);
try DependencyInfo dependencies = context.getDependencyInfo(); if (dependencies != null) continue; if (other.getMode() != ControllerMode.ON_DEMAND) continue; Set<ControllerContext> fromContexts = other.getController().getContextsByState(other.getState()); if (fromContexts.contains(other) == false) log.trace("Could not find ON_DEMAND context " + other.getName() + " in " + other.getState() + " it is probably being uninstalled"); continue; DependencyInfo otherDependencies = other.getDependencyInfo(); if (otherDependencies == null) continue;
controller = context.getController(); if (indexedInstalledState.equals(context.getRequiredState())) return; if (ControllerMode.ON_DEMAND.equals(context.getMode()) == false) throw new IllegalStateException("Context is not ON DEMAND: " + context.toShortString()); getRegisteredControllerContext(context.getName(), true); context.setRequiredState(indexedInstalledState); log.trace("Enable onDemand: " + context.toShortString());
/** * Add a dependency * * @param item the dependency item */ protected void addIDependOn(RequirementDependencyItem item) { if (context == null) throw new IllegalStateException("No controller context"); context.getDependencyInfo().addIDependOn(item); }
if (!stateModel.isValidState(context.getRequiredState())) throw new IllegalArgumentException("Unknown state: " + context.getRequiredState()); while(resolved && stateModel.isBeforeState(context.getState(), context.getRequiredState()) && !interrupted) ControllerState toState = stateModel.getNextState(context.getState()); if (advance(context)) Object ctx = trace ? context : context.getName(); log.error("Error resolving dependencies for " + toState.getStateString() + ": " + ctx, error); uninstallContext(context, stateModel.getInitialState(), trace); errorContexts.put(context.getName(), context); context.setError(error);
Controller controller = context.getController(); if (controller == null) return ResolvedState.UNRESOLVED; ControllerState state = context.getState(); ControllerState requiredState = context.getRequiredState(); if (states.isBeforeState(requiredState, nextState)) return ResolvedState.SEMI_RESOLVED; DependencyInfo info = context.getDependencyInfo();
public void install(ControllerContext ctx) throws Exception { log.trace("Invoking install callback '" + installMethod + "' on " + bean + " for target " + bean + " at " + whenRequired); installed = true; Controller controller = ctx.getController(); ControllerContext callbackContext = controller.getContext(bean, dependentState); if (callbackContext instanceof InvokeDispatchContext) { try { ((InvokeDispatchContext)callbackContext).invoke(installMethod, new Object[]{ctx}, new String[]{ControllerContext.class.getName()}); } catch(Throwable t) { throw new Exception("Error calling callback " + bean + " for target context " + ctx.getName(), t); } } else { throw new IllegalArgumentException("Cannot install " + ctx.getName() + ". Lifecycle callback context " + bean + " does not implement InvokeDispatchContext"); } }
throw new IllegalArgumentException("Unknown state: " + state); if (context.getState().equals(state)) log.trace("No change required toState=" + state.getStateString() + " " + context.toShortString()); return; log.trace("Change toState=" + state.getStateString() + " " + context.toShortString()); context.setRequiredState(state); if (stateModel.isBeforeState(context.getState(), state)) resolveContexts(trace); else while (stateModel.isAfterState(context.getState(), state)) log.trace("Not uninstalling " + context.getName() + " it is already being uninstalled");
throw new IllegalArgumentException("No such target bean installed: " + targetName); Throwable error = targetControllerContext.getError(); if (error != null) throw new IllegalArgumentException("Target bean " + targetName + " is in Error state: " + error); whenRequired = ControllerState.getInstance(whenRequiredState); ControllerState currentTargetState = targetControllerContext.getState(); if (controller.getStates().isBeforeState(currentTargetState, whenRequired) == false) throw new IllegalArgumentException("Target bean " + targetName + " is already past " + whenRequiredState + " state: " + targetControllerContext); dependent = ControllerState.getInstance(dependentState); DependencyInfo di = targetControllerContext.getDependencyInfo(); for (Object dependency : dependencies)
Object name = ctx.getName(); AsynchronousInstallStatus asynchStatus = contextsInstalledByExecutor.checkInstalled(ctx); if (fromState.equals(ctx.getState()) == false) log.error("Error resolving dependencies for " + toState.getStateString() + ": " + ctx.toShortString(), error); uninstallContext(ctx, stateModel.getInitialState(), trace); errorContexts.put(ctx.getName(), ctx); ctx.setError(error);