1 22 package org.jboss.mx.loading; 23 24 import java.security.PrivilegedAction ; 25 import java.security.AccessController ; 26 import java.security.CodeSource ; 27 28 34 class ClassToStringAction implements PrivilegedAction 35 { 36 private StringBuffer buffer; 37 private Class clazz; 38 ClassToStringAction(Class clazz, StringBuffer buffer) 39 { 40 this.clazz = clazz; 41 this.buffer = buffer; 42 } 43 public Object run() 44 { 45 if( clazz != null ) 46 { 47 buffer.append(clazz.getName()); 48 buffer.append("@"+Integer.toHexString(clazz.hashCode())); 49 CodeSource cs = clazz.getProtectionDomain().getCodeSource(); 50 buffer.append("<CodeSource: "+cs+">"); 51 } 52 else 53 { 54 buffer.append("null"); 55 } 56 return null; 57 } 58 59 static void toString(Class clazz, StringBuffer buffer) 60 { 61 PrivilegedAction action = new ClassToStringAction(clazz, buffer); 62 AccessController.doPrivileged(action); 63 } 64 65 static class SysPropertyAction implements PrivilegedAction 66 { 67 private String key; 68 private String def; 69 SysPropertyAction(String key, String def) 70 { 71 this.key = key; 72 this.def = def; 73 } 74 public Object run() 75 { 76 return System.getProperty(key, def); 77 } 78 } 79 static String getProperty(String key, String def) 80 { 81 PrivilegedAction action = new SysPropertyAction(key, def); 82 String value = (String ) AccessController.doPrivileged(action); 83 return value; 84 } 85 } 86 | Popular Tags |