1 package mx4j.remote; 2 3 import java.security.AccessController ; 4 import java.security.PrivilegedAction ; 5 6 import mx4j.log.Log; 7 import mx4j.log.Logger; 8 9 13 public abstract class ProviderHelper 14 { 15 protected static String normalizeProtocol(String protocol) 16 { 17 String normalized = protocol.replace('+', '.'); 19 normalized = normalized.replace('-', '_'); 20 Logger logger = getLogger(); 21 if (logger.isEnabledFor(Logger.TRACE)) logger.trace("Normalizing protocol: " + protocol + " --> " + normalized); 22 return normalized; 23 } 24 25 protected static String findSystemPackageList(final String key) 26 { 27 Logger logger = getLogger(); 28 String providerPackages = (String )AccessController.doPrivileged(new PrivilegedAction () 29 { 30 public Object run() 31 { 32 return System.getProperty(key); 33 } 34 }); 35 if (logger.isEnabledFor(Logger.DEBUG)) logger.debug("Packages in the system property '" + key + "': " + providerPackages); 36 return providerPackages; 37 } 38 39 protected static Class loadClass(String className, ClassLoader loader) throws ClassNotFoundException 40 { 41 Logger logger = getLogger(); 42 if (logger.isEnabledFor(Logger.DEBUG)) logger.debug("Loading class: " + className + " with classloader " + loader); 43 return loader.loadClass(className); 44 } 45 46 protected static String constructClassName(String packageName, String protocol, String className) 47 { 48 return new StringBuffer (packageName).append(".").append(protocol).append(".").append(className).toString(); 49 } 50 51 protected static Logger getLogger() 52 { 53 return Log.getLogger(ProviderHelper.class.getName()); 54 } 55 } 56 | Popular Tags |