|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.abstracthorizon.danube.http.BaseReflectionHTTPConnectionHandler
org.abstracthorizon.danube.http.util.ReadOnlyFileConnectionHandler
public class ReadOnlyFileConnectionHandler
Connection handler that handles static files (and directories)
| Field Summary | |
|---|---|
protected int |
bufferSize
Buffer size |
static SimpleDateFormat |
dateFormat
|
static int |
DEFAULT_BUFFER_SIZE
|
protected File |
filePath
Path of directory files are going to be displayed from |
protected javax.activation.FileTypeMap |
fileTypeMap
File type map |
static long |
GIGABYTE
|
static long |
KILOBYTE
|
static long |
MEGABYTE
|
static long |
TERABYTE
|
| Fields inherited from class org.abstracthorizon.danube.http.BaseReflectionHTTPConnectionHandler |
|---|
cachedMethods, errorResponse, noDefaultHead, noDefaultTrace |
| Constructor Summary | |
|---|---|
ReadOnlyFileConnectionHandler()
Constructor |
|
| Method Summary | |
|---|---|
protected String |
encode(String string)
URL encodes given string |
int |
getBufferSize()
Returns buffer size |
protected File |
getFileHandle(HTTPConnection httpConnection)
Obtains real file system's file from the given connection |
File |
getFilePath()
Sets path where files are stored |
javax.activation.FileTypeMap |
getFileTypeMap()
Returns file type map that is used with this object |
protected String |
getLengthAsString(File f)
Returns file length as a string |
protected void |
handleDirectory(File dir,
HTTPConnection httpConnection)
Handles request of directory. |
protected void |
handleFile(File file,
HTTPConnection httpConnection)
Handles file request. |
void |
methodGET(HTTPConnection httpConnection)
This method retruns list of files from give directory or returns a file, using FileTypeMap to convert file extension to mime type |
void |
methodHEAD(HTTPConnection httpConnection)
This method retruns headers for for GET method but no body |
protected ByteBuffer |
obtainBuffer()
Obtains new buffer |
protected void |
releaseBuffer(ByteBuffer buffer)
Releases used direct buffer |
void |
setBufferSize(int bufferSize)
Sets buffer size |
void |
setFilePath(File filePath)
Sets path where files are stored |
void |
setFileTypeMap(javax.activation.FileTypeMap fileTypeMap)
Sets file type map to be used with this object |
protected void |
transferFromFileChannel(FileChannel inputChannel,
WritableByteChannel outputChannel,
long length)
Transfer file channel to given output channel |
protected void |
transferStreams(InputStream inputStream,
OutputStream outputStream,
long length)
Transfer file input stream to output stream |
protected void |
updateHeadersForFile(HTTPConnection httpConnection,
File resource)
Updates http headers for given resource |
| Methods inherited from class org.abstracthorizon.danube.http.BaseReflectionHTTPConnectionHandler |
|---|
cacheMethods, getErrorResponse, getNoDefaultHead, getNoDefaultTrace, handleConnection, invokeMethod, methodOPTIONS, methodTRACE, returnError, returnSimpleContent, setErrorResponse, setNoDefaultHead, setNoDefaultTrace, updateDefaultHeadMethod, updateDefaultTraceMethod |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
public static final SimpleDateFormat dateFormat
public static final long KILOBYTE
public static final long MEGABYTE
public static final long GIGABYTE
public static final long TERABYTE
public static final int DEFAULT_BUFFER_SIZE
protected File filePath
protected int bufferSize
protected javax.activation.FileTypeMap fileTypeMap
| Constructor Detail |
|---|
public ReadOnlyFileConnectionHandler()
| Method Detail |
|---|
public void setFilePath(File filePath)
filePath - file pathpublic File getFilePath()
public int getBufferSize()
public void setBufferSize(int bufferSize)
bufferSize - buffer sizepublic javax.activation.FileTypeMap getFileTypeMap()
public void setFileTypeMap(javax.activation.FileTypeMap fileTypeMap)
fileTypeMap - file type map to be used with this objectpublic void methodGET(HTTPConnection httpConnection)
FileTypeMap to convert file extension to mime type
connection - http connectionpublic void methodHEAD(HTTPConnection httpConnection)
methodHEAD in class BaseReflectionHTTPConnectionHandlerconnection - http connection
protected void updateHeadersForFile(HTTPConnection httpConnection,
File resource)
httpConnection - http connectionfile - resourceprotected File getFileHandle(HTTPConnection httpConnection)
httpConnection - connection
protected void handleDirectory(File dir,
HTTPConnection httpConnection)
dir - directoryhttpConnection - http connection
IOException
protected void handleFile(File file,
HTTPConnection httpConnection)
FileTypeMap.
file - requested filehttpConnection - http connecitonprotected String getLengthAsString(File f)
f - file
protected String encode(String string)
string - string to be encoded
protected void transferFromFileChannel(FileChannel inputChannel,
WritableByteChannel outputChannel,
long length)
throws IOException
inputChannel - file channeloutputChannel - output channellength - length
IOException - IO exceptionprotected ByteBuffer obtainBuffer()
protected void releaseBuffer(ByteBuffer buffer)
protected void transferStreams(InputStream inputStream,
OutputStream outputStream,
long length)
throws IOException
inputStream - file input streamoutputStream - output streamlength - length
IOException - IO exception
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||