org.gloin.resource
Class HttpServer
java.lang.Object
|
+--java.lang.Thread
|
+--org.gloin.resource.HttpServer
- All Implemented Interfaces:
- java.lang.Runnable
- public class HttpServer
- extends java.lang.Thread
A simple HTTP server, just for serving up the code service's proxy.
Code taken from http server that ships with JSK.
Byte stream on disk are now accessed through the
ByteStore
interface.
Capability to reserve a given name in the "reserved" namespace for
a specific set of bytes has been added. Reserved bytes are held
directly are not written to disk.
Its also possible to register a call back to listen when resources
are downloaded.
Fields inherited from class java.lang.Thread |
MAX_PRIORITY, MIN_PRIORITY, NORM_PRIORITY |
Method Summary |
protected void |
fileDownloaded(java.lang.String fp,
java.net.InetAddress addr)
This method provides a way for subclasses to be notified when a
file has been completely downloaded. |
java.lang.String |
getBaseURL()
|
void |
reserveBytes(java.lang.String path,
byte[] reservedBytes)
|
void |
reserveBytes(java.net.URL bytesURL,
java.lang.String name)
|
void |
run()
Just keep looping, spawning a new thread for each incoming request. |
java.lang.String |
toString()
|
Methods inherited from class java.lang.Thread |
activeCount, checkAccess, countStackFrames, currentThread, destroy, dumpStack, enumerate, getContextClassLoader, getName, getPriority, getThreadGroup, interrupt, interrupted, isAlive, isDaemon, isInterrupted, join, join, join, resume, setContextClassLoader, setDaemon, setName, setPriority, sleep, sleep, start, stop, stop, suspend, yield |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
HttpServer
public HttpServer(ByteStore store,
boolean verbose)
throws java.io.IOException
- Construct a server. Use the start method to run it.
- Parameters:
port
- the port to usedir
- the directory to serve files fromverbose
- true if downloads should be logged
HttpServer
public HttpServer(ByteStore store,
boolean verbose,
DownloadListener downloadListener)
throws java.io.IOException
HttpServer
public HttpServer(ByteStore store,
boolean verbose,
DownloadListener downloadListener,
int port)
throws java.io.IOException
getBaseURL
public java.lang.String getBaseURL()
throws java.io.IOException
toString
public java.lang.String toString()
- Overrides:
toString
in class java.lang.Thread
run
public void run()
- Just keep looping, spawning a new thread for each incoming request.
- Overrides:
run
in class java.lang.Thread
fileDownloaded
protected void fileDownloaded(java.lang.String fp,
java.net.InetAddress addr)
- This method provides a way for subclasses to be notified when a
file has been completely downloaded.
- Parameters:
fp
- The path to the file that was downloaded.
reserveBytes
public void reserveBytes(java.lang.String path,
byte[] reservedBytes)
throws java.io.IOException
reserveBytes
public void reserveBytes(java.net.URL bytesURL,
java.lang.String name)
throws java.io.IOException