You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@servicemix.apache.org by ch...@apache.org on 2006/02/22 00:40:29 UTC

svn commit: r379627 [4/34] - in /incubator/servicemix/trunk: ./ etc/ sandbox/servicemix-wsn-1.2/src/sa/META-INF/ sandbox/servicemix-wsn-1.2/src/su/META-INF/ servicemix-assembly/ servicemix-assembly/src/main/assembly/ servicemix-assembly/src/main/releas...

Modified: incubator/servicemix/trunk/servicemix-assembly/src/main/release/examples/cluster/test-file.xml
URL: http://svn.apache.org/viewcvs/incubator/servicemix/trunk/servicemix-assembly/src/main/release/examples/cluster/test-file.xml?rev=379627&r1=379626&r2=379627&view=diff
==============================================================================
--- incubator/servicemix/trunk/servicemix-assembly/src/main/release/examples/cluster/test-file.xml (original)
+++ incubator/servicemix/trunk/servicemix-assembly/src/main/release/examples/cluster/test-file.xml Tue Feb 21 15:40:05 2006
@@ -1,5 +1,5 @@
-<sample id="555-3482">
-	<data>
-	   This is sample file that can be dropped into the ibox directory.
-	</data>
+<sample id="555-3482">
+	<data>
+	   This is sample file that can be dropped into the ibox directory.
+	</data>
 </sample>

Propchange: incubator/servicemix/trunk/servicemix-assembly/src/main/release/examples/cluster/test-file.xml
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: incubator/servicemix/trunk/servicemix-assembly/src/main/release/examples/loan-broker/src/sa/META-INF/DISCLAIMER.txt
URL: http://svn.apache.org/viewcvs/incubator/servicemix/trunk/servicemix-assembly/src/main/release/examples/loan-broker/src/sa/META-INF/DISCLAIMER.txt?rev=379627&r1=379626&r2=379627&view=diff
==============================================================================
--- incubator/servicemix/trunk/servicemix-assembly/src/main/release/examples/loan-broker/src/sa/META-INF/DISCLAIMER.txt (original)
+++ incubator/servicemix/trunk/servicemix-assembly/src/main/release/examples/loan-broker/src/sa/META-INF/DISCLAIMER.txt Tue Feb 21 15:40:05 2006
@@ -1,7 +1,7 @@
-ActiveMQ is an effort undergoing incubation at the Apache Software Foundation
-(ASF), sponsored by the Geronimo PMC. Incubation is required of all newly
-accepted projects until a further review indicates that the infrastructure,
-communications, and decision making process have stabilized in a manner
-consistent with other successful ASF projects. While incubation status is not
-necessarily a reflection of the completeness or stability of the code, it does
+ActiveMQ is an effort undergoing incubation at the Apache Software Foundation
+(ASF), sponsored by the Geronimo PMC. Incubation is required of all newly
+accepted projects until a further review indicates that the infrastructure,
+communications, and decision making process have stabilized in a manner
+consistent with other successful ASF projects. While incubation status is not
+necessarily a reflection of the completeness or stability of the code, it does
 indicate that the project has yet to be fully endorsed by the ASF.

Propchange: incubator/servicemix/trunk/servicemix-assembly/src/main/release/examples/loan-broker/src/sa/META-INF/DISCLAIMER.txt
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/servicemix/trunk/servicemix-assembly/src/main/release/examples/loan-broker/src/sa/META-INF/LICENSE.txt
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: incubator/servicemix/trunk/servicemix-assembly/src/main/release/examples/loan-broker/src/sa/META-INF/jbi.xml
URL: http://svn.apache.org/viewcvs/incubator/servicemix/trunk/servicemix-assembly/src/main/release/examples/loan-broker/src/sa/META-INF/jbi.xml?rev=379627&r1=379626&r2=379627&view=diff
==============================================================================
--- incubator/servicemix/trunk/servicemix-assembly/src/main/release/examples/loan-broker/src/sa/META-INF/jbi.xml (original)
+++ incubator/servicemix/trunk/servicemix-assembly/src/main/release/examples/loan-broker/src/sa/META-INF/jbi.xml Tue Feb 21 15:40:05 2006
@@ -1,21 +1,21 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<jbi xmlns="http://java.sun.com/xml/ns/jbi" version="1.0">
-     
-   <service-assembly>
-     <identification>
-       <name>loanbroker</name>
-       <description>LoanBroker Service Assembly</description>
-     </identification>
-     <service-unit>
-       <identification>
-         <name>loanbroker</name>
-         <description>LoanBroker Service Unit</description>
-       </identification>
-       <target>
-         <artifacts-zip>loanbroker-su.zip</artifacts-zip>
-         <component-name>servicemix-lwcontainer</component-name>
-       </target>
-     </service-unit>
-    </service-assembly>
-    
-</jbi>
+<?xml version="1.0" encoding="UTF-8"?>
+<jbi xmlns="http://java.sun.com/xml/ns/jbi" version="1.0">
+     
+   <service-assembly>
+     <identification>
+       <name>loanbroker</name>
+       <description>LoanBroker Service Assembly</description>
+     </identification>
+     <service-unit>
+       <identification>
+         <name>loanbroker</name>
+         <description>LoanBroker Service Unit</description>
+       </identification>
+       <target>
+         <artifacts-zip>loanbroker-su.zip</artifacts-zip>
+         <component-name>servicemix-lwcontainer</component-name>
+       </target>
+     </service-unit>
+    </service-assembly>
+    
+</jbi>

Propchange: incubator/servicemix/trunk/servicemix-assembly/src/main/release/examples/loan-broker/src/sa/META-INF/jbi.xml
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: incubator/servicemix/trunk/servicemix-assembly/src/main/release/examples/servicemix-web/src/main/java/org/apache/servicemix/components/HelloWorldComponent.java
URL: http://svn.apache.org/viewcvs/incubator/servicemix/trunk/servicemix-assembly/src/main/release/examples/servicemix-web/src/main/java/org/apache/servicemix/components/HelloWorldComponent.java?rev=379627&r1=379626&r2=379627&view=diff
==============================================================================
--- incubator/servicemix/trunk/servicemix-assembly/src/main/release/examples/servicemix-web/src/main/java/org/apache/servicemix/components/HelloWorldComponent.java (original)
+++ incubator/servicemix/trunk/servicemix-assembly/src/main/release/examples/servicemix-web/src/main/java/org/apache/servicemix/components/HelloWorldComponent.java Tue Feb 21 15:40:05 2006
@@ -1,28 +1,28 @@
-package org.apache.servicemix.components;
-
-import org.apache.servicemix.components.util.TransformComponentSupport;
-import org.apache.servicemix.jbi.jaxp.StringSource;
-
-import javax.jbi.messaging.MessageExchange;
-import javax.jbi.messaging.MessagingException;
-import javax.jbi.messaging.NormalizedMessage;
-
-public class HelloWorldComponent extends TransformComponentSupport {
-
-    private String property;
-    
-    protected boolean transform(MessageExchange exchange, NormalizedMessage in, NormalizedMessage out)
-            throws MessagingException {
-        out.setContent(new StringSource("<hello>" + in.getProperty(property) + "</hello>"));
-        return true;
-    }
-
-    public String getProperty() {
-        return property;
-    }
-
-    public void setProperty(String property) {
-        this.property = property;
-    }
-
-}
+package org.apache.servicemix.components;
+
+import org.apache.servicemix.components.util.TransformComponentSupport;
+import org.apache.servicemix.jbi.jaxp.StringSource;
+
+import javax.jbi.messaging.MessageExchange;
+import javax.jbi.messaging.MessagingException;
+import javax.jbi.messaging.NormalizedMessage;
+
+public class HelloWorldComponent extends TransformComponentSupport {
+
+    private String property;
+    
+    protected boolean transform(MessageExchange exchange, NormalizedMessage in, NormalizedMessage out)
+            throws MessagingException {
+        out.setContent(new StringSource("<hello>" + in.getProperty(property) + "</hello>"));
+        return true;
+    }
+
+    public String getProperty() {
+        return property;
+    }
+
+    public void setProperty(String property) {
+        this.property = property;
+    }
+
+}

