org.eclipse.jetty.io.EndPoint Java Examples

The following examples show how to use org.eclipse.jetty.io.EndPoint. 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: TlsOrPlainConnectionFactoryTest.java    From qpid-broker-j with Apache License 2.0 6 votes vote down vote up
@Before
public void setUp() throws Exception
{

    _sslContextFactory = mock(SslContextFactory.class);
    SSLEngine sslEngine = mock(SSLEngine.class);
    when(_sslContextFactory.newSSLEngine(any())).thenReturn(sslEngine);
    final SSLSession sslSession = mock(SSLSession.class);
    when(sslEngine.getSession()).thenReturn(sslSession);
    when(sslSession.getPacketBufferSize()).thenReturn(Integer.MAX_VALUE);

    _factory = new TlsOrPlainConnectionFactory(_sslContextFactory, "test");

    _actualConnection = mock(AbstractConnection.class);

    _connector = mock(Connector.class);
    when(_connector.getExecutor()).thenReturn(mock(Executor.class));
    ConnectionFactory connectionFactory = mock(ConnectionFactory.class);
    when(_connector.getConnectionFactory(anyString())).thenReturn(connectionFactory);
    when(connectionFactory.newConnection(any(), any())).thenReturn(_actualConnection);

    _endPoint = mock(EndPoint.class);
}
 
Example #2
Source File: SelectorManager.java    From IoTgo_Android_App with MIT License 5 votes vote down vote up
public void addChange(SelectableChannel channel, Object att)
{
    if (att==null)
        addChange(channel);
    else if (att instanceof EndPoint)
        addChange(att);
    else
        addChange(new ChannelAndAttachment(channel,att));
}
 
Example #3
Source File: SelectorManager.java    From WebSocket-for-Android with Apache License 2.0 5 votes vote down vote up
public void addChange(SelectableChannel channel, Object att)
{
    if (att==null)
        addChange(channel);
    else if (att instanceof EndPoint)
        addChange(att);
    else
        addChange(new ChannelAndAttachment(channel,att));
}
 
Example #4
Source File: SslConnection.java    From WebSocket-for-Android with Apache License 2.0 5 votes vote down vote up
public SslConnection(SSLEngine engine,EndPoint endp, long timeStamp)
{
    super(endp,timeStamp);
    _engine=engine;
    _session=_engine.getSession();
    _aEndp=(AsyncEndPoint)endp;
    _sslEndPoint = newSslEndPoint();
}
 
Example #5
Source File: HttpParser.java    From WebSocket-for-Android with Apache License 2.0 5 votes vote down vote up
/**
 * Constructor.
 * @param buffers the buffers to use
 * @param endp the endpoint
 * @param handler the even handler
 */
public HttpParser(Buffers buffers, EndPoint endp, EventHandler handler)
{
    _buffers=buffers;
    _endp=endp;
    _handler=handler;
    _tok0=new View.CaseInsensitive();
    _tok1=new View.CaseInsensitive();
}
 
Example #6
Source File: WebSocketConnectionRFC6455.java    From WebSocket-for-Android with Apache License 2.0 5 votes vote down vote up
public WebSocketConnectionRFC6455(WebSocket websocket, EndPoint endpoint, WebSocketBuffers buffers, long timestamp, int maxIdleTime, String protocol, List<Extension> extensions,int draft, MaskGen maskgen)
    throws IOException
{
    super(endpoint,timestamp);

    _context=Thread.currentThread().getContextClassLoader();

    _endp.setMaxIdleTime(maxIdleTime);

    _webSocket = websocket;
    _onFrame=_webSocket instanceof OnFrame ? (OnFrame)_webSocket : null;
    _onTextMessage=_webSocket instanceof OnTextMessage ? (OnTextMessage)_webSocket : null;
    _onBinaryMessage=_webSocket instanceof OnBinaryMessage ? (OnBinaryMessage)_webSocket : null;
    _onControl=_webSocket instanceof OnControl ? (OnControl)_webSocket : null;
    _generator = new WebSocketGeneratorRFC6455(buffers, _endp,maskgen);

    _extensions=extensions;
    WebSocketParser.FrameHandler frameHandler = new WSFrameHandler();
    if (_extensions!=null)
    {
        int e=0;
        for (Extension extension : _extensions)
        {
            extension.bind(
                    _connection,
                    e==extensions.size()-1? frameHandler :extensions.get(e+1),
                    e==0?_generator:extensions.get(e-1));
            e++;
        }
    }

    _outbound=(_extensions==null||_extensions.size()==0)?_generator:extensions.get(extensions.size()-1);
    WebSocketParser.FrameHandler inbound = (_extensions == null || _extensions.size() == 0) ? frameHandler : extensions.get(0);

    _parser = new WebSocketParserRFC6455(buffers, endpoint, inbound,maskgen==null);

    _protocol=protocol;

}
 
