Class StackIntrospector
java.lang.Object
org.apache.log.util.StackIntrospector
A set of utilities to inspect current stack frame.
- Version:
- $Id: StackIntrospector.java 30977 2004-07-30 03:57:54 -0500 (Fri, 30 Jul 2004) niclas $
- Author:
- Avalon Development Team, Sylvain Wallez, Stuart Roebuck
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprivate static final classHack to get the call stack as an array of classes. -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate static StackIntrospector.CallStackMethod to cache CallStack hack as needed -
Constructor Summary
ConstructorsModifierConstructorDescriptionprivatePrivate constructor to block instantiation. -
Method Summary
Modifier and TypeMethodDescriptionstatic final ClassgetCallerClass(Class clazz) Find the caller of the passed in Class.static final ClassgetCallerClass(Class clazz, int stackDepthOffset) Find the caller of the passed in Class.static final StringgetCallerMethod(Class clazz) Get the method path name for the method from which the LogEvent was created, this includes the path name and the source filename and line number if the source was compiled with debugging on.private static StackIntrospector.CallStackCreate Hack SecurityManager to get CallStack.static final StringgetRecentStack(Class clazz, int entries) Return the current call stack as a String, starting with the first call in the stack after a reference to theclazzclass, and then displayentriesentries.
-
Field Details
-
c_callStack
Method to cache CallStack hack as needed
-
-
Constructor Details
-
StackIntrospector
private StackIntrospector()Private constructor to block instantiation.
-
-
Method Details
-
getCallStack
Create Hack SecurityManager to get CallStack.- Returns:
- the CallStack object
- Throws:
SecurityException- if an existing SecurityManager disallows construction of another SecurityManager
-
getCallerClass
Find the caller of the passed in Class. May return null if caller not found on execution stack- Parameters:
clazz- the Class to search for on stack to find caller of- Returns:
- the Class of object that called parrameter class
- Throws:
SecurityException- if an existing SecurityManager disallows construction of another SecurityManager and thus blocks method results
-
getCallerClass
Find the caller of the passed in Class. May return null if caller not found on execution stack- Parameters:
clazz- the Class to search for on stack to find caller ofstackDepthOffset- Offset call-stack depth to find caller- Returns:
- the Class of object that called parrameter class
- Throws:
SecurityException- if an existing SecurityManager disallows construction of another SecurityManager and thus blocks method results
-
getCallerMethod
Get the method path name for the method from which the LogEvent was created, this includes the path name and the source filename and line number if the source was compiled with debugging on.- Parameters:
clazz- the Class to search for on stack to find caller of- Returns:
- The method path name in the form "the.package.path.Method"
-
getRecentStack
Return the current call stack as a String, starting with the first call in the stack after a reference to theclazzclass, and then displayentriesentries.This can be useful for debugging code to determine where calls to a method are coming from.
- Parameters:
clazz- the last class on the stack you are not interested in!entries- the number of stack lines to return.- Returns:
- The method path name in the form "the.package.path.Method"
-