1 6 7 package org.jzonic.jlo.formatter; 8 9 13 public class CallerStack extends SecurityManager { 14 15 private static CallerStack cs = null; 16 17 public CallerStack() { 18 } 19 20 public static Class getCallerClass(Class clazz) { 21 if ( cs == null ) { 22 cs = new CallerStack(); 23 } 24 Class [] stack = cs.getClassContext(); 25 int idx = 0; 26 for ( int i = 0; i < stack.length;i++) { 27 if ( clazz.isAssignableFrom(stack[i]) || CallerStack.class.isAssignableFrom(stack[i])) { 28 idx ++; 29 } 30 } 31 int index = stack.length; 32 if ( index > 0 ) { 33 index --; 34 } 35 if ( stack.length < idx ) { 36 idx = stack.length; 37 } 38 return stack[idx]; 39 } 40 41 } 42 | Popular Tags |