org.eclipse.jetty.client
类 HttpClient

java.lang.Object
  继承者 org.eclipse.jetty.util.component.AbstractLifeCycle
      继承者 org.eclipse.jetty.util.component.AggregateLifeCycle
          继承者 org.eclipse.jetty.client.HttpClient
所有已实现的接口:
HttpBuffers, Attributes, Destroyable, Dumpable, LifeCycle

public class HttpClient
extends AggregateLifeCycle
implements HttpBuffers, Attributes, Dumpable

Http Client.

HttpClient is the main active component of the client API implementation. It is the opposite of the Connectors in standard Jetty, in that it listens for responses rather than requests. Just like the connectors, there is a blocking socket version and a non-blocking NIO version (implemented as nested classes selected by setConnectorType(int)).

The an instance of HttpExchange is passed to the send(HttpExchange) method to send a request. The exchange contains both the headers and content (source) of the request plus the callbacks to handle responses. A HttpClient can have many exchanges outstanding and they may be queued on the HttpDestination waiting for a AbstractHttpConnection, queued in the AbstractHttpConnection waiting to be transmitted or pipelined on the actual TCP/IP connection waiting for a response.

The HttpDestination class is an aggregation of AbstractHttpConnections for the same host, port and protocol. A destination may limit the number of connections open and they provide a pool of open connections that may be reused. Connections may also be allocated from a destination, so that multiple request sources are not multiplexed over the same connection.

另请参见:
HttpExchange, HttpDestination

嵌套类摘要
 
从类 org.eclipse.jetty.util.component.AbstractLifeCycle 继承的嵌套类/接口
AbstractLifeCycle.AbstractLifeCycleListener
 
从接口 org.eclipse.jetty.util.component.LifeCycle 继承的嵌套类/接口
LifeCycle.Listener
 
字段摘要
static int CONNECTOR_SELECT_CHANNEL
           
static int CONNECTOR_SOCKET
           
 
从类 org.eclipse.jetty.util.component.AbstractLifeCycle 继承的字段
_listeners, FAILED, RUNNING, STARTED, STARTING, STOPPED, STOPPING
 
构造方法摘要
HttpClient()
           
HttpClient(SslContextFactory sslContextFactory)
           
 
方法摘要
 void cancel(Timeout.Task task)
           
 void clearAttributes()
           
protected  void doStart()
          Start the managed lifecycle beans in the order they were added.
protected  void doStop()
          Stop the joined lifecycle beans in the reverse order they were added.
 Object getAttribute(String name)
           
 Enumeration getAttributeNames()
           
 int getConnectorType()
          Get the type of connector (socket, blocking or select) in use.
 int getConnectTimeout()
           
 HttpDestination getDestination(Address remote, boolean ssl)
           
 long getIdleTimeout()
           
 String getKeyManagerAlgorithm()
          已过时。 
 InputStream getKeyStoreInputStream()
          已过时。 
 String getKeyStoreLocation()
          已过时。 
 String getKeyStoreType()
          已过时。 
 int getMaxBuffers()
           
 int getMaxConnectionsPerAddress()
           
 int getMaxQueueSizePerAddress()
           
 Set<String> getNoProxy()
           
 String getProtocol()
          已过时。 
 String getProvider()
          已过时。 
 Address getProxy()
           
 Authentication getProxyAuthentication()
           
 RealmResolver getRealmResolver()
          returns the SecurityRealmResolver reg_realmResolveristered with the HttpClient or null
 LinkedList<String> getRegisteredListeners()
           
 Buffers getRequestBuffers()
           
 int getRequestBufferSize()
           
 Buffers.Type getRequestBufferType()
           
 int getRequestHeaderSize()
           
 Buffers.Type getRequestHeaderType()
           
 Buffers getResponseBuffers()
           
 int getResponseBufferSize()
           
 Buffers.Type getResponseBufferType()
           
 int getResponseHeaderSize()
           
 Buffers.Type getResponseHeaderType()
           
 String getSecureRandomAlgorithm()
          已过时。 
 int getSoTimeout()
          已过时。 use getTimeout() instead.
