01: package org.vraptor.util;
02:
03: import java.util.ArrayList;
04: import java.util.Collections;
05: import java.util.Comparator;
06: import java.util.List;
07:
08: import org.vraptor.component.ComponentType;
09: import org.vraptor.plugin.VRaptorPlugin;
10: import org.vraptor.webapp.WebApplication;
11:
12: /**
13: * Outjects components and plugins variables.
14: *
15: * @author Guilherme Silveira
16: */
17: public class StatsQuery {
18:
19: /**
20: * Compares the name of two ComponentType, ignoring case. Note: this
21: * comparator imposes orderings that are inconsistent with equals
22: */
23: class ComponentTypeNameComparator implements
24: Comparator<ComponentType> {
25:
26: public int compare(ComponentType c1, ComponentType c2) {
27: return c1.getName().compareToIgnoreCase(c2.getName());
28: }
29: }
30:
31: private List<ComponentType> components;
32:
33: private List<VRaptorPlugin> plugins;
34:
35: private final WebApplication webApplication;
36:
37: public StatsQuery(WebApplication webApplication) {
38: this .webApplication = webApplication;
39: }
40:
41: public List<ComponentType> getComponents() {
42: return components;
43: }
44:
45: public List<VRaptorPlugin> getPlugins() {
46: return plugins;
47: }
48:
49: public void read() {
50:
51: this .components = new ArrayList<ComponentType>(
52: this .webApplication.getComponentManager()
53: .getComponents());
54: Collections.sort(this .components,
55: new ComponentTypeNameComparator());
56:
57: this.plugins = this.webApplication.getPluginManager()
58: .getPlugins();
59: }
60: }
|