Author: dblevins Date: Mon Sep 27 12:33:39 2004 New Revision: 47326 Added: geronimo/trunk/modules/common/src/java/org/apache/geronimo/common/ExceptionUtil.java Modified: geronimo/trunk/modules/deployment/src/java/org/apache/geronimo/deployment/DeploymentException.java Log: New util to cut out parts of a stacktrace which are "glue" level. Not perfect, but a step in the right direction.
Cuts out o.a.g.gbean.jmx.*, mx4j.*, and net.sf.cglib.reflect.* Put it in action on the DeploymentException. Added: geronimo/trunk/modules/common/src/java/org/apache/geronimo/common/ExceptionUtil.java ============================================================================== --- (empty file) +++ geronimo/trunk/modules/common/src/java/org/apache/geronimo/common/ExceptionUtil.java Mon Sep 27 12:33:39 2004 @@ -0,0 +1,51 @@ +/** + * + * Copyright 2003-2004 The Apache Software Foundation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.geronimo.deployment; + +import java.util.ArrayList; + +/** + * @version $Rev: 46019 $ $Date: 2004-09-14 02:56:06 -0700 (Tue, 14 Sep 2004) $ + */ +public class ExceptionUtil { + + private static final String[] excludedPackages = { + "org.apache.geronimo.gbean.jmx.", "mx4j.", "net.sf.cglib.reflect" + }; + + public static void trimStackTrace(Throwable t) { + if (t == null) { + return; + } + + StackTraceElement[] trace = t.getStackTrace(); + ArrayList list = new ArrayList(); + + TRIM: for (int i = 0; i < trace.length; i++) { + String className = trace[i].getClassName(); + for (int j = 0; j < excludedPackages.length; j++) { + if (className.startsWith(excludedPackages[j])) { + continue TRIM; + } + } + list.add(trace[i]); + } + + t.setStackTrace((StackTraceElement[]) list.toArray(new StackTraceElement[0])); + trimStackTrace(t.getCause()); + } +} Modified: geronimo/trunk/modules/deployment/src/java/org/apache/geronimo/deployment/DeploymentException.java ============================================================================== --- geronimo/trunk/modules/deployment/src/java/org/apache/geronimo/deployment/DeploymentException.java (original) +++ geronimo/trunk/modules/deployment/src/java/org/apache/geronimo/deployment/DeploymentException.java Mon Sep 27 12:33:39 2004 @@ -17,27 +17,32 @@ package org.apache.geronimo.deployment; + + + /** - * - * * @version $Rev$ $Date$ */ public class DeploymentException extends Exception { public DeploymentException() { + ExceptionUtil.trimStackTrace(this); } public DeploymentException(Throwable cause) { super(cause); + ExceptionUtil.trimStackTrace(this); } public DeploymentException(String message) { super(message); + ExceptionUtil.trimStackTrace(this); } public DeploymentException(String message, Throwable cause) { super(message, cause); + ExceptionUtil.trimStackTrace(this); } }