protected  SSLContext getSSLContext()
          if a keystore location has been provided then client will attempt to use it as the keystore, otherwise we simply ignore certificates and run with a loose ssl context.
 SslContextFactory getSslContextFactory()
           
 ThreadPool getThreadPool()
           
 long getTimeout()
           
 String getTrustManagerAlgorithm()
          已过时。 
 InputStream getTrustStoreInputStream()
          已过时。 
 String getTrustStoreLocation()
          已过时。 
 String getTrustStoreType()
          已过时。 
 boolean getUseDirectBuffers()
          Get whether the connector can use direct NIO buffers.
 boolean hasRealms()
           
 boolean isConnectBlocking()
           
 boolean isProxied()
           
 int maxRedirects()
           
 int maxRetries()
           
 void registerListener(String listenerClass)
          Registers a listener that can listen to the stream of execution between the client and the server and influence events.
 void removeAttribute(String name)
           
 void schedule(Timeout.Task task)
           
 void schedule(Timeout.Task task, long timeout)
           
 void scheduleIdle(Timeout.Task task)
           
 void send(HttpExchange exchange)
           
 void setAttribute(String name, Object attribute)
          Set an attribute on the HttpClient.
 void setConnectBlocking(boolean connectBlocking)
           
 void setConnectorType(int connectorType)
           
 void setConnectTimeout(int connectTimeout)
           
 void setIdleTimeout(long ms)
           
 void setKeyManagerAlgorithm(String keyManagerAlgorithm)
          已过时。 
 void setKeyManagerPassword(String keyManagerPassword)
          已过时。 
 void setKeyStoreInputStream(InputStream keyStoreInputStream)
          已过时。 
 void setKeyStoreLocation(String keyStoreLocation)
          已过时。 
 void setKeyStorePassword(String keyStorePassword)
          已过时。 
 void setKeyStoreType(String keyStoreType)
          已过时。 
 void setMaxBuffers(int maxBuffers)
           
 void setMaxConnectionsPerAddress(int maxConnectionsPerAddress)
           
 void setMaxQueueSizePerAddress(int maxQueueSizePerAddress)
           
 void setMaxRedirects(int redirects)
           
 void setMaxRetries(int retries)
           
 void setNoProxy(Set<String> noProxyAddresses)
           
 void setProtocol(String protocol)
          已过时。 
 void setProvider(String provider)
          已过时。 
 void setProxy(Address proxy)
           
 void setProxyAuthentication(Authentication authentication)
           
 void setRealmResolver(RealmResolver resolver)
          Set a RealmResolver for client Authentication.
 void setRequestBuffers(Buffers requestBuffers)
           
 void setRequestBufferSize(int requestBufferSize)
           
 void setRequestHeaderSize(int requestHeaderSize)
           
 void setResponseBuffers(Buffers responseBuffers)
           
 void setResponseBufferSize(int responseBufferSize)
           
 void setResponseHeaderSize(int responseHeaderSize)
           
 void setSecureRandomAlgorithm(String secureRandomAlgorithm)
          已过时。 
 void setSoTimeout(int timeout)
          已过时。 use setTimeout(long) instead.
 void setThreadPool(ThreadPool threadPool)
          Set the ThreadPool.
 void setTimeout(long timeout)
           
 void setTrustManagerAlgorithm(String trustManagerAlgorithm)
          已过时。 
 void setTrustStoreInputStream(InputStream trustStoreInputStream)
          已过时。 
 void setTrustStoreLocation(String trustStoreLocation)
          已过时。 
 void setTrustStorePassword(String trustStorePassword)
          已过时。 
 void setTrustStoreType(String trustStoreType)
          已过时。 
 void setUseDirectBuffers(boolean direct)
          Set to use NIO direct buffers.
 
从类 org.eclipse.jetty.util.component.AggregateLifeCycle 继承的方法
addBean, addBean, contains, destroy, dump, dump, dump, dump, dump, dumpObject, dumpStdErr, dumpThis, getBean, getBeans, getBeans, isManaged, manage, removeBean, removeBeans, unmanage
 
从类 org.eclipse.jetty.util.component.AbstractLifeCycle 继承的方法
addLifeCycleListener, getState, getState, isFailed, isRunning, isStarted, isStarting, isStopped, isStopping, removeLifeCycleListener, start, stop
 
从类 java.lang.Object 继承的方法
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
从接口 org.eclipse.jetty.util.component.Dumpable 继承的方法
dump, dump
 

