1 |
|
//---PACKAGE DECLARATION--- |
2 |
< |
package uk.ac.ukc.iscream.filter; |
2 |
> |
package uk.org.iscream.filter; |
3 |
|
|
4 |
|
//---IMPORTS--- |
5 |
|
import java.io.*; |
6 |
|
import java.util.*; |
7 |
|
|
8 |
< |
import uk.ac.ukc.iscream.util.*; |
9 |
< |
import uk.ac.ukc.iscream.componentmanager.*; |
10 |
< |
import uk.ac.ukc.iscream.core.*; |
8 |
> |
import uk.org.iscream.util.*; |
9 |
> |
import uk.org.iscream.componentmanager.*; |
10 |
> |
import uk.org.iscream.core.*; |
11 |
|
|
12 |
|
/** |
13 |
|
* This class setups up and manages Plugins for performing service |
44 |
|
public final String REVISION = "$Revision$"; |
45 |
|
|
46 |
|
/** |
47 |
< |
* file name suffix for plugin filter classes: |
47 |
> |
* file name suffix for plugin service check classes: |
48 |
|
*/ |
49 |
|
private final String _suffix = "__ServiceCheck"; |
50 |
|
|
51 |
|
//---STATIC METHODS--- |
52 |
|
|
53 |
|
/** |
54 |
< |
* Return a reference to the single class. |
54 |
> |
* Return a reference to the singleton class. |
55 |
|
* Construct it if it does not already exist, otherwise just return the reference. |
56 |
|
*/ |
57 |
|
public static PluginServiceCheckManager getInstance() { |
58 |
|
if (_instance == null){ |
59 |
< |
_instance = new PluginFilterManager(); |
59 |
> |
_instance = new PluginServiceCheckManager(); |
60 |
|
} |
61 |
|
return _instance; |
62 |
|
} |
67 |
|
* Private Constructor - this part creates the filter pipeline |
68 |
|
* This is a singleton class, btw. |
69 |
|
*/ |
70 |
< |
private PluginFilterManager(){ |
70 |
> |
private PluginServiceCheckManager(){ |
71 |
|
_logger.write(toString(), Logger.SYSINIT, "created"); |
72 |
|
} |
73 |
|
|
74 |
|
//---PUBLIC METHODS--- |
75 |
|
|
76 |
|
/** |
77 |
< |
* apply all of the filters in the pipeline to the packet. |
78 |
< |
* return true if they all accept the packet. |
79 |
< |
* return false if any single filter rejects the packet. |
80 |
< |
* return true if there are no filters inthe pipeline. |
77 |
> |
* run all registered service checks on a given host, |
78 |
> |
* returning XML data with information about the check. |
79 |
|
* |
80 |
< |
* @param the host to run service checks for |
81 |
< |
* @return whether the packet can be passed on |
80 |
> |
* @param hostname the host to run service checks for |
81 |
> |
* @return the xml output from the service checks |
82 |
|
*/ |
83 |
|
public String runServiceChecks(String hostname){ |
84 |
|
if (!_hostPipelines.containsKey(hostname)) { |
85 |
< |
_hostPipelines.put(hostname, new PluginServiceCheckPipeLine(hostname, this); |
85 |
> |
_hostPipelines.put(hostname, new PluginServiceCheckPipeline(hostname, this)); |
86 |
|
} |
87 |
< |
return "<services>" + ((PluginServiceCheckPipeLine) _hostPipelines.get(hostname)).runPipeline() + "</services>"; |
87 |
> |
return "<services>" + ((PluginServiceCheckPipeline) _hostPipelines.get(hostname)).runPipeline() + "</services>"; |
88 |
|
} |
89 |
|
|
90 |
|
/** |
91 |
|
* Overrides the {@link java.lang.Object#toString() Object.toString()} |
92 |
|
* method to provide clean logging (every class should have this). |
93 |
|
* |
94 |
< |
* This uses the uk.ac.ukc.iscream.util.NameFormat class |
94 |
> |
* This uses the uk.org.iscream.util.NameFormat class |
95 |
|
* to format the toString() |
96 |
|
* |
97 |
|
* @return the name of this class and its CVS revision |
117 |
|
* @return the requested PluginServiceCheck |
118 |
|
*/ |
119 |
|
public synchronized PluginServiceCheck getServiceCheck(String className) { |
120 |
+ |
_logger.write(toString(), Logger.DEBUG, "got request for service check - " + className); |
121 |
|
// see if we've already got the service check loaded |
122 |
|
if(_loadedServiceChecks.containsKey(className)) { |
123 |
|
_logger.write(toString(), Logger.DEBUG, className + " already loaded - returning reference to it."); |