com.groiss.wfxml
Class Sender

java.lang.Object
  extended by com.groiss.wfxml.Sender

public class Sender
extends java.lang.Object

Use this class to send a message to a partner. There are four different send methods:

Since:
@enterprise 6.2

Constructor Summary
Sender()
           
 
Method Summary
static WfXMLMessage send(java.lang.String wfxml, Partner partner, java.lang.Class responseListener, java.lang.Class bufferListener, boolean useBuffer)
          This method sends a message (String-representation) to a communication partner.
protected static WfXMLMessage send(java.lang.String message, java.lang.String host, int port, java.lang.String path)
          This is a special send method which is used by the WfXML test client only.
static WfXMLMessage send(WfXMLMessage message, java.lang.Class responseListener, boolean useBuffer)
          Use this method to send NotifyMessage or PIStateChangedMessage objects to a registered observer.
static WfXMLMessage send(WfXMLMessage message, Partner partner, java.lang.Class responseListener, boolean useBuffer)
          Use this method to send a WfXMLMessage message to a communication partner, after you created the message.
static WfXMLMessage send(WfXMLMessage message, Partner partner, java.lang.Class responseListener, java.lang.Class bufferListener)
          Use this method to send a WfXML message if you want to use a buffer listener.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Sender

public Sender()
Method Detail

send

public static WfXMLMessage send(java.lang.String wfxml,
                                Partner partner,
                                java.lang.Class responseListener,
                                java.lang.Class bufferListener,
                                boolean useBuffer)
                         throws java.lang.Exception
This method sends a message (String-representation) to a communication partner. Normally you should use the send(WfXMLMessage,Partner,Class,boolean) method for sending messages.

