Overview | Package | Class | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## org.jboss.web
Class WebServer

    java.lang.Object
      |
      +--org.jboss.web.WebServer

All Implemented Interfaces:
  java.lang.Runnable

public class WebServer
extends java.lang.Object
implements java.lang.Runnable

A mini webserver that should be embedded in another application. It can server any file that is available from classloaders that are registered with it, including class-files. Its primary purpose is to simplify dynamic class-loading in RMI. Create an instance of it, register a classloader with your classes, start it, and you'll be able to let RMI-clients dynamically download classes from it. It is configured by calling any methods programmatically prior to startup.

Version:
  $Revision: 1.5.4.6 $ Revisions: 20010806 scott.stark: Allow binding of listening port to a specific IP address 20010619 scott.stark: Use log4j JBossCategory to enable trace level msgs 20010618 scott.stark: Fixed extraction of mime-type from file extension in getMimeType 20010627 scott.stark: Restore ability to download from the server classpath if no loader key is found amd downloadServerClasses is true
Author:
  Marc Fleury, Scott Stark.
See Also:
  `WebClassLoader`

Constructor Summary
`WebServer()`

Method Summary
`java.net.URL` | `addClassLoader(java.lang.ClassLoader cl)` Add a class loader to the web server map and return the URL that should be used as the annotated codebase for classes that are to be available via RMI dynamic classloading.
`void` | `addMimeType(java.lang.String extension, java.lang.String type)` Augment the type suffix to mime type mappings
`int` | `getBacklog()` Get the server sockets listen queue depth
`java.lang.String` | `getBindAddress()`
`protected byte[]` | `getBytes(java.net.URL url)` Read the local class/resource contents into a byte array.
`protected java.lang.String` | `getClassLoaderKey(java.lang.ClassLoader cl)` Create the string key used as the key into the loaderMap.
`boolean` | `getDownloadServerClasses()`
`protected java.lang.String` | `getMimeType(java.lang.String path)` Lookup the mime type for the suffix of the path argument.
`protected java.lang.String` | `getPath(java.io.BufferedReader in)`
`int` | `getPort()` Get the http listening port
`protected void` | `listen()`
`void` | `removeClassLoader(java.lang.ClassLoader cl)` Remove a class loader previously added via addClassLoader
`void` | `run()` Listen threads entry point.
`void` | `setBacklog(int backlog)` Set the server sockets listen queue depth
`void` | `setBindAddress(java.lang.String host)`
`void` | `setDownloadServerClasses(boolean flag)`
`void` | `setPort(int p)` Set the http listening port
`void` | `start()` Start the web server on port and begin listening for requests.
`void` | `stop()` Close the web server listening socket

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Constructor Detail

### WebServer

    public WebServer()

Method Detail

### setPort

    public void setPort(int p)

  Set the http listening port

### getPort

    public int getPort()

  Get the http listening port
  Returns:
    the http listening port

### getBindAddress

    public java.lang.String getBindAddress()

### setBindAddress

    public void setBindAddress(java.lang.String host)

### getBacklog

    public int getBacklog()

  Get the server sockets listen queue depth
  Returns:
    the listen queue depth

### setBacklog

    public void setBacklog(int backlog)

  Set the server sockets listen queue depth

### getDownloadServerClasses

    public boolean getDownloadServerClasses()

### setDownloadServerClasses

    public void setDownloadServerClasses(boolean flag)

### addMimeType

    public void addMimeType(java.lang.String extension,
                            java.lang.String type)

  Augment the type suffix to mime type mappings
  Parameters:
    `extension,` - the type extension without a period(class, txt)
    `type,` - the mime type string

### start

    public void start()
               throws java.io.IOException

  Start the web server on port and begin listening for requests.

### stop

    public void stop()

  Close the web server listening socket

### addClassLoader

    public java.net.URL addClassLoader(java.lang.ClassLoader cl)

  Add a class loader to the web server map and return the URL that should be used as the annotated codebase for classes that are to be available via RMI dynamic classloading. The codebase URL is formed by taking the java.rmi.server.codebase system property and adding a subpath unique for the class loader instance.
  Parameters:
    `cl,` - the ClassLoader instance to begin serving download requests for
  Returns:
    the annotated codebase to use if java.rmi.server.codebase is set, null otherwise.
  See Also:
    `getClassLoaderKey(ClassLoader)`

### removeClassLoader

    public void removeClassLoader(java.lang.ClassLoader cl)

  Remove a class loader previously added via addClassLoader
  Parameters:
    `cl,` - the ClassLoader previously added via addClassLoader

### run

    public void run()

  Listen threads entry point. Here we accept a client connection and located requested classes/resources using the class loader specified in the http request.
  Specified by:
    `run` in interface `java.lang.Runnable`

### getClassLoaderKey

    protected java.lang.String getClassLoaderKey(java.lang.ClassLoader cl)

  Create the string key used as the key into the loaderMap.
  Returns:
    The class loader instance key.

### listen

    protected void listen()

### getPath

    protected java.lang.String getPath(java.io.BufferedReader in)
                                throws java.io.IOException

  Returns:
    the path portion of the HTTP request header.

### getBytes

    protected byte[] getBytes(java.net.URL url)
                       throws java.io.IOException

  Read the local class/resource contents into a byte array.

### getMimeType

    protected java.lang.String getMimeType(java.lang.String path)

  Lookup the mime type for the suffix of the path argument.
  Returns:
    the mime-type string for path.

Overview | Package | Class | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

Copyright © 2000 The JBoss Organization. All Rights Reserved.