Example #7
Source File: WebSocketParserRFC6455.java    From WebSocket-for-Android with Apache License 2.0 5 votes vote down vote up
/**
 * @param buffers The buffers to use for parsing.  Only the {@link Buffers#getBuffer()} is used.
 * This should be a direct buffer if binary data is mostly used or an indirect buffer if utf-8 data
 * is mostly used.
 * @param endp the endpoint
 * @param handler the handler to notify when a parse event occurs
 * @param shouldBeMasked whether masking should be handled
 */
public WebSocketParserRFC6455(WebSocketBuffers buffers, EndPoint endp, FrameHandler handler, boolean shouldBeMasked)
{
    _buffers=buffers;
    _endp=endp;
    _handler=handler;
    _shouldBeMasked=shouldBeMasked;
    _state=State.START;
}
 
Example #8
Source File: SelectorManager.java    From IoTgo_Android_App with MIT License 5 votes vote down vote up
public void addChange(SelectableChannel channel, Object att)
{
    if (att==null)
        addChange(channel);
    else if (att instanceof EndPoint)
        addChange(att);
    else
        addChange(new ChannelAndAttachment(channel,att));
}
 
Example #9
Source File: SslConnection.java    From IoTgo_Android_App with MIT License 5 votes vote down vote up
public SslConnection(SSLEngine engine,EndPoint endp, long timeStamp)
{
    super(endp,timeStamp);
    _engine=engine;
    _session=_engine.getSession();
    _aEndp=(AsyncEndPoint)endp;
    _sslEndPoint = newSslEndPoint();
}
 
Example #10
Source File: HttpParser.java    From IoTgo_Android_App with MIT License 5 votes vote down vote up
/**
 * Constructor.
 * @param buffers the buffers to use
 * @param endp the endpoint
 * @param handler the even handler
 */
public HttpParser(Buffers buffers, EndPoint endp, EventHandler handler)
{
    _buffers=buffers;
    _endp=endp;
    _handler=handler;
    _tok0=new View.CaseInsensitive();
    _tok1=new View.CaseInsensitive();
}
 