Parameters:
wfxml - A String containing the message that will be sent.
partner - The communication partner to which the message will be sent.
responseListener - A response listener. See send(WfXMLMessage,Partner,Class,boolean) for more details.
bufferListener - A buffer listener. See the BufferListener interface for more details about buffer listeners.
useBuffer - Defines if an outgoing buffer will be used (if necessary) or not. See send(WfXMLMessage,Partner,Class,boolean) for more details.
Returns:
A WfXMLMessage object containing the answer returned from the partner server, or null if one of the following occurs:
  • The partner didn't send a response message (but no error occured!).
  • The local server is passive and so sending immediately is not possible. In that case it is a good idea to provide a ResponseListener.
  • The message was not send now, because of connection problems. In that case the message is stored in a Buffer and will be sent later (if useBuffer is set to true.
Throws:
ApplicationException - if sending the message fails and the message is not stored in the outgoing buffer (because maybe you set useBuffer to false, or there are problems with the buffer). An ApplicationException is also thrown if the local server doesn't have WfXML enabled. So, if this message is thrown, you can be sure, that the message was not sent and will not be sent.
WfXMLMessageException - if the response message is invalid and cannot be used, or if storing a message in the outgoing buffer failed (in case that the local server is passive or immediate sending was not possible).
java.lang.Exception

send

public static WfXMLMessage send(WfXMLMessage message,
                                Partner partner,
                                java.lang.Class responseListener,
                                boolean useBuffer)
                         throws java.lang.Exception
Use this method to send a WfXMLMessage message to a communication partner, after you created the message. You can use this method with passive and active local servers. In case the local server is active, the method will try to send the message immediately. If the local server is passive, the message will be stored in a buffer, where the partner will get it from.

For messages that are not sent immediately you can specify a response listener. As soon as a response is available, the response message will be passed on to that listener.

On an active local server the useBuffer parameter defines, if the message will be stored for later sending, in case that immediate sending is not possible (due to server/network problems or whatever).

Parameters:
message - WfXMLMessage object containing the message that will be sent.
partner - The communication partner to which the message will be sent.
responseListener - A class implementing the ResponseListener interface. This is useful when the message cannot be sent immediately. On a passive server you should always provide a response listener. On an active server it depends on whether you use buffering (useBuffer parameter) or not.
useBuffer - Set this value to true if you want that the message will be sent later, if sending now is not possible. For that case you should also provide a response listener (but it is not obligatory!). Set the value to false if you want that the message is sent now or never. In that case you shouldn't set a response listener, because it doesn't make any sense and it will never be used.
Mind: if the local server is passive, this parameter is ignored. On a passive server, outgoing messages are always stored in a buffer.
Returns:
A WfXMLMessage object containing the answer returned from the partner server, or null if one of the following occurs:
  • The partner didn't send a response message (but no error occured!).
  • The local server is passive and so sending immediately is not possible. In that case it is a good idea to provide a ResponseListener.
  • The message was not send now, because of connection problems. In that case the message is stored in a Buffer and will be sent later (if useBuffer is set to true).
Throws:
ApplicationException - if sending the message fails and the message is not stored in the outgoing buffer (because maybe you set useBuffer to false, or there are problems with the buffer). So, if this message is thrown, you can be sure, that the message was not sent and will not be sent.
WfXMLMessageException - if the response message is invalid and cannot be used.
java.lang.Exception

send

public static WfXMLMessage send(WfXMLMessage message,
                                Partner partner,
                                java.lang.Class responseListener,
                                java.lang.Class bufferListener)
                         throws java.lang.Exception
Use this method to send a WfXML message if you want to use a buffer listener. See BufferListener for more details about buffer listeners. If you call this method and set a buffer listener, the message will automatically be sent with buffering enabled (so, on active servers the buffer will be used in case that it is necessary).
If you don't set a buffer listener and send a message with this method, the message will be sent without using the buffer!

Parameters:
message - A WfXMLMessage object that you want to send.
partner - The target Partner to which you want the message to be sent.
responseListener - see send(WfXMLMessage,Partner,Class,boolean)
bufferListener - A class implementing the BufferListener interface. This class will be used as buffer listener for this message, in case that immediate sending is not possible.
Returns:
see send(WfXMLMessage,Partner,Class,boolean)
Throws:
java.lang.Exception - see send(WfXMLMessage,Partner,Class,boolean)

send

public static WfXMLMessage send(WfXMLMessage message,
                                java.lang.Class responseListener,
                                boolean useBuffer)
                         throws java.lang.Exception
Use this method to send NotifyMessage or PIStateChangedMessage objects to a registered observer. You don't need to provide the target communication partner here, because the WfXML layer knows if there is a observer and where it is located. If there is no observer to which the message could be sent, you will receive a simple null as answer (because this is no error).

Parameters:
message - WfXMLMessage object containing the message that will be sent. When you use this method for sending, the message should be a message type that is sent to observers (NotifyMessage or PIStateChangedMessage).
responseListener - A class implementing the ResponseListener interface. This is useful when the message cannot be sent immediately. On a passive server you should always provide a response listener. On an active server it depends on whether you use buffering (useBuffer parameter) or not.
useBuffer - Set this value to true if you want that the message will be sent later, if sending now is not possible. For that case you should also provide a response listener (but it is not obligatory!). Set the value to false if you want that the message is sent now or never. In that case you shouldn't set a response listener, because it doesn't make any sense and it will never be used.
Mind: if the local server is passive, this parameter is ignored. On a passive server, outgoing messages are always stored in a buffer.
Returns:
A WfXMLMessage object containing the answer returned from the partner server, or null if one of the following occurs:
  • No partner was found (e.g., there is no observer for this message).
  • The partner didn't send a response message (but no error occured!).
  • The local server is passive and so sending immediately is not possible. In that case it is a good idea to provide a ResponseListener.
  • The message was not send now, because of connection problems. In that case the message is stored in a Buffer and will be sent later (if useBuffer is set to true.
Throws:
ApplicationException - if sending the message fails and the message is not stored in the outgoing buffer (because maybe you set useBuffer to false, or there are problems with the buffer). So, if this message is thrown, you can be sure, that the message was not sent and will not be sent.
WfXMLMessageException - if the response message is invalid and cannot be used.
java.lang.Exception

send

protected static WfXMLMessage send(java.lang.String message,
                                   java.lang.String host,
                                   int port,
                                   java.lang.String path)
                            throws java.lang.Exception
This is a special send method which is used by the WfXML test client only. It sends a String to the specified host/port/path and returns the answer message in case that one is received. Otherwise it returns null. If any communication errors occur (socket, etc.), an exception is directly thrown.

Parameters:
message - The message as String.
host - Hostname of the host to which the message has to be sent.
port - Port of the host to which the message has to be sent.
path - The path (context root) that will be written in the POST request that will be sent to the specified host.
Throws:
java.lang.Exception - if any type of exception occurs.


Copyright © 2001-2006 Groiss Informatics GmbH. All Rights Reserved.