/** * Return basic scope names matching given type * * @param type Scope type * @return set of scope names */ public Set<String> getBasicScopeNames(ScopeType type) { if (type != null) { Set<String> names = new HashSet<String>(); for (IBasicScope child : children.keySet()) { if (child.getType().equals(type)) { names.add(child.getName()); } } return names; } return getScopeNames(); }
/** Uninitialize scope and unregister from parent. */ public void uninit() { log.debug("Un-init scope"); for (IBasicScope child : children.keySet()) { if (child instanceof Scope) { ((Scope) child).uninit(); } } stop(); setEnabled(false); if (hasParent()) { if (parent.hasChildScope(name)) { parent.removeChildScope(this); } } }
/** * Destroys scope * * @throws Exception on error */ public void destroy() throws Exception { log.debug("Destroy scope"); if (hasParent()) { parent.removeChildScope(this); } if (hasHandler()) { // Because handler can be null when there is a parent handler getHandler().stop(this); } // kill all child scopes for (IBasicScope child : children.keySet()) { removeChildScope(child); if (child instanceof Scope) { ((Scope) child).uninit(); } } }
// for debugging public void dump() { if (log.isTraceEnabled()) { log.trace("Scope: {} {}", this.getClass().getName(), this); log.trace("Running: {}", running); if (hasParent()) { log.trace("Parent: {}", parent); Set<String> names = parent.getBasicScopeNames(null); log.trace("Sibling count: {}", names.size()); for (String sib : names) { log.trace("Siblings - {}", sib); } names = null; } log.trace("Handler: {}", handler); log.trace("Child count: {}", children.size()); for (IBasicScope child : children.keySet()) { log.trace("Child: {}", child); } } }
/** Removes all the child scopes */ public void removeChildren() { log.trace("removeChildren of {}", name); for (IBasicScope child : children.keySet()) { removeChildScope(child); } }