Top Description Inners Fields Constructors Methods
org.apache.log.util

public final Class StackIntrospector

extends Object
Class Inheritance
Imports
java.io.PrintWriter, .StringWriter

A set of utilities to inspect current stack frame.
Authors
Avalon Development Team, Sylvain Wallez, Stuart Roebuck
Version
$Id: StackIntrospector.java 506267 2007-02-12 04:06:06Z crossley $

Nested and Inner Type Summary

Modifier and TypeClass and Description
private static class
StackIntrospector.CallStack

Deprecated as a consequence of SecurityManager being deprecated.
Hack to get the call stack as an array of classes.

Field Summary

Modifier and TypeField and Description
private static StackIntrospector.CallStack
c_callStack

Deprecated as a consequence of StackIntrospector.CallStack being deprecated.

Constructor Summary

AccessConstructor and Description
private
StackIntrospector()

Private constructor to block instantiation.

Method Summary

Modifier and TypeMethod and Description
public static final Class<T>

Returns:

the Class of object that called parrameter class
getCallerClass
(final Class<T>
the Class to search for on stack to find caller of
clazz
)

Find the caller of the passed in Class.

public static final Class<T>

Returns:

the Class of object that called parrameter class
getCallerClass
(final Class<T>
the Class to search for on stack to find caller of
clazz
,
int
Offset call-stack depth to find caller
stackDepthOffset
)

Find the caller of the passed in Class.

public static final String

Returns:

The method path name in the form "the.package.path.Method"
getCallerMethod
(final Class<T>
the Class to search for on stack to find caller of
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 synchronized StackIntrospector.CallStack

Returns:

the CallStack object
getCallStack
()

Deprecated as a consequence of StackIntrospector.CallStack being deprecated.
Create Hack SecurityManager to get CallStack.
public static final String

Returns:

The method path name in the form "the.package.path.Method"
getRecentStack
(final Class<T>
the last class on the stack you are not interested in!
clazz
,
int
the number of stack lines to return.
entries
)

Return the current call stack as a String, starting with the first call in the stack after a reference to the clazz class, and then display entries entries.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

c_callStackback to summary
private static StackIntrospector.CallStack c_callStack

Deprecated

as a consequence of StackIntrospector.CallStack being deprecated. See corresponding docs for further information.

Constructor Detail

StackIntrospectorback to summary
private StackIntrospector()

Private constructor to block instantiation.

Method Detail

getCallerClassback to summary
public static final Class<T> getCallerClass(final Class<T> clazz) throws SecurityException

Find the caller of the passed in Class. May return null if caller not found on execution stack

Parameters
clazz:Class<T>

the Class to search for on stack to find caller of

Returns:Class<T>

the Class of object that called parrameter class

Exceptions
SecurityException:
if an existing SecurityManager disallows construction of another SecurityManager and thus blocks method results
getCallerClassback to summary
public static final Class<T> getCallerClass(final Class<T> clazz, int stackDepthOffset)

Find the caller of the passed in Class. May return null if caller not found on execution stack

Parameters
clazz:Class<T>

the Class to search for on stack to find caller of

stackDepthOffset:int

Offset call-stack depth to find caller

Returns:Class<T>

the Class of object that called parrameter class

Exceptions
SecurityException:
if an existing SecurityManager disallows construction of another SecurityManager and thus blocks method results
getCallerMethodback to summary
public static final String getCallerMethod(final Class<T> 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.

Parameters
clazz:Class<T>

the Class to search for on stack to find caller of

Returns:String

The method path name in the form "the.package.path.Method"

getCallStackback to summary
private static synchronized StackIntrospector.CallStack getCallStack() throws SecurityException

Deprecated

as a consequence of StackIntrospector.CallStack being deprecated. See corresponding docs for further information.

Create Hack SecurityManager to get CallStack.

Returns:StackIntrospector.CallStack

the CallStack object

Exceptions
SecurityException:
if an existing SecurityManager disallows construction of another SecurityManager
getRecentStackback to summary
public static final String getRecentStack(final Class<T> clazz, int entries)

Return the current call stack as a String, starting with the first call in the stack after a reference to the clazz class, and then display entries entries.

This can be useful for debugging code to determine where calls to a method are coming from.

Parameters
clazz:Class<T>

the last class on the stack you are not interested in!

entries:int

the number of stack lines to return.

Returns:String

The method path name in the form "the.package.path.Method"

org.apache.log.util back to summary

private final Class StackIntrospector.CallStack

extends SecurityManager
Class Inheritance

Deprecated

as a consequence of SecurityManager being deprecated. See corresponding docs for further information.

Hack to get the call stack as an array of classes. The SecurityManager class provides it as a protected method, so change it to public through a new method !

Constructor Summary

AccessConstructor and Description
private

Method Summary

Modifier and TypeMethod and Description
public Class<T>[]
get()

Returns the current execution stack as an array of classes.

Inherited from java.lang.SecurityManager:
checkAcceptcheckAccesscheckAccesscheckConnectcheckConnectcheckCreateClassLoadercheckDeletecheckExeccheckExitcheckLinkcheckListencheckMulticastcheckMulticastcheckPackageAccesscheckPackageDefinitioncheckPermissioncheckPermissioncheckPrintJobAccesscheckPropertiesAccesscheckPropertyAccesscheckReadcheckReadcheckReadcheckSecurityAccesscheckSetFactorycheckWritecheckWritegetClassContextgetSecurityContextgetThreadGroup

Constructor Detail

CallStackback to summary
private CallStack()

Method Detail

getback to summary
public Class<T>[] get()

Returns the current execution stack as an array of classes. The length of the array is the number of methods on the execution stack. The element at index 0 is the class of the currently executing method, the element at index 1 is the class of that method's caller, and so on.