public class HTTPRemoteFileRegistry extends Object implements CleanupIF
Modifier and Type | Class and Description |
---|---|
protected class |
HTTPRemoteFileRegistry.HTTPRemoteFileRegistryHandler
A handler for the registry.
|
Modifier and Type | Field and Description |
---|---|
protected static HTTPRemoteFileRegistry |
instance
The unique instance.
|
protected int |
port
Port number for generating URLs.
|
protected org.eclipse.jetty.server.Server |
server
The embedded webserver.
|
Modifier | Constructor and Description |
---|---|
protected |
HTTPRemoteFileRegistry()
Initialise the registry.
|
Modifier and Type | Method and Description |
---|---|
void |
cleanup()
Stops the server and nulls the instance.
|
static HTTPRemoteFileRegistry |
getInstance()
Get the unique instance.
|
protected String |
getProtocol()
Get the protocol part of URLs, that is HTTP.
|
protected URLConnection |
openConnection(URL url)
Open a connection to an URL in a registry.
|
URL |
registerFile(File file,
boolean deletable)
Register a file for serving to an endpoint.
|
protected void |
startServer()
Start the server, including a handler that responds with registered files, removes registered files on request,
and gives 404 otherwise.
|
protected static HTTPRemoteFileRegistry instance
protected final int port
protected org.eclipse.jetty.server.Server server
protected HTTPRemoteFileRegistry()
IOFailure
- if it cannot be initialised.protected void startServer()
IOFailure
- if it cannot be initialised.protected String getProtocol()
public static HTTPRemoteFileRegistry getInstance()
public URL registerFile(File file, boolean deletable)
file
- The file to register.deletable
- Whether it should be deleted on cleanup.ArgumentNotValid
- on null or unreadable file.IOFailure
- on any trouble registerring the fileprotected URLConnection openConnection(URL url) throws IOException
url
- The URL to open connection to.IOException
- If unable to open the connection.Copyright © 2005–2015 The Royal Danish Library, the Danish State and University Library, the National Library of France and the Austrian National Library.. All rights reserved.