Package org.eclipse.jetty.server
Class LocalConnector
- java.lang.Object
-
- org.eclipse.jetty.util.component.AbstractLifeCycle
-
- org.eclipse.jetty.util.component.ContainerLifeCycle
-
- org.eclipse.jetty.server.AbstractConnector
-
- org.eclipse.jetty.server.LocalConnector
-
- All Implemented Interfaces:
Connector
,Container
,Destroyable
,Dumpable
,Dumpable.DumpableContainer
,Graceful
,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
AbstractLifeCycle.AbstractLifeCycleListener, AbstractLifeCycle.StopException
-
Nested classes/interfaces inherited from interface org.eclipse.jetty.util.component.Container
Container.InheritedListener, Container.Listener
-
Nested classes/interfaces inherited from interface org.eclipse.jetty.util.component.Dumpable
Dumpable.DumpableContainer
-
Nested classes/interfaces inherited from interface org.eclipse.jetty.util.component.Graceful
Graceful.Shutdown, Graceful.ThrowingRunnable
-
Nested classes/interfaces inherited from interface org.eclipse.jetty.util.component.LifeCycle
LifeCycle.Listener
-
-
Field Summary
-
Fields inherited from class org.eclipse.jetty.server.AbstractConnector
LOG
-
-
Constructor Summary
Constructors Constructor Description LocalConnector(Server server)
LocalConnector(Server server, java.util.concurrent.Executor executor, Scheduler scheduler, ByteBufferPool pool, int acceptors, ConnectionFactory... factories)
LocalConnector(Server server, ConnectionFactory connectionFactory)
LocalConnector(Server server, ConnectionFactory connectionFactory, SslContextFactory.Server sslContextFactory)
LocalConnector(Server server, SslContextFactory.Server sslContextFactory)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected void
accept(int acceptorID)
LocalConnector.LocalEndPoint
connect()
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.java.lang.String
getResponse(java.lang.String rawRequest)
Get a single response using a parser to search for the end of the message.java.lang.String
getResponse(java.lang.String rawRequest, boolean head, long time, java.util.concurrent.TimeUnit unit)
Get a single response using a parser to search for the end of the message.java.lang.String
getResponse(java.lang.String rawRequest, long time, java.util.concurrent.TimeUnit unit)
Get a single response using a parser to search for the end of the message.java.nio.ByteBuffer
getResponse(java.nio.ByteBuffer requestsBuffer)
Get a single response using a parser to search for the end of the message.java.nio.ByteBuffer
getResponse(java.nio.ByteBuffer requestBuffer, boolean head, long time, java.util.concurrent.TimeUnit unit)
Get a single response using a parser to search for the end of the message.java.nio.ByteBuffer
getResponse(java.nio.ByteBuffer requestBuffer, long time, java.util.concurrent.TimeUnit unit)
Get a single response using a parser to search for the end of the message.java.lang.Object
getTransport()
-
Methods inherited from class org.eclipse.jetty.server.AbstractConnector
addConnectionFactory, addFirstConnectionFactory, addIfAbsentConnectionFactory, clearConnectionFactories, doStart, doStop, getAcceptorPriorityDelta, getAcceptors, getByteBufferPool, getConnectedEndPoints, getConnectionFactories, getConnectionFactory, getConnectionFactory, getDefaultConnectionFactory, getDefaultProtocol, getExecutor, getHttpChannelListeners, getIdleTimeout, getName, getProtocols, getScheduler, getServer, getShutdownIdleTimeout, handleAcceptFailure, interruptAcceptors, isAccepting, isShutdown, join, join, onEndPointClosed, onEndPointOpened, removeConnectionFactory, setAccepting, setAcceptorPriorityDelta, setConnectionFactories, setDefaultProtocol, setIdleTimeout, setName, setShutdownIdleTimeout, shutdown, toString
-
Methods inherited from class org.eclipse.jetty.util.component.ContainerLifeCycle
addBean, addBean, addEventListener, addManaged, contains, destroy, dump, dump, dump, dumpObjects, dumpStdErr, getBean, getBeans, getBeans, getContainedBeans, getContainedBeans, isAuto, isManaged, isUnmanaged, manage, removeBean, removeBeans, removeEventListener, setBeans, start, stop, unmanage, updateBean, updateBean, updateBeans, updateBeans
-
Methods inherited from class org.eclipse.jetty.util.component.AbstractLifeCycle
getEventListeners, getState, getState, isFailed, isRunning, isStarted, isStarting, isStopped, isStopping, setEventListeners, start, stop
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface org.eclipse.jetty.util.component.Container
addBean, addBean, addEventListener, getBean, getBeans, getBeans, getCachedBeans, getContainedBeans, getEventListeners, isManaged, manage, removeBean, removeEventListener, unmanage
-
Methods inherited from interface org.eclipse.jetty.util.component.Dumpable.DumpableContainer
isDumpable
-
Methods inherited from interface org.eclipse.jetty.util.component.LifeCycle
addEventListener, isFailed, isRunning, isStarted, isStarting, isStopped, isStopping, removeEventListener, start, stop
-
-
-
-
Constructor Detail
-
LocalConnector
public LocalConnector(Server server, java.util.concurrent.Executor executor, Scheduler scheduler, ByteBufferPool pool, int acceptors, ConnectionFactory... factories)
-
LocalConnector
public LocalConnector(Server server)
-
LocalConnector
public LocalConnector(Server server, SslContextFactory.Server sslContextFactory)
-
LocalConnector
public LocalConnector(Server server, ConnectionFactory connectionFactory)
-
LocalConnector
public LocalConnector(Server server, ConnectionFactory connectionFactory, 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
-
connect
public LocalConnector.LocalEndPoint connect()
-
accept
protected void accept(int acceptorID) throws java.lang.InterruptedException
- Specified by:
accept
in classAbstractConnector
- 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 sendtime
- The time to waitunit
- 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 sendhead
- True if the response is for a head requesttime
- The time to waitunit
- 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 sendtime
- The time to waitunit
- 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 sendhead
- True if the response is for a head requesttime
- The time to waitunit
- The units of the wait- Returns:
- ByteBuffer containing response or null.
- Throws:
java.lang.Exception
- If there is a problem
-
-