/** * Get child controllers. * * @return the child controllers */ public Set<AbstractController> getControllers() { lockRead(); try { return Collections.unmodifiableSet(childControllers); } finally { unlockRead(); } }
/** * Get the executor internal w/o security check. * * @return the executor */ protected Executor getExecutionEnvironment() { lockRead(); try { return executor; } finally { unlockRead(); } }
/** * Get the matching callbacks. * * @param name demand name * @param isInstallPhase install or uninstall phase * @return all matching registered callbacks or empty set if no such item */ protected Set<CallbackItem<?>> getCallbacks(Set<CallbackItem<?>> result, Object name, boolean isInstallPhase) { lockRead(); try { Map<Object, Set<CallbackItem<?>>> map = (isInstallPhase ? installCallbacks : uninstallCallbacks); Set<CallbackItem<?>> callbacks = map.get(name); if (callbacks != null) { if (result == null) result = new HashSet<CallbackItem<?>>(); result.addAll(callbacks); } return result; } finally { unlockRead(); } }
/** * Get all the contexts. * In state decending order. * * @return all contexts */ public Set<ControllerContext> getAllContexts() { lockRead(); try { LinkedHashSet<ControllerContext> result = new LinkedHashSet<ControllerContext>(); ListIterator<ControllerState> it = stateModel.listIteraror(); if (it.hasNext()) { result.addAll(getContextsByState(it.next())); while (it.hasPrevious()) { result.addAll(getContextsByState(it.previous())); } } result.addAll(errorContexts.values()); return result; } finally { unlockRead(); } }
/** * Whether the controller has contexts * * @return true when there are registered contexts */ public boolean isActive() { lockRead(); try { // is this active if (allContexts.isEmpty() == false) return true; // any of the children still active for (AbstractController child : getControllers()) { if (child.isActive()) return true; } return false; } finally { unlockRead(); } }
/** * 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; }