@Override public void discoverPost(String hostname, JrdsElement hostEleme, Map<String, JrdsDocument> probdescs, HttpServletRequest request) { super.discoverPost(hostname, hostEleme, probdescs, request); jrdsHandle.connector.tearDown(); } }
protected Element addConnexion(JrdsElement hostElem, String connexionClass, List<String> argsTypes, List<String> argsValues, Map<String, String> beans) { JrdsElement cnxElement = hostElem.addElement("type", String.format("type=%s", connexionClass)); addArgsList(cnxElement, argsTypes, argsValues, beans); return cnxElement; }
/** * This method add a probe to the current host document * * @param hostElement the host element * @param probe the Name of the probe * @param argsTypes a list of type for the argument * @param argsValues a list of value for the argument * @return the generated element for this probe */ public JrdsElement addProbe(JrdsElement hostElement, String probe, List<String> argsTypes, List<String> argsValues, Map<String, String> beans) { return addProbe(hostElement, probe, null, argsTypes, argsValues, beans); }
public void doHtmlDiscoverFields(JrdsDocument document) { try { List<FieldInfo> fields = getFields(); log(Level.DEBUG, "Fields: %s", fields); JrdsElement localRoot = document.getRootElement().addElement("div"); for(FieldInfo f: fields) { f.dojoType.doNode(localRoot, f); } } catch (DOMException e) { log(Level.ERROR, e, "Invalid DOM: %s", e); } }
da.setTimeout(getPropertiesManager().timeout); try { if(da.exist(hostname, request)) { da.addConnection(hostEleme, request); da.discoverPre(hostname, hostEleme, probdescs, request); for(String probeDescName: probeDescsName) { JrdsDocument probeDescDocument = probdescs.get(probeDescName); valid |= c.isAssignableFrom(summary.clazz); if(valid && da.isGoodProbeDesc(summary)) { da.addProbe(hostEleme, summary, request); da.discoverPost(hostname, hostEleme, probdescs, request);
@Override protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException { DocumentBuilder dbuilder; try { dbuilder = DocumentBuilderFactory.newInstance().newDocumentBuilder(); JrdsDocument hostDom = new JrdsDocument(dbuilder.newDocument()); hostDom.doRootElement("div"); for(DiscoverAgent da: getHostsList().getDiscoverAgent()) { logger.debug(jrds.Util.delayedFormatString("Adding discover agent %s", da)); da.doHtmlDiscoverFields(hostDom); } resp.setContentType(CONTENT_TYPE); Map<String, String> prop = new HashMap<String, String>(1); prop.put(OutputKeys.OMIT_XML_DECLARATION, "no"); prop.put(OutputKeys.INDENT, "yes"); prop.put("{http://xml.apache.org/xslt}indent-amount", "4"); Util.serialize(hostDom, resp.getOutputStream(), null, prop); } catch (ParserConfigurationException e) { resp.sendError(HttpServletResponse.SC_INTERNAL_SERVER_ERROR, "Parser configuration error"); } catch (TransformerException e) { resp.sendError(HttpServletResponse.SC_INTERNAL_SERVER_ERROR, "Transformer exception error"); } }
@Override public void discoverPre(String hostname, JrdsElement hostEleme, Map<String, JrdsDocument> probdescs, HttpServletRequest request) { super.discoverPre(hostname, hostEleme, probdescs, request);
for(Class<? extends DiscoverAgent> daClass: daList) { DiscoverAgent da = daClass.getConstructor().newInstance(); da.doHtmlDiscoverFields(doc);
/** * This method add a probe to the current host document * * @param hostElement the host element * @param probe the Name of the probe * @param label the label of the probe * @param argsTypes a list of type for the argument * @param argsValues a list of value for the argument * @return the generated element for this probe */ public JrdsElement addProbe(JrdsElement hostElement, String probe, String label, List<String> argsTypes, List<String> argsValues, Map<String, String> beans) { JrdsElement probeElement = hostElement.addElement("probe"); probeElement.setAttribute("type", probe); addArgsList(probeElement, argsTypes, argsValues, beans); if(label != null) { probeElement.setAttribute("label", label); } return probeElement; }