字段详细信息

CONNECTOR_SOCKET

public static final int CONNECTOR_SOCKET
另请参见:
常量字段值

CONNECTOR_SELECT_CHANNEL

public static final int CONNECTOR_SELECT_CHANNEL
另请参见:
常量字段值
构造方法详细信息

HttpClient

public HttpClient()

HttpClient

public HttpClient(SslContextFactory sslContextFactory)
方法详细信息

isConnectBlocking

public boolean isConnectBlocking()
返回:
True if connects will be in blocking mode.

setConnectBlocking

public void setConnectBlocking(boolean connectBlocking)
参数:
connectBlocking - True if connects will be in blocking mode.

send

public void send(HttpExchange exchange)
          throws IOException
抛出:
IOException

getThreadPool

public ThreadPool getThreadPool()
返回:
the threadpool

setThreadPool

public void setThreadPool(ThreadPool threadPool)
Set the ThreadPool. The threadpool passed is added via AggregateLifeCycle.addBean(Object) so that it's lifecycle may be managed as a AggregateLifeCycle.

参数:
threadPool - the threadPool to set

getAttribute

public Object getAttribute(String name)
指定者:
接口 Attributes 中的 getAttribute
参数:
name -
返回:
Attribute associated with client

getAttributeNames

public Enumeration getAttributeNames()
指定者:
接口 Attributes 中的 getAttributeNames
返回:
names of attributes associated with client

removeAttribute

public void removeAttribute(String name)
指定者:
接口 Attributes 中的 removeAttribute
参数:
name -

setAttribute

public void setAttribute(String name,
                         Object attribute)
Set an attribute on the HttpClient. Attributes are not used by the client, but are provided for so that users of a shared HttpClient may share other structures.

指定者:
接口 Attributes 中的 setAttribute
参数:
name -
attribute -

clearAttributes

public void clearAttributes()
指定者:
接口 Attributes 中的 clearAttributes

getDestination

public HttpDestination getDestination(Address remote,
                                      boolean ssl)
                               throws IOException
抛出:
IOException

schedule

public void schedule(Timeout.Task task)

schedule

public void schedule(Timeout.Task task,
                     long timeout)

scheduleIdle

public void scheduleIdle(Timeout.Task task)

cancel

public void cancel(Timeout.Task task)

getUseDirectBuffers

public boolean getUseDirectBuffers()
Get whether the connector can use direct NIO buffers.


setRealmResolver

public void setRealmResolver(RealmResolver resolver)
Set a RealmResolver for client Authentication. If a realmResolver is set, then the HttpDestinations created by this client will instantiate a SecurityListener so that BASIC and DIGEST authentication can be performed.

参数:
resolver -

getRealmResolver

public RealmResolver getRealmResolver()
returns the SecurityRealmResolver reg_realmResolveristered with the HttpClient or null

返回:
the SecurityRealmResolver reg_realmResolveristered with the HttpClient or null

hasRealms

public boolean hasRealms()

registerListener

public void registerListener(String listenerClass)
Registers a listener that can listen to the stream of execution between the client and the server and influence events. Sequential calls to the method wrapper sequentially wrap the preceding listener in a delegation model.

NOTE: the SecurityListener is a special listener which doesn't need to be added via this mechanic, if you register security realms then it will automatically be added as the top listener of the delegation stack.

参数:
listenerClass -

getRegisteredListeners

public LinkedList<String> getRegisteredListeners()

setUseDirectBuffers

public void setUseDirectBuffers(boolean direct)
Set to use NIO direct buffers.

参数:
direct - If True (the default), the connector can use NIO direct buffers. Some JVMs have memory management issues (bugs) with direct buffers.

getConnectorType

public int getConnectorType()
Get the type of connector (socket, blocking or select) in use.


setConnectorType

public void setConnectorType(int connectorType)

getMaxConnectionsPerAddress

public int getMaxConnectionsPerAddress()

setMaxConnectionsPerAddress

public void setMaxConnectionsPerAddress(int maxConnectionsPerAddress)

getMaxQueueSizePerAddress

public int getMaxQueueSizePerAddress()

setMaxQueueSizePerAddress

public void setMaxQueueSizePerAddress(int maxQueueSizePerAddress)

doStart

protected void doStart()
                throws Exception