Propchange: incubator/servicemix/trunk/servicemix-assembly/src/main/release/examples/servicemix-web/src/main/java/org/apache/servicemix/components/HelloWorldComponent.java
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: incubator/servicemix/trunk/servicemix-assembly/src/main/release/examples/servicemix-web/src/main/java/org/apache/servicemix/web/jmx/JMXServlet.java
URL: http://svn.apache.org/viewcvs/incubator/servicemix/trunk/servicemix-assembly/src/main/release/examples/servicemix-web/src/main/java/org/apache/servicemix/web/jmx/JMXServlet.java?rev=379627&r1=379626&r2=379627&view=diff
==============================================================================
--- incubator/servicemix/trunk/servicemix-assembly/src/main/release/examples/servicemix-web/src/main/java/org/apache/servicemix/web/jmx/JMXServlet.java (original)
+++ incubator/servicemix/trunk/servicemix-assembly/src/main/release/examples/servicemix-web/src/main/java/org/apache/servicemix/web/jmx/JMXServlet.java Tue Feb 21 15:40:05 2006
@@ -1,103 +1,103 @@
-/**
- * 
- * Copyright 2005 LogicBlaze, Inc. http://www.logicblaze.com
- * 
- * Licensed under the Apache License, Version 2.0 (the "License"); 
- * you may not use this file except in compliance with the License. 
- * You may obtain a copy of the License at 
- * 
- * http://www.apache.org/licenses/LICENSE-2.0
- * 
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS, 
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
- * See the License for the specific language governing permissions and 
- * limitations under the License. 
- * 
- **/
-
-package org.apache.servicemix.web.jmx;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-
-import javax.management.JMException;
-import javax.management.MBeanServer;
-import javax.management.ObjectName;
-import javax.management.QueryExp;
-import javax.servlet.ServletException;
-import javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.HttpServletResponse;
-
-import java.io.IOException;
-import java.util.Set;
-
-/**
- * Creates an XML response for one or more MBeans using an optional node in the
- * JMX tree or query parameters.
- * 
- * @version $Revision: 356269 $
- */
-public class JMXServlet extends JMXServletSupport {
-
-    private static final Log log = LogFactory.getLog(JMXServlet.class);
-    private static final long serialVersionUID = -5953322364144161756L;
-
-    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
-        try {
-            MBeanServer beanServer = getMBeanServer();
-            ObjectName name = getObjectName(request);
-            QueryExp query = getQueryExp(request);
-
-            JMXWriter writer = new JMXWriter(response.getWriter(), getManagementContext());
-
-            String style = request.getParameter("style");
-            String view = request.getParameter("view");
-            if (view == null) {
-                view = "";
-            }
-
-            if (style != null && style.equals("html")) {
-                Set names = beanServer.queryNames(name, query);
-
-                if (log.isDebugEnabled()) {
-                    log.debug("ObjectName: " + name);
-                    log.debug("Query: " + query);
-                    log.debug("Matches ObjectNames: " + names);
-                }
-
-                if (view.equals("properties")) {
-                    writer.outputHtmlProperties(names);
-                }
-                else if (view.equals("attributes")) {
-                    writer.outputHtmlAttributes(names);
-                }
-                else if (view.equals("flat")) {
-                    writer.outputHtmlNames(names);
-                }
-                else {
-                    writer.outputHtmlNamesByDomain(names);
-                }
-            }
-            else {
-                writer.outputHeader();
-                if (view.equals("bean")) {
-                    Set mbeans = beanServer.queryMBeans(name, query);
-                    writer.outputMBeans(mbeans);
-                }
-                else if (view.equals("detail")) {
-                    Set names = beanServer.queryNames(name, query);
-                    writer.outputDetail(names);
-                }
-                else {
-                    Set names = beanServer.queryNames(name, query);
-                    writer.outputNames(names);
-                }
-                writer.outputFooter();
-            }
-        }
-        catch (JMException e) {
-            throw new ServletException(e);
-        }
-    }
-}
+/**
+ * 
+ * Copyright 2005 LogicBlaze, Inc. http://www.logicblaze.com
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License"); 
+ * you may not use this file except in compliance with the License. 
+ * You may obtain a copy of the License at 
+ * 
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, 
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
+ * See the License for the specific language governing permissions and 
+ * limitations under the License. 
+ * 
+ **/
+
+package org.apache.servicemix.web.jmx;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+import javax.management.JMException;
+import javax.management.MBeanServer;
+import javax.management.ObjectName;
+import javax.management.QueryExp;
+import javax.servlet.ServletException;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+import java.io.IOException;
+import java.util.Set;
+
+/**
+ * Creates an XML response for one or more MBeans using an optional node in the
+ * JMX tree or query parameters.
+ * 
+ * @version $Revision: 356269 $
+ */
+public class JMXServlet extends JMXServletSupport {
+
+    private static final Log log = LogFactory.getLog(JMXServlet.class);
+    private static final long serialVersionUID = -5953322364144161756L;
+
+    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
+        try {
+            MBeanServer beanServer = getMBeanServer();
+            ObjectName name = getObjectName(request);
+            QueryExp query = getQueryExp(request);
+
+            JMXWriter writer = new JMXWriter(response.getWriter(), getManagementContext());
+
+            String style = request.getParameter("style");
+            String view = request.getParameter("view");
+            if (view == null) {
+                view = "";
+            }
+
+            if (style != null && style.equals("html")) {
+                Set names = beanServer.queryNames(name, query);
+
+                if (log.isDebugEnabled()) {
+                    log.debug("ObjectName: " + name);
+                    log.debug("Query: " + query);
+                    log.debug("Matches ObjectNames: " + names);
+                }
+
+                if (view.equals("properties")) {
+                    writer.outputHtmlProperties(names);
+                }
+                else if (view.equals("attributes")) {
+                    writer.outputHtmlAttributes(names);
+                }
+                else if (view.equals("flat")) {
+                    writer.outputHtmlNames(names);
+                }
+                else {
+                    writer.outputHtmlNamesByDomain(names);
+                }
+            }
+            else {
+                writer.outputHeader();
+                if (view.equals("bean")) {
+                    Set mbeans = beanServer.queryMBeans(name, query);
+                    writer.outputMBeans(mbeans);
+                }
+                else if (view.equals("detail")) {
+                    Set names = beanServer.queryNames(name, query);
+                    writer.outputDetail(names);
+                }
+                else {
+                    Set names = beanServer.queryNames(name, query);
+                    writer.outputNames(names);
+                }
+                writer.outputFooter();
+            }
+        }
+        catch (JMException e) {
+            throw new ServletException(e);
+        }
+    }
+}

Propchange: incubator/servicemix/trunk/servicemix-assembly/src/main/release/examples/servicemix-web/src/main/java/org/apache/servicemix/web/jmx/JMXServlet.java
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: incubator/servicemix/trunk/servicemix-assembly/src/main/release/examples/servicemix-web/src/main/java/org/apache/servicemix/web/jmx/JMXServletSupport.java
URL: http://svn.apache.org/viewcvs/incubator/servicemix/trunk/servicemix-assembly/src/main/release/examples/servicemix-web/src/main/java/org/apache/servicemix/web/jmx/JMXServletSupport.java?rev=379627&r1=379626&r2=379627&view=diff
==============================================================================
--- incubator/servicemix/trunk/servicemix-assembly/src/main/release/examples/servicemix-web/src/main/java/org/apache/servicemix/web/jmx/JMXServletSupport.java (original)
+++ incubator/servicemix/trunk/servicemix-assembly/src/main/release/examples/servicemix-web/src/main/java/org/apache/servicemix/web/jmx/JMXServletSupport.java Tue Feb 21 15:40:05 2006
@@ -1,98 +1,98 @@
-/**
- *
- * Copyright 2005 LogicBlaze, Inc. http://www.logicblaze.com
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- **/
-
-package org.apache.servicemix.web.jmx;
-
-import javax.management.MBeanServer;
-import javax.management.MalformedObjectNameException;
-import javax.management.ObjectName;
-import javax.management.QueryExp;
-import javax.servlet.ServletException;
-import javax.servlet.http.HttpServlet;
-import javax.servlet.http.HttpServletRequest;
-
-/**
- * A useful base class for any JMS related servlet; there are various ways to
- * map JMS operations to web requests so we put most of the common behaviour in
- * a reusable base class.
- *
- * @version $Revision: 356269 $
- */
-public abstract class JMXServletSupport extends HttpServlet {
-
-    protected static final String MANAGEMENT_CONTEXT_PROPERTY = "org.activemq.jmx.ManagementContext";
-
-    private ManagementContext managementContext;
-
-    public void init() throws ServletException {
-        if (managementContext == null) {
-            managementContext = (ManagementContext) getServletContext().getAttribute(MANAGEMENT_CONTEXT_PROPERTY);
-            if (managementContext == null) {
-                managementContext = new ManagementContext();
-            }
-        }
-    }
-
-    public MBeanServer getMBeanServer() {
-        return managementContext.getMBeanServer();
-    }
-
-    public ManagementContext getManagementContext() {
-        return managementContext;
-    }
-
-    public void setManagementContext(ManagementContext managementContext) {
-        this.managementContext = managementContext;
-    }
-
-    protected QueryExp getQueryExp(HttpServletRequest request) throws ServletException {
-        QueryExp answer = null;
-        String value = request.getParameter("query");
-        if (value != null) {
-            try {
-                answer = new ObjectName(value);
-            }
-            catch (MalformedObjectNameException e) {
-                throw new ServletException(e);
-            }
-        }
-        return answer;
-    }
-
-    protected ObjectName getObjectName(HttpServletRequest request) throws ServletException {
-        String value = request.getParameter("name");
-        ObjectName answer = null;
-        if (value != null) {
-            try {
-                answer = new ObjectName(value);
-            }
-            catch (MalformedObjectNameException e) {
-                throw new ServletException("Failed to parse object name: " + value + ". Reason: " + e, e);
-            }
-        }
-        return answer;
-    }
-
-    /**
-     * Converts the value of the named parameter into a boolean
-     */
-    protected boolean asBoolean(HttpServletRequest request, String name) {
-        String param = request.getParameter(name);
-        return param != null && param.equalsIgnoreCase("true");
-    }
-}
+/**
+ *
+ * Copyright 2005 LogicBlaze, Inc. http://www.logicblaze.com
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ **/
+
+package org.apache.servicemix.web.jmx;
+
+import javax.management.MBeanServer;
+import javax.management.MalformedObjectNameException;
+import javax.management.ObjectName;
+import javax.management.QueryExp;
+import javax.servlet.ServletException;
+import javax.servlet.http.HttpServlet;
+import javax.servlet.http.HttpServletRequest;
+
+/**
+ * A useful base class for any JMS related servlet; there are various ways to
+ * map JMS operations to web requests so we put most of the common behaviour in
+ * a reusable base class.
+ *
+ * @version $Revision: 356269 $
+ */
+public abstract class JMXServletSupport extends HttpServlet {
+
+    protected static final String MANAGEMENT_CONTEXT_PROPERTY = "org.activemq.jmx.ManagementContext";
+
+    private ManagementContext managementContext;
+
+    public void init() throws ServletException {
+        if (managementContext == null) {
+            managementContext = (ManagementContext) getServletContext().getAttribute(MANAGEMENT_CONTEXT_PROPERTY);
+            if (managementContext == null) {
+                managementContext = new ManagementContext();
+            }
+        }
+    }
+
+    public MBeanServer getMBeanServer() {
+        return managementContext.getMBeanServer();
+    }
+
+    public ManagementContext getManagementContext() {
+        return managementContext;
+    }
+
+    public void setManagementContext(ManagementContext managementContext) {
+        this.managementContext = managementContext;
+    }
+
+    protected QueryExp getQueryExp(HttpServletRequest request) throws ServletException {
+        QueryExp answer = null;
+        String value = request.getParameter("query");
+        if (value != null) {
+            try {
+                answer = new ObjectName(value);
+            }
+            catch (MalformedObjectNameException e) {
+                throw new ServletException(e);
+            }
+        }
+        return answer;
+    }
+
+    protected ObjectName getObjectName(HttpServletRequest request) throws ServletException {
+        String value = request.getParameter("name");
+        ObjectName answer = null;
+        if (value != null) {
+            try {
+                answer = new ObjectName(value);
+            }
+            catch (MalformedObjectNameException e) {
+                throw new ServletException("Failed to parse object name: " + value + ". Reason: " + e, e);
+            }
+        }
+        return answer;
+    }
+
+    /**
+     * Converts the value of the named parameter into a boolean
+     */
+    protected boolean asBoolean(HttpServletRequest request, String name) {
+        String param = request.getParameter(name);
+        return param != null && param.equalsIgnoreCase("true");
+    }
+}

