本文整理汇总了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);
}
}
示例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();
}
}
示例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);
}
}
示例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);
}
}
示例5: getFallbackClassLoader
import java.rmi.server.RMIClassLoader; //导入方法依赖的package包/类
@Override
protected ClassLoader getFallbackClassLoader() throws IOException {
return RMIClassLoader.getClassLoader(this.codebaseUrl);
}