/** * Get base URL for Jolokia requests * * @return the Jolokia URL */ public URI getUri() { return requestHandler.getJ4pServerUrl(); }
/** * Return the list of MBean names as strings * * @return list of MBean names or an empty list */ public List<String> getMBeanNames() { return getValue(); } }
/** * Get the request/response type * * @return type */ public J4pType getType() { return request.getType(); }
/** {@inheritDoc} */ @Override List<String> getRequestParts() { if (hasSingleAttribute()) { List<String> ret = super.getRequestParts(); ret.add(getAttribute()); addPath(ret,path); return ret; } else if (hasAllAttributes() && path == null) { return super.getRequestParts(); } // A GET request cant be used for multiple attribute fetching or for fetching // all attributes with a path return null; }
private JSONObject getJsonRequestContent(J4pRequest pRequest) { JSONObject requestContent = pRequest.toJson(); if (defaultTargetConfig != null && pRequest.getTargetConfig() == null) { requestContent.put("target", defaultTargetConfig.toJson()); } return requestContent; }
@Override List<String> getRequestParts() { List<String> parts = super.getRequestParts(); parts.add(attribute); parts.add(serializeArgumentToRequestPart(value)); addPath(parts,path); return parts; }
@Override JSONObject toJson() { JSONObject ret = super.toJson(); ret.put("attribute",attribute); ret.put("value",serializeArgumentToJson(value)); if (path != null) { ret.put("path",path); } return ret; }
/** {@inheritDoc} */ @Override List<String> getRequestParts() { List<String> ret = super.getRequestParts(); ret.add(operation); if (arguments.size() > 0) { for (int i = 0; i < arguments.size(); i++) { ret.add(serializeArgumentToRequestPart(arguments.get(i))); } } return ret; }
J4pVersionResponse(J4pVersionRequest pRequest, JSONObject pResponse) { super(pRequest,pResponse); JSONObject value = (JSONObject) getValue(); agentVersion = (String) value.get("agent"); protocolVersion = (String) value.get("protocol"); info = (JSONObject) value.get("info"); if (info == null) { info = new JSONObject(); } }
/** {@inheritDoc} */ @Override J4pReadResponse createResponse(JSONObject pResponse) { return new J4pReadResponse(this,pResponse); }
/** {@inheritDoc} */ @Override J4pVersionResponse createResponse(JSONObject pResponse) { return new J4pVersionResponse(this,pResponse); }
/** {@inheritDoc} */ @Override J4pExecResponse createResponse(JSONObject pResponse) { return new J4pExecResponse(this,pResponse); }
@Override J4pSearchResponse createResponse(JSONObject pResponse) { return new J4pSearchResponse(this,pResponse); } }
@Override J4pListResponse createResponse(JSONObject pResponse) { return new J4pListResponse(this,pResponse); }
private boolean doUseProxy(J4pRequest pRequest) { return defaultTargetConfig != null || pRequest.getTargetConfig() != null; }
/** * Constructor using a path to restrict the information * returned by the list command * * @param pConfig proxy target configuration or <code>null</code> if no proxy should be used * @param pPath path into the JSON response. The path <strong>must already be * properly escaped</strong> when it contains slashes or exclamation marks. * You can use {@link #escape(String)} in order to escape a single path element. */ public J4pListRequest(J4pTargetConfig pConfig, String pPath) { super(J4pType.LIST,pConfig); pathElements = splitPath(pPath); }
@Override J4pWriteResponse createResponse(JSONObject pResponse) { return new J4pWriteResponse(this,pResponse); }
private String getArrayForArgument(Object[] pArg) { StringBuilder inner = new StringBuilder(); for (int i = 0; i< pArg.length; i++) { inner.append(nullEscape(pArg[i])); if (i < pArg.length - 1) { inner.append(","); } } return inner.toString(); }
private Object serializeCollection(Collection pArg) { JSONArray array = new JSONArray(); for (Object value : ((Collection) pArg)) { array.add(serializeArgumentToJson(value)); } return array; }