/** Actual stop */ private void internalStop() { state = ComponentStatus.STOPPING; removeShutdownHook(); List<PrioritizedMethod> stopMethods = new ArrayList<PrioritizedMethod>(componentLookup.size()); for (Component c : componentLookup.values()) stopMethods.addAll(c.stopMethods); Collections.sort(stopMethods); // fire all STOP methods according to priority for (PrioritizedMethod em : stopMethods) em.invoke(); destroy(); }
private void populateLifeCycleMethods(Component c) { if (!c.methodsScanned) { c.methodsScanned = true; c.startMethods.clear(); c.stopMethods.clear(); List<Method> methods = getAllMethodsViaReflection(c.instance.getClass(), Start.class); for (Method m : methods) { PrioritizedMethod em = new PrioritizedMethod(); em.component = c; em.method = m; em.priority = m.getAnnotation(Start.class).priority(); c.startMethods.add(em); } methods = getAllMethodsViaReflection(c.instance.getClass(), Stop.class); for (Method m : methods) { PrioritizedMethod em = new PrioritizedMethod(); em.component = c; em.method = m; em.priority = m.getAnnotation(Stop.class).priority(); c.stopMethods.add(em); } } }
private void internalStart() throws CacheException, IllegalArgumentException { // start all internal components // first cache all start, stop and destroy methods. populateLifecycleMethods(); List<PrioritizedMethod> startMethods = new ArrayList<PrioritizedMethod>(componentLookup.size()); for (Component c : componentLookup.values()) startMethods.addAll(c.startMethods); // sort the start methods by priority Collections.sort(startMethods); // fire all START methods according to priority for (PrioritizedMethod em : startMethods) em.invoke(); addShutdownHook(); getLog().version(Version.printVersion()); state = ComponentStatus.RUNNING; }