Methods Summary |
---|
public static void | bind(java.lang.ClassLoader cl, javax.naming.directory.DirContext dirContext)Binds a directory context to a class loader.
clBindings.put(cl, dirContext);
|
public static void | bind(javax.naming.directory.DirContext dirContext)Binds a directory context to a class loader.
ClassLoader currentCL =
Thread.currentThread().getContextClassLoader();
if (currentCL != null)
clBindings.put(currentCL, dirContext);
|
public static void | bindThread(javax.naming.directory.DirContext dirContext)Binds a directory context to a thread.
threadBindings.put(Thread.currentThread(), dirContext);
|
public static javax.naming.directory.DirContext | get()Get the bound context.
DirContext result = null;
Thread currentThread = Thread.currentThread();
ClassLoader currentCL = currentThread.getContextClassLoader();
// Checking CL binding
result = (DirContext) clBindings.get(currentCL);
if (result != null)
return result;
// Checking thread biding
result = (DirContext) threadBindings.get(currentThread);
// Checking parent CL binding
currentCL = currentCL.getParent();
while (currentCL != null) {
result = (DirContext) clBindings.get(currentCL);
if (result != null)
return result;
currentCL = currentCL.getParent();
}
if (result == null)
throw new IllegalStateException("Illegal class loader binding");
return result;
|
public static javax.naming.directory.DirContext | get(java.lang.ClassLoader cl)Get the bound context.
return (DirContext) clBindings.get(cl);
|
public static javax.naming.directory.DirContext | get(java.lang.Thread thread)Get the bound context.
return (DirContext) threadBindings.get(thread);
|
public static boolean | isBound()Returns true if the thread or the context class loader of the current
thread is bound.
return (clBindings.containsKey
(Thread.currentThread().getContextClassLoader()))
|| (threadBindings.containsKey(Thread.currentThread()));
|
protected java.net.URLConnection | openConnection(java.net.URL u)Opens a connection to the object referenced by the URL
argument.
// ------------------------------------------------------------- Properties
// ----------------------------------------------- URLStreamHandler Methods
DirContext currentContext = this.context;
if (currentContext == null)
currentContext = get();
return new DirContextURLConnection(currentContext, u);
|
public static void | setProtocolHandler()Set the java.protocol.handler.pkgs system property.
String value = System.getProperty(Constants.PROTOCOL_HANDLER_VARIABLE);
if (value == null) {
value = Constants.Package;
System.setProperty(Constants.PROTOCOL_HANDLER_VARIABLE, value);
} else if (value.indexOf(Constants.Package) == -1) {
value += "|" + Constants.Package;
System.setProperty(Constants.PROTOCOL_HANDLER_VARIABLE, value);
}
|
protected java.lang.String | toExternalForm(java.net.URL u)Converts a URL of a specific protocol to a
String .
The impl of this method is almost identical to that of the
java.net.URLStreamHandler superclass, except that it omits the
URL's authority field from the URL's String representation.
// pre-compute length of StringBuffer
int len = u.getProtocol().length() + 1;
if (u.getPath() != null) {
len += u.getPath().length();
}
if (u.getQuery() != null) {
len += 1 + u.getQuery().length();
}
if (u.getRef() != null)
len += 1 + u.getRef().length();
StringBuffer result = new StringBuffer(len);
result.append(u.getProtocol());
result.append(":");
if (u.getPath() != null) {
result.append(u.getPath());
}
if (u.getQuery() != null) {
result.append('?");
result.append(u.getQuery());
}
if (u.getRef() != null) {
result.append("#");
result.append(u.getRef());
}
return result.toString();
|
public static void | unbind(java.lang.ClassLoader cl)Unbinds a directory context to a class loader.
clBindings.remove(cl);
|
public static void | unbind()Unbinds a directory context to a class loader.
ClassLoader currentCL =
Thread.currentThread().getContextClassLoader();
if (currentCL != null)
clBindings.remove(currentCL);
|
public static void | unbindThread()Unbinds a directory context to a thread.
threadBindings.remove(Thread.currentThread());
|