Search in sources :

Example 1 with GadgetModule

use of org.glassfish.admingui.connector.GadgetModule in project Payara by payara.

the class GadgetHandlers method getGadgetModule.

/**
 *	<p> This method returns a {@link GadgetModule} for the given URL.</p>
 */
public static GadgetModule getGadgetModule(URL url) {
    if (url == null) {
        return null;
    }
    // FIXME: Cache?
    // Get our parser...
    ConfigParser parser = new ConfigParser(GuiUtil.getHabitat());
    String id = null;
    // Read the document...
    DomDocument doc = parser.parse(url);
    // Get the GadgetModule
    GadgetModule module = (GadgetModule) doc.getRoot().get();
    return module;
}
Also used : GadgetModule(org.glassfish.admingui.connector.GadgetModule) ConfigParser(org.jvnet.hk2.config.ConfigParser) DomDocument(org.jvnet.hk2.config.DomDocument)

Example 2 with GadgetModule

use of org.glassfish.admingui.connector.GadgetModule in project Payara by payara.

the class GadgetHandlers method getGadgetModule.

/**
 *	<p> This handler returns a {@link GadgetModule} for the named
 *	    gadget.  The <code>name</code> should either be a complete URL,
 *	    or a context-root relative path to the gadget XML file (this
 *	    also includes .xml files stored in .jar's / plugins).</p>
 */
@Handler(id = "gf.getGadgetModule", input = { @HandlerInput(name = "name", type = String.class, required = true) }, output = { @HandlerOutput(name = "module", type = GadgetModule.class) })
public static void getGadgetModule(HandlerContext handlerCtx) {
    String gadgetName = (String) handlerCtx.getInputValue("name");
    URL url = null;
    try {
        if (!gadgetName.contains("://")) {
            // Treat as a path...
            url = FileUtil.searchForFile(gadgetName, null);
        }
        if (url == null) {
            url = new URL(gadgetName);
        }
    } catch (Exception ex) {
        throw new IllegalArgumentException("Cannot creaqte URL from '" + gadgetName + "'!", ex);
    }
    GadgetModule module = getGadgetModule(url);
    handlerCtx.setOutputValue("module", module);
}
Also used : GadgetModule(org.glassfish.admingui.connector.GadgetModule) URL(java.net.URL) UnsupportedEncodingException(java.io.UnsupportedEncodingException) Handler(com.sun.jsftemplating.annotation.Handler)

Aggregations

GadgetModule (org.glassfish.admingui.connector.GadgetModule)2 Handler (com.sun.jsftemplating.annotation.Handler)1 UnsupportedEncodingException (java.io.UnsupportedEncodingException)1 URL (java.net.URL)1 ConfigParser (org.jvnet.hk2.config.ConfigParser)1 DomDocument (org.jvnet.hk2.config.DomDocument)1