You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@sirona.apache.org by ol...@apache.org on 2014/09/05 11:25:01 UTC

svn commit: r1622657 - /incubator/sirona/trunk/server/reporting/reporting-api/src/main/java/org/apache/sirona/reporting/web/jmx/JMXServices.java

Author: olamy
Date: Fri Sep  5 09:25:00 2014
New Revision: 1622657

URL: http://svn.apache.org/r1622657
Log:
rename

Added:
    incubator/sirona/trunk/server/reporting/reporting-api/src/main/java/org/apache/sirona/reporting/web/jmx/JMXServices.java   (with props)

Added: incubator/sirona/trunk/server/reporting/reporting-api/src/main/java/org/apache/sirona/reporting/web/jmx/JMXServices.java
URL: http://svn.apache.org/viewvc/incubator/sirona/trunk/server/reporting/reporting-api/src/main/java/org/apache/sirona/reporting/web/jmx/JMXServices.java?rev=1622657&view=auto
==============================================================================
--- incubator/sirona/trunk/server/reporting/reporting-api/src/main/java/org/apache/sirona/reporting/web/jmx/JMXServices.java (added)
+++ incubator/sirona/trunk/server/reporting/reporting-api/src/main/java/org/apache/sirona/reporting/web/jmx/JMXServices.java Fri Sep  5 09:25:00 2014
@@ -0,0 +1,81 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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.sirona.reporting.web.jmx;
+
+import org.apache.commons.codec.binary.Base64;
+
+import javax.management.InstanceNotFoundException;
+import javax.management.IntrospectionException;
+import javax.management.MBeanInfo;
+import javax.management.MBeanServerConnection;
+import javax.management.MalformedObjectNameException;
+import javax.management.ObjectInstance;
+import javax.management.ObjectName;
+import javax.management.ReflectionException;
+import javax.ws.rs.GET;
+import javax.ws.rs.Path;
+import javax.ws.rs.PathParam;
+import javax.ws.rs.Produces;
+import javax.ws.rs.core.MediaType;
+import java.io.IOException;
+import java.lang.management.ManagementFactory;
+
+/**
+ * @since 0.3
+ */
+@Path( "/jmx" )
+public class JMXServices
+{
+    protected final MBeanServerConnection server = ManagementFactory.getPlatformMBeanServer();
+
+    @GET
+    @Produces( { MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML } )
+    public JMXNode root()
+        throws IOException
+    {
+        JMXNode jmxNode = buildJmxTree();
+        return jmxNode;
+    }
+
+    @GET
+    @Path( "/{encodedName}" )
+    @Produces( { MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML } )
+    public MBeanInfo find(@PathParam( "encodedName" ) String encodedName )
+        throws IOException, MalformedObjectNameException, InstanceNotFoundException, IntrospectionException,
+        ReflectionException
+    {
+        final ObjectName name = new ObjectName( new String( Base64.decodeBase64( encodedName ) ) );
+        final MBeanInfo info = server.getMBeanInfo( name );
+        return info;
+    }
+
+
+    private JMXNode buildJmxTree()
+        throws IOException
+    {
+        final JMXNode root = new JMXNode( "/" );
+
+        for ( final ObjectInstance instance : server.queryMBeans( null, null ) )
+        {
+            final ObjectName objectName = instance.getObjectName();
+            JMXNode.addNode( root, objectName.getDomain(), objectName.getKeyPropertyListString() );
+        }
+
+        return root;
+    }
+
+}

Propchange: incubator/sirona/trunk/server/reporting/reporting-api/src/main/java/org/apache/sirona/reporting/web/jmx/JMXServices.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/sirona/trunk/server/reporting/reporting-api/src/main/java/org/apache/sirona/reporting/web/jmx/JMXServices.java
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision