[jboss-cvs] JBossAS SVN: r71315 - in trunk/varia/src: resources/jmx/html and 1 other directory.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Wed Mar 26 15:52:05 EDT 2008
Author: TobiasF
Date: 2008-03-26 15:52:05 -0400 (Wed, 26 Mar 2008)
New Revision: 71315
Modified:
trunk/varia/src/main/org/jboss/jmx/adaptor/html/HtmlAdaptorServlet.java
trunk/varia/src/resources/jmx/html/displayMBeans.jsp
trunk/varia/src/resources/jmx/html/style_master.css
Log:
JBAS-3406 malformed filter Strings now lead to a proper error message in the jmx-console instead of a 500
Modified: trunk/varia/src/main/org/jboss/jmx/adaptor/html/HtmlAdaptorServlet.java
===================================================================
--- trunk/varia/src/main/org/jboss/jmx/adaptor/html/HtmlAdaptorServlet.java 2008-03-26 19:47:38 UTC (rev 71314)
+++ trunk/varia/src/main/org/jboss/jmx/adaptor/html/HtmlAdaptorServlet.java 2008-03-26 19:52:05 UTC (rev 71315)
@@ -102,95 +102,111 @@
invokeOpByName(request, response);
}
- /** Display all mbeans categorized by domain
+ /**
+ * Display all mbeans categorized by domain
*/
- private void displayMBeans(HttpServletRequest request, HttpServletResponse response)
- throws ServletException, IOException
+ private void displayMBeans(HttpServletRequest request, HttpServletResponse response) throws ServletException,
+ IOException
{
- // get ObjectName filter from request or session context
- HttpSession session = request.getSession(false);
- String filter = request.getParameter(FILTER_PARAM);
+ // get ObjectName filter from request or session context
+ HttpSession session = request.getSession(false);
+ String filter = request.getParameter(FILTER_PARAM);
- if( filter == null && session != null)
+ if (filter == null && session != null)
{
// try using previously provided filter from session context
- filter = (String) session.getAttribute(FILTER_PARAM);
+ filter = (String) session.getAttribute(FILTER_PARAM);
}
-
- if( filter != null && filter.length() > 0 )
+
+ if (filter != null && filter.length() > 0)
{
// Strip any enclosing quotes
- if( filter.charAt(0) == '"' )
+ if (filter.charAt(0) == '"')
filter = filter.substring(1);
- if( filter.charAt(filter.length()-1) == '"')
- filter = filter.substring(0, filter.length()-2);
+ if (filter.charAt(filter.length() - 1) == '"')
+ filter = filter.substring(0, filter.length() - 2);
- // be a litte it tolerant to user input
+ // be a litte it tolerant to user input
String domain = "*";
- String props = "*,*";
+ String props = "*,*";
- int separator = filter.indexOf(':');
+ int separator = filter.indexOf(':');
int assignment = filter.indexOf('=');
if (separator == -1 && assignment != -1)
- {
- // assume properties only
+ {
+ // assume properties only
props = filter.trim();
}
- else if (separator == -1 && assignment == -1)
+ else if (separator == -1 && assignment == -1)
{
- // assume domain name only
- domain = filter.trim();
+ // assume domain name only
+ domain = filter.trim();
}
else
{
- // domain and properties
- domain = filter.substring(0,separator).trim();
- props = filter.substring(separator+1).trim();
- }
+ // domain and properties
+ domain = filter.substring(0, separator).trim();
+ props = filter.substring(separator + 1).trim();
+ }
- if (domain.equals("")) domain = "*";
+ if (domain.equals(""))
+ domain = "*";
- if ( props.equals("") ) props = "*,*";
- if ( props.endsWith("," )) props += "*";
- if (!props.endsWith(",*")) props += ",*";
- if ( props.equals("*,*" )) props = "*";
+ if (props.equals(""))
+ props = "*,*";
+ if (props.endsWith(","))
+ props += "*";
+ if (!props.endsWith(",*"))
+ props += ",*";
+ if (props.equals("*,*"))
+ props = "*";
filter = domain + ":" + props;;
- if (filter.equals("*:*"))
- filter = "";
+ if (filter.equals("*:*"))
+ filter = "";
}
- else
- {
- filter = "";
+ else
+ {
+ filter = "";
}
- // update request filter and store filter in session context,
- // so it can be used when no filter has been submitted in
- // current request
+ // update request filter and store filter in session context,
+ // so it can be used when no filter has been submitted in
+ // current request
request.setAttribute(FILTER_PARAM, filter);
- if( session != null )
- {
- session.setAttribute(FILTER_PARAM, filter);
- }
+ if (session != null)
+ {
+ session.setAttribute(FILTER_PARAM, filter);
+ }
+ Iterator mbeans;
try
{
- Iterator mbeans = Server.getDomainData(filter);
- request.setAttribute("mbeans", mbeans);
- RequestDispatcher rd = this.getServletContext().getRequestDispatcher("/displayMBeans.jsp");
- rd.forward(request, response);
+ mbeans = Server.getDomainData(filter);
}
- catch(JMException e)
+ catch (JMException e)
{
- throw new ServletException("Failed to get MBeans", e);
+ request.setAttribute("filterError", e.getMessage());
+ try
+ {
+ mbeans = Server.getDomainData("");
+ }
+ catch (JMException e1)
+ {
+ throw new ServletException("Failed to get MBeans", e);
+ }
}
+ request.setAttribute("mbeans", mbeans);
+ RequestDispatcher rd = this.getServletContext().getRequestDispatcher("/displayMBeans.jsp");
+ rd.forward(request, response);
}
- /** Display an mbeans attributes and operations
- */
+ /**
+ * Display an mbeans attributes and operations
+ */
private void inspectMBean(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException
{
Modified: trunk/varia/src/resources/jmx/html/displayMBeans.jsp
===================================================================
--- trunk/varia/src/resources/jmx/html/displayMBeans.jsp 2008-03-26 19:47:38 UTC (rev 71314)
+++ trunk/varia/src/resources/jmx/html/displayMBeans.jsp 2008-03-26 19:52:05 UTC (rev 71315)
@@ -14,46 +14,48 @@
<body>
<img src="images/logo.gif" align="right" border="0" alt="logo" />
<%
- String hostname = "";
- try
- {
- hostname = InetAddress.getLocalHost().getHostName();
- }
- catch(IOException e) {}
+ String hostname = "";
+ try {
+ hostname = InetAddress.getLocalHost().getHostName();
+ } catch (IOException e) {
+ }
%>
<h1>JMX Agent View</h1>
- <h3><%= hostname %></h3>
+ <h3><%=hostname%></h3>
<form action="HtmlAdaptor?action=displayMBeans" method="post" name="applyFilter" id="applyFilter">
ObjectName Filter (e.g. "jboss:*", "*:service=invoker,*"): <br />
-<input type="text" name="filter" size="40" value="<%= request.getAttribute("filter")%>" />
+<input type="text" name="filter" size="40" value="<%= request.getAttribute("filter")%>" /> <%
+ if (request.getAttribute("filterError") != null) {
+ out.println("<span class='error'>"+request.getAttribute("filterError")+"</span>");
+ }
+ %>
<br/>
<input type="submit" name="apply" value="Apply Filter" />
<input type="button" onClick="javascript:location='HtmlAdaptor?filter='" value="Clear Filter" />
<%
- for ( Iterator mbeans = (Iterator) request.getAttribute("mbeans"); mbeans.hasNext(); )
- {
- DomainData domainData = (DomainData) mbeans.next();
+ for (Iterator mbeans = (Iterator) request.getAttribute("mbeans"); mbeans
+ .hasNext();) {
+ DomainData domainData = (DomainData) mbeans.next();
%>
<h2 class='DomainName'>
- <a href="javascript:document.applyFilter.filter.value='<%= domainData.getDomainName() %>:*';document.applyFilter.submit()"><%= domainData.getDomainName() %></a>
+ <a href="javascript:document.applyFilter.filter.value='<%= domainData.getDomainName() %>:*';document.applyFilter.submit()"><%=domainData.getDomainName()%></a>
</h2>
<ul class='MBeanList'>
<%
- MBeanData[] data = domainData.getData();
- for(int d = 0; d < data.length; d ++)
- {
- String name = data[d].getObjectName().toString();
- String properties = data[d].getNameProperties();
+ MBeanData[] data = domainData.getData();
+ for (int d = 0; d < data.length; d++) {
+ String name = data[d].getObjectName().toString();
+ String properties = data[d].getNameProperties();
%>
- <li><a href="HtmlAdaptor?action=inspectMBean&name=<%= URLEncoder.encode(name) %>"><%= URLDecoder.decode(properties) %></a></li>
+ <li><a href="HtmlAdaptor?action=inspectMBean&name=<%= URLEncoder.encode(name) %>"><%=URLDecoder.decode(properties)%></a></li>
<%
- }
+ }
%>
</ul>
<%
- }
+ }
%>
</form>
Modified: trunk/varia/src/resources/jmx/html/style_master.css
===================================================================
--- trunk/varia/src/resources/jmx/html/style_master.css 2008-03-26 19:47:38 UTC (rev 71314)
+++ trunk/varia/src/resources/jmx/html/style_master.css 2008-03-26 19:52:05 UTC (rev 71315)
@@ -60,6 +60,9 @@
color: navy;
font-style: oblique;
}
+* .error {
+ color: red;
+}
A:ACTIVE {
color:Red;
More information about the jboss-cvs-commits
mailing list