You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tomcat.apache.org by ma...@apache.org on 2020/01/14 21:12:32 UTC
[tomcat] branch 7.0.x updated: Additional alignment with 8.5.x
This is an automated email from the ASF dual-hosted git repository.
markt pushed a commit to branch 7.0.x
in repository https://gitbox.apache.org/repos/asf/tomcat.git
The following commit(s) were added to refs/heads/7.0.x by this push:
new 6213bba Additional alignment with 8.5.x
6213bba is described below
commit 6213bba16f056c05b7c72c29b703f4c137bd6ee7
Author: Mark Thomas <ma...@apache.org>
AuthorDate: Tue Jan 14 21:11:39 2020 +0000
Additional alignment with 8.5.x
---
.../apache/catalina/manager/JMXProxyServlet.java | 83 ++++++++++------------
1 file changed, 39 insertions(+), 44 deletions(-)
diff --git a/java/org/apache/catalina/manager/JMXProxyServlet.java b/java/org/apache/catalina/manager/JMXProxyServlet.java
index ab77a3e..d6eeb70 100644
--- a/java/org/apache/catalina/manager/JMXProxyServlet.java
+++ b/java/org/apache/catalina/manager/JMXProxyServlet.java
@@ -41,8 +41,8 @@ import org.apache.catalina.tribes.util.StringManager;
import org.apache.tomcat.util.modeler.Registry;
/**
- * This servlet will dump JMX attributes in a simple format
- * and implement proxy services for modeler.
+ * This servlet will dump JMX attributes in a simple format and implement proxy
+ * services for modeler.
*
* @author Costin Manolache
*/
@@ -86,10 +86,8 @@ public class JMXProxyServlet extends HttpServlet {
* @exception ServletException if a servlet-specified error occurs
*/
@Override
- public void doGet(HttpServletRequest request,
- HttpServletResponse response)
- throws IOException, ServletException
- {
+ public void doGet(HttpServletRequest request, HttpServletResponse response)
+ throws IOException, ServletException {
response.setContentType("text/plain");
// Stop older versions of IE thinking they know best. We set text/plain
// in the line above for a reason. IE's behaviour is unwanted at best
@@ -97,38 +95,38 @@ public class JMXProxyServlet extends HttpServlet {
response.setHeader("X-Content-Type-Options", "nosniff");
PrintWriter writer = response.getWriter();
- if( mBeanServer==null ) {
+ if (mBeanServer == null) {
writer.println("Error - No mbean server");
return;
}
- String qry=request.getParameter("set");
- if( qry!= null ) {
- String name=request.getParameter("att");
- String val=request.getParameter("val");
+ String qry = request.getParameter("set");
+ if (qry != null) {
+ String name = request.getParameter("att");
+ String val = request.getParameter("val");
- setAttribute( writer, qry, name, val );
+ setAttribute(writer, qry, name, val);
return;
}
- qry=request.getParameter("get");
- if( qry!= null ) {
- String name=request.getParameter("att");
- getAttribute( writer, qry, name, request.getParameter("key") );
+ qry = request.getParameter("get");
+ if (qry != null) {
+ String name = request.getParameter("att");
+ getAttribute(writer, qry, name, request.getParameter("key"));
return;
}
qry = request.getParameter("invoke");
- if(qry != null) {
- String opName=request.getParameter("op");
+ if (qry != null) {
+ String opName = request.getParameter("op");
String[] params = getInvokeParameters(request.getParameter("ps"));
invokeOperation(writer, qry, opName, params);
return;
}
- qry=request.getParameter("qry");
- if( qry == null ) {
+ qry = request.getParameter("qry");
+ if (qry == null) {
qry = "*:*";
}
- listBeans( writer, qry );
+ listBeans(writer, qry);
}
@@ -137,8 +135,8 @@ public class JMXProxyServlet extends HttpServlet {
ObjectName oname = new ObjectName(onameStr);
Object value = mBeanServer.getAttribute(oname, att);
- if(null != key && value instanceof CompositeData)
- value = ((CompositeData)value).get(key);
+ if (null != key && value instanceof CompositeData)
+ value = ((CompositeData) value).get(key);
String valueStr;
if (value != null) {
@@ -152,7 +150,7 @@ public class JMXProxyServlet extends HttpServlet {
writer.print("' - ");
writer.print(att);
- if(null != key) {
+ if (null != key) {
writer.print(" - key '");
writer.print(key);
writer.print("'");
@@ -167,24 +165,23 @@ public class JMXProxyServlet extends HttpServlet {
}
}
- public void setAttribute( PrintWriter writer,
- String onameStr, String att, String val )
- {
+
+ public void setAttribute(PrintWriter writer, String onameStr, String att, String val) {
try {
setAttributeInternal(onameStr, att, val);
writer.println("OK - Attribute set");
- } catch( Exception ex ) {
+ } catch (Exception ex) {
writer.println("Error - " + ex.toString());
ex.printStackTrace(writer);
}
}
- public void listBeans( PrintWriter writer, String qry )
- {
+
+ public void listBeans(PrintWriter writer, String qry) {
Set<ObjectName> names = null;
try {
- names=mBeanServer.queryNames(new ObjectName(qry), null);
+ names = mBeanServer.queryNames(new ObjectName(qry), null);
writer.println("OK - Number of results: " + names.size());
writer.println();
} catch (Exception ex) {
@@ -201,8 +198,8 @@ public class JMXProxyServlet extends HttpServlet {
/**
* Determines if a type is supported by the {@link JMXProxyServlet}.
*
- * @param type The type to check
- * @return Always returns <code>true</code>
+ * @param type The type to check
+ * @return Always returns <code>true</code>
*/
public boolean isSupported(String type) {
return true;
@@ -219,7 +216,7 @@ public class JMXProxyServlet extends HttpServlet {
} else {
writer.println("OK - Operation " + op + " without return value");
}
- } catch( Exception ex ) {
+ } catch (Exception ex) {
writer.println("Error - " + ex.toString());
ex.printStackTrace(writer);
}
@@ -230,8 +227,8 @@ public class JMXProxyServlet extends HttpServlet {
* Parses parameter values from a parameter string.
*
* @param paramString The string containing comma-separated
- * operation-invocation parameters, or
- * <code>null</code> if there are no parameters.
+ * operation-invocation parameters, or <code>null</code> if there
+ * are no parameters.
* @return An array of String parameters (empty array if
* <code>paramString</code> was <code>null</code>).
*/
@@ -246,14 +243,12 @@ public class JMXProxyServlet extends HttpServlet {
/**
* Sets an MBean attribute's value.
*/
- private void setAttributeInternal(String onameStr,
- String attributeName,
- String value)
- throws OperationsException, MBeanException, ReflectionException {
- ObjectName oname=new ObjectName( onameStr );
- String type=registry.getType(oname, attributeName);
- Object valueObj=registry.convertValue(type, value );
- mBeanServer.setAttribute( oname, new Attribute(attributeName, valueObj));
+ private void setAttributeInternal(String onameStr, String attributeName, String value)
+ throws OperationsException, MBeanException, ReflectionException {
+ ObjectName oname = new ObjectName(onameStr);
+ String type = registry.getType(oname, attributeName);
+ Object valueObj = registry.convertValue(type, value);
+ mBeanServer.setAttribute(oname, new Attribute(attributeName, valueObj));
}
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org