本文整理汇总了Java中java.applet.Applet.setStub方法的典型用法代码示例。如果您正苦于以下问题:Java Applet.setStub方法的具体用法?Java Applet.setStub怎么用?Java Applet.setStub使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类java.applet.Applet
的用法示例。
在下文中一共展示了Applet.setStub方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: fetchApplet
import java.applet.Applet; //导入方法依赖的package包/类
@Override
public Applet fetchApplet() {
try {
Hook.getInstance().init();
final ASMClassLoader classLoader = Context.getInstance().getASMClassLoader();
final Class<?> clientClass = classLoader.loadClass(Context.getInstance().getServerProviderInfo().getClientClass());
final OSScapeParameters parser = new OSScapeParameters();
Object instance = clientClass.newInstance();
Utilities.handleOSScape(parser, classLoader);
Applet applet = (Applet) instance;
applet.setStub(new Stub(parser));
return applet;
} catch (Exception e) {
e.printStackTrace();
return null;
}
}
示例2: setStub
import java.applet.Applet; //导入方法依赖的package包/类
private static void setStub(Applet applet, final ClassLoader loader,
boolean serialized, String beanName) throws ClassNotFoundException {
// Get path to the resource representing the applet.
String pathName = beanName.replace('.', '/');
final String resourceName = serialized ? pathName.concat(".ser") : pathName.concat(".class"); //$NON-NLS-1$ //$NON-NLS-2$
URL objectUrl = AccessController
.doPrivileged(new PrivilegedAction<URL>() {
public URL run() {
if (loader == null) {
return ClassLoader.getSystemResource(resourceName);
}
return loader.getResource(resourceName);
}
});
// If we can't get to the applet itself, the codebase and doc base are
// left as null.
if (objectUrl == null) {
applet.setStub(getAppletStub(getStubAppletContext(applet),
null, null));
return;
}
// Try to decompose the resource URL to get to the doc/code URL
String urlString = objectUrl.toExternalForm();
// This is the URL of the directory that contains the applet.
int codeURLlength = urlString.length() - resourceName.length();
URL codeBase = safeURL(urlString.substring(0, codeURLlength));
// URL of the document containing the applet.
int docURLlength = urlString.lastIndexOf('/');
URL docBase = safeURL(urlString.substring(0, docURLlength + 1));
applet.setStub(getAppletStub(getStubAppletContext(applet),
codeBase, docBase));
}