[jboss-cvs] JBoss Profiler SVN: r420 - in branches: JBossProfiler2 and 21 other directories.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Sun Feb 10 05:59:34 EST 2008
Author: jesper.pedersen
Date: 2008-02-10 05:59:33 -0500 (Sun, 10 Feb 2008)
New Revision: 420
Added:
branches/JBossProfiler2/
branches/JBossProfiler2/build.sh
branches/JBossProfiler2/build.xml
branches/JBossProfiler2/doc/
branches/JBossProfiler2/doc/JBossORG-EULA.txt
branches/JBossProfiler2/doc/README.txt
branches/JBossProfiler2/doc/asm.txt
branches/JBossProfiler2/doc/copyright.txt
branches/JBossProfiler2/doc/lgpl.html
branches/JBossProfiler2/lib/
branches/JBossProfiler2/lib/asm.jar
branches/JBossProfiler2/lib/concurrent.jar
branches/JBossProfiler2/lib/ejb3-persistence.jar
branches/JBossProfiler2/lib/jboss-common.jar
branches/JBossProfiler2/lib/jboss-ejb3x.jar
branches/JBossProfiler2/lib/jboss-remoting.jar
branches/JBossProfiler2/lib/jbossall-client.jar
branches/JBossProfiler2/lib/log4j.jar
branches/JBossProfiler2/lib/servlet.jar
branches/JBossProfiler2/src/
branches/JBossProfiler2/src/etc/
branches/JBossProfiler2/src/etc/agent-manifest.mf
branches/JBossProfiler2/src/etc/client-manifest.mf
branches/JBossProfiler2/src/etc/connectors-manifest.mf
branches/JBossProfiler2/src/etc/jboss-profiler-client.properties
branches/JBossProfiler2/src/etc/jboss-profiler.properties
branches/JBossProfiler2/src/etc/jboss-service.xml
branches/JBossProfiler2/src/etc/jsf-config.xml
branches/JBossProfiler2/src/etc/log4j.xml
branches/JBossProfiler2/src/etc/web.xml
branches/JBossProfiler2/src/main/
branches/JBossProfiler2/src/main/org/
branches/JBossProfiler2/src/main/org/jboss/
branches/JBossProfiler2/src/main/org/jboss/profiler/
branches/JBossProfiler2/src/main/org/jboss/profiler/agent/
branches/JBossProfiler2/src/main/org/jboss/profiler/agent/Agent.java
branches/JBossProfiler2/src/main/org/jboss/profiler/agent/ClassRepository.java
branches/JBossProfiler2/src/main/org/jboss/profiler/agent/ClassUtil.java
branches/JBossProfiler2/src/main/org/jboss/profiler/agent/ExceptionInfo.java
branches/JBossProfiler2/src/main/org/jboss/profiler/agent/ProfiledClass.java
branches/JBossProfiler2/src/main/org/jboss/profiler/agent/ProfiledMethod.java
branches/JBossProfiler2/src/main/org/jboss/profiler/agent/Profiler.java
branches/JBossProfiler2/src/main/org/jboss/profiler/agent/SizeComparator.java
branches/JBossProfiler2/src/main/org/jboss/profiler/agent/Transformer.java
branches/JBossProfiler2/src/main/org/jboss/profiler/agent/jobs/
branches/JBossProfiler2/src/main/org/jboss/profiler/agent/jobs/Job.java
branches/JBossProfiler2/src/main/org/jboss/profiler/agent/jobs/JobHelper.java
branches/JBossProfiler2/src/main/org/jboss/profiler/agent/jobs/StartProfiling.java
branches/JBossProfiler2/src/main/org/jboss/profiler/agent/jobs/StopProfiling.java
branches/JBossProfiler2/src/main/org/jboss/profiler/as/
branches/JBossProfiler2/src/main/org/jboss/profiler/as/Communicator.java
branches/JBossProfiler2/src/main/org/jboss/profiler/as/CommunicatorMBean.java
branches/JBossProfiler2/src/main/org/jboss/profiler/as/Profiler.java
branches/JBossProfiler2/src/main/org/jboss/profiler/as/ProfilerMBean.java
branches/JBossProfiler2/src/main/org/jboss/profiler/client/
branches/JBossProfiler2/src/main/org/jboss/profiler/client/CombinedFrameComparator.java
branches/JBossProfiler2/src/main/org/jboss/profiler/client/CombinedFrameInfo.java
branches/JBossProfiler2/src/main/org/jboss/profiler/client/DifferenceUtil.java
branches/JBossProfiler2/src/main/org/jboss/profiler/client/SnapshotUtil.java
branches/JBossProfiler2/src/main/org/jboss/profiler/client/ThreadHolder.java
branches/JBossProfiler2/src/main/org/jboss/profiler/client/TimedClassComparator.java
branches/JBossProfiler2/src/main/org/jboss/profiler/client/TimedClassInfo.java
branches/JBossProfiler2/src/main/org/jboss/profiler/client/Util.java
branches/JBossProfiler2/src/main/org/jboss/profiler/client/cmd/
branches/JBossProfiler2/src/main/org/jboss/profiler/client/cmd/Client.java
branches/JBossProfiler2/src/main/org/jboss/profiler/connectors/
branches/JBossProfiler2/src/main/org/jboss/profiler/connectors/AbstractHandler.java
branches/JBossProfiler2/src/main/org/jboss/profiler/connectors/HttpHandler.java
branches/JBossProfiler2/src/main/org/jboss/profiler/connectors/LocalHandler.java
branches/JBossProfiler2/src/main/org/jboss/profiler/connectors/RemoteHandler.java
branches/JBossProfiler2/src/main/org/jboss/profiler/connectors/RmiHandler.java
branches/JBossProfiler2/src/main/org/jboss/profiler/connectors/SocketHandler.java
branches/JBossProfiler2/src/main/org/jboss/profiler/package.html
branches/JBossProfiler2/src/main/org/jboss/profiler/plugins/
branches/JBossProfiler2/src/main/org/jboss/profiler/plugins/Hibernate.java
branches/JBossProfiler2/src/main/org/jboss/profiler/plugins/package.html
branches/JBossProfiler2/src/main/org/jboss/profiler/shared/
branches/JBossProfiler2/src/main/org/jboss/profiler/shared/AllocationComparator.java
branches/JBossProfiler2/src/main/org/jboss/profiler/shared/AllocationInfo.java
branches/JBossProfiler2/src/main/org/jboss/profiler/shared/ClassComparator.java
branches/JBossProfiler2/src/main/org/jboss/profiler/shared/ClassInfo.java
branches/JBossProfiler2/src/main/org/jboss/profiler/shared/ClassType.java
branches/JBossProfiler2/src/main/org/jboss/profiler/shared/Command.java
branches/JBossProfiler2/src/main/org/jboss/profiler/shared/CommandType.java
branches/JBossProfiler2/src/main/org/jboss/profiler/shared/FrameComparator.java
branches/JBossProfiler2/src/main/org/jboss/profiler/shared/FrameHelper.java
branches/JBossProfiler2/src/main/org/jboss/profiler/shared/FrameInfo.java
branches/JBossProfiler2/src/main/org/jboss/profiler/shared/Math.java
branches/JBossProfiler2/src/main/org/jboss/profiler/shared/MethodInfo.java
branches/JBossProfiler2/src/main/org/jboss/profiler/shared/Plugin.java
branches/JBossProfiler2/src/main/org/jboss/profiler/shared/PluginHelper.java
branches/JBossProfiler2/src/main/org/jboss/profiler/shared/Snapshot.java
branches/JBossProfiler2/src/main/org/jboss/profiler/shared/SnapshotHelper.java
branches/JBossProfiler2/src/main/org/jboss/profiler/shared/ThreadComparator.java
branches/JBossProfiler2/src/main/org/jboss/profiler/shared/ThreadHelper.java
branches/JBossProfiler2/src/main/org/jboss/profiler/shared/ThreadInfo.java
branches/JBossProfiler2/src/main/org/jboss/profiler/shared/Version.java
branches/JBossProfiler2/src/main/org/jboss/profiler/shared/Visibility.java
branches/JBossProfiler2/src/test/
branches/JBossProfiler2/src/test/org/
branches/JBossProfiler2/src/test/org/jboss/
branches/JBossProfiler2/src/test/org/jboss/profiler/
branches/JBossProfiler2/src/test/org/jboss/profiler/test/
branches/JBossProfiler2/src/test/org/jboss/profiler/test/Complex.java
branches/JBossProfiler2/src/test/org/jboss/profiler/test/Entity.java
branches/JBossProfiler2/src/test/org/jboss/profiler/test/Entity3.java
branches/JBossProfiler2/src/test/org/jboss/profiler/test/JMX.java
branches/JBossProfiler2/src/test/org/jboss/profiler/test/JMXMBean.java
branches/JBossProfiler2/src/test/org/jboss/profiler/test/ManagedBean.java
branches/JBossProfiler2/src/test/org/jboss/profiler/test/Message.java
branches/JBossProfiler2/src/test/org/jboss/profiler/test/Message3.java
branches/JBossProfiler2/src/test/org/jboss/profiler/test/Session.java
branches/JBossProfiler2/src/test/org/jboss/profiler/test/Session3.java
branches/JBossProfiler2/src/test/org/jboss/profiler/test/Simple.java
branches/JBossProfiler2/src/test/org/jboss/profiler/test/Test.java
branches/JBossProfiler2/src/test/org/jboss/profiler/test/TestServlet.java
Log:
JBoss Profiler 2 snapshot
Added: branches/JBossProfiler2/build.sh
===================================================================
--- branches/JBossProfiler2/build.sh (rev 0)
+++ branches/JBossProfiler2/build.sh 2008-02-10 10:59:33 UTC (rev 420)
@@ -0,0 +1,14 @@
+#!/bin/sh
+
+if [ -z $ANT_HOME ]; then
+ echo "Please set the ANT_HOME variable."
+ exit 1
+fi
+
+if [ -z $JAVA_HOME ]; then
+ echo "Please set the JAVA_HOME variable."
+ exit 1
+fi
+
+export PATH=$ANT_HOME/bin:$JAVA_HOME/bin:$PATH
+ant $*
Property changes on: branches/JBossProfiler2/build.sh
___________________________________________________________________
Name: svn:executable
+
Added: branches/JBossProfiler2/build.xml
===================================================================
--- branches/JBossProfiler2/build.xml (rev 0)
+++ branches/JBossProfiler2/build.xml 2008-02-10 10:59:33 UTC (rev 420)
@@ -0,0 +1,329 @@
+<?xml version="1.0" encoding="ISO-8859-1"?>
+
+<project name="jboss-profiler" default="dist" basedir=".">
+ <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.test.dir" value="${src.dir}/test"/>
+ <property name="etc.dir" value="${src.dir}/etc"/>
+ <property name="dist.dir" value="${basedir}/dist"/>
+
+ <property name="name" value="jboss-profiler"/>
+ <property name="major" value="2"/>
+ <property name="minor" value="0"/>
+ <property name="type" value="CR9"/>
+
+ <property name="jboss-profiler.jar" value="jboss-profiler.jar"/>
+ <property name="jboss-profiler-connectors.jar" value="jboss-profiler-connectors.jar"/>
+ <property name="jboss-profiler-client.jar" value="jboss-profiler-client.jar"/>
+ <property name="jboss-profiler-plugins.jar" value="jboss-profiler-plugins.jar"/>
+ <property name="jboss-profiler-test.jar" value="jboss-profiler-test.jar"/>
+
+ <property name="jboss-profiler.sar" value="jboss-profiler.sar"/>
+
+ <!-- =================================================================== -->
+ <!-- Define the class path -->
+ <!-- =================================================================== -->
+ <path id="class.path">
+ <fileset dir="${lib.dir}">
+ <include name="*.jar"/>
+ </fileset>
+ </path>
+
+ <path id="test.class.path">
+ <fileset dir="${lib.dir}">
+ <include name="*.jar"/>
+ </fileset>
+ <fileset dir="${dist.dir}">
+ <include name="*.jar"/>
+ </fileset>
+ </path>
+
+ <!-- =================================================================== -->
+ <!-- Initialize -->
+ <!-- =================================================================== -->
+ <target name="init">
+ </target>
+
+ <!-- =================================================================== -->
+ <!-- Prepares the directory structure -->
+ <!-- =================================================================== -->
+ <target name="prepare" depends="init">
+ <mkdir dir="${build.dir}"/>
+ <mkdir dir="${dist.dir}"/>
+ </target>
+
+ <!-- =================================================================== -->
+ <!-- Agent -->
+ <!-- =================================================================== -->
+ <target name="agent" depends="prepare">
+ <delete dir="${build.dir}"/>
+ <mkdir dir="${build.dir}"/>
+ <javac
+ destdir="${build.dir}"
+ classpathref="class.path"
+ debug="on"
+ deprecation="on"
+ optimize="off"
+ source="1.5"
+ target="1.5"
+ >
+ <src path="${src.main.dir}"/>
+ </javac>
+ <copy todir="${build.dir}">
+ <fileset dir="${etc.dir}">
+ <include name="**/jboss-profiler.properties"/>
+ </fileset>
+ </copy>
+ <jar destfile="${dist.dir}/${jboss-profiler.jar}"
+ basedir="${build.dir}"
+ manifest="${etc.dir}/agent-manifest.mf"
+ includes="org/jboss/profiler/agent/**,org/jboss/profiler/shared/**,**/*.properties"
+ excludes="**/*.java"/>
+ </target>
+
+ <!-- =================================================================== -->
+ <!-- Connectors -->
+ <!-- =================================================================== -->
+ <target name="connectors" depends="prepare">
+ <delete dir="${build.dir}"/>
+ <mkdir dir="${build.dir}"/>
+ <javac
+ destdir="${build.dir}"
+ classpathref="class.path"
+ debug="on"
+ deprecation="on"
+ optimize="off"
+ source="1.5"
+ target="1.5"
+ >
+ <src path="${src.main.dir}"/>
+ </javac>
+ <jar destfile="${dist.dir}/${jboss-profiler-connectors.jar}"
+ basedir="${build.dir}"
+ manifest="${etc.dir}/connectors-manifest.mf"
+ includes="org/jboss/profiler/connectors/**"
+ excludes="**/*.java"/>
+ </target>
+
+ <!-- =================================================================== -->
+ <!-- Client -->
+ <!-- =================================================================== -->
+ <target name="client" depends="prepare">
+ <delete dir="${build.dir}"/>
+ <mkdir dir="${build.dir}"/>
+ <javac
+ destdir="${build.dir}"
+ classpathref="class.path"
+ debug="on"
+ deprecation="on"
+ optimize="off"
+ source="1.5"
+ target="1.5"
+ >
+ <src path="${src.main.dir}"/>
+ </javac>
+ <copy todir="${build.dir}">
+ <fileset dir="${etc.dir}">
+ <include name="**/log4j.xml"/>
+ </fileset>
+ </copy>
+ <copy todir="${build.dir}">
+ <fileset dir="${etc.dir}">
+ <include name="**/jboss-profiler-client.properties"/>
+ </fileset>
+ </copy>
+
+ <jar destfile="${dist.dir}/${jboss-profiler-client.jar}"
+ basedir="${build.dir}"
+ manifest="${etc.dir}/client-manifest.mf"
+ includes="org/jboss/profiler/client/**,org/jboss/profiler/shared/**,**/*.xml,**/*.properties"
+ excludes="**/*.java"/>
+ </target>
+
+ <!-- =================================================================== -->
+ <!-- Plugins -->
+ <!-- =================================================================== -->
+ <target name="plugins" depends="prepare">
+ <delete dir="${build.dir}"/>
+ <mkdir dir="${build.dir}"/>
+ <javac
+ destdir="${build.dir}"
+ classpathref="class.path"
+ debug="on"
+ deprecation="on"
+ optimize="off"
+ source="1.5"
+ target="1.5"
+ >
+ <src path="${src.main.dir}"/>
+ </javac>
+
+ <jar destfile="${dist.dir}/${jboss-profiler-plugins.jar}"
+ basedir="${build.dir}"
+ includes="org/jboss/profiler/plugins/**"
+ excludes="**/*.java"/>
+ </target>
+
+ <!-- =================================================================== -->
+ <!-- Test -->
+ <!-- =================================================================== -->
+ <target name="test" depends="prepare">
+ <delete dir="${build.dir}"/>
+ <mkdir dir="${build.dir}"/>
+
+ <mkdir dir="${build.dir}/WEB-INF"/>
+ <copy todir="${build.dir}/WEB-INF">
+ <fileset dir="${etc.dir}">
+ <include name="**/*.xml"/>
+ <exclude name="**/log4j.xml"/>
+ </fileset>
+ </copy>
+
+ <javac
+ destdir="${build.dir}"
+ classpathref="test.class.path"
+ debug="on"
+ deprecation="on"
+ optimize="off"
+ source="1.5"
+ target="1.5"
+ >
+ <src path="${src.test.dir}"/>
+ </javac>
+
+ <jar destfile="${dist.dir}/${jboss-profiler-test.jar}"
+ basedir="${build.dir}"
+ excludes="**/*.java"/>
+
+ </target>
+
+ <!-- =================================================================== -->
+ <!-- SAR -->
+ <!-- =================================================================== -->
+ <target name="sar" depends="prepare">
+ <delete dir="${build.dir}"/>
+ <mkdir dir="${build.dir}"/>
+ <javac
+ destdir="${build.dir}"
+ classpathref="class.path"
+ debug="on"
+ deprecation="on"
+ optimize="off"
+ source="1.5"
+ target="1.5"
+ >
+ <src path="${src.main.dir}"/>
+ </javac>
+ <mkdir dir="${build.dir}/META-INF"/>
+ <copy todir="${build.dir}/META-INF">
+ <fileset dir="${etc.dir}">
+ <include name="**/jboss-service.xml"/>
+ </fileset>
+ </copy>
+ <jar destfile="${dist.dir}/${jboss-profiler.sar}"
+ basedir="${build.dir}"
+ includes="org/jboss/profiler/as/**,org/jboss/profiler/connectors/**,**/*.xml"
+ excludes="**/*.java"/>
+ </target>
+
+ <!-- =================================================================== -->
+ <!-- Doc -->
+ <!-- =================================================================== -->
+ <target name="doc">
+ <mkdir dir="${doc.api.dir}"/>
+ <javadoc packagenames="org.*"
+ sourcepath="${src.main.dir}"
+ destdir="${doc.api.dir}"
+ author="true"
+ version="true"
+ windowtitle="JBoss Profiler 2"
+ doctitle="JBoss Profiler 2"
+ use="true"
+ classpathref="class.path"
+ bottom="Copyright © 2007 JBoss (http://www.jboss.com/)">
+ <link offline="true" href="http://java.sun.com/j2se/1.5/docs/api/" packagelistLoc="${java.home}/../docs/api"/>
+ </javadoc>
+
+ </target>
+
+ <!-- =================================================================== -->
+ <!-- Dist -->
+ <!-- =================================================================== -->
+ <target name="dist" depends="agent,connectors,client,plugins,test,sar">
+ <copy todir="${dist.dir}">
+ <fileset dir="${lib.dir}">
+ <include name="**/*.jar"/>
+ </fileset>
+ </copy>
+ <copy todir="${dist.dir}">
+ <fileset dir="${etc.dir}">
+ <include name="**/log4j.xml"/>
+ </fileset>
+ </copy>
+ <copy todir="${dist.dir}">
+ <fileset dir="${etc.dir}">
+ <include name="**/*.properties"/>
+ </fileset>
+ </copy>
+ <copy todir="${dist.dir}">
+ <fileset dir="${doc.dir}">
+ <include name="**/*.txt"/>
+ <include name="**/*.html"/>
+ </fileset>
+ </copy>
+ </target>
+
+ <!-- =================================================================== -->
+ <!-- Release -->
+ <!-- =================================================================== -->
+ <target name="release" depends="clean,dist">
+ <delete dir="${build.dir}"/>
+ <mkdir dir="${build.dir}/${name}-${major}.${minor}.${type}"/>
+ <move todir="${build.dir}/${name}-${major}.${minor}.${type}"
+ includeEmptyDirs="false">
+ <fileset dir="${dist.dir}"
+ excludes="**/ejb3-persistence.jar,
+ **/jbossall-client.jar,
+ **/jboss-ejb3x.jar,
+ **/servlet.jar,
+ **/*test.jar "/>
+ </move>
+ <zip destfile="${name}-${major}.${minor}.${type}.zip"
+ basedir="${build.dir}"/>
+
+ <tar destfile="${name}-${major}.${minor}.${type}.tar"
+ basedir="${build.dir}"/>
+
+ <gzip zipfile="${name}-${major}.${minor}.${type}.tar.gz"
+ src="${name}-${major}.${minor}.${type}.tar"/>
+
+ <bzip2 zipfile="${name}-${major}.${minor}.${type}.bz2"
+ src="${name}-${major}.${minor}.${type}.tar"/>
+
+ <delete file="${name}-${major}.${minor}.${type}.tar"/>
+
+ </target>
+
+ <!-- =================================================================== -->
+ <!-- Clean -->
+ <!-- =================================================================== -->
+ <target name="clean">
+ <delete>
+ <fileset dir="${basedir}" defaultexcludes="no">
+ <include name="**/*~" />
+ <include name="**/*.bak"/>
+ </fileset>
+ </delete>
+ <delete dir="${build.dir}"/>
+ <delete dir="${dist.dir}"/>
+ <delete dir="${doc.api.dir}"/>
+ <delete file="jboss-profiler.zip"/>
+ <delete file="jboss-profiler.tar.gz"/>
+ <delete file="jboss-profiler.tar.bz2"/>
+ </target>
+
+</project>
Added: branches/JBossProfiler2/doc/JBossORG-EULA.txt
===================================================================
--- branches/JBossProfiler2/doc/JBossORG-EULA.txt (rev 0)
+++ branches/JBossProfiler2/doc/JBossORG-EULA.txt 2008-02-10 10:59:33 UTC (rev 420)
@@ -0,0 +1,107 @@
+LICENSE AGREEMENT
+JBOSS(r)
+
+This License Agreement governs the use of the Software Packages and any updates to the Software
+Packages, regardless of the delivery mechanism. Each Software Package is a collective work
+under U.S. Copyright Law. Subject to the following terms, Red Hat, Inc. ("Red Hat") grants to
+the user ("Client") a license to the applicable collective work(s) pursuant to the
+GNU Lesser General Public License v. 2.1 except for the following Software Packages:
+(a) JBoss Portal Forums and JBoss Transactions JTS, each of which is licensed pursuant to the
+GNU General Public License v.2;
+
+(b) JBoss Rules, which is licensed pursuant to the Apache License v.2.0;
+
+(c) an optional download for JBoss Cache for the Berkeley DB for Java database, which is licensed under the
+(open source) Sleepycat License (if Client does not wish to use the open source version of this database,
+it may purchase a license from Sleepycat Software);
+
+and (d) the BPEL extension for JBoss jBPM, which is licensed under the Common Public License v.1,
+and, pursuant to the OASIS BPEL4WS standard, requires parties wishing to redistribute to enter various
+royalty-free patent licenses.
+
+Each of the foregoing licenses is available at http://www.opensource.org/licenses/index.php.
+
+1. The Software. "Software Packages" refer to the various software modules that are created and made available
+for distribution by the JBoss.org open source community at http://www.jboss.org. Each of the Software Packages
+may be comprised of hundreds of software components. The end user license agreement for each component is located in
+the component's source code. With the exception of certain image files identified in Section 2 below,
+the license terms for the components permit Client to copy, modify, and redistribute the component,
+in both source code and binary code forms. This agreement does not limit Client's rights under,
+or grant Client rights that supersede, the license terms of any particular component.
+
+2. Intellectual Property Rights. The Software Packages are owned by Red Hat and others and are protected under copyright
+and other laws. Title to the Software Packages and any component, or to any copy, modification, or merged portion shall
+remain with the aforementioned, subject to the applicable license. The "JBoss" trademark, "Red Hat" trademark, the
+individual Software Package trademarks, and the "Shadowman" logo are registered trademarks of Red Hat and its affiliates
+in the U.S. and other countries. This agreement permits Client to distribute unmodified copies of the Software Packages
+using the Red Hat trademarks that Red Hat has inserted in the Software Packages on the condition that Client follows Red Hat's
+trademark guidelines for those trademarks located at http://www.redhat.com/about/corporate/trademark/. Client must abide by
+these trademark guidelines when distributing the Software Packages, regardless of whether the Software Packages have been modified.
+If Client modifies the Software Packages, then Client must replace all Red Hat trademarks and logos identified at
+http://www.jboss.com/company/logos, unless a separate agreement with Red Hat is executed or other permission granted.
+Merely deleting the files containing the Red Hat trademarks may corrupt the Software Packages.
+
+3. Limited Warranty. Except as specifically stated in this Paragraph 3 or a license for a particular
+component, to the maximum extent permitted under applicable law, the Software Packages and the
+components are provided and licensed "as is" without warranty of any kind, expressed or implied,
+including the implied warranties of merchantability, non-infringement or fitness for a particular purpose.
+Red Hat warrants that the media on which Software Packages may be furnished will be free from defects in
+materials and manufacture under normal use for a period of 30 days from the date of delivery to Client.
+Red Hat does not warrant that the functions contained in the Software Packages will meet Client's requirements
+or that the operation of the Software Packages will be entirely error free or appear precisely as described
+in the accompanying documentation. This warranty extends only to the party that purchases the Services
+pertaining to the Software Packages from Red Hat or a Red Hat authorized distributor.
+
+4. Limitation of Remedies and Liability. To the maximum extent permitted by applicable law, the remedies
+described below are accepted by Client as its only remedies. Red Hat's entire liability, and Client's
+exclusive remedies, shall be: If the Software media is defective, Client may return it within 30 days of
+delivery along with a copy of Client's payment receipt and Red Hat, at its option, will replace it or
+refund the money paid by Client for the Software. To the maximum extent permitted by applicable law,
+Red Hat or any Red Hat authorized dealer will not be liable to Client for any incidental or consequential
+damages, including lost profits or lost savings arising out of the use or inability to use the Software,
+even if Red Hat or such dealer has been advised of the possibility of such damages. In no event shall
+Red Hat's liability under this agreement exceed the amount that Client paid to Red Hat under this
+Agreement during the twelve months preceding the action.
+
+5. Export Control. As required by U.S. law, Client represents and warrants that it:
+(a) understands that the Software Packages are subject to export controls under the
+U.S. Commerce Department's Export Administration Regulations ("EAR");
+
+(b) is not located in a prohibited destination country under the EAR or U.S. sanctions regulations
+(currently Cuba, Iran, Iraq, Libya, North Korea, Sudan and Syria);
+
+(c) will not export, re-export, or transfer the Software Packages to any prohibited destination, entity,
+or individual without the necessary export license(s) or authorizations(s) from the U.S. Government;
+
+(d) will not use or transfer the Software Packages for use in any sensitive nuclear, chemical or
+biological weapons, or missile technology end-uses unless authorized by the U.S. Government by
+regulation or specific license;
+
+(e) understands and agrees that if it is in the United States and exports or transfers the Software
+Packages to eligible end users, it will, as required by EAR Section 740.17(e), submit semi-annual
+reports to the Commerce Department's Bureau of Industry & Security (BIS), which include the name and
+address (including country) of each transferee;
+
+and (f) understands that countries other than the United States may restrict the import, use, or
+export of encryption products and that it shall be solely responsible for compliance with any such
+import, use, or export restrictions.
+
+6. Third Party Programs. Red Hat may distribute third party software programs with the Software Packages
+that are not part of the Software Packages and which Client must install separately. These third party
+programs are subject to their own license terms. The license terms either accompany the programs or
+can be viewed at http://www.redhat.com/licenses/. If Client does not agree to abide by the applicable
+license terms for such programs, then Client may not install them. If Client wishes to install the programs
+on more than one system or transfer the programs to another party, then Client must contact the licensor
+of the programs.
+
+7. General. If any provision of this agreement is held to be unenforceable, that shall not affect the
+enforceability of the remaining provisions. This License Agreement shall be governed by the laws of the
+State of North Carolina and of the United States, without regard to any conflict of laws provisions,
+except that the United Nations Convention on the International Sale of Goods shall not apply.
+
+Copyright 2006 Red Hat, Inc. All rights reserved.
+"JBoss" and the JBoss logo are registered trademarks of Red Hat, Inc.
+All other trademarks are the property of their respective owners.
+
+ Page 1 of 1 18 October 2006
+
Added: branches/JBossProfiler2/doc/README.txt
===================================================================
--- branches/JBossProfiler2/doc/README.txt (rev 0)
+++ branches/JBossProfiler2/doc/README.txt 2008-02-10 10:59:33 UTC (rev 420)
@@ -0,0 +1,328 @@
+JBoss Profiler 2
+================
+
+JBoss Profiler 2 is a 100% pure Java profiler capable of profiling
+Java Enterprise 5 applications.
+
+Overview:
+---------
+ * 100% Pure Java
+
+ * Integration with JBoss Enterprise Middleware Suite (JEMS)
+
+ * Access through multiple protocols using JBoss Remoting
+ x Socket
+ x Remote Method Invocation (RMI)
+ x Hyper Text Transport Protocol (HTTP)
+
+ * Reports
+ x Overview
+ x Classes
+ x Methods
+ x Hotspots
+ x PerThread
+ x PerClass
+
+ * Able to specify method visibility
+ x Global
+ x Package
+ x Class
+
+ * Component identification
+ x Plain Old Java Object (POJO)
+ x java.lang.Throwable
+ x Enterprise JavaBean: Entity
+ x Enterprise JavaBean: Session
+ x Enterprise JavaBean: Message
+ x Servlet
+ x Servlet filter
+ x JavaServer Pages
+ x JMX MBean
+ x JavaServer Faces Converter
+ x JavaServer Faces Managed Bean
+ x RMI: Remote
+ x RMI: Server
+ x CORBA: Object
+ x CORBA: Servant
+ x 3rd party plugins
+
+ * Compare snapshots
+
+ * Client
+ x Command line
+
+
+Command line client:
+--------------------
+Usage: Client [-h host] [-p port] <command>
+ startProfiler : Start the profiler
+ stopProfiler : Stop the profiler
+ snapshot : Take a snapshot
+ getSnapshot : Get a snapshot
+ listSnapshots : List snapshots
+ clearSnapshots : Clear snapshots
+ gc : Trigger garbage collection
+ enable : Enable the profiler
+ disable : Disable the profiler
+ load : Load a snapshot
+ save : Save a snapshot
+ diff : Compare snapshots
+ add : Add classes (public|protected|private)
+ remove : Remove classes
+
+Host defaults to 'localhost'.
+Port defaults to '5400'.
+
+Examples:
+
+Client startProfiler
+Client stopProfiler
+Client snapshot
+Client getSnapshot 1
+Client listSnapshots
+Client clearSnapshots
+Client gc
+Client enable
+Client disable
+Client load 20070806144635343-20070806144638444.jps
+Client load 20070806144635343/
+Client save 1
+Client save 1 mysnapshot.jps
+Client diff oldsnapshot.jps newsnapshot.jps
+Client add org.jboss.profiler.test.* public
+Client remove org.jboss.profiler.test.*
+
+
+jboss-profiler.properties:
+--------------------------
+enable Enable / disable profiler
+ [yes|no] default: yes
+
+cpu Enable / disable CPU profiling
+ [yes|no] default: yes
+
+memory Enable / disable memory profiling
+ [yes|no] default: yes
+
+includes Classes that should be profiled
+ [package|class][|visibility][,...]
+ f.ex: org.jboss.profiler.test.*|public,org.jboss.profiler.test.sub.*|private
+
+excludes Classes that should excluded
+ [package|class][,...]
+ f.ex: *
+
+visibility The method visibility
+ [public|protected|private] default: private
+
+save Save snapshots on exit
+ [yes|no] default: yes
+
+startup Start profiler during startup
+ [yes|no] default: yes
+
+repository Repository for class files. Must be enabled in order to add/remove classes at run-time
+ [yes|no] default: no
+
+remote Enable / disable remote API
+ [yes|no] default: yes
+
+store Where should the profile information be stored in the agent
+ [memory|file] default: memory
+
+location The location for the file store. If not specified will default to java.io.tmpdir
+ default: current directory
+ f.ex: /tmp/profiles
+
+host Name of binding address
+ f.ex: localhost
+
+port Port number (socket)
+ f.ex: 5400
+
+ejb Identify Enterprise JavaBeans components
+ [yes|no] default: yes
+
+servlet Identify Servlet components
+ [yes|no] default: yes
+
+jsf Identify JavaServer Faces components
+ [yes|no] default: yes
+
+jmx Identify JMX MBean
+ [yes|no] default: yes
+
+rmi Identify RMI components
+ [yes|no] default: yes
+
+corba Identify CORBA components
+ [yes|no] default: yes
+
+plugin.<number> Plugin to load
+ class
+ f.ex: plugin.1=org.jboss.profiler.plugins.Hibernate
+
+job.<number>.type The job type
+ class
+ f.ex: job.1.type=org.jboss.profiler.agent.jobs.StartProfiling
+
+job.<number>.time The job time in millis. The specified time represents a date.
+ long
+ f.ex: job.1.time=1167609600000
+
+job.<number>.period The job execution period in millis. The jobs are executed at fixed rate.
+ If not specified the job is only executed once.
+ long
+ f.ex: job.1.period=3600000
+
+jboss-profiler-client.properties:
+---------------------------------
+protocol Protocol to use
+ [socket|rmi|http] default: socket
+
+host The host name
+ default: localhost
+
+port The port number
+ default: 5400
+
+threshold Method threshold in ms
+ default: 1.0
+
+plugin.<number> Plugin to load
+ class
+ f.ex: plugin.1=org.jboss.profiler.plugins.Hibernate
+
+Communicator MBean:
+-------------------
+Configuration can be found in jboss-service.xml
+
+Host The host name
+ default: localhost
+
+Socket Should socket communication be enabled ?
+ [true|false] default: true
+
+SocketPort The socket port
+ default: 5400
+
+Rmi Should RMI communication be enabled ?
+ [true|false] default: false
+
+RmiPort The RMI port
+ default: 5401
+
+Http Should HTTP communication be enabled ?
+ [true|false] default: false
+
+HttpPort The HTTP port
+ default: 5402
+
+
+Deployment in JBoss Application Server:
+---------------------------------------
+
+* Copy jboss-profiler.jar to jbossas/bin
+* Copy jboss-profiler.properties to jbossas/bin
+* Edit jboss-profiler.properties in jbossas/bin to include the classes to be profiled
+* Copy jboss-profiler-plugins.jar to jbossas/bin
+* Copy asm.jar to jbossas/bin
+* Edit run.conf in jbossas/bin to include JBoss Profiler in JAVA_OPTS
+* Copy jboss-profiler.sar to jbossas/server/<conf>/deploy
+* Boot application server
+
+* java -jar jboss-profiler-client.jar startProfiler
+* Run application
+* java -jar jboss-profiler-client.jar stopProfiler
+* java -jar jboss-profiler-client.jar getSnapshot 1
+
+Please, note that the report creation may take some time to complete.
+
+
+Component identification plugins:
+---------------------------------
+Component identification plugins must implement the following interface
+
+ org.jboss.profiler.shared.Plugin
+
+and contain a default constructor.
+
+Furthermore the plugin must be enabled in both the agent and the client using
+the "plugins" configuration parameter.
+
+Agent jobs:
+-----------
+Agent jobs are tasks that the agent can execute at a specific time and interval.
+
+The jobs can be used to profile your application at a certain time where you think
+there may be a performance problem.
+
+Current job types include:
+
+ Start profiling: org.jboss.profiler.agent.jobs.StartProfiling
+ Stop profiling: org.jboss.profiler.agent.jobs.StopProfiling
+
+A job must extend the following class:
+
+ org.jboss.profiler.agent.jobs.Job
+
+and contain a default constructor.
+
+Warning: The jobs override the current settings used in agent.
+
+Third party libraries:
+----------------------
+The following libraries are needed
+
+ x asm.jar (ASM 3.0)
+ x concurrent.jar (Oswego Concurrent)
+ x ejb3-persistence.jar (EJB3 Persistence API (test))
+ x jbossall-client.jar (JBoss client API (test))
+ x jboss-common.jar (JBoss Common)
+ x jboss-ejb3x.jar (EJB3 API (test))
+ x jboss-remoting.jar (JBoss Remoting)
+ x log4j.jar (Log4J)
+ x servlet.jar (Servlet API (test))
+
+Build instructions:
+-------------------
+The following command will build the profiler.
+
+ ant clean dist
+
+Apache Ant 1.7 is supported.
+
+Running the agent:
+------------------
+Include the following in JAVA_OPTS: -javaagent:jboss-profiler.jar -Djboss-profiler.properties=jboss-profiler.properties
+
+Running the example:
+--------------------
+java -javaagent:jboss-profiler.jar=remote=no -Djboss-profiler.properties=jboss-profiler.properties -classpath jboss-profiler.jar:jboss-profiler-connectors.jar:jboss-profiler-test.jar:jbossall-client.jar:servlet.jar:ejb3-persistence.jar:jboss-ejb3x.jar:. org.jboss.profiler.test.Test
+
+Running the client:
+-------------------
+java -Xmx512m -Djboss-profiler-client.properties=jboss-profiler-client.properties -jar jboss-profiler-client.jar load file.jps
+
+Output: Directory with analysis reports
+
+Twiddle:
+--------
+Information:
+ ./twiddle.sh get 'org.jboss.profiler:service=Profiler' Running
+ ./twiddle.sh get 'org.jboss.profiler:service=Profiler' Enabled
+ ./twiddle.sh get 'org.jboss.profiler:service=Profiler' Memory
+ ./twiddle.sh get 'org.jboss.profiler:service=Profiler' File
+ ./twiddle.sh get 'org.jboss.profiler:service=Profiler' EJB
+ ./twiddle.sh get 'org.jboss.profiler:service=Profiler' Servlet
+ ./twiddle.sh get 'org.jboss.profiler:service=Profiler' JSF
+ ./twiddle.sh get 'org.jboss.profiler:service=Profiler' JMX
+ ./twiddle.sh get 'org.jboss.profiler:service=Profiler' RMI
+ ./twiddle.sh get 'org.jboss.profiler:service=Profiler' CORBA
+
+Operations:
+ ./twiddle.sh invoke 'org.jboss.profiler:service=Profiler' startProfiler
+ ./twiddle.sh invoke 'org.jboss.profiler:service=Profiler' stopProfiler
+ ./twiddle.sh invoke 'org.jboss.profiler:service=Profiler' enableProfiler
+ ./twiddle.sh invoke 'org.jboss.profiler:service=Profiler' disableProfiler
+ ./twiddle.sh invoke 'org.jboss.profiler:service=Profiler' clearSnapshots
Added: branches/JBossProfiler2/doc/asm.txt
===================================================================
--- branches/JBossProfiler2/doc/asm.txt (rev 0)
+++ branches/JBossProfiler2/doc/asm.txt 2008-02-10 10:59:33 UTC (rev 420)
@@ -0,0 +1,29 @@
+Copyright (c) 2000-2005 INRIA, France Telecom
+All rights reserved.
+
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions
+are met:
+
+1. Redistributions of source code must retain the above copyright
+ notice, this list of conditions and the following disclaimer.
+
+2. Redistributions in binary form must reproduce the above copyright
+ notice, this list of conditions and the following disclaimer in the
+ documentation and/or other materials provided with the distribution.
+
+3. Neither the name of the copyright holders nor the names of its
+ contributors may be used to endorse or promote products derived from
+ this software without specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
+LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+THE POSSIBILITY OF SUCH DAMAGE.
Added: branches/JBossProfiler2/doc/copyright.txt
===================================================================
--- branches/JBossProfiler2/doc/copyright.txt (rev 0)
+++ branches/JBossProfiler2/doc/copyright.txt 2008-02-10 10:59:33 UTC (rev 420)
@@ -0,0 +1,4 @@
+Authors:
+--------
+Jesper Pedersen <jep at worldleaguesports.com>
+
Added: branches/JBossProfiler2/doc/lgpl.html
===================================================================
--- branches/JBossProfiler2/doc/lgpl.html (rev 0)
+++ branches/JBossProfiler2/doc/lgpl.html 2008-02-10 10:59:33 UTC (rev 420)
@@ -0,0 +1,350 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
+<html><head>
+ <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
+ <title>Appendix A. GNU Lesser General Public License</title><meta name="generator" content="DocBook XSL Stylesheets V1.69.1a"></head><body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF"><div class="appendix" lang="en"><div class="titlepage"><div><div><h1 class="title"><a name="lgpl"></a>GNU Lesser General Public License</h1></div><div><p class="releaseinfo">This is the first released version of the Lesser GPL. It also counts
+ as the successor of the GNU Library Public License, version 2, hence
+ the version number 2.1.</p></div><div><p class="copyright">Copyright © 1991, 1999 Free Software Foundation, Inc.</p></div><div><div class="legalnotice"><a name="gpl-legalnotice"></a><p>
+ </p><div class="address"><p>Free Software Foundation, Inc.<br>
+ <span class="street">51 Franklin Street, Fifth Floor</span>,<br>
+ <span class="city">Boston</span>,<br>
+ <span class="state">MA</span><br>
+ <span class="postcode">02110-1301</span><br>
+ <span class="country">USA</span><br>
+ </p></div><p>
+ </p><p>Everyone is permitted to copy and distribute verbatim
+ copies of this license document, but changing it is not
+ allowed.</p></div></div><div><p class="pubdate">Version 2.1, February 1999</p></div></div></div>
+<div class="section" lang="en"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="lgpl-1"></a>Preamble</h2></div></div></div><p>The licenses for most software are designed to take away your
+ freedom to share and change it. By contrast, the GNU General Public
+ Licenses are intended to guarantee your freedom to share and change
+ free software--to make sure the software is free for all its users.</p><p>This license, the Lesser General Public License, applies to some
+ specially designated software packages--typically libraries--of the
+ Free Software Foundation and other authors who decide to use it. You
+ can use it too, but we suggest you first think carefully about whether
+ this license or the ordinary General Public License is the better
+ strategy to use in any particular case, based on the explanations below.</p><p>When we speak of free software, we are referring to freedom of use,
+ not price. Our General Public Licenses are designed to make sure that
+ you have the freedom to distribute copies of free software (and charge
+ for this service if you wish); that you receive source code or can get
+ it if you want it; that you can change the software and use pieces of
+ it in new free programs; and that you are informed that you can do
+ these things.</p><p>To protect your rights, we need to make restrictions that forbid
+ distributors to deny you these rights or to ask you to surrender these
+ rights. These restrictions translate to certain responsibilities for
+ you if you distribute copies of the library or if you modify it.</p><p>For example, if you distribute copies of the library, whether gratis
+ or for a fee, you must give the recipients all the rights that we gave
+ you. You must make sure that they, too, receive or can get the source
+ code. If you link other code with the library, you must provide
+ complete object files to the recipients, so that they can relink them
+ with the library after making changes to the library and recompiling
+ it. And you must show them these terms so they know their rights.</p><p>We protect your rights with a two-step method:
+ </p><div class="orderedlist"><ol type="1"><li><p>we copyright the library, and</p></li><li><p>we offer you this license, which gives you legal
+ permission to copy, distribute and/or modify the library.</p></li></ol></div><p>
+ </p><p>To protect each distributor, we want to make it very clear that
+ there is no warranty for the free library. Also, if the library is
+ modified by someone else and passed on, the recipients should know
+ that what they have is not the original version, so that the original
+ author's reputation will not be affected by problems that might be
+ introduced by others.</p><p>Finally, software patents pose a constant threat to the existence of
+ any free program. We wish to make sure that a company cannot
+ effectively restrict the users of a free program by obtaining a
+ restrictive license from a patent holder. Therefore, we insist that
+ any patent license obtained for a version of the library must be
+ consistent with the full freedom of use specified in this license.</p><p>Most GNU software, including some libraries, is covered by the
+ ordinary GNU General Public License. This license, the GNU Lesser
+ General Public License, applies to certain designated libraries, and
+ is quite different from the ordinary General Public License. We use
+ this license for certain libraries in order to permit linking those
+ libraries into non-free programs.</p><p>When a program is linked with a library, whether statically or using
+ a shared library, the combination of the two is legally speaking a
+ combined work, a derivative of the original library. The ordinary
+ General Public License therefore permits such linking only if the
+ entire combination fits its criteria of freedom. The Lesser General
+ Public License permits more lax criteria for linking other code with
+ the library.</p><p>We call this license the <span class="emphasis"><em>Lesser</em></span> General Public License because it
+ does Less to protect the user's freedom than the ordinary General
+ Public License. It also provides other free software developers Less
+ of an advantage over competing non-free programs. These disadvantages
+ are the reason we use the ordinary General Public License for many
+ libraries. However, the Lesser license provides advantages in certain
+ special circumstances.</p><p>For example, on rare occasions, there may be a special need to
+ encourage the widest possible use of a certain library, so that it becomes
+ a de-facto standard. To achieve this, non-free programs must be
+ allowed to use the library. A more frequent case is that a free
+ library does the same job as widely used non-free libraries. In this
+ case, there is little to gain by limiting the free library to free
+ software only, so we use the Lesser General Public License.</p><p>In other cases, permission to use a particular library in non-free
+ programs enables a greater number of people to use a large body of
+ free software. For example, permission to use the GNU C Library in
+ non-free programs enables many more people to use the whole GNU
+ operating system, as well as its variant, the GNU/Linux operating
+ system.</p><p>Although the Lesser General Public License is Less protective of the
+ users' freedom, it does ensure that the user of a program that is
+ linked with the Library has the freedom and the wherewithal to run
+ that program using a modified version of the Library.</p><p>The precise terms and conditions for copying, distribution and
+ modification follow. Pay close attention to the difference between a
+ “<span class="quote">work based on the library</span>” and a “<span class="quote">work that uses the library</span>”. The
+ former contains code derived from the library, whereas the latter must
+ be combined with the library in order to run.</p></div><div class="section" lang="en"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="lgpl-2"></a>TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION</h2></div></div></div><div class="section" lang="en"><div class="titlepage"><div><div><h3 class="title"><a name="lgpl-2-0"></a>Section 0</h3></div></div></div><p>This License Agreement applies to any software library or other
+ program which contains a notice placed by the copyright holder or
+ other authorized party saying it may be distributed under the terms of
+ this Lesser General Public License (also called “<span class="quote">this License</span>”).
+ Each licensee is addressed as “<span class="quote">you</span>”.</p><p>A “<span class="quote">library</span>” means a collection of software functions and/or data
+ prepared so as to be conveniently linked with application programs
+ (which use some of those functions and data) to form executables.</p><p>The “<span class="quote">Library</span>”, below, refers to any such software library or work
+ which has been distributed under these terms. A “<span class="quote">work based on the
+ Library</span>” means either the Library or any derivative work under
+ copyright law: that is to say, a work containing the Library or a
+ portion of it, either verbatim or with modifications and/or translated
+ straightforwardly into another language. (Hereinafter, translation is
+ included without limitation in the term “<span class="quote">modification</span>”.)</p><p>“<span class="quote">Source code</span>” for a work means the preferred form of the work for
+ making modifications to it. For a library, complete source code means
+ all the source code for all modules it contains, plus any associated
+ interface definition files, plus the scripts used to control compilation
+ and installation of the library.</p><p>Activities other than copying, distribution and modification are not
+ covered by this License; they are outside its scope. The act of
+ running a program using the Library is not restricted, and output from
+ such a program is covered only if its contents constitute a work based
+ on the Library (independent of the use of the Library in a tool for
+ writing it). Whether that is true depends on what the Library does
+ and what the program that uses the Library does.</p></div><div class="section" lang="en"><div class="titlepage"><div><div><h3 class="title"><a name="lgpl-2-1"></a>Section 1</h3></div></div></div><p>You may copy and distribute verbatim copies of the Library's
+ complete source code as you receive it, in any medium, provided that
+ you conspicuously and appropriately publish on each copy an
+ appropriate copyright notice and disclaimer of warranty; keep intact
+ all the notices that refer to this License and to the absence of any
+ warranty; and distribute a copy of this License along with the
+ Library.</p><p>You may charge a fee for the physical act of transferring a copy,
+ and you may at your option offer warranty protection in exchange for a
+ fee.</p></div><div class="section" lang="en"><div class="titlepage"><div><div><h3 class="title"><a name="lgpl-2-2"></a>Section 2</h3></div></div></div><p>You may modify your copy or copies of the Library or any portion
+ of it, thus forming a work based on the Library, and copy and
+ distribute such modifications or work under the terms of <a href="#lgpl-2-1" title="Section 1">Section 1</a>
+ above, provided that you also meet all of these conditions:
+ </p><div class="orderedlist"><ol type="a"><li><p>The modified work must itself be a software library.</p></li><li><p>You must cause the files modified to carry prominent notices
+ stating that you changed the files and the date of any change.</p></li><li><p>You must cause the whole of the work to be licensed at no
+ charge to all third parties under the terms of this License.</p></li><li><p><a name="lgpl-2-2-d"></a>If a facility in the modified Library refers to a function or a
+ table of data to be supplied by an application program that uses
+ the facility, other than as an argument passed when the facility
+ is invoked, then you must make a good faith effort to ensure that,
+ in the event an application does not supply such function or
+ table, the facility still operates, and performs whatever part of
+ its purpose remains meaningful.</p><p>(For example, a function in a library to compute square roots has
+ a purpose that is entirely well-defined independent of the
+ application. Therefore, <a href="#lgpl-2-2-d">Subsection 2d</a> requires that any
+ application-supplied function or table used by this function must
+ be optional: if the application does not supply it, the square
+ root function must still compute square roots.)</p></li></ol></div><p>
+ </p><p>These requirements apply to the modified work as a whole. If
+ identifiable sections of that work are not derived from the Library,
+ and can be reasonably considered independent and separate works in
+ themselves, then this License, and its terms, do not apply to those
+ sections when you distribute them as separate works. But when you
+ distribute the same sections as part of a whole which is a work based
+ on the Library, the distribution of the whole must be on the terms of
+ this License, whose permissions for other licensees extend to the
+ entire whole, and thus to each and every part regardless of who wrote
+ it.</p><p>Thus, it is not the intent of this section to claim rights or contest
+ your rights to work written entirely by you; rather, the intent is to
+ exercise the right to control the distribution of derivative or
+ collective works based on the Library.</p><p>In addition, mere aggregation of another work not based on the Library
+ with the Library (or with a work based on the Library) on a volume of
+ a storage or distribution medium does not bring the other work under
+ the scope of this License.</p></div><div class="section" lang="en"><div class="titlepage"><div><div><h3 class="title"><a name="lgpl-2-3"></a>Section 3</h3></div></div></div><p>You may opt to apply the terms of the ordinary GNU General Public
+ License instead of this License to a given copy of the Library. To do
+ this, you must alter all the notices that refer to this License, so
+ that they refer to the ordinary GNU General Public License, version 2,
+ instead of to this License. (If a newer version than version 2 of the
+ ordinary GNU General Public License has appeared, then you can specify
+ that version instead if you wish.) Do not make any other change in
+ these notices.</p><p>Once this change is made in a given copy, it is irreversible for
+ that copy, so the ordinary GNU General Public License applies to all
+ subsequent copies and derivative works made from that copy.</p><p>This option is useful when you wish to copy part of the code of
+ the Library into a program that is not a library.</p></div><div class="section" lang="en"><div class="titlepage"><div><div><h3 class="title"><a name="lgpl-2-4"></a>Section 4</h3></div></div></div><p>You may copy and distribute the Library (or a portion or
+ derivative of it, under <a href="#lgpl-2-2" title="Section 2">Section 2</a>) in object code or executable form
+ under the terms of <a href="#lgpl-2-1" title="Section 1">Sections 1</a> and <a href="#lgpl-2-2" title="Section 2">2</a> above provided that you accompany
+ it with the complete corresponding machine-readable source code, which
+ must be distributed under the terms of <a href="#lgpl-2-1" title="Section 1">Sections 1</a> and <a href="#lgpl-2-2" title="Section 2">2</a> above on a
+ medium customarily used for software interchange.</p><p>If distribution of object code is made by offering access to copy
+ from a designated place, then offering equivalent access to copy the
+ source code from the same place satisfies the requirement to
+ distribute the source code, even though third parties are not
+ compelled to copy the source along with the object code.</p></div><div class="section" lang="en"><div class="titlepage"><div><div><h3 class="title"><a name="lgpl-2-5"></a>Section 5</h3></div></div></div><p>A program that contains no derivative of any portion of the
+ Library, but is designed to work with the Library by being compiled or
+ linked with it, is called a “<span class="quote">work that uses the Library</span>”. Such a
+ work, in isolation, is not a derivative work of the Library, and
+ therefore falls outside the scope of this License.</p><p>However, linking a “<span class="quote">work that uses the Library</span>” with the Library
+ creates an executable that is a derivative of the Library (because it
+ contains portions of the Library), rather than a “<span class="quote">work that uses the
+ library</span>”. The executable is therefore covered by this License.
+ <a href="#lgpl-2-6" title="Section 6">Section 6</a> states terms for distribution of such executables.</p><p>When a “<span class="quote">work that uses the Library</span>” uses material from a header file
+ that is part of the Library, the object code for the work may be a
+ derivative work of the Library even though the source code is not.
+ Whether this is true is especially significant if the work can be
+ linked without the Library, or if the work is itself a library. The
+ threshold for this to be true is not precisely defined by law.</p><p>If such an object file uses only numerical parameters, data
+ structure layouts and accessors, and small macros and small inline
+ functions (ten lines or less in length), then the use of the object
+ file is unrestricted, regardless of whether it is legally a derivative
+ work. (Executables containing this object code plus portions of the
+ Library will still fall under <a href="#lgpl-2-6" title="Section 6">Section 6</a>.)</p><p>Otherwise, if the work is a derivative of the Library, you may
+ distribute the object code for the work under the terms of <a href="#lgpl-2-6" title="Section 6">Section 6</a>.
+ Any executables containing that work also fall under <a href="#lgpl-2-6" title="Section 6">Section 6</a>,
+ whether or not they are linked directly with the Library itself.</p></div><div class="section" lang="en"><div class="titlepage"><div><div><h3 class="title"><a name="lgpl-2-6"></a>Section 6</h3></div></div></div><p>As an exception to the Sections above, you may also combine or
+ link a “<span class="quote">work that uses the Library</span>” with the Library to produce a
+ work containing portions of the Library, and distribute that work
+ under terms of your choice, provided that the terms permit
+ modification of the work for the customer's own use and reverse
+ engineering for debugging such modifications.</p><p>You must give prominent notice with each copy of the work that the
+ Library is used in it and that the Library and its use are covered by
+ this License. You must supply a copy of this License. If the work
+ during execution displays copyright notices, you must include the
+ copyright notice for the Library among them, as well as a reference
+ directing the user to the copy of this License. Also, you must do one
+ of these things:
+ </p><div class="orderedlist"><ol type="a"><li><p><a name="lgpl-2-6-a"></a>Accompany the work with the complete corresponding
+ machine-readable source code for the Library including whatever
+ changes were used in the work (which must be distributed under
+ <a href="#lgpl-2-1" title="Section 1">Sections 1</a> and <a href="#lgpl-2-2" title="Section 2">2</a> above); and, if the work is an executable linked
+ with the Library, with the complete machine-readable “<span class="quote">work that
+ uses the Library</span>”, as object code and/or source code, so that the
+ user can modify the Library and then relink to produce a modified
+ executable containing the modified Library. (It is understood
+ that the user who changes the contents of definitions files in the
+ Library will not necessarily be able to recompile the application
+ to use the modified definitions.)</p></li><li><p>Use a suitable shared library mechanism for linking with the
+ Library. A suitable mechanism is one that (1) uses at run time a
+ copy of the library already present on the user's computer system,
+ rather than copying library functions into the executable, and (2)
+ will operate properly with a modified version of the library, if
+ the user installs one, as long as the modified version is
+ interface-compatible with the version that the work was made with.</p></li><li><p>Accompany the work with a written offer, valid for at
+ least three years, to give the same user the materials
+ specified in <a href="#lgpl-2-6-a">Subsection 6a</a>, above, for a charge no more
+ than the cost of performing this distribution.</p></li><li><p>If distribution of the work is made by offering access to copy
+ from a designated place, offer equivalent access to copy the above
+ specified materials from the same place.</p></li><li><p>Verify that the user has already received a copy of these
+ materials or that you have already sent this user a copy.</p></li></ol></div><p>
+ </p><p>For an executable, the required form of the “<span class="quote">work that uses the
+ Library</span>” must include any data and utility programs needed for
+ reproducing the executable from it. However, as a special exception,
+ the materials to be distributed need not include anything that is
+ normally distributed (in either source or binary form) with the major
+ components (compiler, kernel, and so on) of the operating system on
+ which the executable runs, unless that component itself accompanies
+ the executable.</p><p>It may happen that this requirement contradicts the license
+ restrictions of other proprietary libraries that do not normally
+ accompany the operating system. Such a contradiction means you cannot
+ use both them and the Library together in an executable that you
+ distribute.</p></div><div class="section" lang="en"><div class="titlepage"><div><div><h3 class="title"><a name="lgpl-2-7"></a>Section 7</h3></div></div></div><p>You may place library facilities that are a work based on the
+ Library side-by-side in a single library together with other library
+ facilities not covered by this License, and distribute such a combined
+ library, provided that the separate distribution of the work based on
+ the Library and of the other library facilities is otherwise
+ permitted, and provided that you do these two things:
+ </p><div class="orderedlist"><ol type="a"><li><p>Accompany the combined library with a copy of the same work
+ based on the Library, uncombined with any other library
+ facilities. This must be distributed under the terms of the
+ Sections above.</p></li><li><p>Give prominent notice with the combined library of the fact
+ that part of it is a work based on the Library, and explaining
+ where to find the accompanying uncombined form of the same work.</p></li></ol></div><p>
+ </p></div><div class="section" lang="en"><div class="titlepage"><div><div><h3 class="title"><a name="lgpl-2-8"></a>Section 8</h3></div></div></div><p>You may not copy, modify, sublicense, link with, or distribute
+ the Library except as expressly provided under this License. Any
+ attempt otherwise to copy, modify, sublicense, link with, or
+ distribute the Library is void, and will automatically terminate your
+ rights under this License. However, parties who have received copies,
+ or rights, from you under this License will not have their licenses
+ terminated so long as such parties remain in full compliance.</p></div><div class="section" lang="en"><div class="titlepage"><div><div><h3 class="title"><a name="lgpl-2-9"></a>Section 9</h3></div></div></div><p>You are not required to accept this License, since you have not
+ signed it. However, nothing else grants you permission to modify or
+ distribute the Library or its derivative works. These actions are
+ prohibited by law if you do not accept this License. Therefore, by
+ modifying or distributing the Library (or any work based on the
+ Library), you indicate your acceptance of this License to do so, and
+ all its terms and conditions for copying, distributing or modifying
+ the Library or works based on it.</p></div><div class="section" lang="en"><div class="titlepage"><div><div><h3 class="title"><a name="lgpl-2-10"></a>Section 10</h3></div></div></div><p>Each time you redistribute the Library (or any work based on the
+ Library), the recipient automatically receives a license from the
+ original licensor to copy, distribute, link with or modify the Library
+ subject to these terms and conditions. You may not impose any further
+ restrictions on the recipients' exercise of the rights granted herein.
+ You are not responsible for enforcing compliance by third parties with
+ this License.</p></div><div class="section" lang="en"><div class="titlepage"><div><div><h3 class="title"><a name="lgpl-2-11"></a>Section 11</h3></div></div></div><p>If, as a consequence of a court judgment or allegation of patent
+ infringement or for any other reason (not limited to patent issues),
+ conditions are imposed on you (whether by court order, agreement or
+ otherwise) that contradict the conditions of this License, they do not
+ excuse you from the conditions of this License. If you cannot
+ distribute so as to satisfy simultaneously your obligations under this
+ License and any other pertinent obligations, then as a consequence you
+ may not distribute the Library at all. For example, if a patent
+ license would not permit royalty-free redistribution of the Library by
+ all those who receive copies directly or indirectly through you, then
+ the only way you could satisfy both it and this License would be to
+ refrain entirely from distribution of the Library.</p><p>If any portion of this section is held invalid or unenforceable under any
+ particular circumstance, the balance of the section is intended to apply,
+ and the section as a whole is intended to apply in other circumstances.</p><p>It is not the purpose of this section to induce you to infringe any
+ patents or other property right claims or to contest validity of any
+ such claims; this section has the sole purpose of protecting the
+ integrity of the free software distribution system which is
+ implemented by public license practices. Many people have made
+ generous contributions to the wide range of software distributed
+ through that system in reliance on consistent application of that
+ system; it is up to the author/donor to decide if he or she is willing
+ to distribute software through any other system and a licensee cannot
+ impose that choice.</p><p>This section is intended to make thoroughly clear what is believed to
+ be a consequence of the rest of this License.</p></div><div class="section" lang="en"><div class="titlepage"><div><div><h3 class="title"><a name="lgpl-2-12"></a>Section 12</h3></div></div></div><p>If the distribution and/or use of the Library is restricted in
+ certain countries either by patents or by copyrighted interfaces, the
+ original copyright holder who places the Library under this License may add
+ an explicit geographical distribution limitation excluding those countries,
+ so that distribution is permitted only in or among countries not thus
+ excluded. In such case, this License incorporates the limitation as if
+ written in the body of this License.</p></div><div class="section" lang="en"><div class="titlepage"><div><div><h3 class="title"><a name="lgpl-2-13"></a>Section 13</h3></div></div></div><p>The Free Software Foundation may publish revised and/or new
+ versions of the Lesser General Public License from time to time.
+ Such new versions will be similar in spirit to the present version,
+ but may differ in detail to address new problems or concerns.</p><p>Each version is given a distinguishing version number. If the Library
+ specifies a version number of this License which applies to it and
+ “<span class="quote">any later version</span>”, you have the option of following the terms and
+ conditions either of that version or of any later version published by
+ the Free Software Foundation. If the Library does not specify a
+ license version number, you may choose any version ever published by
+ the Free Software Foundation.</p></div><div class="section" lang="en"><div class="titlepage"><div><div><h3 class="title"><a name="lgpl-2-14"></a>Section 14</h3></div></div></div><p>If you wish to incorporate parts of the Library into other free
+ programs whose distribution conditions are incompatible with these,
+ write to the author to ask for permission. For software which is
+ copyrighted by the Free Software Foundation, write to the Free
+ Software Foundation; we sometimes make exceptions for this. Our
+ decision will be guided by the two goals of preserving the free status
+ of all derivatives of our free software and of promoting the sharing
+ and reuse of software generally.</p></div><div class="section" lang="en"><div class="titlepage"><div><div><h3 class="title"><a name="lgpl-2-15"></a>NO WARRANTY Section 15</h3></div></div></div><p>BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO
+ WARRANTY FOR THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE LAW.
+ EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR
+ OTHER PARTIES PROVIDE THE LIBRARY “<span class="quote">AS IS</span>” WITHOUT WARRANTY OF ANY
+ KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE
+ IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE
+ LIBRARY IS WITH YOU. SHOULD THE LIBRARY PROVE DEFECTIVE, YOU ASSUME
+ THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION.</p></div><div class="section" lang="en"><div class="titlepage"><div><div><h3 class="title"><a name="lgpl-2-16"></a>Section 16</h3></div></div></div><p>IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN
+ WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY
+ AND/OR REDISTRIBUTE THE LIBRARY AS PERMITTED ABOVE, BE LIABLE TO YOU
+ FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR
+ CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE
+ LIBRARY (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING
+ RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A
+ FAILURE OF THE LIBRARY TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF
+ SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH
+ DAMAGES.</p><p>END OF TERMS AND CONDITIONS</p></div></div><div class="section" lang="en"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="lgpl-3"></a>How to Apply These Terms to Your New Libraries</h2></div></div></div><p>If you develop a new library, and you want it to be of the greatest
+ possible use to the public, we recommend making it free software that
+ everyone can redistribute and change. You can do so by permitting
+ redistribution under these terms (or, alternatively, under the terms of the
+ ordinary General Public License).</p><p>To apply these terms, attach the following notices to the library. It is
+ safest to attach them to the start of each source file to most effectively
+ convey the exclusion of warranty; and each file should have at least the
+ “<span class="quote">copyright</span>” line and a pointer to where the full notice is found.</p><p><one line to give the library's name and a brief idea of what it does.>
+ Copyright (C) <year> <name of author></p><p>This library 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.</p><p>This library 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.</p><p>You should have received a copy of the GNU Lesser General Public
+ License along with this library; if not, write to the Free Software
+ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA</p><p>Also add information on how to contact you by electronic and paper mail.</p><p>You should also get your employer (if you work as a programmer) or your
+ school, if any, to sign a “<span class="quote">copyright disclaimer</span>” for the library, if
+ necessary. Here is a sample; alter the names:</p><p>Yoyodyne, Inc., hereby disclaims all copyright interest in the
+ library `Frob' (a library for tweaking knobs) written by James Random Hacker.</p><p><signature of Ty Coon>, 1 April 1990
+ Ty Coon, President of Vice</p><p>That's all there is to it!</p></div></div></body></html>
Added: branches/JBossProfiler2/lib/asm.jar
===================================================================
(Binary files differ)
Property changes on: branches/JBossProfiler2/lib/asm.jar
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: branches/JBossProfiler2/lib/concurrent.jar
===================================================================
(Binary files differ)
Property changes on: branches/JBossProfiler2/lib/concurrent.jar
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: branches/JBossProfiler2/lib/ejb3-persistence.jar
===================================================================
(Binary files differ)
Property changes on: branches/JBossProfiler2/lib/ejb3-persistence.jar
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: branches/JBossProfiler2/lib/jboss-common.jar
===================================================================
(Binary files differ)
Property changes on: branches/JBossProfiler2/lib/jboss-common.jar
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: branches/JBossProfiler2/lib/jboss-ejb3x.jar
===================================================================
(Binary files differ)
Property changes on: branches/JBossProfiler2/lib/jboss-ejb3x.jar
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: branches/JBossProfiler2/lib/jboss-remoting.jar
===================================================================
(Binary files differ)
Property changes on: branches/JBossProfiler2/lib/jboss-remoting.jar
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: branches/JBossProfiler2/lib/jbossall-client.jar
===================================================================
(Binary files differ)
Property changes on: branches/JBossProfiler2/lib/jbossall-client.jar
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: branches/JBossProfiler2/lib/log4j.jar
===================================================================
(Binary files differ)
Property changes on: branches/JBossProfiler2/lib/log4j.jar
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: branches/JBossProfiler2/lib/servlet.jar
===================================================================
(Binary files differ)
Property changes on: branches/JBossProfiler2/lib/servlet.jar
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: branches/JBossProfiler2/src/etc/agent-manifest.mf
===================================================================
--- branches/JBossProfiler2/src/etc/agent-manifest.mf (rev 0)
+++ branches/JBossProfiler2/src/etc/agent-manifest.mf 2008-02-10 10:59:33 UTC (rev 420)
@@ -0,0 +1,7 @@
+Manifest-Version: 1.0
+Premain-Class: org.jboss.profiler.agent.Agent
+Agent-Class: org.jboss.profiler.agent.Agent
+Boot-Class-Path: jboss-profiler.jar jboss-profiler-connectors.jar jboss-profiler-plugins.jar asm.jar jboss-remoting.jar jboss-common.jar concurrent.jar log4j.jar
+Can-Redefine-Classes: true
+Can-Retransform-Classes: false
+Can-Set-Native-Method-Prefix: false
Added: branches/JBossProfiler2/src/etc/client-manifest.mf
===================================================================
--- branches/JBossProfiler2/src/etc/client-manifest.mf (rev 0)
+++ branches/JBossProfiler2/src/etc/client-manifest.mf 2008-02-10 10:59:33 UTC (rev 420)
@@ -0,0 +1,3 @@
+Manifest-Version: 1.0
+Main-Class: org.jboss.profiler.client.cmd.Client
+Class-Path: jboss-profiler-client.jar jboss-profiler-plugins.jar log4j.jar jboss-remoting.jar jboss-common.jar concurrent.jar
Added: branches/JBossProfiler2/src/etc/connectors-manifest.mf
===================================================================
--- branches/JBossProfiler2/src/etc/connectors-manifest.mf (rev 0)
+++ branches/JBossProfiler2/src/etc/connectors-manifest.mf 2008-02-10 10:59:33 UTC (rev 420)
@@ -0,0 +1 @@
+Manifest-Version: 1.0
Added: branches/JBossProfiler2/src/etc/jboss-profiler-client.properties
===================================================================
--- branches/JBossProfiler2/src/etc/jboss-profiler-client.properties (rev 0)
+++ branches/JBossProfiler2/src/etc/jboss-profiler-client.properties 2008-02-10 10:59:33 UTC (rev 420)
@@ -0,0 +1,5 @@
+protocol=socket
+host=localhost
+port=5400
+threshold=1.0
+plugin.1=org.jboss.profiler.plugins.Hibernate
Added: branches/JBossProfiler2/src/etc/jboss-profiler.properties
===================================================================
--- branches/JBossProfiler2/src/etc/jboss-profiler.properties (rev 0)
+++ branches/JBossProfiler2/src/etc/jboss-profiler.properties 2008-02-10 10:59:33 UTC (rev 420)
@@ -0,0 +1,21 @@
+enable=yes
+cpu=yes
+memory=yes
+includes=org.jboss.profiler.*
+excludes=*
+visibility=private
+save=yes
+startup=yes
+repository=no
+remote=yes
+store=memory
+location=.
+host=localhost
+port=5400
+ejb=yes
+servlet=yes
+jsf=yes
+jmx=yes
+rmi=yes
+corba=yes
+plugin.1=org.jboss.profiler.plugins.Hibernate
Added: branches/JBossProfiler2/src/etc/jboss-service.xml
===================================================================
--- branches/JBossProfiler2/src/etc/jboss-service.xml (rev 0)
+++ branches/JBossProfiler2/src/etc/jboss-service.xml 2008-02-10 10:59:33 UTC (rev 420)
@@ -0,0 +1,45 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<!-- ===================================================================== -->
+<!-- -->
+<!-- JBoss Profiler -->
+<!-- -->
+<!-- ===================================================================== -->
+
+<server>
+
+ <!-- JBoss Profiler: Profiler -->
+ <mbean code="org.jboss.profiler.as.Profiler"
+ name="org.jboss.profiler:service=Profiler">
+
+ </mbean>
+
+ <!-- JBoss Profiler: Communicator -->
+ <mbean code="org.jboss.profiler.as.Communicator"
+ name="org.jboss.profiler:service=Communicator">
+
+ <!-- The host name -->
+ <attribute name="Host">localhost</attribute>
+
+ <!-- Socket -->
+ <attribute name="Socket">true</attribute>
+
+ <!-- The socket port -->
+ <attribute name="SocketPort">5400</attribute>
+
+ <!-- RMI -->
+ <attribute name="Rmi">false</attribute>
+
+ <!-- The RMI port -->
+ <attribute name="RmiPort">5401</attribute>
+
+ <!-- HTTP -->
+ <attribute name="Socket">false</attribute>
+
+ <!-- The HTTP port -->
+ <attribute name="HttpPort">5402</attribute>
+
+ </mbean>
+
+</server>
+
Added: branches/JBossProfiler2/src/etc/jsf-config.xml
===================================================================
--- branches/JBossProfiler2/src/etc/jsf-config.xml (rev 0)
+++ branches/JBossProfiler2/src/etc/jsf-config.xml 2008-02-10 10:59:33 UTC (rev 420)
@@ -0,0 +1,21 @@
+<?xml version="1.0"?>
+
+<!DOCTYPE faces-config PUBLIC
+ "-//Sun Microsystems, Inc.//DTD JavaServer Faces Config 1.1//EN"
+ "http://java.sun.com/dtd/web-facesconfig_1_1.dtd">
+
+<faces-config>
+
+ <managed-bean>
+ <managed-bean-name>dontexist</managed-bean-name>
+ <managed-bean-class>org.jboss.profiler.test.DontExist</managed-bean-class>
+ <managed-bean-scope>request</managed-bean-scope>
+ </managed-bean>
+
+ <managed-bean>
+ <managed-bean-name>mybean</managed-bean-name>
+ <managed-bean-class>org.jboss.profiler.test.ManagedBean</managed-bean-class>
+ <managed-bean-scope>request</managed-bean-scope>
+ </managed-bean>
+
+</faces-config>
Added: branches/JBossProfiler2/src/etc/log4j.xml
===================================================================
--- branches/JBossProfiler2/src/etc/log4j.xml (rev 0)
+++ branches/JBossProfiler2/src/etc/log4j.xml 2008-02-10 10:59:33 UTC (rev 420)
@@ -0,0 +1,17 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+<!DOCTYPE log4j:configuration SYSTEM "log4j.dtd">
+
+<log4j:configuration xmlns:log4j="http://jakarta.apache.org/log4j/">
+ <appender name="console" class="org.apache.log4j.ConsoleAppender">
+ <param name="Target" value="System.out"/>
+ <layout class="org.apache.log4j.PatternLayout">
+ <param name="ConversionPattern" value="%d %-5p [%c] %m%n"/>
+ </layout>
+ </appender>
+
+ <root>
+ <priority value ="info" />
+ <appender-ref ref="console" />
+ </root>
+
+</log4j:configuration>
Added: branches/JBossProfiler2/src/etc/web.xml
===================================================================
--- branches/JBossProfiler2/src/etc/web.xml (rev 0)
+++ branches/JBossProfiler2/src/etc/web.xml 2008-02-10 10:59:33 UTC (rev 420)
@@ -0,0 +1,19 @@
+<?xml version="1.0"?>
+
+<!DOCTYPE web-app PUBLIC
+ "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"
+ "http://java.sun.com/dtd/web-app_2_3.dtd">
+
+<web-app>
+
+ <context-param>
+ <param-name>javax.faces.CONFIG_FILES</param-name>
+ <param-value>/WEB-INF/jsf-config.xml</param-value>
+ </context-param>
+
+ <context-param>
+ <param-name>javax.faces.STATE_SAVING_METHOD</param-name>
+ <param-value>server</param-value>
+ </context-param>
+
+</web-app>
Added: branches/JBossProfiler2/src/main/org/jboss/profiler/agent/Agent.java
===================================================================
--- branches/JBossProfiler2/src/main/org/jboss/profiler/agent/Agent.java (rev 0)
+++ branches/JBossProfiler2/src/main/org/jboss/profiler/agent/Agent.java 2008-02-10 10:59:33 UTC (rev 420)
@@ -0,0 +1,944 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2007, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file 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.agent;
+
+import org.jboss.profiler.agent.jobs.Job;
+import org.jboss.profiler.agent.jobs.JobHelper;
+import org.jboss.profiler.shared.Plugin;
+import org.jboss.profiler.shared.PluginHelper;
+import org.jboss.profiler.shared.Snapshot;
+import org.jboss.profiler.shared.SnapshotHelper;
+import org.jboss.profiler.shared.Version;
+import org.jboss.profiler.shared.Visibility;
+
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.lang.instrument.ClassDefinition;
+import java.lang.instrument.Instrumentation;
+import java.lang.reflect.Constructor;
+import java.lang.reflect.Method;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+import java.util.Properties;
+import java.util.StringTokenizer;
+import java.util.Timer;
+import java.util.TreeMap;
+
+/**
+ * The agent class
+ * @author Jesper Pedersen <jep at worldleaguesports.com>
+ */
+public class Agent {
+
+ /** Transformer */
+ private static Transformer transformer;
+
+ /** Instrumentation */
+ private static Instrumentation instrumentation;
+
+ /** Enabled */
+ private static boolean enabled = true;
+
+ /** CPU */
+ private static boolean cpu = true;
+
+ /** Memory */
+ private static boolean memory = true;
+
+ /** Quite */
+ private static boolean quite = false;
+
+ /** Include all */
+ private static boolean includeAll = false;
+
+ /** The include list */
+ private static List<String> includeList = new ArrayList<String>();
+
+ /** Exclude all */
+ private static boolean excludeAll = true;
+
+ /** The exclude list */
+ private static List<String> excludeList = new ArrayList<String>();
+
+ /** Repository */
+ private static boolean repository = false;
+
+ /** Store */
+ private static boolean store = true;
+
+ /** Store location */
+ private static String storeLocation;
+
+ /** Remote */
+ private static boolean remote = true;
+
+ /** Host */
+ private static String host;
+
+ /** Port */
+ private static int port;
+
+ /** Connector */
+ private static Object connector = null;
+
+ /** Global visibility */
+ private static Visibility visibility;
+
+ /** Visibility tree */
+ private static TreeMap visibilityTree;
+
+ /** Save */
+ private static boolean save = true;
+
+ /** Startup */
+ private static boolean startup = true;
+
+ /** EJB */
+ private static boolean ejb = true;
+
+ /** Servlet */
+ private static boolean servlet = true;
+
+ /** JSF */
+ private static boolean jsf = true;
+
+ /** JMX */
+ private static boolean jmx = true;
+
+ /** RMI */
+ private static boolean rmi = true;
+
+ /** CORBA */
+ private static boolean corba = true;
+
+ /** Timer */
+ private static Timer timer;
+
+ /**
+ * Parse configuration
+ */
+ private static void parseConfiguration() {
+ Properties properties = new Properties();
+ String propertiesFile = System.getProperty("jboss-profiler.properties");
+ boolean loaded = false;
+
+ if (propertiesFile != null) {
+ FileInputStream fis = null;
+ try {
+ fis = new FileInputStream(propertiesFile);
+ properties.load(fis);
+ loaded = true;
+ } catch (IOException e) {
+ System.err.println("Unable to open " + propertiesFile);
+ } finally {
+ if (fis != null) {
+ try {
+ fis.close();
+ } catch (IOException ioe) {
+ // Nothing to do
+ }
+ }
+ }
+ }
+ if (!loaded) {
+ InputStream is = null;
+ try {
+ ClassLoader cl = Thread.currentThread().getContextClassLoader();
+ is = cl.getResourceAsStream("jboss-profiler.properties");
+ properties.load(is);
+ loaded = true;
+ } catch (Exception ie) {
+ // Properties file not found
+ } finally {
+ if (is != null) {
+ try {
+ is.close();
+ } catch (IOException ioe) {
+ // Nothing to do
+ }
+ }
+ }
+ }
+
+ String vs = properties.getProperty("visibility", "private");
+ visibility = parseVisibility(vs);
+ visibilityTree = new TreeMap(new SizeComparator());
+
+ ejb = parseBoolean(properties.getProperty("ejb"), true);
+ servlet = parseBoolean(properties.getProperty("servlet"), true);
+ jsf = parseBoolean(properties.getProperty("jsf"), true);
+ jmx = parseBoolean(properties.getProperty("jmx"), true);
+ rmi = parseBoolean(properties.getProperty("rmi"), true);
+ corba = parseBoolean(properties.getProperty("corba"), true);
+
+ repository = parseBoolean(properties.getProperty("repository"), false);
+
+ parse(properties.getProperty("includes"), properties.getProperty("excludes"));
+
+ enabled = parseBoolean(properties.getProperty("enable"), true);
+ cpu = parseBoolean(properties.getProperty("cpu"), true);
+ memory = parseBoolean(properties.getProperty("memory"), true);
+ remote = parseBoolean(properties.getProperty("remote"), true);
+ host = properties.getProperty("host", "localhost");
+ port = Integer.parseInt(properties.getProperty("port", "5400"));
+
+ save = parseBoolean(properties.getProperty("save"), true);
+ startup = parseBoolean(properties.getProperty("startup"), true);
+
+ store = parseStore(properties.getProperty("store"), true);
+ storeLocation = properties.getProperty("location", System.getProperty("java.io.tmpdir"));
+ if (!storeLocation.endsWith(File.separator)) {
+ storeLocation += File.separator;
+ }
+
+ loadPlugins(properties);
+ loadJobs(properties);
+ }
+
+ /**
+ * Parse boolean property
+ * @param p The property
+ * @param def The default value
+ * @return True or false
+ */
+ private static boolean parseBoolean(String p, boolean def) {
+ if (p != null) {
+ p = p.trim();
+ if ("ON".equalsIgnoreCase(p) ||
+ "YES".equalsIgnoreCase(p) ||
+ "TRUE".equalsIgnoreCase(p)) {
+ return true;
+ } else {
+ return false;
+ }
+ }
+
+ return def;
+ }
+
+ /**
+ * Parse visibility property
+ * @param vs The property
+ * @return The visibility
+ */
+ private static Visibility parseVisibility(String vs) {
+ if (vs != null) {
+ if ("public".equalsIgnoreCase(vs)) {
+ return Visibility.PUBLIC;
+ } else if ("protected".equalsIgnoreCase(vs)) {
+ return Visibility.PROTECTED;
+ }
+ }
+ return Visibility.PRIVATE;
+ }
+
+ /**
+ * Parse include / exclude lists
+ * @param include The include input
+ * @param exclude The exclude input
+ */
+ private static void parse(String include, String exclude) {
+ if (include != null) {
+ if (servlet) {
+ includeList.add("org/apache/jsp/");
+ visibilityTree.put("org/apache/jsp/", Visibility.PUBLIC);
+ }
+
+ StringTokenizer st = new StringTokenizer(include, ",");
+ List<String> l = new ArrayList<String>();
+ while (st.hasMoreTokens()) {
+ String s = st.nextToken();
+ s = s.trim();
+ if ("*".equals(s)) {
+ includeAll = true;
+ } else {
+ l.add(s);
+ }
+ }
+ Collections.sort(l, new SizeComparator());
+ Collections.reverse(l);
+
+ for (String s: l) {
+ String c = s;
+ String v = null;
+ if (s.indexOf("|") != -1) {
+ c = s.substring(0, s.indexOf("|"));
+ c = c.trim();
+ v = s.substring(s.indexOf("|") + 1);
+ v = v.trim();
+ }
+
+ if (c.endsWith(".*")) {
+ c = c.substring(0, c.indexOf(".*")) + "/";
+ }
+ if (c.endsWith(".class")) {
+ c = c.substring(0, c.indexOf(".class"));
+ }
+ c = c.replace('.', '/');
+
+ Iterator it = includeList.iterator();
+ while (it.hasNext()) {
+ String t = (String)it.next();
+
+ if (t.startsWith(c)) {
+ it.remove();
+ }
+ }
+ it = visibilityTree.keySet().iterator();
+ while (it.hasNext()) {
+ String t = (String)it.next();
+
+ if (t.startsWith(c)) {
+ it.remove();
+ }
+ }
+
+ includeList.add(c);
+ if (v != null) {
+ visibilityTree.put(c, parseVisibility(v));
+ }
+ }
+ }
+
+ if (exclude != null) {
+ excludeAll = false;
+ StringTokenizer st = new StringTokenizer(exclude, ",");
+ List<String> l = new ArrayList<String>();
+ while (st.hasMoreTokens()) {
+ String s = st.nextToken();
+ s = s.trim();
+ if ("*".equals(s)) {
+ excludeAll = true;
+ } else {
+ l.add(s);
+ }
+ }
+ Collections.sort(l, new SizeComparator());
+
+ for (String c: l) {
+ if (c.endsWith(".*")) {
+ c = c.substring(0, c.indexOf(".*")) + "/";
+ }
+ if (c.endsWith(".class")) {
+ c = c.substring(0, c.indexOf(".class"));
+ }
+ c = c.replace('.', '/');
+
+ Iterator it = excludeList.iterator();
+ while (it.hasNext()) {
+ String s = (String)it.next();
+
+ if (s.startsWith(c)) {
+ it.remove();
+ }
+ }
+
+ excludeList.add(c);
+ }
+ }
+
+ Collections.sort(includeList, new SizeComparator());
+ Collections.sort(excludeList, new SizeComparator());
+ }
+
+ /**
+ * Parse store property
+ * @param p The property
+ * @param def The default value
+ * @return True or false
+ */
+ private static boolean parseStore(String p, boolean def) {
+ if (p != null) {
+ p = p.trim();
+ if ("FILE".equalsIgnoreCase(p)) {
+ return false;
+ } else {
+ return true;
+ }
+ }
+
+ return def;
+ }
+
+ /**
+ * Is the memory store enabled ?
+ * @return True if the memory store is enabled; otherwise false (file store)
+ */
+ public static boolean isMemoryStore() {
+ return store;
+ }
+
+ /**
+ * Get the file store location
+ * @return The file store location
+ */
+ public static String getFileStoreLocation() {
+ return storeLocation;
+ }
+
+ /**
+ * Is the repository enabled ?
+ * @return True if the repository is enabled; otherwise false
+ */
+ public static boolean isRepository() {
+ return repository;
+ }
+
+ /**
+ * Is the profiler enabled ?
+ * @return True if the profiler is enabled; otherwise false
+ */
+ public static boolean isEnabled() {
+ return enabled;
+ }
+
+ /**
+ * Set the enabled state of the agent
+ * @param e The enabled state
+ */
+ public static void setEnabled(boolean e) {
+ enabled = e;
+
+ if (isRepository()) {
+ List<Class> l = new ArrayList<Class>();
+
+ for (Class c : instrumentation.getAllLoadedClasses()) {
+ String className = c.getName().replace(".", "/");
+
+ boolean added = false;
+ for (int i = 0; !added && i < includeList.size(); i++) {
+ String classes = includeList.get(i);
+ if (className.startsWith(classes)) {
+ l.add(c);
+ added = true;
+ }
+ }
+ }
+
+ Class[] clz = new Class[l.size()];
+ for (int i = 0; i < l.size(); i++) {
+ clz[i] = l.get(i);
+ }
+
+ if (enabled) {
+ redefine(clz, true);
+ } else {
+ redefine(clz, false);
+ }
+ }
+ }
+
+ /**
+ * Is the CPU profiling enabled ?
+ * @return True if enabled; otherwise false
+ */
+ public static boolean isCPU() {
+ return cpu;
+ }
+
+ /**
+ * Is the memory profiling enabled ?
+ * @return True if enabled; otherwise false
+ */
+ public static boolean isMemory() {
+ return memory;
+ }
+
+ /**
+ * Load plugins
+ * @param prop The properties
+ */
+ private static void loadPlugins(Properties prop) {
+ List<Plugin> ps = PluginHelper.load(prop);
+
+ for (Plugin p : ps) {
+ ClassUtil.addPlugin(p);
+ }
+ }
+
+ /**
+ * Load jobs
+ * @param prop The properties
+ */
+ private static void loadJobs(Properties prop) {
+ List<Job> js = JobHelper.load(prop);
+
+ if (js != null && js.size() > 0) {
+ timer = new Timer(Version.VENDOR + " " + Version.PRODUCT + ": Job executer", true);
+ for (Job j : js) {
+ if (j.getPeriod() >= 0) {
+ timer.scheduleAtFixedRate(j, j.getTime(), j.getPeriod());
+ } else {
+ timer.schedule(j, j.getTime());
+ }
+ }
+ }
+ }
+
+ /**
+ * Get the instrumentation interface
+ * @return The instrumentation
+ */
+ public static Instrumentation getInstrumentation() {
+ return instrumentation;
+ }
+
+ /**
+ * Approve the following class for transformation
+ * @param className The class name
+ * @return True if the class is approved; otherwise false
+ */
+ private static boolean approve(String className) {
+ // We can't profile the profiler, Java / Sun classes nor ASM
+ if (className.startsWith("org/jboss/profiler/agent") ||
+ className.startsWith("org/jboss/profiler/as") ||
+ className.startsWith("org/jboss/profiler/shared") ||
+ className.startsWith("org/jboss/profiler/client") ||
+ className.startsWith("org/jboss/profiler/connectors") ||
+ className.startsWith("org/jboss/profiler/plugins") ||
+ className.startsWith("java/") ||
+ className.startsWith("javax/") ||
+ className.startsWith("sun/") ||
+ className.startsWith("com/sun/") ||
+ className.startsWith("org/objectweb/asm/")) {
+ return false;
+ }
+
+ return true;
+ }
+
+ /**
+ * Accept the following class for transformation
+ * @param className The class name
+ * @return True if the class should be transformed; otherwise false
+ */
+ public static boolean accept(String className) {
+ if (!approve(className)) {
+ return false;
+ }
+
+ if (!excludeAll) {
+ for (String cl : excludeList) {
+ if (className.startsWith(cl)) {
+ return false;
+ }
+ }
+ }
+
+ if (includeAll && !excludeAll) {
+ return true;
+ }
+
+ for (String cl : includeList) {
+ if (className.startsWith(cl)) {
+ return true;
+ }
+ }
+
+ return false;
+ }
+
+ /**
+ * Get the visibility for class
+ * @param className The class name
+ * @return The visibility
+ */
+ public static Visibility getVisibility(String className) {
+ Iterator it = visibilityTree.entrySet().iterator();
+ while (it.hasNext()) {
+ Map.Entry entry = (Map.Entry)it.next();
+ String key = (String)entry.getKey();
+ if (className.startsWith(key)) {
+ return (Visibility)entry.getValue();
+ }
+ }
+
+ return visibility;
+ }
+
+ /**
+ * Is EJB ?
+ * @return True if enabled; otherwise false
+ */
+ public static boolean isEJB() {
+ return ejb;
+ }
+
+ /**
+ * Is Servlet ?
+ * @return True if enabled; otherwise false
+ */
+ public static boolean isServlet() {
+ return servlet;
+ }
+
+ /**
+ * Is JSF ?
+ * @return True if enabled; otherwise false
+ */
+ public static boolean isJSF() {
+ return jsf;
+ }
+
+ /**
+ * Is JMX ?
+ * @return True if enabled; otherwise false
+ */
+ public static boolean isJMX() {
+ return jmx;
+ }
+
+ /**
+ * Is RMI ?
+ * @return True if enabled; otherwise false
+ */
+ public static boolean isRMI() {
+ return rmi;
+ }
+
+ /**
+ * Is CORBA ?
+ * @return True if enabled; otherwise false
+ */
+ public static boolean isCORBA() {
+ return corba;
+ }
+
+ /**
+ * Add classes
+ * @param classes The classes
+ * @param v The visibility
+ */
+ public static void addClasses(String classes, Visibility v) {
+ if (isRepository()) {
+
+ if (classes.endsWith(".*")) {
+ classes = classes.substring(0, classes.indexOf(".*")) + "/";
+ }
+ if (classes.endsWith(".class")) {
+ classes = classes.substring(0, classes.indexOf(".class"));
+ }
+ classes = classes.replace('.', '/');
+
+ if (approve(classes)) {
+ List<Class> l = new ArrayList<Class>();
+
+ for (Class c : instrumentation.getAllLoadedClasses()) {
+ String className = c.getName().replace(".", "/");
+ if (className.startsWith(classes)) {
+ l.add(c);
+ }
+ }
+
+ Class[] clz = new Class[l.size()];
+ for (int i = 0; i < l.size(); i++) {
+ clz[i] = l.get(i);
+ }
+
+ Iterator it = includeList.iterator();
+ while (it.hasNext()) {
+ String s = (String)it.next();
+
+ if (s.startsWith(classes)) {
+ it.remove();
+ }
+ }
+
+ it = visibilityTree.keySet().iterator();
+ while (it.hasNext()) {
+ String s = (String)it.next();
+
+ if (s.startsWith(classes)) {
+ it.remove();
+ }
+ }
+
+ it = excludeList.iterator();
+ while (it.hasNext()) {
+ String s = (String)it.next();
+
+ if (s.startsWith(classes)) {
+ it.remove();
+ }
+ }
+
+ includeList.add(classes);
+ visibilityTree.put(classes, v);
+
+ Collections.sort(includeList, new SizeComparator());
+ Collections.sort(excludeList, new SizeComparator());
+
+ redefine(clz, true);
+ }
+ }
+ }
+
+ /**
+ * Remove classes
+ * @param classes The classes
+ */
+ public static void removeClasses(String classes) {
+ if (isRepository()) {
+ boolean all = false;
+
+ if (classes.endsWith(".*")) {
+ classes = classes.substring(0, classes.indexOf(".*")) + "/";
+ }
+ if (classes.endsWith(".class")) {
+ classes = classes.substring(0, classes.indexOf(".class"));
+ }
+ classes = classes.replace('.', '/');
+
+ List<Class> l = new ArrayList<Class>();
+
+ for (Class c : instrumentation.getAllLoadedClasses()) {
+ String className = c.getName().replace(".", "/");
+ if (className.startsWith(classes)) {
+ l.add(c);
+ }
+ }
+
+ Class[] clz = new Class[l.size()];
+ for (int i = 0; i < l.size(); i++) {
+ clz[i] = l.get(i);
+ }
+
+ Iterator it = includeList.iterator();
+ while (it.hasNext()) {
+ String s = (String)it.next();
+
+ if (s.startsWith(classes)) {
+ it.remove();
+ }
+ }
+
+ it = visibilityTree.keySet().iterator();
+ while (it.hasNext()) {
+ String s = (String)it.next();
+
+ if (s.startsWith(classes)) {
+ it.remove();
+ }
+ }
+
+ Collections.sort(includeList, new SizeComparator());
+
+ redefine(clz, false);
+ }
+ }
+
+ /**
+ * Redefine
+ * @param clz The classes
+ * @param instrument Should the classes be instrumented ?
+ */
+ private static void redefine(Class[] clz, boolean instrument) {
+ try {
+ List<ClassDefinition> l = new ArrayList<ClassDefinition>();
+
+ if (clz != null) {
+ for (Class c : clz) {
+ byte[] buffer = null;
+ if (instrument) {
+ buffer = transformer.loadInstrumented(c.getName(), c.getClassLoader());
+ } else {
+ buffer = transformer.loadNonInstrumented(c.getName(), c.getClassLoader());
+ }
+
+ if (buffer != null) {
+ ClassDefinition cd = new ClassDefinition(c, buffer);
+ l.add(cd);
+ }
+ }
+ }
+
+ ClassDefinition[] cds = new ClassDefinition[l.size()];
+ for (int i = 0; i < l.size(); i++) {
+ cds[i] = l.get(i);
+ }
+
+ instrumentation.redefineClasses(cds);
+ } catch (Throwable t) {
+ System.err.println(t.getMessage());
+ t.printStackTrace(System.err);
+ }
+ }
+
+
+ /**
+ * The agentmain method
+ * @param args The arguments
+ * @param inst The instrumentation
+ */
+ public static void agentmain(String args, Instrumentation inst) {
+ boot(args, inst);
+ }
+
+ /**
+ * The premain method
+ * @param args The arguments
+ * @param inst The instrumentation
+ */
+ public static void premain(String args, Instrumentation inst) {
+ boot(args, inst);
+ }
+
+ /**
+ * The boot method
+ * @param args The arguments
+ * @param inst The instrumentation
+ */
+ private static void boot(String args, Instrumentation inst) {
+ parseConfiguration();
+
+ if (args != null && !args.equals("")) {
+ StringTokenizer st = new StringTokenizer(args, ",");
+ while (st.hasMoreTokens()) {
+ String s = st.nextToken();
+
+ String key = s.substring(0, s.indexOf("="));
+ String value = s.substring(s.indexOf("=") + 1);
+
+ if ("enable".equals(key)) {
+ enabled = parseBoolean(value, enabled);
+ }
+ if ("remote".equals(key)) {
+ remote = parseBoolean(value, remote);
+ }
+ if ("quite".equals(key)) {
+ quite = parseBoolean(value, quite);
+ }
+ }
+ }
+
+ if (!quite) {
+ System.out.println(Version.FULL_VERSION + " (" + System.getProperty("java.vendor") + " " +
+ System.getProperty("java.version") + ")");
+ }
+
+ if (!quite && !enabled) {
+ System.out.println("JBoss Profiler not enabled");
+ }
+
+ transformer = new Transformer();
+ instrumentation = inst;
+ instrumentation.addTransformer(transformer);
+
+ if (save) {
+ Runtime.getRuntime().addShutdownHook(new Thread() {
+ @Override
+ public void run() {
+ Profiler.stopProfiler();
+
+ for (Snapshot snapshot : Profiler.getSnapshots()) {
+ try {
+ SnapshotHelper.save(snapshot, new File(SnapshotHelper.getName(snapshot) + ".jps"));
+ } catch (Exception e) {
+ System.err.println(e.getMessage());
+ e.printStackTrace(System.err);
+ }
+ }
+
+ if (connector != null) {
+ try {
+ Method connectorStop = connector.getClass().getMethod("stop", (Class[])null);
+
+ connectorStop.invoke(connector, (Object[])null);
+
+ Method connectorDestroy = connector.getClass().getMethod("destroy", (Class[])null);
+
+ connectorDestroy.invoke(connector, (Object[])null);
+ } catch (Exception e) {
+ System.err.println(e.getMessage());
+ e.printStackTrace();
+ }
+ }
+ }
+ });
+ }
+
+ boolean remoteInit = false;
+ if (remote) {
+ try {
+ Class invokerClass = Class.forName("org.jboss.remoting.InvokerLocator");
+ Constructor invokerConstructor = invokerClass.getConstructor(String.class);
+
+ Object invoker = invokerConstructor.newInstance("socket://" + host + ":" + Integer.toString(port));
+
+ Class connectorClass = Class.forName("org.jboss.remoting.transport.Connector");
+ Constructor connectorConstructor = connectorClass.getConstructor(invokerClass);
+
+ connector = connectorConstructor.newInstance(invoker);
+
+ Method connectorCreate = connectorClass.getMethod("create", (Class[])null);
+
+ connectorCreate.invoke(connector, (Object[])null);
+
+ Class socketHandlerClass = Class.forName("org.jboss.profiler.connectors.SocketHandler");
+ Object socketHandler = socketHandlerClass.newInstance();
+
+ Class serverInvocationHandlerClass = Class.forName("org.jboss.remoting.ServerInvocationHandler");
+
+ Method connectorAddInvocationHandler = connectorClass.getMethod("addInvocationHandler",
+ new Class[] {
+ String.class,
+ serverInvocationHandlerClass
+ });
+
+ connectorAddInvocationHandler.invoke(connector,
+ new Object[] {
+ "jboss-profiler-socket",
+ socketHandler
+ });
+
+ Method connectorStart = connectorClass.getMethod("start", (Class[])null);
+
+ connectorStart.invoke(connector, (Object[])null);
+
+ remoteInit = true;
+ if (!quite) {
+ System.out.println("JBoss Profiler: Socket=" + host + ":" + Integer.toString(port));
+ }
+
+ } catch (ClassNotFoundException cnfe) {
+ // JBoss Remoting or JBoss Profiler Connectors not in classpath
+ // Assume running in application server with external communication module
+ } catch (Exception e) {
+ System.err.println(e.getMessage());
+ e.printStackTrace();
+ }
+ }
+
+ if (remote && !remoteInit && !quite) {
+ System.out.println("JBoss Profiler depends on external communication module");
+ }
+
+ if (startup) {
+ Profiler.startProfiler();
+ }
+ }
+}
Added: branches/JBossProfiler2/src/main/org/jboss/profiler/agent/ClassRepository.java
===================================================================
--- branches/JBossProfiler2/src/main/org/jboss/profiler/agent/ClassRepository.java (rev 0)
+++ branches/JBossProfiler2/src/main/org/jboss/profiler/agent/ClassRepository.java 2008-02-10 10:59:33 UTC (rev 420)
@@ -0,0 +1,130 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2007, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file 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.agent;
+
+import java.io.BufferedInputStream;
+import java.io.BufferedOutputStream;
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileOutputStream;
+import java.io.IOException;
+
+/**
+ * Class repository
+ * @author Jesper Pedersen <jep at worldleaguesports.com>
+ */
+public class ClassRepository {
+
+ /** Lock */
+ private static Object lock = new Object();
+
+ /** Repository location */
+ private static File location = new File(System.getProperty("java.io.tmpdir"),
+ "jboss-profiler.tmp");
+
+ static {
+ location.mkdirs();
+ location.deleteOnExit();
+ }
+
+ /**
+ * Load
+ * @param name The class name
+ * @param loader The class loader
+ * @return The class
+ * @exception IOException If an error occurs
+ */
+ public static byte[] load(String name, ClassLoader loader) throws IOException {
+ synchronized (lock) {
+ File file = getFile(name, loader);
+
+ if (file.exists()) {
+ byte[] buffer = new byte[(int)file.length()];
+
+ FileInputStream fis = new FileInputStream(file);
+ BufferedInputStream bis = new BufferedInputStream(fis, 16384);
+
+ bis.read(buffer);
+ bis.close();
+
+ return buffer;
+ }
+
+ return null;
+ }
+ }
+
+ /**
+ * Save
+ * @param name The class name
+ * @param loader The class loader
+ * @param clz The class
+ * @exception IOException If an error occurs
+ */
+ public static void save(String name, ClassLoader loader, byte[] clz) throws IOException {
+ synchronized (lock) {
+ File file = getFile(name, loader);
+
+ FileOutputStream fos = new FileOutputStream(file);
+ BufferedOutputStream bos = new BufferedOutputStream(fos, 16384);
+
+ bos.write(clz);
+
+ bos.flush();
+ bos.close();
+ }
+ }
+
+ /**
+ * Exists
+ * @param name The class name
+ * @param loader The class loader
+ * @return True if the class exists in the repository; otherwise false
+ */
+ public static boolean exists(String name, ClassLoader loader) {
+ synchronized (lock) {
+ File file = getFile(name, loader);
+
+ if (file.exists()) {
+ return true;
+ }
+
+ return false;
+ }
+ }
+
+ /**
+ * Get the file
+ * @param name The class name
+ * @param loader The class loader
+ * @return The file
+ */
+ private static File getFile(String name, ClassLoader loader) {
+ if (loader == null) {
+ loader = ClassLoader.getSystemClassLoader();
+ }
+ String prefix = (loader == null) ? "SYSCL_" : String.format("CL@%08X_", System.identityHashCode(loader));
+ String suffix = name.replace("/", "_");
+
+ return new File(location, prefix + suffix + ".class");
+ }
+}
Added: branches/JBossProfiler2/src/main/org/jboss/profiler/agent/ClassUtil.java
===================================================================
--- branches/JBossProfiler2/src/main/org/jboss/profiler/agent/ClassUtil.java (rev 0)
+++ branches/JBossProfiler2/src/main/org/jboss/profiler/agent/ClassUtil.java 2008-02-10 10:59:33 UTC (rev 420)
@@ -0,0 +1,588 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2007, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file 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.agent;
+
+import org.jboss.profiler.shared.ClassInfo;
+import org.jboss.profiler.shared.ClassType;
+import org.jboss.profiler.shared.Plugin;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.lang.annotation.Annotation;
+import java.lang.instrument.Instrumentation;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+
+import javax.xml.parsers.DocumentBuilder;
+import javax.xml.parsers.DocumentBuilderFactory;
+
+import org.w3c.dom.Document;
+import org.w3c.dom.Node;
+import org.w3c.dom.NodeList;
+
+/**
+ * The class utility class
+ * @author Jesper Pedersen <jep at worldleaguesports.com>
+ */
+public class ClassUtil {
+
+ /** Plugins */
+ private static List<Plugin> plugins = new ArrayList<Plugin>();
+
+ /** Web.xml map */
+ private static Map<ClassLoader, String> webMap =
+ new HashMap<ClassLoader, String>();
+
+ /** JSF map */
+ private static Map<ClassLoader, Map<Integer, List<String>>> jsfMap =
+ new HashMap<ClassLoader, Map<Integer, List<String>>>();
+
+ /**
+ * Add a plugin
+ * @param plugin The plugin
+ */
+ public static void addPlugin(Plugin plugin) {
+ plugins.add(plugin);
+ }
+
+ /**
+ * Get the classes
+ * @return The classes
+ */
+ public static List<ClassInfo> getClasses() {
+ List<ClassInfo> result = new ArrayList<ClassInfo>();
+
+ Instrumentation instrumentation = Agent.getInstrumentation();
+ if (instrumentation != null) {
+ Class[] loaded = instrumentation.getAllLoadedClasses();
+
+ Set<String> processed = new HashSet<String>();
+
+ for (Class c : loaded) {
+ if (!c.isInterface()&&
+ !c.isArray() &&
+ !c.isAnnotation() &&
+ !c.isSynthetic()) {
+ String className = c.getName().replace(".", "/");
+ if (Agent.accept(className) && !processed.contains(className)) {
+ int ct = ClassType.POJO;
+
+ if (Agent.isEJB() && isSession(c)) {
+ ct = ClassType.EJB_SESSION;
+ } else if (Agent.isEJB() && isEntity(c)) {
+ ct = ClassType.EJB_ENTITY;
+ } else if (Agent.isEJB() && isMessage(c)) {
+ ct = ClassType.EJB_MESSAGE;
+ } else if (Agent.isServlet() && isJSP(c)) {
+ ct = ClassType.JSP;
+ } else if (Agent.isServlet() && isServlet(c)) {
+ ct = ClassType.SERVLET;
+ } else if (Agent.isServlet() && isServletFilter(c)) {
+ ct = ClassType.SERVLET_FILTER;
+ } else if (Agent.isJMX() && isJMXMBean(c)) {
+ ct = ClassType.JMX_MBEAN;
+ } else if (Agent.isJSF() && isJSFConverter(c)) {
+ ct = ClassType.JSF_CONVERTER;
+ } else if (Agent.isJSF() && isJSFManagedBean(c)) {
+ ct = ClassType.JSF_MANAGED_BEAN;
+ } else if (isThrowable(c)) {
+ ct = ClassType.THROWABLE;
+ } else if (Agent.isCORBA() && isCORBAServant(c)) {
+ ct = ClassType.CORBA_SERVANT;
+ } else if (Agent.isCORBA() && isCORBAObject(c)) {
+ ct = ClassType.CORBA_OBJECT;
+ } else if (Agent.isRMI() && isRMIServer(c)) {
+ ct = ClassType.RMI_SERVER;
+ } else if (Agent.isRMI() && isRMIRemote(c)) {
+ ct = ClassType.RMI_REMOTE;
+ }
+
+ for (Plugin plugin : plugins) {
+ if (plugin.isSupported(c)) {
+ ct = plugin.getType(c);
+ }
+ }
+
+ processed.add(className);
+
+ ClassInfo ci = new ClassInfo(className, ct);
+ result.add(ci);
+ }
+ }
+ }
+ }
+
+ webMap.clear();
+ jsfMap.clear();
+
+ return result;
+ }
+
+ /**
+ * Enterprise Session Bean
+ * @param clz The class
+ * @return True if session; otherwise false
+ */
+ private static boolean isSession(Class clz) {
+ if (clz != null) {
+ Annotation[] annotations = clz.getDeclaredAnnotations();
+ for (Annotation ca : annotations) {
+ if (ca.annotationType().getName().startsWith("javax.ejb.Stateful") ||
+ ca.annotationType().getName().startsWith("javax.ejb.Stateless")) {
+ return true;
+ }
+ }
+
+ Class[] interfaces = clz.getInterfaces();
+ for (Class cint : interfaces) {
+ if (cint.getName().startsWith("javax.ejb.SessionBean")) {
+ return true;
+ }
+ }
+
+ return isSession(clz.getSuperclass());
+ }
+
+ return false;
+ }
+
+ /**
+ * Enterprise Entity Bean
+ * @param clz The class
+ * @return True if entity; otherwise false
+ */
+ private static boolean isEntity(Class clz) {
+ if (clz != null) {
+ Annotation[] annotations = clz.getDeclaredAnnotations();
+ for (Annotation ca : annotations) {
+ if (ca.annotationType().getName().startsWith("javax.persistence.Entity")) {
+ return true;
+ }
+ }
+
+ Class[] interfaces = clz.getInterfaces();
+ for (Class cint : interfaces) {
+ if (cint.getName().startsWith("javax.ejb.EntityBean")) {
+ return true;
+ }
+ }
+
+ return isEntity(clz.getSuperclass());
+ }
+
+ return false;
+ }
+
+ /**
+ * Enterprise Message Bean
+ * @param clz The class
+ * @return True if message; otherwise false
+ */
+ private static boolean isMessage(Class clz) {
+ if (clz != null) {
+ Annotation[] annotations = clz.getDeclaredAnnotations();
+ for (Annotation ca : annotations) {
+ if (ca.annotationType().getName().startsWith("javax.ejb.MessageDriven")) {
+ return true;
+ }
+ }
+
+ Class[] interfaces = clz.getInterfaces();
+ for (Class cint : interfaces) {
+ if (cint.getName().startsWith("javax.ejb.MessageDrivenBean")) {
+ return true;
+ }
+ }
+
+ return isMessage(clz.getSuperclass());
+ }
+
+ return false;
+ }
+
+ /**
+ * Servlet
+ * @param clz The class
+ * @return True if servlet; otherwise false
+ */
+ private static boolean isServlet(Class clz) {
+ if (clz != null) {
+ Class[] interfaces = clz.getInterfaces();
+ for (Class cint : interfaces) {
+ if (cint.getName().startsWith("javax.servlet.Servlet")) {
+ return true;
+ }
+ }
+
+ return isServlet(clz.getSuperclass());
+ }
+
+ return false;
+ }
+
+ /**
+ * Servlet filter
+ * @param clz The class
+ * @return True if servlet; otherwise false
+ */
+ private static boolean isServletFilter(Class clz) {
+ if (clz != null) {
+ Class[] interfaces = clz.getInterfaces();
+ for (Class cint : interfaces) {
+ if (cint.getName().startsWith("javax.servlet.Filter")) {
+ return true;
+ }
+ }
+
+ return isServletFilter(clz.getSuperclass());
+ }
+
+ return false;
+ }
+
+ /**
+ * JSP
+ * @param clz The class
+ * @return True if JSP; otherwise false
+ */
+ private static boolean isJSP(Class clz) {
+ if (clz != null) {
+ if (clz.getName().startsWith("org.apache.jsp")) {
+ return true;
+ }
+ }
+
+ return false;
+ }
+
+ /**
+ * JMX: MBean
+ * @param clz The class
+ * @return True if mbean; otherwise false
+ */
+ private static boolean isJMXMBean(Class clz) {
+ if (clz != null) {
+ Class[] interfaces = clz.getInterfaces();
+ for (Class cint : interfaces) {
+ if (cint.getName().endsWith("MBean")) {
+ return true;
+ }
+ }
+
+ return isJMXMBean(clz.getSuperclass());
+ }
+
+ return false;
+ }
+
+ /**
+ * JavaServer Faces: Converter
+ * @param clz The class
+ * @return True if converter; otherwise false
+ */
+ private static boolean isJSFConverter(Class clz) {
+ if (clz != null) {
+ loadJSFConfig(clz);
+
+ Map<Integer, List<String>> m = jsfMap.get(clz.getClassLoader());
+ if (m != null) {
+ List<String> result = m.get(Integer.valueOf(ClassType.JSF_CONVERTER));
+ if (result != null) {
+ for (String cn : result) {
+ if (cn.equals(clz.getName())) {
+ return true;
+ }
+ }
+ }
+ }
+ }
+
+ return false;
+ }
+
+ /**
+ * JavaServer Faces: Managed bean
+ * @param clz The class
+ * @return True if managed bean; otherwise false
+ */
+ private static boolean isJSFManagedBean(Class clz) {
+ if (clz != null) {
+ loadJSFConfig(clz);
+
+ Map<Integer, List<String>> m = jsfMap.get(clz.getClassLoader());
+ if (m != null) {
+ List<String> result = m.get(Integer.valueOf(ClassType.JSF_MANAGED_BEAN));
+ if (result != null) {
+ for (String cn : result) {
+ if (cn.equals(clz.getName())) {
+ return true;
+ }
+ }
+ }
+ }
+ }
+
+ return false;
+ }
+
+ /**
+ * Load web.xml
+ * @param clz The class
+ */
+ private static void loadWebXml(Class clz) {
+ InputStream web = null;
+ try {
+ ClassLoader cl = clz.getClassLoader();
+
+ if (webMap.containsKey(cl)) {
+ return;
+ }
+
+ web = cl.getResourceAsStream("WEB-INF/web.xml");
+
+ while (web == null && cl != null) {
+ cl = cl.getParent();
+ if (cl != null) {
+ web = cl.getResourceAsStream("WEB-INF/web.xml");
+ }
+ }
+
+ if (web != null) {
+ DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
+ DocumentBuilder db = dbf.newDocumentBuilder();
+ Document wd = db.parse(web);
+
+ String path = null;
+
+ NodeList nl = wd.getElementsByTagName("context-param");
+
+ for (int i = 0; path == null && i < nl.getLength(); i++) {
+ Node n = nl.item(i);
+ boolean insert = false;
+
+ NodeList children = n.getChildNodes();
+ for (int j = 0; j < children.getLength(); j++) {
+ Node child = children.item(j);
+ if ("param-name".equals(child.getNodeName()) &&
+ "javax.faces.CONFIG_FILES".equals(child.getTextContent())) {
+ insert = true;
+ } else if (insert && "param-value".equals(child.getNodeName())) {
+ path = child.getTextContent();
+ if (path.startsWith("/")) {
+ path = path.substring(1);
+ }
+ insert = false;
+ }
+ }
+ }
+
+ webMap.put(clz.getClassLoader(), path);
+ }
+
+ } catch (Exception e) {
+ //
+ } finally {
+ if (web != null) {
+ try {
+ web.close();
+ } catch (IOException ioe) {
+ //
+ }
+ }
+ }
+ }
+
+ /**
+ * Load JSF configuration
+ * @param clz The class
+ */
+ private static void loadJSFConfig(Class clz) {
+ InputStream jsf = null;
+ try {
+ ClassLoader cl = clz.getClassLoader();
+
+ if (jsfMap.containsKey(cl)) {
+ return;
+ }
+
+ loadWebXml(clz);
+
+ String path = webMap.get(cl);
+
+ if (path == null || path.trim().equals("")) {
+ return;
+ }
+
+ jsf = cl.getResourceAsStream(path);
+
+ while (jsf == null && cl != null) {
+ cl = cl.getParent();
+ if (cl != null) {
+ jsf = cl.getResourceAsStream(path);
+ }
+ }
+
+ if (jsf != null) {
+ DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
+ DocumentBuilder db = dbf.newDocumentBuilder();
+ Document jd = db.parse(jsf);
+
+ Map<Integer, List<String>> result = new HashMap<Integer, List<String>>();
+
+ List<String> l = new ArrayList<String>();
+
+ NodeList nl = jd.getElementsByTagName("converter-class");
+
+ for (int i = 0; i < nl.getLength(); i++) {
+ Node n = nl.item(i);
+ l.add(n.getTextContent());
+ }
+
+ if (!l.isEmpty()) {
+ result.put(Integer.valueOf(ClassType.JSF_CONVERTER), l);
+ }
+
+ l = new ArrayList<String>();
+
+ nl = jd.getElementsByTagName("managed-bean-class");
+
+ for (int i = 0; i < nl.getLength(); i++) {
+ Node n = nl.item(i);
+ l.add(n.getTextContent());
+ }
+
+ if (!l.isEmpty()) {
+ result.put(Integer.valueOf(ClassType.JSF_MANAGED_BEAN), l);
+ }
+
+ jsfMap.put(clz.getClassLoader(), result);
+ }
+
+ } catch (Exception e) {
+ //
+ } finally {
+ if (jsf != null) {
+ try {
+ jsf.close();
+ } catch (IOException ioe) {
+ //
+ }
+ }
+ }
+ }
+
+ /**
+ * Throwable
+ * @param clz The class
+ * @return True if throwable; otherwise false
+ */
+ private static boolean isThrowable(Class clz) {
+ if (clz != null) {
+ if (clz.getName().startsWith("java.lang.Throwable")) {
+ return true;
+ }
+
+ return isThrowable(clz.getSuperclass());
+ }
+
+ return false;
+ }
+
+ /**
+ * CORBA: Object
+ * @param clz The class
+ * @return True if CORBA object; otherwise false
+ */
+ private static boolean isCORBAObject(Class clz) {
+ if (clz != null) {
+ Class[] interfaces = clz.getInterfaces();
+ for (Class cint : interfaces) {
+ if (cint.getName().startsWith("org.omg.CORBA.Object")) {
+ return true;
+ }
+ }
+
+ return isCORBAObject(clz.getSuperclass());
+ }
+
+ return false;
+ }
+
+ /**
+ * CORBA: Servant
+ * @param clz The class
+ * @return True if CORBA servant; otherwise false
+ */
+ private static boolean isCORBAServant(Class clz) {
+ if (clz != null) {
+ if (clz.getName().startsWith("org.omg.CORBA.portable.Servant")) {
+ return true;
+ }
+
+ return isCORBAServant(clz.getSuperclass());
+ }
+
+ return false;
+ }
+
+ /**
+ * RMI: Server
+ * @param clz The class
+ * @return True if server; otherwise false
+ */
+ private static boolean isRMIServer(Class clz) {
+ if (clz != null) {
+ if (clz.getName().startsWith("java.rmi.server.RemoteServer")) {
+ return true;
+ }
+
+ return isRMIServer(clz.getSuperclass());
+ }
+
+ return false;
+ }
+
+ /**
+ * RMI: Remote
+ * @param clz The class
+ * @return True if remote; otherwise false
+ */
+ private static boolean isRMIRemote(Class clz) {
+ if (clz != null) {
+ Class[] interfaces = clz.getInterfaces();
+ for (Class cint : interfaces) {
+ if (cint.getName().startsWith("java.rmi.Remote")) {
+ return true;
+ }
+ }
+
+ return isRMIRemote(clz.getSuperclass());
+ }
+
+ return false;
+ }
+}
Added: branches/JBossProfiler2/src/main/org/jboss/profiler/agent/ExceptionInfo.java
===================================================================
--- branches/JBossProfiler2/src/main/org/jboss/profiler/agent/ExceptionInfo.java (rev 0)
+++ branches/JBossProfiler2/src/main/org/jboss/profiler/agent/ExceptionInfo.java 2008-02-10 10:59:33 UTC (rev 420)
@@ -0,0 +1,72 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2007, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file 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.agent;
+
+/**
+ * Represents an exception
+ * @author Jesper Pedersen <jep at worldleaguesports.com>
+ */
+public class ExceptionInfo {
+
+ /** The type */
+ private String type;
+
+ /**
+ * Constructor
+ * @param type The type
+ */
+ public ExceptionInfo(String type) {
+ this.type = type;
+ }
+
+ /**
+ * Get the type
+ * @return The type
+ */
+ public String getType() {
+ return type;
+ }
+
+ /**
+ * Equals
+ * @param other The other object
+ * @return True if equal; otherwise false
+ */
+ @Override
+ public boolean equals(Object other) {
+ if (!(other instanceof ExceptionInfo)) {
+ return false;
+ }
+
+ ExceptionInfo ei = (ExceptionInfo)other;
+ return this.type.equals(ei.getType());
+ }
+
+ /**
+ * Hash code
+ * @return The hash code
+ */
+ @Override
+ public int hashCode() {
+ return type.hashCode();
+ }
+}
Added: branches/JBossProfiler2/src/main/org/jboss/profiler/agent/ProfiledClass.java
===================================================================
--- branches/JBossProfiler2/src/main/org/jboss/profiler/agent/ProfiledClass.java (rev 0)
+++ branches/JBossProfiler2/src/main/org/jboss/profiler/agent/ProfiledClass.java 2008-02-10 10:59:33 UTC (rev 420)
@@ -0,0 +1,96 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2007, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file 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.agent;
+
+import org.jboss.profiler.shared.Visibility;
+
+import org.objectweb.asm.ClassAdapter;
+import org.objectweb.asm.ClassVisitor;
+import org.objectweb.asm.MethodVisitor;
+import org.objectweb.asm.Opcodes;
+
+/**
+ * Wraps a profiled class
+ * @author Jesper Pedersen <jep at worldleaguesports.com>
+ */
+public class ProfiledClass extends ClassAdapter {
+ /** The class name */
+ private String className;
+
+ /**
+ * Constructor
+ * @param visitor The class visitor
+ * @param className The class name
+ */
+ public ProfiledClass(ClassVisitor visitor, String className) {
+ super(visitor);
+ this.className = className;
+ }
+
+ /**
+ * Visit method
+ * @param access The access
+ * @param name The name
+ * @param descriptor The descriptor
+ * @param signature The signature
+ * @param exceptions The exceptions
+ * @return The method visitor
+ */
+ public MethodVisitor visitMethod(int access,
+ String name,
+ String descriptor,
+ String signature,
+ String[] exceptions) {
+
+ MethodVisitor mv = super.visitMethod(access,
+ name,
+ descriptor,
+ signature,
+ exceptions);
+
+ boolean include = true;
+
+ if ((access & Opcodes.ACC_PRIVATE) != 0) {
+ Visibility v = Agent.getVisibility(className);
+ if (v == Visibility.PROTECTED ||
+ v == Visibility.PUBLIC) {
+ include = false;
+ }
+ } else if ((access & Opcodes.ACC_PROTECTED) != 0) {
+ Visibility v = Agent.getVisibility(className);
+ if (v == Visibility.PUBLIC) {
+ include = false;
+ }
+ }
+ // Opcodes.ACC_PUBLIC -- no need to check for method visibility
+
+ if (include) {
+ if (descriptor != null) {
+ return new ProfiledMethod(mv, className, name + descriptor);
+ } else {
+ return new ProfiledMethod(mv, className, name);
+ }
+ }
+
+ return mv;
+ }
+}
Added: branches/JBossProfiler2/src/main/org/jboss/profiler/agent/ProfiledMethod.java
===================================================================
--- branches/JBossProfiler2/src/main/org/jboss/profiler/agent/ProfiledMethod.java (rev 0)
+++ branches/JBossProfiler2/src/main/org/jboss/profiler/agent/ProfiledMethod.java 2008-02-10 10:59:33 UTC (rev 420)
@@ -0,0 +1,257 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2007, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file 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.agent;
+
+import org.objectweb.asm.Label;
+import org.objectweb.asm.MethodAdapter;
+import org.objectweb.asm.MethodVisitor;
+import org.objectweb.asm.Opcodes;
+
+/**
+ * Wraps a profiled method
+ * @author Jesper Pedersen <jep at worldleaguesports.com>
+ */
+public class ProfiledMethod extends MethodAdapter {
+
+ /** The class name */
+ private String className;
+
+ /** The method name */
+ private String methodName;
+
+ /** CINIT call */
+ private boolean clinit = false;
+
+ /** INIT call */
+ private boolean init = false;
+
+ /**
+ * Constructor
+ * @param visitor The visitor
+ * @param className The class name
+ * @param methodName The method name
+ */
+ public ProfiledMethod(MethodVisitor visitor,
+ String className,
+ String methodName) {
+ super(visitor);
+ this.className = className;
+ this.methodName = methodName;
+
+ if ("<clinit>".equals(methodName)) {
+ this.clinit = true;
+ } else if (methodName.startsWith("<init>")) {
+ this.init = true;
+ }
+ }
+
+ /**
+ * Visit: Code
+ */
+ public void visitCode() {
+ if (clinit) {
+ super.visitCode();
+ return;
+ }
+
+ if (init) {
+ this.visitLdcInsn(className);
+ this.visitMethodInsn(Opcodes.INVOKESTATIC,
+ Profiler.CLASSNAME,
+ "allocation",
+ "(Ljava/lang/String;)V");
+ }
+
+ this.visitLdcInsn(className);
+ this.visitLdcInsn(methodName);
+ this.visitMethodInsn(Opcodes.INVOKESTATIC,
+ Profiler.CLASSNAME,
+ "start",
+ "(Ljava/lang/String;Ljava/lang/String;)V");
+
+ super.visitCode();
+ }
+
+ /**
+ * Visit: Insn
+ * @param inst The instruction
+ */
+ public void visitInsn(int inst) {
+ if (clinit) {
+ super.visitInsn(inst);
+ return;
+ }
+
+ switch (inst) {
+ case Opcodes.ARETURN:
+ case Opcodes.DRETURN:
+ case Opcodes.FRETURN:
+ case Opcodes.IRETURN:
+ case Opcodes.LRETURN:
+ case Opcodes.RETURN:
+ case Opcodes.ATHROW:
+
+ this.visitLdcInsn(className);
+ this.visitLdcInsn(methodName);
+
+ this.visitMethodInsn(Opcodes.INVOKESTATIC,
+ Profiler.CLASSNAME,
+ "end",
+ "(Ljava/lang/String;Ljava/lang/String;)V");
+ break;
+
+ default:
+ break;
+ }
+
+ if (Opcodes.MONITORENTER == inst) {
+ this.visitLdcInsn(className);
+ this.visitLdcInsn(methodName);
+
+ this.visitMethodInsn(Opcodes.INVOKESTATIC,
+ Profiler.CLASSNAME,
+ "beginWait",
+ "(Ljava/lang/String;Ljava/lang/String;)V");
+
+ super.visitInsn(inst);
+
+ this.visitLdcInsn(className);
+ this.visitLdcInsn(methodName);
+
+ this.visitMethodInsn(Opcodes.INVOKESTATIC,
+ Profiler.CLASSNAME,
+ "endWait",
+ "(Ljava/lang/String;Ljava/lang/String;)V");
+ } else {
+ super.visitInsn(inst);
+ }
+ }
+
+ /**
+ * Visit: Method inst
+ * @param opcode The opcode
+ * @param owner The owner
+ * @param name The name
+ * @param desc The description
+ */
+ @Override
+ public void visitMethodInsn(int opcode, String owner, String name, String desc) {
+ if (isWaitInsn(opcode, owner, name, desc)) {
+
+ this.visitLdcInsn(className);
+ this.visitLdcInsn(methodName);
+
+ this.visitMethodInsn(Opcodes.INVOKESTATIC,
+ Profiler.CLASSNAME,
+ "beginWait",
+ "(Ljava/lang/String;Ljava/lang/String;)V");
+
+ super.visitMethodInsn(opcode, owner, name, desc);
+
+ this.visitLdcInsn(className);
+ this.visitLdcInsn(methodName);
+
+ this.visitMethodInsn(Opcodes.INVOKESTATIC,
+ Profiler.CLASSNAME,
+ "endWait",
+ "(Ljava/lang/String;Ljava/lang/String;)V");
+ } else {
+ super.visitMethodInsn(opcode, owner, name, desc);
+ }
+ }
+
+ /**
+ * Visit: Try / catch
+ * @param start The start label
+ * @param end The end label
+ * @param handler The handler label
+ * @param type The type
+ */
+ @Override
+ public void visitTryCatchBlock(Label start, Label end, Label handler, String type) {
+ super.visitTryCatchBlock(start, end, handler, type);
+
+ if (type != null && !clinit) {
+ handler.info = new ExceptionInfo(type);
+ }
+ }
+
+ /**
+ * Visit: Label
+ * @param label The label
+ */
+ @Override
+ public void visitLabel(Label label) {
+ super.visitLabel(label);
+
+ if (label.info instanceof ExceptionInfo) {
+ this.visitLdcInsn(className);
+ this.visitLdcInsn(methodName);
+ this.visitLdcInsn(((ExceptionInfo)label.info).getType());
+
+ this.visitMethodInsn(Opcodes.INVOKESTATIC,
+ Profiler.CLASSNAME,
+ "unwind",
+ "(Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;)V");
+ }
+ }
+
+ /**
+ * Method: Waiting
+ * @param opcode The opcode
+ * @param owner The owner
+ * @param name The name
+ * @param desc The description
+ */
+ private static boolean isWaitInsn(int opcode, String owner, String name, String desc) {
+ boolean isWait = (opcode == Opcodes.INVOKEVIRTUAL
+ && "java/lang/Object".equals(owner)
+ && "wait".equals(name)
+ && ("()V".equals(desc) || "(J)V".equals(desc) || "(JI)V".equals(desc)));
+ if (isWait) {
+ return true;
+ }
+
+ isWait = (opcode == Opcodes.INVOKEVIRTUAL
+ && "java/lang/Thread".equals(owner)
+ && "join".equals(name)
+ && ("()V".equals(desc) || "(J)V".equals(desc) || "(JI)V".equals(desc)));
+ if (isWait) {
+ return true;
+ }
+
+ isWait = (opcode == Opcodes.INVOKESTATIC
+ && "java/lang/Thread".equals(owner)
+ && "sleep".equals(name)
+ && ("(J)V".equals(desc) || "(JI)V".equals(desc)));
+ if (isWait) {
+ return true;
+ }
+
+ isWait = (opcode == Opcodes.INVOKESTATIC
+ && "java/lang/Thread".equals(owner)
+ && "yield".equals(name)
+ && "()V".equals(desc));
+
+ return isWait;
+ }
+}
Added: branches/JBossProfiler2/src/main/org/jboss/profiler/agent/Profiler.java
===================================================================
--- branches/JBossProfiler2/src/main/org/jboss/profiler/agent/Profiler.java (rev 0)
+++ branches/JBossProfiler2/src/main/org/jboss/profiler/agent/Profiler.java 2008-02-10 10:59:33 UTC (rev 420)
@@ -0,0 +1,502 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2007, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file 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.agent;
+
+import org.jboss.profiler.shared.AllocationInfo;
+import org.jboss.profiler.shared.ClassInfo;
+import org.jboss.profiler.shared.FrameHelper;
+import org.jboss.profiler.shared.FrameInfo;
+import org.jboss.profiler.shared.MethodInfo;
+import org.jboss.profiler.shared.Snapshot;
+import org.jboss.profiler.shared.SnapshotHelper;
+import org.jboss.profiler.shared.ThreadHelper;
+import org.jboss.profiler.shared.ThreadInfo;
+
+import java.io.File;
+import java.io.IOException;
+import java.text.DecimalFormat;
+import java.text.SimpleDateFormat;
+import java.util.ArrayList;
+import java.util.Calendar;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.Comparator;
+import java.util.Date;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+/**
+ * The profiler
+ * @author Jesper Pedersen <jep at worldleaguesports.com>
+ */
+public class Profiler {
+
+ /** The class name */
+ public static final String CLASSNAME = "org/jboss/profiler/agent/Profiler";
+
+ /** The threads map */
+ private static Map<Long, ThreadInfo> threadMap;
+
+ /** The active frame for all threads */
+ private static Map<Long, FrameInfo> activeFrameMap;
+
+ /** The frame number map */
+ private static Map<Long, Long> frameNumberMap;
+
+ /** The allocation map */
+ private static Map<String, AllocationInfo> allocationMap;
+
+ /** The from date */
+ private static Date from;
+
+ /** The current top level directory */
+ private static File root;
+
+ /** The snapshots */
+ private static List<Snapshot> snapshots = new ArrayList<Snapshot>();
+
+ /** Lock */
+ private static Object lock = new Object();
+
+ /** Running */
+ private static boolean running = false;
+
+ /**
+ * Constructor
+ */
+ private Profiler() {
+ }
+
+ /**
+ * Start the profiler
+ */
+ public static void startProfiler() {
+ synchronized (lock) {
+ threadMap = new HashMap<Long, ThreadInfo>();
+ activeFrameMap = new HashMap<Long, FrameInfo>();
+ allocationMap = new HashMap<String, AllocationInfo>();
+ from = new Date();
+
+ if (!Agent.isMemoryStore()) {
+ frameNumberMap = new HashMap<Long, Long>();
+
+ Calendar c = Calendar.getInstance();
+ DecimalFormat df = new DecimalFormat("00");
+ DecimalFormat df3 = new DecimalFormat("000");
+ StringBuffer sb = new StringBuffer();
+
+ c.setTime(from);
+
+ sb = sb.append(Agent.getFileStoreLocation());
+
+ sb = sb.append(Integer.toString(c.get(Calendar.YEAR)));
+ sb = sb.append(df.format(c.get(Calendar.MONTH) + 1));
+ sb = sb.append(df.format(c.get(Calendar.DATE)));
+ sb = sb.append(df.format(c.get(Calendar.HOUR_OF_DAY)));
+ sb = sb.append(df.format(c.get(Calendar.MINUTE)));
+ sb = sb.append(df.format(c.get(Calendar.SECOND)));
+ sb = sb.append(df3.format(c.get(Calendar.MILLISECOND)));
+
+ sb = sb.append(File.separator);
+
+ root = new File(sb.toString());
+ root.mkdirs();
+ }
+
+ running = true;
+ }
+ }
+
+ /**
+ * Stop the profiler
+ */
+ public static void stopProfiler() {
+ synchronized (lock) {
+ if (running) {
+ for (Long threadId: threadMap.keySet()) {
+ ThreadInfo ti = threadMap.get(threadId);
+
+ if (ti.getFrames().size() > 0) {
+ FrameInfo fi = ti.getRecentFrame();
+ fi.close();
+ }
+ }
+
+ Date to = new Date();
+ List<ClassInfo> classList = ClassUtil.getClasses();
+
+ if (Agent.isMemoryStore()) {
+ Snapshot snapshot = new Snapshot(new ArrayList<ThreadInfo>(threadMap.values()),
+ new ArrayList<AllocationInfo>(allocationMap.values()),
+ classList,
+ from,
+ to);
+ snapshots.add(snapshot);
+ } else {
+ try {
+ Snapshot snapshot = new Snapshot(null,
+ new ArrayList<AllocationInfo>(allocationMap.values()),
+ classList,
+ from,
+ to);
+ SnapshotHelper.save(snapshot, new File(root, "data"));
+ } catch (Exception e) {
+ System.err.println(e.getMessage());
+ e.printStackTrace(System.err);
+ }
+ }
+ }
+
+ running = false;
+ }
+ }
+
+ /**
+ * Take a snapshot
+ * @return The snapshot
+ */
+ public static Snapshot snapshot() {
+ synchronized (lock) {
+ Snapshot snapshot = null;
+ boolean wasRunning = false;
+
+ if (running) {
+ stopProfiler();
+ wasRunning = true;
+ }
+
+ if (snapshots.size() > 0) {
+ snapshot = snapshots.get(snapshots.size() - 1);
+ }
+
+ if (wasRunning) {
+ startProfiler();
+ }
+ return snapshot;
+ }
+ }
+
+ /**
+ * Get all snapshots
+ * @return The snapshots
+ */
+ public static List<Snapshot> getSnapshots() {
+ return snapshots;
+ }
+
+ /**
+ * Get a snapshot
+ * @param index The snapshot index
+ * @return The snapshot
+ */
+ public static Snapshot getSnapshot(int index) {
+ Snapshot result = null;
+ if (index >= 1 && index <= snapshots.size()) {
+ result = snapshots.get(index - 1);
+ }
+ return result;
+ }
+
+ /**
+ * List snapshots
+ * @return The snapshots
+ */
+ public static String[] listSnapshots() {
+ SimpleDateFormat dateFormat = new SimpleDateFormat("dd MMMMM yyyy HH:mm:ss:SSS");
+ String[] result = new String[snapshots.size()];
+ for (int i = 0; i < snapshots.size(); i++) {
+ Snapshot s = snapshots.get(i);
+ result[i] = Integer.toString(i + 1) + ": " +
+ dateFormat.format(s.getFrom()) + " -> " + dateFormat.format(s.getTo());
+ }
+ return result;
+ }
+
+ /**
+ * Clear snapshots
+ */
+ public static void clearSnapshots() {
+ synchronized (lock) {
+ snapshots = new ArrayList<Snapshot>();
+ }
+ }
+
+ /**
+ * Garbage collection
+ */
+ public static void garbageCollection() {
+ synchronized (lock) {
+ System.gc();
+ }
+ }
+
+ /**
+ * Is the profiler running ?
+ * @return True if running; otherwise false
+ */
+ public static boolean isRunning() {
+ synchronized (lock) {
+ return running;
+ }
+ }
+
+ /**
+ * Register start time for a method
+ * @param className The class name
+ * @param methodName The method name
+ */
+ public static void start(String className, String methodName) {
+ long start = System.nanoTime();
+
+ if (!Agent.isEnabled() || !Agent.isCPU() || !running) {
+ return;
+ }
+
+ synchronized (lock) {
+ Thread thread = Thread.currentThread();
+ long threadId = thread.getId();
+
+ MethodInfo mi = new MethodInfo(methodName, className);
+
+ FrameInfo parent = (FrameInfo)activeFrameMap.get(threadId);
+ FrameInfo fi = null;
+
+ if (parent != null) {
+ fi = (FrameInfo)parent.getChild(mi);
+
+ if (fi == null) {
+ fi = new FrameInfo(mi, parent);
+ }
+ } else {
+ fi = new FrameInfo(mi, null);
+ ThreadInfo ti = threadMap.get(threadId);
+ if (ti == null) {
+ List<String> groups = new ArrayList<String>();
+
+ ThreadGroup tg = thread.getThreadGroup();
+ while (tg != null) {
+ groups.add(tg.getName());
+ tg = tg.getParent();
+ }
+
+ ti = new ThreadInfo(threadId, thread.getName(), thread.getPriority(), thread.isDaemon(), groups);
+ threadMap.put(threadId, ti);
+
+ if (!Agent.isMemoryStore()) {
+ File directory = new File(root, Long.toString(threadId));
+
+ try {
+ ThreadHelper.save(ti, directory);
+ } catch (Exception e) {
+ System.err.println(e.getMessage());
+ e.printStackTrace(System.err);
+ }
+ }
+ }
+ ti.add(fi);
+ }
+
+ activeFrameMap.put(threadId, fi);
+
+ fi.setOverhead(System.nanoTime() - start);
+ fi.setBeginTime(System.nanoTime());
+ }
+ }
+
+ /**
+ * Register end time for a method
+ * @param className The class name
+ * @param methodName The method name
+ */
+ public static void end(String className, String methodName) {
+ long start = System.nanoTime();
+
+ if (!Agent.isEnabled() || !Agent.isCPU() || !running) {
+ return;
+ }
+
+ synchronized (lock) {
+ long threadId = Thread.currentThread().getId();
+ FrameInfo fi = findFrame(threadId, className, methodName);
+
+ if (fi == null) {
+ return;
+ }
+
+ fi.setOverhead(System.nanoTime() - start);
+ fi.setEndTime(System.nanoTime());
+
+ if (fi.getParent() != null) {
+ activeFrameMap.put(threadId, fi.getParent());
+ } else {
+ activeFrameMap.put(threadId, null);
+
+ if (!Agent.isMemoryStore()) {
+ Long l = frameNumberMap.get(threadId);
+ if (l == null) {
+ l = Long.valueOf(0);
+ }
+
+ File directory = new File(root, Long.toString(threadId));
+
+ try {
+ FrameHelper.save(fi, l, directory);
+
+ ThreadInfo ti = threadMap.get(threadId);
+ ti.getFrames().clear();
+
+ frameNumberMap.put(threadId, Long.valueOf(l.longValue() + 1));
+ } catch (Exception e) {
+ System.err.println(e.getMessage());
+ e.printStackTrace(System.err);
+ }
+ }
+ }
+ }
+ }
+
+ /**
+ * Register start wait time for a method
+ * @param className The class name
+ * @param methodName The method name
+ */
+ public static void beginWait(String className, String methodName) {
+ long start = System.nanoTime();
+
+ if (!Agent.isEnabled() || !Agent.isCPU() || !running) {
+ return;
+ }
+
+ synchronized (lock) {
+ FrameInfo fi = findFrame(Thread.currentThread().getId(), className, methodName);
+
+ if (fi == null) {
+ return;
+ }
+
+ fi.setOverhead(System.nanoTime() - start);
+ fi.setBeginWaitTime(System.nanoTime());
+ }
+ }
+
+ /**
+ * Register end wait time for a method
+ * @param className The class name
+ * @param methodName The method name
+ */
+ public static void endWait(String className, String methodName) {
+ long start = System.nanoTime();
+
+ if (!Agent.isEnabled() || !Agent.isCPU() || !running) {
+ return;
+ }
+
+ synchronized (lock) {
+ FrameInfo fi = findFrame(Thread.currentThread().getId(), className, methodName);
+
+ if (fi == null) {
+ return;
+ }
+
+ fi.setOverhead(System.nanoTime() - start);
+ fi.setEndWaitTime(System.nanoTime());
+ }
+ }
+
+ /**
+ * Unwind exception
+ * @param className The class name
+ * @param methodName The method name
+ * @param exception The exception
+ */
+ public static void unwind(String className, String methodName, String exception) {
+ if (!Agent.isEnabled() || !Agent.isCPU() || !running) {
+ return;
+ }
+
+ synchronized (lock) {
+ long threadId = Thread.currentThread().getId();
+ FrameInfo fi = findFrame(threadId, className, methodName);
+
+ if (fi == null) {
+ return;
+ }
+
+ activeFrameMap.put(threadId, fi);
+ }
+ }
+
+ /**
+ * Class allocation
+ * @param className The class being allocated
+ */
+ public static void allocation(String className) {
+ if (!Agent.isEnabled() || !Agent.isMemory() || !running) {
+ return;
+ }
+
+ synchronized (lock) {
+ long threadId = Thread.currentThread().getId();
+ FrameInfo fi = (FrameInfo)activeFrameMap.get(threadId);
+
+ // Constructor delegation
+ if (fi != null && fi.getMethod().getClassName().equals(className)
+ && "<init>".equals(fi.getMethod().getMethodName())) {
+ return;
+ }
+
+ AllocationInfo ai = allocationMap.get(className);
+
+ if (ai == null) {
+ ai = new AllocationInfo(className);
+ allocationMap.put(className, ai);
+ }
+
+ ai.increase();
+ }
+ }
+
+ /**
+ * Find the frame which contains the call
+ * @param threadId The thread id
+ * @param className The class name
+ * @param methodName The method name
+ * @return The frame; null if not found
+ */
+ private static final FrameInfo findFrame(long threadId, String className, String methodName) {
+ FrameInfo fi = (FrameInfo)activeFrameMap.get(threadId);
+
+ while (fi != null) {
+ if (fi.getMethod().getClassName().equals(className)
+ && fi.getMethod().getMethodName().equals(methodName)) {
+ // Found the first frame
+ return fi;
+ } else {
+ fi.setEndTime(System.nanoTime());
+ fi = fi.getParent();
+ }
+ }
+
+ return fi;
+ }
+}
Added: branches/JBossProfiler2/src/main/org/jboss/profiler/agent/SizeComparator.java
===================================================================
--- branches/JBossProfiler2/src/main/org/jboss/profiler/agent/SizeComparator.java (rev 0)
+++ branches/JBossProfiler2/src/main/org/jboss/profiler/agent/SizeComparator.java 2008-02-10 10:59:33 UTC (rev 420)
@@ -0,0 +1,47 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2007, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file 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.agent;
+
+import java.util.Comparator;
+
+/**
+ * Size comparator
+ * @author Jesper Pedersen <jep at worldleaguesports.com>
+ */
+public class SizeComparator implements Comparator<String> {
+
+ /**
+ * Compare two objects
+ * @param sa String
+ * @param sb String
+ * @return Positive if sb greater than sa; zero if equal; otherwise negative
+ */
+ public int compare(String sa, String sb) {
+ if (sa.length() < sb.length()) {
+ return 1;
+ } else if (sa.length() == sb.length()) {
+ return sa.compareTo(sb);
+ } else {
+ return -1;
+ }
+ }
+}
Added: branches/JBossProfiler2/src/main/org/jboss/profiler/agent/Transformer.java
===================================================================
--- branches/JBossProfiler2/src/main/org/jboss/profiler/agent/Transformer.java (rev 0)
+++ branches/JBossProfiler2/src/main/org/jboss/profiler/agent/Transformer.java 2008-02-10 10:59:33 UTC (rev 420)
@@ -0,0 +1,165 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2007, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file 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.agent;
+
+import java.lang.instrument.ClassFileTransformer;
+import java.lang.instrument.IllegalClassFormatException;
+import java.io.BufferedInputStream;
+import java.io.InputStream;
+import java.io.IOException;
+import java.security.ProtectionDomain;
+
+import org.objectweb.asm.ClassAdapter;
+import org.objectweb.asm.ClassReader;
+import org.objectweb.asm.ClassWriter;
+
+/**
+ * Implements the transformer
+ * @author Jesper Pedersen <jep at worldleaguesports.com>
+ */
+public class Transformer implements ClassFileTransformer {
+
+ /**
+ * The transform method
+ * @param loader The class loader
+ * @param className The class name
+ * @param classBeingRedefined The class being redefined
+ * @param protectionDomain The protection domain
+ * @param classfileBuffer The class buffer
+ * @return The transformed class; null if no transformation have been done
+ * @exception IllegalClassFormatException If the class can't be transformed
+ */
+ public byte[] transform(ClassLoader loader,
+ String className,
+ Class<?> classBeingRedefined,
+ ProtectionDomain protectionDomain,
+ byte[] classfileBuffer) throws IllegalClassFormatException {
+
+ byte[] result = null;
+
+ if (Agent.isEnabled() && Agent.accept(className)) {
+ try {
+ if (Agent.isRepository() && !ClassRepository.exists(className, loader)) {
+ ClassRepository.save(className, loader, classfileBuffer);
+ }
+
+ byte[] buffer = null;
+ if (classBeingRedefined != null) {
+ buffer = loadNonInstrumented(className, loader);
+ }
+ if (buffer == null) {
+ buffer = classfileBuffer;
+ }
+
+ ClassReader reader = new ClassReader(buffer);
+ ClassWriter writer = new ClassWriter(ClassWriter.COMPUTE_MAXS);
+ ClassAdapter adapter = new ProfiledClass(writer, className);
+ reader.accept(adapter, ClassReader.SKIP_DEBUG);
+ result = writer.toByteArray();
+ } catch (Throwable t) {
+ IllegalClassFormatException ice = new IllegalClassFormatException(t.getMessage());
+ ice.initCause(t);
+ throw ice;
+ }
+ } else if (classBeingRedefined != null) {
+ try {
+ result = loadNonInstrumented(className, loader);
+ } catch (Throwable t) {
+ IllegalClassFormatException ice = new IllegalClassFormatException(t.getMessage());
+ ice.initCause(t);
+ throw ice;
+ }
+ }
+ if (Agent.isRepository() &&
+ className.indexOf("$Proxy") != -1 &&
+ !ClassRepository.exists(className, loader)) {
+ try {
+ // Create backup of all proxy classes regardless of policy
+ ClassRepository.save(className, loader, classfileBuffer);
+ } catch (Throwable t) {
+ //
+ }
+ }
+
+ return result;
+ }
+
+ /**
+ * Load instrumented class
+ * @param className The class name
+ * @param loader The class loader
+ * @return The bytes
+ * @exception IOException If an error occurs
+ */
+ public byte[] loadInstrumented(String className, ClassLoader loader) throws IOException {
+ byte[] clz = loadNonInstrumented(className, loader);
+
+ ClassReader reader = new ClassReader(clz);
+ ClassWriter writer = new ClassWriter(ClassWriter.COMPUTE_MAXS);
+ ClassAdapter adapter = new ProfiledClass(writer, className);
+ reader.accept(adapter, ClassReader.SKIP_DEBUG);
+
+ return writer.toByteArray();
+ }
+
+ /**
+ * Load non instrumented class
+ * @param className The class name
+ * @param loader The class loader
+ * @return The bytes
+ * @exception IOException If an error occurs
+ */
+ public byte[] loadNonInstrumented(String className, ClassLoader loader) throws IOException {
+ byte[] clz = null;
+ className = className.replace(".", "/");
+
+ if (Agent.isRepository() && ClassRepository.exists(className, loader)) {
+ clz = ClassRepository.load(className, loader);
+ } else if (loader != null) {
+ InputStream is = null;
+ try {
+ is = loader.getResourceAsStream(className + ".class");
+
+ if (is != null) {
+ BufferedInputStream bis = new BufferedInputStream(is);
+ clz = new byte[bis.available()];
+ int n = bis.read(clz);
+ }
+
+ } finally {
+ if (is != null) {
+ try {
+ is.close();
+ } catch (IOException ioe) {
+ //
+ }
+ }
+ }
+
+ if (Agent.isRepository() && !ClassRepository.exists(className, loader) && clz != null) {
+ ClassRepository.save(className, loader, clz);
+ }
+ }
+
+ return clz;
+ }
+}
Added: branches/JBossProfiler2/src/main/org/jboss/profiler/agent/jobs/Job.java
===================================================================
--- branches/JBossProfiler2/src/main/org/jboss/profiler/agent/jobs/Job.java (rev 0)
+++ branches/JBossProfiler2/src/main/org/jboss/profiler/agent/jobs/Job.java 2008-02-10 10:59:33 UTC (rev 420)
@@ -0,0 +1,90 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2007, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file 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.agent.jobs;
+
+import java.util.Date;
+import java.util.TimerTask;
+
+/**
+ * The job class
+ * @author Jesper Pedersen <jep at worldleaguesports.com>
+ */
+public abstract class Job extends TimerTask {
+
+ /** The time */
+ private Date time;
+
+ /** The period */
+ private long period;
+
+ /**
+ * Constructor
+ */
+ protected Job() {
+ time = null;
+ period = -1;
+ }
+
+ /**
+ * Get the time
+ * @return The time
+ */
+ public Date getTime() {
+ return time;
+ }
+
+ /**
+ * Set the time
+ * @param t The time
+ */
+ public void setTime(Date t) {
+ time = t;
+ }
+
+ /**
+ * Get the period
+ * @return The period
+ */
+ public long getPeriod() {
+ return period;
+ }
+
+ /**
+ * Set the period
+ * @param p The period
+ */
+ public void setPeriod(long p) {
+ period = p;
+ }
+
+ /**
+ * The run method
+ */
+ public void run() {
+ doJob();
+ }
+
+ /**
+ * Execute the job
+ */
+ public abstract void doJob();
+}
Added: branches/JBossProfiler2/src/main/org/jboss/profiler/agent/jobs/JobHelper.java
===================================================================
--- branches/JBossProfiler2/src/main/org/jboss/profiler/agent/jobs/JobHelper.java (rev 0)
+++ branches/JBossProfiler2/src/main/org/jboss/profiler/agent/jobs/JobHelper.java 2008-02-10 10:59:33 UTC (rev 420)
@@ -0,0 +1,127 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2007, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file 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.agent.jobs;
+
+import java.util.ArrayList;
+import java.util.Date;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+import java.util.Properties;
+import java.util.TreeMap;
+
+/**
+ * The job helper
+ * @author Jesper Pedersen <jep at worldleaguesports.com>
+ */
+public class JobHelper {
+
+ /** Argument: type */
+ private static final String ARGUMENT_TYPE = "type";
+
+ /** Argument: time */
+ private static final String ARGUMENT_TIME = "time";
+
+ /** Argument: period */
+ private static final String ARGUMENT_PERIOD = "period";
+
+ /**
+ * Constructor
+ */
+ private JobHelper() {
+ }
+
+ /**
+ * Load a list of jobs
+ * @param properties The properties
+ * @return The list
+ */
+ public static List<Job> load(Properties properties) {
+ List<Job> result = new ArrayList<Job>();
+
+ if (properties != null) {
+ Map<Integer, Map<String, String>> jobs =
+ new TreeMap<Integer, Map<String, String>>();
+
+ Iterator it = properties.entrySet().iterator();
+ while (it.hasNext()) {
+ Map.Entry entry = (Map.Entry)it.next();
+
+ String key = (String)entry.getKey();
+ String value = (String)entry.getValue();
+
+ if (key.startsWith("job.")) {
+ int from = key.indexOf(".") + 1;
+ int to = key.indexOf(".", from);
+
+ Integer idx = Integer.parseInt(key.substring(from, to));
+
+ Map<String, String> m = jobs.get(idx);
+ if (m == null) {
+ m = new HashMap<String, String>();
+ }
+
+ String kt = key.substring(to + 1);
+ kt = kt.trim().toLowerCase();
+
+ if (kt.equals(ARGUMENT_TYPE) ||
+ kt.equals(ARGUMENT_TIME) ||
+ kt.equals(ARGUMENT_PERIOD)) {
+ m.put(kt, value.trim());
+
+ jobs.put(idx, m);
+ }
+ }
+ }
+
+ List<Map<String, String>> js = new ArrayList<Map<String, String>>(jobs.values());
+ for (Map<String, String> ji : js) {
+
+ String className = ji.get(ARGUMENT_TYPE);
+ try {
+ Class c = Class.forName(className);
+ Job j = (Job)c.newInstance();
+
+ String ts = ji.get(ARGUMENT_TIME);
+ if (ts != null) {
+ j.setTime(new Date(Long.parseLong(ts)));
+
+ String ps = ji.get(ARGUMENT_PERIOD);
+ if (ps != null) {
+ j.setPeriod(Long.parseLong(ps));
+ }
+
+ result.add(j);
+ } else {
+ System.err.println("Job " + className + " could not be loaded");
+ }
+ } catch (Exception e) {
+ // Nothing to do
+ System.err.println("Job " + className + " could not be loaded");
+ }
+ }
+ }
+
+ return result;
+ }
+}
Added: branches/JBossProfiler2/src/main/org/jboss/profiler/agent/jobs/StartProfiling.java
===================================================================
--- branches/JBossProfiler2/src/main/org/jboss/profiler/agent/jobs/StartProfiling.java (rev 0)
+++ branches/JBossProfiler2/src/main/org/jboss/profiler/agent/jobs/StartProfiling.java 2008-02-10 10:59:33 UTC (rev 420)
@@ -0,0 +1,46 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2007, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file 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.agent.jobs;
+
+import org.jboss.profiler.agent.Agent;
+import org.jboss.profiler.agent.Profiler;
+
+/**
+ * The start profiling job
+ * @author Jesper Pedersen <jep at worldleaguesports.com>
+ */
+public class StartProfiling extends Job {
+
+ /**
+ * Constructor
+ */
+ public StartProfiling() {
+ }
+
+ /**
+ * The job method
+ */
+ public void doJob() {
+ Agent.setEnabled(true);
+ Profiler.startProfiler();
+ }
+}
Added: branches/JBossProfiler2/src/main/org/jboss/profiler/agent/jobs/StopProfiling.java
===================================================================
--- branches/JBossProfiler2/src/main/org/jboss/profiler/agent/jobs/StopProfiling.java (rev 0)
+++ branches/JBossProfiler2/src/main/org/jboss/profiler/agent/jobs/StopProfiling.java 2008-02-10 10:59:33 UTC (rev 420)
@@ -0,0 +1,46 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2007, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file 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.agent.jobs;
+
+import org.jboss.profiler.agent.Agent;
+import org.jboss.profiler.agent.Profiler;
+
+/**
+ * The stop profiling job
+ * @author Jesper Pedersen <jep at worldleaguesports.com>
+ */
+public class StopProfiling extends Job {
+
+ /**
+ * Constructor
+ */
+ public StopProfiling() {
+ }
+
+ /**
+ * The job method
+ */
+ public void doJob() {
+ Profiler.stopProfiler();
+ Agent.setEnabled(false);
+ }
+}
Added: branches/JBossProfiler2/src/main/org/jboss/profiler/as/Communicator.java
===================================================================
--- branches/JBossProfiler2/src/main/org/jboss/profiler/as/Communicator.java (rev 0)
+++ branches/JBossProfiler2/src/main/org/jboss/profiler/as/Communicator.java 2008-02-10 10:59:33 UTC (rev 420)
@@ -0,0 +1,418 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2007, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file 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.as;
+
+import org.jboss.profiler.connectors.HttpHandler;
+import org.jboss.profiler.connectors.RmiHandler;
+import org.jboss.profiler.connectors.SocketHandler;
+import org.jboss.profiler.shared.Version;
+
+import org.jboss.remoting.InvokerLocator;
+import org.jboss.remoting.transport.Connector;
+
+import org.jboss.logging.Logger;
+
+/**
+ * The communicator class
+ * @author Jesper Pedersen <jep at worldleaguesports.com>
+ */
+public class Communicator implements CommunicatorMBean {
+ /** The logger */
+ private static Logger log = Logger.getLogger(Communicator.class);
+
+ /** Host */
+ private String host;
+
+ /** Socket */
+ private boolean socket;
+
+ /** Socket port */
+ private int socketPort;
+
+ /** Socket connector */
+ private Connector socketConnector;
+
+ /** RMI */
+ private boolean rmi;
+
+ /** RMI port */
+ private int rmiPort;
+
+ /** RMI connector */
+ private Connector rmiConnector;
+
+ /** HTTP */
+ private boolean http;
+
+ /** HTTP port */
+ private int httpPort;
+
+ /** HTTP connector */
+ private Connector httpConnector;
+
+ /** Communicator initialized */
+ private boolean initialized;
+
+ /**
+ * Constructor
+ */
+ public Communicator() {
+ host = "localhost";
+
+ socket = true;
+ socketPort = 5400;
+ socketConnector = null;
+
+ rmi = false;
+ rmiPort = 5401;
+ rmiConnector = null;
+
+ http = false;
+ httpPort = 5402;
+ httpConnector = null;
+
+ initialized = false;
+ }
+
+ /**
+ * Get the host
+ * @return The host
+ */
+ public String getHost() {
+ return host;
+ }
+
+ /**
+ * Set the host
+ * @param h The host
+ */
+ public void setHost(String h) {
+ host = h;
+
+ try {
+ if (initialized && socket) {
+ stopSocket();
+ startSocket();
+ }
+
+ if (initialized && rmi) {
+ stopRMI();
+ startRMI();
+ }
+
+ if (initialized && http) {
+ stopHTTP();
+ startHTTP();
+ }
+ } catch (Exception e) {
+ log.error(e.getMessage(), e);
+ }
+ }
+
+ /**
+ * Is socket enabled ?
+ * @return True if enabled; otherwise false
+ */
+ public boolean isSocket() {
+ return socket;
+ }
+
+ /**
+ * Enable / disable socket
+ * @param b True for enable; false for disable
+ */
+ public void setSocket(boolean b) {
+ try {
+ if (initialized && socket && !b) {
+ stopSocket();
+ }
+ if (initialized && !socket && b) {
+ startSocket();
+ }
+ } catch (Exception e) {
+ log.error(e.getMessage(), e);
+ }
+
+ socket = b;
+ }
+
+ /**
+ * Get the socket port
+ * @return The port
+ */
+ public int getSocketPort() {
+ return socketPort;
+ }
+
+ /**
+ * Set the socket port
+ * @param p The socket port
+ */
+ public void setSocketPort(int p) {
+ socketPort = p;
+
+ try {
+ if (initialized && socket) {
+ stopSocket();
+ startSocket();
+ }
+ } catch (Exception e) {
+ log.error(e.getMessage(), e);
+ }
+ }
+
+ /**
+ * Is rmi enabled ?
+ * @return True if enabled; otherwise false
+ */
+ public boolean isRmi() {
+ return rmi;
+ }
+
+ /**
+ * Enable / disable rmi
+ * @param b True for enable; false for disable
+ */
+ public void setRmi(boolean b) {
+ try {
+ if (initialized && rmi && !b) {
+ stopRMI();
+ }
+ if (initialized && !rmi && b) {
+ startRMI();
+ }
+ } catch (Exception e) {
+ log.error(e.getMessage(), e);
+ }
+
+ rmi = b;
+ }
+
+ /**
+ * Get the rmi port
+ * @return The port
+ */
+ public int getRmiPort() {
+ return rmiPort;
+ }
+
+ /**
+ * Set the rmi port
+ * @param p The rmi port
+ */
+ public void setRmiPort(int p) {
+ rmiPort = p;
+
+ try {
+ if (initialized && rmi) {
+ stopRMI();
+ startRMI();
+ }
+ } catch (Exception e) {
+ log.error(e.getMessage(), e);
+ }
+ }
+
+ /**
+ * Is http enabled ?
+ * @return True if enabled; otherwise false
+ */
+ public boolean isHttp() {
+ return http;
+ }
+
+ /**
+ * Enable / disable http
+ * @param b True for enable; false for disable
+ */
+ public void setHttp(boolean b) {
+ try {
+ if (initialized && http && !b) {
+ stopHTTP();
+ }
+ if (initialized && !http && b) {
+ startHTTP();
+ }
+ } catch (Exception e) {
+ log.error(e.getMessage(), e);
+ }
+
+ http = b;
+ }
+
+ /**
+ * Get the http port
+ * @return The port
+ */
+ public int getHttpPort() {
+ return httpPort;
+ }
+
+ /**
+ * Set the http port
+ * @param p The http port
+ */
+ public void setHttpPort(int p) {
+ httpPort = p;
+
+ try {
+ if (initialized && http) {
+ stopHTTP();
+ startHTTP();
+ }
+ } catch (Exception e) {
+ log.error(e.getMessage(), e);
+ }
+ }
+
+ /**
+ * Start the service
+ * @exception Exception Thrown if an exception occurs
+ */
+ public void start() throws Exception {
+ log.info("JBoss Profiler: Communicator for " + Version.FULL_VERSION);
+
+ try {
+ if (socket) {
+ startSocket();
+ }
+ if (rmi) {
+ startRMI();
+ }
+ if (http) {
+ startHTTP();
+ }
+ } catch (Exception e) {
+ log.error(e.getMessage(), e);
+ throw e;
+ }
+
+ initialized = true;
+ }
+
+ /**
+ * Stop the service
+ * @exception Exception Thrown if an exception occurs
+ */
+ public void stop() throws Exception {
+ stopSocket();
+ stopRMI();
+ stopHTTP();
+
+ initialized = false;
+
+ log.info("JBoss Profiler: Communicator stopped");
+ }
+
+ /**
+ * Start socket
+ * @exception Exception If an error occurs
+ */
+ private void startSocket() throws Exception {
+ InvokerLocator locator =
+ new InvokerLocator("socket://" + host + ":" + Integer.toString(socketPort));
+
+ socketConnector = new Connector(locator);
+ socketConnector.create();
+
+ SocketHandler socketHandler = new SocketHandler();
+
+ socketConnector.addInvocationHandler("jboss-profiler-socket", socketHandler);
+ socketConnector.start();
+
+ log.info("JBoss Profiler: Socket=" + host + ":" + Integer.toString(socketPort));
+ }
+
+ /**
+ * Stop socket
+ * @exception Exception If an error occurs
+ */
+ private void stopSocket() throws Exception {
+ if (socketConnector != null) {
+ socketConnector.stop();
+ socketConnector.destroy();
+ }
+ socketConnector = null;
+ }
+
+ /**
+ * Start RMI
+ * @exception Exception If an error occurs
+ */
+ private void startRMI() throws Exception {
+ InvokerLocator locator =
+ new InvokerLocator("rmi://" + host + ":" + Integer.toString(rmiPort));
+
+ rmiConnector = new Connector(locator);
+ rmiConnector.create();
+
+ RmiHandler rmiHandler = new RmiHandler();
+
+ rmiConnector.addInvocationHandler("jboss-profiler-rmi", rmiHandler);
+ rmiConnector.start();
+
+ log.info("JBoss Profiler: Rmi=" + host + ":" + Integer.toString(rmiPort));
+ }
+
+ /**
+ * Stop RMI
+ * @exception Exception If an error occurs
+ */
+ private void stopRMI() throws Exception {
+ if (rmiConnector != null) {
+ rmiConnector.stop();
+ rmiConnector.destroy();
+ }
+ rmiConnector = null;
+ }
+
+ /**
+ * Start HTTP
+ * @exception Exception If an error occurs
+ */
+ private void startHTTP() throws Exception {
+ InvokerLocator locator =
+ new InvokerLocator("http://" + host + ":" + Integer.toString(httpPort));
+
+ httpConnector = new Connector(locator);
+ httpConnector.create();
+
+ HttpHandler httpHandler = new HttpHandler();
+
+ httpConnector.addInvocationHandler("jboss-profiler-http", httpHandler);
+ httpConnector.start();
+
+ log.info("JBoss Profiler: Http=" + host + ":" + Integer.toString(httpPort));
+ }
+
+ /**
+ * Stop HTTP
+ * @exception Exception If an error occurs
+ */
+ private void stopHTTP() throws Exception {
+ if (httpConnector != null) {
+ httpConnector.stop();
+ httpConnector.destroy();
+ }
+ httpConnector = null;
+ }
+}
Added: branches/JBossProfiler2/src/main/org/jboss/profiler/as/CommunicatorMBean.java
===================================================================
--- branches/JBossProfiler2/src/main/org/jboss/profiler/as/CommunicatorMBean.java (rev 0)
+++ branches/JBossProfiler2/src/main/org/jboss/profiler/as/CommunicatorMBean.java 2008-02-10 10:59:33 UTC (rev 420)
@@ -0,0 +1,125 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2007, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file 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.as;
+
+/**
+ * The communicator mbean
+ * @author Jesper Pedersen <jep at worldleaguesports.com>
+ */
+public interface CommunicatorMBean {
+
+ /**
+ * Get the host
+ * @return The host
+ */
+ public String getHost();
+
+ /**
+ * Set the host
+ * @param h The host
+ */
+ public void setHost(String h);
+
+ /**
+ * Is socket enabled ?
+ * @return True if enabled; otherwise false
+ */
+ public boolean isSocket();
+
+ /**
+ * Enable / disable socket
+ * @param b True for enable; false for disable
+ */
+ public void setSocket(boolean b);
+
+ /**
+ * Get the socket port
+ * @return The port
+ */
+ public int getSocketPort();
+
+ /**
+ * Set the socket port
+ * @param p The socket port
+ */
+ public void setSocketPort(int p);
+
+ /**
+ * Is rmi enabled ?
+ * @return True if enabled; otherwise false
+ */
+ public boolean isRmi();
+
+ /**
+ * Enable / disable rmi
+ * @param b True for enable; false for disable
+ */
+ public void setRmi(boolean b);
+
+ /**
+ * Get the rmi port
+ * @return The port
+ */
+ public int getRmiPort();
+
+ /**
+ * Set the rmi port
+ * @param p The rmi port
+ */
+ public void setRmiPort(int p);
+
+ /**
+ * Is http enabled ?
+ * @return True if enabled; otherwise false
+ */
+ public boolean isHttp();
+
+ /**
+ * Enable / disable http
+ * @param b True for enable; false for disable
+ */
+ public void setHttp(boolean b);
+
+ /**
+ * Get the http port
+ * @return The port
+ */
+ public int getHttpPort();
+
+ /**
+ * Set the http port
+ * @param p The http port
+ */
+ public void setHttpPort(int p);
+
+ /**
+ * Start the service
+ * @exception Exception Thrown if an exception occurs
+ */
+ public void start() throws Exception;
+
+ /**
+ * Stop the service
+ * @exception Exception Thrown if an exception occurs
+ */
+ public void stop() throws Exception;
+}
Added: branches/JBossProfiler2/src/main/org/jboss/profiler/as/Profiler.java
===================================================================
--- branches/JBossProfiler2/src/main/org/jboss/profiler/as/Profiler.java (rev 0)
+++ branches/JBossProfiler2/src/main/org/jboss/profiler/as/Profiler.java 2008-02-10 10:59:33 UTC (rev 420)
@@ -0,0 +1,200 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2007, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file 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.as;
+
+import org.jboss.profiler.agent.Agent;
+import org.jboss.profiler.connectors.LocalHandler;
+import org.jboss.profiler.shared.Command;
+import org.jboss.profiler.shared.CommandType;
+import org.jboss.profiler.shared.Visibility;
+
+import org.jboss.logging.Logger;
+
+/**
+ * The profiler mbean class
+ * @author Jesper Pedersen <jep at worldleaguesports.com>
+ */
+public class Profiler implements ProfilerMBean {
+ /** The logger */
+ private static Logger log = Logger.getLogger(Profiler.class);
+
+ /**
+ * Constructor
+ */
+ public Profiler() {
+ }
+
+ /**
+ * Is the profiler enabled ?
+ * @return True if enabled; otherwise false
+ */
+ public boolean isEnabled() {
+ return Agent.isEnabled();
+ }
+
+ /**
+ * Is the profiler running ?
+ * @return True if running; otherwise false
+ */
+ public boolean isRunning() {
+ return org.jboss.profiler.agent.Profiler.isRunning();
+ }
+
+ /**
+ * Is the profiler using a memory store ?
+ * @return True if memory store; otherwise false
+ */
+ public boolean isMemory() {
+ return Agent.isMemoryStore();
+ }
+
+ /**
+ * Is the profiler using a file store ?
+ * @return True if file store; otherwise false
+ */
+ public boolean isFile() {
+ return !Agent.isMemoryStore();
+ }
+
+ /**
+ * Is EJB ?
+ * @return True if enabled; otherwise false
+ */
+ public boolean isEJB() {
+ return Agent.isEJB();
+ }
+
+ /**
+ * Is Servlet ?
+ * @return True if enabled; otherwise false
+ */
+ public boolean isServlet() {
+ return Agent.isServlet();
+ }
+
+ /**
+ * Is JSF ?
+ * @return True if enabled; otherwise false
+ */
+ public boolean isJSF() {
+ return Agent.isJSF();
+ }
+
+ /**
+ * Is JMX ?
+ * @return True if enabled; otherwise false
+ */
+ public boolean isJMX() {
+ return Agent.isJMX();
+ }
+
+ /**
+ * Is RMI ?
+ * @return True if enabled; otherwise false
+ */
+ public boolean isRMI() {
+ return Agent.isRMI();
+ }
+
+ /**
+ * Is CORBA ?
+ * @return True if enabled; otherwise false
+ */
+ public boolean isCORBA() {
+ return Agent.isCORBA();
+ }
+
+ /**
+ * Start the profiler
+ */
+ public void startProfiler() {
+ LocalHandler lh = new LocalHandler();
+ lh.handleCommand(new Command(CommandType.START_PROFILER));
+ }
+
+ /**
+ * Stop the profiler
+ */
+ public void stopProfiler() {
+ LocalHandler lh = new LocalHandler();
+ lh.handleCommand(new Command(CommandType.STOP_PROFILER));
+ }
+
+ /**
+ * Enable the profiler
+ */
+ public void enableProfiler() {
+ LocalHandler lh = new LocalHandler();
+ lh.handleCommand(new Command(CommandType.ENABLE));
+ }
+
+ /**
+ * Disable the profiler
+ */
+ public void disableProfiler() {
+ LocalHandler lh = new LocalHandler();
+ lh.handleCommand(new Command(CommandType.DISABLE));
+ }
+
+ /**
+ * Add classes
+ * @param classes The classes
+ * @param v The visibility
+ */
+ public void addClasses(String classes, Visibility v) {
+ LocalHandler lh = new LocalHandler();
+ lh.handleCommand(new Command(CommandType.ADD_CLASSES, new Object[] { classes, v }));
+ }
+
+ /**
+ * Remove classes
+ * @param classes The classes
+ */
+ public void removeClasses(String classes) {
+ LocalHandler lh = new LocalHandler();
+ lh.handleCommand(new Command(CommandType.REMOVE_CLASSES, new Object[] { classes }));
+ }
+
+ /**
+ * Clear snapshots
+ */
+ public void clearSnapshots() {
+ LocalHandler lh = new LocalHandler();
+ lh.handleCommand(new Command(CommandType.CLEAR_SNAPSHOTS));
+ }
+
+ /**
+ * Start the service
+ * @exception Exception Thrown if an exception occurs
+ */
+ public void start() throws Exception {
+ log.info("JBoss Profiler: ProfilerMBean started");
+ }
+
+ /**
+ * Stop the service
+ * @exception Exception Thrown if an exception occurs
+ */
+ public void stop() throws Exception {
+ log.info("JBoss Profiler: ProfilerMBean stopped");
+ }
+}
Added: branches/JBossProfiler2/src/main/org/jboss/profiler/as/ProfilerMBean.java
===================================================================
--- branches/JBossProfiler2/src/main/org/jboss/profiler/as/ProfilerMBean.java (rev 0)
+++ branches/JBossProfiler2/src/main/org/jboss/profiler/as/ProfilerMBean.java 2008-02-10 10:59:33 UTC (rev 420)
@@ -0,0 +1,141 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2007, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file 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.as;
+
+import org.jboss.profiler.shared.Visibility;
+
+/**
+ * The profiler mbean
+ * @author Jesper Pedersen <jep at worldleaguesports.com>
+ */
+public interface ProfilerMBean {
+
+ /**
+ * Is the profiler enabled ?
+ * @return True if enabled; otherwise false
+ */
+ public boolean isEnabled();
+
+ /**
+ * Is the profiler running ?
+ * @return True if running; otherwise false
+ */
+ public boolean isRunning();
+
+ /**
+ * Is the profiler using a memory store ?
+ * @return True if memory store; otherwise false
+ */
+ public boolean isMemory();
+
+ /**
+ * Is the profiler using a file store ?
+ * @return True if file store; otherwise false
+ */
+ public boolean isFile();
+
+ /**
+ * Is EJB ?
+ * @return True if enabled; otherwise false
+ */
+ public boolean isEJB();
+
+ /**
+ * Is Servlet ?
+ * @return True if enabled; otherwise false
+ */
+ public boolean isServlet();
+
+ /**
+ * Is JSF ?
+ * @return True if enabled; otherwise false
+ */
+ public boolean isJSF();
+
+ /**
+ * Is JMX ?
+ * @return True if enabled; otherwise false
+ */
+ public boolean isJMX();
+
+ /**
+ * Is RMI ?
+ * @return True if enabled; otherwise false
+ */
+ public boolean isRMI();
+
+ /**
+ * Is CORBA ?
+ * @return True if enabled; otherwise false
+ */
+ public boolean isCORBA();
+
+ /**
+ * Start the profiler
+ */
+ public void startProfiler();
+
+ /**
+ * Stop the profiler
+ */
+ public void stopProfiler();
+
+ /**
+ * Enable the profiler
+ */
+ public void enableProfiler();
+
+ /**
+ * Disable the profiler
+ */
+ public void disableProfiler();
+
+ /**
+ * Add classes
+ * @param classes The classes
+ * @param v The visibility
+ */
+ public void addClasses(String classes, Visibility v);
+
+ /**
+ * Remove classes
+ * @param classes The classes
+ */
+ public void removeClasses(String classes);
+
+ /**
+ * Clear snapshots
+ */
+ public void clearSnapshots();
+
+ /**
+ * Start the service
+ * @exception Exception Thrown if an exception occurs
+ */
+ public void start() throws Exception;
+
+ /**
+ * Stop the service
+ * @exception Exception Thrown if an exception occurs
+ */
+ public void stop() throws Exception;
+}
Added: branches/JBossProfiler2/src/main/org/jboss/profiler/client/CombinedFrameComparator.java
===================================================================
--- branches/JBossProfiler2/src/main/org/jboss/profiler/client/CombinedFrameComparator.java (rev 0)
+++ branches/JBossProfiler2/src/main/org/jboss/profiler/client/CombinedFrameComparator.java 2008-02-10 10:59:33 UTC (rev 420)
@@ -0,0 +1,81 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2007, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file 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.client;
+
+import java.util.Comparator;
+
+/**
+ * Frame comparator
+ * @author Jesper Pedersen <jep at worldleaguesports.com>
+ */
+public class CombinedFrameComparator implements Comparator<CombinedFrameInfo> {
+
+ /** Method: TOTAL TIME */
+ public static final int TOTAL_TIME = 0;
+
+ /** Method: TOTAL TIME AVG */
+ public static final int TOTAL_TIME_AVG = 1;
+
+ /** The method */
+ private int method;
+
+ /**
+ * Constructor
+ * @param method The method
+ */
+ public CombinedFrameComparator(int method) {
+ this.method = method;
+ }
+
+ /**
+ * Compare two objects
+ * @param fa Combined frame info
+ * @param fb Combined frame info
+ * @return Positive if fb greater than fa; zero if equal otherwise negative
+ */
+ public int compare(CombinedFrameInfo fa, CombinedFrameInfo fb) {
+ double va;
+ double vb;
+
+ if (method == TOTAL_TIME) {
+ va = fa.getTotalTime();
+ vb = fb.getTotalTime();
+ } else {
+ va = fa.getTotalTime() / fa.getCount();
+ vb = fb.getTotalTime() / fb.getCount();
+ }
+
+ if (va < vb) {
+ return 1;
+ } else if (va == vb) {
+ if (fa.getCount() < fb.getCount()) {
+ return 1;
+ } else if (fa.getCount() == fb.getCount()) {
+ return fa.getPrettyName().compareTo(fb.getPrettyName());
+ } else {
+ return -1;
+ }
+ } else {
+ return -1;
+ }
+ }
+}
Added: branches/JBossProfiler2/src/main/org/jboss/profiler/client/CombinedFrameInfo.java
===================================================================
--- branches/JBossProfiler2/src/main/org/jboss/profiler/client/CombinedFrameInfo.java (rev 0)
+++ branches/JBossProfiler2/src/main/org/jboss/profiler/client/CombinedFrameInfo.java 2008-02-10 10:59:33 UTC (rev 420)
@@ -0,0 +1,142 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2007, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file 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.client;
+
+import org.jboss.profiler.shared.FrameInfo;
+
+/**
+ * The combined frame info class
+ * @author Jesper Pedersen <jep at worldleaguesports.com>
+ */
+public class CombinedFrameInfo {
+ /** The class name */
+ private String className;
+
+ /** The pretty name */
+ private String prettyName;
+
+ /** The count */
+ private long count;
+
+ /** The time */
+ private double time;
+
+ /** The percent */
+ private double percent;
+
+ /** The wait */
+ private double wait;
+
+ /**
+ * Constructor
+ * @param className The class name
+ * @param prettyName The pretty name
+ */
+ public CombinedFrameInfo(String className, String prettyName) {
+ this.className = className;
+ this.prettyName = prettyName;
+ this.count = 0;
+ this.time = 0.0;
+ this.percent = 0.0;
+ this.wait = 0.0;
+ }
+
+ /**
+ * Get the count (#)
+ * @return The count
+ */
+ public long getCount() {
+ return count;
+ }
+
+ /**
+ * Get the time (ms)
+ * @return The time
+ */
+ public double getTotalTime() {
+ return time;
+ }
+
+ /**
+ * Get the percent (%)
+ * @return The percent
+ */
+ public double getPercent() {
+ return percent;
+ }
+
+ /**
+ * Get the class name
+ * @return The class name
+ */
+ public String getClassName() {
+ return className;
+ }
+
+ /**
+ * Get the pretty name
+ * @return The pretty name
+ */
+ public String getPrettyName() {
+ return prettyName;
+ }
+
+ /**
+ * Get the time (ms)
+ * @return The time
+ */
+ public double getWaitTime() {
+ return wait;
+ }
+
+ /**
+ * Increase the count (#)
+ * @param c The count
+ */
+ public void increaseCount(long c) {
+ count += c;
+ }
+
+ /**
+ * Increase the time (ms)
+ * @param t The time
+ */
+ public void increaseTotalTime(double t) {
+ time += t;
+ }
+
+ /**
+ * Increase the percent (%)
+ * @param p The percent
+ */
+ public void increasePercent(double p) {
+ percent += p;
+ }
+
+ /**
+ * Increase the wait time (ms)
+ * @param t The wait time
+ */
+ public void increaseWaitTime(double t) {
+ wait += t;
+ }
+}
Added: branches/JBossProfiler2/src/main/org/jboss/profiler/client/DifferenceUtil.java
===================================================================
--- branches/JBossProfiler2/src/main/org/jboss/profiler/client/DifferenceUtil.java (rev 0)
+++ branches/JBossProfiler2/src/main/org/jboss/profiler/client/DifferenceUtil.java 2008-02-10 10:59:33 UTC (rev 420)
@@ -0,0 +1,407 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2007, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file 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.client;
+
+import org.jboss.profiler.shared.AllocationInfo;
+import org.jboss.profiler.shared.ClassInfo;
+import org.jboss.profiler.shared.FrameInfo;
+import org.jboss.profiler.shared.Snapshot;
+import org.jboss.profiler.shared.ThreadInfo;
+
+import java.io.BufferedWriter;
+import java.io.File;
+import java.io.FileWriter;
+import java.io.Writer;
+import java.text.DecimalFormat;
+import java.text.SimpleDateFormat;
+import java.util.ArrayList;
+import java.util.Calendar;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+
+import org.jboss.logging.Logger;
+
+/**
+ * The difference utility class
+ * @author Jesper Pedersen <jep at worldleaguesports.com>
+ */
+public class DifferenceUtil extends SnapshotUtil {
+ /** The logger */
+ private static Logger log = Logger.getLogger(DifferenceUtil.class);
+
+ /**
+ * Constructor
+ */
+ public DifferenceUtil() {
+ super();
+ }
+
+ /**
+ * Constructor
+ * @param threshold The threshold
+ */
+ public DifferenceUtil(double threshold) {
+ super(threshold);
+ }
+
+ /**
+ * Dump the difference between two snapshots to a directory
+ * @param os The old snapshot
+ * @param ns The new snapshot
+ * @param d The directory
+ * @exception Exception If an error occurs
+ */
+ public void dump(Snapshot os, Snapshot ns, File d) throws Exception {
+ if (os != null && ns != null) {
+ StringBuffer sb = new StringBuffer();
+ DecimalFormat df = new DecimalFormat("00");
+ DecimalFormat df3 = new DecimalFormat("000");
+
+ Calendar c = Calendar.getInstance();
+ c.setTime(os.getFrom());
+
+ sb = sb.append(Integer.toString(c.get(Calendar.YEAR)));
+ sb = sb.append(df.format(c.get(Calendar.MONTH) + 1));
+ sb = sb.append(df.format(c.get(Calendar.DATE)));
+ sb = sb.append(df.format(c.get(Calendar.HOUR_OF_DAY)));
+ sb = sb.append(df.format(c.get(Calendar.MINUTE)));
+ sb = sb.append(df.format(c.get(Calendar.SECOND)));
+ sb = sb.append(df3.format(c.get(Calendar.MILLISECOND)));
+
+ sb = sb.append("-");
+
+ c.setTime(ns.getTo());
+ sb = sb.append(Integer.toString(c.get(Calendar.YEAR)));
+ sb = sb.append(df.format(c.get(Calendar.MONTH) + 1));
+ sb = sb.append(df.format(c.get(Calendar.DATE)));
+ sb = sb.append(df.format(c.get(Calendar.HOUR_OF_DAY)));
+ sb = sb.append(df.format(c.get(Calendar.MINUTE)));
+ sb = sb.append(df.format(c.get(Calendar.SECOND)));
+ sb = sb.append(df3.format(c.get(Calendar.MILLISECOND)));
+
+ File dir = new File(d, sb.toString());
+ dir.mkdirs();
+
+ String directory = dir.getPath() + File.separator;
+
+ Map<String, List<CombinedFrameInfo>> oInfo = getInformation(os);
+ List<TimedClassInfo> oClasses = getTimedClasses(os.getClasses(), oInfo);
+
+ Map<String, List<CombinedFrameInfo>> nInfo = getInformation(ns);
+ List<TimedClassInfo> nClasses = getTimedClasses(ns.getClasses(), nInfo);
+
+ dumpThreads(ns.getThreads(), directory);
+ dumpOverview(ns, nInfo, nClasses, directory);
+ dumpMethods(oInfo, nInfo, directory);
+ dumpHotspots(nInfo, directory);
+ dumpClasses(nClasses, nInfo, ns.getAllocations(), directory);
+ }
+ }
+
+ /**
+ * Dump the threads to a file writer
+ * @param os The old threads
+ * @param ns The new threads
+ * @param directory The directory
+ * @exception Exception If an error occurs
+ */
+ private void dumpThreads(List<ThreadInfo> ots, List<ThreadInfo> nts, String directory) throws Exception {
+ File f = new File(directory + "threads");
+ f.mkdirs();
+
+ Set<ThreadHolder> ths = matchThreads(ots, nts);
+ for (ThreadHolder th : ths) {
+ FileWriter ftw = new FileWriter(directory + "threads" + File.separator +
+ "thread-" + th.getNew().getId() + ".txt");
+ BufferedWriter bw = new BufferedWriter(ftw, 8192);
+
+ bw.write("Thread: " + th.getNew().getId() + NEW_LINE);
+ bw.write("Name: " + th.getNew().getName() + NEW_LINE);
+ bw.write("Priority: " + th.getNew().getPriority() + NEW_LINE);
+ bw.write("Daemon: " + th.getNew().isDaemon() + NEW_LINE);
+
+ if (th.getNew().getGroups() != null) {
+ bw.write("Groups: ");
+
+ Iterator it = th.getNew().getGroups().iterator();
+ while (it.hasNext()) {
+ String g = (String)it.next();
+ bw.write(g);
+ if (it.hasNext()) {
+ bw.write(" -> ");
+ }
+ }
+
+ bw.write(NEW_LINE);
+ }
+
+ bw.write(NEW_LINE);
+
+ /*
+ int frameNumber = 1;
+
+ for (FrameInfo fi: th.getNew().getFrames()) {
+ dumpFrame(fi, frameNumber, bw);
+ frameNumber++;
+ bw.write(NEW_LINE);
+ }
+ */
+
+ bw.flush();
+ bw.close();
+ }
+ }
+
+ /**
+ * Dump the methods
+ * @param oInfo The old information
+ * @param nInfo The new information
+ * @param directory The directory
+ * @exception Exception If an error occurs
+ */
+ protected void dumpMethods(Map<String, List<CombinedFrameInfo>> oInfo,
+ Map<String, List<CombinedFrameInfo>> nInfo,
+ String directory) throws Exception {
+
+ List<CombinedFrameInfo> methods = new ArrayList<CombinedFrameInfo>();
+ Map<String, CombinedFrameInfo> oMap = new HashMap<String, CombinedFrameInfo>();
+ Map<String, CombinedFrameInfo> nMap = new HashMap<String, CombinedFrameInfo>();
+
+ Map<String, CombinedFrameInfo> tMap = new HashMap<String, CombinedFrameInfo>();
+
+ Iterator it = oInfo.values().iterator();
+ while (it.hasNext()) {
+ List<CombinedFrameInfo> l = (List<CombinedFrameInfo>)it.next();
+ for (CombinedFrameInfo cfi : l) {
+ oMap.put(cfi.getPrettyName(), cfi);
+ tMap.put(cfi.getPrettyName(), cfi);
+ }
+ }
+ it = nInfo.values().iterator();
+ while (it.hasNext()) {
+ List<CombinedFrameInfo> l = (List<CombinedFrameInfo>)it.next();
+ for (CombinedFrameInfo cfi : l) {
+ nMap.put(cfi.getPrettyName(), cfi);
+ }
+ }
+
+ it = nMap.entrySet().iterator();
+ while (it.hasNext()) {
+ Map.Entry entry = (Map.Entry)it.next();
+ String key = (String)entry.getKey();
+ CombinedFrameInfo cfi = (CombinedFrameInfo)entry.getValue();
+
+ double oTime = 0.0;
+ long oCount = 0;
+ if (oMap.containsKey(key)) {
+ CombinedFrameInfo oCfi = oMap.get(key);
+ oTime = oCfi.getTotalTime();
+ oCount = oCfi.getCount();
+ tMap.remove(key);
+ }
+
+ CombinedFrameInfo c = new CombinedFrameInfo(cfi.getClassName(), cfi.getPrettyName());
+ c.increaseTotalTime(cfi.getTotalTime() - oTime);
+ c.increaseCount(cfi.getCount() - oCount);
+
+ methods.add(c);
+ }
+ it = tMap.entrySet().iterator();
+ while (it.hasNext()) {
+ Map.Entry entry = (Map.Entry)it.next();
+ String key = (String)entry.getKey();
+ CombinedFrameInfo cfi = (CombinedFrameInfo)entry.getValue();
+
+ CombinedFrameInfo c = new CombinedFrameInfo(cfi.getClassName(), cfi.getPrettyName());
+ c.increaseTotalTime(-cfi.getTotalTime());
+ c.increaseCount(-cfi.getCount());
+
+ methods.add(c);
+ }
+
+ FileWriter fw = new FileWriter(directory + "methods.txt");
+ BufferedWriter bw = new BufferedWriter(fw, 8192);
+
+ bw.write("Methods:" + NEW_LINE);
+ bw.write("--------" + NEW_LINE);
+ bw.write("Diff Ms\tOld Ms\tNew Ms\tDiff #\tOld #\tNew #\tMethod" + NEW_LINE);
+
+ Collections.sort(methods, new CombinedFrameComparator(CombinedFrameComparator.TOTAL_TIME));
+ Collections.reverse(methods);
+
+ DecimalFormat df = new DecimalFormat("#0.00");
+
+ int count = 0;
+
+ for (int i = 0; i < methods.size(); i++) {
+ CombinedFrameInfo h = methods.get(i);
+ CombinedFrameInfo o = oMap.get(h.getPrettyName());
+ CombinedFrameInfo n = nMap.get(h.getPrettyName());
+
+ double oTime = 0.0;
+ long oCount = 0;
+ if (o != null) {
+ oTime = o.getTotalTime();
+ oCount = o.getCount();
+ }
+ double nTime = 0.0;
+ long nCount = 0;
+ if (n != null) {
+ nTime = n.getTotalTime();
+ nCount = n.getCount();
+ }
+
+ if (h.getTotalTime() >= threshold || h.getTotalTime() <= -threshold) {
+ bw.write(df.format(h.getTotalTime()) + "\t");
+ bw.write(df.format(oTime) + "\t");
+ bw.write(df.format(nTime) + "\t");
+ bw.write(h.getCount() + "\t");
+ bw.write(oCount + "\t");
+ bw.write(nCount + "\t");
+ bw.write(h.getPrettyName() + NEW_LINE);
+ } else {
+ count++;
+ }
+ }
+
+ if (count > 0) {
+ bw.write(NEW_LINE);
+ bw.write(count + " methods filtered by threshold." + NEW_LINE);
+ }
+
+ bw.flush();
+ bw.close();
+ }
+
+ /**
+ * Match the threads against each other
+ * @param ots The old threads
+ * @param nts The new threads
+ * @return The set of matched threads
+ */
+ private Set<ThreadHolder> matchThreads(List<ThreadInfo> ots, List<ThreadInfo> nts) {
+ Set<ThreadHolder> result = new HashSet<ThreadHolder>();
+
+ Set<Long> taken = new HashSet<Long>();
+
+ for (ThreadInfo nt : nts) {
+ double[] scores = new double[ots.size()];
+
+ for (int i = 0; i < ots.size(); i++) {
+ ThreadInfo ot = ots.get(i);
+ double score = 0.0;
+
+ if (!taken.contains(Long.valueOf(ot.getId()))) {
+ score = matchThread(ot, nt);
+
+ scores[i] = score;
+ }
+ }
+
+ double score = 0.0;
+ int index = -1;
+ for (int i = 0; i < scores.length; i++) {
+ if (scores[i] > score) {
+ score = scores[i];
+ index = i;
+ }
+ }
+
+ ThreadInfo ot = ots.get(index);
+
+ ThreadHolder th = new ThreadHolder(ot, nt, score);
+ result.add(th);
+
+ taken.add(Long.valueOf(ot.getId()));
+ }
+
+ return result;
+ }
+
+ /**
+ * Match if two threads are equal
+ * @param t1 The first thread
+ * @param t2 The second thread
+ * @return 1.0 if equal; otherwise 0.0
+ */
+ private double matchThread(ThreadInfo t1, ThreadInfo t2) {
+ return matchFrames(t1.getFrames(), t2.getFrames(), 1.0);
+ }
+
+ /**
+ * Match if two lists of frames are equal
+ * @param ofs The first list of frames
+ * @param nfs The second list of frames
+ * @param maximum The maximum value allowed to be returned
+ * @return Between 1.0 (full match) and 0.0 (no match)
+ */
+ private double matchFrames(List<FrameInfo> ofs, List<FrameInfo> nfs, double maximum) {
+
+ if (ofs == null && nfs == null) {
+ return maximum;
+ }
+ if (ofs == null || nfs == null) {
+ return 0.0;
+ }
+
+ double step = maximum / nfs.size();
+ double total = 0.0;
+
+ for (int i = 0; i < nfs.size(); i++) {
+ FrameInfo nf = nfs.get(i);
+ FrameInfo of = null;
+ if (i < ofs.size()) {
+ of = ofs.get(i);
+
+ // TODO - look at frame before and after if not equal to get higher score
+
+ if (nf.getChildren() != null) {
+ if (of.getChildren() != null) {
+ total += matchFrames(of.getChildren(), nf.getChildren(), step);
+ }
+ } else {
+ total += (step * matchFrame(of, nf));
+ }
+ }
+ }
+ return total;
+ }
+
+ /**
+ * Match if two frames are equal
+ * @param f1 The first frame
+ * @param f2 The second frame
+ * @return 1.0 if equal; otherwise 0.0
+ */
+ private double matchFrame(FrameInfo f1, FrameInfo f2) {
+ if (f1.getMethod().equals(f2.getMethod())) {
+ return 1.0;
+ }
+
+ return 0.0;
+ }
+}
Added: branches/JBossProfiler2/src/main/org/jboss/profiler/client/SnapshotUtil.java
===================================================================
--- branches/JBossProfiler2/src/main/org/jboss/profiler/client/SnapshotUtil.java (rev 0)
+++ branches/JBossProfiler2/src/main/org/jboss/profiler/client/SnapshotUtil.java 2008-02-10 10:59:33 UTC (rev 420)
@@ -0,0 +1,678 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2007, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file 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.client;
+
+import org.jboss.profiler.shared.AllocationComparator;
+import org.jboss.profiler.shared.AllocationInfo;
+import org.jboss.profiler.shared.ClassComparator;
+import org.jboss.profiler.shared.ClassInfo;
+import org.jboss.profiler.shared.FrameComparator;
+import org.jboss.profiler.shared.FrameInfo;
+import org.jboss.profiler.shared.Math;
+import org.jboss.profiler.shared.Snapshot;
+import org.jboss.profiler.shared.SnapshotHelper;
+import org.jboss.profiler.shared.ThreadComparator;
+import org.jboss.profiler.shared.ThreadInfo;
+
+import java.io.BufferedWriter;
+import java.io.File;
+import java.io.FileWriter;
+import java.io.Writer;
+import java.text.DecimalFormat;
+import java.text.SimpleDateFormat;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.Comparator;
+import java.util.HashMap;
+import java.util.Locale;
+import java.util.List;
+import java.util.Map;
+import java.util.Iterator;
+
+import org.jboss.logging.Logger;
+
+/**
+ * The snapshot utility class
+ * @author Jesper Pedersen <jep at worldleaguesports.com>
+ */
+public class SnapshotUtil {
+ /** The logger */
+ private static Logger log = Logger.getLogger(SnapshotUtil.class);
+
+ /** New line character */
+ protected static final String NEW_LINE = System.getProperty("line.separator");
+
+ /** Threshold */
+ protected double threshold;
+
+ /**
+ * Constructor
+ */
+ public SnapshotUtil() {
+ this(1.0);
+ }
+
+ /**
+ * Constructor
+ * @param threshold The threshold
+ */
+ public SnapshotUtil(double threshold) {
+ this.threshold = threshold;
+ }
+
+ /**
+ * Get information about the snapshot
+ * @param snapshot The snapshot
+ * @return The information
+ */
+ protected Map<String, List<CombinedFrameInfo>> getInformation(Snapshot snapshot) {
+ Map<String, Map<String, CombinedFrameInfo>> data =
+ new HashMap<String, Map<String, CombinedFrameInfo>>();
+
+ long tt = 0;
+ for (ThreadInfo ti: snapshot.getThreads()) {
+ tt += ti.getTotalTime();
+ }
+
+ for (ThreadInfo ti: snapshot.getThreads()) {
+ for (FrameInfo fi: ti.getFrames()) {
+ frameInformation(fi, tt, data);
+ }
+ }
+
+ Map<String, List<CombinedFrameInfo>> result = new HashMap<String, List<CombinedFrameInfo>>();
+
+ Iterator it = data.entrySet().iterator();
+ while (it.hasNext()) {
+ Map.Entry entry = (Map.Entry)it.next();
+ String key = (String)entry.getKey();
+ Map<String, CombinedFrameInfo> value = (Map<String, CombinedFrameInfo>)entry.getValue();
+
+ result.put(key, new ArrayList<CombinedFrameInfo>(value.values()));
+ }
+
+ return result;
+ }
+
+ /**
+ * Generate frame information
+ * @param fi The frame
+ * @param tt The total time (ns)
+ * @param data The data
+ */
+ private void frameInformation(FrameInfo fi, long tt, Map<String, Map<String, CombinedFrameInfo>> data) {
+ Map<String, CombinedFrameInfo> classData = data.get(fi.getMethod().getClassName());
+
+ if (classData == null) {
+ classData = new HashMap<String, CombinedFrameInfo>();
+ data.put(fi.getMethod().getClassName(), classData);
+ }
+
+ String prettyName = Util.getPrettyName(fi.getMethod());
+ CombinedFrameInfo methodData = classData.get(prettyName);
+
+ if (methodData == null) {
+ methodData = new CombinedFrameInfo(fi.getMethod().getClassName(), prettyName);
+ classData.put(prettyName, methodData);
+ }
+
+ long net = fi.getNetTime();
+ double percent = Math.toPercent(net, (double)tt);
+ double time = Math.nanoToMilli(net);
+
+ methodData.increaseCount(fi.getCount());
+ methodData.increaseTotalTime(time);
+ methodData.increasePercent(percent);
+ methodData.increaseWaitTime(Math.nanoToMilli(fi.getWaitTime()));
+
+ List<FrameInfo> l = fi.getChildren();
+ if (l != null) {
+ for (FrameInfo child: l) {
+ frameInformation(child, tt, data);
+ }
+ }
+ }
+
+ /**
+ * Get the timed classes
+ * @param classes The classes
+ * @param info The information
+ * @return The timed classes
+ */
+ protected List<TimedClassInfo> getTimedClasses(List<ClassInfo> classes,
+ Map<String, List<CombinedFrameInfo>> info) {
+ List<TimedClassInfo> result = new ArrayList<TimedClassInfo>();
+
+ for (ClassInfo ci : classes) {
+ List<CombinedFrameInfo> l = info.get(ci.getClassName());
+
+ double time = 0.0;
+ double wait = 0.0;
+
+ if (l != null) {
+ for (CombinedFrameInfo cfi: l) {
+ time += cfi.getTotalTime();
+ wait += cfi.getWaitTime();
+ }
+ }
+
+ TimedClassInfo tci = new TimedClassInfo(ci, time, wait);
+ result.add(tci);
+ }
+
+ return result;
+ }
+
+ /**
+ * Dump the snapshot to a directory
+ * @param snapshot The snapshot
+ * @param d The directory
+ * @exception Exception If an error occurs
+ */
+ public void dump(Snapshot snapshot, File d) throws Exception {
+ if (snapshot != null) {
+ File dir = new File(d, SnapshotHelper.getName(snapshot));
+ dir.mkdirs();
+
+ String directory = dir.getPath() + File.separator;
+
+ dumpThreads(snapshot.getThreads(), directory);
+
+ Map<String, List<CombinedFrameInfo>> info = getInformation(snapshot);
+ List<TimedClassInfo> classes = getTimedClasses(snapshot.getClasses(), info);
+
+ dumpOverview(snapshot, info, classes, directory);
+ dumpMethods(info, directory);
+ dumpHotspots(info, directory);
+ dumpClasses(classes, info, snapshot.getAllocations(), directory);
+ }
+ }
+
+ /**
+ * Dump the overview
+ * @param snapshot The snapshot
+ * @param info The information
+ * @param classes The classes
+ * @param directory The directory
+ * @exception Exception If an error occurs
+ */
+ protected void dumpOverview(Snapshot snapshot,
+ Map<String, List<CombinedFrameInfo>> info,
+ List<TimedClassInfo> classes,
+ String directory) throws Exception {
+
+ SimpleDateFormat dateFormat = new SimpleDateFormat("dd MMMMM yyyy HH:mm:ss:SSS");
+ DecimalFormat df = new DecimalFormat("#0.00");
+
+ FileWriter fw = new FileWriter(directory + "overview.txt");
+ BufferedWriter bw = new BufferedWriter(fw, 8192);
+ bw.write("From: " + dateFormat.format(snapshot.getFrom()) + NEW_LINE);
+ bw.write("To : " + dateFormat.format(snapshot.getTo()) + NEW_LINE);
+ bw.write(NEW_LINE);
+
+ Collections.sort(snapshot.getThreads(), new ThreadComparator());
+
+ bw.write("Threads:" + NEW_LINE);
+ bw.write("========" + NEW_LINE);
+
+ for (ThreadInfo ti: snapshot.getThreads()) {
+ bw.write("Thread-" + ti.getId() + "\t" + df.format(Math.nanoToMilli(ti.getTotalTime())) + " ms");
+ bw.write(NEW_LINE);
+ }
+
+ bw.write(NEW_LINE);
+ dumpMostTime(info, bw);
+ bw.write(NEW_LINE);
+ dumpAllocations(snapshot, bw);
+ bw.write(NEW_LINE);
+
+ Collections.sort(classes, new TimedClassComparator(TimedClassComparator.NAME));
+
+ bw.write("Classes:" + NEW_LINE);
+ bw.write("========" + NEW_LINE);
+
+ for (TimedClassInfo tci: classes) {
+ bw.write(Util.getPrettyName(tci) + "\t");
+ bw.write(Util.getDescription(tci) + "\t");
+ bw.write(df.format(tci.getTotalTime()) + " ms");
+ bw.write(NEW_LINE);
+ }
+
+ bw.flush();
+ bw.close();
+ }
+
+ /**
+ * Dump the threads to a file writer
+ * @param threads The threads
+ * @param directory The directory
+ * @exception Exception If an error occurs
+ */
+ protected void dumpThreads(List<ThreadInfo> threads, String directory) throws Exception {
+ File f = new File(directory + "threads");
+ f.mkdirs();
+
+ for (ThreadInfo ti: threads) {
+ FileWriter ftw = new FileWriter(directory + "threads" + File.separator +
+ "thread-" + ti.getId() + ".txt");
+ BufferedWriter bw = new BufferedWriter(ftw, 8192);
+
+ bw.write("Thread: " + ti.getId() + NEW_LINE);
+ bw.write("Name: " + ti.getName() + NEW_LINE);
+ bw.write("Priority: " + ti.getPriority() + NEW_LINE);
+ bw.write("Daemon: " + ti.isDaemon() + NEW_LINE);
+
+ if (ti.getGroups() != null) {
+ bw.write("Groups: ");
+
+ Iterator it = ti.getGroups().iterator();
+ while (it.hasNext()) {
+ String g = (String)it.next();
+ bw.write(g);
+ if (it.hasNext()) {
+ bw.write(" -> ");
+ }
+ }
+
+ bw.write(NEW_LINE);
+ }
+
+ bw.write(NEW_LINE);
+
+ int frameNumber = 1;
+
+ for (FrameInfo fi: ti.getFrames()) {
+ dumpFrame(fi, frameNumber, bw);
+ frameNumber++;
+ bw.write(NEW_LINE);
+ }
+ bw.flush();
+ bw.close();
+ }
+ }
+
+ /**
+ * Dump the frame to a file writer
+ * @param fi The frame
+ * @param fn The frame number
+ * @param w The writer
+ * @exception Exception If an error occurs
+ */
+ protected void dumpFrame(FrameInfo fi, int fn, Writer w) throws Exception {
+ w.write("Frame: " + fn + NEW_LINE);
+ w.write("Count\tMs (T)\tMs (N)\t% (T)\t% (N)\tMethod" + NEW_LINE);
+
+ long totalTime = fi.getTotalTime();
+ dumpFrame(fi, 0, (double)totalTime, w);
+ }
+
+ /**
+ * Dump the frame to a file writer
+ * @param fi The frame
+ * @param level The level
+ * @param tt The total time
+ * @param w The writer
+ * @exception Exception If an error occurs
+ */
+ protected void dumpFrame(FrameInfo fi, int level, double tt, Writer w) throws Exception {
+ DecimalFormat df = new DecimalFormat("#0.00");
+
+ long total = fi.getTotalTime();
+ long net = fi.getNetTime();
+
+ w.write(fi.getCount() + "\t");
+ w.write(df.format(Math.nanoToMilli(total)) + "\t");
+ w.write(df.format(Math.nanoToMilli(net)) + "\t");
+ w.write(df.format(Math.toPercent(total, tt)) + "\t");
+ w.write(df.format(Math.toPercent(net, tt)) + "\t");
+
+ for (int i = 0; i < level; i++) {
+ w.write("+");
+ }
+ if (level > 0) {
+ w.write(" ");
+ }
+
+ w.write(Util.getPrettyName(fi.getMethod()));
+ w.write(NEW_LINE);
+
+ List<FrameInfo> l = fi.getChildren();
+ if (l != null) {
+ for (FrameInfo child: l) {
+ dumpFrame(child, level + 1, tt, w);
+ }
+ }
+ }
+
+ /**
+ * Dump the most time to a file writer
+ * @param info The information
+ * @param w The writer
+ * @exception Exception If an error occurs
+ */
+ protected void dumpMostTime(Map<String, List<CombinedFrameInfo>> info, Writer w) throws Exception {
+ w.write("Most time:" + NEW_LINE);
+ w.write("==========" + NEW_LINE);
+ w.write("Count\tMs\t%\tMethod" + NEW_LINE);
+
+ List<CombinedFrameInfo> allMethods = new ArrayList<CombinedFrameInfo>();
+
+ Iterator it = info.values().iterator();
+ while (it.hasNext()) {
+ List<CombinedFrameInfo> l = (List<CombinedFrameInfo>)it.next();
+ allMethods.addAll(l);
+ }
+
+ Collections.sort(allMethods, new CombinedFrameComparator(CombinedFrameComparator.TOTAL_TIME));
+
+ DecimalFormat df = new DecimalFormat("#0.00");
+
+ for (int i = 0; i < 10 && i < allMethods.size(); i++) {
+ CombinedFrameInfo cfi = allMethods.get(i);
+
+ w.write(cfi.getCount() + "\t");
+ w.write(df.format(cfi.getTotalTime()) + "\t");
+ w.write(df.format(cfi.getPercent()) + "\t");
+ w.write(cfi.getPrettyName() + NEW_LINE);
+ }
+
+ w.write(NEW_LINE);
+ dumpHotspot(allMethods, 10, w);
+ }
+
+ /**
+ * Dump the methods
+ * @param info The information
+ * @param directory The directory
+ * @exception Exception If an error occurs
+ */
+ protected void dumpMethods(Map<String, List<CombinedFrameInfo>> info,
+ String directory) throws Exception {
+
+ List<CombinedFrameInfo> methods = new ArrayList<CombinedFrameInfo>();
+
+ Iterator it = info.values().iterator();
+ while (it.hasNext()) {
+ List<CombinedFrameInfo> l = (List<CombinedFrameInfo>)it.next();
+ methods.addAll(l);
+ }
+
+ FileWriter fw = new FileWriter(directory + "methods.txt");
+ BufferedWriter bw = new BufferedWriter(fw, 8192);
+
+ bw.write("Methods:" + NEW_LINE);
+ bw.write("--------" + NEW_LINE);
+ bw.write("Count\tMs\tAvg\t%\tMethod" + NEW_LINE);
+
+ Collections.sort(methods, new CombinedFrameComparator(CombinedFrameComparator.TOTAL_TIME));
+
+ DecimalFormat df = new DecimalFormat("#0.00");
+
+ int count = 0;
+
+ for (int i = 0; i < methods.size(); i++) {
+ CombinedFrameInfo h = methods.get(i);
+
+ if (h.getTotalTime() >= threshold) {
+ double avg = h.getTotalTime() / h.getCount();
+
+ bw.write(h.getCount() + "\t");
+ bw.write(df.format(h.getTotalTime()) + "\t");
+ bw.write(df.format(avg) + "\t");
+ bw.write(df.format(h.getPercent()) + "\t");
+ bw.write(h.getPrettyName() + NEW_LINE);
+ } else {
+ count++;
+ }
+ }
+
+ if (count > 0) {
+ bw.write(NEW_LINE);
+ bw.write(count + " methods below threshold." + NEW_LINE);
+ }
+
+ bw.flush();
+ bw.close();
+ }
+
+ /**
+ * Dump the hotspots
+ * @param info The information
+ * @param directory The directory
+ * @exception Exception If an error occurs
+ */
+ protected void dumpHotspots(Map<String, List<CombinedFrameInfo>> info,
+ String directory) throws Exception {
+
+ List<CombinedFrameInfo> hotspots = new ArrayList<CombinedFrameInfo>();
+
+ Iterator it = info.values().iterator();
+ while (it.hasNext()) {
+ List<CombinedFrameInfo> l = (List<CombinedFrameInfo>)it.next();
+ hotspots.addAll(l);
+ }
+
+ FileWriter fw = new FileWriter(directory + "hotspots.txt");
+ BufferedWriter bw = new BufferedWriter(fw, 8192);
+
+ bw.write("Hotspots:" + NEW_LINE);
+ bw.write("---------" + NEW_LINE);
+ bw.write("Count\tMs\tAvg\t%\tMethod" + NEW_LINE);
+
+ Collections.sort(hotspots, new CombinedFrameComparator(CombinedFrameComparator.TOTAL_TIME_AVG));
+
+ DecimalFormat df = new DecimalFormat("#0.00");
+
+ int count = 0;
+
+ for (int i = 0; i < hotspots.size(); i++) {
+ CombinedFrameInfo h = hotspots.get(i);
+
+ double avg = h.getTotalTime() / h.getCount();
+
+ if (avg >= threshold) {
+ bw.write(h.getCount() + "\t");
+ bw.write(df.format(h.getTotalTime()) + "\t");
+ bw.write(df.format(avg) + "\t");
+ bw.write(df.format(h.getPercent()) + "\t");
+ bw.write(h.getPrettyName() + NEW_LINE);
+ } else {
+ count++;
+ }
+ }
+
+ if (count > 0) {
+ bw.write(NEW_LINE);
+ bw.write(count + " methods below threshold." + NEW_LINE);
+ }
+
+ bw.flush();
+ bw.close();
+ }
+
+ /**
+ * Dump the hotspots to a file writer
+ * @param hotspots The hotspots
+ * @param max The maximum hotspots
+ * @param w The writer
+ * @exception Exception If an error occurs
+ */
+ protected void dumpHotspot(List<CombinedFrameInfo> hotspots, int max, Writer w) throws Exception {
+ w.write("Hotspots:" + NEW_LINE);
+ w.write("=========" + NEW_LINE);
+ w.write("Count\tMs\tAvg\t%\tMethod" + NEW_LINE);
+
+ if (hotspots != null) {
+ Collections.sort(hotspots, new CombinedFrameComparator(CombinedFrameComparator.TOTAL_TIME_AVG));
+
+ DecimalFormat df = new DecimalFormat("#0.00");
+
+ int count = 0;
+
+ for (int i = 0; i < max && i < hotspots.size(); i++) {
+ CombinedFrameInfo h = hotspots.get(i);
+
+ double avg = h.getTotalTime() / h.getCount();
+
+ if (avg >= threshold) {
+ w.write(h.getCount() + "\t");
+ w.write(df.format(h.getTotalTime()) + "\t");
+ w.write(df.format(avg) + "\t");
+ w.write(df.format(h.getPercent()) + "\t");
+ w.write(h.getPrettyName() + NEW_LINE);
+ } else {
+ count++;
+ }
+ }
+
+ if (count > 0) {
+ w.write(NEW_LINE);
+ w.write(count + " methods below threshold." + NEW_LINE);
+ }
+ }
+ }
+
+ /**
+ * Dump the allocations to a file writer
+ * @param snapshot The snapshot
+ * @param w The file writer
+ * @exception Exception If an error occurs
+ */
+ protected void dumpAllocations(Snapshot snapshot, Writer w) throws Exception {
+ if (snapshot.getAllocations() != null && snapshot.getAllocations().size() > 0) {
+ Collections.sort(snapshot.getAllocations(), new AllocationComparator());
+
+ w.write("Allocations:" + NEW_LINE);
+ w.write("============" + NEW_LINE);
+
+ for (AllocationInfo ai: snapshot.getAllocations()) {
+ w.write(ai.getClassName() + "\t" + ai.getCount() + NEW_LINE);
+ }
+ }
+ }
+
+ /**
+ * Dump the classes to a file writer
+ * @param classes The classes
+ * @param allocs The allocations
+ * @param directory The directory
+ * @exception Exception If an error occurs
+ */
+ protected void dumpClasses(List<TimedClassInfo> classes,
+ Map<String, List<CombinedFrameInfo>> info,
+ List<AllocationInfo> allocs,
+ String directory) throws Exception {
+ File f = new File(directory + "classes");
+ f.mkdirs();
+
+ Collections.sort(classes, new TimedClassComparator(TimedClassComparator.TOTAL_TIME));
+
+ DecimalFormat df = new DecimalFormat("#0.00");
+
+ FileWriter fw = new FileWriter(directory + "classes.txt");
+ BufferedWriter bw = new BufferedWriter(fw, 8192);
+
+ bw.write("Classes:" + NEW_LINE);
+ bw.write("--------" + NEW_LINE);
+
+ for (TimedClassInfo tci: classes) {
+ bw.write(Util.getPrettyName(tci) + "\t");
+ bw.write(Util.getDescription(tci) + "\t");
+ bw.write(df.format(tci.getTotalTime()) + " ms" + NEW_LINE);
+
+ List<CombinedFrameInfo> l = info.get(tci.getClassName());
+ dumpClass(tci, l, allocs, directory);
+ }
+
+ bw.flush();
+ bw.close();
+ }
+
+ /**
+ * Dump the class to a file writer
+ * @param tci The timed class
+ * @param cfs The combined frames
+ * @param allocs The allocations
+ * @param directory The directory
+ * @exception Exception If an error occurs
+ */
+ protected void dumpClass(TimedClassInfo tci,
+ List<CombinedFrameInfo> cfs,
+ List<AllocationInfo> allocs,
+ String directory) throws Exception {
+
+ String prettyClassName = Util.getPrettyName(tci);
+ FileWriter fcw = new FileWriter(directory + "classes" + File.separator +
+ prettyClassName + ".txt");
+ BufferedWriter bw = new BufferedWriter(fcw, 8192);
+
+ bw.write(Util.getPrettyName(tci) + "\t" + Util.getDescription(tci) + NEW_LINE);
+
+ DecimalFormat df = new DecimalFormat("#0.00");
+
+ bw.write("Total time: " + df.format(tci.getTotalTime()) + " ms" + NEW_LINE);
+ bw.write(" Wait time: " + df.format(tci.getWaitTime()) + " ms" + NEW_LINE);
+
+ if (allocs != null && allocs.size() > 0) {
+ long alloc = 0;
+ boolean found = false;
+
+ for (int i = 0; !found && i < allocs.size(); i++) {
+ AllocationInfo ai = allocs.get(i);
+ if (ai.getClassName().equals(prettyClassName)) {
+ alloc = ai.getCount();
+ found = true;
+ }
+ }
+
+ if (alloc < 2) {
+ bw.write(alloc + " allocation" + NEW_LINE);
+ } else {
+ bw.write(alloc + " allocations" + NEW_LINE);
+ }
+ }
+
+ bw.write(NEW_LINE);
+
+ bw.write("Methods:" + NEW_LINE);
+ bw.write("========" + NEW_LINE);
+ bw.write("Count\tMs\t% (C)\t% (T)\tMethod" + NEW_LINE);
+
+ if (cfs != null) {
+ Collections.sort(cfs, new CombinedFrameComparator(CombinedFrameComparator.TOTAL_TIME));
+
+ for (CombinedFrameInfo cfi : cfs) {
+ bw.write(cfi.getCount() + "\t");
+ bw.write(df.format(cfi.getTotalTime()) + "\t");
+ bw.write(df.format(Math.toPercent(cfi.getTotalTime(), tci.getTotalTime())) + "\t");
+ bw.write(df.format(cfi.getPercent()) + "\t");
+ bw.write(cfi.getPrettyName() + NEW_LINE);
+ }
+ }
+
+ bw.write(NEW_LINE);
+ dumpHotspot(cfs, Integer.MAX_VALUE, bw);
+
+ bw.flush();
+ bw.close();
+ }
+}
Added: branches/JBossProfiler2/src/main/org/jboss/profiler/client/ThreadHolder.java
===================================================================
--- branches/JBossProfiler2/src/main/org/jboss/profiler/client/ThreadHolder.java (rev 0)
+++ branches/JBossProfiler2/src/main/org/jboss/profiler/client/ThreadHolder.java 2008-02-10 10:59:33 UTC (rev 420)
@@ -0,0 +1,76 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2007, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file 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.client;
+
+import org.jboss.profiler.shared.ThreadInfo;
+
+/**
+ * The thread info holder class
+ * @author Jesper Pedersen <jep at worldleaguesports.com>
+ */
+public class ThreadHolder {
+
+ /** The score */
+ private double score;
+
+ /** The old thread */
+ private ThreadInfo oldThread;
+
+ /** The new thread */
+ private ThreadInfo newThread;
+
+ /**
+ * Constructor
+ * @param ot The old thread
+ * @param nt The new thread
+ * @param sc The score
+ */
+ public ThreadHolder(ThreadInfo ot, ThreadInfo nt, double sc) {
+ oldThread = ot;
+ newThread = nt;
+ score = sc;
+ }
+
+ /**
+ * Get the old thread
+ * @return The old thread
+ */
+ public ThreadInfo getOld() {
+ return oldThread;
+ }
+
+ /**
+ * Get the new thread
+ * @return The new thread
+ */
+ public ThreadInfo getNew() {
+ return newThread;
+ }
+
+ /**
+ * Get the score
+ * @return The score
+ */
+ public double getScore() {
+ return score;
+ }
+}
Added: branches/JBossProfiler2/src/main/org/jboss/profiler/client/TimedClassComparator.java
===================================================================
--- branches/JBossProfiler2/src/main/org/jboss/profiler/client/TimedClassComparator.java (rev 0)
+++ branches/JBossProfiler2/src/main/org/jboss/profiler/client/TimedClassComparator.java 2008-02-10 10:59:33 UTC (rev 420)
@@ -0,0 +1,68 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2007, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file 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.client;
+
+import java.util.Comparator;
+
+/**
+ * Timed class comparator
+ * @author Jesper Pedersen <jep at worldleaguesports.com>
+ */
+public class TimedClassComparator implements Comparator<TimedClassInfo> {
+
+ /** Method: TOTAL TIME */
+ public static final int TOTAL_TIME = 0;
+
+ /** Method: NAME */
+ public static final int NAME = 1;
+
+ /** The method */
+ private int method;
+
+ /**
+ * Constructor
+ * @param method The method
+ */
+ public TimedClassComparator(int method) {
+ this.method = method;
+ }
+
+ /**
+ * Compare two objects
+ * @param ta Timed class info
+ * @param tb Timed class info
+ * @return Positive if tb greater than ta; zero if equal otherwise negative
+ */
+ public int compare(TimedClassInfo ta, TimedClassInfo tb) {
+ if (method == TOTAL_TIME) {
+ if (ta.getTotalTime() < tb.getTotalTime()) {
+ return 1;
+ } else if (ta.getTotalTime() == tb.getTotalTime()) {
+ return ta.getClassName().compareTo(tb.getClassName());
+ } else {
+ return -1;
+ }
+ } else {
+ return ta.getClassName().compareTo(tb.getClassName());
+ }
+ }
+}
Added: branches/JBossProfiler2/src/main/org/jboss/profiler/client/TimedClassInfo.java
===================================================================
--- branches/JBossProfiler2/src/main/org/jboss/profiler/client/TimedClassInfo.java (rev 0)
+++ branches/JBossProfiler2/src/main/org/jboss/profiler/client/TimedClassInfo.java 2008-02-10 10:59:33 UTC (rev 420)
@@ -0,0 +1,67 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2007, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file 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.client;
+
+import org.jboss.profiler.shared.ClassInfo;
+
+import java.io.Serializable;
+
+/**
+ * Represents a timed class
+ * @author Jesper Pedersen <jep at worldleaguesports.com>
+ */
+public class TimedClassInfo extends ClassInfo {
+
+ /** The time */
+ private double time;
+
+ /** The wait time */
+ private double wait;
+
+ /**
+ * Constructor
+ * @param ci The class info
+ * @param time The total time (ms)
+ * @param wait The wait time (ms)
+ */
+ public TimedClassInfo(ClassInfo ci, double time, double wait) {
+ super(ci.getClassName(), ci.getClassType());
+ this.time = time;
+ this.wait = wait;
+ }
+
+ /**
+ * Get the time (ms)
+ * @return The time
+ */
+ public double getTotalTime() {
+ return time;
+ }
+
+ /**
+ * Get the wait time (ms)
+ * @return The wait time
+ */
+ public double getWaitTime() {
+ return wait;
+ }
+}
Added: branches/JBossProfiler2/src/main/org/jboss/profiler/client/Util.java
===================================================================
--- branches/JBossProfiler2/src/main/org/jboss/profiler/client/Util.java (rev 0)
+++ branches/JBossProfiler2/src/main/org/jboss/profiler/client/Util.java 2008-02-10 10:59:33 UTC (rev 420)
@@ -0,0 +1,199 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2007, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file 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.client;
+
+import org.jboss.profiler.shared.ClassInfo;
+import org.jboss.profiler.shared.ClassType;
+import org.jboss.profiler.shared.MethodInfo;
+import org.jboss.profiler.shared.Plugin;
+
+import java.util.List;
+
+import org.jboss.logging.Logger;
+
+/**
+ * The utility class
+ * @author Jesper Pedersen <jep at worldleaguesports.com>
+ */
+public class Util {
+ /** The logger */
+ private static Logger log = Logger.getLogger(Util.class);
+
+ /** The plugins */
+ private static List<Plugin> plugins;
+
+ /**
+ * Set the list of plugins
+ * @param ps The plugins
+ */
+ public static void setPlugins(List<Plugin> ps) {
+ plugins = ps;
+ }
+
+ /**
+ * Get the class type description
+ * @param ci The class info
+ * @return The description
+ */
+ public static String getDescription(ClassInfo ci) {
+ if (ClassType.POJO == ci.getClassType()) {
+ return "POJO";
+ } else if (ClassType.THROWABLE == ci.getClassType()) {
+ return "THROWABLE";
+ } else if (ClassType.EJB_SESSION == ci.getClassType()) {
+ return "EJB_SESSION";
+ } else if (ClassType.EJB_ENTITY == ci.getClassType()) {
+ return "EJB_ENTITY";
+ } else if (ClassType.EJB_MESSAGE == ci.getClassType()) {
+ return "EJB_MESSAGE";
+ } else if (ClassType.SERVLET == ci.getClassType()) {
+ return "SERVLET";
+ } else if (ClassType.SERVLET_FILTER == ci.getClassType()) {
+ return "SERVLET_FILTER";
+ } else if (ClassType.JSP == ci.getClassType()) {
+ return "JSP";
+ } else if (ClassType.JMX_MBEAN == ci.getClassType()) {
+ return "JMX_MBEAN";
+ } else if (ClassType.JSF_CONVERTER == ci.getClassType()) {
+ return "JSF_CONVERTER";
+ } else if (ClassType.JSF_MANAGED_BEAN == ci.getClassType()) {
+ return "JSF_MANAGED_BEAN";
+ } else if (ClassType.RMI_REMOTE == ci.getClassType()) {
+ return "RMI_REMOTE";
+ } else if (ClassType.RMI_SERVER == ci.getClassType()) {
+ return "RMI_SERVER";
+ } else if (ClassType.CORBA_OBJECT == ci.getClassType()) {
+ return "CORBA_OBJECT";
+ } else if (ClassType.CORBA_SERVANT == ci.getClassType()) {
+ return "CORBA_SERVANT";
+ }
+
+ if (plugins != null) {
+ for (Plugin p : plugins) {
+ String description = p.getDescription(ci.getClassType());
+ if (description != null) {
+ return description;
+ }
+ }
+ }
+
+ return "UNKNOWN (" + ci.getClassType() + ")";
+ }
+
+ /**
+ * Get pretty name
+ * @param ci The class info
+ * @return The pretty name
+ */
+ public static String getPrettyName(ClassInfo ci) {
+ return ci.getClassName().replace('/', '.');
+ }
+
+ /**
+ * Get pretty name
+ * @param mi The method info
+ * @return The pretty name
+ */
+ public static String getPrettyName(MethodInfo mi) {
+ StringBuffer sb = new StringBuffer(mi.getClassName().replace('/', '.'));
+ sb = sb.append('#');
+
+ String m = mi.getMethodName();
+
+ m = m.replace('/', '.');
+ m = m.substring(0, m.indexOf(")") + 1);
+
+ int start = m.indexOf("(");
+ int end = m.indexOf(")");
+
+ sb = sb.append(m.substring(0, start + 1));
+
+ if (start + 1 != end) {
+ String input = m.substring(start + 1, end);
+ String postfix = "";
+
+ while (input != null && input.length() > 0) {
+ char c = input.charAt(0);
+
+ while (c == '[') {
+ postfix += "[]";
+ input = input.substring(1);
+ c = input.charAt(0);
+ }
+
+ if (c == 'Z') {
+ sb = sb.append("boolean");
+ input = input.substring(1);
+ } else if (c == 'B') {
+ sb = sb.append("byte");
+ input = input.substring(1);
+ } else if (c == 'C') {
+ sb = sb.append("char");
+ input = input.substring(1);
+ } else if (c == 'D') {
+ sb = sb.append("double");
+ input = input.substring(1);
+ } else if (c == 'F') {
+ sb = sb.append("float");
+ input = input.substring(1);
+ } else if (c == 'I') {
+ sb = sb.append("int");
+ input = input.substring(1);
+ } else if (c == 'J') {
+ sb = sb.append("long");
+ input = input.substring(1);
+ } else if (c == 'S') {
+ sb = sb.append("short");
+ input = input.substring(1);
+ } else {
+ int cEnd = input.indexOf(";");
+ String clz = input.substring(1, cEnd);
+ if (cEnd + 1 < input.length()) {
+ input = input.substring(cEnd + 1);
+ } else {
+ input = "";
+ }
+ int jl = clz.indexOf("java.lang");
+ if (jl != -1) {
+ if (clz.indexOf(".", jl + 10) == -1) {
+ clz = clz.replace("java.lang.", "");
+ }
+ }
+ sb = sb.append(clz);
+ }
+
+ if (postfix.length() > 0) {
+ sb = sb.append(postfix);
+ postfix = "";
+ }
+
+ if (input != null && input.length() > 0) {
+ sb = sb.append(", ");
+ }
+ }
+ }
+
+ sb = sb.append(")");
+
+ return sb.toString();
+ }
+}
Added: branches/JBossProfiler2/src/main/org/jboss/profiler/client/cmd/Client.java
===================================================================
--- branches/JBossProfiler2/src/main/org/jboss/profiler/client/cmd/Client.java (rev 0)
+++ branches/JBossProfiler2/src/main/org/jboss/profiler/client/cmd/Client.java 2008-02-10 10:59:33 UTC (rev 420)
@@ -0,0 +1,341 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2007, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file 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.client.cmd;
+
+import org.jboss.profiler.client.DifferenceUtil;
+import org.jboss.profiler.client.SnapshotUtil;
+import org.jboss.profiler.client.Util;
+import org.jboss.profiler.shared.Command;
+import org.jboss.profiler.shared.CommandType;
+import org.jboss.profiler.shared.Plugin;
+import org.jboss.profiler.shared.PluginHelper;
+import org.jboss.profiler.shared.Snapshot;
+import org.jboss.profiler.shared.SnapshotHelper;
+import org.jboss.profiler.shared.Visibility;
+
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.InputStream;
+import java.io.IOException;
+import java.text.DecimalFormat;
+import java.util.Map;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Properties;
+
+import org.jboss.remoting.InvokerLocator;
+
+import org.jboss.logging.Logger;
+
+/**
+ * The client
+ * @author Jesper Pedersen <jep at worldleaguesports.com>
+ */
+public class Client {
+ /** The logger */
+ private static Logger log = Logger.getLogger(Client.class);
+
+ /**
+ * The usage method
+ */
+ private static void usage() {
+ System.out.println("Usage: Client [-h host] [-p port] <command>");
+ System.out.println(" startProfiler : Start the profiler");
+ System.out.println(" stopProfiler : Stop the profiler");
+ System.out.println(" snapshot : Take a snapshot");
+ System.out.println(" getSnapshot : Get a snapshot");
+ System.out.println(" listSnapshots : List snapshots");
+ System.out.println(" clearSnapshots : Clear snapshots");
+ System.out.println(" gc : Trigger garbage collection");
+ System.out.println(" enable : Enable the profiler");
+ System.out.println(" disable : Disable the profiler");
+ System.out.println(" load : Load a snapshot");
+ System.out.println(" save : Save a snapshot");
+ System.out.println(" diff : Difference between snapshots");
+ System.out.println(" add : Add classes (repository must be enabled)");
+ System.out.println(" remove : Remove classes (repository must be enabled)");
+ }
+
+ /**
+ * The emain method
+ * @param args The arguments
+ */
+ public static void main(String[] args) {
+ if (args.length > 0) {
+ try {
+ String protocol = "socket";
+ String host = "localhost";
+ int port = 5400;
+ double threshold = 1.0;
+
+ Properties properties = new Properties();
+ String propertiesFile = System.getProperty("jboss-profiler-client.properties");
+ boolean loaded = false;
+
+ if (propertiesFile != null) {
+ FileInputStream fis = null;
+ try {
+ fis = new FileInputStream(propertiesFile);
+ properties.load(fis);
+ loaded = true;
+ } catch (IOException e) {
+ System.err.println("Unable to open " + propertiesFile);
+ } finally {
+ if (fis != null) {
+ try {
+ fis.close();
+ } catch (IOException ioe) {
+ // Nothing to do
+ }
+ }
+ }
+ }
+ if (!loaded) {
+ InputStream is = null;
+ try {
+ ClassLoader cl = Thread.currentThread().getContextClassLoader();
+ is = cl.getResourceAsStream("jboss-profiler-client.properties");
+ properties.load(is);
+ loaded = true;
+ } catch (Exception ie) {
+ // Properties file not found
+ } finally {
+ if (is != null) {
+ try {
+ is.close();
+ } catch (IOException ioe) {
+ // Nothing to do
+ }
+ }
+ }
+ }
+
+ if (loaded) {
+ protocol = properties.getProperty("protocol", "socket");
+ host = properties.getProperty("host", "localhost");
+ port = Integer.valueOf(properties.getProperty("port", "5400"));
+ threshold = Double.valueOf(properties.getProperty("threshold", "1.0"));
+ List<Plugin> plugins = PluginHelper.load(properties);
+ if (plugins.size() > 0) {
+ Util.setPlugins(plugins);
+ }
+ }
+
+ int i = 0;
+
+ if ("-h".equalsIgnoreCase(args[i])) {
+ i++;
+ host = args[i];
+ i++;
+ }
+ if ("-p".equalsIgnoreCase(args[i])) {
+ i++;
+ port = Integer.valueOf(args[i]);
+ i++;
+ }
+
+ String cmdStr = args[i];
+ i++;
+
+ Command cmd = null;
+
+ if (cmdStr.equalsIgnoreCase("startProfiler")) {
+ cmd = new Command(CommandType.START_PROFILER);
+ } else if (cmdStr.equalsIgnoreCase("stopProfiler")) {
+ cmd = new Command(CommandType.STOP_PROFILER);
+ } else if (cmdStr.equalsIgnoreCase("snapshot")) {
+ cmd = new Command(CommandType.SNAPSHOT);
+ } else if (cmdStr.equalsIgnoreCase("getSnapshot")) {
+ if (i < args.length) {
+ cmd = new Command(CommandType.GET_SNAPSHOT, new Object[] {Integer.valueOf(args[i]) });
+ i++;
+ }
+ } else if (cmdStr.equalsIgnoreCase("listSnapshots")) {
+ cmd = new Command(CommandType.LIST_SNAPSHOTS);
+ } else if (cmdStr.equalsIgnoreCase("clearSnapshots")) {
+ cmd = new Command(CommandType.CLEAR_SNAPSHOTS);
+ } else if (cmdStr.equalsIgnoreCase("gc")) {
+ cmd = new Command(CommandType.GC);
+ } else if (cmdStr.equalsIgnoreCase("enable")) {
+ cmd = new Command(CommandType.ENABLE);
+ } else if (cmdStr.equalsIgnoreCase("disable")) {
+ cmd = new Command(CommandType.DISABLE);
+ } else if (cmdStr.equalsIgnoreCase("load")) {
+ if (i < args.length) {
+ cmd = new Command(CommandType.LOAD, new Object[] { args[i] } );
+ i++;
+ }
+ } else if (cmdStr.equalsIgnoreCase("save")) {
+ Integer number = null;
+ String filename = null;
+
+ if (i < args.length) {
+ number= Integer.valueOf(args[i]);
+ i++;
+ }
+ if (i < args.length) {
+ filename = args[i];
+ i++;
+ }
+ cmd = new Command(CommandType.SAVE, new Object[] { number, filename } );
+
+ } else if (cmdStr.equalsIgnoreCase("diff")) {
+ String filename1 = null;
+ String filename2 = null;
+
+ if (i < args.length) {
+ filename1 = args[i];
+ i++;
+ }
+ if (i < args.length) {
+ filename2 = args[i];
+ i++;
+ }
+ cmd = new Command(CommandType.DIFFERENCE, new Object[] { filename1, filename2 } );
+ } else if (cmdStr.equalsIgnoreCase("add")) {
+ if (i + 1 < args.length) {
+ String clz = args[i];
+ Visibility v = Visibility.PUBLIC;
+ if (args[i + 1].equalsIgnoreCase("private")) {
+ v = Visibility.PRIVATE;
+ } else if (args[i + 1].equalsIgnoreCase("protected")) {
+ v = Visibility.PROTECTED;
+ }
+ cmd = new Command(CommandType.ADD_CLASSES, new Object[] { clz, v } );
+ i++;
+ i++;
+ }
+ } else if (cmdStr.equalsIgnoreCase("remove")) {
+ if (i < args.length) {
+ cmd = new Command(CommandType.REMOVE_CLASSES, new Object[] { args[i] } );
+ i++;
+ }
+ } else {
+ usage();
+ return;
+ }
+
+ if (cmd != null) {
+ InvokerLocator locator = new InvokerLocator(protocol + "://" + host + ":" + port);
+
+ org.jboss.remoting.Client remotingClient =
+ new org.jboss.remoting.Client(locator);
+ remotingClient.connect();
+
+ if (cmd.getCommand() == CommandType.START_PROFILER ||
+ cmd.getCommand() == CommandType.STOP_PROFILER ||
+ cmd.getCommand() == CommandType.CLEAR_SNAPSHOTS ||
+ cmd.getCommand() == CommandType.GC ||
+ cmd.getCommand() == CommandType.ENABLE ||
+ cmd.getCommand() == CommandType.DISABLE ||
+ cmd.getCommand() == CommandType.ADD_CLASSES ||
+ cmd.getCommand() == CommandType.REMOVE_CLASSES) {
+ String response = (String)remotingClient.invoke(cmd);
+ } else if (cmd.getCommand() == CommandType.SNAPSHOT ||
+ cmd.getCommand() == CommandType.GET_SNAPSHOT) {
+ Snapshot snapshot = (Snapshot)remotingClient.invoke(cmd);
+ if (snapshot != null) {
+ File f = new File(".");
+ SnapshotUtil su = new SnapshotUtil(threshold);
+ su.dump(snapshot, f);
+ }
+ } else if (cmd.getCommand() == CommandType.LIST_SNAPSHOTS) {
+ String[] result = (String[])remotingClient.invoke(cmd);
+ if (result != null) {
+ for (int j = 0; j < result.length; j++) {
+ System.out.println(result[j]);
+ }
+ }
+ } else if (cmd.getCommand() == CommandType.LOAD) {
+ File file = new File((String)cmd.getArguments()[0]);
+ if (file.exists()) {
+ Snapshot snapshot = null;
+
+ if (file.isFile()) {
+ snapshot = SnapshotHelper.load(file);
+ } else if (file.isDirectory()) {
+ snapshot = SnapshotHelper.generate(file);
+ }
+
+ if (snapshot != null) {
+ File f = new File(".");
+ SnapshotUtil su = new SnapshotUtil(threshold);
+ su.dump(snapshot, f);
+ }
+ }
+ } else if (cmd.getCommand() == CommandType.SAVE) {
+ Snapshot snapshot = (Snapshot)remotingClient.invoke(cmd);
+
+ if (snapshot != null) {
+ if (cmd.getArguments()[1] == null) {
+ SnapshotHelper.save(snapshot);
+ } else {
+ SnapshotHelper.save(snapshot, new File((String)cmd.getArguments()[1]));
+ }
+ }
+ } else if (cmd.getCommand() == CommandType.DIFFERENCE) {
+ File of = null;
+ if (cmd.getArguments()[0] != null) {
+ of = new File((String)cmd.getArguments()[0]);
+ }
+ File nf = null;
+ if (cmd.getArguments()[1] != null) {
+ nf = new File((String)cmd.getArguments()[1]);
+ }
+
+ Snapshot os = null;
+ Snapshot ns = null;
+
+ if (of != null && of.exists()) {
+ if (of.isFile()) {
+ os = SnapshotHelper.load(of);
+ } else if (of.isDirectory()) {
+ os = SnapshotHelper.generate(of);
+ }
+ }
+
+ if (nf != null && nf.exists()) {
+ if (nf.isFile()) {
+ ns = SnapshotHelper.load(nf);
+ } else if (nf.isDirectory()) {
+ ns = SnapshotHelper.generate(nf);
+ }
+ }
+
+ if (os != null && ns != null) {
+ DifferenceUtil du = new DifferenceUtil(threshold);
+
+ File f = new File(".");
+ du.dump(os, ns, f);
+ }
+ }
+
+ remotingClient.disconnect();
+ }
+ } catch (Throwable t) {
+ log.error(t.getMessage(), t);
+ }
+ } else {
+ usage();
+ }
+ }
+}
Added: branches/JBossProfiler2/src/main/org/jboss/profiler/connectors/AbstractHandler.java
===================================================================
--- branches/JBossProfiler2/src/main/org/jboss/profiler/connectors/AbstractHandler.java (rev 0)
+++ branches/JBossProfiler2/src/main/org/jboss/profiler/connectors/AbstractHandler.java 2008-02-10 10:59:33 UTC (rev 420)
@@ -0,0 +1,75 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2007, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file 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.connectors;
+
+import org.jboss.profiler.agent.Agent;
+import org.jboss.profiler.agent.Profiler;
+import org.jboss.profiler.shared.Command;
+import org.jboss.profiler.shared.CommandType;
+import org.jboss.profiler.shared.Visibility;
+
+/**
+ * The abstract handler class
+ * @author Jesper Pedersen <jep at worldleaguesports.com>
+ */
+public abstract class AbstractHandler {
+
+ /**
+ * Constructor
+ */
+ protected AbstractHandler() {
+ }
+
+ /**
+ * Handle commands
+ * @param cmd The command
+ * @return The result
+ */
+ protected Object handleCommand(Command cmd) {
+ if (cmd.getCommand() == CommandType.START_PROFILER && Agent.isEnabled()) {
+ Profiler.startProfiler();
+ } else if (cmd.getCommand() == CommandType.STOP_PROFILER && Agent.isEnabled()) {
+ Profiler.stopProfiler();
+ } else if (cmd.getCommand() == CommandType.SNAPSHOT && Agent.isEnabled()) {
+ return Profiler.snapshot();
+ } else if (cmd.getCommand() == CommandType.GET_SNAPSHOT ||
+ cmd.getCommand() == CommandType.SAVE) {
+ return Profiler.getSnapshot(((Integer)cmd.getArguments()[0]).intValue());
+ } else if (cmd.getCommand() == CommandType.LIST_SNAPSHOTS) {
+ return Profiler.listSnapshots();
+ } else if (cmd.getCommand() == CommandType.CLEAR_SNAPSHOTS) {
+ Profiler.clearSnapshots();
+ } else if (cmd.getCommand() == CommandType.GC && Agent.isEnabled()) {
+ Profiler.garbageCollection();
+ } else if (cmd.getCommand() == CommandType.ENABLE && !Agent.isEnabled()) {
+ Agent.setEnabled(true);
+ } else if (cmd.getCommand() == CommandType.DISABLE && Agent.isEnabled()) {
+ Profiler.stopProfiler();
+ Agent.setEnabled(false);
+ } else if (cmd.getCommand() == CommandType.ADD_CLASSES && Agent.isRepository()) {
+ Agent.addClasses((String)cmd.getArguments()[0], (Visibility)cmd.getArguments()[1]);
+ } else if (cmd.getCommand() == CommandType.REMOVE_CLASSES && Agent.isRepository()) {
+ Agent.removeClasses((String)cmd.getArguments()[0]);
+ }
+ return "";
+ }
+}
Added: branches/JBossProfiler2/src/main/org/jboss/profiler/connectors/HttpHandler.java
===================================================================
--- branches/JBossProfiler2/src/main/org/jboss/profiler/connectors/HttpHandler.java (rev 0)
+++ branches/JBossProfiler2/src/main/org/jboss/profiler/connectors/HttpHandler.java 2008-02-10 10:59:33 UTC (rev 420)
@@ -0,0 +1,54 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2007, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file 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.connectors;
+
+import org.jboss.profiler.shared.Command;
+
+import org.jboss.remoting.InvocationRequest;
+
+/**
+ * The HTTP handler class
+ * @author Jesper Pedersen <jep at worldleaguesports.com>
+ */
+public class HttpHandler extends RemoteHandler {
+
+ /**
+ * Constructor
+ */
+ public HttpHandler() {
+ }
+
+ /**
+ * Called to handle a specific invocation
+ * @param invocation The invocation
+ * @return The result
+ * @throws Throwable If an error occurs
+ */
+ public Object invoke(InvocationRequest invocation) throws Throwable {
+ if (invocation.getParameter() instanceof Command) {
+ Command cmd = (Command)invocation.getParameter();
+
+ return handleCommand(cmd);
+ }
+ return null;
+ }
+}
Added: branches/JBossProfiler2/src/main/org/jboss/profiler/connectors/LocalHandler.java
===================================================================
--- branches/JBossProfiler2/src/main/org/jboss/profiler/connectors/LocalHandler.java (rev 0)
+++ branches/JBossProfiler2/src/main/org/jboss/profiler/connectors/LocalHandler.java 2008-02-10 10:59:33 UTC (rev 420)
@@ -0,0 +1,46 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2007, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file 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.connectors;
+
+import org.jboss.profiler.shared.Command;
+
+/**
+ * The local handler class
+ * @author Jesper Pedersen <jep at worldleaguesports.com>
+ */
+public class LocalHandler extends AbstractHandler {
+
+ /**
+ * Constructor
+ */
+ public LocalHandler() {
+ }
+
+ /**
+ * Handle commands
+ * @param cmd The command
+ * @return The result
+ */
+ public Object handleCommand(Command cmd) {
+ return super.handleCommand(cmd);
+ }
+}
Added: branches/JBossProfiler2/src/main/org/jboss/profiler/connectors/RemoteHandler.java
===================================================================
--- branches/JBossProfiler2/src/main/org/jboss/profiler/connectors/RemoteHandler.java (rev 0)
+++ branches/JBossProfiler2/src/main/org/jboss/profiler/connectors/RemoteHandler.java 2008-02-10 10:59:33 UTC (rev 420)
@@ -0,0 +1,80 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2007, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file 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.connectors;
+
+import javax.management.MBeanServer;
+
+import org.jboss.remoting.InvocationRequest;
+import org.jboss.remoting.ServerInvocationHandler;
+import org.jboss.remoting.ServerInvoker;
+import org.jboss.remoting.callback.InvokerCallbackHandler;
+
+/**
+ * The remote handler class
+ * @author Jesper Pedersen <jep at worldleaguesports.com>
+ */
+public abstract class RemoteHandler extends AbstractHandler implements ServerInvocationHandler {
+
+ /**
+ * Constructor
+ */
+ protected RemoteHandler() {
+ }
+
+ /**
+ * Adds a callback handler that will listen for callbacks from
+ * the server invoker handler.
+ * @param callbackHandler The callback handler
+ */
+ public void addListener(InvokerCallbackHandler callbackHandler) {
+ }
+
+ /**
+ * Removes the callback handler that was listening for callbacks
+ * from the server invoker handler.
+ * @param callbackHandler The callback handler
+ */
+ public void removeListener(InvokerCallbackHandler callbackHandler) {
+ }
+
+ /**
+ * Set the mbean server that the handler can reference
+ * @param server The MBean server
+ */
+ public void setMBeanServer(MBeanServer server) {
+ }
+
+ /**
+ * Set the invoker that owns this handler
+ * @param invoker The invoker
+ */
+ public void setInvoker(ServerInvoker invoker) {
+ }
+
+ /**
+ * Called to handle a specific invocation
+ * @param invocation The invocation
+ * @return The result
+ * @throws Throwable If an error occurs
+ */
+ public abstract Object invoke(InvocationRequest invocation) throws Throwable;
+}
Added: branches/JBossProfiler2/src/main/org/jboss/profiler/connectors/RmiHandler.java
===================================================================
--- branches/JBossProfiler2/src/main/org/jboss/profiler/connectors/RmiHandler.java (rev 0)
+++ branches/JBossProfiler2/src/main/org/jboss/profiler/connectors/RmiHandler.java 2008-02-10 10:59:33 UTC (rev 420)
@@ -0,0 +1,54 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2007, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file 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.connectors;
+
+import org.jboss.profiler.shared.Command;
+
+import org.jboss.remoting.InvocationRequest;
+
+/**
+ * The RMI handler class
+ * @author Jesper Pedersen <jep at worldleaguesports.com>
+ */
+public class RmiHandler extends RemoteHandler {
+
+ /**
+ * Constructor
+ */
+ public RmiHandler() {
+ }
+
+ /**
+ * Called to handle a specific invocation
+ * @param invocation The invocation
+ * @return The result
+ * @throws Throwable If an error occurs
+ */
+ public Object invoke(InvocationRequest invocation) throws Throwable {
+ if (invocation.getParameter() instanceof Command) {
+ Command cmd = (Command)invocation.getParameter();
+
+ return handleCommand(cmd);
+ }
+ return null;
+ }
+}
Added: branches/JBossProfiler2/src/main/org/jboss/profiler/connectors/SocketHandler.java
===================================================================
--- branches/JBossProfiler2/src/main/org/jboss/profiler/connectors/SocketHandler.java (rev 0)
+++ branches/JBossProfiler2/src/main/org/jboss/profiler/connectors/SocketHandler.java 2008-02-10 10:59:33 UTC (rev 420)
@@ -0,0 +1,54 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2007, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file 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.connectors;
+
+import org.jboss.profiler.shared.Command;
+
+import org.jboss.remoting.InvocationRequest;
+
+/**
+ * The socket handler class
+ * @author Jesper Pedersen <jep at worldleaguesports.com>
+ */
+public class SocketHandler extends RemoteHandler {
+
+ /**
+ * Constructor
+ */
+ public SocketHandler() {
+ }
+
+ /**
+ * Called to handle a specific invocation
+ * @param invocation The invocation
+ * @return The result
+ * @throws Throwable If an error occurs
+ */
+ public Object invoke(InvocationRequest invocation) throws Throwable {
+ if (invocation.getParameter() instanceof Command) {
+ Command cmd = (Command)invocation.getParameter();
+
+ return handleCommand(cmd);
+ }
+ return null;
+ }
+}
Added: branches/JBossProfiler2/src/main/org/jboss/profiler/package.html
===================================================================
--- branches/JBossProfiler2/src/main/org/jboss/profiler/package.html (rev 0)
+++ branches/JBossProfiler2/src/main/org/jboss/profiler/package.html 2008-02-10 10:59:33 UTC (rev 420)
@@ -0,0 +1,3 @@
+<body>
+JBoss Profiler 2
+</body>
Added: branches/JBossProfiler2/src/main/org/jboss/profiler/plugins/Hibernate.java
===================================================================
--- branches/JBossProfiler2/src/main/org/jboss/profiler/plugins/Hibernate.java (rev 0)
+++ branches/JBossProfiler2/src/main/org/jboss/profiler/plugins/Hibernate.java 2008-02-10 10:59:33 UTC (rev 420)
@@ -0,0 +1,268 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2007, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file 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.plugins;
+
+import org.jboss.profiler.shared.Plugin;
+
+import java.lang.annotation.Annotation;
+import java.io.IOException;
+import java.io.InputStream;
+import java.util.HashSet;
+import java.util.Set;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.ArrayList;
+import java.util.List;
+
+import javax.xml.parsers.DocumentBuilder;
+import javax.xml.parsers.DocumentBuilderFactory;
+
+import org.w3c.dom.Document;
+import org.w3c.dom.Node;
+import org.w3c.dom.NodeList;
+
+/**
+ * The Hibernate plugin
+ * @author Jesper Pedersen <jep at worldleaguesports.com>
+ */
+public class Hibernate implements Plugin {
+
+ /** The Hibernate constant */
+ private static final int HIBERNATE = 100;
+
+ /** The vendor */
+ private static final String VENDOR = "JBoss";
+
+ /** The product */
+ private static final String PRODUCT = "Hibernate Profiler Plugin";
+
+ /** The version */
+ private static final String VERSION = "1.0.CR1";
+
+ /** Full version */
+ private static final String FULL_VERSION = VENDOR + " " + PRODUCT + " " + VERSION;
+
+ /** HBM XML map */
+ private Map<ClassLoader, List<String>> hbmMap;
+
+ /** Known classes */
+ private Set<String> known;
+
+ /**
+ * Constructor
+ */
+ public Hibernate() {
+ known = new HashSet<String>();
+ hbmMap = new HashMap<ClassLoader, List<String>>();
+ }
+
+ /**
+ * Get the name of the plugin
+ * @return The name
+ */
+ public String getName() {
+ return FULL_VERSION;
+ }
+
+ /**
+ * Is the class supported by the plugin
+ * @param c The class
+ * @return True if supported; otherwise false
+ */
+ public boolean isSupported(Class c) {
+
+ if (isAnnotated(c) || isHbmXml(c)) {
+ known.add(c.getName());
+ return true;
+ }
+
+ return false;
+ }
+
+ /**
+ * Get the type of the class
+ * @param c The class
+ * @return The type; negative if unknown
+ */
+ public int getType(Class c) {
+ if (known.contains(c.getName())) {
+ return HIBERNATE;
+ }
+ return -1;
+ }
+
+ /**
+ * Get the description of the type
+ * @param type The type
+ * @return The description; otherwise null
+ */
+ public String getDescription(int type) {
+ if (HIBERNATE == type) {
+ return "HIBERNATE";
+ }
+ return null;
+ }
+
+ /**
+ * Annotated with @Entity
+ * @param clz The class
+ * @return True if found; otherwise false
+ */
+ private boolean isAnnotated(Class clz) {
+ if (clz != null) {
+ Annotation[] annotations = clz.getDeclaredAnnotations();
+ for (Annotation ca : annotations) {
+ if (ca.annotationType().getName().startsWith("org.hibernate.annotations.Entity")) {
+ return true;
+ }
+ }
+
+ return isAnnotated(clz.getSuperclass());
+ }
+
+ return false;
+ }
+
+ /**
+ * .hbm.xml
+ * @param clz The class
+ * @return True if found; otherwise false
+ */
+ private boolean isHbmXml(Class clz) {
+ if (hbmMap.get(clz.getClassLoader()) == null) {
+ loadHibernateCfgXml(clz);
+ }
+
+ List<String> classes = hbmMap.get(clz.getClassLoader());
+
+ for (String c : classes) {
+ if (clz.getName().equals(c)) {
+ return true;
+ }
+ }
+
+ return false;
+ }
+
+ /**
+ * Load
+ * @param clz The class
+ */
+ private void loadHibernateCfgXml(Class clz) {
+ List<String> result = new ArrayList<String>();
+
+ InputStream hibernateCfgXml = null;
+
+ try {
+ ClassLoader cl = clz.getClassLoader();
+ String file = "hibernate.cfg.xml";
+
+ hibernateCfgXml = cl.getResourceAsStream(file);
+
+ while (hibernateCfgXml == null && cl != null) {
+ cl = cl.getParent();
+ if (cl != null) {
+ hibernateCfgXml = cl.getResourceAsStream(file);
+ }
+ }
+
+ if (hibernateCfgXml != null) {
+ DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
+ DocumentBuilder db = dbf.newDocumentBuilder();
+ Document wd = db.parse(hibernateCfgXml);
+
+ NodeList nl = wd.getElementsByTagName("mapping");
+
+ for (int i = 0; i < nl.getLength(); i++) {
+ Node n = nl.item(i);
+
+ if (n.hasAttributes()) {
+ Node att = n.getAttributes().getNamedItem("resource");
+ if (att != null) {
+ result.addAll(loadHbmXml(cl, att.getNodeValue()));
+ }
+ }
+ }
+ }
+
+ } catch (Exception e) {
+ //
+ } finally {
+ if (hibernateCfgXml != null) {
+ try {
+ hibernateCfgXml.close();
+ } catch (IOException ioe) {
+ //
+ }
+ }
+ }
+
+ hbmMap.put(clz.getClassLoader(), result);
+ }
+
+ /**
+ * Load hbm.xml file
+ * @param cl The class loader
+ * @param file The file
+ * @return The Hibernate classes
+ */
+ private List<String> loadHbmXml(ClassLoader cl, String file) {
+ List<String> result = new ArrayList<String>();
+ InputStream hbmXml = null;
+
+ try {
+ hbmXml = cl.getResourceAsStream(file);
+
+ if (hbmXml != null) {
+ DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
+ DocumentBuilder db = dbf.newDocumentBuilder();
+ Document wd = db.parse(hbmXml);
+
+ NodeList nl = wd.getElementsByTagName("class");
+
+ for (int i = 0; i < nl.getLength(); i++) {
+ Node n = nl.item(i);
+
+ if (n.hasAttributes()) {
+ Node att = n.getAttributes().getNamedItem("name");
+ if (att != null) {
+ result.add(att.getNodeValue());
+ }
+ }
+ }
+ }
+
+ } catch (Exception e) {
+ //
+ } finally {
+ if (hbmXml != null) {
+ try {
+ hbmXml.close();
+ } catch (IOException ioe) {
+ //
+ }
+ }
+ }
+
+ return result;
+ }
+}
Added: branches/JBossProfiler2/src/main/org/jboss/profiler/plugins/package.html
===================================================================
--- branches/JBossProfiler2/src/main/org/jboss/profiler/plugins/package.html (rev 0)
+++ branches/JBossProfiler2/src/main/org/jboss/profiler/plugins/package.html 2008-02-10 10:59:33 UTC (rev 420)
@@ -0,0 +1,3 @@
+<body>
+This package contains various plugins for the component identification framework
+</body>
Added: branches/JBossProfiler2/src/main/org/jboss/profiler/shared/AllocationComparator.java
===================================================================
--- branches/JBossProfiler2/src/main/org/jboss/profiler/shared/AllocationComparator.java (rev 0)
+++ branches/JBossProfiler2/src/main/org/jboss/profiler/shared/AllocationComparator.java 2008-02-10 10:59:33 UTC (rev 420)
@@ -0,0 +1,47 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2007, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file 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.shared;
+
+import java.util.Comparator;
+
+/**
+ * Allocation comparator
+ * @author Jesper Pedersen <jep at worldleaguesports.com>
+ */
+public class AllocationComparator implements Comparator<AllocationInfo> {
+
+ /**
+ * Compare two objects
+ * @param a1 Allocation info
+ * @param a2 Allocation info
+ * @return Positive if a1 greater than a2; zero if equal otherwise negative
+ */
+ public int compare(AllocationInfo a1, AllocationInfo a2) {
+ if (a2.getCount() > a1.getCount()) {
+ return 1;
+ } else if (a2.getCount() == a1.getCount()) {
+ return a1.getClassName().compareTo(a2.getClassName());
+ } else {
+ return -1;
+ }
+ }
+}
Added: branches/JBossProfiler2/src/main/org/jboss/profiler/shared/AllocationInfo.java
===================================================================
--- branches/JBossProfiler2/src/main/org/jboss/profiler/shared/AllocationInfo.java (rev 0)
+++ branches/JBossProfiler2/src/main/org/jboss/profiler/shared/AllocationInfo.java 2008-02-10 10:59:33 UTC (rev 420)
@@ -0,0 +1,72 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2007, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file 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.shared;
+
+import java.io.Serializable;
+
+/**
+ * Represents allocations for a class
+ * @author Jesper Pedersen <jep at worldleaguesports.com>
+ */
+public class AllocationInfo implements Serializable {
+
+ /** Serial version UID */
+ static final long serialVersionUID = -2265307853705778866L;
+
+ /** The class name */
+ private String className;
+
+ /** The allocation count */
+ private long count;
+
+ /**
+ * Constructor
+ * @param className The class name
+ */
+ public AllocationInfo(String className) {
+ this.className = className.replace('/', '.');
+ this.count = 0;
+ }
+
+ /**
+ * Get the class name
+ * @return The name
+ */
+ public String getClassName() {
+ return className;
+ }
+
+ /**
+ * Get the allocation count
+ * @return The count
+ */
+ public long getCount() {
+ return count;
+ }
+
+ /**
+ * Increase the allocation count (agent only)
+ */
+ public void increase() {
+ count++;
+ }
+}
Added: branches/JBossProfiler2/src/main/org/jboss/profiler/shared/ClassComparator.java
===================================================================
--- branches/JBossProfiler2/src/main/org/jboss/profiler/shared/ClassComparator.java (rev 0)
+++ branches/JBossProfiler2/src/main/org/jboss/profiler/shared/ClassComparator.java 2008-02-10 10:59:33 UTC (rev 420)
@@ -0,0 +1,41 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2007, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file 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.shared;
+
+import java.util.Comparator;
+
+/**
+ * Class comparator
+ * @author Jesper Pedersen <jep at worldleaguesports.com>
+ */
+public class ClassComparator implements Comparator<ClassInfo> {
+
+ /**
+ * Compare two objects
+ * @param ca Class info
+ * @param cb Class info
+ * @return Positive if ca greater than cb; zero if equal otherwise negative
+ */
+ public int compare(ClassInfo ca, ClassInfo cb) {
+ return ca.getClassName().compareTo(cb.getClassName());
+ }
+}
Added: branches/JBossProfiler2/src/main/org/jboss/profiler/shared/ClassInfo.java
===================================================================
--- branches/JBossProfiler2/src/main/org/jboss/profiler/shared/ClassInfo.java (rev 0)
+++ branches/JBossProfiler2/src/main/org/jboss/profiler/shared/ClassInfo.java 2008-02-10 10:59:33 UTC (rev 420)
@@ -0,0 +1,90 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2007, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file 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.shared;
+
+import java.io.Serializable;
+
+/**
+ * Represents a class
+ * @author Jesper Pedersen <jep at worldleaguesports.com>
+ */
+public class ClassInfo implements Serializable {
+
+ /** Serial version UID */
+ static final long serialVersionUID = 7377350379376880440L;
+
+ /** The class name */
+ private String className;
+
+ /** The class type */
+ private int classType;
+
+ /**
+ * Constructor
+ * @param className The class name
+ * @param classType The class type
+ */
+ public ClassInfo(String className, int classType) {
+ this.className = className;
+ this.classType = classType;
+ }
+
+ /**
+ * Get the class name
+ * @return The name
+ */
+ public String getClassName() {
+ return className;
+ }
+
+ /**
+ * Get the class type
+ * @return The type
+ */
+ public int getClassType() {
+ return classType;
+ }
+
+ /**
+ * Equals
+ * @param other The other object
+ * @return True if equal; otherwise false
+ */
+ @Override
+ public boolean equals(Object other) {
+ if (!(other instanceof ClassInfo)) {
+ return false;
+ }
+
+ ClassInfo ci = (ClassInfo)other;
+ return this.className.equals(ci.getClassName());
+ }
+
+ /**
+ * Hash code
+ * @return The hash code
+ */
+ @Override
+ public int hashCode() {
+ return className.hashCode();
+ }
+}
Added: branches/JBossProfiler2/src/main/org/jboss/profiler/shared/ClassType.java
===================================================================
--- branches/JBossProfiler2/src/main/org/jboss/profiler/shared/ClassType.java (rev 0)
+++ branches/JBossProfiler2/src/main/org/jboss/profiler/shared/ClassType.java 2008-02-10 10:59:33 UTC (rev 420)
@@ -0,0 +1,105 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2007, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file 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.shared;
+
+/**
+ * Defines the different class types.
+ * This is not an enum since plugins should be able to defined their own constants.
+ * @author Jesper Pedersen <jep at worldleaguesports.com>
+ */
+public interface ClassType {
+
+ /**
+ * Plain Old Java Object (POJO)
+ */
+ public static final int POJO = 0;
+
+ /**
+ * Throwable
+ */
+ public static final int THROWABLE = 1;
+
+ /**
+ * Enterprise JavaBean: Session
+ */
+ public static final int EJB_SESSION = 2;
+
+ /**
+ * Enterprise JavaBean: Entity
+ */
+ public static final int EJB_ENTITY = 3;
+
+ /**
+ * Enterprise JavaBean: Message
+ */
+ public static final int EJB_MESSAGE = 4;
+
+ /**
+ * Servlet
+ */
+ public static final int SERVLET = 5;
+
+ /**
+ * Servlet filter
+ */
+ public static final int SERVLET_FILTER = 6;
+
+ /**
+ * JavaServer Page
+ */
+ public static final int JSP = 7;
+
+ /**
+ * JMX: MBean
+ */
+ public static final int JMX_MBEAN = 8;
+
+ /**
+ * JavaServer Faces: Converter
+ */
+ public static final int JSF_CONVERTER = 9;
+
+ /**
+ * JavaServer Faces: Managed bean
+ */
+ public static final int JSF_MANAGED_BEAN = 10;
+
+ /**
+ * RMI: Remote
+ */
+ public static final int RMI_REMOTE = 11;
+
+ /**
+ * RMI: Server
+ */
+ public static final int RMI_SERVER = 12;
+
+ /**
+ * CORBA: Object
+ */
+ public static final int CORBA_OBJECT = 13;
+
+ /**
+ * CORBA: Servant
+ */
+ public static final int CORBA_SERVANT = 14;
+}
Added: branches/JBossProfiler2/src/main/org/jboss/profiler/shared/Command.java
===================================================================
--- branches/JBossProfiler2/src/main/org/jboss/profiler/shared/Command.java (rev 0)
+++ branches/JBossProfiler2/src/main/org/jboss/profiler/shared/Command.java 2008-02-10 10:59:33 UTC (rev 420)
@@ -0,0 +1,74 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2007, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file 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.shared;
+
+import java.io.Serializable;
+
+/**
+ * The client / server API
+ * @author Jesper Pedersen <jep at worldleaguesports.com>
+ */
+public class Command implements Serializable {
+
+ /** Serial version UID */
+ static final long serialVersionUID = -5659221681712713474L;
+
+ /** The command type */
+ private CommandType cmd;
+
+ /** The argument */
+ private Object[] args;
+
+ /**
+ * Constructor
+ * @param cmd The command
+ */
+ public Command(CommandType cmd) {
+ this(cmd, null);
+ }
+
+ /**
+ * Constructor
+ * @param cmd The command
+ * @param args The arguments
+ */
+ public Command(CommandType cmd, Object[] args) {
+ this.cmd = cmd;
+ this.args = args;
+ }
+
+ /**
+ * Get the command
+ * @return The command
+ */
+ public CommandType getCommand() {
+ return cmd;
+ }
+
+ /**
+ * Get the arguments
+ * @return The arguments
+ */
+ public Object[] getArguments() {
+ return args;
+ }
+}
Added: branches/JBossProfiler2/src/main/org/jboss/profiler/shared/CommandType.java
===================================================================
--- branches/JBossProfiler2/src/main/org/jboss/profiler/shared/CommandType.java (rev 0)
+++ branches/JBossProfiler2/src/main/org/jboss/profiler/shared/CommandType.java 2008-02-10 10:59:33 UTC (rev 420)
@@ -0,0 +1,99 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2007, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file 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.shared;
+
+/**
+ * Defines the different command types
+ * @author Jesper Pedersen <jep at worldleaguesports.com>
+ */
+public enum CommandType {
+
+ /**
+ * Start the profiler
+ */
+ START_PROFILER,
+
+ /**
+ * Stop the profiler
+ */
+ STOP_PROFILER,
+
+ /**
+ * Take a snapshot
+ */
+ SNAPSHOT,
+
+ /**
+ * Get a snapshot
+ */
+ GET_SNAPSHOT,
+
+ /**
+ * List snapshots
+ */
+ LIST_SNAPSHOTS,
+
+ /**
+ * Clear snapshots
+ */
+ CLEAR_SNAPSHOTS,
+
+ /**
+ * Trigger garbage collection
+ */
+ GC,
+
+ /**
+ * Enable profiler
+ */
+ ENABLE,
+
+ /**
+ * Disable profiler
+ */
+ DISABLE,
+
+ /**
+ * Load a snapshot
+ */
+ LOAD,
+
+ /**
+ * Save a snapshot
+ */
+ SAVE,
+
+ /**
+ * Difference between snapshots
+ */
+ DIFFERENCE,
+
+ /**
+ * Add classes
+ */
+ ADD_CLASSES,
+
+ /**
+ * Remove classes
+ */
+ REMOVE_CLASSES
+}
Added: branches/JBossProfiler2/src/main/org/jboss/profiler/shared/FrameComparator.java
===================================================================
--- branches/JBossProfiler2/src/main/org/jboss/profiler/shared/FrameComparator.java (rev 0)
+++ branches/JBossProfiler2/src/main/org/jboss/profiler/shared/FrameComparator.java 2008-02-10 10:59:33 UTC (rev 420)
@@ -0,0 +1,47 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2007, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file 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.shared;
+
+import java.util.Comparator;
+
+/**
+ * Frame comparator
+ * @author Jesper Pedersen <jep at worldleaguesports.com>
+ */
+public class FrameComparator implements Comparator<FrameInfo> {
+
+ /**
+ * Compare two objects
+ * @param fa Frame info
+ * @param fb Frame info
+ * @return Positive if fb greater than fa; zero if equal otherwise negative
+ */
+ public int compare(FrameInfo fa, FrameInfo fb) {
+ if (fa.getNetTime() < fb.getNetTime()) {
+ return 1;
+ } else if (fa.getNetTime() == fb.getNetTime()) {
+ return 0;
+ } else {
+ return -1;
+ }
+ }
+}
Added: branches/JBossProfiler2/src/main/org/jboss/profiler/shared/FrameHelper.java
===================================================================
--- branches/JBossProfiler2/src/main/org/jboss/profiler/shared/FrameHelper.java (rev 0)
+++ branches/JBossProfiler2/src/main/org/jboss/profiler/shared/FrameHelper.java 2008-02-10 10:59:33 UTC (rev 420)
@@ -0,0 +1,111 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2007, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file 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.shared;
+
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.io.ObjectInputStream;
+import java.io.ObjectOutputStream;
+import java.util.zip.GZIPInputStream;
+import java.util.zip.GZIPOutputStream;
+
+/**
+ * The frame helper
+ * @author Jesper Pedersen <jep at worldleaguesports.com>
+ */
+public class FrameHelper {
+
+ /**
+ * Constructor
+ */
+ private FrameHelper() {
+ }
+
+ /**
+ * Load a frame
+ * @param file The file
+ * @exception IOException If an error occurs
+ */
+ public static FrameInfo load(File file) throws IOException {
+ FrameInfo fi = null;
+ FileInputStream fis = null;
+
+ if (file != null && file.exists()) {
+ try {
+ fis = new FileInputStream(file);
+ GZIPInputStream gis = new GZIPInputStream(fis);
+ ObjectInputStream ois = new ObjectInputStream(gis);
+ fi = (FrameInfo)ois.readObject();
+ } catch (Exception e) {
+ IOException ioe = new IOException(e.getMessage());
+ ioe.initCause(e);
+ throw ioe;
+ } finally {
+ if (fis != null) {
+ try {
+ fis.close();
+ } catch (Exception ne) {
+ }
+ }
+ }
+ } else {
+ throw new IOException("File " + file + " does not exist");
+ }
+
+ return fi;
+ }
+
+ /**
+ * Save
+ * @param fi The frame
+ * @param number The frame number
+ * @param directory The directory
+ * @exception IOException If an error occurs
+ */
+ public static void save(FrameInfo fi, Long number, File directory) throws IOException {
+ if (fi == null) {
+ throw new IOException("FrameInfo is null");
+ }
+
+ if (directory == null) {
+ throw new IOException("Directory is null");
+ }
+
+ if (number == null) {
+ throw new IOException("Number is null");
+ }
+
+ if (!directory.exists()) {
+ directory.mkdirs();
+ }
+
+ File file = new File(directory, number.toString());
+ FileOutputStream fos = new FileOutputStream(file);
+ GZIPOutputStream gos = new GZIPOutputStream(fos);
+ ObjectOutputStream oos = new ObjectOutputStream(gos);
+ oos.writeObject(fi);
+ oos.flush();
+ oos.close();
+ }
+}
Added: branches/JBossProfiler2/src/main/org/jboss/profiler/shared/FrameInfo.java
===================================================================
--- branches/JBossProfiler2/src/main/org/jboss/profiler/shared/FrameInfo.java (rev 0)
+++ branches/JBossProfiler2/src/main/org/jboss/profiler/shared/FrameInfo.java 2008-02-10 10:59:33 UTC (rev 420)
@@ -0,0 +1,301 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2007, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file 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.shared;
+
+import java.io.Serializable;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+
+/**
+ * Represents a frame
+ * @author Jesper Pedersen <jep at worldleaguesports.com>
+ */
+public class FrameInfo implements Serializable {
+
+ /** Serial version UID */
+ static final long serialVersionUID = 8251940154906731467L;
+
+ /** The method */
+ private MethodInfo method;
+
+ /** The parent frame */
+ private FrameInfo parent;
+
+ /** The child frames */
+ private List<FrameInfo> children;
+
+ /** The net time */
+ private long netTime;
+
+ /** The count */
+ private long count;
+
+ /** The time */
+ private long time;
+
+ /** The wait time */
+ private long waitTime;
+
+ /** Child map */
+ private transient Map<MethodInfo, Integer> childMap;
+
+ /** The last start time */
+ private transient long lastStartTime;
+
+ /** The last wait start time */
+ private transient long lastWaitStartTime;
+
+ /**
+ * Constructor
+ * @param method The method
+ * @param parent The parent
+ */
+ public FrameInfo(MethodInfo method, FrameInfo parent) {
+ this.method = method;
+ this.parent = parent;
+ this.children = null;
+ this.netTime = -1;
+ this.count = 0;
+ this.time = 0;
+ this.waitTime = 0;
+ this.childMap = null;
+ this.lastStartTime = 0;
+ this.lastWaitStartTime = 0;
+
+ if (parent != null) {
+ parent.addChild(method, this);
+ }
+ }
+
+ /**
+ * Get the method
+ * @return The method
+ */
+ public MethodInfo getMethod() {
+ return method;
+ }
+
+ /**
+ * Get the parent
+ * @return The parent
+ */
+ public FrameInfo getParent() {
+ return parent;
+ }
+
+ /**
+ * Get the children
+ * @return The children
+ */
+ public List<FrameInfo> getChildren() {
+ return children;
+ }
+
+ /**
+ * Get the net time
+ * @return The net time
+ */
+ public long getNetTime() {
+ if (netTime < 0) {
+ computeNetTime();
+ }
+
+ return netTime;
+ }
+
+ /**
+ * Get the count
+ * @return The count
+ */
+ public long getCount() {
+ return count;
+ }
+
+ /**
+ * Get the time
+ * @return The time
+ */
+ public long getTime() {
+ return time;
+ }
+
+ /**
+ * Get the wait time
+ * @return The wait time
+ */
+ public long getWaitTime() {
+ return waitTime;
+ }
+
+ /**
+ * Set the begin time (agent only)
+ * @param t The time
+ */
+ public void setBeginTime(long t) {
+ lastStartTime = t;
+ }
+
+ /**
+ * Set the end time (agent only)
+ * @param t The time
+ */
+ public void setEndTime(long t) {
+ long delta = t - lastStartTime;
+
+ if (lastStartTime > 0 && delta > 0) {
+ time += delta;
+ }
+
+ count++;
+ lastStartTime = 0;
+ }
+
+ /**
+ * Set the begin wait time (agent only)
+ * @param t The time
+ */
+ public void setBeginWaitTime(long t) {
+ lastWaitStartTime = t;
+ }
+
+ /**
+ * Set the end wait time (agent only)
+ * @param t The time
+ */
+ public void setEndWaitTime(long t) {
+ long delta = t - lastWaitStartTime;
+
+ if (lastWaitStartTime > 0 && delta > 0) {
+ waitTime += delta;
+ }
+ lastWaitStartTime = 0;
+ }
+
+ /**
+ * Get the child for a method (agent only)
+ * @param m The method
+ * @return The frame
+ */
+ public FrameInfo getChild(MethodInfo m) {
+ if (childMap != null) {
+ Integer i = childMap.get(m);
+ if (i != null) {
+ return children.get(i.intValue());
+ }
+ }
+ return null;
+ }
+
+ /**
+ * Set overhead (agent only)
+ * @param overhead The overhead
+ */
+ public void setOverhead(long overhead) {
+ if (overhead > 0 && (time - overhead) > 0) {
+ time -= overhead;
+ }
+ }
+
+ /**
+ * Get the total time
+ * @return The total time
+ */
+ public long getTotalTime() {
+ long totalTime = getNetTime();
+
+ if (getChildren() != null) {
+ for (FrameInfo f : getChildren()) {
+ totalTime += f.getTotalTime();
+ }
+ }
+
+ return totalTime;
+ }
+
+ /**
+ * Close the frame (agent only)
+ */
+ public void close() {
+ if (lastStartTime > 0) {
+ setEndTime(System.nanoTime());
+ }
+
+ List<FrameInfo> l = getChildren();
+ if (l != null) {
+ for (FrameInfo child: l) {
+ child.close();
+ }
+ }
+
+ childMap = null;
+ }
+
+ /**
+ * Compute the net time
+ */
+ private void computeNetTime() {
+ long childTime = 0;
+
+ List<FrameInfo> l = getChildren();
+ if (l != null) {
+ for (FrameInfo child: l) {
+ childTime += child.getTime();
+ }
+ }
+
+ netTime = getTime() - childTime - waitTime;
+
+ if (netTime < 0) {
+ netTime = 0;
+ }
+ }
+
+ /**
+ * Init children
+ */
+ private void initChildren() {
+ if (childMap == null) {
+ childMap = new HashMap<MethodInfo, Integer>();
+ }
+ if (children == null) {
+ children = new ArrayList<FrameInfo>();
+ }
+ }
+
+ /**
+ * Add a child
+ * @param mi The method
+ * @param fi The child
+ */
+ private void addChild(MethodInfo mi, FrameInfo fi) {
+ if (children == null || childMap == null) {
+ initChildren();
+ }
+
+ children.add(fi);
+ childMap.put(mi, Integer.valueOf(children.size() - 1));
+ netTime = -1;
+ }
+}
Added: branches/JBossProfiler2/src/main/org/jboss/profiler/shared/Math.java
===================================================================
--- branches/JBossProfiler2/src/main/org/jboss/profiler/shared/Math.java (rev 0)
+++ branches/JBossProfiler2/src/main/org/jboss/profiler/shared/Math.java 2008-02-10 10:59:33 UTC (rev 420)
@@ -0,0 +1,58 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2007, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file 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.shared;
+
+/**
+ * Math utility functions
+ * @author Jesper Pedersen <jep at worldleaguesports.com>
+ */
+public class Math {
+
+ /**
+ * Convert nano to millis
+ * @param nanos The nanos
+ * @return The millis
+ */
+ public static double nanoToMilli(long nanos) {
+ return ((double)nanos) / 1000000.0;
+ }
+
+ /**
+ * Get the percent
+ * @param nom The nomenator
+ * @param denom The denomenator
+ * @return The percent
+ */
+ public static double toPercent(long nom, double denom) {
+ return toPercent((double)nom, denom);
+ }
+
+ /**
+ * Get the percent
+ * @param nom The nomenator
+ * @param denom The denomenator
+ * @return The percent
+ */
+ public static double toPercent(double nom, double denom) {
+ return (nom / denom) * 100.0;
+ }
+}
Added: branches/JBossProfiler2/src/main/org/jboss/profiler/shared/MethodInfo.java
===================================================================
--- branches/JBossProfiler2/src/main/org/jboss/profiler/shared/MethodInfo.java (rev 0)
+++ branches/JBossProfiler2/src/main/org/jboss/profiler/shared/MethodInfo.java 2008-02-10 10:59:33 UTC (rev 420)
@@ -0,0 +1,91 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2007, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file 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.shared;
+
+import java.io.Serializable;
+
+/**
+ * Represents a method
+ * @author Jesper Pedersen <jep at worldleaguesports.com>
+ */
+public class MethodInfo implements Serializable {
+
+ /** Serial version UID */
+ static final long serialVersionUID = 7334560988667012888L;
+
+ /** The method name */
+ private String methodName;
+
+ /** The class name */
+ private String className;
+
+ /**
+ * Constructor
+ * @param methodName The method name
+ * @param className The class name
+ */
+ public MethodInfo(String methodName, String className) {
+ this.methodName = methodName;
+ this.className = className;
+ }
+
+ /**
+ * Get the method name
+ * @return The name
+ */
+ public String getMethodName() {
+ return methodName;
+ }
+
+ /**
+ * Get the class name
+ * @return The name
+ */
+ public String getClassName() {
+ return className;
+ }
+
+ /**
+ * Equals
+ * @param other The other object
+ * @return True if equal; otherwise false
+ */
+ @Override
+ public boolean equals(Object other) {
+ if (!(other instanceof MethodInfo)) {
+ return false;
+ }
+
+ MethodInfo mi = (MethodInfo)other;
+ return this.methodName.equals(mi.getMethodName())
+ && this.className.equals(mi.getClassName());
+ }
+
+ /**
+ * Hash code
+ * @return The hash code
+ */
+ @Override
+ public int hashCode() {
+ return methodName.hashCode() + className.hashCode();
+ }
+}
Added: branches/JBossProfiler2/src/main/org/jboss/profiler/shared/Plugin.java
===================================================================
--- branches/JBossProfiler2/src/main/org/jboss/profiler/shared/Plugin.java (rev 0)
+++ branches/JBossProfiler2/src/main/org/jboss/profiler/shared/Plugin.java 2008-02-10 10:59:33 UTC (rev 420)
@@ -0,0 +1,56 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2007, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file 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.shared;
+
+/**
+ * Defines the component class plugin interface.
+ * @author Jesper Pedersen <jep at worldleaguesports.com>
+ */
+public interface Plugin {
+
+ /**
+ * Get the name of the plugin
+ * @return The name
+ */
+ public String getName();
+
+ /**
+ * Is the class supported by the plugin
+ * @param c The class
+ * @return True if supported; otherwise false
+ */
+ public boolean isSupported(Class c);
+
+ /**
+ * Get the type of the class
+ * @param c The class
+ * @return The type; negative if unknown
+ */
+ public int getType(Class c);
+
+ /**
+ * Get the description of the type
+ * @param type The type
+ * @return The description; otherwise null
+ */
+ public String getDescription(int type);
+}
Added: branches/JBossProfiler2/src/main/org/jboss/profiler/shared/PluginHelper.java
===================================================================
--- branches/JBossProfiler2/src/main/org/jboss/profiler/shared/PluginHelper.java (rev 0)
+++ branches/JBossProfiler2/src/main/org/jboss/profiler/shared/PluginHelper.java 2008-02-10 10:59:33 UTC (rev 420)
@@ -0,0 +1,84 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2007, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file 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.shared;
+
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+import java.util.Properties;
+import java.util.TreeMap;
+
+/**
+ * The plugin helper
+ * @author Jesper Pedersen <jep at worldleaguesports.com>
+ */
+public class PluginHelper {
+
+ /**
+ * Constructor
+ */
+ private PluginHelper() {
+ }
+
+ /**
+ * Load a list of plugins
+ * @param properties The properties
+ * @return The list
+ */
+ public static List<Plugin> load(Properties properties) {
+ List<Plugin> result = new ArrayList<Plugin>();
+
+ if (properties != null) {
+ Map<Integer, String> plugins = new TreeMap<Integer, String>();
+
+ Iterator it = properties.entrySet().iterator();
+ while (it.hasNext()) {
+ Map.Entry entry = (Map.Entry)it.next();
+
+ String key = (String)entry.getKey();
+ String value = (String)entry.getValue();
+
+ if (key.startsWith("plugin.")) {
+ Integer idx = Integer.parseInt(key.substring(key.indexOf(".") + 1));
+ plugins.put(idx, value);
+ }
+ }
+
+ List<String> classes = new ArrayList<String>(plugins.values());
+ for (String clz : classes) {
+ clz = clz.trim();
+
+ try {
+ Class c = Class.forName(clz);
+ Plugin p = (Plugin)c.newInstance();
+ result.add(p);
+ } catch (Exception e) {
+ // Nothing to do
+ System.err.println("Plugin " + clz + " could not be loaded");
+ }
+ }
+ }
+
+ return result;
+ }
+}
Added: branches/JBossProfiler2/src/main/org/jboss/profiler/shared/Snapshot.java
===================================================================
--- branches/JBossProfiler2/src/main/org/jboss/profiler/shared/Snapshot.java (rev 0)
+++ branches/JBossProfiler2/src/main/org/jboss/profiler/shared/Snapshot.java 2008-02-10 10:59:33 UTC (rev 420)
@@ -0,0 +1,110 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2007, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file 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.shared;
+
+import java.io.Serializable;
+import java.util.Date;
+import java.util.List;
+
+/**
+ * The snapshot
+ * @author Jesper Pedersen <jep at worldleaguesports.com>
+ */
+public class Snapshot implements Serializable {
+
+ /** Serial version UID */
+ static final long serialVersionUID = 2227827499078876487L;
+
+ /** The threads list */
+ private List<ThreadInfo> threadList;
+
+ /** The allocation list */
+ private List<AllocationInfo> allocationList;
+
+ /** The class list */
+ private List<ClassInfo> classList;
+
+ /** From date */
+ private Date from;
+
+ /** To date */
+ private Date to;
+
+ /**
+ * Constructor
+ * @param threadList The thread list
+ * @param allocationList The allocation list
+ * @param from The from date
+ * @param to The to date
+ */
+ public Snapshot(List <ThreadInfo> threadList,
+ List<AllocationInfo> allocationList,
+ List<ClassInfo> classList,
+ Date from,
+ Date to) {
+ this.threadList = threadList;
+ this.allocationList = allocationList;
+ this.classList = classList;
+ this.from = from;
+ this.to = to;
+ }
+
+ /**
+ * Get the from date
+ * @return The date
+ */
+ public Date getFrom() {
+ return from;
+ }
+
+ /**
+ * Get the to date
+ * @return The date
+ */
+ public Date getTo() {
+ return to;
+ }
+
+ /**
+ * Get the threads
+ * @return The threads
+ */
+ public List<ThreadInfo> getThreads() {
+ return threadList;
+ }
+
+ /**
+ * Get the allocations
+ * @return The allocations
+ */
+ public List<AllocationInfo> getAllocations() {
+ return allocationList;
+ }
+
+ /**
+ * Get the classes
+ * @return The classes
+ */
+ public List<ClassInfo> getClasses() {
+ return classList;
+ }
+}
Added: branches/JBossProfiler2/src/main/org/jboss/profiler/shared/SnapshotHelper.java
===================================================================
--- branches/JBossProfiler2/src/main/org/jboss/profiler/shared/SnapshotHelper.java (rev 0)
+++ branches/JBossProfiler2/src/main/org/jboss/profiler/shared/SnapshotHelper.java 2008-02-10 10:59:33 UTC (rev 420)
@@ -0,0 +1,199 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2007, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file 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.shared;
+
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.io.ObjectInputStream;
+import java.io.ObjectOutputStream;
+import java.text.DecimalFormat;
+import java.util.ArrayList;
+import java.util.Calendar;
+import java.util.List;
+import java.util.zip.GZIPInputStream;
+import java.util.zip.GZIPOutputStream;
+
+/**
+ * The snapshot helper
+ * @author Jesper Pedersen <jep at worldleaguesports.com>
+ */
+public class SnapshotHelper {
+
+ /**
+ * Constructor
+ */
+ private SnapshotHelper() {
+ }
+
+ /**
+ * Default name for a snapshot
+ * @param snapshot The snapshot
+ * @return The name
+ */
+ public static String getName(Snapshot snapshot) {
+ StringBuffer sb = new StringBuffer();
+ DecimalFormat df = new DecimalFormat("00");
+ DecimalFormat df3 = new DecimalFormat("000");
+
+ Calendar c = Calendar.getInstance();
+ c.setTime(snapshot.getFrom());
+
+ sb = sb.append(Integer.toString(c.get(Calendar.YEAR)));
+ sb = sb.append(df.format(c.get(Calendar.MONTH) + 1));
+ sb = sb.append(df.format(c.get(Calendar.DATE)));
+ sb = sb.append(df.format(c.get(Calendar.HOUR_OF_DAY)));
+ sb = sb.append(df.format(c.get(Calendar.MINUTE)));
+ sb = sb.append(df.format(c.get(Calendar.SECOND)));
+ sb = sb.append(df3.format(c.get(Calendar.MILLISECOND)));
+
+ sb = sb.append("-");
+
+ c.setTime(snapshot.getTo());
+ sb = sb.append(Integer.toString(c.get(Calendar.YEAR)));
+ sb = sb.append(df.format(c.get(Calendar.MONTH) + 1));
+ sb = sb.append(df.format(c.get(Calendar.DATE)));
+ sb = sb.append(df.format(c.get(Calendar.HOUR_OF_DAY)));
+ sb = sb.append(df.format(c.get(Calendar.MINUTE)));
+ sb = sb.append(df.format(c.get(Calendar.SECOND)));
+ sb = sb.append(df3.format(c.get(Calendar.MILLISECOND)));
+
+ return sb.toString();
+ }
+
+ /**
+ * Load a snapshot
+ * @param file The file
+ * @exception IOException If an error occurs
+ */
+ public static Snapshot load(File file) throws IOException {
+ Snapshot snapshot = null;
+ FileInputStream fis = null;
+
+ if (file != null && file.exists()) {
+ try {
+ fis = new FileInputStream(file);
+ GZIPInputStream gis = new GZIPInputStream(fis);
+ ObjectInputStream ois = new ObjectInputStream(gis);
+ snapshot = (Snapshot)ois.readObject();
+ } catch (Exception e) {
+ IOException ioe = new IOException(e.getMessage());
+ ioe.initCause(e);
+ throw ioe;
+ } finally {
+ if (fis != null) {
+ try {
+ fis.close();
+ } catch (Exception ne) {
+ }
+ }
+ }
+ } else {
+ throw new IOException("File " + file + " does not exist");
+ }
+
+ return snapshot;
+ }
+
+ /**
+ * Save
+ * @param snapshot The snapshot
+ * @exception IOException If an error occurs
+ */
+ public static void save(Snapshot snapshot) throws IOException {
+ save(snapshot, new File(getName(snapshot) + ".jps"));
+ }
+
+ /**
+ * Save
+ * @param snapshot The snapshot
+ * @param file The file
+ * @exception IOException If an error occurs
+ */
+ public static void save(Snapshot snapshot, File file) throws IOException {
+ if (snapshot == null) {
+ throw new IOException("Snapshot is null");
+ }
+
+ if (file == null) {
+ throw new IOException("File is null");
+ }
+
+ FileOutputStream fos = new FileOutputStream(file);
+ GZIPOutputStream gos = new GZIPOutputStream(fos);
+ ObjectOutputStream oos = new ObjectOutputStream(gos);
+ oos.writeObject(snapshot);
+ oos.flush();
+ oos.close();
+ }
+
+ /**
+ * Generate a snapshot from a directory
+ * @param directory The directory
+ * @exception IOException If an error occurs
+ */
+ public static Snapshot generate(File directory) throws IOException {
+ if (directory == null) {
+ throw new IOException("Directory is null");
+ }
+
+ File baseFile = new File(directory, "data");
+ Snapshot base = load(baseFile);
+
+ List<ThreadInfo> threads = new ArrayList<ThreadInfo>();
+
+ File[] entries = directory.listFiles();
+ for (File entry: entries) {
+ if (entry.isDirectory()) {
+ File tf = new File(directory, entry.getName());
+ ThreadInfo ti = ThreadHelper.load(tf);
+
+ boolean found = true;
+ long counter = 0;
+ while (found) {
+ try {
+ File f = new File(entry, Long.toString(counter));
+ if (f.exists()) {
+ FrameInfo fi = FrameHelper.load(f);
+ ti.add(fi);
+
+ counter += 1;
+ } else {
+ found = false;
+ }
+ } catch (Exception e) {
+ found = false;
+ }
+ }
+
+ threads.add(ti);
+ }
+ }
+
+ return new Snapshot(threads,
+ base.getAllocations(),
+ base.getClasses(),
+ base.getFrom(),
+ base.getTo());
+ }
+}
Added: branches/JBossProfiler2/src/main/org/jboss/profiler/shared/ThreadComparator.java
===================================================================
--- branches/JBossProfiler2/src/main/org/jboss/profiler/shared/ThreadComparator.java (rev 0)
+++ branches/JBossProfiler2/src/main/org/jboss/profiler/shared/ThreadComparator.java 2008-02-10 10:59:33 UTC (rev 420)
@@ -0,0 +1,52 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2007, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file 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.shared;
+
+import java.util.Comparator;
+
+/**
+ * Thread comparator
+ * @author Jesper Pedersen <jep at worldleaguesports.com>
+ */
+public class ThreadComparator implements Comparator<ThreadInfo> {
+
+ /**
+ * Compare two objects
+ * @param ta Thread info
+ * @param tb Thread info
+ * @return Positive if tb greater than ta; zero if equal otherwise negative
+ */
+ public int compare(ThreadInfo ta, ThreadInfo tb) {
+ if (ta.getTotalTime() < tb.getTotalTime()) {
+ return 1;
+ } else if (ta.getTotalTime() == tb.getTotalTime()) {
+ if (ta.getId() < tb.getId()) {
+ return -1;
+ } else if (ta.getId() > tb.getId()) {
+ return 1;
+ }
+ return 0;
+ } else {
+ return -1;
+ }
+ }
+}
Added: branches/JBossProfiler2/src/main/org/jboss/profiler/shared/ThreadHelper.java
===================================================================
--- branches/JBossProfiler2/src/main/org/jboss/profiler/shared/ThreadHelper.java (rev 0)
+++ branches/JBossProfiler2/src/main/org/jboss/profiler/shared/ThreadHelper.java 2008-02-10 10:59:33 UTC (rev 420)
@@ -0,0 +1,119 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2007, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file 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.shared;
+
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.io.ObjectInputStream;
+import java.io.ObjectOutputStream;
+import java.util.List;
+import java.util.zip.GZIPInputStream;
+import java.util.zip.GZIPOutputStream;
+
+/**
+ * The thread helper
+ * @author Jesper Pedersen <jep at worldleaguesports.com>
+ */
+public class ThreadHelper {
+
+ /**
+ * Constructor
+ */
+ private ThreadHelper() {
+ }
+
+ /**
+ * Load a thread
+ * @param directory The directory
+ * @exception IOException If an error occurs
+ */
+ public static ThreadInfo load(File directory) throws IOException {
+ ThreadInfo ti = null;
+ FileInputStream fis = null;
+
+ if (directory != null && directory.exists()) {
+ try {
+ fis = new FileInputStream(new File(directory, "base"));
+ GZIPInputStream gis = new GZIPInputStream(fis);
+ ObjectInputStream ois = new ObjectInputStream(gis);
+
+ long id = ois.readLong();
+ String name = ois.readUTF();
+ int priority = ois.readInt();
+ boolean daemon = ois.readBoolean();
+ List<String> groups = (List<String>)ois.readObject();
+
+ ti = new ThreadInfo(id, name, priority, daemon, groups);
+
+ } catch (Exception e) {
+ IOException ioe = new IOException(e.getMessage());
+ ioe.initCause(e);
+ throw ioe;
+ } finally {
+ if (fis != null) {
+ try {
+ fis.close();
+ } catch (Exception ne) {
+ }
+ }
+ }
+ } else {
+ throw new IOException("Directory " + directory + " does not exist");
+ }
+
+ return ti;
+ }
+
+ /**
+ * Save
+ * @param ti The thread
+ * @param directory The directory
+ * @exception IOException If an error occurs
+ */
+ public static void save(ThreadInfo ti, File directory) throws IOException {
+ if (ti == null) {
+ throw new IOException("ThreadInfo is null");
+ }
+
+ if (directory == null) {
+ throw new IOException("Directory is null");
+ }
+
+ if (!directory.exists()) {
+ directory.mkdirs();
+ }
+
+ File file = new File(directory, "base");
+ FileOutputStream fos = new FileOutputStream(file);
+ GZIPOutputStream gos = new GZIPOutputStream(fos);
+ ObjectOutputStream oos = new ObjectOutputStream(gos);
+ oos.writeLong(ti.getId());
+ oos.writeUTF(ti.getName());
+ oos.writeInt(ti.getPriority());
+ oos.writeBoolean(ti.isDaemon());
+ oos.writeObject(ti.getGroups());
+ oos.flush();
+ oos.close();
+ }
+}
Added: branches/JBossProfiler2/src/main/org/jboss/profiler/shared/ThreadInfo.java
===================================================================
--- branches/JBossProfiler2/src/main/org/jboss/profiler/shared/ThreadInfo.java (rev 0)
+++ branches/JBossProfiler2/src/main/org/jboss/profiler/shared/ThreadInfo.java 2008-02-10 10:59:33 UTC (rev 420)
@@ -0,0 +1,176 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2007, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file 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.shared;
+
+import java.io.Serializable;
+import java.util.LinkedList;
+import java.util.List;
+
+/**
+ * Represents a thread and its frames
+ * @author Jesper Pedersen <jep at worldleaguesports.com>
+ */
+public class ThreadInfo implements Serializable {
+
+ /** Serial version UID */
+ static final long serialVersionUID = -1310252393096580495L;
+
+ /** The thread id */
+ private long id;
+
+ /** The thread name */
+ private String name;
+
+ /** The thread priority */
+ private int priority;
+
+ /** Is daemon */
+ private boolean daemon;
+
+ /** The thread groups */
+ private List<String> groups;
+
+ /** Frames */
+ private LinkedList<FrameInfo> frames;
+
+ /** The total time */
+ private transient long totalTime;
+
+ /**
+ * Constructor
+ * @param id The thread id
+ * @param name The thread name
+ * @param priority The thread priority
+ * @param daemon The thread daemon status
+ * @param groups The thread groups
+ */
+ public ThreadInfo(long id, String name, int priority, boolean daemon, List<String> groups) {
+ this.id = id;
+ this.name = name;
+ this.priority = priority;
+ this.daemon = daemon;
+ this.groups = groups;
+ this.frames = new LinkedList<FrameInfo>();
+ this.totalTime = 0;
+ }
+
+ /**
+ * Get the id
+ * @return The id
+ */
+ public long getId() {
+ return id;
+ }
+
+ /**
+ * Get the name
+ * @return The name
+ */
+ public String getName() {
+ return name;
+ }
+
+ /**
+ * Get the priority
+ * @return The priority
+ */
+ public int getPriority() {
+ return priority;
+ }
+
+ /**
+ * Is daemon
+ * @return The daemon status
+ */
+ public boolean isDaemon() {
+ return daemon;
+ }
+
+ /**
+ * Get the thread groups
+ * @return The thread groups
+ */
+ public List<String> getGroups() {
+ return groups;
+ }
+
+ /**
+ * Get the frames
+ * @return The frames
+ */
+ public List<FrameInfo> getFrames() {
+ return frames;
+ }
+
+ /**
+ * Add a frame to a thread
+ * @param f The frame
+ */
+ public void add(FrameInfo f) {
+ frames.add(f);
+ totalTime = 0;
+ }
+
+ /**
+ * Get the recent frame for a thread
+ * @return The frame
+ */
+ public FrameInfo getRecentFrame() {
+ return frames.getLast();
+ }
+
+ /**
+ * Get the total time
+ * @return The total time
+ */
+ public long getTotalTime() {
+ if (totalTime <= 0) {
+ totalTime = 0;
+
+ if (getFrames() != null) {
+ for (FrameInfo f : getFrames()) {
+ totalTime += f.getNetTime();
+ totalTime += getTotalTime(f.getChildren());
+ }
+ }
+ }
+ return totalTime;
+ }
+
+ /**
+ * Get the total time for a thread
+ * @param ti The thread
+ * @return The total time (ns)
+ */
+ private long getTotalTime(List<FrameInfo> l) {
+ long r = 0;
+
+ if (l != null) {
+ for (FrameInfo f : l) {
+ r += f.getNetTime();
+ r += getTotalTime(f.getChildren());
+ }
+ }
+
+ return r;
+ }
+}
Added: branches/JBossProfiler2/src/main/org/jboss/profiler/shared/Version.java
===================================================================
--- branches/JBossProfiler2/src/main/org/jboss/profiler/shared/Version.java (rev 0)
+++ branches/JBossProfiler2/src/main/org/jboss/profiler/shared/Version.java 2008-02-10 10:59:33 UTC (rev 420)
@@ -0,0 +1,47 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2007, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file 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.shared;
+
+/**
+ * The version class
+ * @author Jesper Pedersen <jep at worldleaguesports.com>
+ */
+public class Version {
+
+ /** The vendor */
+ public static final String VENDOR = "JBoss";
+
+ /** The product */
+ public static final String PRODUCT = "Profiler";
+
+ /** The version */
+ public static final String VERSION = "2.0.CR9";
+
+ /** Full version */
+ public static final String FULL_VERSION = VENDOR + " " + PRODUCT + " " + VERSION;
+
+ /**
+ * Constructor
+ */
+ private Version() {
+ }
+}
Added: branches/JBossProfiler2/src/main/org/jboss/profiler/shared/Visibility.java
===================================================================
--- branches/JBossProfiler2/src/main/org/jboss/profiler/shared/Visibility.java (rev 0)
+++ branches/JBossProfiler2/src/main/org/jboss/profiler/shared/Visibility.java 2008-02-10 10:59:33 UTC (rev 420)
@@ -0,0 +1,44 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2007, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file 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.shared;
+
+/**
+ * Defines the method visibility
+ * @author Jesper Pedersen <jep at worldleaguesports.com>
+ */
+public enum Visibility {
+
+ /**
+ * Private
+ */
+ PRIVATE,
+
+ /**
+ * Protected
+ */
+ PROTECTED,
+
+ /**
+ * Public
+ */
+ PUBLIC
+}
Added: branches/JBossProfiler2/src/test/org/jboss/profiler/test/Complex.java
===================================================================
--- branches/JBossProfiler2/src/test/org/jboss/profiler/test/Complex.java (rev 0)
+++ branches/JBossProfiler2/src/test/org/jboss/profiler/test/Complex.java 2008-02-10 10:59:33 UTC (rev 420)
@@ -0,0 +1,55 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2007, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file 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;
+
+/**
+ * The complex class
+ * @author Jesper Pedersen <jep at worldleaguesports.com>
+ */
+public class Complex {
+
+ /**
+ * Constructor
+ */
+ public Complex() {
+ }
+
+ /**
+ * Call: Public
+ */
+ public void call() {
+ privateCall();
+ }
+
+ /**
+ * Call: Private
+ */
+ private void privateCall() {
+ publicCall();
+ }
+
+ /**
+ * Call: Public
+ */
+ public void publicCall() {
+ }
+}
Added: branches/JBossProfiler2/src/test/org/jboss/profiler/test/Entity.java
===================================================================
--- branches/JBossProfiler2/src/test/org/jboss/profiler/test/Entity.java (rev 0)
+++ branches/JBossProfiler2/src/test/org/jboss/profiler/test/Entity.java 2008-02-10 10:59:33 UTC (rev 420)
@@ -0,0 +1,130 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2007, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file 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;
+
+import javax.ejb.CreateException;
+import javax.ejb.EJBException;
+import javax.ejb.EntityBean;
+import javax.ejb.EntityContext;
+import javax.ejb.RemoveException;
+
+/**
+ * Entity
+ * @author Jesper Pedersen <jep at worldleaguesports.com>
+ */
+public class Entity implements EntityBean {
+ /** Entity context */
+ protected EntityContext ejbContext;
+
+ /**
+ * A container invokes this method when the instance is
+ * taken out of the pool of available instances to become
+ * associated with a specific EJB object.
+ *
+ * @exception EJBException Thrown by the method to indicate a failure
+ * caused by a system-level error.
+ */
+ public void ejbActivate() throws EJBException {
+ }
+
+ /**
+ * A container invokes this method on an instance before
+ * the instance becomes disassociated with a specific EJB object.
+ *
+ * @exception EJBException Thrown by the method to indicate a failure
+ * caused by a system-level error.
+ */
+ public void ejbPassivate() throws EJBException {
+ }
+
+ /**
+ * A container invokes this method before it removes the EJB object
+ * that is currently associated with the instance.
+ *
+ * @exception RemoveException Thrown by the method to indicate a failure
+ * caused by a remove error.
+ * @exception EJBException Thrown by the method to indicate a failure
+ * caused by a system-level error.
+ */
+ public void ejbRemove() throws RemoveException, EJBException {
+ }
+
+ /**
+ * A container invokes this method to instruct the instance to
+ * synchronize its state by loading it state from the underlying
+ * database.
+ *
+ * @exception EJBException Thrown by the method to indicate a failure
+ * caused by a system-level error.
+ */
+ public void ejbLoad() throws EJBException {
+ }
+
+ /**
+ * A container invokes this method to instruct the instance to
+ * synchronize its state by storing it to the underlying database.
+ *
+ * @exception EJBException Thrown by the method to indicate a failure
+ * caused by a system-level error.
+ */
+ public void ejbStore() throws EJBException {
+ }
+
+ /**
+ * Set the associated entity context.
+ *
+ * @param ctx An EntityContext interface for the instance. The instance should store the reference
+ * to the context in an instance variable.
+ * @exception EJBException Thrown by the method to indicate a failure
+ * caused by a system-level error.
+ */
+ public void setEntityContext(EntityContext ctx) throws EJBException {
+ ejbContext = ctx;
+ }
+
+ /**
+ * Unset the associated entity context.
+ *
+ * @exception EJBException Thrown by the method to indicate a failure
+ * caused by a system-level error.
+ */
+ public void unsetEntityContext() throws EJBException {
+ ejbContext = null;
+ }
+
+ /**
+ * Create
+ * @return The primary key of the new instance
+ * @exception CreateException Thrown if a create error occurs
+ */
+ public Long ejbCreate() throws CreateException {
+ return null;
+ }
+
+ /**
+ * Post create method
+ * @exception CreateException Thrown if a create error occurs
+ */
+ public void ejbPostCreate(String name, String logo, Integer pc, Integer sc)
+ throws CreateException {
+ }
+}
Added: branches/JBossProfiler2/src/test/org/jboss/profiler/test/Entity3.java
===================================================================
--- branches/JBossProfiler2/src/test/org/jboss/profiler/test/Entity3.java (rev 0)
+++ branches/JBossProfiler2/src/test/org/jboss/profiler/test/Entity3.java 2008-02-10 10:59:33 UTC (rev 420)
@@ -0,0 +1,32 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2007, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file 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;
+
+import javax.persistence.Entity;
+
+/**
+ * Entity
+ * @author Jesper Pedersen <jep at worldleaguesports.com>
+ */
+ at Entity
+public class Entity3 {
+}
Added: branches/JBossProfiler2/src/test/org/jboss/profiler/test/JMX.java
===================================================================
--- branches/JBossProfiler2/src/test/org/jboss/profiler/test/JMX.java (rev 0)
+++ branches/JBossProfiler2/src/test/org/jboss/profiler/test/JMX.java 2008-02-10 10:59:33 UTC (rev 420)
@@ -0,0 +1,35 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2007, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file 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;
+
+/**
+ * JMX MBean: Implementation
+ * @author Jesper Pedersen <jep at worldleaguesports.com>
+ */
+public class JMX implements JMXMBean {
+
+ /**
+ * Constructor
+ */
+ public JMX() {
+ }
+}
Added: branches/JBossProfiler2/src/test/org/jboss/profiler/test/JMXMBean.java
===================================================================
--- branches/JBossProfiler2/src/test/org/jboss/profiler/test/JMXMBean.java (rev 0)
+++ branches/JBossProfiler2/src/test/org/jboss/profiler/test/JMXMBean.java 2008-02-10 10:59:33 UTC (rev 420)
@@ -0,0 +1,29 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2007, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file 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;
+
+/**
+ * JMX MBean: Interface
+ * @author Jesper Pedersen <jep at worldleaguesports.com>
+ */
+public interface JMXMBean {
+}
Added: branches/JBossProfiler2/src/test/org/jboss/profiler/test/ManagedBean.java
===================================================================
--- branches/JBossProfiler2/src/test/org/jboss/profiler/test/ManagedBean.java (rev 0)
+++ branches/JBossProfiler2/src/test/org/jboss/profiler/test/ManagedBean.java 2008-02-10 10:59:33 UTC (rev 420)
@@ -0,0 +1,37 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2007, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file 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;
+
+import java.io.Serializable;
+
+/**
+ * JSF: Managed Bean
+ * @author Jesper Pedersen <jep at worldleaguesports.com>
+ */
+public class ManagedBean implements Serializable {
+
+ /**
+ * Constructor
+ */
+ public ManagedBean() {
+ }
+}
Added: branches/JBossProfiler2/src/test/org/jboss/profiler/test/Message.java
===================================================================
--- branches/JBossProfiler2/src/test/org/jboss/profiler/test/Message.java (rev 0)
+++ branches/JBossProfiler2/src/test/org/jboss/profiler/test/Message.java 2008-02-10 10:59:33 UTC (rev 420)
@@ -0,0 +1,74 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2007, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file 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;
+
+import javax.ejb.EJBException;
+import javax.ejb.MessageDrivenContext;
+import javax.ejb.MessageDrivenBean;
+import javax.jms.MessageListener;
+
+
+/**
+ * Message
+ * @author Jesper Pedersen <jep at worldleaguesports.com>
+ */
+public class Message implements MessageDrivenBean, MessageListener {
+ /** Message context */
+ protected MessageDrivenContext ejbContext;
+
+ /**
+ * Default message driven create method
+ */
+ public void ejbCreate() {
+ }
+
+ /**
+ * A container invokes this method before it removes the EJB object
+ * that is currently associated with the instance.
+ *
+ * @exception EJBException Thrown by the method to indicate a failure
+ * caused by a system-level error.
+ */
+ public void ejbRemove() throws EJBException {
+ ejbContext = null;
+ }
+
+ /**
+ * Set the associated message context.
+ *
+ * @param ctx A MessageDrivenContext interface for the instance. The instance should store the
+ * reference to the context in an instance variable.
+ * @exception EJBException Thrown by the method to indicate a failure
+ * caused by a system-level error.
+ */
+ public void setMessageDrivenContext(MessageDrivenContext ctx) throws EJBException {
+ ejbContext = ctx;
+ }
+
+ /**
+ * On message
+ * @param message The incoming message
+ */
+ public void onMessage(javax.jms.Message message) {
+ }
+
+}
Added: branches/JBossProfiler2/src/test/org/jboss/profiler/test/Message3.java
===================================================================
--- branches/JBossProfiler2/src/test/org/jboss/profiler/test/Message3.java (rev 0)
+++ branches/JBossProfiler2/src/test/org/jboss/profiler/test/Message3.java 2008-02-10 10:59:33 UTC (rev 420)
@@ -0,0 +1,32 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2007, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file 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;
+
+import javax.ejb.MessageDriven;
+
+/**
+ * Message
+ * @author Jesper Pedersen <jep at worldleaguesports.com>
+ */
+ at MessageDriven
+public class Message3 {
+}
Added: branches/JBossProfiler2/src/test/org/jboss/profiler/test/Session.java
===================================================================
--- branches/JBossProfiler2/src/test/org/jboss/profiler/test/Session.java (rev 0)
+++ branches/JBossProfiler2/src/test/org/jboss/profiler/test/Session.java 2008-02-10 10:59:33 UTC (rev 420)
@@ -0,0 +1,93 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2007, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file 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;
+
+import javax.ejb.CreateException;
+import javax.ejb.EJBException;
+import javax.ejb.SessionBean;
+import javax.ejb.SessionContext;
+
+/**
+ * Session
+ * @author Jesper Pedersen <jep at worldleaguesports.com>
+ */
+public class Session implements SessionBean {
+ /** Session context */
+ protected SessionContext ejbContext;
+
+ /**
+ * A container invokes this method when the instance is
+ * taken out of the pool of available instances to become
+ * associated with a specific EJB object.
+ *
+ * @exception EJBException Thrown by the method to indicate a failure
+ * caused by a system-level error.
+ */
+ public void ejbActivate() throws EJBException {
+ }
+
+ /**
+ * A container invokes this method on an instance before
+ * the instance becomes disassociated with a specific EJB object.
+ *
+ * @exception EJBException Thrown by the method to indicate a failure
+ * caused by a system-level error.
+ */
+ public void ejbPassivate() throws EJBException {
+ }
+
+ /**
+ * A container invokes this method before it removes the EJB object
+ * that is currently associated with the instance.
+ *
+ * @exception EJBException Thrown by the method to indicate a failure
+ * caused by a system-level error.
+ */
+ public void ejbRemove() throws EJBException {
+ }
+
+ /**
+ * Set the associated session context.
+ *
+ * @param ctx A SessionContext interface for the instance. The instance should store the reference
+ * to the context in an instance variable.
+ * @exception EJBException Thrown by the method to indicate a failure
+ * caused by a system-level error.
+ */
+ public void setSessionContext(SessionContext ctx) throws EJBException {
+ ejbContext = ctx;
+ }
+
+ /**
+ * Unset the associated session context.
+ */
+ public void unsetSessionContext() {
+ ejbContext = null;
+ }
+
+ /**
+ * Create
+ * @exception CreateException Thrown if a create error occurs
+ */
+ public void ejbCreate() throws CreateException {
+ }
+}
Added: branches/JBossProfiler2/src/test/org/jboss/profiler/test/Session3.java
===================================================================
--- branches/JBossProfiler2/src/test/org/jboss/profiler/test/Session3.java (rev 0)
+++ branches/JBossProfiler2/src/test/org/jboss/profiler/test/Session3.java 2008-02-10 10:59:33 UTC (rev 420)
@@ -0,0 +1,32 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2007, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file 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;
+
+import javax.ejb.Stateless;
+
+/**
+ * Session
+ * @author Jesper Pedersen <jep at worldleaguesports.com>
+ */
+ at Stateless
+public class Session3 {
+}
Added: branches/JBossProfiler2/src/test/org/jboss/profiler/test/Simple.java
===================================================================
--- branches/JBossProfiler2/src/test/org/jboss/profiler/test/Simple.java (rev 0)
+++ branches/JBossProfiler2/src/test/org/jboss/profiler/test/Simple.java 2008-02-10 10:59:33 UTC (rev 420)
@@ -0,0 +1,41 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2007, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file 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;
+
+/**
+ * The simple class
+ * @author Jesper Pedersen <jep at worldleaguesports.com>
+ */
+public class Simple {
+
+ /**
+ * Constructor
+ */
+ public Simple() {
+ }
+
+ /**
+ * Call
+ */
+ public void call() {
+ }
+}
Added: branches/JBossProfiler2/src/test/org/jboss/profiler/test/Test.java
===================================================================
--- branches/JBossProfiler2/src/test/org/jboss/profiler/test/Test.java (rev 0)
+++ branches/JBossProfiler2/src/test/org/jboss/profiler/test/Test.java 2008-02-10 10:59:33 UTC (rev 420)
@@ -0,0 +1,122 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2007, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file 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;
+
+/**
+ * The test class
+ * @author Jesper Pedersen <jep at worldleaguesports.com>
+ */
+public class Test {
+
+ /**
+ * Method: A
+ * @param times The number of times
+ */
+ public void a(int times) {
+ for (int i = 0; i < times; i++) {
+ Simple s = new Simple();
+ s.call();
+ }
+ }
+
+ /**
+ * Method: B
+ */
+ public void b() {
+ for (int i = 0; i < 5000; i++) {
+ Complex c = new Complex();
+ c.call();
+ }
+ }
+
+ /**
+ * Method: C
+ */
+ public void c() {
+ for (int i = 0; i < 10; i++) {
+ Thread t = new Thread() {
+ @Override
+ public void run() {
+ d();
+ }
+ };
+ t.start();
+ }
+ }
+
+ /**
+ * Method: D
+ */
+ public void d() {
+ }
+
+ /**
+ * Method: E
+ */
+ public void e() {
+ try {
+ Session session = new Session();
+ session.ejbCreate();
+
+ Entity entity = new Entity();
+ entity.ejbCreate();
+
+ Message message = new Message();
+ message.onMessage(null);
+
+ TestServlet servlet = new TestServlet();
+ servlet.doGet(null, null);
+
+ JMX jmx = new JMX();
+
+ ManagedBean mb = new ManagedBean();
+
+ Session3 session3 = new Session3();
+
+ Entity3 entity3 = new Entity3();
+
+ Message3 message3 = new Message3();
+
+ } catch (Exception e) {
+ }
+ }
+
+ /**
+ * The main method
+ * @param args The arguments
+ */
+ public static void main(String[] args) {
+ Test t = new Test();
+
+ int i = 10000;
+
+ if (args != null && args.length > 0) {
+ i = Integer.parseInt(args[0]);
+ }
+
+ t.a(i);
+ t.b();
+ t.c();
+ t.e();
+ System.out.println("Done.");
+ }
+}
Added: branches/JBossProfiler2/src/test/org/jboss/profiler/test/TestServlet.java
===================================================================
--- branches/JBossProfiler2/src/test/org/jboss/profiler/test/TestServlet.java (rev 0)
+++ branches/JBossProfiler2/src/test/org/jboss/profiler/test/TestServlet.java 2008-02-10 10:59:33 UTC (rev 420)
@@ -0,0 +1,46 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2007, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file 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;
+
+import java.io.IOException;
+import javax.servlet.ServletException;
+import javax.servlet.http.HttpServlet;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+/**
+ * Servlet
+ * @author Jesper Pedersen <jep at worldleaguesports.com>
+ */
+public class TestServlet extends HttpServlet {
+
+ /**
+ * Handles the GET requests
+ * @param req The servlet request
+ * @param resp The servlet response
+ * @throws ServletException in case of servlet error
+ * @throws IOException in case of IO error
+ */
+ public void doGet(HttpServletRequest req, HttpServletResponse resp)
+ throws ServletException, IOException {
+ }
+}
More information about the jboss-cvs-commits
mailing list