Class ClientDownloadFilter
java.lang.Object
org.glassfish.grizzly.filterchain.BaseFilter
org.glassfish.grizzly.samples.http.download.ClientDownloadFilter
- All Implemented Interfaces:
org.glassfish.grizzly.filterchain.Filter
public class ClientDownloadFilter
extends org.glassfish.grizzly.filterchain.BaseFilter
HTTP client download filter.
This Filter is responsible for asynchronous downloading of a HTTP resource and
saving its content in a local file.
- Author:
- Alexey Stashok
-
Constructor Summary
ConstructorsConstructorDescriptionClientDownloadFilter(URI uri, org.glassfish.grizzly.impl.FutureImpl<String> completeFuture) ClientDownloadFilter constructor -
Method Summary
Modifier and TypeMethodDescriptionorg.glassfish.grizzly.filterchain.NextActionhandleClose(org.glassfish.grizzly.filterchain.FilterChainContext ctx) The method is called, when the client connection will get closed.org.glassfish.grizzly.filterchain.NextActionhandleConnect(org.glassfish.grizzly.filterchain.FilterChainContext ctx) The method is called, when a client connection gets connected to a web server.org.glassfish.grizzly.filterchain.NextActionhandleRead(org.glassfish.grizzly.filterchain.FilterChainContext ctx) The method is called, when we receive aHttpContentfrom a server.Methods inherited from class org.glassfish.grizzly.filterchain.BaseFilter
createContext, exceptionOccurred, handleAccept, handleEvent, handleWrite, onAdded, onFilterChainChanged, onRemoved, toString
-
Constructor Details
-
ClientDownloadFilter
ClientDownloadFilter constructor- Parameters:
uri-URIof a remote resource to downloadcompleteFuture- download completion handler (FutureImpl)
-
-
Method Details
-
handleConnect
public org.glassfish.grizzly.filterchain.NextAction handleConnect(org.glassfish.grizzly.filterchain.FilterChainContext ctx) throws IOException The method is called, when a client connection gets connected to a web server. When this method gets called by a framework - it means that client connection has been established and we can send HTTP request to the web server.- Specified by:
handleConnectin interfaceorg.glassfish.grizzly.filterchain.Filter- Overrides:
handleConnectin classorg.glassfish.grizzly.filterchain.BaseFilter- Parameters:
ctx- Client connect processing context- Returns:
NextAction- Throws:
IOException
-
handleRead
public org.glassfish.grizzly.filterchain.NextAction handleRead(org.glassfish.grizzly.filterchain.FilterChainContext ctx) throws IOException The method is called, when we receive aHttpContentfrom a server. Once we receive one - we save the content chunk to a local file.- Specified by:
handleReadin interfaceorg.glassfish.grizzly.filterchain.Filter- Overrides:
handleReadin classorg.glassfish.grizzly.filterchain.BaseFilter- Parameters:
ctx- Request processing context- Returns:
NextAction- Throws:
IOException
-
handleClose
public org.glassfish.grizzly.filterchain.NextAction handleClose(org.glassfish.grizzly.filterchain.FilterChainContext ctx) throws IOException The method is called, when the client connection will get closed. Intercepting this method let's use release resources, like local FileChannel, if it wasn't released before.- Specified by:
handleClosein interfaceorg.glassfish.grizzly.filterchain.Filter- Overrides:
handleClosein classorg.glassfish.grizzly.filterchain.BaseFilter- Parameters:
ctx- Request processing context- Returns:
NextAction- Throws:
IOException
-