1 23 package com.sun.enterprise.tools.jsfext.util; 24 25 import java.util.Locale ; 26 import java.util.Map ; 27 import java.util.Properties ; 28 29 30 35 public class Util { 36 37 46 public static ClassLoader getClassLoader(Object obj) { 47 ClassLoader loader = Thread.currentThread().getContextClassLoader(); 49 if (loader == null) { 50 if (obj != null) { 51 loader = obj.getClass().getClassLoader(); 52 } else { 53 loader = ClassLoader.getSystemClassLoader(); 54 } 55 } 56 return loader; 57 } 58 59 67 public static Class getClass(Object obj) throws ClassNotFoundException { 68 if ((obj == null) || (obj instanceof Class )) { 69 return (Class ) obj; 70 } 71 Class cls = null; 72 if (obj instanceof String ) { 73 ClassLoader loader = getClassLoader(obj); 74 cls = loader.loadClass((String ) obj); 75 } else { 76 cls = obj.getClass(); 77 } 78 return cls; 79 } 80 81 85 public static Properties mapToProperties(Map map) { 86 if ((map == null) || (map instanceof Properties )) { 87 return (Properties ) map; 88 } 89 90 Properties props = new Properties (); 92 props.putAll(map); 93 94 return props; 96 } 97 } 98 | Popular Tags |