org.apache.tomcat.util.net.AbstractEndpoint Java Examples

The following examples show how to use org.apache.tomcat.util.net.AbstractEndpoint. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: AbstractAjpProcessor.java    From tomcatsrc with Apache License 2.0 6 votes vote down vote up
public AbstractAjpProcessor(int packetSize, AbstractEndpoint<S> endpoint) {

        super(endpoint);

        this.packetSize = packetSize;

        request.setInputBuffer(new SocketInputBuffer());

        requestHeaderMessage = new AjpMessage(packetSize);
        responseMessage = new AjpMessage(packetSize);
        bodyMessage = new AjpMessage(packetSize);

        // Set the getBody message buffer
        AjpMessage getBodyMessage = new AjpMessage(16);
        getBodyMessage.reset();
        getBodyMessage.appendByte(Constants.JK_AJP13_GET_BODY_CHUNK);
        // Adjust read size if packetSize != default (Constants.MAX_PACKET_SIZE)
        getBodyMessage.appendInt(Constants.MAX_READ_SIZE + packetSize -
                Constants.MAX_PACKET_SIZE);
        getBodyMessage.end();
        getBodyMessageArray = new byte[getBodyMessage.getLen()];
        System.arraycopy(getBodyMessage.getBuffer(), 0, getBodyMessageArray,
                0, getBodyMessage.getLen());
    }
 
Example #2
Source File: AbstractAjpProcessor.java    From Tomcat7.0.67 with Apache License 2.0 6 votes vote down vote up
public AbstractAjpProcessor(int packetSize, AbstractEndpoint<S> endpoint) {

        super(endpoint);

        this.packetSize = packetSize;

        request.setInputBuffer(new SocketInputBuffer());

        requestHeaderMessage = new AjpMessage(packetSize);
        responseMessage = new AjpMessage(packetSize);
        bodyMessage = new AjpMessage(packetSize);

        // Set the getBody message buffer
        AjpMessage getBodyMessage = new AjpMessage(16);
        getBodyMessage.reset();
        getBodyMessage.appendByte(Constants.JK_AJP13_GET_BODY_CHUNK);
        // Adjust read size if packetSize != default (Constants.MAX_PACKET_SIZE)
        getBodyMessage.appendInt(Constants.MAX_READ_SIZE + packetSize -
                Constants.MAX_PACKET_SIZE);
        getBodyMessage.end();
        getBodyMessageArray = new byte[getBodyMessage.getLen()];
        System.arraycopy(getBodyMessage.getBuffer(), 0, getBodyMessageArray, 
                0, getBodyMessage.getLen());
    }
 
Example #3
Source File: TesterBug50640SslImpl.java    From tomcatsrc with Apache License 2.0 5 votes vote down vote up
@Override
public ServerSocketFactory getServerSocketFactory(
        AbstractEndpoint<?> endpoint)  {

    // Check the custom attribute is visible & correcly set
    String flag = endpoint.getProperty(PROPERTY_NAME);
    if (PROPERTY_VALUE.equals(flag)) {
        return super.getServerSocketFactory(endpoint);
    } else {
        return null;
    }
}
 
Example #4
Source File: TesterBug50640SslImpl.java    From Tomcat7.0.67 with Apache License 2.0 5 votes vote down vote up
@Override
public ServerSocketFactory getServerSocketFactory(
        AbstractEndpoint<?> endpoint)  {

    // Check the custom attribute is visible & correcly set
    String flag = endpoint.getProperty(PROPERTY_NAME);
    if (PROPERTY_VALUE.equals(flag)) {
        return super.getServerSocketFactory(endpoint);
    } else {
        return null;
    }
}
 
Example #5
Source File: AbstractProcessor.java    From Tomcat7.0.67 with Apache License 2.0 5 votes vote down vote up
public AbstractProcessor(AbstractEndpoint<S> endpoint) {
    this.endpoint = endpoint;
    asyncStateMachine = new AsyncStateMachine<S>(this);
    request = new Request();
    response = new Response();
    response.setHook(this);
    request.setResponse(response);
}
 