Example #11
Source File: WebSocketConnectionRFC6455.java    From IoTgo_Android_App with MIT License 5 votes vote down vote up
public WebSocketConnectionRFC6455(WebSocket websocket, EndPoint endpoint, WebSocketBuffers buffers, long timestamp, int maxIdleTime, String protocol, List<Extension> extensions,int draft, MaskGen maskgen)
    throws IOException
{
    super(endpoint,timestamp);

    _context=Thread.currentThread().getContextClassLoader();

    _endp.setMaxIdleTime(maxIdleTime);

    _webSocket = websocket;
    _onFrame=_webSocket instanceof OnFrame ? (OnFrame)_webSocket : null;
    _onTextMessage=_webSocket instanceof OnTextMessage ? (OnTextMessage)_webSocket : null;
    _onBinaryMessage=_webSocket instanceof OnBinaryMessage ? (OnBinaryMessage)_webSocket : null;
    _onControl=_webSocket instanceof OnControl ? (OnControl)_webSocket : null;
    _generator = new WebSocketGeneratorRFC6455(buffers, _endp,maskgen);

    _extensions=extensions;
    WebSocketParser.FrameHandler frameHandler = new WSFrameHandler();
    if (_extensions!=null)
    {
        int e=0;
        for (Extension extension : _extensions)
        {
            extension.bind(
                    _connection,
                    e==extensions.size()-1? frameHandler :extensions.get(e+1),
                    e==0?_generator:extensions.get(e-1));
            e++;
        }
    }

    _outbound=(_extensions==null||_extensions.size()==0)?_generator:extensions.get(extensions.size()-1);
    WebSocketParser.FrameHandler inbound = (_extensions == null || _extensions.size() == 0) ? frameHandler : extensions.get(0);

    _parser = new WebSocketParserRFC6455(buffers, endpoint, inbound,maskgen==null);

    _protocol=protocol;

}
 
Example #12
Source File: WebSocketParserRFC6455.java    From IoTgo_Android_App with MIT License 5 votes vote down vote up
/**
 * @param buffers The buffers to use for parsing.  Only the {@link Buffers#getBuffer()} is used.
 * This should be a direct buffer if binary data is mostly used or an indirect buffer if utf-8 data
 * is mostly used.
 * @param endp the endpoint
 * @param handler the handler to notify when a parse event occurs
 * @param shouldBeMasked whether masking should be handled
 */
public WebSocketParserRFC6455(WebSocketBuffers buffers, EndPoint endp, FrameHandler handler, boolean shouldBeMasked)
{
    _buffers=buffers;
    _endp=endp;
    _handler=handler;
    _shouldBeMasked=shouldBeMasked;
    _state=State.START;
}
 
Example #13
Source File: SslConnection.java    From IoTgo_Android_App with MIT License 5 votes vote down vote up
public SslConnection(SSLEngine engine,EndPoint endp, long timeStamp)
{
    super(endp,timeStamp);
    _engine=engine;
    _session=_engine.getSession();
    _aEndp=(AsyncEndPoint)endp;
    _sslEndPoint = newSslEndPoint();
}
 
Example #14
Source File: HttpParser.java    From IoTgo_Android_App with MIT License 5 votes vote down vote up
/**
 * Constructor.
 * @param buffers the buffers to use
 * @param endp the endpoint
 * @param handler the even handler
 */
public HttpParser(Buffers buffers, EndPoint endp, EventHandler handler)
{
    _buffers=buffers;
    _endp=endp;
    _handler=handler;
    _tok0=new View.CaseInsensitive();
    _tok1=new View.CaseInsensitive();
}
 
Example #15
Source File: WebSocketConnectionRFC6455.java    From IoTgo_Android_App with MIT License 5 votes vote down vote up
public WebSocketConnectionRFC6455(WebSocket websocket, EndPoint endpoint, WebSocketBuffers buffers, long timestamp, int maxIdleTime, String protocol, List<Extension> extensions,int draft, MaskGen maskgen)
    throws IOException
{
    super(endpoint,timestamp);

    _context=Thread.currentThread().getContextClassLoader();

    _endp.setMaxIdleTime(maxIdleTime);

    _webSocket = websocket;
    _onFrame=_webSocket instanceof OnFrame ? (OnFrame)_webSocket : null;
    _onTextMessage=_webSocket instanceof OnTextMessage ? (OnTextMessage)_webSocket : null;
    _onBinaryMessage=_webSocket instanceof OnBinaryMessage ? (OnBinaryMessage)_webSocket : null;
    _onControl=_webSocket instanceof OnControl ? (OnControl)_webSocket : null;
    _generator = new WebSocketGeneratorRFC6455(buffers, _endp,maskgen);

    _extensions=extensions;
    WebSocketParser.FrameHandler frameHandler = new WSFrameHandler();
    if (_extensions!=null)
    {
        int e=0;
        for (Extension extension : _extensions)
        {
            extension.bind(
                    _connection,
                    e==extensions.size()-1? frameHandler :extensions.get(e+1),
                    e==0?_generator:extensions.get(e-1));
            e++;
        }
    }

    _outbound=(_extensions==null||_extensions.size()==0)?_generator:extensions.get(extensions.size()-1);
    WebSocketParser.FrameHandler inbound = (_extensions == null || _extensions.size() == 0) ? frameHandler : extensions.get(0);

    _parser = new WebSocketParserRFC6455(buffers, endpoint, inbound,maskgen==null);

    _protocol=protocol;

}
 
