FileDocCategorySizeDatePackage
VersionHelper12.javaAPI DocJava SE 5 API5750Fri Aug 26 14:55:16 BST 2005com.sun.naming.internal

VersionHelper12

public final class VersionHelper12 extends VersionHelper
An implementation of VersionHelper for the Java 2 platform.
author
Rosanna Lee
author
Scott Seligman
version
1.9 03/12/19

Fields Summary
private boolean
getSystemPropsFailed
Constructors Summary
VersionHelper12()


     
Methods Summary
java.lang.ClassLoadergetContextClassLoader()

	return (ClassLoader) AccessController.doPrivileged(
	    new PrivilegedAction() {
		public Object run() {
		    return Thread.currentThread().getContextClassLoader();
		}
	    }
	);
    
java.io.InputStreamgetJavaHomeLibStream(java.lang.String filename)

	return (InputStream) AccessController.doPrivileged(
	    new PrivilegedAction() {
		public Object run() {
		    try {
			String javahome = System.getProperty("java.home");
			if (javahome == null) {
			    return null;
			}
			String pathname = javahome + java.io.File.separator +
			    "lib" + java.io.File.separator + filename;
			return new java.io.FileInputStream(pathname);
		    } catch (Exception e) {
			return null;
		    }
		}
	    }
	);
    
java.lang.String[]getJndiProperties()

	if (getSystemPropsFailed) {
	    return null;	// after one failure, don't bother trying again
	}
	Properties sysProps = (Properties) AccessController.doPrivileged(
	    new PrivilegedAction() {
		public Object run() {
		    try {
			return System.getProperties();
		    } catch (SecurityException e) {
			getSystemPropsFailed = true;
			return null;
		    }
		}
	    }
	);
	if (sysProps == null) {
	    return null;
	}
	String[] jProps = new String[PROPS.length];
	for (int i = 0; i < PROPS.length; i++) {
	    jProps[i] = sysProps.getProperty(PROPS[i]);
	}
	return jProps;
    
java.lang.StringgetJndiProperty(int i)

	return (String) AccessController.doPrivileged(
	    new PrivilegedAction() {
		public Object run() {
		    try {
			return System.getProperty(PROPS[i]);
		    } catch (SecurityException e) {
			return null;
		    }
	        }
	    }
	);
    
java.io.InputStreamgetResourceAsStream(java.lang.Class c, java.lang.String name)

	return (InputStream) AccessController.doPrivileged(
	    new PrivilegedAction() {
		public Object run() {
	            return c.getResourceAsStream(name);
	        }
	    }
	);
    
javax.naming.NamingEnumerationgetResources(java.lang.ClassLoader cl, java.lang.String name)

	Enumeration urls;
	try {
	    urls = (Enumeration) AccessController.doPrivileged(
		new PrivilegedExceptionAction() {
		    public Object run() throws IOException {
			return (cl == null)
			    ? ClassLoader.getSystemResources(name)
			    : cl.getResources(name);
		    }
		}
	    );
	} catch (PrivilegedActionException e) {
	    throw (IOException)e.getException();
	}
	return new InputStreamEnumeration(urls);
    
public java.lang.ClassloadClass(java.lang.String className)

	ClassLoader cl = getContextClassLoader();
	return Class.forName(className, true, cl);
    
java.lang.ClassloadClass(java.lang.String className, java.lang.ClassLoader cl)
Package private.

	return Class.forName(className, true, cl);
    
public java.lang.ClassloadClass(java.lang.String className, java.lang.String codebase)

param
className A non-null fully qualified class name.
param
codebase A non-null, space-separated list of URL strings.

	ClassLoader cl;

	ClassLoader parent = getContextClassLoader();
	cl = URLClassLoader.newInstance(getUrlArray(codebase), parent);

	return Class.forName(className, true, cl);