Top Inners Fields Constructors Methods
org.glassfish.grizzly.http.server

public Class FileCacheFilter

extends BaseFilter
Class Inheritance
Imports
java.io.File, .FileInputStream, .IOException, java.nio.channels.FileChannel, java.util.logging.Level, .Logger, org.glassfish.grizzly.Buffer, .EmptyCompletionHandler, .FileTransfer, .Grizzly, .OutputSink, .WriteHandler, .WriteResult, org.glassfish.grizzly.filterchain.BaseFilter, .FilterChainContext, .NextAction, org.glassfish.grizzly.http.HttpContent, .HttpContext, .HttpRequestPacket, .HttpResponsePacket, .Method, org.glassfish.grizzly.http.server.filecache.FileCache, .FileCache.CacheType, .FileCacheEntry, org.glassfish.grizzly.http.util.Header, org.glassfish.grizzly.memory.Buffers

Author
oleksiys

Nested and Inner Type Summary

Modifier and TypeClass and Description
private static class

Field Summary

Modifier and TypeField and Description
private final FileCache
private static final Logger

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
private NextAction
public FileCache
public NextAction
handleRead(final FilterChainContext ctx)

Overrides org.glassfish.grizzly.filterchain.BaseFilter.handleRead.

Implements org.glassfish.grizzly.filterchain.Filter.handleRead.

Execute a unit of processing work to be performed, when channel will become available for reading.

private void
prepareResponse(final FileCacheEntry entry, final HttpResponsePacket response)

Prepares common response headers.

private void
prepareResponseWithPayload(final FileCacheEntry entry, final HttpResponsePacket response, final boolean isServeCompressed)

Prepare response with payload headers.

private NextAction
sendFileUsingBuffers(final FilterChainContext ctx, final HttpResponsePacket response, final FileCacheEntry cacheEntry, final boolean isServeCompressed)

private NextAction
sendFileZeroCopy(final FilterChainContext ctx, final HttpResponsePacket response, final FileCacheEntry cacheEntry, final boolean isServeCompressed)

Inherited from org.glassfish.grizzly.filterchain.BaseFilter:
createContextexceptionOccurredhandleAccepthandleClosehandleConnecthandleEventhandleWriteonAddedonFilterChainChangedonRemovedtoString

Field Detail

fileCacheback to summary
private final FileCache fileCache
LOGGERback to summary
private static final Logger LOGGER

Constructor Detail

FileCacheFilterback to summary
public FileCacheFilter(FileCache fileCache)

Method Detail

flushback to summary
private NextAction flush(final FilterChainContext ctx)
getFileCacheback to summary
public FileCache getFileCache()
handleReadback to summary
public NextAction handleRead(final FilterChainContext ctx) throws IOException

Overrides org.glassfish.grizzly.filterchain.BaseFilter.handleRead.

Implements org.glassfish.grizzly.filterchain.Filter.handleRead.

Doc from org.glassfish.grizzly.filterchain.BaseFilter.handleRead.

Execute a unit of processing work to be performed, when channel will become available for reading. This Filter may either complete the required processing and return false, or delegate remaining processing to the next Filter in a FilterChain containing this Filter by returning true.

Annotations
@Override
prepareResponseback to summary
private void prepareResponse(final FileCacheEntry entry, final HttpResponsePacket response) throws IOException

Prepares common response headers.

prepareResponseWithPayloadback to summary
private void prepareResponseWithPayload(final FileCacheEntry entry, final HttpResponsePacket response, final boolean isServeCompressed) throws IOException

Prepare response with payload headers.

sendFileUsingBuffersback to summary
private NextAction sendFileUsingBuffers(final FilterChainContext ctx, final HttpResponsePacket response, final FileCacheEntry cacheEntry, final boolean isServeCompressed)
sendFileZeroCopyback to summary
private NextAction sendFileZeroCopy(final FilterChainContext ctx, final HttpResponsePacket response, final FileCacheEntry cacheEntry, final boolean isServeCompressed)
org.glassfish.grizzly.http.server back to summary

private Class FileCacheFilter.FileSendEntry

extends Object
implements WriteHandler
Class Inheritance
  • java.lang.Object
  • org.glassfish.grizzly.http.server.FileCacheFilter.FileSendEntry
All Implemented Interfaces
org.glassfish.grizzly.WriteHandler

Field Summary

Modifier and TypeField and Description
private final FilterChainContext
private final FileChannel
private final FileInputStream
private final OutputSink
private long
private final HttpResponsePacket

Constructor Summary

AccessConstructor and Description
public
FileSendEntry(final FilterChainContext ctx, final HttpResponsePacket response, final FileInputStream fis, final FileChannel fc, final long size)

Method Summary

Modifier and TypeMethod and Description
public void
public static FileCacheFilter.FileSendEntry
create(final FilterChainContext ctx, final HttpResponsePacket response, final File file, final long size)

private void
done()

public void
onError(Throwable t)

Implements org.glassfish.grizzly.WriteHandler.onError.

Invoked when an error occurs processing the request asynchronously.

public void
onWritePossible()

Implements org.glassfish.grizzly.WriteHandler.onWritePossible.

This callback will be invoked when the requirements as dictated by writer are met.

private void
send()

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

ctxback to summary
private final FilterChainContext ctx
fcback to summary
private final FileChannel fc
fisback to summary
private final FileInputStream fis
outputback to summary
private final OutputSink output
remainingback to summary
private long remaining
responseback to summary
private final HttpResponsePacket response

Constructor Detail

FileSendEntryback to summary
public FileSendEntry(final FilterChainContext ctx, final HttpResponsePacket response, final FileInputStream fis, final FileChannel fc, final long size)

Method Detail

closeback to summary
public void close()
createback to summary
public static FileCacheFilter.FileSendEntry create(final FilterChainContext ctx, final HttpResponsePacket response, final File file, final long size) throws IOException
doneback to summary
private void done()
onErrorback to summary
public void onError(Throwable t)

Implements org.glassfish.grizzly.WriteHandler.onError.

Doc from org.glassfish.grizzly.WriteHandler.onError.

Invoked when an error occurs processing the request asynchronously.

Annotations
@Override
onWritePossibleback to summary
public void onWritePossible() throws Exception

Implements org.glassfish.grizzly.WriteHandler.onWritePossible.

Doc from org.glassfish.grizzly.WriteHandler.onWritePossible.

This callback will be invoked when the requirements as dictated by writer are met.

Annotations
@Override
Exceptions
Exception:
Exception might be thrown by the custom handler code. This exception will be delegated for processing to onError(java.lang.Throwable).
sendback to summary
private void send()