use of org.glassfish.admingui.connector.IntegrationPoint in project Payara by payara.
the class PluginHandlers method includeIntegrations.
/**
* <p> This handler adds {@link IntegrationPoint}s of a given type to a
* <code>UIComponent</code> tree. It looks for
* {@link IntegrationPoint}s using the given <code>type</code>. It
* then sorts the results (if any) by <code>parentId</code>, and then
* by priority. It next interates over each one looking for a
* <code>UIComponent</code> with an <code>id</code> which matches the
* its own <code>parentId</code> value. It then uses the content of
* the {@link IntegrationPoint} to attempt to include the .jsf page
* it refers to under the identified parent component.</p>
*/
@Handler(id = "includeIntegrations", input = { @HandlerInput(name = "type", type = String.class, required = true), @HandlerInput(name = "root", type = UIComponent.class, required = false) })
public static void includeIntegrations(HandlerContext handlerCtx) {
// Get the input
String type = (String) handlerCtx.getInputValue("type");
UIComponent root = (UIComponent) handlerCtx.getInputValue("root");
try {
// Get the IntegrationPoints
FacesContext ctx = handlerCtx.getFacesContext();
List<IntegrationPoint> points = getIntegrationPoints(ctx, type);
// Include them
includeIntegrationPoints(ctx, root, getSortedIntegrationPoints(points));
} catch (Exception ex) {
GuiUtil.getLogger().severe("Error in includeIntegrations ; \ntype = " + type + "; root=" + root.toString());
if (GuiUtil.getLogger().isLoggable(Level.FINE)) {
ex.printStackTrace();
}
}
}
use of org.glassfish.admingui.connector.IntegrationPoint in project Payara by payara.
the class PluginHandlers method getAppEditIntegrationPoint.
@Handler(id = "getAppEditIntegrationPoint", input = { @HandlerInput(name = "type", type = String.class, required = true) }, output = { @HandlerOutput(name = "appEditPageMap", type = Map.class) })
public static void getAppEditIntegrationPoint(HandlerContext handlerCtx) throws java.io.IOException {
// Get the input
String type = (String) handlerCtx.getInputValue("type");
// Get the IntegrationPoints
FacesContext ctx = handlerCtx.getFacesContext();
Set<IntegrationPoint> points = getSortedIntegrationPoints(getIntegrationPoints(ctx, type));
Map result = new HashMap();
if (points != null) {
for (IntegrationPoint it : points) {
String content = it.getContent();
if (GuiUtil.isEmpty(content)) {
GuiUtil.getLogger().warning("No Content specified for Integration Point: " + type + " id : " + it.getId());
continue;
}
List<String> vv = GuiUtil.parseStringList(content, ":");
if (vv.size() != 2) {
GuiUtil.getLogger().warning("Invalid content specified for Integration Point: " + type + " id : " + it.getId());
continue;
}
result.put(vv.get(0), vv.get(1));
}
}
handlerCtx.setOutputValue("appEditPageMap", result);
}
use of org.glassfish.admingui.connector.IntegrationPoint in project Payara by payara.
the class ThemeHandlers method getThemeFromIntegrationPoints.
/**
* <p> This method gets the <code>themeName</code> and <code>themeVersion</code>
* via <code>Integration Point</code>. If more than one is provided
* the one with the lowest <code>priority</code> number will be used.
* This method should be invoked before the theme is
* accessed (for example on the initPage or beforeCreate of the login page).</p>
*/
@Handler(id = "getThemeFromIntegrationPoints", output = { @HandlerOutput(name = "themeContext", type = ThemeContext.class) })
public static void getThemeFromIntegrationPoints(HandlerContext handlerCtx) {
FacesContext ctx = handlerCtx.getFacesContext();
String type = "org.glassfish.admingui:customtheme";
List<IntegrationPoint> ipList = PluginHandlers.getIntegrationPoints(ctx, type);
if (ipList != null) {
// if more than one integration point is provided then we
// need to find the lowest priority number
int lowest = getLowestPriorityNum(ipList);
for (IntegrationPoint ip : ipList) {
int priority = ip.getPriority();
if (priority == lowest) {
String content = ip.getContent();
if (content == null || content.equals("")) {
throw new IllegalArgumentException("No Properties File Name Provided!");
}
ClassLoader pluginCL = ConsoleClassLoader.findModuleClassLoader(ip.getConsoleConfigId());
URL propertyFileURL = pluginCL.getResource("/" + content);
try {
Properties propertyMap = new Properties();
propertyMap.load(propertyFileURL.openStream());
ThemeContext themeContext = AdminguiThemeContext.getInstance(ctx, propertyMap);
themeContext.setDefaultClassLoader(pluginCL);
handlerCtx.setOutputValue("themeContext", themeContext);
} catch (Exception ex) {
throw new RuntimeException("Unable to access properties file '" + content + "'!", ex);
}
}
}
}
}
Aggregations