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 AbstractLifeCycle
AbstractLifeCycle.AbstractLifeCycleListener, AbstractLifeCycle.StopExceptionNested classes/interfaces inherited from interface Callback
Callback.Completable, Callback.Completing, Callback.NestedNested classes/interfaces inherited from interface Container
Container.InheritedListener, Container.ListenerNested classes/interfaces inherited from interface Dumpable
Dumpable.DumpableContainerNested classes/interfaces inherited from interface Invocable
Invocable.Callable, Invocable.InvocationType, Invocable.ReadyTask, Invocable.TaskNested classes/interfaces inherited from interface LifeCycle
LifeCycle.Listener -
Field Summary
Fields inherited from interface Invocable
__nonBlocking -
Constructor Summary
ConstructorsConstructorDescriptionHttpDestination(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 TypeMethodDescriptionvoidaccept(Connection connection) asString()protected voidcreateConnection(Promise<Connection> promise) protected voiddoStart()Starts the managed lifecycle beans in the order they were added.protected voiddoStop()Stops the managed lifecycle beans in the reverse order they were added.voiddump(Appendable out, String indent) Dump this object (and children) into an Appendable using the provided indent after any new lines.protected booleanenqueue(Queue<HttpExchange> queue, HttpExchange exchange) voidCallback invoked when the operation fails.getHost()longgetIdle()intgetPort()getProxy()intbooleanisSecure()booleanisStale()voidnewConnection(Promise<Connection> promise) Creates asynchronously a new, unpooled,Connectionthat will be returned at a later time through the givenPromise.protected ConnectionPoolnewConnectionPool(HttpClient client) protected Queue<HttpExchange> newExchangeQueue(HttpClient client) voidrelease(Connection connection) booleanremove(Connection connection) booleanremove(HttpExchange exchange) voidsend()voidsend(Request request, Response.CompleteListener listener) Sends the given request to this destination.voidsend(HttpExchange exchange) protected SendFailuresend(IConnection connection, HttpExchange exchange) booleanstale()voidCallback invoked when the operation completes.booleansweep()toString()Methods inherited from class 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, updateBeansMethods inherited from class AbstractLifeCycle
getEventListeners, getState, getState, isFailed, isRunning, isStarted, isStarting, isStopped, isStopping, setEventListeners, start, stopMethods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface Callback
completeWithMethods inherited from interface Container
getCachedBeans, getEventListenersMethods inherited from interface Destination
newConnectionMethods inherited from interface Dumpable.DumpableContainer
isDumpableMethods inherited from interface 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- theHttpClientorigin- theOriginintrinsicallySecure- whether the destination is intrinsically secure
-
HttpDestination
Creates a new HTTP destination.
- Parameters:
client- theHttpClientorigin- theOrigin
-
-
Method Details
-
accept
-
stale
public boolean stale() -
sweep
public boolean sweep()- Specified by:
sweepin interfaceSweeper.Sweepable- Returns:
- whether this resource should be swept
-
doStart
Description copied from class:ContainerLifeCycleStarts the managed lifecycle beans in the order they were added.- Overrides:
doStartin classContainerLifeCycle- Throws:
Exception- If there was a problem starting. Will cause a transition to FAILED state
-
doStop
Description copied from class:ContainerLifeCycleStops the managed lifecycle beans in the reverse order they were added.- Overrides:
doStopin classContainerLifeCycle- Throws:
Exception- If there was a problem stopping. Will cause a transition to FAILED state
-
newConnectionPool
-
newExchangeQueue
-
isSecure
public boolean isSecure()- Specified by:
isSecurein interfaceDestination- Returns:
- whether the communication with the destination is secure
-
getHttpClient
- Specified by:
getHttpClientin interfaceDestination- Returns:
- the
HttpClientthat manages this destination
-
getOrigin
- Specified by:
getOriginin interfaceDestination- Returns:
- the origin of this destination
-
getHttpExchanges
-
getProxy
- Specified by:
getProxyin interfaceDestination- Returns:
- the proxy associated with this destination,
or
nullif 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:
getConnectionPoolin interfaceDestination- Returns:
- the connection pool associated with this destination
-
succeeded
-
failed
-
send
Description copied from interface:DestinationSends 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
HttpClientis used in a proxy, it may receive a request with authorityyourserver.combut 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:
sendin 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:DestinationCreates asynchronously a new, unpooled,Connectionthat will be returned at a later time through the givenPromise.Use
FuturePromiseto wait for the connection:Destination destination = ...; FuturePromise<Connection> futureConnection = new FuturePromise<>(); destination.newConnection(futureConnection); Connection connection = futureConnection.get(5, TimeUnit.SECONDS);- Specified by:
newConnectionin interfaceDestination- Parameters:
promise- the promise of a new, unpooled,Connection
-
createConnection
-
remove
-
release
-
remove
-
dump
Description copied from interface:DumpableDump 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:
dumpin interfaceDumpable- Overrides:
dumpin 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:
toStringin classAbstractLifeCycle
-
HttpDestination(HttpClient, Origin)instead