Example #6
Source File: AbstractAjpProtocol.java    From Tomcat8-Source-Read with MIT License 5 votes vote down vote up
public AbstractAjpProtocol(AbstractEndpoint<S> endpoint) {
    super(endpoint);
    setConnectionTimeout(Constants.DEFAULT_CONNECTION_TIMEOUT);
    // AJP does not use Send File
    getEndpoint().setUseSendfile(false);
    ConnectionHandler<S> cHandler = new ConnectionHandler<>(this);
    setHandler(cHandler);
    getEndpoint().setHandler(cHandler);
}
 
Example #7
Source File: InternalAprOutputBuffer.java    From Tomcat7.0.67 with Apache License 2.0 5 votes vote down vote up
@Override
public void init(SocketWrapper<Long> socketWrapper,
        AbstractEndpoint<Long> endpoint) throws IOException {

    socket = socketWrapper.getSocket().longValue();
    Socket.setsbb(this.socket, bbuf);
}
 
Example #8
Source File: InternalAprInputBuffer.java    From tomcatsrc with Apache License 2.0 5 votes vote down vote up
@Override
protected void init(SocketWrapper<Long> socketWrapper,
        AbstractEndpoint<Long> endpoint) throws IOException {

    wrapper = socketWrapper;
    socket = socketWrapper.getSocket().longValue();
    Socket.setrbb(this.socket, bbuf);
}
 
Example #9
Source File: InternalNioOutputBuffer.java    From Tomcat7.0.67 with Apache License 2.0 5 votes vote down vote up
@Override
public void init(SocketWrapper<NioChannel> socketWrapper,
        AbstractEndpoint<NioChannel> endpoint) throws IOException {

    socket = socketWrapper.getSocket();
    pool = ((NioEndpoint)endpoint).getSelectorPool();
}
 
Example #10
Source File: InternalNioInputBuffer.java    From tomcatsrc with Apache License 2.0 5 votes vote down vote up
@Override
protected void init(SocketWrapper<NioChannel> socketWrapper,
        AbstractEndpoint<NioChannel> endpoint) throws IOException {

    socket = socketWrapper.getSocket();
    socketReadBufferSize =
        socket.getBufHandler().getReadBuffer().capacity();

    int bufLength = headerBufferSize + socketReadBufferSize;
    if (buf == null || buf.length < bufLength) {
        buf = new byte[bufLength];
    }

    pool = ((NioEndpoint)endpoint).getSelectorPool();
}
 
Example #11
Source File: InternalNioInputBuffer.java    From Tomcat7.0.67 with Apache License 2.0 5 votes vote down vote up
@Override
protected void init(SocketWrapper<NioChannel> socketWrapper,
        AbstractEndpoint<NioChannel> endpoint) throws IOException {

    socket = socketWrapper.getSocket();
    socketReadBufferSize =
        socket.getBufHandler().getReadBuffer().capacity();

    int bufLength = headerBufferSize + socketReadBufferSize;
    if (buf == null || buf.length < bufLength) {
        buf = new byte[bufLength];
    }

    pool = ((NioEndpoint)endpoint).getSelectorPool();
}
 
Example #12
Source File: InternalAprInputBuffer.java    From Tomcat7.0.67 with Apache License 2.0 5 votes vote down vote up
@Override
protected void init(SocketWrapper<Long> socketWrapper,
        AbstractEndpoint<Long> endpoint) throws IOException {

    wrapper = socketWrapper;
    socket = socketWrapper.getSocket().longValue();
    Socket.setrbb(this.socket, bbuf);
}
 
Example #13
Source File: InternalAprOutputBuffer.java    From tomcatsrc with Apache License 2.0 5 votes vote down vote up
@Override
public void init(SocketWrapper<Long> socketWrapper,
        AbstractEndpoint<Long> endpoint) throws IOException {

    socket = socketWrapper.getSocket().longValue();
    Socket.setsbb(this.socket, bbuf);
}
 
