Package com.yahoo.jdisc.handler
Class NullContent
java.lang.Object
com.yahoo.jdisc.handler.NullContent
- All Implemented Interfaces:
ContentChannel
This class provides a convenient implementation of ContentChannel
that does not support being written to.
If write(ByteBuffer, CompletionHandler)
is called, it throws an UnsupportedOperationException. If close(CompletionHandler)
is called, it calls the given CompletionHandler
.
A RequestHandler
s that does not expect content can simply return the INSTANCE
of this class for
every invocation of its RequestHandler.handleRequest(Request, ResponseHandler)
.
- Author:
- Simon Thoresen Hult
-
Field Summary
-
Method Summary
Modifier and TypeMethodDescriptionvoid
close
(CompletionHandler handler) Closes this ContentChannel.void
write
(ByteBuffer buf, CompletionHandler handler) Schedules the givenByteBuffer
to be written to the content corresponding to this ContentChannel.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface com.yahoo.jdisc.handler.ContentChannel
onError
-
Field Details
-
INSTANCE
-
-
Method Details
-
write
Description copied from interface:ContentChannel
Schedules the givenByteBuffer
to be written to the content corresponding to this ContentChannel. This call transfers ownership of the given ByteBuffer to this ContentChannel, i.e. no further calls can be made to the buffer. The execution of writes happen in the same order as this method was invoked.- Specified by:
write
in interfaceContentChannel
- Parameters:
buf
- TheByteBuffer
to schedule for write. No further calls can be made to this buffer.handler
- TheCompletionHandler
to call after the write has been executed.
-
close
Description copied from interface:ContentChannel
Closes this ContentChannel. After a channel is closed, any further attempt to invokeContentChannel.write(ByteBuffer, CompletionHandler)
upon it will cause anIllegalStateException
to be thrown. If this channel is already closed then invoking this method has no effect, butCompletionHandler.completed()
will still be called. Notice that you MUST call this method, regardless of any exceptions that might have occurred while writing to this ContentChannel. Failure to do so will prevent theContainer
from ever shutting down.- Specified by:
close
in interfaceContentChannel
- Parameters:
handler
- TheCompletionHandler
to call after the close has been executed.
-