从类 AggregateLifeCycle 复制的描述
Start the managed lifecycle beans in the order they were added.

覆盖:
AggregateLifeCycle 中的 doStart
抛出:
Exception
另请参见:
AbstractLifeCycle.doStart()

doStop

protected void doStop()
               throws Exception
从类 AggregateLifeCycle 复制的描述
Stop the joined lifecycle beans in the reverse order they were added.

覆盖:
AggregateLifeCycle 中的 doStop
抛出:
Exception
另请参见:
AbstractLifeCycle.doStart()

getSSLContext

protected SSLContext getSSLContext()
if a keystore location has been provided then client will attempt to use it as the keystore, otherwise we simply ignore certificates and run with a loose ssl context.

返回:
the SSL context

getSslContextFactory

public SslContextFactory getSslContextFactory()
返回:
the instance of SslContextFactory associated with the client

getIdleTimeout

public long getIdleTimeout()
返回:
the period in milliseconds a AbstractHttpConnection can be idle for before it is closed.

setIdleTimeout

public void setIdleTimeout(long ms)
参数:
ms - the period in milliseconds a AbstractHttpConnection can be idle for before it is closed.

getSoTimeout

@Deprecated
public int getSoTimeout()
已过时。 use getTimeout() instead.

返回:
the period in ms that an exchange will wait for a response from the server.

setSoTimeout

@Deprecated
public void setSoTimeout(int timeout)
已过时。 use setTimeout(long) instead.

参数:
timeout - the period in ms that an exchange will wait for a response from the server.

getTimeout

public long getTimeout()
返回:
the period in ms that an exchange will wait for a response from the server.

setTimeout

public void setTimeout(long timeout)
参数:
timeout - the period in ms that an exchange will wait for a response from the server.

getConnectTimeout

public int getConnectTimeout()
返回:
the period in ms before timing out an attempt to connect

setConnectTimeout

public void setConnectTimeout(int connectTimeout)
参数:
connectTimeout - the period in ms before timing out an attempt to connect

getProxy

public Address getProxy()

setProxy

public void setProxy(Address proxy)

getProxyAuthentication

public Authentication getProxyAuthentication()

setProxyAuthentication

public void setProxyAuthentication(Authentication authentication)

isProxied

public boolean isProxied()

getNoProxy

public Set<String> getNoProxy()

setNoProxy

public void setNoProxy(Set<String> noProxyAddresses)

maxRetries

public int maxRetries()

setMaxRetries

public void setMaxRetries(int retries)

maxRedirects

public int maxRedirects()

setMaxRedirects

public void setMaxRedirects(int redirects)

getRequestBufferSize

public int getRequestBufferSize()
指定者:
接口 HttpBuffers 中的 getRequestBufferSize
返回:
the requestBufferSize

setRequestBufferSize

public void setRequestBufferSize(int requestBufferSize)
指定者:
接口 HttpBuffers 中的 setRequestBufferSize
参数:
requestBufferSize - the requestBufferSize to set

getRequestHeaderSize

public int getRequestHeaderSize()
指定者:
接口 HttpBuffers 中的 getRequestHeaderSize
返回:
the requestHeaderSize

setRequestHeaderSize

public void setRequestHeaderSize(int requestHeaderSize)
指定者:
接口 HttpBuffers 中的 setRequestHeaderSize
参数:
requestHeaderSize - the requestHeaderSize to set

getResponseBufferSize

public int getResponseBufferSize()
指定者:
接口 HttpBuffers 中的 getResponseBufferSize
返回:
the responseBufferSize

setResponseBufferSize

public void setResponseBufferSize(int responseBufferSize)
指定者:
接口 HttpBuffers 中的 setResponseBufferSize
参数:
responseBufferSize - the responseBufferSize to set

getResponseHeaderSize

public int getResponseHeaderSize()
指定者:
接口 HttpBuffers 中的 getResponseHeaderSize
返回:
the responseHeaderSize

setResponseHeaderSize

public void setResponseHeaderSize(int responseHeaderSize)
指定者:
接口 HttpBuffers 中的 setResponseHeaderSize
参数:
responseHeaderSize - the responseHeaderSize to set

getRequestBufferType

public Buffers.Type getRequestBufferType()
指定者:
接口 HttpBuffers 中的 getRequestBufferType
返回:
the requestBufferType