Example #14
Source File: InternalNioOutputBuffer.java    From tomcatsrc with Apache License 2.0 5 votes vote down vote up
@Override
public void init(SocketWrapper<NioChannel> socketWrapper,
        AbstractEndpoint<NioChannel> endpoint) throws IOException {

    socket = socketWrapper.getSocket();
    pool = ((NioEndpoint)endpoint).getSelectorPool();
}
 
Example #15
Source File: WsRemoteEndpointImplServer.java    From Tomcat8-Source-Read with MIT License 5 votes vote down vote up
/**
 *
 * @param t             The throwable associated with any error that
 *                      occurred
 * @param useDispatch   Should {@link SendHandler#onResult(SendResult)} be
 *                      called from a new thread, keeping in mind the
 *                      requirements of
 *                      {@link javax.websocket.RemoteEndpoint.Async}
 */
private void clearHandler(Throwable t, boolean useDispatch) {
    // Setting the result marks this (partial) message as
    // complete which means the next one may be sent which
    // could update the value of the handler. Therefore, keep a
    // local copy before signalling the end of the (partial)
    // message.
    SendHandler sh = handler;
    handler = null;
    buffers = null;
    if (sh != null) {
        if (useDispatch) {
            OnResultRunnable r = new OnResultRunnable(sh, t);
            AbstractEndpoint<?> endpoint = socketWrapper.getEndpoint();
            Executor containerExecutor = endpoint.getExecutor();
            if (endpoint.isRunning() && containerExecutor != null) {
                containerExecutor.execute(r);
            } else {
                // Can't use the executor so call the runnable directly.
                // This may not be strictly specification compliant in all
                // cases but during shutdown only close messages are going
                // to be sent so there should not be the issue of nested
                // calls leading to stack overflow as described in bug
                // 55715. The issues with nested calls was the reason for
                // the separate thread requirement in the specification.
                r.run();
            }
        } else {
            if (t == null) {
                sh.onResult(new SendResult());
            } else {
                sh.onResult(new SendResult(t));
            }
        }
    }
}
 
Example #16
Source File: AbstractProcessor.java    From Tomcat8-Source-Read with MIT License 5 votes vote down vote up
protected AbstractProcessor(AbstractEndpoint<?> endpoint, Request coyoteRequest,
        Response coyoteResponse) {
    this.endpoint = endpoint;
    asyncStateMachine = new AsyncStateMachine(this);
    request = coyoteRequest;
    response = coyoteResponse;
    response.setHook(this);
    request.setResponse(response);
    request.setHook(this);
    userDataHelper = new UserDataHelper(getLog());
}
 
Example #17
Source File: AjpProcessor.java    From Tomcat8-Source-Read with MIT License 5 votes vote down vote up
public AjpProcessor(int packetSize, AbstractEndpoint<?> endpoint) {

        super(endpoint);

        // Calculate maximum chunk size as packetSize may have been changed from
        // the default (Constants.MAX_PACKET_SIZE)
        this.outputMaxChunkSize =
                Constants.MAX_SEND_SIZE + packetSize - Constants.MAX_PACKET_SIZE;

        request.setInputBuffer(new SocketInputBuffer());

        requestHeaderMessage = new AjpMessage(packetSize);
        responseMessage = new AjpMessage(packetSize);
        bodyMessage = new AjpMessage(packetSize);

        // Set the getBody message buffer
        AjpMessage getBodyMessage = new AjpMessage(16);
        getBodyMessage.reset();
        getBodyMessage.appendByte(Constants.JK_AJP13_GET_BODY_CHUNK);
        // Adjust read size if packetSize != default (Constants.MAX_PACKET_SIZE)
        getBodyMessage.appendInt(Constants.MAX_READ_SIZE + packetSize -
                Constants.MAX_PACKET_SIZE);
        getBodyMessage.end();
        getBodyMessageArray = new byte[getBodyMessage.getLen()];
        System.arraycopy(getBodyMessage.getBuffer(), 0, getBodyMessageArray,
                0, getBodyMessage.getLen());

        response.setOutputBuffer(new SocketOutputBuffer());
    }
 
