incubator-kato-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From monte...@apache.org
Subject svn commit: r780036 - in /incubator/kato/branches/experimental/maven_restructure/org.apache.kato/kato.tools.katoview/src/main/java/org/apache/kato/katoview/commands: TomcatCommand.java helpers/KatoSearch.java
Date Fri, 29 May 2009 17:13:42 GMT
Author: monteith
Date: Fri May 29 17:13:42 2009
New Revision: 780036

URL: http://svn.apache.org/viewvc?rev=780036&view=rev
Log:
Add missing JSP command

Modified:
    incubator/kato/branches/experimental/maven_restructure/org.apache.kato/kato.tools.katoview/src/main/java/org/apache/kato/katoview/commands/TomcatCommand.java
    incubator/kato/branches/experimental/maven_restructure/org.apache.kato/kato.tools.katoview/src/main/java/org/apache/kato/katoview/commands/helpers/KatoSearch.java

Modified: incubator/kato/branches/experimental/maven_restructure/org.apache.kato/kato.tools.katoview/src/main/java/org/apache/kato/katoview/commands/TomcatCommand.java
URL: http://svn.apache.org/viewvc/incubator/kato/branches/experimental/maven_restructure/org.apache.kato/kato.tools.katoview/src/main/java/org/apache/kato/katoview/commands/TomcatCommand.java?rev=780036&r1=780035&r2=780036&view=diff
==============================================================================
--- incubator/kato/branches/experimental/maven_restructure/org.apache.kato/kato.tools.katoview/src/main/java/org/apache/kato/katoview/commands/TomcatCommand.java
(original)
+++ incubator/kato/branches/experimental/maven_restructure/org.apache.kato/kato.tools.katoview/src/main/java/org/apache/kato/katoview/commands/TomcatCommand.java
Fri May 29 17:13:42 2009
@@ -16,6 +16,7 @@
 import java.util.Vector;
 
 import org.apache.kato.katoview.Output;
+import org.apache.kato.katoview.commands.tomcat.TomcatJSPCommand;
 import org.apache.kato.katoview.commands.tomcat.TomcatThreadPoolsCommand;
 import org.apache.kato.katoview.commands.tomcat.TomcatVersionCommand;
 
@@ -34,6 +35,8 @@
 		child_commands = new Vector();
 		child_commands.add(new TomcatVersionCommand(o));
 		child_commands.add(new TomcatThreadPoolsCommand(o));
+		child_commands.add(new TomcatJSPCommand(o));
+
 	}
 	
 }

Modified: incubator/kato/branches/experimental/maven_restructure/org.apache.kato/kato.tools.katoview/src/main/java/org/apache/kato/katoview/commands/helpers/KatoSearch.java
URL: http://svn.apache.org/viewvc/incubator/kato/branches/experimental/maven_restructure/org.apache.kato/kato.tools.katoview/src/main/java/org/apache/kato/katoview/commands/helpers/KatoSearch.java?rev=780036&r1=780035&r2=780036&view=diff
==============================================================================
--- incubator/kato/branches/experimental/maven_restructure/org.apache.kato/kato.tools.katoview/src/main/java/org/apache/kato/katoview/commands/helpers/KatoSearch.java
(original)
+++ incubator/kato/branches/experimental/maven_restructure/org.apache.kato/kato.tools.katoview/src/main/java/org/apache/kato/katoview/commands/helpers/KatoSearch.java
Fri May 29 17:13:42 2009
@@ -19,6 +19,7 @@
 
 import org.apache.kato.image.CorruptData;
 import org.apache.kato.image.CorruptDataException;
+import org.apache.kato.image.DataUnavailable;
 import org.apache.kato.image.Image;
 import org.apache.kato.image.ImageAddressSpace;
 import org.apache.kato.image.ImageProcess;
@@ -27,8 +28,12 @@
 import org.apache.kato.java.JavaClassLoader;
 import org.apache.kato.java.JavaField;
 import org.apache.kato.java.JavaHeap;
+import org.apache.kato.java.JavaLocation;
+import org.apache.kato.java.JavaMethod;
 import org.apache.kato.java.JavaObject;
 import org.apache.kato.java.JavaRuntime;
+import org.apache.kato.java.JavaStackFrame;
+import org.apache.kato.java.JavaThread;
 
 /**
  * Provides utility classes for retrieving things from dumps
@@ -241,6 +246,56 @@
 	}
 	
 	/**
+	 * Find all instances of a JavaClass with a passed name, and all of it's
+	 * subclasses.
+	 * 
+	 * @param runtime JavaRuntime 
+	 * @param className name o
+	 * @return List of JavaClasses
+	 */
+	public static List<JavaClass> findClasses(JavaRuntime runtime, String className) {
+		LinkedList<JavaClass> list = new LinkedList<JavaClass>();
+		
+		SubclassFinder finder = new SubclassFinder(className, list);
+		
+		visitClasses(runtime, finder);
+		
+		return list;
+	}
+	
+	/**
+	 * Supports findClasses method. 
+	 *
+	 */
+	private static class SubclassFinder implements JavaClassVisitor {
+		private String clazzName;
+		private List<JavaClass> list;
+		
+		public SubclassFinder(String name, List<JavaClass> list) {
+			if (name == null) {
+				throw new IllegalArgumentException("Cannot accept null class name");
+			}
+			this.clazzName = name;
+			this.list = list;
+		}
+		
+		public boolean visit(JavaClass clazz) throws KatoException {
+			JavaClass subClass = clazz;
+			while((clazz != null) 
+					&& !(clazzName.equals(clazz.getName()))) {
+				clazz = clazz.getSuperclass();
+			}
+			
+			if (clazz != null) {
+				list.add(subClass);
+			}
+			
+			return true;
+		}
+		
+	}
+	
+	/**
 	 * Executes the passed JavaObjectVisitor over all objects on all the heaps in
 	 * the given JavaRuntime.
 	 * CorruptData objects are not passed.
@@ -283,4 +338,56 @@
 			 }
 		}
 	}
+	
+	/**
+	 * Given a JavaClass, find all threads that are executing a method in that class.
+	 * 
+	 * @param runtime JavaRuntime to search
+	 * @param clazz JavaClass to look for
+	 * @return List of JavaThreads
+	 */
+	public static List<JavaThread> findClassInThreads(JavaRuntime runtime, JavaClass clazz)
{
+		List<JavaThread> list = new LinkedList<JavaThread>();
+		
+		for (Object nextThread : runtime.getThreads()) {
+			if (nextThread instanceof CorruptData) {
+				continue;
+			}
+			
+			JavaThread thread = (JavaThread) nextThread;
+			
+			// Iterate over all frames. If method is in passed class, add it to the list.
+	FRAMES:	for (Object nextFrame : thread.getStackFrames()) {
+				if (nextFrame instanceof CorruptData) {
+					continue;
+				}
+				
+				JavaStackFrame frame = (JavaStackFrame) nextFrame;
+				
+				JavaLocation location;
+				try {
+					location = frame.getLocation();
+				} catch (CorruptDataException e) {
+					continue FRAMES;
+				}
+				
+				if (location != null) {
+					try {
+						JavaMethod method = location.getMethod();
+						if (clazz.equals(method.getDeclaringClass())) {
+							list.add(thread);
+							break FRAMES;
+						}
+					} catch (CorruptDataException e) {
+						continue FRAMES;
+					} catch (DataUnavailable e) {
+						
+					}					
+				}				
+			}
+		}
+		
+		return list;
+	}
+	
 }



Mime
View raw message