1 package net.logAnalyzer.config;
2
3 import net.logAnalyzer.analysis.LAAnalyzer;
4 import net.logAnalyzer.reports.LAReportRenderer;
5
6 /***
7 * This class contains the current commands file content. Commands are of
8 * several kinds :
9 * <ul>
10 * <li>the pattern used to parse log files;</li>
11 * <li>analyzers used to analyze parsed messages;</li>
12 * <li>renderers used to render reports on analyzers results.</li>
13 * </ul>
14 *
15 * @author Karim REFEYTON
16 * @version 0.1
17 */
18 public class CommandsManager {
19 /***
20 * Pattern used to parse log files.
21 */
22 private String pattern = null;
23
24 /***
25 * Analyzers used to analyze parsed messages.
26 */
27 private LAAnalyzer[] analyzers = null;
28
29 /***
30 * Renderers used to render reports.
31 */
32 private LAReportRenderer[] renderers = null;
33
34 /***
35 * Default constructor.
36 *
37 * @param pattern
38 * Pattern used to parse log messages.
39 * @param analyzers
40 * Analyzers used to analyze log messages and to produce user
41 * defined computations.
42 * @param renderers
43 * Renderers used to render analyzers results.
44 */
45 protected CommandsManager(String pattern, LAAnalyzer[] analyzers,
46 LAReportRenderer[] renderers) {
47 this.pattern = pattern;
48 this.analyzers = analyzers;
49 this.renderers = renderers;
50 }
51
52 /***
53 * Create a new configuration manager instance from the specified commands
54 * file.
55 *
56 * @param filename
57 * Name of the commands file.
58 * @return The new instance.
59 */
60 public static CommandsManager createInstance(String filename) {
61 XMLCommandsLoader loader = new XMLCommandsLoader();
62 return loader.loadCommands(filename);
63 }
64
65 /***
66 * Return the analyzers declared in the commands file used to analyze parsed
67 * messages.
68 *
69 * @return Analyzers.
70 */
71 public final LAAnalyzer[] getAnalyzers() {
72 return this.analyzers;
73 }
74
75 /***
76 * Return the pattern declared in the commands file to parse log file
77 * messages.
78 *
79 * @return Pattern.
80 */
81 public final String getPattern() {
82 return this.pattern;
83 }
84
85 /***
86 * Return the renderers declared in the commands file used to render
87 * reports.
88 *
89 * @return Renderers.
90 */
91 public final LAReportRenderer[] getRenderers() {
92 return this.renderers;
93 }
94 }