[jboss-cvs] JBoss Profiler SVN: r564 - in branches/JBossProfiler2: src and 17 other directories.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Tue Aug 25 18:26:45 EDT 2009
Author: clebert.suconic at jboss.com
Date: 2009-08-25 18:26:45 -0400 (Tue, 25 Aug 2009)
New Revision: 564
Added:
branches/JBossProfiler2/src/jdk16/
branches/JBossProfiler2/src/jdk16/main/
branches/JBossProfiler2/src/jdk16/main/org/
branches/JBossProfiler2/src/jdk16/main/org/jboss/
branches/JBossProfiler2/src/jdk16/main/org/jboss/profiler/
branches/JBossProfiler2/src/jdk16/main/org/jboss/profiler/jvmti/
branches/JBossProfiler2/src/jdk16/main/org/jboss/profiler/jvmti/memoryweb/
branches/JBossProfiler2/src/jdk16/main/org/jboss/profiler/jvmti/memoryweb/AbstractHandler.java
branches/JBossProfiler2/src/jdk16/main/org/jboss/profiler/jvmti/memoryweb/InstancesHandler.java
branches/JBossProfiler2/src/jdk16/main/org/jboss/profiler/jvmti/memoryweb/ReferenceHandler.java
branches/JBossProfiler2/src/jdk16/main/org/jboss/profiler/jvmti/memoryweb/RootHandler.java
branches/JBossProfiler2/src/jdk16/main/org/jboss/profiler/jvmti/memoryweb/StopHandler.java
branches/JBossProfiler2/src/jdk16/main/org/jboss/profiler/jvmti/memoryweb/WebMemoryUI.java
branches/JBossProfiler2/src/jdk16/test/
branches/JBossProfiler2/src/jdk16/test/org/
branches/JBossProfiler2/src/jdk16/test/org/jboss/
branches/JBossProfiler2/src/jdk16/test/org/jboss/profiler/
branches/JBossProfiler2/src/jdk16/test/org/jboss/profiler/test/
branches/JBossProfiler2/src/jdk16/test/org/jboss/profiler/test/jvmti/
branches/JBossProfiler2/src/jdk16/test/org/jboss/profiler/test/jvmti/memoryweb/
branches/JBossProfiler2/src/jdk16/test/org/jboss/profiler/test/jvmti/memoryweb/JVMTIWebTestManual.java
branches/JBossProfiler2/src/main/org/jboss/profiler/jvmti/MemoryUI.java
Removed:
branches/JBossProfiler2/src/main/org/jboss/profiler/jvmti/memoryweb/AbstractHandler.java
branches/JBossProfiler2/src/main/org/jboss/profiler/jvmti/memoryweb/InstancesHandler.java
branches/JBossProfiler2/src/main/org/jboss/profiler/jvmti/memoryweb/MemoryProfilerEmbedded.java
branches/JBossProfiler2/src/main/org/jboss/profiler/jvmti/memoryweb/ReferenceHandler.java
branches/JBossProfiler2/src/main/org/jboss/profiler/jvmti/memoryweb/RootHandler.java
branches/JBossProfiler2/src/main/org/jboss/profiler/jvmti/memoryweb/StopHandler.java
branches/JBossProfiler2/src/test/java/org/jboss/profiler/test/jvmti/JVMTIWebTestManual.java
Modified:
branches/JBossProfiler2/.classpath
branches/JBossProfiler2/build.xml
branches/JBossProfiler2/src/main/org/jboss/profiler/jvmti/JVMTIInterface.java
Log:
Fixing JDK15 build
Modified: branches/JBossProfiler2/.classpath
===================================================================
--- branches/JBossProfiler2/.classpath 2009-08-18 21:41:47 UTC (rev 563)
+++ branches/JBossProfiler2/.classpath 2009-08-25 22:26:45 UTC (rev 564)
@@ -1,7 +1,9 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="src" path="src/main"/>
+ <classpathentry kind="src" path="src/jdk16/main"/>
<classpathentry kind="src" path="src/test/java"/>
+ <classpathentry kind="src" path="src/jdk16/test"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
<classpathentry kind="lib" path="lib/commons-beanutils.jar"/>
<classpathentry kind="lib" path="lib/commons-digester.jar"/>
Modified: branches/JBossProfiler2/build.xml
===================================================================
--- branches/JBossProfiler2/build.xml 2009-08-18 21:41:47 UTC (rev 563)
+++ branches/JBossProfiler2/build.xml 2009-08-25 22:26:45 UTC (rev 564)
@@ -1,12 +1,17 @@
<?xml version="1.0" encoding="ISO-8859-1"?>
<project name="jboss-profiler" default="dist" basedir=".">
+
+ <available classname="com.sun.net.httpserver.HttpServer" property="AVAILABLE_JDK_1.6"/>
+
+
<property name="build.dir" value="${basedir}/build"/>
<property name="lib.dir" value="${basedir}/lib"/>
<property name="doc.dir" value="${basedir}/doc"/>
<property name="doc.api.dir" value="${doc.dir}/api"/>
<property name="src.dir" value="${basedir}/src"/>
<property name="src.main.dir" value="${src.dir}/main"/>
+ <property name="src.main.jdk16.dir" value="${src.dir}/jdk16/main"/>
<property name="src.test.dir" value="${src.dir}/test"/>
<property name="etc.dir" value="${src.dir}/etc"/>
<property name="dist.dir" value="${basedir}/dist"/>
@@ -229,8 +234,25 @@
</target>
<!-- =================================================================== -->
- <!-- Embedded -->
+ <!-- JVMTI -->
<!-- =================================================================== -->
+ <target name="jvmti-jdk16" if="AVAILABLE_JDK_1.6">
+ <echo message="compiling"/>
+ <javac
+ destdir="${build.dir}"
+ classpathref="class.path"
+ debug="on"
+ deprecation="on"
+ optimize="off"
+ source="1.5"
+ target="1.5"
+ depend="false"
+ failonerror="true">
+ <src path="${src.main.jdk16.dir}"/>
+
+ </javac>
+ </target>
+
<target name="jvmti" depends="prepare">
<delete dir="${build.dir}"/>
<mkdir dir="${build.dir}"/>
@@ -250,6 +272,8 @@
<include name="org/jboss/profiler/jvmti/**/*.java" />
</javac>
+
+ <antcall target="jvmti-jdk16"/>
<copy todir="${build.dir}">
<fileset dir="${etc.dir}">
Copied: branches/JBossProfiler2/src/jdk16/main/org/jboss/profiler/jvmti/memoryweb/AbstractHandler.java (from rev 563, branches/JBossProfiler2/src/main/org/jboss/profiler/jvmti/memoryweb/AbstractHandler.java)
===================================================================
--- branches/JBossProfiler2/src/jdk16/main/org/jboss/profiler/jvmti/memoryweb/AbstractHandler.java (rev 0)
+++ branches/JBossProfiler2/src/jdk16/main/org/jboss/profiler/jvmti/memoryweb/AbstractHandler.java 2009-08-25 22:26:45 UTC (rev 564)
@@ -0,0 +1,130 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005-2009, Red Hat Middleware LLC, and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+
+package org.jboss.profiler.jvmti.memoryweb;
+
+import com.sun.net.httpserver.HttpExchange;
+import com.sun.net.httpserver.HttpHandler;
+
+import java.io.IOException;
+import java.io.PrintStream;
+import java.net.URI;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.StringTokenizer;
+
+/**
+ * A AbstractHandler
+ *
+ * @author <mailto:clebert.suconic at jboss.org">Clebert Suconic</a>
+ *
+ *
+ */
+public abstract class AbstractHandler implements HttpHandler
+{
+
+ // Constants -----------------------------------------------------
+
+ // Attributes ----------------------------------------------------
+
+ protected final WebMemoryUI server;
+
+ // Static --------------------------------------------------------
+
+ // Constructors --------------------------------------------------
+
+ // Public --------------------------------------------------------
+
+ /**
+ * @param server
+ */
+ public AbstractHandler(final WebMemoryUI server)
+ {
+ super();
+ this.server = server;
+ }
+
+ /* (non-Javadoc)
+ * @see com.sun.net.httpserver.HttpHandler#handle(com.sun.net.httpserver.HttpExchange)
+ */
+ public void handle(final HttpExchange exchange) throws IOException
+ {
+ exchange.getRequestBody().close();
+ PrintStream output = new PrintStream(exchange.getResponseBody());
+ try
+ {
+ exchange.sendResponseHeaders(200, 0);
+ output.println("<html><body>");
+ output.println("<a href='./'>Main Page</a><br/>");
+ output.println("<a href='./stop'>Stop</a><br/>");
+ output.println("<br/>");
+ handle(exchange, parseURI(exchange.getRequestURI()), output);
+ output.println("</body></html>");
+ output.close();
+ }
+ catch (Throwable e)
+ {
+ e.printStackTrace();
+ output.println("Error: " +
+ e.getMessage());
+ output.close();
+ }
+ }
+
+ public abstract void handle(HttpExchange exchange, Map<String, String> queryAttributes, PrintStream output)
+ throws Exception;
+
+ // Package protected ---------------------------------------------
+
+ // Protected -----------------------------------------------------
+
+ protected Map<String, String> parseURI(final URI uri)
+ {
+
+ HashMap<String, String> map = new HashMap<String, String>();
+
+ if (uri.getQuery() != null)
+ {
+
+ StringTokenizer tokens = new StringTokenizer(uri.getQuery(), "&");
+
+ while (tokens.hasMoreTokens())
+ {
+ String str = tokens.nextToken();
+
+ StringTokenizer tokenEqual = new StringTokenizer(str, "=");
+
+ String key = tokenEqual.nextToken();
+ String value = tokenEqual.nextToken();
+
+ map.put(key, value);
+ }
+ }
+
+ return map;
+ }
+
+ // Private -------------------------------------------------------
+
+ // Inner classes -------------------------------------------------
+
+}
Copied: branches/JBossProfiler2/src/jdk16/main/org/jboss/profiler/jvmti/memoryweb/InstancesHandler.java (from rev 563, branches/JBossProfiler2/src/main/org/jboss/profiler/jvmti/memoryweb/InstancesHandler.java)
===================================================================
--- branches/JBossProfiler2/src/jdk16/main/org/jboss/profiler/jvmti/memoryweb/InstancesHandler.java (rev 0)
+++ branches/JBossProfiler2/src/jdk16/main/org/jboss/profiler/jvmti/memoryweb/InstancesHandler.java 2009-08-25 22:26:45 UTC (rev 564)
@@ -0,0 +1,181 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005-2009, Red Hat Middleware LLC, and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+
+package org.jboss.profiler.jvmti.memoryweb;
+
+import org.jboss.profiler.jvmti.JVMTIInterface;
+import org.jboss.profiler.jvmti.JVMTITypes;
+import org.jboss.profiler.jvmti.ReferenceDataPoint;
+
+import com.sun.net.httpserver.HttpExchange;
+
+import java.io.PrintStream;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Map;
+
+/**
+ * A InstancesHandler
+ *
+ * @author <mailto:clebert.suconic at jboss.org">Clebert Suconic</a>
+ *
+ *
+ */
+public class InstancesHandler extends AbstractHandler
+{
+
+ // Constants -----------------------------------------------------
+
+ private static final int NUMBER_OF_ELEMENTS = 50;
+
+ // Attributes ----------------------------------------------------
+
+ // Static --------------------------------------------------------
+
+ // Constructors --------------------------------------------------
+ /**
+ * @param server
+ */
+ public InstancesHandler(final WebMemoryUI server)
+ {
+ super(server);
+ }
+
+ // Public --------------------------------------------------------
+
+ /* (non-Javadoc)
+ * @see org.jboss.profiler.jvmti.webembed.AbstractHandler#handle(com.sun.net.httpserver.HttpExchange, java.util.Map, java.io.PrintStream)
+ */
+ @Override
+ public synchronized void handle(final HttpExchange exchange, final Map<String, String> queryAttributes,
+ final PrintStream output) throws Exception
+ {
+ JVMTIInterface jvmti = server.getJvmti();
+ String classToPrint = queryAttributes.get("class");
+ String elementStr = queryAttributes.get("element");
+
+ if (elementStr == null)
+ {
+ elementStr = "0";
+ }
+
+ int elementNR = Integer.parseInt(elementStr);
+
+ output.println("<a href='./instances?class=" +
+ classToPrint + "&element=" + (elementNR + NUMBER_OF_ELEMENTS) + "'>NEXT</a>");
+ if (elementNR > 0)
+ {
+ output.println("<a href='./instances?class=" +
+ classToPrint + "&element=" + (elementNR - NUMBER_OF_ELEMENTS) + "'>PREVIOUS</a>");
+ }
+
+ output.println("<br/>");
+ output.println("<br/>");
+
+ Map<Long, List<ReferenceDataPoint>> index = server.getIndex();
+ if (index == null)
+ {
+ index = server.createIndex();
+ }
+
+ Class<?>[] clazzes = jvmti.getAllClassMachingName(classToPrint);
+
+ output.println("Classes:<br/>");
+ for (Class<?> clazzElement : clazzes)
+ {
+ long classTagId = jvmti.getTagOnObject(clazzElement);
+ output.println("<a href='./reference?obj0=" +
+ classTagId + "'>" + clazzElement.getCanonicalName() + " with ClassLoader = (" +
+ clazzElement.getClassLoader() + ")</a><br>");
+ }
+
+ output.println("<br/><br/> Instances:<br/><br/>");
+ Class clazz = jvmti.getClassByName(classToPrint);
+
+ if (clazz == null)
+ {
+ output.println("No Objects");
+ }
+
+ long objID = jvmti.getTagOnObject(clazz);
+
+ List<ReferenceDataPoint> references = index.get(objID);
+
+ if (references == null ||
+ references.size() == 0)
+ {
+ output.println("No Objects for " +
+ classToPrint);
+ return;
+ }
+
+ ArrayList<Long> objs = new ArrayList<Long>();
+
+ int elementFound = 0;
+ for (ReferenceDataPoint point : references)
+ {
+ System.out.println("Reference = " +
+ JVMTITypes.toString(point.getReferenceType()));
+ if (point.getReferenceType() == JVMTITypes.JVMTI_REFERENCE_INSTANCE)
+ {
+ if (elementFound++ >= elementNR)
+ {
+ if (point.getReferenceHolder() != 0)
+ {
+ objs.add(point.getReferenceHolder());
+ }
+ }
+
+ if (objs.size() > NUMBER_OF_ELEMENTS)
+ {
+ break;
+ }
+ }
+ }
+
+ for (Long objReferencedID : objs)
+ {
+ Object referenced = jvmti.getObjectOnTag(objReferencedID);
+ String strName;
+ if (referenced == null)
+ {
+ strName = "Null";
+ }
+ else
+ {
+ strName = referenced.toString();
+ }
+
+ output.println("<a href='./reference?obj0=" +
+ objReferencedID + "'>" + strName + "</a><br/>");
+ }
+
+ }
+ // Package protected ---------------------------------------------
+
+ // Protected -----------------------------------------------------
+
+ // Private -------------------------------------------------------
+
+ // Inner classes -------------------------------------------------
+
+}
Copied: branches/JBossProfiler2/src/jdk16/main/org/jboss/profiler/jvmti/memoryweb/ReferenceHandler.java (from rev 563, branches/JBossProfiler2/src/main/org/jboss/profiler/jvmti/memoryweb/ReferenceHandler.java)
===================================================================
--- branches/JBossProfiler2/src/jdk16/main/org/jboss/profiler/jvmti/memoryweb/ReferenceHandler.java (rev 0)
+++ branches/JBossProfiler2/src/jdk16/main/org/jboss/profiler/jvmti/memoryweb/ReferenceHandler.java 2009-08-25 22:26:45 UTC (rev 564)
@@ -0,0 +1,225 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005-2009, Red Hat Middleware LLC, and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+
+package org.jboss.profiler.jvmti.memoryweb;
+
+import org.jboss.profiler.jvmti.JVMTIInterface;
+import org.jboss.profiler.jvmti.JVMTITypes;
+import org.jboss.profiler.jvmti.ReferenceDataPoint;
+
+import com.sun.net.httpserver.HttpExchange;
+
+import java.io.PrintStream;
+import java.lang.reflect.Field;
+import java.util.List;
+import java.util.Map;
+
+/**
+ * A ReferenceHandler
+ *
+ * @author <mailto:clebert.suconic at jboss.org">Clebert Suconic</a>
+ *
+ *
+ */
+public class ReferenceHandler extends AbstractHandler
+{
+
+ // Constants -----------------------------------------------------
+
+ // Attributes ----------------------------------------------------
+
+ // Static --------------------------------------------------------
+
+ // Constructors --------------------------------------------------
+ /**
+ * @param server
+ */
+ public ReferenceHandler(final WebMemoryUI server)
+ {
+ super(server);
+ }
+
+ // Public --------------------------------------------------------
+
+ /* (non-Javadoc)
+ * @see org.jboss.profiler.jvmti.webembed.AbstractHandler#handle(com.sun.net.httpserver.HttpExchange, java.util.Map, java.io.PrintStream)
+ */
+ @Override
+ public synchronized void handle(final HttpExchange exchange, final Map<String, String> queryAttributes,
+ final PrintStream output) throws Exception
+ {
+
+ String query = exchange.getRequestURI().getRawQuery();
+
+ JVMTIInterface jvmti = server.getJvmti();
+
+ Map<Long, List<ReferenceDataPoint>> index = server.getIndex();
+
+ if (index == null)
+ {
+ index = server.createIndex();
+ }
+
+ int nparams = 0;
+
+ Object obj;
+ long objId = 0;
+
+ while (true)
+ {
+ if (queryAttributes.get("obj" +
+ nparams) != null)
+ {
+ if (nparams > 0)
+ {
+ output.println(" -> ");
+ }
+ objId = Integer.parseInt(queryAttributes.get("obj" +
+ nparams));
+ obj = jvmti.getObjectOnTag(objId);
+
+ String name = obj != null
+ ? obj.toString() : "Null";
+
+ for (int i = 0; i < nparams; i++)
+ {
+ output.print("...");
+ }
+
+ output.print(name +
+ "<br/>");
+ nparams++;
+ }
+ else
+ {
+ break;
+ }
+ }
+
+ List<ReferenceDataPoint> list = index.get(objId);
+
+ if (list == null ||
+ list.isEmpty())
+ {
+ output.println("Empty!");
+ return;
+ }
+
+ for (ReferenceDataPoint point : list)
+ {
+ String newURL = "./reference?" +
+ query + "&obj" + nparams + "=" + point.getReferenceHolder();
+
+ Object referenceHolder = null;
+ if (point.getReferenceHolder() > 0)
+ {
+ referenceHolder = jvmti.getObjectOnTag(point.getReferenceHolder());
+ }
+
+ if (point.getReferenceType() == JVMTITypes.JVMTI_REFERENCE_FIELD)
+ {
+ Class<?> referenceClass = null;
+ Field referencedField = null;
+ if (referenceHolder != null)
+ {
+ referenceClass = referenceHolder.getClass();
+
+ referencedField = jvmti.getObjectField(referenceClass, (int)point.getIndex());
+ }
+
+ if (referencedField != null)
+ {
+ output.println("Field reference:" +
+ referencedField.getDeclaringClass().getCanonicalName() + "::" + referencedField.getName() +
+
+ "<a href='" + newURL + "'>(" + jvmti.convertToString(referenceHolder, true) + ")</a><br/>");
+ }
+ else
+ {
+ output.println("<a href='./reference?" +
+ query + "&obj" + nparams + "=" + point.getReferenceHolder() + "'>Unkown Field reference</a><br/>");
+ }
+
+ }
+ else if (point.getReferenceType() == JVMTITypes.JVMTI_REFERENCE_ARRAY_ELEMENT)
+ {
+ if (referenceHolder == null)
+ {
+ output.println("Array reference (gone)</br>");
+ }
+ else
+ {
+ output.println("Array Refeference: <a href='" +
+ newURL + "'>" + "array[" + point.getIndex() + "]</a><br/>");
+ }
+ }
+ else if (point.getReferenceType() == JVMTITypes.ROOT_REFERENCE)
+ {
+ output.println("ROOT</br>");
+ }
+ else if (point.getReferenceType() == JVMTITypes.THREAD_REFERENCE)
+ {
+
+ Class<?> methodClass = jvmti.getMethodClass(point.getMethod());
+ if (methodClass != null)
+ {
+ String className = null;
+ if (methodClass != null)
+ {
+ className = methodClass.getName();
+ }
+
+ String methodName = jvmti.getMethodName(point.getMethod());
+ output.println("<br> Reference inside a method - " +
+ className + "::" + methodName);
+ }
+ }
+ else if (point.getReferenceType() == JVMTITypes.JVMTI_REFERENCE_STATIC_FIELD)
+ {
+ Class<?> clazz = (Class<?>)referenceHolder;
+ Field field = jvmti.getObjectField(clazz, (int)point.getIndex());
+ String fieldName = null;
+ if (field == null)
+ {
+ fieldName = "UndefinedField@" +
+ referenceHolder;
+ }
+ else
+ {
+ fieldName = field.toString();
+ }
+ output.println("<a href='" +
+ newURL + "'>Static field reference:" + fieldName + "</a>");
+ }
+
+ }
+ }
+
+ // Package protected ---------------------------------------------
+
+ // Protected -----------------------------------------------------
+
+ // Private -------------------------------------------------------
+
+ // Inner classes -------------------------------------------------
+
+}
Copied: branches/JBossProfiler2/src/jdk16/main/org/jboss/profiler/jvmti/memoryweb/RootHandler.java (from rev 563, branches/JBossProfiler2/src/main/org/jboss/profiler/jvmti/memoryweb/RootHandler.java)
===================================================================
--- branches/JBossProfiler2/src/jdk16/main/org/jboss/profiler/jvmti/memoryweb/RootHandler.java (rev 0)
+++ branches/JBossProfiler2/src/jdk16/main/org/jboss/profiler/jvmti/memoryweb/RootHandler.java 2009-08-25 22:26:45 UTC (rev 564)
@@ -0,0 +1,109 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005-2009, Red Hat Middleware LLC, and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+
+package org.jboss.profiler.jvmti.memoryweb;
+
+import org.jboss.profiler.jvmti.InventoryDataPoint;
+
+import com.sun.net.httpserver.HttpExchange;
+
+import java.io.PrintStream;
+import java.net.URLEncoder;
+import java.util.Iterator;
+import java.util.Map;
+import java.util.TreeSet;
+
+/**
+ * A RootHandler
+ *
+ * @author <mailto:clebert.suconic at jboss.org">Clebert Suconic</a>
+ *
+ *
+ */
+public class RootHandler extends AbstractHandler
+{
+
+ // Constants -----------------------------------------------------
+
+ // Attributes ----------------------------------------------------
+
+ // Static --------------------------------------------------------
+
+ // Constructors --------------------------------------------------
+
+ /**
+ * @param server
+ */
+ public RootHandler(final WebMemoryUI server)
+ {
+ super(server);
+ }
+
+ // Public --------------------------------------------------------
+
+ /* (non-Javadoc)
+ * @see org.jboss.profiler.jvmti.webembed.AbstractHandler#handle(com.sun.net.httpserver.HttpExchange, java.util.Map)
+ */
+ @Override
+ public synchronized void handle(final HttpExchange exchange, final Map<String, String> queryAttributes,
+ final PrintStream output) throws Exception
+ {
+ server.clearIndex();
+
+ Map<Class<?>, InventoryDataPoint> inventory = server.getJvmti().produceInventory();
+
+ TreeSet<InventoryDataPoint> points = new TreeSet<InventoryDataPoint>(inventory.values());
+ Iterator iterDataPoints = points.iterator();
+
+ output.println("<table>");
+
+ output.println("<tr><td>Name</td><td>#Instances</td><td>#Bytes</td></tr>");
+
+ while (iterDataPoints.hasNext())
+ {
+ InventoryDataPoint point = (InventoryDataPoint)iterDataPoints.next();
+ output.println("<tr><td><a href='./instances?class=" +
+ URLEncoder.encode(point.getClazz().getName()) + "'>" + point.getClazz().getName() + "</a>" +
+ "</td><td>" + point.getInstances() + "</td><td>" + point.getBytes() + "</td></tr>");
+ }
+
+ output.println("</table>");
+ }
+
+ public synchronized void handle2(final HttpExchange exchange, final Map<String, String> queryAttributes,
+ final PrintStream output) throws Exception
+ {
+ server.clearIndex();
+
+ output.println(server.getJvmti().inventoryReport(true));
+
+ }
+
+ // Package protected ---------------------------------------------
+
+ // Protected -----------------------------------------------------
+
+ // Private -------------------------------------------------------
+
+ // Inner classes -------------------------------------------------
+
+}
Copied: branches/JBossProfiler2/src/jdk16/main/org/jboss/profiler/jvmti/memoryweb/StopHandler.java (from rev 563, branches/JBossProfiler2/src/main/org/jboss/profiler/jvmti/memoryweb/StopHandler.java)
===================================================================
--- branches/JBossProfiler2/src/jdk16/main/org/jboss/profiler/jvmti/memoryweb/StopHandler.java (rev 0)
+++ branches/JBossProfiler2/src/jdk16/main/org/jboss/profiler/jvmti/memoryweb/StopHandler.java 2009-08-25 22:26:45 UTC (rev 564)
@@ -0,0 +1,76 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005-2009, Red Hat Middleware LLC, and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+
+package org.jboss.profiler.jvmti.memoryweb;
+
+import com.sun.net.httpserver.HttpExchange;
+
+import java.io.PrintStream;
+import java.util.Map;
+
+/**
+ * A StopHandler
+ *
+ * @author <mailto:clebert.suconic at jboss.org">Clebert Suconic</a>
+ *
+ *
+ */
+public class StopHandler extends AbstractHandler
+{
+
+ // Constants -----------------------------------------------------
+
+ // Attributes ----------------------------------------------------
+
+ // Static --------------------------------------------------------
+
+ // Constructors --------------------------------------------------
+ /**
+ * @param server
+ */
+ public StopHandler(final WebMemoryUI server)
+ {
+ super(server);
+ }
+
+ // Public --------------------------------------------------------
+
+ /* (non-Javadoc)
+ * @see org.jboss.profiler.jvmti.webembed.AbstractHandler#handle(com.sun.net.httpserver.HttpExchange, java.util.Map, java.io.PrintStream)
+ */
+ @Override
+ public void handle(final HttpExchange exchange, final Map<String, String> queryAttributes, final PrintStream output)
+ throws Exception
+ {
+ output.println("Profiler stopped");
+ server.stop();
+ }
+
+ // Package protected ---------------------------------------------
+
+ // Protected -----------------------------------------------------
+
+ // Private -------------------------------------------------------
+
+ // Inner classes -------------------------------------------------
+
+}
Copied: branches/JBossProfiler2/src/jdk16/main/org/jboss/profiler/jvmti/memoryweb/WebMemoryUI.java (from rev 563, branches/JBossProfiler2/src/main/org/jboss/profiler/jvmti/memoryweb/MemoryProfilerEmbedded.java)
===================================================================
--- branches/JBossProfiler2/src/jdk16/main/org/jboss/profiler/jvmti/memoryweb/WebMemoryUI.java (rev 0)
+++ branches/JBossProfiler2/src/jdk16/main/org/jboss/profiler/jvmti/memoryweb/WebMemoryUI.java 2009-08-25 22:26:45 UTC (rev 564)
@@ -0,0 +1,180 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005-2009, Red Hat Middleware LLC, and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+
+package org.jboss.profiler.jvmti.memoryweb;
+
+import org.jboss.profiler.jvmti.JVMTIInterface;
+import org.jboss.profiler.jvmti.MemoryUI;
+import org.jboss.profiler.jvmti.ReferenceDataPoint;
+
+import com.sun.net.httpserver.HttpServer;
+
+import java.net.InetSocketAddress;
+import java.util.List;
+import java.util.Map;
+import java.util.concurrent.CountDownLatch;
+
+/**
+ * A WebMemoryUI
+ *
+ * @author <mailto:clebert.suconic at jboss.org">Clebert Suconic</a>
+ *
+ *
+ */
+public class WebMemoryUI implements MemoryUI
+{
+
+ // Constants -----------------------------------------------------
+
+ // Attributes ----------------------------------------------------
+
+ private HttpServer server;
+
+ private volatile CountDownLatch running;
+
+ private final InetSocketAddress address;
+
+ private final JVMTIInterface jvmti;
+
+ private Map<Long, List<ReferenceDataPoint>> index;
+
+ // Static --------------------------------------------------------
+
+ // Constructors --------------------------------------------------
+
+ /**
+ * @param running
+ */
+ public WebMemoryUI(final InetSocketAddress address,
+ final JVMTIInterface jvmti)
+ {
+ super();
+ this.address = address;
+ this.jvmti = jvmti;
+ }
+
+ // Public --------------------------------------------------------
+
+
+ /* (non-Javadoc)
+ * @see org.jboss.profiler.jvmti.MemoryUI#startMemoryProfiler(java.util.concurrent.CountDownLatch)
+ */
+ public void start(CountDownLatch latchRunning) throws Exception
+ {
+ System.out.println("JBoss Web Memory Profiler running on " +
+ address);
+
+ this.running = latchRunning;
+
+ server = HttpServer.create(address, 0);
+
+ server.createContext("/", new RootHandler(this));
+ server.createContext("/instances", new InstancesHandler(this));
+ server.createContext("/reference", new ReferenceHandler(this));
+ server.createContext("/stop", new StopHandler(this));
+
+ server.start();
+ }
+
+
+ public void start() throws Exception
+ {
+ CountDownLatch latchRunning = new CountDownLatch(1);
+ start(latchRunning);
+ latchRunning.await();
+ }
+
+ /**
+ * @return the running
+ */
+ public CountDownLatch getRunning()
+ {
+ return running;
+ }
+
+ /**
+ * @return the address
+ */
+ public InetSocketAddress getAddress()
+ {
+ return address;
+ }
+
+ /**
+ * @return the jvmti
+ */
+ public JVMTIInterface getJvmti()
+ {
+ return jvmti;
+ }
+
+ public void clearIndex()
+ {
+ jvmti.releaseTags();
+ if (index != null)
+ {
+ index.clear();
+ }
+ index = null;
+ }
+
+ public Map<Long, List<ReferenceDataPoint>> createIndex() throws Exception
+ {
+ clearIndex();
+
+ index = jvmti.createIndexMatrix();
+
+ return index;
+ }
+
+ public Map<Long, List<ReferenceDataPoint>> getIndex() throws Exception
+ {
+ return index;
+ }
+
+ /**
+ *
+ */
+ public void stop() throws Exception
+ {
+ new Thread()
+ {
+ @Override
+ public void run()
+ {
+
+ server.stop(0);
+ running.countDown();
+ server = null;
+ }
+ }.start();
+ }
+
+ // Package protected ---------------------------------------------
+
+ // Protected -----------------------------------------------------
+
+ // Private -------------------------------------------------------
+
+ // Inner classes -------------------------------------------------
+
+}
Copied: branches/JBossProfiler2/src/jdk16/test/org/jboss/profiler/test/jvmti/memoryweb/JVMTIWebTestManual.java (from rev 563, branches/JBossProfiler2/src/test/java/org/jboss/profiler/test/jvmti/JVMTIWebTestManual.java)
===================================================================
--- branches/JBossProfiler2/src/jdk16/test/org/jboss/profiler/test/jvmti/memoryweb/JVMTIWebTestManual.java (rev 0)
+++ branches/JBossProfiler2/src/jdk16/test/org/jboss/profiler/test/jvmti/memoryweb/JVMTIWebTestManual.java 2009-08-25 22:26:45 UTC (rev 564)
@@ -0,0 +1,97 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005-2009, Red Hat Middleware LLC, and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+
+package org.jboss.profiler.test.jvmti.memoryweb;
+
+import java.net.InetSocketAddress;
+import java.util.concurrent.CountDownLatch;
+
+import org.jboss.profiler.jvmti.JVMTIInterface;
+import org.jboss.profiler.jvmti.memoryweb.WebMemoryUI;
+import org.jboss.profiler.test.jvmti.TestClass;
+
+/**
+ *
+ * This test has to be done manually, as it is done to validate the UI.
+ *
+ * Add this to you VM options:
+ *
+ * -Djava.library.path=/work/projects/prof2/src/native/ -agentpath:/work/projects/prof2/src/native/libJBossProfiler.so
+ *
+ * Execute this test, and navigate through the interface. open http://localhost:3232
+ *
+ * This test should stop When you press stop on the WebInterface
+ *
+ * Look for the strings created at this test
+ *
+ * @author <mailto:clebert.suconic at jboss.org">Clebert Suconic</a>
+ *
+ *
+ */
+public class JVMTIWebTestManual
+{
+ TestClass str2[] = null;
+
+ TestClass strroot;
+
+ static TestClass staticField;
+
+ public static void main(String arg[])
+ {
+ try
+ {
+ JVMTIWebTestManual manual = new JVMTIWebTestManual();
+ manual.testWeb();
+ }
+ catch (Exception e)
+ {
+ e.printStackTrace();
+ }
+ }
+
+ public void testWeb() throws Exception
+ {
+ TestClass str[] = new TestClass[1000];
+
+ for (int i = 0 ; i < 1000; i++)
+ {
+ str[i] = new TestClass();
+ }
+
+ str2 = str;
+
+ TestClass strroot2 = str[0];
+ strroot = str[0];
+
+ staticField = str[0];
+
+ JVMTIInterface jvmti = new JVMTIInterface();
+
+ System.out.println(jvmti.inventoryReport(false));
+
+ WebMemoryUI web = new WebMemoryUI(new InetSocketAddress(3232), jvmti);
+ web.start();
+
+ System.out.println("strroot = " + strroot2);
+ }
+
+}
Modified: branches/JBossProfiler2/src/main/org/jboss/profiler/jvmti/JVMTIInterface.java
===================================================================
--- branches/JBossProfiler2/src/main/org/jboss/profiler/jvmti/JVMTIInterface.java 2009-08-18 21:41:47 UTC (rev 563)
+++ branches/JBossProfiler2/src/main/org/jboss/profiler/jvmti/JVMTIInterface.java 2009-08-25 22:26:45 UTC (rev 564)
@@ -22,8 +22,6 @@
package org.jboss.profiler.jvmti;
-import org.jboss.profiler.jvmti.memoryweb.MemoryProfilerEmbedded;
-
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.CharArrayWriter;
@@ -37,7 +35,6 @@
import java.lang.ref.SoftReference;
import java.lang.ref.WeakReference;
import java.lang.reflect.Field;
-import java.net.InetSocketAddress;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
@@ -49,7 +46,6 @@
import java.util.Map;
import java.util.TreeSet;
import java.util.WeakHashMap;
-import java.util.concurrent.CountDownLatch;
/**
* @author Clebert Suconic
@@ -960,21 +956,6 @@
private static final long serialVersionUID = 1L;
}
- public void startMemoryProfiler(final InetSocketAddress address, final CountDownLatch latchRunning) throws Exception
- {
- System.out.println("JBoss Memory Profiler running on " +
- address);
- MemoryProfilerEmbedded profilerServer = new MemoryProfilerEmbedded(address, latchRunning, this);
- profilerServer.start();
- }
-
- public void startMemoryProfiler(final InetSocketAddress address) throws Exception
- {
- CountDownLatch latchRunning = new CountDownLatch(1);
- startMemoryProfiler(address, latchRunning);
- latchRunning.await();
- }
-
/**
* Will show a report of every class loaded on this JVM. At the beggining of
* the report you will see duplicated classes (classes loaded in more than
Added: branches/JBossProfiler2/src/main/org/jboss/profiler/jvmti/MemoryUI.java
===================================================================
--- branches/JBossProfiler2/src/main/org/jboss/profiler/jvmti/MemoryUI.java (rev 0)
+++ branches/JBossProfiler2/src/main/org/jboss/profiler/jvmti/MemoryUI.java 2009-08-25 22:26:45 UTC (rev 564)
@@ -0,0 +1,71 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005-2009, Red Hat Middleware LLC, and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+
+
+package org.jboss.profiler.jvmti;
+
+import java.util.concurrent.CountDownLatch;
+
+/**
+ * A MemoryUI
+ *
+ * @author <mailto:clebert.suconic at jboss.org">Clebert Suconic</a>
+ *
+ *
+ */
+public interface MemoryUI
+{
+
+ // Constants -----------------------------------------------------
+
+ // Attributes ----------------------------------------------------
+
+ // Static --------------------------------------------------------
+
+ // Constructors --------------------------------------------------
+
+ // Public --------------------------------------------------------
+
+
+ /**
+ * Start the Memory Profiler UI
+ * @param address The Inet Address
+ * @param latchRunning A CountDownLatch that will be updated when the UI is finished
+ */
+ void start(final CountDownLatch latchRunning) throws Exception;
+
+ /**
+ * Start the Memory Profiler UI. It should block until the UI is finished.
+ */
+ void start() throws Exception;
+
+
+
+ // Package protected ---------------------------------------------
+
+ // Protected -----------------------------------------------------
+
+ // Private -------------------------------------------------------
+
+ // Inner classes -------------------------------------------------
+
+}
Deleted: branches/JBossProfiler2/src/main/org/jboss/profiler/jvmti/memoryweb/AbstractHandler.java
===================================================================
--- branches/JBossProfiler2/src/main/org/jboss/profiler/jvmti/memoryweb/AbstractHandler.java 2009-08-18 21:41:47 UTC (rev 563)
+++ branches/JBossProfiler2/src/main/org/jboss/profiler/jvmti/memoryweb/AbstractHandler.java 2009-08-25 22:26:45 UTC (rev 564)
@@ -1,130 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2005-2009, Red Hat Middleware LLC, and individual contributors
- * by the @authors tag. See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-
-package org.jboss.profiler.jvmti.memoryweb;
-
-import com.sun.net.httpserver.HttpExchange;
-import com.sun.net.httpserver.HttpHandler;
-
-import java.io.IOException;
-import java.io.PrintStream;
-import java.net.URI;
-import java.util.HashMap;
-import java.util.Map;
-import java.util.StringTokenizer;
-
-/**
- * A AbstractHandler
- *
- * @author <mailto:clebert.suconic at jboss.org">Clebert Suconic</a>
- *
- *
- */
-public abstract class AbstractHandler implements HttpHandler
-{
-
- // Constants -----------------------------------------------------
-
- // Attributes ----------------------------------------------------
-
- protected final MemoryProfilerEmbedded server;
-
- // Static --------------------------------------------------------
-
- // Constructors --------------------------------------------------
-
- // Public --------------------------------------------------------
-
- /**
- * @param server
- */
- public AbstractHandler(final MemoryProfilerEmbedded server)
- {
- super();
- this.server = server;
- }
-
- /* (non-Javadoc)
- * @see com.sun.net.httpserver.HttpHandler#handle(com.sun.net.httpserver.HttpExchange)
- */
- public void handle(final HttpExchange exchange) throws IOException
- {
- exchange.getRequestBody().close();
- PrintStream output = new PrintStream(exchange.getResponseBody());
- try
- {
- exchange.sendResponseHeaders(200, 0);
- output.println("<html><body>");
- output.println("<a href='./'>Main Page</a><br/>");
- output.println("<a href='./stop'>Stop</a><br/>");
- output.println("<br/>");
- handle(exchange, parseURI(exchange.getRequestURI()), output);
- output.println("</body></html>");
- output.close();
- }
- catch (Throwable e)
- {
- e.printStackTrace();
- output.println("Error: " +
- e.getMessage());
- output.close();
- }
- }
-
- public abstract void handle(HttpExchange exchange, Map<String, String> queryAttributes, PrintStream output)
- throws Exception;
-
- // Package protected ---------------------------------------------
-
- // Protected -----------------------------------------------------
-
- protected Map<String, String> parseURI(final URI uri)
- {
-
- HashMap<String, String> map = new HashMap<String, String>();
-
- if (uri.getQuery() != null)
- {
-
- StringTokenizer tokens = new StringTokenizer(uri.getQuery(), "&");
-
- while (tokens.hasMoreTokens())
- {
- String str = tokens.nextToken();
-
- StringTokenizer tokenEqual = new StringTokenizer(str, "=");
-
- String key = tokenEqual.nextToken();
- String value = tokenEqual.nextToken();
-
- map.put(key, value);
- }
- }
-
- return map;
- }
-
- // Private -------------------------------------------------------
-
- // Inner classes -------------------------------------------------
-
-}
Deleted: branches/JBossProfiler2/src/main/org/jboss/profiler/jvmti/memoryweb/InstancesHandler.java
===================================================================
--- branches/JBossProfiler2/src/main/org/jboss/profiler/jvmti/memoryweb/InstancesHandler.java 2009-08-18 21:41:47 UTC (rev 563)
+++ branches/JBossProfiler2/src/main/org/jboss/profiler/jvmti/memoryweb/InstancesHandler.java 2009-08-25 22:26:45 UTC (rev 564)
@@ -1,181 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2005-2009, Red Hat Middleware LLC, and individual contributors
- * by the @authors tag. See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-
-package org.jboss.profiler.jvmti.memoryweb;
-
-import org.jboss.profiler.jvmti.JVMTIInterface;
-import org.jboss.profiler.jvmti.JVMTITypes;
-import org.jboss.profiler.jvmti.ReferenceDataPoint;
-
-import com.sun.net.httpserver.HttpExchange;
-
-import java.io.PrintStream;
-import java.util.ArrayList;
-import java.util.List;
-import java.util.Map;
-
-/**
- * A InstancesHandler
- *
- * @author <mailto:clebert.suconic at jboss.org">Clebert Suconic</a>
- *
- *
- */
-public class InstancesHandler extends AbstractHandler
-{
-
- // Constants -----------------------------------------------------
-
- private static final int NUMBER_OF_ELEMENTS = 50;
-
- // Attributes ----------------------------------------------------
-
- // Static --------------------------------------------------------
-
- // Constructors --------------------------------------------------
- /**
- * @param server
- */
- public InstancesHandler(final MemoryProfilerEmbedded server)
- {
- super(server);
- }
-
- // Public --------------------------------------------------------
-
- /* (non-Javadoc)
- * @see org.jboss.profiler.jvmti.webembed.AbstractHandler#handle(com.sun.net.httpserver.HttpExchange, java.util.Map, java.io.PrintStream)
- */
- @Override
- public synchronized void handle(final HttpExchange exchange, final Map<String, String> queryAttributes,
- final PrintStream output) throws Exception
- {
- JVMTIInterface jvmti = server.getJvmti();
- String classToPrint = queryAttributes.get("class");
- String elementStr = queryAttributes.get("element");
-
- if (elementStr == null)
- {
- elementStr = "0";
- }
-
- int elementNR = Integer.parseInt(elementStr);
-
- output.println("<a href='./instances?class=" +
- classToPrint + "&element=" + (elementNR + NUMBER_OF_ELEMENTS) + "'>NEXT</a>");
- if (elementNR > 0)
- {
- output.println("<a href='./instances?class=" +
- classToPrint + "&element=" + (elementNR - NUMBER_OF_ELEMENTS) + "'>PREVIOUS</a>");
- }
-
- output.println("<br/>");
- output.println("<br/>");
-
- Map<Long, List<ReferenceDataPoint>> index = server.getIndex();
- if (index == null)
- {
- index = server.createIndex();
- }
-
- Class<?>[] clazzes = jvmti.getAllClassMachingName(classToPrint);
-
- output.println("Classes:<br/>");
- for (Class<?> clazzElement : clazzes)
- {
- long classTagId = jvmti.getTagOnObject(clazzElement);
- output.println("<a href='./reference?obj0=" +
- classTagId + "'>" + clazzElement.getCanonicalName() + " with ClassLoader = (" +
- clazzElement.getClassLoader() + ")</a><br>");
- }
-
- output.println("<br/><br/> Instances:<br/><br/>");
- Class clazz = jvmti.getClassByName(classToPrint);
-
- if (clazz == null)
- {
- output.println("No Objects");
- }
-
- long objID = jvmti.getTagOnObject(clazz);
-
- List<ReferenceDataPoint> references = index.get(objID);
-
- if (references == null ||
- references.size() == 0)
- {
- output.println("No Objects for " +
- classToPrint);
- return;
- }
-
- ArrayList<Long> objs = new ArrayList<Long>();
-
- int elementFound = 0;
- for (ReferenceDataPoint point : references)
- {
- System.out.println("Reference = " +
- JVMTITypes.toString(point.getReferenceType()));
- if (point.getReferenceType() == JVMTITypes.JVMTI_REFERENCE_INSTANCE)
- {
- if (elementFound++ >= elementNR)
- {
- if (point.getReferenceHolder() != 0)
- {
- objs.add(point.getReferenceHolder());
- }
- }
-
- if (objs.size() > NUMBER_OF_ELEMENTS)
- {
- break;
- }
- }
- }
-
- for (Long objReferencedID : objs)
- {
- Object referenced = jvmti.getObjectOnTag(objReferencedID);
- String strName;
- if (referenced == null)
- {
- strName = "Null";
- }
- else
- {
- strName = referenced.toString();
- }
-
- output.println("<a href='./reference?obj0=" +
- objReferencedID + "'>" + strName + "</a><br/>");
- }
-
- }
- // Package protected ---------------------------------------------
-
- // Protected -----------------------------------------------------
-
- // Private -------------------------------------------------------
-
- // Inner classes -------------------------------------------------
-
-}
Deleted: branches/JBossProfiler2/src/main/org/jboss/profiler/jvmti/memoryweb/MemoryProfilerEmbedded.java
===================================================================
--- branches/JBossProfiler2/src/main/org/jboss/profiler/jvmti/memoryweb/MemoryProfilerEmbedded.java 2009-08-18 21:41:47 UTC (rev 563)
+++ branches/JBossProfiler2/src/main/org/jboss/profiler/jvmti/memoryweb/MemoryProfilerEmbedded.java 2009-08-25 22:26:45 UTC (rev 564)
@@ -1,165 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2005-2009, Red Hat Middleware LLC, and individual contributors
- * by the @authors tag. See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-
-package org.jboss.profiler.jvmti.memoryweb;
-
-import org.jboss.profiler.jvmti.JVMTIInterface;
-import org.jboss.profiler.jvmti.ReferenceDataPoint;
-
-import com.sun.net.httpserver.HttpServer;
-
-import java.net.InetSocketAddress;
-import java.util.List;
-import java.util.Map;
-import java.util.concurrent.CountDownLatch;
-
-/**
- * A MemoryProfilerEmbedded
- *
- * @author <mailto:clebert.suconic at jboss.org">Clebert Suconic</a>
- *
- *
- */
-public class MemoryProfilerEmbedded
-{
-
- // Constants -----------------------------------------------------
-
- // Attributes ----------------------------------------------------
-
- private HttpServer server;
-
- private final CountDownLatch running;
-
- private final InetSocketAddress address;
-
- private final JVMTIInterface jvmti;
-
- private Map<Long, List<ReferenceDataPoint>> index;
-
- // Static --------------------------------------------------------
-
- // Constructors --------------------------------------------------
-
- /**
- * @param running
- */
- public MemoryProfilerEmbedded(final InetSocketAddress address,
- final CountDownLatch running,
- final JVMTIInterface jvmti)
- {
- super();
- this.running = running;
- this.address = address;
- this.jvmti = jvmti;
- }
-
- // Public --------------------------------------------------------
-
- public void start() throws Exception
- {
-
- server = HttpServer.create(address, 0);
-
- server.createContext("/", new RootHandler(this));
- server.createContext("/instances", new InstancesHandler(this));
- server.createContext("/reference", new ReferenceHandler(this));
- server.createContext("/stop", new StopHandler(this));
-
- server.start();
- }
-
- /**
- * @return the running
- */
- public CountDownLatch getRunning()
- {
- return running;
- }
-
- /**
- * @return the address
- */
- public InetSocketAddress getAddress()
- {
- return address;
- }
-
- /**
- * @return the jvmti
- */
- public JVMTIInterface getJvmti()
- {
- return jvmti;
- }
-
- public void clearIndex()
- {
- jvmti.releaseTags();
- if (index != null)
- {
- index.clear();
- }
- index = null;
- }
-
- public Map<Long, List<ReferenceDataPoint>> createIndex() throws Exception
- {
- clearIndex();
-
- index = jvmti.createIndexMatrix();
-
- return index;
- }
-
- public Map<Long, List<ReferenceDataPoint>> getIndex() throws Exception
- {
- return index;
- }
-
- /**
- *
- */
- public void stop() throws Exception
- {
- new Thread()
- {
- @Override
- public void run()
- {
-
- server.stop(0);
- running.countDown();
- server = null;
- }
- }.start();
- }
-
- // Package protected ---------------------------------------------
-
- // Protected -----------------------------------------------------
-
- // Private -------------------------------------------------------
-
- // Inner classes -------------------------------------------------
-
-}
Deleted: branches/JBossProfiler2/src/main/org/jboss/profiler/jvmti/memoryweb/ReferenceHandler.java
===================================================================
--- branches/JBossProfiler2/src/main/org/jboss/profiler/jvmti/memoryweb/ReferenceHandler.java 2009-08-18 21:41:47 UTC (rev 563)
+++ branches/JBossProfiler2/src/main/org/jboss/profiler/jvmti/memoryweb/ReferenceHandler.java 2009-08-25 22:26:45 UTC (rev 564)
@@ -1,225 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2005-2009, Red Hat Middleware LLC, and individual contributors
- * by the @authors tag. See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-
-package org.jboss.profiler.jvmti.memoryweb;
-
-import org.jboss.profiler.jvmti.JVMTIInterface;
-import org.jboss.profiler.jvmti.JVMTITypes;
-import org.jboss.profiler.jvmti.ReferenceDataPoint;
-
-import com.sun.net.httpserver.HttpExchange;
-
-import java.io.PrintStream;
-import java.lang.reflect.Field;
-import java.util.List;
-import java.util.Map;
-
-/**
- * A ReferenceHandler
- *
- * @author <mailto:clebert.suconic at jboss.org">Clebert Suconic</a>
- *
- *
- */
-public class ReferenceHandler extends AbstractHandler
-{
-
- // Constants -----------------------------------------------------
-
- // Attributes ----------------------------------------------------
-
- // Static --------------------------------------------------------
-
- // Constructors --------------------------------------------------
- /**
- * @param server
- */
- public ReferenceHandler(final MemoryProfilerEmbedded server)
- {
- super(server);
- }
-
- // Public --------------------------------------------------------
-
- /* (non-Javadoc)
- * @see org.jboss.profiler.jvmti.webembed.AbstractHandler#handle(com.sun.net.httpserver.HttpExchange, java.util.Map, java.io.PrintStream)
- */
- @Override
- public synchronized void handle(final HttpExchange exchange, final Map<String, String> queryAttributes,
- final PrintStream output) throws Exception
- {
-
- String query = exchange.getRequestURI().getRawQuery();
-
- JVMTIInterface jvmti = server.getJvmti();
-
- Map<Long, List<ReferenceDataPoint>> index = server.getIndex();
-
- if (index == null)
- {
- index = server.createIndex();
- }
-
- int nparams = 0;
-
- Object obj;
- long objId = 0;
-
- while (true)
- {
- if (queryAttributes.get("obj" +
- nparams) != null)
- {
- if (nparams > 0)
- {
- output.println(" -> ");
- }
- objId = Integer.parseInt(queryAttributes.get("obj" +
- nparams));
- obj = jvmti.getObjectOnTag(objId);
-
- String name = obj != null
- ? obj.toString() : "Null";
-
- for (int i = 0; i < nparams; i++)
- {
- output.print("...");
- }
-
- output.print(name +
- "<br/>");
- nparams++;
- }
- else
- {
- break;
- }
- }
-
- List<ReferenceDataPoint> list = index.get(objId);
-
- if (list == null ||
- list.isEmpty())
- {
- output.println("Empty!");
- return;
- }
-
- for (ReferenceDataPoint point : list)
- {
- String newURL = "./reference?" +
- query + "&obj" + nparams + "=" + point.getReferenceHolder();
-
- Object referenceHolder = null;
- if (point.getReferenceHolder() > 0)
- {
- referenceHolder = jvmti.getObjectOnTag(point.getReferenceHolder());
- }
-
- if (point.getReferenceType() == JVMTITypes.JVMTI_REFERENCE_FIELD)
- {
- Class<?> referenceClass = null;
- Field referencedField = null;
- if (referenceHolder != null)
- {
- referenceClass = referenceHolder.getClass();
-
- referencedField = jvmti.getObjectField(referenceClass, (int)point.getIndex());
- }
-
- if (referencedField != null)
- {
- output.println("Field reference:" +
- referencedField.getDeclaringClass().getCanonicalName() + "::" + referencedField.getName() +
-
- "<a href='" + newURL + "'>(" + jvmti.convertToString(referenceHolder, true) + ")</a><br/>");
- }
- else
- {
- output.println("<a href='./reference?" +
- query + "&obj" + nparams + "=" + point.getReferenceHolder() + "'>Unkown Field reference</a><br/>");
- }
-
- }
- else if (point.getReferenceType() == JVMTITypes.JVMTI_REFERENCE_ARRAY_ELEMENT)
- {
- if (referenceHolder == null)
- {
- output.println("Array reference (gone)</br>");
- }
- else
- {
- output.println("Array Refeference: <a href='" +
- newURL + "'>" + "array[" + point.getIndex() + "]</a><br/>");
- }
- }
- else if (point.getReferenceType() == JVMTITypes.ROOT_REFERENCE)
- {
- output.println("ROOT</br>");
- }
- else if (point.getReferenceType() == JVMTITypes.THREAD_REFERENCE)
- {
-
- Class<?> methodClass = jvmti.getMethodClass(point.getMethod());
- if (methodClass != null)
- {
- String className = null;
- if (methodClass != null)
- {
- className = methodClass.getName();
- }
-
- String methodName = jvmti.getMethodName(point.getMethod());
- output.println("<br> Reference inside a method - " +
- className + "::" + methodName);
- }
- }
- else if (point.getReferenceType() == JVMTITypes.JVMTI_REFERENCE_STATIC_FIELD)
- {
- Class<?> clazz = (Class<?>)referenceHolder;
- Field field = jvmti.getObjectField(clazz, (int)point.getIndex());
- String fieldName = null;
- if (field == null)
- {
- fieldName = "UndefinedField@" +
- referenceHolder;
- }
- else
- {
- fieldName = field.toString();
- }
- output.println("<a href='" +
- newURL + "'>Static field reference:" + fieldName + "</a>");
- }
-
- }
- }
-
- // Package protected ---------------------------------------------
-
- // Protected -----------------------------------------------------
-
- // Private -------------------------------------------------------
-
- // Inner classes -------------------------------------------------
-
-}
Deleted: branches/JBossProfiler2/src/main/org/jboss/profiler/jvmti/memoryweb/RootHandler.java
===================================================================
--- branches/JBossProfiler2/src/main/org/jboss/profiler/jvmti/memoryweb/RootHandler.java 2009-08-18 21:41:47 UTC (rev 563)
+++ branches/JBossProfiler2/src/main/org/jboss/profiler/jvmti/memoryweb/RootHandler.java 2009-08-25 22:26:45 UTC (rev 564)
@@ -1,109 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2005-2009, Red Hat Middleware LLC, and individual contributors
- * by the @authors tag. See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-
-package org.jboss.profiler.jvmti.memoryweb;
-
-import org.jboss.profiler.jvmti.InventoryDataPoint;
-
-import com.sun.net.httpserver.HttpExchange;
-
-import java.io.PrintStream;
-import java.net.URLEncoder;
-import java.util.Iterator;
-import java.util.Map;
-import java.util.TreeSet;
-
-/**
- * A RootHandler
- *
- * @author <mailto:clebert.suconic at jboss.org">Clebert Suconic</a>
- *
- *
- */
-public class RootHandler extends AbstractHandler
-{
-
- // Constants -----------------------------------------------------
-
- // Attributes ----------------------------------------------------
-
- // Static --------------------------------------------------------
-
- // Constructors --------------------------------------------------
-
- /**
- * @param server
- */
- public RootHandler(final MemoryProfilerEmbedded server)
- {
- super(server);
- }
-
- // Public --------------------------------------------------------
-
- /* (non-Javadoc)
- * @see org.jboss.profiler.jvmti.webembed.AbstractHandler#handle(com.sun.net.httpserver.HttpExchange, java.util.Map)
- */
- @Override
- public synchronized void handle(final HttpExchange exchange, final Map<String, String> queryAttributes,
- final PrintStream output) throws Exception
- {
- server.clearIndex();
-
- Map<Class<?>, InventoryDataPoint> inventory = server.getJvmti().produceInventory();
-
- TreeSet<InventoryDataPoint> points = new TreeSet<InventoryDataPoint>(inventory.values());
- Iterator iterDataPoints = points.iterator();
-
- output.println("<table>");
-
- output.println("<tr><td>Name</td><td>#Instances</td><td>#Bytes</td></tr>");
-
- while (iterDataPoints.hasNext())
- {
- InventoryDataPoint point = (InventoryDataPoint)iterDataPoints.next();
- output.println("<tr><td><a href='./instances?class=" +
- URLEncoder.encode(point.getClazz().getName()) + "'>" + point.getClazz().getName() + "</a>" +
- "</td><td>" + point.getInstances() + "</td><td>" + point.getBytes() + "</td></tr>");
- }
-
- output.println("</table>");
- }
-
- public synchronized void handle2(final HttpExchange exchange, final Map<String, String> queryAttributes,
- final PrintStream output) throws Exception
- {
- server.clearIndex();
-
- output.println(server.getJvmti().inventoryReport(true));
-
- }
-
- // Package protected ---------------------------------------------
-
- // Protected -----------------------------------------------------
-
- // Private -------------------------------------------------------
-
- // Inner classes -------------------------------------------------
-
-}
Deleted: branches/JBossProfiler2/src/main/org/jboss/profiler/jvmti/memoryweb/StopHandler.java
===================================================================
--- branches/JBossProfiler2/src/main/org/jboss/profiler/jvmti/memoryweb/StopHandler.java 2009-08-18 21:41:47 UTC (rev 563)
+++ branches/JBossProfiler2/src/main/org/jboss/profiler/jvmti/memoryweb/StopHandler.java 2009-08-25 22:26:45 UTC (rev 564)
@@ -1,76 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2005-2009, Red Hat Middleware LLC, and individual contributors
- * by the @authors tag. See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-
-package org.jboss.profiler.jvmti.memoryweb;
-
-import com.sun.net.httpserver.HttpExchange;
-
-import java.io.PrintStream;
-import java.util.Map;
-
-/**
- * A StopHandler
- *
- * @author <mailto:clebert.suconic at jboss.org">Clebert Suconic</a>
- *
- *
- */
-public class StopHandler extends AbstractHandler
-{
-
- // Constants -----------------------------------------------------
-
- // Attributes ----------------------------------------------------
-
- // Static --------------------------------------------------------
-
- // Constructors --------------------------------------------------
- /**
- * @param server
- */
- public StopHandler(final MemoryProfilerEmbedded server)
- {
- super(server);
- }
-
- // Public --------------------------------------------------------
-
- /* (non-Javadoc)
- * @see org.jboss.profiler.jvmti.webembed.AbstractHandler#handle(com.sun.net.httpserver.HttpExchange, java.util.Map, java.io.PrintStream)
- */
- @Override
- public void handle(final HttpExchange exchange, final Map<String, String> queryAttributes, final PrintStream output)
- throws Exception
- {
- output.println("Profiler stopped");
- server.stop();
- }
-
- // Package protected ---------------------------------------------
-
- // Protected -----------------------------------------------------
-
- // Private -------------------------------------------------------
-
- // Inner classes -------------------------------------------------
-
-}
Deleted: branches/JBossProfiler2/src/test/java/org/jboss/profiler/test/jvmti/JVMTIWebTestManual.java
===================================================================
--- branches/JBossProfiler2/src/test/java/org/jboss/profiler/test/jvmti/JVMTIWebTestManual.java 2009-08-18 21:41:47 UTC (rev 563)
+++ branches/JBossProfiler2/src/test/java/org/jboss/profiler/test/jvmti/JVMTIWebTestManual.java 2009-08-25 22:26:45 UTC (rev 564)
@@ -1,95 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2005-2009, Red Hat Middleware LLC, and individual contributors
- * by the @authors tag. See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-
-package org.jboss.profiler.test.jvmti;
-
-import java.net.InetSocketAddress;
-import java.util.concurrent.CountDownLatch;
-
-import org.jboss.profiler.jvmti.JVMTIInterface;
-
-/**
- *
- * This test has to be done manually, as it is done to validate the UI.
- *
- * Add this to you VM options:
- *
- * -Djava.library.path=/work/projects/prof2/src/native/ -agentpath:/work/projects/prof2/src/native/libJBossProfiler.so
- *
- * Execute this test, and navigate through the interface. open http://localhost:3232
- *
- * This test should stop When you press stop on the WebInterface
- *
- * Look for the strings created at this test
- *
- * @author <mailto:clebert.suconic at jboss.org">Clebert Suconic</a>
- *
- *
- */
-public class JVMTIWebTestManual
-{
- TestClass str2[] = null;
-
- TestClass strroot;
-
- static TestClass staticField;
-
- public static void main(String arg[])
- {
- try
- {
- JVMTIWebTestManual manual = new JVMTIWebTestManual();
- manual.testWeb();
- }
- catch (Exception e)
- {
- e.printStackTrace();
- }
- }
-
- public void testWeb() throws Exception
- {
- TestClass str[] = new TestClass[1];
-
- str[0] = new TestClass();
-
- str2 = str;
-
- TestClass strroot2 = str[0];
- strroot = str[0];
-
- staticField = str[0];
-
- JVMTIInterface jvmti = new JVMTIInterface();
-
- System.out.println(jvmti.inventoryReport());
-
- CountDownLatch latch = new CountDownLatch(1);
-
- jvmti.startMemoryProfiler(new InetSocketAddress(3232), latch);
-
- latch.await();
-
- System.out.println("strroot = " + strroot2);
- }
-
-}
More information about the jboss-cvs-commits
mailing list