FileDocCategorySizeDatePackage
JDKBridge.javaAPI DocJava SE 5 API6145Fri Aug 26 14:54:34 BST 2005com.sun.corba.se.impl.util

JDKBridge

public class JDKBridge extends Object
Utility methods for doing various method calls which are used by multiple classes

Fields Summary
private static final String
LOCAL_CODEBASE_KEY
private static final String
USE_CODEBASE_ONLY_KEY
private static String
localCodebase
private static boolean
useCodebaseOnly
Constructors Summary
Methods Summary
public static java.lang.StringgetLocalCodebase()
Get local codebase System property (java.rmi.server.codebase). May be null or a space separated array of URLS.

        return localCodebase;
    
public static java.lang.ClassloadClass(java.lang.String className, java.lang.String remoteCodebase, java.lang.ClassLoader loader)
Returns a class instance for the specified class.

param
className the name of the class
param
remoteCodebase a space-separated array of urls at which the class might be found. May be null.
param
loader a ClassLoader who may be used to load the class if all other methods fail.
return
the Class object representing the loaded class.
exception
throws ClassNotFoundException if class cannot be loaded.

        
        if (loader == null) {
            return loadClassM(className,remoteCodebase,useCodebaseOnly);
        } else {
            try {
                return loadClassM(className,remoteCodebase,useCodebaseOnly);
            } catch (ClassNotFoundException e) {
                return loader.loadClass(className);
            }
        }
    
public static java.lang.ClassloadClass(java.lang.String className, java.lang.String remoteCodebase)
Returns a class instance for the specified class.

param
className the name of the class
param
remoteCodebase a space-separated array of urls at which the class might be found. May be null.
return
the Class object representing the loaded class.
exception
throws ClassNotFoundException if class cannot be loaded.

        return loadClass(className,remoteCodebase,null);
    
public static java.lang.ClassloadClass(java.lang.String className)
Returns a class instance for the specified class.

param
className the name of the class
return
the Class object representing the loaded class.
exception
throws ClassNotFoundException if class cannot be loaded.

        return loadClass(className,null,null);
    
private static java.lang.ClassloadClassM(java.lang.String className, java.lang.String remoteCodebase, boolean useCodebaseOnly)


        try {
            return JDKClassLoader.loadClass(null,className);
        } catch (ClassNotFoundException e) {}
        try {
            if (!useCodebaseOnly && remoteCodebase != null) {
                return RMIClassLoader.loadClass(remoteCodebase,
                                                className);
            } else {
                return RMIClassLoader.loadClass(className);
            }
        } catch (MalformedURLException e) {
            className = className + ": " + e.toString();
        }

        throw new ClassNotFoundException(className);
    
public static final voidmain(java.lang.String[] args)


     
        setCodebaseProperties();
    
        System.out.println("1.2 VM");
        
	/*       
		 // If on 1.2, use a policy with all permissions.
		 System.setSecurityManager (new javax.rmi.download.SecurityManager());
		 String targetClass = "[[Lrmic.Typedef;";
		 System.out.println("localCodebase =  "+localCodebase);
		 System.out.println("Trying to load "+targetClass);
		 try {
		 Class clz = loadClass(targetClass,null,localCodebase);
		 System.out.println("Loaded: "+clz);
		 } catch (ClassNotFoundException e) {
		 System.out.println("Caught "+e);
		 }
	*/
    
public static synchronized voidsetCodebaseProperties()
Set the codebase and useCodebaseOnly properties. This is public only for test code.

        String prop = (String)AccessController.doPrivileged(
            new GetPropertyAction(LOCAL_CODEBASE_KEY)
        );
        if (prop != null && prop.trim().length() > 0) {
            localCodebase = prop;
        }

        prop = (String)AccessController.doPrivileged(
            new GetPropertyAction(USE_CODEBASE_ONLY_KEY)
        );
        if (prop != null && prop.trim().length() > 0) {
            useCodebaseOnly = Boolean.valueOf(prop).booleanValue();
        }
    
public static synchronized voidsetLocalCodebase(java.lang.String codebase)
Set the default code base. This method is here only for test code.

        localCodebase = codebase;    
    
public static booleanuseCodebaseOnly()
Return true if the system property "java.rmi.server.useCodebaseOnly" is set, false otherwise.

        return useCodebaseOnly;