KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > mx4j > remote > ProviderHelper


1 package mx4j.remote;
2
3 import java.security.AccessController JavaDoc;
4 import java.security.PrivilegedAction JavaDoc;
5
6 import mx4j.log.Log;
7 import mx4j.log.Logger;
8
9 /**
10  *
11  * @version $Revision: 1.3 $
12  */

13 public abstract class ProviderHelper
14 {
15    protected static String JavaDoc normalizeProtocol(String JavaDoc protocol)
16    {
17       // Replace special chars as required by the spec
18
String JavaDoc 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 JavaDoc findSystemPackageList(final String JavaDoc key)
26    {
27       Logger logger = getLogger();
28       String JavaDoc providerPackages = (String JavaDoc)AccessController.doPrivileged(new PrivilegedAction JavaDoc()
29       {
30          public Object JavaDoc 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 JavaDoc loadClass(String JavaDoc className, ClassLoader JavaDoc loader) throws ClassNotFoundException JavaDoc
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 JavaDoc constructClassName(String JavaDoc packageName, String JavaDoc protocol, String JavaDoc className)
47    {
48       return new StringBuffer JavaDoc(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