本文整理匯總了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));
}