Example #18
Source File: AbstractHttp11Protocol.java    From Tomcat8-Source-Read with MIT License 5 votes vote down vote up
public AbstractHttp11Protocol(AbstractEndpoint<S> endpoint) {
    super(endpoint);
    setConnectionTimeout(Constants.DEFAULT_CONNECTION_TIMEOUT);
    ConnectionHandler<S> cHandler = new ConnectionHandler<>(this);
    setHandler(cHandler);
    getEndpoint().setHandler(cHandler);
}
 
Example #19
Source File: AbstractProcessor.java    From tomcatsrc with Apache License 2.0 5 votes vote down vote up
public AbstractProcessor(AbstractEndpoint<S> endpoint) {
    this.endpoint = endpoint;
    asyncStateMachine = new AsyncStateMachine<S>(this);

    // 创建出 request、response 对象
    request = new Request();
    response = new Response();
    response.setHook(this);
    request.setResponse(response);
}
 
Example #20
Source File: Http11AprProtocol.java    From Tomcat7.0.67 with Apache License 2.0 4 votes vote down vote up
@Override
protected AbstractEndpoint.Handler getHandler() {
    return cHandler;
}
 
Example #21
Source File: AjpProtocol.java    From tomcatsrc with Apache License 2.0 4 votes vote down vote up
@Override
protected AbstractEndpoint.Handler getHandler() {
    return cHandler;
}
 
Example #22
Source File: AjpAprProtocol.java    From tomcatsrc with Apache License 2.0 4 votes vote down vote up
@Override
protected AbstractEndpoint.Handler getHandler() {
    return cHandler;
}
 
Example #23
Source File: JSSEImplementation.java    From tomcatsrc with Apache License 2.0 4 votes vote down vote up
@Override
public SSLUtil getSSLUtil(AbstractEndpoint<?> endpoint) {
    return new JSSESocketFactory(endpoint);
}
 
Example #24
Source File: JSSEImplementation.java    From tomcatsrc with Apache License 2.0 4 votes vote down vote up
@Override
public ServerSocketFactory getServerSocketFactory(AbstractEndpoint<?> endpoint)  {
    return new JSSESocketFactory(endpoint);
}
 
Example #25
Source File: AbstractProcessor.java    From tomcatsrc with Apache License 2.0 4 votes vote down vote up
/**
 * The endpoint receiving connections that are handled by this processor.
 */
protected AbstractEndpoint<S> getEndpoint() {
    return endpoint;
}
 
Example #26
Source File: AbstractHttp11Processor.java    From tomcatsrc with Apache License 2.0 4 votes vote down vote up
public AbstractHttp11Processor(AbstractEndpoint<S> endpoint) {
    super(endpoint);
    userDataHelper = new UserDataHelper(getLog());
}
 
Example #27
Source File: Http11AprProtocol.java    From tomcatsrc with Apache License 2.0 4 votes vote down vote up
@Override
protected AbstractEndpoint.Handler getHandler() {
    return cHandler;
}
 
Example #28
Source File: InternalOutputBuffer.java    From tomcatsrc with Apache License 2.0 4 votes vote down vote up
@Override
public void init(SocketWrapper<Socket> socketWrapper,
        AbstractEndpoint<Socket> endpoint) throws IOException {

    outputStream = socketWrapper.getSocket().getOutputStream();
}
 
Example #29
Source File: InternalInputBuffer.java    From tomcatsrc with Apache License 2.0 4 votes vote down vote up
@Override
protected void init(SocketWrapper<Socket> socketWrapper,
        AbstractEndpoint<Socket> endpoint) throws IOException {
    inputStream = socketWrapper.getSocket().getInputStream();
}
 
Example #30
Source File: AbstractInputBuffer.java    From tomcatsrc with Apache License 2.0 4 votes vote down vote up
protected abstract void init(SocketWrapper<S> socketWrapper,
AbstractEndpoint<S> endpoint) throws IOException;