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;
}
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);
}
Aggregations