/** * Begins the HTTP service. */ public void run() { super.run(); }
public void run() { try { web.process(sock); } catch (IOException e) { } } }
/** * Starts a web server. * The port number is specified by the first argument. */ public static void main(String[] args) throws IOException { if (args.length == 1) { Webserver web = new Webserver(args[0]); web.run(); } else System.err.println( "Usage: java javassist.tools.web.Webserver <port number>"); }
/** * Begins the HTTP service. */ public void run() { System.err.println("ready to service..."); for (;;) try { ServiceThread th = new ServiceThread(this, socket.accept()); th.start(); } catch (IOException e) { logging(e.toString()); } }
/** * Requests the class loader to load a class. */ protected synchronized Class loadClass(String name, boolean resolve) throws ClassNotFoundException { Class c = findLoadedClass(name); if (c == null) c = findClass(name); if (c == null) throw new ClassNotFoundException(name); if (resolve) resolveClass(c); return c; }
/** * Finds the specified class. The implementation in this class * fetches the class from the http server. If the class is * either <code>java.*</code>, <code>javax.*</code>, or * <code>Viewer</code>, then it is loaded by the parent class * loader. * * <p>This method can be overridden by a subclass of * <code>Viewer</code>. */ protected Class findClass(String name) throws ClassNotFoundException { Class c = null; if (name.startsWith("java.") || name.startsWith("javax.") || name.equals("javassist.tools.web.Viewer")) c = findSystemClass(name); if (c == null) try { byte[] b = fetchClass(name); if (b != null) c = defineClass(name, b, 0, b.length); } catch (Exception e) { } return c; }
/** * Starts a program. */ public static void main(String[] args) throws Throwable { if (args.length >= 3) { Viewer cl = new Viewer(args[0], Integer.parseInt(args[1])); String[] args2 = new String[args.length - 3]; System.arraycopy(args, 3, args2, 0, args.length - 3); cl.run(args[2], args2); } else System.err.println( "Usage: java javassist.tools.web.Viewer <host> <port> class [args ...]"); }
private boolean letUsersSendClassfile(OutputStream out, String filename, int length) throws IOException, BadHttpRequest { if (classPool == null) return false; byte[] classfile; String classname = filename.substring(0, length - 6).replace('/', '.'); try { if (translator != null) translator.onLoad(classPool, classname); CtClass c = classPool.get(classname); classfile = c.toBytecode(); if (debugDir != null) c.writeFile(debugDir); } catch (Exception e) { throw new BadHttpRequest(e); } sendHeader(out, classfile.length, typeClass); out.write(classfile); return true; }
private void checkFilename(String filename, int len) throws BadHttpRequest { for (int i = 0; i < len; ++i) { char c = filename.charAt(i); if (!Character.isJavaIdentifierPart(c) && c != '.' && c != '/') throw new BadHttpRequest(); } if (filename.indexOf("..") >= 0) throw new BadHttpRequest(); }
/** * Processes a request from a web browser (an ObjectImporter). */ public void doReply(InputStream in, OutputStream out, String cmd) throws IOException, BadHttpRequest { if (cmd.startsWith("POST /rmi ")) processRMI(in, out); else if (cmd.startsWith("POST /lookup ")) lookupName(cmd, in, out); else super.doReply(in, out, cmd); }
/** * Invokes main() in the class specified by <code>classname</code>. * * @param classname executed class * @param args the arguments passed to <code>main()</code>. */ public void run(String classname, String[] args) throws Throwable { Class c = loadClass(classname); try { c.getDeclaredMethod("main", new Class[] { String[].class }) .invoke(null, new Object[] { args }); } catch (java.lang.reflect.InvocationTargetException e) { throw e.getTargetException(); } }
/** * Begins the HTTP service. */ public void run() { System.err.println("ready to service..."); for (;;) try { ServiceThread th = new ServiceThread(this, socket.accept()); th.start(); } catch (IOException e) { logging(e.toString()); } }
/** * Requests the class loader to load a class. */ @Override protected synchronized Class<?> loadClass(String name, boolean resolve) throws ClassNotFoundException { Class<?> c = findLoadedClass(name); if (c == null) c = findClass(name); if (c == null) throw new ClassNotFoundException(name); if (resolve) resolveClass(c); return c; }
/** * Starts a web server. * The port number is specified by the first argument. */ public static void main(String[] args) throws IOException { if (args.length == 1) { Webserver web = new Webserver(args[0]); web.run(); } else System.err.println( "Usage: java javassist.tools.web.Webserver <port number>"); }
/** * Begins the HTTP service. */ @Override public void run() { super.run(); }
@Override public void run() { try { web.process(sock); } catch (IOException e) { } } }
private void checkFilename(String filename, int len) throws BadHttpRequest { for (int i = 0; i < len; ++i) { char c = filename.charAt(i); if (!Character.isJavaIdentifierPart(c) && c != '.' && c != '/') throw new BadHttpRequest(); } if (filename.indexOf("..") >= 0) throw new BadHttpRequest(); }
/** * Processes a request from a web browser (an ObjectImporter). */ @Override public void doReply(InputStream in, OutputStream out, String cmd) throws IOException, BadHttpRequest { if (cmd.startsWith("POST /rmi ")) processRMI(in, out); else if (cmd.startsWith("POST /lookup ")) lookupName(cmd, in, out); else super.doReply(in, out, cmd); }