Propchange: incubator/servicemix/trunk/servicemix-assembly/src/main/release/examples/servicemix-web/src/main/java/org/apache/servicemix/web/jmx/JMXServletSupport.java
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: incubator/servicemix/trunk/servicemix-assembly/src/main/release/examples/servicemix-web/src/main/java/org/apache/servicemix/web/jmx/JMXWriter.java
URL: http://svn.apache.org/viewcvs/incubator/servicemix/trunk/servicemix-assembly/src/main/release/examples/servicemix-web/src/main/java/org/apache/servicemix/web/jmx/JMXWriter.java?rev=379627&r1=379626&r2=379627&view=diff
==============================================================================
--- incubator/servicemix/trunk/servicemix-assembly/src/main/release/examples/servicemix-web/src/main/java/org/apache/servicemix/web/jmx/JMXWriter.java (original)
+++ incubator/servicemix/trunk/servicemix-assembly/src/main/release/examples/servicemix-web/src/main/java/org/apache/servicemix/web/jmx/JMXWriter.java Tue Feb 21 15:40:05 2006
@@ -1,569 +1,569 @@
-/**
- *
- * Copyright 2005 LogicBlaze, Inc. http://www.logicblaze.com
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- **/
-
-package org.apache.servicemix.web.jmx;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-
-import javax.management.AttributeNotFoundException;
-import javax.management.InstanceNotFoundException;
-import javax.management.JMException;
-import javax.management.MBeanAttributeInfo;
-import javax.management.MBeanException;
-import javax.management.MBeanInfo;
-import javax.management.MBeanServer;
-import javax.management.ObjectInstance;
-import javax.management.ObjectName;
-import javax.management.ReflectionException;
-
-import java.io.IOException;
-import java.io.PrintWriter;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.HashSet;
-import java.util.Hashtable;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-import java.util.TreeMap;
-import java.util.TreeSet;
-import java.util.Map.Entry;
-
-/**
- * A useful class for turning JMX statistics into XML and XHTML
- *
- * @version $Revision: 356269 $
- */
-public class JMXWriter {
-    private static final Log log = LogFactory.getLog(JMXWriter.class);
-
-    private PrintWriter writer;
-    private ManagementContext managementContext;
-    private String unknownValue = "Unknown";
-
-    public JMXWriter(PrintWriter writer, ManagementContext context) {
-        this.writer = writer;
-        managementContext = context;
-    }
-
-    public MBeanServer getMBeanServer() {
-        return managementContext.getMBeanServer();
-    }
-
-    public ManagementContext getManagementContext() {
-        return managementContext;
-    }
-
-    public void setManagementContext(ManagementContext managementContext) {
-        this.managementContext = managementContext;
-    }
-
-    public void outputHtmlNamesByDomain(Collection names) throws IOException {
-        Map map = new TreeMap();
-        for (Iterator iter = names.iterator(); iter.hasNext();) {
-            ObjectName name = (ObjectName) iter.next();
-            String domain = name.getDomain();
-            List list = (List) map.get(domain);
-            if (list == null) {
-                list = new ArrayList();
-                map.put(domain, list);
-            }
-            list.add(name);
-        }
-        for (Iterator iter = map.entrySet().iterator(); iter.hasNext();) {
-            Map.Entry entry = (Map.Entry) iter.next();
-            String domain = (String) entry.getKey();
-            names = (List) entry.getValue();
-
-            writer.print("<li>");
-            writer.print(domain);
-
-            writer.print("<ul>");
-            outputHtmlNamesByProperty(names, "type");
-            writer.print("</ul>");
-            writer.print("</li>");
-        }
-    }
-
-    public void outputHtmlNamesByProperty(Collection names, String property) throws IOException {
-        Map map = new TreeMap();
-        for (Iterator iter = names.iterator(); iter.hasNext();) {
-            ObjectName name = (ObjectName) iter.next();
-            String propertyValue = name.getKeyProperty(property);
-            if (propertyValue == null) {
-                propertyValue = unknownValue;
-            }
-            List list = (List) map.get(propertyValue);
-            if (list == null) {
-                list = new ArrayList();
-                map.put(propertyValue, list);
-            }
-            list.add(name);
-        }
-        for (Iterator iter = map.entrySet().iterator(); iter.hasNext();) {
-            Map.Entry entry = (Map.Entry) iter.next();
-            String propertyValue = (String) entry.getKey();
-            names = (List) entry.getValue();
-
-            if (names.size() > 1) {
-                writer.print("<li><a href='");
-                printDetailURL(property, propertyValue);
-                writer.print("'>");
-                writer.print(propertyValue);
-                writer.print("</a><ul>");
-
-                // outputHtmlNames(names);
-                outputHtmlNamesSortedByShortName(names);
-                writer.print("</ul>");
-                writer.print("</li>");
-            }
-            else if (names.size() == 1) {
-                ObjectName name = (ObjectName) ((List) names).get(0);
-                outputHtmlName(name, propertyValue);
-            }
-        }
-    }
-
-    public void outputHtmlNamesSortedByShortName(Collection names) throws IOException {
-        Map map = new TreeMap();
-        for (Iterator iter = names.iterator(); iter.hasNext();) {
-            ObjectName name = (ObjectName) iter.next();
-            String propertyValue = getShortName(name);
-            map.put(propertyValue, name);
-        }
-        for (Iterator iter = map.entrySet().iterator(); iter.hasNext();) {
-            Map.Entry entry = (Map.Entry) iter.next();
-            String description = (String) entry.getKey();
-            ObjectName name = (ObjectName) entry.getValue();
-            outputHtmlName(name, description);
-        }
-    }
-
-    public void outputHtmlNames(Collection names) throws IOException {
-        for (Iterator iter = names.iterator(); iter.hasNext();) {
-            outputHtmlNames((ObjectName) iter.next());
-        }
-    }
-
-    public void outputHtmlNames(ObjectName name) throws IOException {
-        outputHtmlName(name, getShortName(name));
-    }
-
-    public void outputHtmlName(ObjectName name, String shortName) throws IOException {
-        writer.print("<li><a href='");
-        printDetailURL(name);
-
-        /*
-         * Map properties = name.getKeyPropertyList(); for (Iterator iter =
-         * properties.entrySet().iterator(); iter.hasNext();) { Map.Entry entry =
-         * (Map.Entry) iter.next(); writer.print("<property name='");
-         * writer.print(entry.getKey()); writer.print("'>");
-         * writer.print(entry.getValue()); writer.println("</property>"); }
-         */
-
-        writer.print("'>");
-        // writer.print(name.getCanonicalKeyPropertyListString());
-        writer.print(shortName);
-        writer.print("</a></li>");
-    }
-
-    /**
-     * Returns a short descriptive name of the ObjectName without the domain
-     */
-    protected String getShortName(ObjectName name) {
-        // TODO Auto-generated method stub
-        String answer = name.toString();
-        int idx = answer.indexOf(':');
-        if (idx >= 0) {
-            return answer.substring(idx + 1);
-        }
-        return answer;
-    }
-
-    public void outputNames(Collection names) throws IOException {
-        for (Iterator iter = names.iterator(); iter.hasNext();) {
-            outputNames((ObjectName) iter.next());
-        }
-    }
-
-    public void outputNames(ObjectName name) throws IOException {
-        writer.print("<mbean name='");
-        writer.print(name.getCanonicalName());
-        writer.print("' domain='");
-        writer.print(name.getDomain());
-        writer.println("'>");
-        Map properties = name.getKeyPropertyList();
-        for (Iterator iter = properties.entrySet().iterator(); iter.hasNext();) {
-            Map.Entry entry = (Map.Entry) iter.next();
-            writer.print("<property name='");
-            writer.print(entry.getKey());
-            writer.print("'>");
-            writer.print(entry.getValue());
-            writer.println("</property>");
-        }
-        writer.println("</mbean>");
-    }
-
-    public void outputDetail(Set names) throws IOException, JMException {
-
-        for (Iterator iter = names.iterator(); iter.hasNext();) {
-            outputDetail((ObjectName) iter.next());
-        }
-    }
-
-    public void outputDetail(ObjectName name) throws JMException, IOException {
-
-        MBeanServer beanServer = getMBeanServer();
-        MBeanInfo beanInfo = beanServer.getMBeanInfo(name);
-        writer.print("<mbean name='");
-        writer.print(name.getCanonicalName());
-        writer.print("' domain='");
-        writer.print(name.getDomain());
-        writer.println("'>");
-
-        MBeanAttributeInfo[] attributes = beanInfo.getAttributes();
-        for (int i = 0; i < attributes.length; i++) {
-            MBeanAttributeInfo info = attributes[i];
-            if (info.isReadable()) {
-                String attributeName = info.getName();
-                Object value = getAttributeValue(name, attributeName);
-                if (value != null) {
-                    writer.print("<attribute name='");
-                    writer.print(attributeName);
-                    writer.print("' type='");
-                    writer.print(info.getType());
-                    writer.print("'>");
-                    printEncodedValue(value);
-                    writer.println("</attribute>");
-                }
-            }
-        }
-
-        writer.println("</mbean>");
-    }
-
-    public void outputHtmlProperties(Set names) throws JMException, IOException {
-        if (names.size() <= 1) {
-        for (Iterator iter = names.iterator(); iter.hasNext();) {
-            outputHtmlProperties((ObjectName) iter.next());
-        }
-        }else {
-            outputHtmlPropertiesGrid(names);
-        }
-    }
-
-    public void outputHtmlPropertiesGrid(Set names) throws JMException {
-        Set propertyNames = new TreeSet();
-        Map[] propertyNamesPerMBeanArray = new Map[names.size()];
-        int beanCounter = 0;
-        for (Iterator iter = names.iterator(); iter.hasNext();) {
-            ObjectName name = (ObjectName) iter.next();
-            Hashtable keyMap = name.getKeyPropertyList();
-            propertyNamesPerMBeanArray[beanCounter++] = keyMap;
-            propertyNames.addAll(keyMap.keySet());
-        }
-
-        writer.println("<table>");
-        writer.println("<tr>");
-        writer.print("<th>Domain</th>");
-        for (Iterator iter = propertyNames.iterator(); iter.hasNext();) {
-            writer.print("<th>");
-            writer.print(iter.next());
-            writer.print("</th>");
-        }
-        writer.println();
-        writer.println("</tr>");
-
-        beanCounter = 0;
-        for (Iterator iter = names.iterator(); iter.hasNext();) {
-            ObjectName name = (ObjectName) iter.next();
-
-            writer.print("<tr><td class='domainName'>");
-            writer.print(name.getDomain());
-            writer.print("</td>");
-
-            for (Iterator iter2 = propertyNames.iterator(); iter2.hasNext();) {
-                String propertyName = (String) iter2.next();
-
-                if (propertyNamesPerMBeanArray[beanCounter].containsKey(propertyName)) {
-                    String value = name.getKeyProperty(propertyName);
-                    writer.print("<td class='");
-                    writer.print(propertyName);
-                    writer.print("'>");
-                    if (value != null) {
-                        printEncodedValue(value);
-                    }
-                    writer.print("</td>");
-                }
-            }
-            writer.print("</tr>");
-            beanCounter++;
-        }
-        writer.println("</table>");
-    }
-
-
-    public void outputHtmlProperties(ObjectName name) throws JMException, IOException {
-        writer.println("<table>");
-        writer.println("<tr>");
-        writer.println("<th>Property</th><th>Value</th>");
-        writer.println("</tr>");
-
-        writer.print("<tr><td>Domain</td><td>");
-        String domain = name.getDomain();
-        if (domain != null) {
-            printEncodedValue(domain);
-        }
-        writer.print("</td></tr>");
-
-        Map map = name.getKeyPropertyList();
-        for (Iterator iter = map.entrySet().iterator(); iter.hasNext();) {
-            Map.Entry entry = (Entry) iter.next();
-            String attributeName = (String) entry.getKey();
-            String value = (String) entry.getValue();
-
-            writer.print("<tr><td>");
-            writer.print(attributeName);
-            writer.print("</td><td>");
-            if (value != null) {
-                printEncodedValue(value);
-            }
-            writer.print("</td></tr>");
-        }
-
-        writer.println("</table>");
-    }
-
-    public void outputHtmlAttributes(Set names) throws IOException, JMException {
-        if (names.size() <= 1) {
-            for (Iterator iter = names.iterator(); iter.hasNext();) {
-                outputHtmlAttributes((ObjectName) iter.next());
-            }
-        }
-        else {
-            outputHtmlAttributeGrid(names);
-        }
-    }
-
-    public void outputHtmlAttributeGrid(Set names) throws JMException {
-        MBeanServer beanServer = getMBeanServer();
-        Set attributeNames = new TreeSet();
-        Set[] attributeNamesPerMBeanArray = new Set[names.size()];
-        int beanCounter = 0;
-        for (Iterator iter = names.iterator(); iter.hasNext();) {
-            ObjectName name = (ObjectName) iter.next();
-            MBeanInfo beanInfo = beanServer.getMBeanInfo(name);
-            MBeanAttributeInfo[] attributes = beanInfo.getAttributes();
-
-            Set availableNamesPerMBean = new HashSet();
-            attributeNamesPerMBeanArray[beanCounter++] = availableNamesPerMBean;
-            for (int i = 0; i < attributes.length; i++) {
-                MBeanAttributeInfo info = attributes[i];
-                if (info.isReadable()) {
-                    String attributeName = info.getName();
-                    availableNamesPerMBean.add(attributeName);
-                    attributeNames.add(attributeName);
-                }
-            }
-        }
-
-        writer.println("<table>");
-        writer.println("<tr>");
-        writer.print("<th>MBean</th>");
-        for (Iterator iter = attributeNames.iterator(); iter.hasNext();) {
-            writer.print("<th>");
-            writer.print(iter.next());
-            writer.print("</th>");
-        }
-        writer.println();
-        writer.println("</tr>");
-
-        beanCounter = 0;
-        for (Iterator iter = names.iterator(); iter.hasNext();) {
-            ObjectName name = (ObjectName) iter.next();
-
-            writer.print("<tr><td class='mbeanName'>");
-            writer.print(name);
-            writer.print("</td>");
-
-            for (Iterator iter2 = attributeNames.iterator(); iter2.hasNext();) {
-                String attributeName = (String) iter2.next();
-
-                if (attributeNamesPerMBeanArray[beanCounter].contains(attributeName)) {
-                    Object value = getAttributeValue(name, attributeName);
-                    writer.print("<td class='");
-                    writer.print(attributeName);
-                    writer.print("'>");
-                    if (value != null) {
-                        printEncodedValue(value);
-                    }
-                    writer.print("</td>");
-                }
-            }
-            writer.print("</tr>");
-            beanCounter++;
-        }
-        writer.println("</table>");
-    }
-
-    public void outputHtmlAttributes(ObjectName name) throws JMException, IOException {
-        MBeanServer beanServer = getMBeanServer();
-        MBeanInfo beanInfo = beanServer.getMBeanInfo(name);
-        writer.println("<table>");
-        writer.println("<tr>");
-        writer.println("<th>Attribute</th><th>Value</th><th>Type</th>");
-        writer.println("</tr>");
-
-        MBeanAttributeInfo[] attributes = beanInfo.getAttributes();
-        for (int i = 0; i < attributes.length; i++) {
-            MBeanAttributeInfo info = attributes[i];
-            if (info.isReadable()) {
-                String attributeName = info.getName();
-
-                Object value = getAttributeValue(name, attributeName);
-                writer.print("<tr><td>");
-                writer.print(attributeName);
-                writer.print("</td><td>");
-                if (value != null) {
-                    printEncodedValue(value);
-                }
-                writer.print("</td><td>");
-                writer.print(info.getType());
-                writer.print("</td></tr>");
-            }
-        }
-
-        writer.println("</table>");
-    }
-
-    public void outputMBeans(Collection names) throws IOException {
-        for (Iterator iter = names.iterator(); iter.hasNext();) {
-            outputMBeans((ObjectName) iter.next());
-        }
-    }
-
-    public void outputMBeans(ObjectName name) throws IOException {
-        Map properties = name.getKeyPropertyList();
-        for (Iterator iter = properties.entrySet().iterator(); iter.hasNext();) {
-            Map.Entry entry = (Map.Entry) iter.next();
-            writer.print("<mbean name='");
-            writer.print(entry.getKey());
-            ObjectInstance objectInstance = (ObjectInstance) entry.getValue();
-            if (objectInstance != null) {
-                writer.print("' className='");
-                writer.print(objectInstance.getClassName());
-            }
-            writer.println("'/>");
-        }
-    }
-
-    public void outputHeader() throws IOException {
-        writer.println("<?xml version='1.0'?>");
-        writer.println("<mbeans>");
-    }
-
-    public void outputFooter() throws IOException {
-        writer.println("</mbeans>");
-    }
-
-    /**
-     * Encodes the value as a String and ensures that there are no bad XML
-     * characters like < or > which are encoded.
-     */
-    public void printEncodedValue(Object value) {
-        if (value != null) {
-            String text = value.toString();
-            for (int i = 0, size = text.length(); i < size; i++) {
-                char ch = text.charAt(i);
-                switch (ch) {
-                case '<':
-                    writer.print("&lt;");
-                    break;
-
-                case '>':
-                    writer.print("&gt;");
-                    break;
-
-                case '&':
-                    writer.print("&amp;");
-                    break;
-
-                // used in ObjectName
-                case ',':
-                    writer.print("%2C");
-                    break;
-
-                case ':':
-                    writer.print("%3A");
-                    break;
-
-                case '=':
-                    writer.print("%3D");
-                    break;
-
-                default:
-                    writer.print(ch);
-                }
-            }
-        }
-    }
-
-    /**
-     * Prints a HTTP encoded ObjectName suitable for use inside URLs
-     */
-    public void printEncodedObjectName(ObjectName name) {
-        printEncodedValue(name);
-    }
-
-    /**
-     * Outputs a URL to the detail JMX stats view
-     */
-    protected void printDetailURL(ObjectName name) {
-        writer.print("mbeanDetail.jsp?view=detail&style=html&name=");
-        printEncodedObjectName(name);
-    }
-
-    /**
-     * Outputs a URL to the detail JMX stats view
-     */
-    protected void printDetailURL(String propertyName, String propertyValue) {
-        writer.print("mbeanDetail.jsp?view=detail&style=html&query=");
-        printEncodedValue("*:" + propertyName + "=" + propertyValue + ",*");
-    }
-
-    protected Object getAttributeValue(ObjectName name, String attributeName) throws MBeanException {
-        MBeanServer beanServer = getMBeanServer();
-        Object value = null;
-        try {
-            value = beanServer.getAttribute(name, attributeName);
-        }
-        catch (AttributeNotFoundException e) {
-            log.warn("Caught: " + e, e);
-        }
-        catch (InstanceNotFoundException e) {
-            log.warn("Caught: " + e, e);
-        }
-        catch (ReflectionException e) {
-            log.warn("Caught: " + e, e);
-        }
-        return value;
-    }
-
-}
+/**
+ *
+ * Copyright 2005 LogicBlaze, Inc. http://www.logicblaze.com
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ **/
+
+package org.apache.servicemix.web.jmx;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+import javax.management.AttributeNotFoundException;
+import javax.management.InstanceNotFoundException;
+import javax.management.JMException;
+import javax.management.MBeanAttributeInfo;
+import javax.management.MBeanException;
+import javax.management.MBeanInfo;
+import javax.management.MBeanServer;
+import javax.management.ObjectInstance;
+import javax.management.ObjectName;
+import javax.management.ReflectionException;
+
+import java.io.IOException;
+import java.io.PrintWriter;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.HashSet;
+import java.util.Hashtable;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+import java.util.TreeMap;
+import java.util.TreeSet;
+import java.util.Map.Entry;
+
+/**
+ * A useful class for turning JMX statistics into XML and XHTML
+ *
+ * @version $Revision: 356269 $
+ */
+public class JMXWriter {
+    private static final Log log = LogFactory.getLog(JMXWriter.class);
+
+    private PrintWriter writer;
+    private ManagementContext managementContext;
+    private String unknownValue = "Unknown";
+
+    public JMXWriter(PrintWriter writer, ManagementContext context) {
+        this.writer = writer;
+        managementContext = context;
+    }
+
+    public MBeanServer getMBeanServer() {
+        return managementContext.getMBeanServer();
+    }
+
+    public ManagementContext getManagementContext() {
+        return managementContext;
+    }
+
+    public void setManagementContext(ManagementContext managementContext) {
+        this.managementContext = managementContext;
+    }
+
+    public void outputHtmlNamesByDomain(Collection names) throws IOException {
+        Map map = new TreeMap();
+        for (Iterator iter = names.iterator(); iter.hasNext();) {
+            ObjectName name = (ObjectName) iter.next();
+            String domain = name.getDomain();
+            List list = (List) map.get(domain);
+            if (list == null) {
+                list = new ArrayList();
+                map.put(domain, list);
+            }
+            list.add(name);
+        }
+        for (Iterator iter = map.entrySet().iterator(); iter.hasNext();) {
+            Map.Entry entry = (Map.Entry) iter.next();
+            String domain = (String) entry.getKey();
+            names = (List) entry.getValue();
+
+            writer.print("<li>");
+            writer.print(domain);
+
+            writer.print("<ul>");
+            outputHtmlNamesByProperty(names, "type");
+            writer.print("</ul>");
+            writer.print("</li>");
+        }
+    }
+
+    public void outputHtmlNamesByProperty(Collection names, String property) throws IOException {
+        Map map = new TreeMap();
+        for (Iterator iter = names.iterator(); iter.hasNext();) {
+            ObjectName name = (ObjectName) iter.next();
+            String propertyValue = name.getKeyProperty(property);
+            if (propertyValue == null) {
+                propertyValue = unknownValue;
+            }
+            List list = (List) map.get(propertyValue);
+            if (list == null) {
+                list = new ArrayList();
+                map.put(propertyValue, list);
+            }
+            list.add(name);
+        }
+        for (Iterator iter = map.entrySet().iterator(); iter.hasNext();) {
+            Map.Entry entry = (Map.Entry) iter.next();
+            String propertyValue = (String) entry.getKey();
+            names = (List) entry.getValue();
+
+            if (names.size() > 1) {
+                writer.print("<li><a href='");
+                printDetailURL(property, propertyValue);
+                writer.print("'>");
+                writer.print(propertyValue);
+                writer.print("</a><ul>");
+
+                // outputHtmlNames(names);
+                outputHtmlNamesSortedByShortName(names);
+                writer.print("</ul>");
+                writer.print("</li>");
+            }
+            else if (names.size() == 1) {
+                ObjectName name = (ObjectName) ((List) names).get(0);
+                outputHtmlName(name, propertyValue);
+            }
+        }
+    }
+
+    public void outputHtmlNamesSortedByShortName(Collection names) throws IOException {
+        Map map = new TreeMap();
+        for (Iterator iter = names.iterator(); iter.hasNext();) {
+            ObjectName name = (ObjectName) iter.next();
+            String propertyValue = getShortName(name);
+            map.put(propertyValue, name);
+        }
+        for (Iterator iter = map.entrySet().iterator(); iter.hasNext();) {
+            Map.Entry entry = (Map.Entry) iter.next();
+            String description = (String) entry.getKey();
+            ObjectName name = (ObjectName) entry.getValue();
+            outputHtmlName(name, description);
+        }
+    }
+
+    public void outputHtmlNames(Collection names) throws IOException {
+        for (Iterator iter = names.iterator(); iter.hasNext();) {
+            outputHtmlNames((ObjectName) iter.next());
+        }
+    }
+
+    public void outputHtmlNames(ObjectName name) throws IOException {
+        outputHtmlName(name, getShortName(name));
+    }
+
+    public void outputHtmlName(ObjectName name, String shortName) throws IOException {
+        writer.print("<li><a href='");
+        printDetailURL(name);
+
+        /*
+         * Map properties = name.getKeyPropertyList(); for (Iterator iter =
+         * properties.entrySet().iterator(); iter.hasNext();) { Map.Entry entry =
+         * (Map.Entry) iter.next(); writer.print("<property name='");
+         * writer.print(entry.getKey()); writer.print("'>");
+         * writer.print(entry.getValue()); writer.println("</property>"); }
+         */
+
+        writer.print("'>");
+        // writer.print(name.getCanonicalKeyPropertyListString());
+        writer.print(shortName);
+        writer.print("</a></li>");
+    }
+
+    /**
+     * Returns a short descriptive name of the ObjectName without the domain
+     */
+    protected String getShortName(ObjectName name) {
+        // TODO Auto-generated method stub
+        String answer = name.toString();
+        int idx = answer.indexOf(':');
+        if (idx >= 0) {
+            return answer.substring(idx + 1);
+        }
+        return answer;
+    }
+
+    public void outputNames(Collection names) throws IOException {
+        for (Iterator iter = names.iterator(); iter.hasNext();) {
+            outputNames((ObjectName) iter.next());
+        }
+    }
+
+    public void outputNames(ObjectName name) throws IOException {
+        writer.print("<mbean name='");
+        writer.print(name.getCanonicalName());
+        writer.print("' domain='");
+        writer.print(name.getDomain());
+        writer.println("'>");
+        Map properties = name.getKeyPropertyList();
+        for (Iterator iter = properties.entrySet().iterator(); iter.hasNext();) {
+            Map.Entry entry = (Map.Entry) iter.next();
+            writer.print("<property name='");
+            writer.print(entry.getKey());
+            writer.print("'>");
+            writer.print(entry.getValue());
+            writer.println("</property>");
+        }
+        writer.println("</mbean>");
+    }
+
+    public void outputDetail(Set names) throws IOException, JMException {
+
+        for (Iterator iter = names.iterator(); iter.hasNext();) {
+            outputDetail((ObjectName) iter.next());
+        }
+    }
+
+    public void outputDetail(ObjectName name) throws JMException, IOException {
+
+        MBeanServer beanServer = getMBeanServer();
+        MBeanInfo beanInfo = beanServer.getMBeanInfo(name);
+        writer.print("<mbean name='");
+        writer.print(name.getCanonicalName());
+        writer.print("' domain='");
+        writer.print(name.getDomain());
+        writer.println("'>");
+
+        MBeanAttributeInfo[] attributes = beanInfo.getAttributes();
+        for (int i = 0; i < attributes.length; i++) {
+            MBeanAttributeInfo info = attributes[i];
+            if (info.isReadable()) {
+                String attributeName = info.getName();
+                Object value = getAttributeValue(name, attributeName);
+                if (value != null) {
+                    writer.print("<attribute name='");
+                    writer.print(attributeName);
+                    writer.print("' type='");
+                    writer.print(info.getType());
+                    writer.print("'>");
+                    printEncodedValue(value);
+                    writer.println("</attribute>");
+                }
+            }
+        }
+
+        writer.println("</mbean>");
+    }
+
+    public void outputHtmlProperties(Set names) throws JMException, IOException {
+        if (names.size() <= 1) {
+        for (Iterator iter = names.iterator(); iter.hasNext();) {
+            outputHtmlProperties((ObjectName) iter.next());
+        }
+        }else {
+            outputHtmlPropertiesGrid(names);
+        }
+    }
+
+    public void outputHtmlPropertiesGrid(Set names) throws JMException {
+        Set propertyNames = new TreeSet();
+        Map[] propertyNamesPerMBeanArray = new Map[names.size()];
+        int beanCounter = 0;
+        for (Iterator iter = names.iterator(); iter.hasNext();) {
+            ObjectName name = (ObjectName) iter.next();
+            Hashtable keyMap = name.getKeyPropertyList();
+            propertyNamesPerMBeanArray[beanCounter++] = keyMap;
+            propertyNames.addAll(keyMap.keySet());
+        }
+
+        writer.println("<table>");
+        writer.println("<tr>");
+        writer.print("<th>Domain</th>");
+        for (Iterator iter = propertyNames.iterator(); iter.hasNext();) {
+            writer.print("<th>");
+            writer.print(iter.next());
+            writer.print("</th>");
+        }
+        writer.println();
+        writer.println("</tr>");
+
+        beanCounter = 0;
+        for (Iterator iter = names.iterator(); iter.hasNext();) {
+            ObjectName name = (ObjectName) iter.next();
+
+            writer.print("<tr><td class='domainName'>");
+            writer.print(name.getDomain());
+            writer.print("</td>");
+
+            for (Iterator iter2 = propertyNames.iterator(); iter2.hasNext();) {
+                String propertyName = (String) iter2.next();
+
+                if (propertyNamesPerMBeanArray[beanCounter].containsKey(propertyName)) {
+                    String value = name.getKeyProperty(propertyName);
+                    writer.print("<td class='");
+                    writer.print(propertyName);
+                    writer.print("'>");
+                    if (value != null) {
+                        printEncodedValue(value);
+                    }
+                    writer.print("</td>");
+                }
+            }
+            writer.print("</tr>");
+            beanCounter++;
+        }
+        writer.println("</table>");
+    }
+
+
+    public void outputHtmlProperties(ObjectName name) throws JMException, IOException {
+        writer.println("<table>");
+        writer.println("<tr>");
+        writer.println("<th>Property</th><th>Value</th>");
+        writer.println("</tr>");
+
+        writer.print("<tr><td>Domain</td><td>");
+        String domain = name.getDomain();
+        if (domain != null) {
+            printEncodedValue(domain);
+        }
+        writer.print("</td></tr>");
+
+        Map map = name.getKeyPropertyList();
+        for (Iterator iter = map.entrySet().iterator(); iter.hasNext();) {
+            Map.Entry entry = (Entry) iter.next();
+            String attributeName = (String) entry.getKey();
+            String value = (String) entry.getValue();
+
+            writer.print("<tr><td>");
+            writer.print(attributeName);
+            writer.print("</td><td>");
+            if (value != null) {
+                printEncodedValue(value);
+            }
+            writer.print("</td></tr>");
+        }
+
+        writer.println("</table>");
+    }
+
+    public void outputHtmlAttributes(Set names) throws IOException, JMException {
+        if (names.size() <= 1) {
+            for (Iterator iter = names.iterator(); iter.hasNext();) {
+                outputHtmlAttributes((ObjectName) iter.next());
+            }
+        }
+        else {
+            outputHtmlAttributeGrid(names);
+        }
+    }
+
+    public void outputHtmlAttributeGrid(Set names) throws JMException {
+        MBeanServer beanServer = getMBeanServer();
+        Set attributeNames = new TreeSet();
+        Set[] attributeNamesPerMBeanArray = new Set[names.size()];
+        int beanCounter = 0;
+        for (Iterator iter = names.iterator(); iter.hasNext();) {
+            ObjectName name = (ObjectName) iter.next();
+            MBeanInfo beanInfo = beanServer.getMBeanInfo(name);
+            MBeanAttributeInfo[] attributes = beanInfo.getAttributes();
+
+            Set availableNamesPerMBean = new HashSet();
+            attributeNamesPerMBeanArray[beanCounter++] = availableNamesPerMBean;
+            for (int i = 0; i < attributes.length; i++) {
+                MBeanAttributeInfo info = attributes[i];
+                if (info.isReadable()) {
+                    String attributeName = info.getName();
+                    availableNamesPerMBean.add(attributeName);
+                    attributeNames.add(attributeName);
+                }
+            }
+        }
+
+        writer.println("<table>");
+        writer.println("<tr>");
+        writer.print("<th>MBean</th>");
+        for (Iterator iter = attributeNames.iterator(); iter.hasNext();) {
+            writer.print("<th>");
+            writer.print(iter.next());
+            writer.print("</th>");
+        }
+        writer.println();
+        writer.println("</tr>");
+
+        beanCounter = 0;
+        for (Iterator iter = names.iterator(); iter.hasNext();) {
+            ObjectName name = (ObjectName) iter.next();
+
+            writer.print("<tr><td class='mbeanName'>");
+            writer.print(name);
+            writer.print("</td>");
+
+            for (Iterator iter2 = attributeNames.iterator(); iter2.hasNext();) {
+                String attributeName = (String) iter2.next();
+
+                if (attributeNamesPerMBeanArray[beanCounter].contains(attributeName)) {
+                    Object value = getAttributeValue(name, attributeName);
+                    writer.print("<td class='");
+                    writer.print(attributeName);
+                    writer.print("'>");
+                    if (value != null) {
+                        printEncodedValue(value);
+                    }
+                    writer.print("</td>");
+                }
+            }
+            writer.print("</tr>");
+            beanCounter++;
+        }
+        writer.println("</table>");
+    }
+
+    public void outputHtmlAttributes(ObjectName name) throws JMException, IOException {
+        MBeanServer beanServer = getMBeanServer();
+        MBeanInfo beanInfo = beanServer.getMBeanInfo(name);
+        writer.println("<table>");
+        writer.println("<tr>");
+        writer.println("<th>Attribute</th><th>Value</th><th>Type</th>");
+        writer.println("</tr>");
+
+        MBeanAttributeInfo[] attributes = beanInfo.getAttributes();
+        for (int i = 0; i < attributes.length; i++) {
+            MBeanAttributeInfo info = attributes[i];
+            if (info.isReadable()) {
+                String attributeName = info.getName();
+
+                Object value = getAttributeValue(name, attributeName);
+                writer.print("<tr><td>");
+                writer.print(attributeName);
+                writer.print("</td><td>");
+                if (value != null) {
+                    printEncodedValue(value);
+                }
+                writer.print("</td><td>");
+                writer.print(info.getType());
+                writer.print("</td></tr>");
+            }
+        }
+
+        writer.println("</table>");
+    }
+
+    public void outputMBeans(Collection names) throws IOException {
+        for (Iterator iter = names.iterator(); iter.hasNext();) {
+            outputMBeans((ObjectName) iter.next());
+        }
+    }
+
+    public void outputMBeans(ObjectName name) throws IOException {
+        Map properties = name.getKeyPropertyList();
+        for (Iterator iter = properties.entrySet().iterator(); iter.hasNext();) {
+            Map.Entry entry = (Map.Entry) iter.next();
+            writer.print("<mbean name='");
+            writer.print(entry.getKey());
+            ObjectInstance objectInstance = (ObjectInstance) entry.getValue();
+            if (objectInstance != null) {
+                writer.print("' className='");
+                writer.print(objectInstance.getClassName());
+            }
+            writer.println("'/>");
+        }
+    }
+
+    public void outputHeader() throws IOException {
+        writer.println("<?xml version='1.0'?>");
+        writer.println("<mbeans>");
+    }
+
+    public void outputFooter() throws IOException {
+        writer.println("</mbeans>");
+    }
+
+    /**
+     * Encodes the value as a String and ensures that there are no bad XML
+     * characters like < or > which are encoded.
+     */
+    public void printEncodedValue(Object value) {
+        if (value != null) {
+            String text = value.toString();
+            for (int i = 0, size = text.length(); i < size; i++) {
+                char ch = text.charAt(i);
+                switch (ch) {
+                case '<':
+                    writer.print("&lt;");
+                    break;
+
+                case '>':
+                    writer.print("&gt;");
+                    break;
+
+                case '&':
+                    writer.print("&amp;");
+                    break;
+
+                // used in ObjectName
+                case ',':
+                    writer.print("%2C");
+                    break;
+
+                case ':':
+                    writer.print("%3A");
+                    break;
+
+                case '=':
+                    writer.print("%3D");
+                    break;
+
+                default:
+                    writer.print(ch);
+                }
+            }
+        }
+    }
+
+    /**
+     * Prints a HTTP encoded ObjectName suitable for use inside URLs
+     */
+    public void printEncodedObjectName(ObjectName name) {
+        printEncodedValue(name);
+    }
+
+    /**
+     * Outputs a URL to the detail JMX stats view
+     */
+    protected void printDetailURL(ObjectName name) {
+        writer.print("mbeanDetail.jsp?view=detail&style=html&name=");
+        printEncodedObjectName(name);
+    }
+
+    /**
+     * Outputs a URL to the detail JMX stats view
+     */
+    protected void printDetailURL(String propertyName, String propertyValue) {
+        writer.print("mbeanDetail.jsp?view=detail&style=html&query=");
+        printEncodedValue("*:" + propertyName + "=" + propertyValue + ",*");
+    }
+
+    protected Object getAttributeValue(ObjectName name, String attributeName) throws MBeanException {
+        MBeanServer beanServer = getMBeanServer();
+        Object value = null;
+        try {
+            value = beanServer.getAttribute(name, attributeName);
+        }
+        catch (AttributeNotFoundException e) {
+            log.warn("Caught: " + e, e);
+        }
+        catch (InstanceNotFoundException e) {
+            log.warn("Caught: " + e, e);
+        }
+        catch (ReflectionException e) {
+            log.warn("Caught: " + e, e);
+        }
+        return value;
+    }
+
+}

