37 |
package gnu.applet; |
package gnu.applet; |
38 |
|
|
39 |
import java.applet.Applet; |
import java.applet.Applet; |
40 |
import java.net.HttpURLConnection; |
import java.net.MalformedURLException; |
41 |
import java.net.URL; |
import java.net.URL; |
42 |
import java.net.URLClassLoader; |
import java.net.URLClassLoader; |
43 |
|
import java.util.Hashtable; |
44 |
|
|
45 |
public class AppletLoader |
public class AppletLoader |
46 |
{ |
{ |
60 |
catch (ClassNotFoundException e) |
catch (ClassNotFoundException e) |
61 |
{ |
{ |
62 |
} |
} |
63 |
catch (InstantiationException e) |
catch (IllegalAccessException e) |
64 |
{ |
{ |
65 |
} |
} |
66 |
catch (IllegalAccessException e) |
catch (InstantiationException e) |
67 |
{ |
{ |
68 |
} |
} |
69 |
|
|
70 |
return null; |
return null; |
71 |
} |
} |
72 |
|
|
73 |
|
private String code; |
74 |
|
private URL codeBase; |
75 |
|
private URL documentBase; |
76 |
|
private String archive; |
77 |
|
private Hashtable params = new Hashtable(); |
78 |
|
private Applet applet; |
79 |
|
|
80 |
|
public AppletLoader() |
81 |
|
{ |
82 |
|
// Do nothing here. |
83 |
|
} |
84 |
|
|
85 |
|
public void setCode (String code) |
86 |
|
{ |
87 |
|
this.code = code; |
88 |
|
} |
89 |
|
|
90 |
|
public void setCodeBase (String codeBase) |
91 |
|
{ |
92 |
|
try |
93 |
|
{ |
94 |
|
this.codeBase = new URL (codeBase); |
95 |
|
} |
96 |
|
catch (MalformedURLException e) |
97 |
|
{ |
98 |
|
} |
99 |
|
} |
100 |
|
|
101 |
|
public void setDocumentBase (String documentBase) |
102 |
|
{ |
103 |
|
try |
104 |
|
{ |
105 |
|
this.documentBase = new URL (documentBase); |
106 |
|
} |
107 |
|
catch (MalformedURLException e) |
108 |
|
{ |
109 |
|
} |
110 |
|
} |
111 |
|
|
112 |
|
public void setArchive (String archive) |
113 |
|
{ |
114 |
|
this.archive = archive; |
115 |
|
} |
116 |
|
|
117 |
|
public void addParameter (String name, String value) |
118 |
|
{ |
119 |
|
params.put (name, value); |
120 |
|
} |
121 |
|
|
122 |
|
public synchronized Applet loadApplet() |
123 |
|
{ |
124 |
|
if (archive != null) |
125 |
|
return null; |
126 |
|
|
127 |
|
applet = loadApplet (codeBase, name); |
128 |
|
AppletContextImpl context = new AppletContextImpl(); |
129 |
|
AppletStubImpl stub = new AppletStubImpl (context, codeBase, documentBase, |
130 |
|
params); |
131 |
|
applet.setStub (stub); |
132 |
|
return applet; |
133 |
|
} |
134 |
} |
} |