iaik.xkms.transport
Class Communication

Object
  extended by Communication

public class Communication
extends Object

Communication support class.


Field Summary
static int REPOLL_INTERVAL
          Automatic repolling interval for pending requests, in seconds.
 
Constructor Summary
Communication(XKMSContext context, URI uri)
          Prepares a new communication.
 
Method Summary
 String getOriginalResult()
          Gets original String result message after removal of wrapping.
 XResultType getResult()
          Gets result message as imported into library.
 XResultType sendAndRetryRequest(XRequestAbstractType request, TransportMethod method)
          See sendRequest.
 XResultType sendAndRetryRequest(XRequestAbstractType request, TransportMethod method, int timeout)
          Send message to an XKMS service and retry on represent/twophase.
 void sendSingleRequest(XMessageAbstractType request, TransportMethod method)
          Sends message to an XKMS service and stores the result.
 void setCreateOnly(boolean createonly)
          Sets option of create only request and let sendRequest terminate immediately.
 void setDebugName(String debugnameprefix)
          Sets option of dumping ALL requests and responses to specified filename(s).
 void setShowProgress(boolean showprogress)
          Sets option of showing progress characters on console.
 void setShowRawtext(boolean showrawtext)
          Sets option of showing full raw requests/responses on console.
 
Methods inherited from class Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

REPOLL_INTERVAL

public static final int REPOLL_INTERVAL
Automatic repolling interval for pending requests, in seconds.

See Also:
Constant Field Values
Constructor Detail

Communication

public Communication(XKMSContext context,
                     URI uri)
              throws XKMSException
Prepares a new communication.

Parameters:
context - XKMSContext to use for (un)marshalling.
uri - Remote destination to connect to.
Throws:
XKMSException - if passed a null parameter.
Method Detail

sendSingleRequest

public void sendSingleRequest(XMessageAbstractType request,
                              TransportMethod method)
                       throws Exception
Sends message to an XKMS service and stores the result.

The result can be obtained with getResult() and getOriginalResult().

Parameters:
request - the message to send
method - type of message wrapping to use
Throws:
Exception

sendAndRetryRequest

public XResultType sendAndRetryRequest(XRequestAbstractType request,
                                       TransportMethod method,
                                       int timeout)
                                throws XKMSException
Send message to an XKMS service and retry on represent/twophase.

Convenience method which hides the difficulties of communicating with an XKMS server. It sends the request to specified host and port, performs the represent and pending mechanism (if necessary) and returns the result. If the server insists on performing the result asynchronously, the client will poll the server in regular intervals. The caller can specify how long this should take at maximum by specifying a timeout value (in seconds). When approximately the given time has elapsed and still no result is available, an XKMSException is thrown.

Parameters:
request - message to send
method - type of message wrapping to use
timeout - maximum amount of time to poll for a result. -1 means infinite timeout
Returns:
result received from the server
Throws:
XKMSException - if something goes wrong

sendAndRetryRequest

public XResultType sendAndRetryRequest(XRequestAbstractType request,
                                       TransportMethod method)
                                throws XKMSException
See sendRequest.

Calls sendAndRetryRequest(XRequestAbstractType, TransportMethod, int) with timeout=100.

Throws:
XKMSException

getOriginalResult

public String getOriginalResult()
Gets original String result message after removal of wrapping.

The recovery of the raw message is necessary if one wants to store it, as import+reexport of message with the library destroys XML signatures.

Returns:
String of original message.

getResult

public XResultType getResult()
Gets result message as imported into library.

Returns:
result message

setShowProgress

public void setShowProgress(boolean showprogress)
Sets option of showing progress characters on console.

Characters:

 s - sending
r - receiving
2 - twophase protocol
w - pending wait


setShowRawtext

public void setShowRawtext(boolean showrawtext)
Sets option of showing full raw requests/responses on console.


setCreateOnly

public void setCreateOnly(boolean createonly)
Sets option of create only request and let sendRequest terminate immediately.


setDebugName

public void setDebugName(String debugnameprefix)
Sets option of dumping ALL requests and responses to specified filename(s).