[jboss-cvs] JBossAS SVN: r87651 - in branches/Branch_5_x: profileservice/src/main/org/jboss/profileservice/web and 1 other directories.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Tue Apr 21 23:46:17 EDT 2009
Author: scott.stark at jboss.org
Date: 2009-04-21 23:46:17 -0400 (Tue, 21 Apr 2009)
New Revision: 87651
Added:
branches/Branch_5_x/profileservice/src/main/org/jboss/profileservice/web/
branches/Branch_5_x/profileservice/src/main/org/jboss/profileservice/web/DebugServlet.java
Modified:
branches/Branch_5_x/varia/src/resources/jmx/jmx-console-web.xml
Log:
JBAS-5992, a profileservice debug servlet
Added: branches/Branch_5_x/profileservice/src/main/org/jboss/profileservice/web/DebugServlet.java
===================================================================
--- branches/Branch_5_x/profileservice/src/main/org/jboss/profileservice/web/DebugServlet.java (rev 0)
+++ branches/Branch_5_x/profileservice/src/main/org/jboss/profileservice/web/DebugServlet.java 2009-04-22 03:46:17 UTC (rev 87651)
@@ -0,0 +1,162 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2009, Red Hat Middleware LLC, and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.profileservice.web;
+
+import java.io.IOException;
+import java.io.PrintWriter;
+import java.util.Arrays;
+import java.util.Map;
+import java.util.Set;
+
+import javax.annotation.Resource;
+import javax.naming.InitialContext;
+import javax.naming.NamingException;
+import javax.servlet.ServletConfig;
+import javax.servlet.ServletException;
+import javax.servlet.http.HttpServlet;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+import org.jboss.deployers.spi.management.ManagementView;
+import org.jboss.managed.api.ManagedComponent;
+import org.jboss.managed.api.ManagedDeployment;
+
+/**
+ * @author Scott.Stark at jboss.org
+ * @version $Revision:$
+ */
+public class DebugServlet extends HttpServlet
+{
+ private static final long serialVersionUID = 1;
+ @Resource(mappedName="java:ManagementView")
+ private ManagementView mgtView;
+ enum Operations {
+ listDeploymentTree,
+ listOperations
+ };
+
+
+ @Override
+ public void init(ServletConfig config) throws ServletException
+ {
+ super.init(config);
+ if(mgtView == null)
+ {
+ try
+ {
+ InitialContext ctx = new InitialContext();
+ mgtView = (ManagementView) ctx.lookup("java:ManagementView");
+ }
+ catch (NamingException e)
+ {
+ throw new ServletException("Failed to lookup ManagementView", e);
+ }
+ }
+ }
+
+ @Override
+ protected void doGet(HttpServletRequest req, HttpServletResponse resp)
+ throws ServletException, IOException
+ {
+ if(mgtView == null)
+ throw new ServletException("The ManagementView has not been injected");
+ String op = req.getParameter("op");
+ if(op == null)
+ op = "listOperations";
+ Operations theOP = Enum.valueOf(Operations.class, "listDeploymentTree");
+ String opResult = "";
+ super.log("op="+op);
+ switch(theOP)
+ {
+ case listDeploymentTree:
+ opResult = listDeploymentTree();
+ break;
+ case listOperations:
+ opResult = listOperations();
+ break;
+ default:
+ throw new ServletException("Unknown op: "+op+", valid ops: "+Operations.values());
+ }
+
+ PrintWriter pw = resp.getWriter();
+ pw.write("<h1>");
+ pw.write(theOP+" Results");
+ pw.write("</h1>");
+ pw.write("<pre>");
+ pw.write(opResult);
+ pw.write("</pre>");
+ }
+
+ protected String listDeploymentTree()
+ throws ServletException
+ {
+ StringBuilder tmp = new StringBuilder();
+ try
+ {
+ mgtView.load();
+ Set<String> names = mgtView.getDeploymentNames();
+ for(String name : names)
+ {
+ ManagedDeployment md = mgtView.getDeployment(name);
+ tmp.append("ManagedDeployment: ");
+ tmp.append(md.getName());
+ tmp.append('\n');
+ Map<String, ManagedComponent> mcs = md.getComponents();
+ if(mcs != null)
+ {
+ for(ManagedComponent mc : mcs.values())
+ {
+ tmp.append("+++ ManagedComponent(name=");
+ tmp.append(mc.getName());
+ tmp.append(", type=(");
+ tmp.append(mc.getType());
+ tmp.append("), compName=");
+ tmp.append(mc.getComponentName());
+ tmp.append(", attachment: ");
+ tmp.append(mc.getAttachmentName());
+ tmp.append("\n++++++ properties: ");
+ tmp.append(mc.getPropertyNames());
+ tmp.append('\n');
+ }
+ }
+ }
+ }
+ catch(Exception e)
+ {
+ throw new ServletException("listDeploymentTree failure", e);
+ }
+ return tmp.toString();
+ }
+ protected String listOperations()
+ {
+ StringBuilder tmp = new StringBuilder();
+ tmp.append("Available operations: ");
+ tmp.append("<ul>");
+ for(Operations op : Operations.values())
+ {
+ tmp.append("<li>");
+ tmp.append(op.name());
+ tmp.append("</li>\n");
+ }
+ return tmp.toString();
+ }
+}
Modified: branches/Branch_5_x/varia/src/resources/jmx/jmx-console-web.xml
===================================================================
--- branches/Branch_5_x/varia/src/resources/jmx/jmx-console-web.xml 2009-04-22 03:27:25 UTC (rev 87650)
+++ branches/Branch_5_x/varia/src/resources/jmx/jmx-console-web.xml 2009-04-22 03:46:17 UTC (rev 87651)
@@ -1,9 +1,9 @@
<?xml version="1.0"?>
-<!DOCTYPE web-app PUBLIC
- "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"
- "http://java.sun.com/dtd/web-app_2_3.dtd">
-
-<web-app>
+<web-app version="2.5"
+ xmlns="http://java.sun.com/xml/ns/javaee"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd">
+
<description>The standard web descriptor for the html adaptor</description>
<!--
<filter>
@@ -33,11 +33,11 @@
<servlet-name>ClusteredConsoleServlet</servlet-name>
<servlet-class>org.jboss.jmx.adaptor.html.ClusteredConsoleServlet</servlet-class>
<init-param>
+ <description>The JGroups protocol stack config</description>
<param-name>jgProps</param-name>
<param-value>UDP(ip_mcast=true;ip_ttl=16;loopback=false;mcast_addr=${jboss.partition.udpGroup:228.1.2.3};mcast_port=${jboss.jmxconsolepartition.mcast_port:46666}):
org.jboss.jmx.adaptor.control.FindView
</param-value>
- <description>The JGroups protocol stack config</description>
</init-param>
</servlet>
<servlet>
@@ -56,6 +56,10 @@
<servlet-name>ClusterView</servlet-name>
<jsp-file>/cluster/clusterView.jsp</jsp-file>
</servlet>
+ <servlet>
+ <servlet-name>ProfileServiceDebugServlet</servlet-name>
+ <servlet-class>org.jboss.profileservice.web.DebugServlet</servlet-class>
+ </servlet>
<servlet-mapping>
<servlet-name>HtmlAdaptor</servlet-name>
@@ -77,6 +81,10 @@
<servlet-name>DisplayOpResult</servlet-name>
<url-pattern>/DisplayOpResult</url-pattern>
</servlet-mapping>
+ <servlet-mapping>
+ <servlet-name>ProfileServiceDebugServlet</servlet-name>
+ <url-pattern>/ProfileServiceDebugServlet</url-pattern>
+ </servlet-mapping>
<!-- Display a generic error page when HTTP Status 500 exceptions
occur. -->
More information about the jboss-cvs-commits
mailing list