当前位置: 首页>>代码示例>>Java>>正文


Java RMIClassLoader.getClassLoader方法代码示例

本文整理汇总了Java中java.rmi.server.RMIClassLoader.getClassLoader方法的典型用法代码示例。如果您正苦于以下问题:Java RMIClassLoader.getClassLoader方法的具体用法?Java RMIClassLoader.getClassLoader怎么用?Java RMIClassLoader.getClassLoader使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在java.rmi.server.RMIClassLoader的用法示例。


在下文中一共展示了RMIClassLoader.getClassLoader方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: testGetClassLoaderInvalidCodebase

import java.rmi.server.RMIClassLoader; //导入方法依赖的package包/类
/**
 * Test for java.rmi.server.RMIClassLoader.getClassLoader(String)
 * testing invalid url as a codebase.
 */
public void testGetClassLoaderInvalidCodebase() throws Exception {
    //Regression for HARMONY-1134
    SecurityManager previous = System.getSecurityManager();
    System.setSecurityManager(null);

    try { 
        RMIClassLoader.getClassLoader("zzz");
        fail("MalformedURLException expected");
    } catch (MalformedURLException e) { 
        //expected 
    } finally {
        System.setSecurityManager(previous);            
    } 
}
 
开发者ID:shannah,项目名称:cn1,代码行数:19,代码来源:RMIClassLoaderTest.java

示例2: main

import java.rmi.server.RMIClassLoader; //导入方法依赖的package包/类
public static void main(String[] args) throws Exception {

        Registry registry = LocateRegistry.getRegistry();
        IEcho stub = (IEcho) registry.lookup("Echo2");
        String response = stub.echo("Real Time in client: "
                + System.currentTimeMillis());
        System.out.println("Answer from server: " + response);

        try {
            RMIClassLoader.getClassLoader("file://home/odemo/classes");
        } catch (SecurityException e) {
            e.printStackTrace();
        }

    }
 
开发者ID:freeVM,项目名称:freeVM,代码行数:16,代码来源:EchoClient.java

示例3: testGetClassLoaderInvalidCodebase

import java.rmi.server.RMIClassLoader; //导入方法依赖的package包/类
/**
 * Test for java.rmi.server.RMIClassLoader.getClassLoader(String) testing
 * invalid url as a codebase.
 */
public void testGetClassLoaderInvalidCodebase() throws Exception {
    // Regression for HARMONY-1134
    SecurityManager previous = System.getSecurityManager();
    System.setSecurityManager(null);

    try {
        RMIClassLoader.getClassLoader("zzz");
        fail("MalformedURLException expected");
    } catch (MalformedURLException e) {
        // expected
    } finally {
        System.setSecurityManager(previous);
    }
}
 
开发者ID:freeVM,项目名称:freeVM,代码行数:19,代码来源:RMIClassLoaderTest.java

示例4: testLoadClassCodebaseOrder4

import java.rmi.server.RMIClassLoader; //导入方法依赖的package包/类
/**
 * Modify the above method to test loadClass, loadClass(String, String) for
 * coverage.
 */
public void testLoadClassCodebaseOrder4() throws Exception {
    SecurityManager previous = System.getSecurityManager();
    System.setSecurityManager(new SecurityManager() {
        @Override
        public void checkPermission(Permission perm) {
            /*
             * Override checkPermission to allow everything. Specifically,
             * we want to allow the SecurityManager to be set to null at the
             * end of the test and we want to allow the 'testClass.jar' file
             * to be allowed to load.
             */
            return;
        }
    });
    try {
        URL testJarURL = getClass().getResource("testClass.jar");
        String[] paths = new String[] { testJarURL.getPath(),
        /*
         * to be sure this path will be the first after sorting
         */
        "/_fake.jar" };

        ClassLoader cl = RMIClassLoader.getClassLoader(new URI("file://"
                + paths[0]).toURL().toString());
        Class<?> c = cl.loadClass("TestClass");

        assertNotNull(c);

    } finally {
        // reset the security manager back to null state
        System.setSecurityManager(previous);
    }
}
 
开发者ID:freeVM,项目名称:freeVM,代码行数:38,代码来源:RMIClassLoaderTest.java

示例5: getFallbackClassLoader

import java.rmi.server.RMIClassLoader; //导入方法依赖的package包/类
@Override
protected ClassLoader getFallbackClassLoader() throws IOException {
	return RMIClassLoader.getClassLoader(this.codebaseUrl);
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:5,代码来源:CodebaseAwareObjectInputStream.java


注:本文中的java.rmi.server.RMIClassLoader.getClassLoader方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。