
org.glassfish.admingui.common.handlers.InstanceHandler Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of console-common Show documentation
Show all versions of console-common Show documentation
This bundle contains common code that may be shared across plugins.
The newest version!
/*
* Copyright (c) 1997, 2018 Oracle and/or its affiliates. All rights reserved.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v. 2.0, which is available at
* http://www.eclipse.org/legal/epl-2.0.
*
* This Source Code may also be made available under the following Secondary
* Licenses when the conditions for such availability set forth in the
* Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
* version 2 with the GNU Classpath Exception, which is available at
* https://www.gnu.org/software/classpath/license.html.
*
* SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
*/
/*
* InstanceHandler.java
*
* Created on August 10, 2006, 2:32 PM
*
* To change this template, choose Tools | Template Manager
* and open the template in the editor.
*/
/**
*
* @author anilam
*/
package org.glassfish.admingui.common.handlers;
import com.sun.jsftemplating.annotation.Handler;
import com.sun.jsftemplating.annotation.HandlerInput;
import com.sun.jsftemplating.annotation.HandlerOutput;
import com.sun.jsftemplating.layout.descriptors.handler.HandlerContext;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.logging.Level;
import org.glassfish.admingui.common.util.GuiUtil;
import org.glassfish.admingui.common.util.RestUtil;
public class InstanceHandler {
/** Creates a new instance of InstanceHandler */
public InstanceHandler() {
}
@Handler(id="getJvmOptionsValues",
input={
@HandlerInput(name="endpoint", type=String.class, required=true),
@HandlerInput(name="attrs", type=Map.class, required=false)
},
output={
@HandlerOutput(name="result", type=java.util.List.class)})
public static void getJvmOptionsValues(HandlerContext handlerCtx) {
try{
ArrayList list = getJvmOptions(handlerCtx);
handlerCtx.setOutputValue("result", GuiUtil.convertArrayToListOfMap(list.toArray(), "value"));
}catch (Exception ex){
handlerCtx.setOutputValue("result", new HashMap());
GuiUtil.getLogger().info(GuiUtil.getCommonMessage("log.error.getJvmOptionsValues") + ex.getLocalizedMessage());
if (GuiUtil.getLogger().isLoggable(Level.FINE)){
ex.printStackTrace();
}
}
}
public static ArrayList getJvmOptions(HandlerContext handlerCtx) {
ArrayList list;
String endpoint = (String) handlerCtx.getInputValue("endpoint");
if (!endpoint.endsWith(".json"))
endpoint = endpoint + ".json";
Map attrs = (Map) handlerCtx.getInputValue("attrs");
Map result = (HashMap) RestUtil.restRequest(endpoint, attrs, "get", handlerCtx, false).get("data");
list = (ArrayList) ((Map) result.get("extraProperties")).get("leafList");
if (list == null)
list = new ArrayList();
return list;
}
@Handler(id="saveJvmOptionValues",
input={
@HandlerInput(name="endpoint", type=String.class, required=true),
@HandlerInput(name="target", type=String.class, required=true),
@HandlerInput(name="attrs", type=Map.class, required=false),
@HandlerInput(name="profiler", type=String.class, required=true),
@HandlerInput(name="options", type=List.class),
@HandlerInput(name="deleteProfileEndpoint", type=String.class),
@HandlerInput(name="origList", type=List.class)
} )
public static void saveJvmOptionValues(HandlerContext handlerCtx) {
String endpoint = (String) handlerCtx.getInputValue("endpoint");
String target = (String) handlerCtx.getInputValue("target");
try {
List
© 2015 - 2025 Weber Informatics LLC | Privacy Policy