getRequestHeaderType

public Buffers.Type getRequestHeaderType()
指定者:
接口 HttpBuffers 中的 getRequestHeaderType
返回:
the requestHeaderType

getResponseBufferType

public Buffers.Type getResponseBufferType()
指定者:
接口 HttpBuffers 中的 getResponseBufferType
返回:
the responseBufferType

getResponseHeaderType

public Buffers.Type getResponseHeaderType()
指定者:
接口 HttpBuffers 中的 getResponseHeaderType
返回:
the responseHeaderType

setRequestBuffers

public void setRequestBuffers(Buffers requestBuffers)
指定者:
接口 HttpBuffers 中的 setRequestBuffers
参数:
requestBuffers - the requestBuffers to set

setResponseBuffers

public void setResponseBuffers(Buffers responseBuffers)
指定者:
接口 HttpBuffers 中的 setResponseBuffers
参数:
responseBuffers - the responseBuffers to set

getRequestBuffers

public Buffers getRequestBuffers()
指定者:
接口 HttpBuffers 中的 getRequestBuffers

getResponseBuffers

public Buffers getResponseBuffers()
指定者:
接口 HttpBuffers 中的 getResponseBuffers

setMaxBuffers

public void setMaxBuffers(int maxBuffers)
指定者:
接口 HttpBuffers 中的 setMaxBuffers

getMaxBuffers

public int getMaxBuffers()
指定者:
接口 HttpBuffers 中的 getMaxBuffers

getTrustStoreLocation

@Deprecated
public String getTrustStoreLocation()
已过时。 


setTrustStoreLocation

@Deprecated
public void setTrustStoreLocation(String trustStoreLocation)
已过时。 


getTrustStoreInputStream

@Deprecated
public InputStream getTrustStoreInputStream()
已过时。 


setTrustStoreInputStream

@Deprecated
public void setTrustStoreInputStream(InputStream trustStoreInputStream)
已过时。 


getKeyStoreLocation

@Deprecated
public String getKeyStoreLocation()
已过时。 


setKeyStoreLocation

@Deprecated
public void setKeyStoreLocation(String keyStoreLocation)
已过时。 


getKeyStoreInputStream

@Deprecated
public InputStream getKeyStoreInputStream()
已过时。 


setKeyStoreInputStream

@Deprecated
public void setKeyStoreInputStream(InputStream keyStoreInputStream)
已过时。 


setKeyStorePassword

@Deprecated
public void setKeyStorePassword(String keyStorePassword)
已过时。 


setKeyManagerPassword

@Deprecated
public void setKeyManagerPassword(String keyManagerPassword)
已过时。 


setTrustStorePassword

@Deprecated
public void setTrustStorePassword(String trustStorePassword)
已过时。 


getKeyStoreType

@Deprecated
public String getKeyStoreType()
已过时。 


setKeyStoreType

@Deprecated
public void setKeyStoreType(String keyStoreType)
已过时。 


getTrustStoreType

@Deprecated
public String getTrustStoreType()
已过时。 


setTrustStoreType

@Deprecated
public void setTrustStoreType(String trustStoreType)
已过时。 


getKeyManagerAlgorithm

@Deprecated
public String getKeyManagerAlgorithm()
已过时。 


setKeyManagerAlgorithm

@Deprecated
public void setKeyManagerAlgorithm(String keyManagerAlgorithm)
已过时。 


getTrustManagerAlgorithm

@Deprecated
public String getTrustManagerAlgorithm()
已过时。 


setTrustManagerAlgorithm

@Deprecated
public void setTrustManagerAlgorithm(String trustManagerAlgorithm)
已过时。 


getProtocol

@Deprecated
public String getProtocol()
已过时。 


setProtocol

@Deprecated
public void setProtocol(String protocol)
已过时。 


getProvider

@Deprecated
public String getProvider()
已过时。 


setProvider

@Deprecated
public void setProvider(String provider)
已过时。 


getSecureRandomAlgorithm

@Deprecated
public String getSecureRandomAlgorithm()
已过时。 


setSecureRandomAlgorithm

@Deprecated
public void setSecureRandomAlgorithm(String secureRandomAlgorithm)
已过时。 



Copyright © 2013. All Rights Reserved.