Class HttpDestination
java.lang.Object
org.eclipse.jetty.util.component.AbstractLifeCycle
org.eclipse.jetty.util.component.ContainerLifeCycle
org.eclipse.jetty.client.transport.HttpDestination
- All Implemented Interfaces:
Destination
,Callback
,Container
,Destroyable
,Dumpable
,Dumpable.DumpableContainer
,LifeCycle
,Invocable
,Sweeper.Sweepable
@ManagedObject
public class HttpDestination
extends ContainerLifeCycle
implements Destination, Callback, Dumpable, Sweeper.Sweepable
-
Nested Class Summary
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.Callback
Callback.Completable, Callback.Completing, Callback.Nested
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.thread.Invocable
Invocable.Callable, Invocable.InvocationType, Invocable.ReadyTask, Invocable.Task
Nested classes/interfaces inherited from interface org.eclipse.jetty.util.component.LifeCycle
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.thread.Invocable
__nonBlocking
-
Constructor Summary
ConstructorDescriptionHttpDestination
(HttpClient client, Origin origin) Creates a new HTTP destination.HttpDestination
(HttpClient client, Origin origin, boolean intrinsicallySecure) Deprecated, for removal: This API element is subject to removal in a future version. -
Method Summary
Modifier and TypeMethodDescriptionvoid
accept
(Connection connection) asString()
protected void
createConnection
(Promise<Connection> promise) protected void
doStart()
Starts the managed lifecycle beans in the order they were added.protected void
doStop()
Stops the managed lifecycle beans in the reverse order they were added.void
dump
(Appendable out, String indent) Dump this object (and children) into an Appendable using the provided indent after any new lines.protected boolean
enqueue
(Queue<HttpExchange> queue, HttpExchange exchange) void
Callback invoked when the operation fails.getHost()
long
getIdle()
int
getPort()
getProxy()
int
boolean
isSecure()
boolean
isStale()
void
newConnection
(Promise<Connection> promise) Creates asynchronously a new, unpooled,Connection
that will be returned at a later time through the givenPromise
.protected ConnectionPool
newConnectionPool
(HttpClient client) protected Queue<HttpExchange>
newExchangeQueue
(HttpClient client) void
release
(Connection connection) boolean
remove
(Connection connection) boolean
remove
(HttpExchange exchange) void
send()
void
send
(Request request, Response.CompleteListener listener) Sends the given request to this destination.void
send
(HttpExchange exchange) protected SendFailure
send
(IConnection connection, HttpExchange exchange) boolean
stale()
void
Callback invoked when the operation completes.boolean
sweep()
toString()
Methods inherited from class org.eclipse.jetty.util.component.ContainerLifeCycle
addBean, addBean, addEventListener, addManaged, contains, destroy, dump, dump, dumpObjects, dumpStdErr, getBean, getBeans, getBeans, getContainedBeans, getContainedBeans, installBean, installBean, 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.Callback
completeWith
Methods inherited from interface org.eclipse.jetty.util.component.Container
getCachedBeans, getEventListeners
Methods inherited from interface org.eclipse.jetty.client.Destination
newConnection
Methods inherited from interface org.eclipse.jetty.util.component.Dumpable.DumpableContainer
isDumpable
Methods inherited from interface org.eclipse.jetty.util.thread.Invocable
getInvocationType
-
Constructor Details
-
HttpDestination
@Deprecated(since="12.0.7", forRemoval=true) public HttpDestination(HttpClient client, Origin origin, boolean intrinsicallySecure) Deprecated, for removal: This API element is subject to removal in a future version.useHttpDestination(HttpClient, Origin)
instead- Parameters:
client
- theHttpClient
origin
- theOrigin
intrinsicallySecure
- whether the destination is intrinsically secure
-
HttpDestination
Creates a new HTTP destination.
- Parameters:
client
- theHttpClient
origin
- theOrigin
-
-
Method Details
-
accept
-
stale
public boolean stale() -
sweep
public boolean sweep()- Specified by:
sweep
in interfaceSweeper.Sweepable
- Returns:
- whether this resource should be swept
-
doStart
Description copied from class:ContainerLifeCycle
Starts the managed lifecycle beans in the order they were added.- Overrides:
doStart
in classContainerLifeCycle
- Throws:
AbstractLifeCycle.StopException
- If thrown, the lifecycle will immediately be stopped.Exception
- If there was a problem starting. Will cause a transition to FAILED state
-
doStop
Description copied from class:ContainerLifeCycle
Stops the managed lifecycle beans in the reverse order they were added.- Overrides:
doStop
in classContainerLifeCycle
- Throws:
Exception
- If there was a problem stopping. Will cause a transition to FAILED state
-
newConnectionPool
-
newExchangeQueue
-
isSecure
public boolean isSecure()- Specified by:
isSecure
in interfaceDestination
- Returns:
- whether the communication with the destination is secure
-
getHttpClient
- Specified by:
getHttpClient
in interfaceDestination
- Returns:
- the
HttpClient
that manages this destination
-
getOrigin
- Specified by:
getOrigin
in interfaceDestination
- Returns:
- the origin of this destination
-
getHttpExchanges
-
getProxy
- Specified by:
getProxy
in interfaceDestination
- Returns:
- the proxy associated with this destination,
or
null
if there is no proxy
-
getClientConnectionFactory
-
getScheme
-
getHost
-
getPort
-
getQueuedRequestCount
@ManagedAttribute(value="The number of queued requests", readonly=true) public int getQueuedRequestCount() -
getHostField
-
getConnectionPool
@ManagedAttribute(value="The connection pool", readonly=true) public ConnectionPool getConnectionPool()- Specified by:
getConnectionPool
in interfaceDestination
- Returns:
- the connection pool associated with this destination
-
succeeded
public void succeeded()Description copied from interface:Callback
Callback invoked when the operation completes.
-
failed
Description copied from interface:Callback
Callback invoked when the operation fails.
-
send
Description copied from interface:Destination
Sends the given request to this destination.
You can use this method to send the request to a specific destination that may be different from the request authority.
For example when
HttpClient
is used in a proxy, it may receive a request with authorityyourserver.com
but the proxy logic may want to forward the request to a specific backend server, saybackend01
, therefore:// Resolve the backend destination. Origin backendOrigin = new Origin(backendScheme, "backend01", backendPort); Destination backendDestination = httpClient.resolveDestination(backendOrigin); // Create a request with the original authority. Request request = httpClient.newRequest("https://yourserver.com/path"); // Send the request to the specific backend. backendDestination.send(request, result -> { ... });
- Specified by:
send
in interfaceDestination
- Parameters:
request
- the request to send to this destinationlistener
- the listener that receives response events
-
send
-
enqueue
-
send
public void send() -
send
-
newConnection
Description copied from interface:Destination
Creates asynchronously a new, unpooled,Connection
that will be returned at a later time through the givenPromise
.Use
FuturePromise
to wait for the connection:Destination destination = ...; FuturePromise<Connection> futureConnection = new FuturePromise<>(); destination.newConnection(futureConnection); Connection connection = futureConnection.get(5, TimeUnit.SECONDS);
- Specified by:
newConnection
in interfaceDestination
- Parameters:
promise
- the promise of a new, unpooled,Connection
-
createConnection
-
remove
-
release
-
remove
-
dump
Description copied from interface:Dumpable
Dump this object (and children) into an Appendable using the provided indent after any new lines. The indent should not be applied to the first object dumped.- Specified by:
dump
in interfaceDumpable
- Overrides:
dump
in classContainerLifeCycle
- Parameters:
out
- The appendable to dump toindent
- The indent to apply after any new lines.- Throws:
IOException
- if unable to write to Appendable
-
asString
-
getIdle
-
isStale
-
toString
- Overrides:
toString
in classAbstractLifeCycle
-
HttpDestination(HttpClient, Origin)
instead