Propchange: incubator/servicemix/trunk/servicemix-assembly/src/main/release/examples/servicemix-web/src/main/java/org/apache/servicemix/web/jmx/JMXWriter.java
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: incubator/servicemix/trunk/servicemix-assembly/src/main/release/examples/servicemix-web/src/main/java/org/apache/servicemix/web/jmx/ManagementContext.java
URL: http://svn.apache.org/viewcvs/incubator/servicemix/trunk/servicemix-assembly/src/main/release/examples/servicemix-web/src/main/java/org/apache/servicemix/web/jmx/ManagementContext.java?rev=379627&r1=379626&r2=379627&view=diff
==============================================================================
--- incubator/servicemix/trunk/servicemix-assembly/src/main/release/examples/servicemix-web/src/main/java/org/apache/servicemix/web/jmx/ManagementContext.java (original)
+++ incubator/servicemix/trunk/servicemix-assembly/src/main/release/examples/servicemix-web/src/main/java/org/apache/servicemix/web/jmx/ManagementContext.java Tue Feb 21 15:40:05 2006
@@ -1,232 +1,232 @@
-/**
- *
- * Copyright 2005 LogicBlaze, Inc. http://www.logicblaze.com
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- **/
-package org.apache.servicemix.web.jmx;
-
-import org.apache.activemq.Service;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-
-import javax.jms.JMSException;
-import javax.management.JMException;
-import javax.management.MBeanServer;
-import javax.management.MBeanServerFactory;
-import javax.management.MalformedObjectNameException;
-import javax.management.ObjectName;
-
-import java.util.List;
-
-/**
- * A Flow provides different dispatch policies within the NMR
- *
- * @version $Revision: 356583 $
- */
-public class ManagementContext implements Service {
-    /**
-     * Default servicemix domain
-     */
-    public static String DEFAULT_DOMAIN = "org.apache.activemq";
-
-    private final static Log log = LogFactory.getLog(ManagementContext.class);
-
-    private MBeanServer beanServer;
-    private String jmxDomainName = DEFAULT_DOMAIN;
-    private boolean useMBeanServer = true;
-    private boolean createMBeanServer = true;
-    private boolean locallyCreateMBeanServer = false;
-
-    public ManagementContext() {
-        this(null);
-    }
-
-    public ManagementContext(MBeanServer server) {
-        this.beanServer = server;
-    }
-
-    public void start() throws JMSException {
-        // lets force the MBeanServer to be created if needed
-        getMBeanServer();
-    }
-
-    public void stop() throws JMSException {
-        if (locallyCreateMBeanServer && beanServer != null) {
-            // check to see if the factory knows about this server
-            List list = MBeanServerFactory.findMBeanServer(null);
-            if (list != null && !list.isEmpty() && list.contains(beanServer)) {
-                MBeanServerFactory.releaseMBeanServer(beanServer);
-            }
-        }
-    }
-
-    /**
-     * @return Returns the jmxDomainName.
-     */
-    public String getJmxDomainName() {
-        return jmxDomainName;
-    }
-
-    /**
-     * @param jmxDomainName
-     *            The jmxDomainName to set.
-     */
-    public void setJmxDomainName(String jmxDomainName) {
-        this.jmxDomainName = jmxDomainName;
-    }
-
-    /**
-     * Get the MBeanServer
-     *
-     * @return the MBeanServer
-     */
-    public MBeanServer getMBeanServer() {
-        if (this.beanServer == null) {
-            this.beanServer = findMBeanServer();
-        }
-        return beanServer;
-    }
-
-    /**
-     * @return Returns the useMBeanServer.
-     */
-    public boolean isUseMBeanServer() {
-        return useMBeanServer;
-    }
-
-    /**
-     * @param useMBeanServer
-     *            The useMBeanServer to set.
-     */
-    public void setUseMBeanServer(boolean useMBeanServer) {
-        this.useMBeanServer = useMBeanServer;
-    }
-
-    /**
-     * @return Returns the createMBeanServer flag.
-     */
-    public boolean isCreateMBeanServer() {
-        return createMBeanServer;
-    }
-
-    /**
-     * @param enableJMX
-     *            Set createMBeanServer.
-     */
-    public void setCreateMBeanServer(boolean enableJMX) {
-        this.createMBeanServer = enableJMX;
-    }
-
-    /**
-     * Formulate and return the MBean ObjectName of a custom control MBean
-     *
-     * @param type
-     * @param name
-     * @return the JMX ObjectName of the MBean, or <code>null</code> if
-     *         <code>customName</code> is invalid.
-     */
-    public ObjectName createCustomComponentMBeanName(String type, String name) {
-        ObjectName result = null;
-        String tmp = jmxDomainName + ":" + "type=" + sanitizeString(type) + ",name=" + sanitizeString(name);
-        try {
-            result = new ObjectName(tmp);
-        }
-        catch (MalformedObjectNameException e) {
-            log.error("Couldn't create ObjectName from: " + type + " , " + name);
-        }
-        return result;
-    }
-
-    /**
-     * The ':' and '/' characters are reserved in ObjectNames
-     *
-     * @param in
-     * @return sanitized String
-     */
-    private static String sanitizeString(String in) {
-        String result = null;
-        if (in != null) {
-            result = in.replace(':', '_');
-            result = result.replace('/', '_');
-            result = result.replace('\\', '_');
-        }
-        return result;
-    }
-
-    /**
-     * Retrive an System ObjectName
-     *
-     * @param domainName
-     * @param containerName
-     * @param theClass
-     * @return the ObjectName
-     * @throws MalformedObjectNameException
-     */
-    public static ObjectName getSystemObjectName(String domainName, String containerName, Class theClass)
-            throws MalformedObjectNameException, NullPointerException {
-        String tmp = domainName + ":" + "type=" + theClass.getName() + ",name="
-                + getRelativeName(containerName, theClass);
-        return new ObjectName(tmp);
-    }
-
-    private static String getRelativeName(String containerName, Class theClass) {
-        String name = theClass.getName();
-        int index = name.lastIndexOf(".");
-        if (index >= 0 && (index + 1) < name.length()) {
-            name = name.substring(index + 1);
-        }
-        return containerName + "." + name;
-    }
-
-    /**
-     * Unregister an MBean
-     *
-     * @param name
-     * @throws JMException
-     */
-    public void unregisterMBean(ObjectName name) throws JMException {
-        if (beanServer != null && beanServer.isRegistered(name)) {
-            beanServer.unregisterMBean(name);
-        }
-    }
-
-    protected synchronized MBeanServer findMBeanServer() {
-        MBeanServer result = null;
-        // create the mbean server
-        try {
-            if (useMBeanServer) {
-                // lets piggy back on another MBeanServer -
-                // we could be in an appserver!
-                List list = MBeanServerFactory.findMBeanServer(null);
-                if (list != null && list.size() > 0) {
-                    result = (MBeanServer) list.get(0);
-                }
-            }
-
-            if (result == null && createMBeanServer) {
-                result = MBeanServerFactory.createMBeanServer(jmxDomainName);
-                locallyCreateMBeanServer = true;
-            }
-        }
-        catch (NoClassDefFoundError e) {
-            log.error("Couldnot load MBeanServer", e);
-        }
-        catch (Throwable e) {
-            // probably don't have access to system properties
-            log.error("Failed to initialize MBeanServer", e);
-        }
-        return result;
-    }
+/**
+ *
+ * Copyright 2005 LogicBlaze, Inc. http://www.logicblaze.com
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ **/
+package org.apache.servicemix.web.jmx;
+
+import org.apache.activemq.Service;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+import javax.jms.JMSException;
+import javax.management.JMException;
+import javax.management.MBeanServer;
+import javax.management.MBeanServerFactory;
+import javax.management.MalformedObjectNameException;
+import javax.management.ObjectName;
+
+import java.util.List;
+
+/**
+ * A Flow provides different dispatch policies within the NMR
+ *
+ * @version $Revision: 356583 $
+ */
+public class ManagementContext implements Service {
+    /**
+     * Default servicemix domain
+     */
+    public static String DEFAULT_DOMAIN = "org.apache.activemq";
+
+    private final static Log log = LogFactory.getLog(ManagementContext.class);
+
+    private MBeanServer beanServer;
+    private String jmxDomainName = DEFAULT_DOMAIN;
+    private boolean useMBeanServer = true;
+    private boolean createMBeanServer = true;
+    private boolean locallyCreateMBeanServer = false;
+
+    public ManagementContext() {
+        this(null);
+    }
+
+    public ManagementContext(MBeanServer server) {
+        this.beanServer = server;
+    }
+
+    public void start() throws JMSException {
+        // lets force the MBeanServer to be created if needed
+        getMBeanServer();
+    }
+
+    public void stop() throws JMSException {
+        if (locallyCreateMBeanServer && beanServer != null) {
+            // check to see if the factory knows about this server
+            List list = MBeanServerFactory.findMBeanServer(null);
+            if (list != null && !list.isEmpty() && list.contains(beanServer)) {
+                MBeanServerFactory.releaseMBeanServer(beanServer);
+            }
+        }
+    }
+
+    /**
+     * @return Returns the jmxDomainName.
+     */
+    public String getJmxDomainName() {
+        return jmxDomainName;
+    }
+
+    /**
+     * @param jmxDomainName
+     *            The jmxDomainName to set.
+     */
+    public void setJmxDomainName(String jmxDomainName) {
+        this.jmxDomainName = jmxDomainName;
+    }
+
+    /**
+     * Get the MBeanServer
+     *
+     * @return the MBeanServer
+     */
+    public MBeanServer getMBeanServer() {
+        if (this.beanServer == null) {
+            this.beanServer = findMBeanServer();
+        }
+        return beanServer;
+    }
+
+    /**
+     * @return Returns the useMBeanServer.
+     */
+    public boolean isUseMBeanServer() {
+        return useMBeanServer;
+    }
+
+    /**
+     * @param useMBeanServer
+     *            The useMBeanServer to set.
+     */
+    public void setUseMBeanServer(boolean useMBeanServer) {
+        this.useMBeanServer = useMBeanServer;
+    }
+
+    /**
+     * @return Returns the createMBeanServer flag.
+     */
+    public boolean isCreateMBeanServer() {
+        return createMBeanServer;
+    }
+
+    /**
+     * @param enableJMX
+     *            Set createMBeanServer.
+     */
+    public void setCreateMBeanServer(boolean enableJMX) {
+        this.createMBeanServer = enableJMX;
+    }
+
+    /**
+     * Formulate and return the MBean ObjectName of a custom control MBean
+     *
+     * @param type
+     * @param name
+     * @return the JMX ObjectName of the MBean, or <code>null</code> if
+     *         <code>customName</code> is invalid.
+     */
+    public ObjectName createCustomComponentMBeanName(String type, String name) {
+        ObjectName result = null;
+        String tmp = jmxDomainName + ":" + "type=" + sanitizeString(type) + ",name=" + sanitizeString(name);
+        try {
+            result = new ObjectName(tmp);
+        }
+        catch (MalformedObjectNameException e) {
+            log.error("Couldn't create ObjectName from: " + type + " , " + name);
+        }
+        return result;
+    }
+
+    /**
+     * The ':' and '/' characters are reserved in ObjectNames
+     *
+     * @param in
+     * @return sanitized String
+     */
+    private static String sanitizeString(String in) {
+        String result = null;
+        if (in != null) {
+            result = in.replace(':', '_');
+            result = result.replace('/', '_');
+            result = result.replace('\\', '_');
+        }
+        return result;
+    }
+
+    /**
+     * Retrive an System ObjectName
+     *
+     * @param domainName
+     * @param containerName
+     * @param theClass
+     * @return the ObjectName
+     * @throws MalformedObjectNameException
+     */
+    public static ObjectName getSystemObjectName(String domainName, String containerName, Class theClass)
+            throws MalformedObjectNameException, NullPointerException {
+        String tmp = domainName + ":" + "type=" + theClass.getName() + ",name="
+                + getRelativeName(containerName, theClass);
+        return new ObjectName(tmp);
+    }
+
+    private static String getRelativeName(String containerName, Class theClass) {
+        String name = theClass.getName();
+        int index = name.lastIndexOf(".");
+        if (index >= 0 && (index + 1) < name.length()) {
+            name = name.substring(index + 1);
+        }
+        return containerName + "." + name;
+    }
+
+    /**
+     * Unregister an MBean
+     *
+     * @param name
+     * @throws JMException
+     */
+    public void unregisterMBean(ObjectName name) throws JMException {
+        if (beanServer != null && beanServer.isRegistered(name)) {
+            beanServer.unregisterMBean(name);
+        }
+    }
+
+    protected synchronized MBeanServer findMBeanServer() {
+        MBeanServer result = null;
+        // create the mbean server
+        try {
+            if (useMBeanServer) {
+                // lets piggy back on another MBeanServer -
+                // we could be in an appserver!
+                List list = MBeanServerFactory.findMBeanServer(null);
+                if (list != null && list.size() > 0) {
+                    result = (MBeanServer) list.get(0);
+                }
+            }
+
+            if (result == null && createMBeanServer) {
+                result = MBeanServerFactory.createMBeanServer(jmxDomainName);
+                locallyCreateMBeanServer = true;
+            }
+        }
+        catch (NoClassDefFoundError e) {
+            log.error("Couldnot load MBeanServer", e);
+        }
+        catch (Throwable e) {
+            // probably don't have access to system properties
+            log.error("Failed to initialize MBeanServer", e);
+        }
+        return result;
+    }
 }

Propchange: incubator/servicemix/trunk/servicemix-assembly/src/main/release/examples/servicemix-web/src/main/java/org/apache/servicemix/web/jmx/ManagementContext.java
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: incubator/servicemix/trunk/servicemix-assembly/src/main/release/examples/servicemix-web/src/test/java/org/apache/servicemix/web/JettyServer.java
URL: http://svn.apache.org/viewcvs/incubator/servicemix/trunk/servicemix-assembly/src/main/release/examples/servicemix-web/src/test/java/org/apache/servicemix/web/JettyServer.java?rev=379627&r1=379626&r2=379627&view=diff
==============================================================================
--- incubator/servicemix/trunk/servicemix-assembly/src/main/release/examples/servicemix-web/src/test/java/org/apache/servicemix/web/JettyServer.java (original)
+++ incubator/servicemix/trunk/servicemix-assembly/src/main/release/examples/servicemix-web/src/test/java/org/apache/servicemix/web/JettyServer.java Tue Feb 21 15:40:05 2006
@@ -1,56 +1,56 @@
-package org.apache.servicemix.web;
-/**
- *
- * Copyright 2005 LogicBlaze, Inc. http://www.logicblaze.com
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- **/
-
-import org.mortbay.jetty.bio.SocketConnector;
-import org.mortbay.jetty.webapp.WebAppContext;
-import org.mortbay.jetty.Connector;
-import org.mortbay.jetty.Handler;
-import org.mortbay.jetty.Server;
-
-/**
- * A simple bootstrap class for starting Jetty in your IDE using the local web application.
- *
- * @version $Revision: 356269 $
- */
-public class JettyServer {
-
-    public static final int PORT = 8080;
-
-    public static final String WEBAPP_DIR = "src/webapp";
-
-    public static final String WEBAPP_CTX = "/";
-
-    public static void main(String[] args) throws Exception {
-        int port = PORT;
-        if (args.length > 0) {
-            String text = args[0];
-            port = Integer.parseInt(text);
-        }
-        System.out.println("Starting Web Server on port: " + port);
-        Server server = new Server();
-        SocketConnector connector = new SocketConnector();
-        connector.setPort(port);
-        WebAppContext webapp = new WebAppContext();
-        webapp.setContextPath(WEBAPP_CTX);
-        webapp.setResourceBase(WEBAPP_DIR);
-        server.setHandlers(new Handler[] { webapp });
-        server.setConnectors(new Connector[] { connector });
-        server.start();
-    }
-}
+package org.apache.servicemix.web;
+/**
+ *
+ * Copyright 2005 LogicBlaze, Inc. http://www.logicblaze.com
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ **/
+
+import org.mortbay.jetty.bio.SocketConnector;
+import org.mortbay.jetty.webapp.WebAppContext;
+import org.mortbay.jetty.Connector;
+import org.mortbay.jetty.Handler;
+import org.mortbay.jetty.Server;
+
+/**
+ * A simple bootstrap class for starting Jetty in your IDE using the local web application.
+ *
+ * @version $Revision: 356269 $
+ */
+public class JettyServer {
+
+    public static final int PORT = 8080;
+
+    public static final String WEBAPP_DIR = "src/webapp";
+
+    public static final String WEBAPP_CTX = "/";
+
+    public static void main(String[] args) throws Exception {
+        int port = PORT;
+        if (args.length > 0) {
+            String text = args[0];
+            port = Integer.parseInt(text);
+        }
+        System.out.println("Starting Web Server on port: " + port);
+        Server server = new Server();
+        SocketConnector connector = new SocketConnector();
+        connector.setPort(port);
+        WebAppContext webapp = new WebAppContext();
+        webapp.setContextPath(WEBAPP_CTX);
+        webapp.setResourceBase(WEBAPP_DIR);
+        server.setHandlers(new Handler[] { webapp });
+        server.setConnectors(new Connector[] { connector });
+        server.start();
+    }
+}

Propchange: incubator/servicemix/trunk/servicemix-assembly/src/main/release/examples/servicemix-web/src/test/java/org/apache/servicemix/web/JettyServer.java
------------------------------------------------------------------------------
    svn:eol-style = native