Class LocalConnector

  • All Implemented Interfaces:
    Connector, org.eclipse.jetty.util.component.Container, org.eclipse.jetty.util.component.Destroyable, org.eclipse.jetty.util.component.Dumpable, org.eclipse.jetty.util.component.Dumpable.DumpableContainer, org.eclipse.jetty.util.component.Graceful, org.eclipse.jetty.util.component.LifeCycle

    public class LocalConnector
    extends AbstractConnector
    A local connector, mostly for testing purposes.
      HttpTester.Request request = HttpTester.newRequest();
      request.setURI("/some/resource");
      HttpTester.Response response =
          HttpTester.parseResponse(HttpTester.from(localConnector.getResponse(request.generate())));
     
    • Nested Class Summary

      Nested Classes 
      Modifier and Type Class Description
      class  LocalConnector.LocalEndPoint
      Local EndPoint
      • Nested classes/interfaces inherited from class org.eclipse.jetty.util.component.AbstractLifeCycle

        org.eclipse.jetty.util.component.AbstractLifeCycle.AbstractLifeCycleListener, org.eclipse.jetty.util.component.AbstractLifeCycle.StopException
      • Nested classes/interfaces inherited from interface org.eclipse.jetty.util.component.Container

        org.eclipse.jetty.util.component.Container.InheritedListener, org.eclipse.jetty.util.component.Container.Listener
      • Nested classes/interfaces inherited from interface org.eclipse.jetty.util.component.Dumpable

        org.eclipse.jetty.util.component.Dumpable.DumpableContainer
      • Nested classes/interfaces inherited from interface org.eclipse.jetty.util.component.Graceful

        org.eclipse.jetty.util.component.Graceful.Shutdown, org.eclipse.jetty.util.component.Graceful.ThrowingRunnable
      • Nested classes/interfaces inherited from interface org.eclipse.jetty.util.component.LifeCycle

        org.eclipse.jetty.util.component.LifeCycle.Listener
    • Field Summary

      • Fields inherited from class org.eclipse.jetty.util.component.AbstractLifeCycle

        FAILED, STARTED, STARTING, STOPPED, STOPPING
      • Fields inherited from interface org.eclipse.jetty.util.component.Dumpable

        KEY
    • Constructor Detail

      • LocalConnector

        public LocalConnector​(Server server,
                              java.util.concurrent.Executor executor,
                              org.eclipse.jetty.util.thread.Scheduler scheduler,
                              org.eclipse.jetty.io.ByteBufferPool pool,
                              int acceptors,
                              ConnectionFactory... factories)
      • LocalConnector

        public LocalConnector​(Server server)
      • LocalConnector

        public LocalConnector​(Server server,
                              org.eclipse.jetty.util.ssl.SslContextFactory.Server sslContextFactory)
      • LocalConnector

        public LocalConnector​(Server server,
                              ConnectionFactory connectionFactory,
                              org.eclipse.jetty.util.ssl.SslContextFactory.Server sslContextFactory)
    • Method Detail

      • getTransport

        public java.lang.Object getTransport()
        Returns:
        the underlying socket, channel, buffer etc. for the connector.
      • executeRequest

        public LocalConnector.LocalEndPoint executeRequest​(java.lang.String rawRequest)
        Execute a request and return the EndPoint through which multiple responses can be received or more input provided.
        Parameters:
        rawRequest - the request
        Returns:
        the local endpoint
      • accept

        protected void accept​(int acceptorID)
                       throws java.lang.InterruptedException
        Specified by:
        accept in class AbstractConnector
        Throws:
        java.lang.InterruptedException
      • getResponse

        public java.nio.ByteBuffer getResponse​(java.nio.ByteBuffer requestsBuffer)
                                        throws java.lang.Exception
        Get a single response using a parser to search for the end of the message.
        Parameters:
        requestsBuffer - The request to send
        Returns:
        ByteBuffer containing response or null.
        Throws:
        java.lang.Exception - If there is a problem
      • getResponse

        public java.nio.ByteBuffer getResponse​(java.nio.ByteBuffer requestBuffer,
                                               long time,
                                               java.util.concurrent.TimeUnit unit)
                                        throws java.lang.Exception
        Get a single response using a parser to search for the end of the message.
        Parameters:
        requestBuffer - The request to send
        time - The time to wait
        unit - The units of the wait
        Returns:
        ByteBuffer containing response or null.
        Throws:
        java.lang.Exception - If there is a problem
      • getResponse

        public java.nio.ByteBuffer getResponse​(java.nio.ByteBuffer requestBuffer,
                                               boolean head,
                                               long time,
                                               java.util.concurrent.TimeUnit unit)
                                        throws java.lang.Exception
        Get a single response using a parser to search for the end of the message.
        Parameters:
        requestBuffer - The request to send
        head - True if the response is for a head request
        time - The time to wait
        unit - The units of the wait
        Returns:
        ByteBuffer containing response or null.
        Throws:
        java.lang.Exception - If there is a problem
      • getResponse

        public java.lang.String getResponse​(java.lang.String rawRequest)
                                     throws java.lang.Exception
        Get a single response using a parser to search for the end of the message.
        Parameters:
        rawRequest - The request to send
        Returns:
        ByteBuffer containing response or null.
        Throws:
        java.lang.Exception - If there is a problem
      • getResponse

        public java.lang.String getResponse​(java.lang.String rawRequest,
                                            long time,
                                            java.util.concurrent.TimeUnit unit)
                                     throws java.lang.Exception
        Get a single response using a parser to search for the end of the message.
        Parameters:
        rawRequest - The request to send
        time - The time to wait
        unit - The units of the wait
        Returns:
        ByteBuffer containing response or null.
        Throws:
        java.lang.Exception - If there is a problem
      • getResponse

        public java.lang.String getResponse​(java.lang.String rawRequest,
                                            boolean head,
                                            long time,
                                            java.util.concurrent.TimeUnit unit)
                                     throws java.lang.Exception
        Get a single response using a parser to search for the end of the message.
        Parameters:
        rawRequest - The request to send
        head - True if the response is for a head request
        time - The time to wait
        unit - The units of the wait
        Returns:
        ByteBuffer containing response or null.
        Throws:
        java.lang.Exception - If there is a problem