Example #16
Source File: ServerConnectionFactory.java    From java-11-examples with Apache License 2.0 5 votes vote down vote up
@Override
public Connection newConnection(Connector connector, EndPoint endPoint) {
    LOG.info("newConnection: {}", endPoint.getLocalAddress().toString());
    ServerSessionListener listener = new CustomSessionListener(connector, endPoint, streamProcessors);

    Generator generator = new Generator(connector.getByteBufferPool(), getMaxDynamicTableSize(), getMaxHeaderBlockFragment());
    FlowControlStrategy flowControl = getFlowControlStrategyFactory().newFlowControlStrategy();
    HTTP2ServerSession session = new HTTP2ServerSession(connector.getScheduler(), endPoint, generator, listener, flowControl);
    session.setMaxLocalStreams(getMaxConcurrentStreams());
    session.setMaxRemoteStreams(getMaxConcurrentStreams());
    // For a single stream in a connection, there will be a race between
    // the stream idle timeout and the connection idle timeout. However,
    // the typical case is that the connection will be busier and the
    // stream idle timeout will expire earlier than the connection's.
    long streamIdleTimeout = getStreamIdleTimeout();
    if (streamIdleTimeout <= 0) {
        streamIdleTimeout = endPoint.getIdleTimeout();
    }
    session.setStreamIdleTimeout(streamIdleTimeout);
    session.setInitialSessionRecvWindow(getInitialSessionRecvWindow());

    ServerParser parser = newServerParser(connector, session, RateControl.NO_RATE_CONTROL);
    HTTP2Connection connection = new HTTP2ServerConnection(connector.getByteBufferPool(), executor,
            endPoint, getHttpConfiguration(), parser, session, getInputBufferSize(), listener);
    connection.addListener(connectionListener);
    return configure(connection, connector, endPoint);
}
 
Example #17
Source File: WebSocketParserRFC6455.java    From IoTgo_Android_App with MIT License 5 votes vote down vote up
/**
 * @param buffers The buffers to use for parsing.  Only the {@link Buffers#getBuffer()} is used.
 * This should be a direct buffer if binary data is mostly used or an indirect buffer if utf-8 data
 * is mostly used.
 * @param endp the endpoint
 * @param handler the handler to notify when a parse event occurs
 * @param shouldBeMasked whether masking should be handled
 */
public WebSocketParserRFC6455(WebSocketBuffers buffers, EndPoint endp, FrameHandler handler, boolean shouldBeMasked)
{
    _buffers=buffers;
    _endp=endp;
    _handler=handler;
    _shouldBeMasked=shouldBeMasked;
    _state=State.START;
}
 
Example #18
Source File: TlsOrPlainConnectionFactory.java    From qpid-broker-j with Apache License 2.0 5 votes vote down vote up
@Override
public PlainOrTlsConnection newConnection(final Connector connector, final EndPoint realEndPoint)
{
    final MarkableEndPoint endPoint = new MarkableEndPoint(realEndPoint);
    final PlainOrTlsConnection plainOrTlsConnection = new PlainOrTlsConnection(connector, endPoint);
    endPoint.setConnection(plainOrTlsConnection);

    return plainOrTlsConnection;

}
 
Example #19
Source File: SslConnection.java    From IoTgo_Android_App with MIT License 4 votes vote down vote up
public SslConnection(SSLEngine engine,EndPoint endp)
{
    this(engine,endp,System.currentTimeMillis());
}
 
Example #20
Source File: HttpConnectionCustomFactory.java    From sofa-registry with Apache License 2.0 4 votes vote down vote up
@Override
public Connection newConnection(Connector connector, EndPoint endPoint) {
    HttpConnectionCustom conn = new HttpConnectionCustom(getHttpConfiguration(), connector,
        endPoint, getHttpCompliance(), isRecordHttpComplianceViolations());
    return configure(conn, connector, endPoint);
}
 
Example #21
Source File: HttpConnectionCustom.java    From sofa-registry with Apache License 2.0 4 votes vote down vote up
public HttpConnectionCustom(HttpConfiguration config, Connector connector, EndPoint endPoint,
                            HttpCompliance compliance, boolean recordComplianceViolations) {
    super(config, connector, endPoint, compliance, recordComplianceViolations);
}
 
Example #22
Source File: SslConnection.java    From WebSocket-for-Android with Apache License 2.0 4 votes vote down vote up
public SslConnection(SSLEngine engine,EndPoint endp)
{
    this(engine,endp,System.currentTimeMillis());
}
 
Example #23
Source File: WebSocketGeneratorRFC6455.java    From WebSocket-for-Android with Apache License 2.0 4 votes vote down vote up
public WebSocketGeneratorRFC6455(WebSocketBuffers buffers, EndPoint endp, MaskGen maskGen)
{
    _buffers = buffers;
    _endp = endp;
    _maskGen = maskGen;
}
 
Example #24
Source File: WebSocketGeneratorRFC6455.java    From WebSocket-for-Android with Apache License 2.0 4 votes vote down vote up
public WebSocketGeneratorRFC6455(WebSocketBuffers buffers, EndPoint endp)
{
    this(buffers, endp, null);
}
 
Example #25
Source File: CustomSessionListener.java    From java-11-examples with Apache License 2.0 4 votes vote down vote up
public CustomSessionListener(Connector connector, EndPoint endPoint, Map<String, StreamProcessorRegistration> streamProcessors) {
    this.connector = connector;
    this.endPoint = endPoint;
    this.streamProcessors = streamProcessors;
}
 
Example #26
Source File: WebSocketClientFactory.java    From WebSocket-for-Android with Apache License 2.0 4 votes vote down vote up
public WebSocketClientConnection(WebSocketClientFactory factory, WebSocket webSocket, EndPoint endPoint, WebSocketBuffers buffers, long timeStamp, int maxIdleTime, String protocol, List<Extension> extensions, int draftVersion, MaskGen maskGen) throws IOException
{
    super(webSocket, endPoint, buffers, timeStamp, maxIdleTime, protocol, extensions, draftVersion, maskGen);
    this.factory = factory;
}
 
Example #27
Source File: HandleInterceptorTest.java    From skywalking with Apache License 2.0 4 votes vote down vote up
public MockService(Connector connector, HttpConfiguration configuration, EndPoint endPoint,
    HttpTransport transport, HttpInput input) {
    super(connector, configuration, endPoint, transport, input);
}
 
Example #28
Source File: ArmeriaConnector.java    From armeria with Apache License 2.0 4 votes vote down vote up
@Override
public Connection newConnection(Connector connector, EndPoint endPoint) {
    throw new UnsupportedOperationException();
}
 
Example #29
Source File: TlsOrPlainConnectionFactory.java    From qpid-broker-j with Apache License 2.0 4 votes vote down vote up
@Override
public EndPoint getEndPoint()
{
    return _endPoint;
}
 
Example #30
Source File: TlsOrPlainConnectionFactory.java    From qpid-broker-j with Apache License 2.0 4 votes vote down vote up
private SslConnection newSslConnection(final Connector connector, final EndPoint endPoint, final SSLEngine engine)
{
    return new SslConnection(connector.getByteBufferPool(), connector.getExecutor(), endPoint, engine);
}