FileDocCategorySizeDatePackage
VersionHelper12.javaAPI DocJava SE 6 API6015Tue Jun 10 00:22:16 BST 2008com.sun.naming.internal

VersionHelper12

public final class VersionHelper12 extends VersionHelper
VersionHelper was used by JNDI to accommodate differences between JDK 1.1.x and the Java 2 platform. As this is no longer necessary since JNDI's inclusion in the platform, this class currently serves as a set of utilities for performing system-level things, such as class-loading and reading system properties.
author
Rosanna Lee
author
Scott Seligman
version
1.11 06/07/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);