|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectjava.lang.ClassLoader
javassist.tools.web.Viewer
public class Viewer
A sample applet viewer.
This is a sort of applet viewer that can run any program even if
the main class is not a subclass of Applet
.
This viewwer first calls main()
in the main class.
To run, you should type:
% java javassist.tools.web.Viewer host port Main arg1, ...
This command calls Main.main()
with arg1,...
All classes including Main
are fetched from
a server http://host:port.
Only the class file for Viewer
must exist
on a local file system at the client side; even other
javassist.*
classes are not needed at the client side.
Viewer
uses only Java core API classes.
Note: since a Viewer
object is a class loader,
a program loaded by this object can call a method in Viewer
.
For example, you can write something like this:
Viewer v = (Viewer)this.getClass().getClassLoader(); String port = v.getPort();
Constructor Summary | |
---|---|
Viewer(String host,
int p)
Constructs a viewer. |
Method Summary | |
---|---|
protected byte[] |
fetchClass(String classname)
Fetches the class file of the specified class from the http server. |
protected Class |
findClass(String name)
Finds the specified class. |
int |
getPort()
Returns the port number. |
String |
getServer()
Returns the server name. |
protected Class |
loadClass(String name,
boolean resolve)
Requests the class loader to load a class. |
static void |
main(String[] args)
Starts a program. |
void |
run(String classname,
String[] args)
Invokes main() in the class specified by classname . |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public Viewer(String host, int p)
host
- server namep
- port numberMethod Detail |
---|
public static void main(String[] args) throws Throwable
Throwable
public String getServer()
public int getPort()
public void run(String classname, String[] args) throws Throwable
classname
.
classname
- executed classargs
- the arguments passed to main()
.
Throwable
protected Class loadClass(String name, boolean resolve) throws ClassNotFoundException
loadClass
in class ClassLoader
ClassNotFoundException
protected Class findClass(String name) throws ClassNotFoundException
java.*
, javax.*
, or
Viewer
, then it is loaded by the parent class
loader.
This method can be overridden by a subclass of
Viewer
.
findClass
in class ClassLoader
ClassNotFoundException
protected byte[] fetchClass(String classname) throws Exception
Exception
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |