/** * Get the context only in this scope. * No hierarchy lookup. * * @param name the context name * @param state the controller state * @return found context or null if not available */ public ControllerContext getContextLocally(Object name, ControllerState state) { return super.getContext(name, state); }
@Override public void install(ControllerContext context) throws Throwable { super.install(context); }
/** * Create an abstract controller */ public AbstractController() { addState(ControllerState.NOT_INSTALLED, null); addState(ControllerState.PRE_INSTALL, null); addState(ControllerState.DESCRIBED, null); addState(ControllerState.INSTANTIATED, null); addState(ControllerState.CONFIGURED, null); addState(ControllerState.CREATE, null); addState(ControllerState.START, null); addState(ControllerState.INSTALLED, null); indexedInstalledState = indexState(ControllerState.INSTALLED); registry = createContextRegistry(); }
protected ControllerContext getContextInternal(AbstractController controller, Object name, ControllerState state) { AbstractController parent = controller.getParentController(); if (parent != null) return parent.getContext(name, state); else return null; } }
getContexts(item.getName(), dependents); if (dependents.isEmpty() == false) if (stateModel.isBeforeState(dependent.getState(), whenRequired) == false) uninstallContext(dependent, whenRequired, trace); dependencies.removeDependsOnMe(item); ControllerContext dependency = getContext(iDependOn, item.getDependentState()); if (dependency != null) unlockWrite(); try resolveCallbacks(context, fromState, false); handleUninstallLifecycleCallbacks(context, toState); uninstall(context, fromState, toState); context.setState(toState); uninstallUnusedOnDemandContexts(context, trace); lockWrite();
throw new IllegalArgumentException("Null name"); lockWrite(); try log.trace("Tidied up context in error state: " + name); ControllerContext context = getRegisteredContextAndInterruptAsynchronousInstall(name); if (context != null) AbstractController parent = getParentController(); uninstallContext(context, stateModel.getInitialState(), trace); unregisterControllerContext(context); parent.unregisterControllerContext(context); parent = parent.getParentController(); for (AbstractController controller : getControllers()) context = controller.uninstall(name, level + 1); if (context != null) break; unlockWrite();
errorContexts.remove(context); Throwable error = null; unlockWrite(); try install(context, ControllerState.ERROR, initialState); lockWrite(); if (error != null) unlockWrite(); Throwable error = null; try install(context, fromState, toState); context.setState(toState); handleInstallLifecycleCallbacks(context, toState); resolveCallbacks(context, toState, true); lockWrite(); if (error != null) uninstallContext(context, stateModel.getInitialState(), trace); errorContexts.put(context.getName(), context); context.setError(error);
public void shutdown() lockWrite(); try Set<AbstractController> children = getControllers(); if (children != null && children.isEmpty() == false) child.shutdown(); Set<ControllerContext> contexts = getAllContexts(); if (contexts != null && contexts.isEmpty() == false) uninstall(context.getName()); unlockWrite();
List<ControllerState> states = controller.getStates(); for (int i = states.size()-1; i >= 0; --i) controller.change(deploymentControllerContext, state); try controller.uninstall(deploymentControllerContext.getName()); setState(context, DeploymentState.UNDEPLOYED, null); try controller.install(deploymentControllerContext); context.setState(DeploymentState.DEPLOYING); log.debug("Deploying " + context.getName()); List<ControllerState> states = controller.getStates(); for (ControllerState state : states) try controller.change(deploymentControllerContext, state);
if (resolveContexts(fromState, toState, trace)) if (stateModel.isValidState(nextState)) // only check states with valid next state Set<ControllerContext> stillUnresolved = getContextsByState(state); if (stillUnresolved != null && stillUnresolved.isEmpty() == false) if (advance(ctx)) log.trace("Still unresolved " + nextState.getStateString() + ": " + ctx); controller.lockWrite(); try controller.resolveContexts(trace); controller.unlockWrite(); AbstractController parent = getParentController(); if (parent != null) parent.resolveContexts(trace);
lockWrite(); try continue; ControllerContext other = getContext(name, null); if (other == null) uninstallContext(other, state, trace); unlockWrite();
/** * Get all contexts by name, * check child controllers as well. * * @param name the name of the context * @param contexts found contexts */ protected void getContexts(Object name, Set<ControllerContext> contexts) { ControllerContext context = getContext(name, null); if (context != null) { Set<Object> aliases = context.getAliases(); // only pick up unique name // TODO also ignore alises from @Aliases? if (aliases == null || aliases.contains(name) == false) contexts.add(context); } Set<AbstractController> children = getControllers(); if (children != null && children.isEmpty() == false) { for (AbstractController child : children) { child.getContexts(name, contexts); } } }
public void addAlias(Object alias, Object original) throws Throwable { Map<ControllerState, ControllerContextAction> map = createAliasActions(); ControllerContextActions actions = new AbstractControllerContextActions(map); AliasControllerContext context = new InnerAliasControllerContext(alias, getId(), original, actions); preAliasInstall(context); install(context); // is alias in error Throwable error = context.getError(); if (error != null) throw error; if (ControllerState.ERROR.equals(context.getState())) throw new IllegalArgumentException("Alias " + context + " is in error."); }
/** * Return the executor stored in this controller or in its parent hierarchy. The nearest executor is returned. * <p/> * This method must be called with the write or read lock taken * @return The found executor */ protected Executor searchForExecutor() { if (executor != null) { return executor; } AbstractController parent = getParentController(); if (parent != null) { try { parent.lockRead(); return parent.searchForExecutor(); } finally { parent.unlockRead(); } } return null; }
Set<ControllerContext> notInstalled = controller.getNotInstalled(); List<ControllerState> states = controller.getStates(); checkComplete(context, contextsInError, contextsMissingDependencies, notInstalled, states);
public void change(ControllerContext context, ControllerState state) throws Throwable { boolean trace = log.isTraceEnabled(); if (context == null) throw new IllegalArgumentException("Null context"); if (state == null) throw new IllegalArgumentException("Null state"); change(context, indexState(state), trace); }
protected ControllerContext getContextInternal(AbstractController controller, Object name, ControllerState state) { AbstractController parent = controller.getParentController(); if (parent != null) return getLocalContext(parent, name, state); else return null; } }
public ControllerContext uninstall(Object name) { return uninstall(name, 0); }