[jboss-cvs] JBoss Profiler SVN: r449 - in branches/JBossProfiler2: src/main/org/jboss/profiler/ant and 1 other directory.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Sat May 17 12:01:42 EDT 2008
Author: jesper.pedersen
Date: 2008-05-17 12:01:42 -0400 (Sat, 17 May 2008)
New Revision: 449
Added:
branches/JBossProfiler2/src/main/org/jboss/profiler/ant/AddClassesTask.java
branches/JBossProfiler2/src/main/org/jboss/profiler/ant/ClearSnapshotsTask.java
branches/JBossProfiler2/src/main/org/jboss/profiler/ant/GCTask.java
branches/JBossProfiler2/src/main/org/jboss/profiler/ant/RemoveClassesTask.java
branches/JBossProfiler2/src/main/org/jboss/profiler/ant/SaveTask.java
Modified:
branches/JBossProfiler2/doc/README.txt
Log:
Additional Ant tasks
Modified: branches/JBossProfiler2/doc/README.txt
===================================================================
--- branches/JBossProfiler2/doc/README.txt 2008-05-17 15:19:06 UTC (rev 448)
+++ branches/JBossProfiler2/doc/README.txt 2008-05-17 16:01:42 UTC (rev 449)
@@ -49,9 +49,14 @@
* Compare snapshots
* Client
+ x Ant integration
x Command line
+JBoss Profiler 2 was designed to run on the JBoss Application Server 4.2 and JBoss Application Server 5.0
+releases or any other Java applications using Java Runtime Environment 5 or higher.
+
+
Command line client:
--------------------
Usage: Client [-h host] [-p port] <command>
@@ -285,10 +290,15 @@
The following tasks exists:
- <taskdef name="enableprofiler" classname="org.jboss.profiler.ant.EnableProfilerTask"/>
- <taskdef name="disableprofiler" classname="org.jboss.profiler.ant.DisableProfilerTask"/>
+ <taskdef name="enable" classname="org.jboss.profiler.ant.EnableProfilerTask"/>
+ <taskdef name="disable" classname="org.jboss.profiler.ant.DisableProfilerTask"/>
<taskdef name="startprofiler" classname="org.jboss.profiler.ant.StartProfilerTask"/>
<taskdef name="stopprofiler" classname="org.jboss.profiler.ant.StopProfilerTask"/>
+ <taskdef name="clearsnapshots" classname="org.jboss.profiler.ant.ClearSnapshotsTask"/>
+ <taskdef name="gc" classname="org.jboss.profiler.ant.GCTask"/>
+ <taskdef name="save" classname="org.jboss.profiler.ant.SaveTask"/>
+ <taskdef name="add" classname="org.jboss.profiler.ant.AddClassesTask"/>
+ <taskdef name="remove" classname="org.jboss.profiler.ant.RemoveClassesTask"/>
All tasks have the following attributes in common:
@@ -296,6 +306,23 @@
host - The host name (default: localhost)
port - The port number (default: 5400)
+Save task:
+
+ snapshot - The snapshot number
+ destination - The destination of the snapshot
+
+Add task:
+
+ classes - The classes that should be added
+ [package|class][|visibility][,...]
+ f.ex: org.jboss.profiler.test.*|public,org.jboss.profiler.test.sub.*|private
+
+Remove task:
+
+ classes - The classes that should be removed
+ [package|class][,...]
+ f.ex: org.jboss.profiler.test.*
+
Example:
<startprofiler protocol="socket"
host="localhost"
Added: branches/JBossProfiler2/src/main/org/jboss/profiler/ant/AddClassesTask.java
===================================================================
--- branches/JBossProfiler2/src/main/org/jboss/profiler/ant/AddClassesTask.java (rev 0)
+++ branches/JBossProfiler2/src/main/org/jboss/profiler/ant/AddClassesTask.java 2008-05-17 16:01:42 UTC (rev 449)
@@ -0,0 +1,110 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2007-2008, 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.ant;
+
+import org.jboss.profiler.shared.Command;
+import org.jboss.profiler.shared.CommandType;
+import org.jboss.profiler.shared.Visibility;
+
+import java.util.StringTokenizer;
+
+import org.jboss.remoting.InvokerLocator;
+
+import org.apache.tools.ant.BuildException;
+
+/**
+ * The add classes Ant task
+ * @author Jesper Pedersen <jesper.pedersen at jboss.org>
+ */
+public class AddClassesTask extends AbstractTask {
+
+ /** Classes */
+ private String classes;
+
+ /**
+ * Constructor
+ */
+ public AddClassesTask() {
+ super();
+ }
+
+ /**
+ * Get the classes
+ * @return The classes
+ */
+ public String getClasses() {
+ return classes;
+ }
+
+ /**
+ * Set the classes
+ * @param c The classes
+ */
+ public void setClasses(String c) {
+ classes = c;
+ }
+
+ /**
+ * Execute Ant task
+ * @exception BuildException If an error occurs
+ */
+ public void execute() throws BuildException {
+ try {
+ if (classes != null && classes.trim().length() > 0) {
+ InvokerLocator locator = new InvokerLocator(getProtocol() + "://" + getHost() + ":" + getPort());
+
+ org.jboss.remoting.Client remotingClient = new org.jboss.remoting.Client(locator);
+ remotingClient.connect();
+
+ StringTokenizer st = new StringTokenizer(classes, ", ");
+ while (st.hasMoreTokens()) {
+ String token = st.nextToken();
+
+ String clz = "";
+ String vs = "";
+
+ if (token.indexOf("|") == -1) {
+ clz = token;
+ } else {
+ clz = token.substring(0, token.indexOf("|"));
+ vs = token.substring(token.indexOf("|") + 1);
+ }
+
+ Visibility v = Visibility.PUBLIC;
+ if (vs.equalsIgnoreCase("private")) {
+ v = Visibility.PRIVATE;
+ } else if (vs.equalsIgnoreCase("protected")) {
+ v = Visibility.PROTECTED;
+ } else if (vs.equalsIgnoreCase("package")) {
+ v = Visibility.PACKAGE;
+ }
+ Command cmd = new Command(CommandType.ADD_CLASSES, new Object[] { clz, v } );
+ String response = (String)remotingClient.invoke(cmd);
+ }
+
+ remotingClient.disconnect();
+ }
+ } catch (Throwable t) {
+ throw new BuildException(t.getMessage(), t);
+ }
+ }
+}
Added: branches/JBossProfiler2/src/main/org/jboss/profiler/ant/ClearSnapshotsTask.java
===================================================================
--- branches/JBossProfiler2/src/main/org/jboss/profiler/ant/ClearSnapshotsTask.java (rev 0)
+++ branches/JBossProfiler2/src/main/org/jboss/profiler/ant/ClearSnapshotsTask.java 2008-05-17 16:01:42 UTC (rev 449)
@@ -0,0 +1,64 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2007-2008, 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.ant;
+
+import org.jboss.profiler.shared.Command;
+import org.jboss.profiler.shared.CommandType;
+
+import org.jboss.remoting.InvokerLocator;
+
+import org.apache.tools.ant.BuildException;
+
+/**
+ * The clear snapshots Ant task
+ * @author Jesper Pedersen <jesper.pedersen at jboss.org>
+ */
+public class ClearSnapshotsTask extends AbstractTask {
+
+ /**
+ * Constructor
+ */
+ public ClearSnapshotsTask() {
+ super();
+ }
+
+ /**
+ * Execute Ant task
+ * @exception BuildException If an error occurs
+ */
+ public void execute() throws BuildException {
+ try {
+ Command cmd = new Command(CommandType.CLEAR_SNAPSHOTS);
+
+ InvokerLocator locator = new InvokerLocator(getProtocol() + "://" + getHost() + ":" + getPort());
+
+ org.jboss.remoting.Client remotingClient = new org.jboss.remoting.Client(locator);
+ remotingClient.connect();
+
+ String response = (String)remotingClient.invoke(cmd);
+
+ remotingClient.disconnect();
+ } catch (Throwable t) {
+ throw new BuildException(t.getMessage(), t);
+ }
+ }
+}
Added: branches/JBossProfiler2/src/main/org/jboss/profiler/ant/GCTask.java
===================================================================
--- branches/JBossProfiler2/src/main/org/jboss/profiler/ant/GCTask.java (rev 0)
+++ branches/JBossProfiler2/src/main/org/jboss/profiler/ant/GCTask.java 2008-05-17 16:01:42 UTC (rev 449)
@@ -0,0 +1,64 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2007-2008, 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.ant;
+
+import org.jboss.profiler.shared.Command;
+import org.jboss.profiler.shared.CommandType;
+
+import org.jboss.remoting.InvokerLocator;
+
+import org.apache.tools.ant.BuildException;
+
+/**
+ * The garbage collection Ant task
+ * @author Jesper Pedersen <jesper.pedersen at jboss.org>
+ */
+public class GCTask extends AbstractTask {
+
+ /**
+ * Constructor
+ */
+ public GCTask() {
+ super();
+ }
+
+ /**
+ * Execute Ant task
+ * @exception BuildException If an error occurs
+ */
+ public void execute() throws BuildException {
+ try {
+ Command cmd = new Command(CommandType.GC);
+
+ InvokerLocator locator = new InvokerLocator(getProtocol() + "://" + getHost() + ":" + getPort());
+
+ org.jboss.remoting.Client remotingClient = new org.jboss.remoting.Client(locator);
+ remotingClient.connect();
+
+ String response = (String)remotingClient.invoke(cmd);
+
+ remotingClient.disconnect();
+ } catch (Throwable t) {
+ throw new BuildException(t.getMessage(), t);
+ }
+ }
+}
Added: branches/JBossProfiler2/src/main/org/jboss/profiler/ant/RemoveClassesTask.java
===================================================================
--- branches/JBossProfiler2/src/main/org/jboss/profiler/ant/RemoveClassesTask.java (rev 0)
+++ branches/JBossProfiler2/src/main/org/jboss/profiler/ant/RemoveClassesTask.java 2008-05-17 16:01:42 UTC (rev 449)
@@ -0,0 +1,90 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2007-2008, 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.ant;
+
+import org.jboss.profiler.shared.Command;
+import org.jboss.profiler.shared.CommandType;
+
+import java.util.StringTokenizer;
+
+import org.jboss.remoting.InvokerLocator;
+
+import org.apache.tools.ant.BuildException;
+
+/**
+ * The remove classes Ant task
+ * @author Jesper Pedersen <jesper.pedersen at jboss.org>
+ */
+public class RemoveClassesTask extends AbstractTask {
+
+ /** Classes */
+ private String classes;
+
+ /**
+ * Constructor
+ */
+ public RemoveClassesTask() {
+ super();
+ }
+
+ /**
+ * Get the classes
+ * @return The classes
+ */
+ public String getClasses() {
+ return classes;
+ }
+
+ /**
+ * Set the classes
+ * @param c The classes
+ */
+ public void setClasses(String c) {
+ classes = c;
+ }
+
+ /**
+ * Execute Ant task
+ * @exception BuildException If an error occurs
+ */
+ public void execute() throws BuildException {
+ try {
+ if (classes != null && classes.trim().length() > 0) {
+ InvokerLocator locator = new InvokerLocator(getProtocol() + "://" + getHost() + ":" + getPort());
+
+ org.jboss.remoting.Client remotingClient = new org.jboss.remoting.Client(locator);
+ remotingClient.connect();
+
+ StringTokenizer st = new StringTokenizer(classes, ", ");
+ while (st.hasMoreTokens()) {
+ String token = st.nextToken();
+ Command cmd = new Command(CommandType.REMOVE_CLASSES, new Object[] { token } );
+ String response = (String)remotingClient.invoke(cmd);
+ }
+
+ remotingClient.disconnect();
+ }
+ } catch (Throwable t) {
+ throw new BuildException(t.getMessage(), t);
+ }
+ }
+}
Added: branches/JBossProfiler2/src/main/org/jboss/profiler/ant/SaveTask.java
===================================================================
--- branches/JBossProfiler2/src/main/org/jboss/profiler/ant/SaveTask.java (rev 0)
+++ branches/JBossProfiler2/src/main/org/jboss/profiler/ant/SaveTask.java 2008-05-17 16:01:42 UTC (rev 449)
@@ -0,0 +1,114 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2007-2008, 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.ant;
+
+import org.jboss.profiler.shared.Command;
+import org.jboss.profiler.shared.CommandType;
+import org.jboss.profiler.shared.Snapshot;
+import org.jboss.profiler.shared.SnapshotHelper;
+
+import java.io.File;
+
+import org.jboss.remoting.InvokerLocator;
+
+import org.apache.tools.ant.BuildException;
+
+/**
+ * The save Ant task
+ * @author Jesper Pedersen <jesper.pedersen at jboss.org>
+ */
+public class SaveTask extends AbstractTask {
+
+ /** The snapshot */
+ private int snapshot;
+
+ /** Destination */
+ private File destination;
+
+ /**
+ * Constructor
+ */
+ public SaveTask() {
+ super();
+ }
+
+ /**
+ * Get the snapshot
+ * @return The snapshot
+ */
+ public int getSnapshot() {
+ return snapshot;
+ }
+
+ /**
+ * Set the snapshot
+ * @param s The snapshot
+ */
+ public void setSnapshot(int s) {
+ snapshot = s;
+ }
+
+ /**
+ * Get the destination
+ * @return The destination
+ */
+ public File getDestination() {
+ return destination;
+ }
+
+ /**
+ * Set the destination
+ * @param d The destination
+ */
+ public void setDestination(File d) {
+ destination = d;
+ }
+
+ /**
+ * Execute Ant task
+ * @exception BuildException If an error occurs
+ */
+ public void execute() throws BuildException {
+ try {
+ Command cmd = new Command(CommandType.SAVE, new Object[] { Integer.valueOf(snapshot) } );
+
+ InvokerLocator locator = new InvokerLocator(getProtocol() + "://" + getHost() + ":" + getPort());
+
+ org.jboss.remoting.Client remotingClient = new org.jboss.remoting.Client(locator);
+ remotingClient.connect();
+
+ Snapshot snapshot = (Snapshot)remotingClient.invoke(cmd);
+
+ if (snapshot != null) {
+ if (getDestination() == null) {
+ SnapshotHelper.save(snapshot);
+ } else {
+ SnapshotHelper.save(snapshot, getDestination());
+ }
+ }
+
+ remotingClient.disconnect();
+ } catch (Throwable t) {
+ throw new BuildException(t.getMessage(), t);
+ }
+ }
+}
More information about the jboss-cvs-commits
mailing list