net.jxta.impl.endpoint.servlethttp
Class HttpClientMessenger
java.lang.Object
net.jxta.util.AbstractSimpleSelectable
net.jxta.endpoint.AbstractMessenger
net.jxta.impl.endpoint.BlockingMessenger
net.jxta.impl.endpoint.servlethttp.HttpClientMessenger
- All Implemented Interfaces:
- Messenger, SimpleSelectable
public class HttpClientMessenger
- extends BlockingMessenger
Simple messenger that simply posts a message to a URL.
URL/HttpURLConnection is used, so (depending on your JDK) you will get
reasonably good persistent connection management.
Fields inherited from interface net.jxta.endpoint.Messenger |
ANYSTATE, BREAKING, BROKEN, CLOSED, CLOSING, CONNECTED, DISCONNECTED, DISCONNECTING, IDLE, RECONCLOSING, RECONNECTING, RECONSATURATED, RESOLCLOSING, RESOLPENDING, RESOLSATURATED, RESOLVED, RESOLVING, SATURATED, SENDING, SENDINGSATURATED, TERMINAL, UNRESOLVABLE, UNRESOLVED, UNRESOLVING, USABLE |
Methods inherited from class net.jxta.impl.endpoint.BlockingMessenger |
close, getChannelMessenger, getDestAddressToUse, getLogicalDestinationAddress, getState, isClosed, resolve, sendMessageB, sendMessageN, setOwner, shutdown |
Methods inherited from class net.jxta.endpoint.AbstractMessenger |
flush, getDestinationAddress, getDestinationAddressObject, getMTU, isIdle, isSynchronous, itemChanged, sendMessage, sendMessage, sendMessage, setStateLock, waitState |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
HttpClientMessenger
public HttpClientMessenger(ServletHttpTransport servletHttpTransport,
PeerID peerId,
EndpointAddress destAddr)
throws IOException
- Constructs the messenger.
- Parameters:
servletHttpTransport
- The transport this messenger will work for.peerId
- The peerId of this peer.destAddr
- The destination address.
- Throws:
IOException
doshutdown
void doshutdown()
closeImpl
public void closeImpl()
- Close connection. May fail current send.
- Specified by:
closeImpl
in class BlockingMessenger
sendMessageBImpl
public boolean sendMessageBImpl(Message message,
String service,
String serviceParam)
throws IOException
- send message. block as needed. throw IOException or runtime exception as needed.
The boolean return value is for historical reasons: so that transports just need to rename their sendMessage() methods.
No need to change a bit of the code.
- Specified by:
sendMessageBImpl
in class BlockingMessenger
- Throws:
IOException
getLogicalDestinationImpl
public EndpointAddress getLogicalDestinationImpl()
- Obtain the logical destination address from the implementer (a transport for example).
- Specified by:
getLogicalDestinationImpl
in class BlockingMessenger
isIdleImpl
public boolean isIdleImpl()
- return true if this messenger has not been used for a long time. The definition of long time is: "so long that closing it
is worth the risk of having to re-open". A messenger should self close if it thinks it meets the definition of
idle. BlockingMessenger leaves the evaluation to the transport but does the work automatically. Important: if
self destruction is used, this method must work; not just return false. See the constructor. In general, if closeImpl does
not need to do anyhing, then self destruction is not needed.
- Specified by:
isIdleImpl
in class BlockingMessenger