Package org.apache.tomcat.util.net
Class AprEndpoint.AprSocketWrapper
- java.lang.Object
-
- org.apache.tomcat.util.net.SocketWrapperBase<java.lang.Long>
-
- org.apache.tomcat.util.net.AprEndpoint.AprSocketWrapper
-
- Enclosing class:
- AprEndpoint
public static class AprEndpoint.AprSocketWrapper extends SocketWrapperBase<java.lang.Long>
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class org.apache.tomcat.util.net.SocketWrapperBase
SocketWrapperBase.BlockingMode, SocketWrapperBase.CompletionCheck, SocketWrapperBase.CompletionHandlerCall, SocketWrapperBase.CompletionState, SocketWrapperBase.OperationState<A>, SocketWrapperBase.VectoredIOCompletionHandler<A>
-
-
Field Summary
-
Fields inherited from class org.apache.tomcat.util.net.SocketWrapperBase
bufferedWriteSize, closed, COMPLETE_READ, COMPLETE_READ_WITH_COMPLETION, COMPLETE_WRITE, COMPLETE_WRITE_WITH_COMPLETION, localAddr, localName, localPort, nonBlockingWriteBuffer, previousIOException, READ_DATA, readOperation, readPending, remoteAddr, remoteHost, remotePort, sm, sniHostName, socketBufferHandler, writeOperation, writePending
-
-
Constructor Summary
Constructors Constructor Description AprSocketWrapper(java.lang.Long socket, AprEndpoint endpoint)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidclose()Close the socket wrapper.SendfileDataBasecreateSendfileData(java.lang.String filename, long pos, long length)Creates a sendfile data object for the specified file.voiddoClientAuth(SSLSupport sslSupport)Require the client to perform CLIENT-CERT authentication if it hasn't already done so.protected voiddoClose()Perform the actual close.protected voiddoWrite(boolean block, java.nio.ByteBuffer from)Write the contents of the ByteBuffer to the socket.protected booleanflushNonBlocking()Flushes remaining buffered data using a non-blocking write.booleangetBlockingStatus()java.util.concurrent.locks.LockgetBlockingStatusReadLock()java.util.concurrent.locks.ReentrantReadWriteLock.WriteLockgetBlockingStatusWriteLock()SSLSupportgetSslSupport()Obtain an SSLSupport instance for this socket.SSLSupportgetSslSupport(java.lang.String clientCertProvider)Obtain an SSLSupport instance for this socket.booleanisReadyForRead()Checks if the socket is ready for reading.protected <A> SocketWrapperBase.OperationState<A>newOperationState(boolean read, java.nio.ByteBuffer[] buffers, int offset, int length, SocketWrapperBase.BlockingMode block, long timeout, java.util.concurrent.TimeUnit unit, A attachment, SocketWrapperBase.CompletionCheck check, java.nio.channels.CompletionHandler<java.lang.Long,? super A> handler, java.util.concurrent.Semaphore semaphore, SocketWrapperBase.VectoredIOCompletionHandler<A> completion)Creates a new operation state for vectored I/O operations.protected voidpopulateLocalAddr()Populates the cached local IP address from the underlying socket.protected voidpopulateLocalName()Populates the cached local host name from the underlying socket.protected voidpopulateLocalPort()Populates the cached local port number from the underlying socket.protected voidpopulateRemoteAddr()Populates the cached remote IP address from the underlying socket.protected voidpopulateRemoteHost()Populates the cached remote host name from the underlying socket.protected voidpopulateRemotePort()Populates the cached remote port number from the underlying socket.SendfileStateprocessSendfile(SendfileDataBase sendfileData)Starts the sendfile process.intread(boolean block, byte[] b, int off, int len)Reads data from the socket into a byte array.intread(boolean block, java.nio.ByteBuffer to)Reads data from the socket into a ByteBuffer.voidregisterReadInterest()Registers interest in read events.voidregisterWriteInterest()Registers interest in write events.voidsetAppReadBufHandler(ApplicationBufferHandler handler)Sets the application-level read buffer handler.voidsetBlockingStatus(boolean blockingStatus)-
Methods inherited from class org.apache.tomcat.util.net.SocketWrapperBase
awaitReadComplete, awaitWriteComplete, buffersArrayHasRemaining, canWrite, checkError, decrementKeepAlive, doWrite, execute, flush, flushBlocking, getCurrentProcessor, getEndpoint, getError, getLocalAddr, getLocalName, getLocalPort, getLock, getNegotiatedProtocol, getReadTimeout, getRemoteAddr, getRemoteHost, getRemotePort, getSniHostName, getSocket, getSocketBufferHandler, getWriteTimeout, hasAsyncIO, hasDataToRead, hasDataToWrite, hasPerOperationTimeout, isClosed, isReadPending, isReadyForWrite, isSecure, isUpgraded, isWritePending, needSemaphores, populateReadBuffer, populateReadBuffer, processSocket, read, read, read, reset, setCurrentProcessor, setError, setKeepAliveLeft, setNegotiatedProtocol, setReadTimeout, setSecure, setSniHostName, setUpgraded, setWriteTimeout, takeCurrentProcessor, toString, transfer, transfer, unRead, vectoredOperation, write, write, write, write, write, writeBlocking, writeBlocking, writeNonBlocking, writeNonBlocking, writeNonBlockingInternal
-
-
-
-
Constructor Detail
-
AprSocketWrapper
public AprSocketWrapper(java.lang.Long socket, AprEndpoint endpoint)
-
-
Method Detail
-
getBlockingStatus
public boolean getBlockingStatus()
-
setBlockingStatus
public void setBlockingStatus(boolean blockingStatus)
-
getBlockingStatusReadLock
public java.util.concurrent.locks.Lock getBlockingStatusReadLock()
-
getBlockingStatusWriteLock
public java.util.concurrent.locks.ReentrantReadWriteLock.WriteLock getBlockingStatusWriteLock()
-
read
public int read(boolean block, byte[] b, int off, int len) throws java.io.IOExceptionDescription copied from class:SocketWrapperBaseReads data from the socket into a byte array.- Specified by:
readin classSocketWrapperBase<java.lang.Long>- Parameters:
block- Whether to blockb- The byte array to read intooff- The offset in the arraylen- The number of bytes to read- Returns:
- the number of bytes read
- Throws:
java.io.IOException- If an I/O error occurs
-
read
public int read(boolean block, java.nio.ByteBuffer to) throws java.io.IOExceptionDescription copied from class:SocketWrapperBaseReads data from the socket into a ByteBuffer.- Specified by:
readin classSocketWrapperBase<java.lang.Long>- Parameters:
block- Whether to blockto- The ByteBuffer to read into- Returns:
- the number of bytes read
- Throws:
java.io.IOException- If an I/O error occurs
-
isReadyForRead
public boolean isReadyForRead() throws java.io.IOExceptionDescription copied from class:SocketWrapperBaseChecks if the socket is ready for reading.- Specified by:
isReadyForReadin classSocketWrapperBase<java.lang.Long>- Returns:
trueif data is available to read- Throws:
java.io.IOException- If an I/O error occurs
-
close
public void close()
Description copied from class:SocketWrapperBaseClose the socket wrapper.- Overrides:
closein classSocketWrapperBase<java.lang.Long>
-
doClose
protected void doClose()
Description copied from class:SocketWrapperBasePerform the actual close. The closed atomic boolean guarantees this will be called only once per wrapper.- Specified by:
doClosein classSocketWrapperBase<java.lang.Long>
-
flushNonBlocking
protected boolean flushNonBlocking() throws java.io.IOExceptionDescription copied from class:SocketWrapperBaseFlushes remaining buffered data using a non-blocking write.- Specified by:
flushNonBlockingin classSocketWrapperBase<java.lang.Long>- Returns:
trueif data remains to be flushed after this method completes, otherwisefalse- Throws:
java.io.IOException- If an IO error occurs during the write
-
doWrite
protected void doWrite(boolean block, java.nio.ByteBuffer from) throws java.io.IOExceptionDescription copied from class:SocketWrapperBaseWrite the contents of the ByteBuffer to the socket. For blocking writes either then entire contents of the buffer will be written or an IOException will be thrown. Partial blocking writes will not occur.- Specified by:
doWritein classSocketWrapperBase<java.lang.Long>- Parameters:
block- Should the write be blocking or not?from- the ByteBuffer containing the data to be written- Throws:
java.io.IOException- If an I/O error such as a timeout occurs during the write
-
registerReadInterest
public void registerReadInterest()
Description copied from class:SocketWrapperBaseRegisters interest in read events.- Specified by:
registerReadInterestin classSocketWrapperBase<java.lang.Long>
-
registerWriteInterest
public void registerWriteInterest()
Description copied from class:SocketWrapperBaseRegisters interest in write events.- Specified by:
registerWriteInterestin classSocketWrapperBase<java.lang.Long>
-
createSendfileData
public SendfileDataBase createSendfileData(java.lang.String filename, long pos, long length)
Description copied from class:SocketWrapperBaseCreates a sendfile data object for the specified file.- Specified by:
createSendfileDatain classSocketWrapperBase<java.lang.Long>- Parameters:
filename- The file to sendpos- The starting position in the filelength- The number of bytes to send- Returns:
- a new sendfile data object
-
processSendfile
public SendfileState processSendfile(SendfileDataBase sendfileData)
Description copied from class:SocketWrapperBaseStarts the sendfile process. It is expected that if the sendfile process does not complete during this call and does not report an error, that the caller will not add the socket to the poller (or equivalent). That is the responsibility of this method.- Specified by:
processSendfilein classSocketWrapperBase<java.lang.Long>- Parameters:
sendfileData- Data representing the file to send- Returns:
- The state of the sendfile process after the first write.
-
populateRemoteAddr
protected void populateRemoteAddr()
Description copied from class:SocketWrapperBasePopulates the cached remote IP address from the underlying socket.- Specified by:
populateRemoteAddrin classSocketWrapperBase<java.lang.Long>
-
populateRemoteHost
protected void populateRemoteHost()
Description copied from class:SocketWrapperBasePopulates the cached remote host name from the underlying socket.- Specified by:
populateRemoteHostin classSocketWrapperBase<java.lang.Long>
-
populateRemotePort
protected void populateRemotePort()
Description copied from class:SocketWrapperBasePopulates the cached remote port number from the underlying socket.- Specified by:
populateRemotePortin classSocketWrapperBase<java.lang.Long>
-
populateLocalName
protected void populateLocalName()
Description copied from class:SocketWrapperBasePopulates the cached local host name from the underlying socket.- Specified by:
populateLocalNamein classSocketWrapperBase<java.lang.Long>
-
populateLocalAddr
protected void populateLocalAddr()
Description copied from class:SocketWrapperBasePopulates the cached local IP address from the underlying socket.- Specified by:
populateLocalAddrin classSocketWrapperBase<java.lang.Long>
-
populateLocalPort
protected void populateLocalPort()
Description copied from class:SocketWrapperBasePopulates the cached local port number from the underlying socket.- Specified by:
populateLocalPortin classSocketWrapperBase<java.lang.Long>
-
getSslSupport
public SSLSupport getSslSupport(java.lang.String clientCertProvider)
Description copied from class:SocketWrapperBaseObtain an SSLSupport instance for this socket.- Overrides:
getSslSupportin classSocketWrapperBase<java.lang.Long>- Parameters:
clientCertProvider- The name of the client certificate provider to use. Only used by APR/native.- Returns:
- An SSLSupport instance for this socket.
-
getSslSupport
public SSLSupport getSslSupport()
Description copied from class:SocketWrapperBaseObtain an SSLSupport instance for this socket.- Specified by:
getSslSupportin classSocketWrapperBase<java.lang.Long>- Returns:
- An SSLSupport instance for this socket.
-
doClientAuth
public void doClientAuth(SSLSupport sslSupport) throws java.io.IOException
Description copied from class:SocketWrapperBaseRequire the client to perform CLIENT-CERT authentication if it hasn't already done so.- Specified by:
doClientAuthin classSocketWrapperBase<java.lang.Long>- Parameters:
sslSupport- The SSL/TLS support instance currently being used by the connection that may need updating after the client authentication- Throws:
java.io.IOException- If authentication is required then there will be I/O with the client and this exception will be thrown if that goes wrong
-
setAppReadBufHandler
public void setAppReadBufHandler(ApplicationBufferHandler handler)
Description copied from class:SocketWrapperBaseSets the application-level read buffer handler.- Specified by:
setAppReadBufHandlerin classSocketWrapperBase<java.lang.Long>- Parameters:
handler- The application buffer handler
-
newOperationState
protected <A> SocketWrapperBase.OperationState<A> newOperationState(boolean read, java.nio.ByteBuffer[] buffers, int offset, int length, SocketWrapperBase.BlockingMode block, long timeout, java.util.concurrent.TimeUnit unit, A attachment, SocketWrapperBase.CompletionCheck check, java.nio.channels.CompletionHandler<java.lang.Long,? super A> handler, java.util.concurrent.Semaphore semaphore, SocketWrapperBase.VectoredIOCompletionHandler<A> completion)
Description copied from class:SocketWrapperBaseCreates a new operation state for vectored I/O operations.- Specified by:
newOperationStatein classSocketWrapperBase<java.lang.Long>- Type Parameters:
A- The attachment type- Parameters:
read- Whether this is a read operationbuffers- The buffers for the operationoffset- The offset in the buffer arraylength- The number of buffersblock- The blocking modetimeout- The timeout durationunit- The timeout time unitattachment- An attachment objectcheck- The completion checkhandler- The completion handlersemaphore- The semaphore for synchronizationcompletion- The vectored I/O completion handler- Returns:
- a new operation state instance
-
-