Websphere MQ Everyplace

examples.adapters
Class MQeTcpipLengthGUIAdapter

java.lang.Object
  |
  +--com.ibm.mqe.adapters.MQeCommunicationsAdapter
        |
        +--examples.adapters.MQeTcpipLengthGUIAdapter

public class MQeTcpipLengthGUIAdapter
extends MQeCommunicationsAdapter

The MQeTcpipLengthGUIAdapter is a simple example of how to create a communications adapter to be used with MQe. There is no rigorous error checking, neither does the adapter correctly deal with the situation where the data length to be written is greater than the length of buffer to use.


Field Summary
static short[] version
           
 
Fields inherited from class com.ibm.mqe.adapters.MQeCommunicationsAdapter
COMMS_ADAPTER_ADDRESS, COMMS_ADAPTER_CLASS, COMMS_ADAPTER_GROUP_SIZE, COMMS_ADAPTER_HTTP_VERSION, COMMS_ADAPTER_LISTEN, COMMS_ADAPTER_NONBLOCKING_TIMEOUT, COMMS_ADAPTER_NOPERSIST, COMMS_ADAPTER_PERSIST, COMMS_ADAPTER_PKTSIZE, COMMS_ADAPTER_PORT, COMMS_ADAPTER_RETRIES, COMMS_ADAPTER_SERVLET, COMMS_ADAPTER_TIMEOUT, COMMS_ADAPTER_VARIANCE, listeningAdapter, persistentAdapter, responderAdapter
 
Constructor Summary
MQeTcpipLengthGUIAdapter()
           
 
Method Summary
 void activate(MQePropertyProvider info)
          Used to activate an adapter and should only ever be called once in the life-time of the object.
 void close()
          Closes an adapter.
 void open()
          Opens an adapter for use.
 byte[] read()
          Reads data from the adapter.
protected  void setSocket(java.net.Socket newSocket)
           
 void temporaryClose()
          Closes a non persistent adapter.
 MQeCommunicationsAdapter waitForContact(MQePropertyProvider info)
          Used by the listening adapter to wait for incoming data.
 void writeData(byte[] data)
          Writes a request to the adapter stream.
 void writeResponse(byte[] data)
          Writes response information to the adapter stream.
 
Methods inherited from class com.ibm.mqe.adapters.MQeCommunicationsAdapter
createNewAdapter, isStopDemanded, isStopRequested
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

version

public static short[] version
Constructor Detail

MQeTcpipLengthGUIAdapter

public MQeTcpipLengthGUIAdapter()
Method Detail

activate

public void activate(MQePropertyProvider info)
              throws java.lang.Exception
Description copied from class: MQeCommunicationsAdapter

Used to activate an adapter and should only ever be called once in the life-time of the object.

Note : This entry point is meant to be used by the WebSphere MQ Everyplace object library not by application programs.

Specified by:
activate in class MQeCommunicationsAdapter
Returns:
void
Throws:
java.lang.Exception - a Java lang exception if an error is encountered
See Also:
MQeCommunicationsAdapter.activate(MQePropertyProvider)

close

public void close()
           throws java.lang.Exception
Description copied from class: MQeCommunicationsAdapter

Closes an adapter. Implementations of this method should ensure that all network and system objects are correctly closed.

Note: This entry point is meant to be used by the WebSphere MQ Everyplace object library not by application programs.

Specified by:
close in class MQeCommunicationsAdapter
Returns:
void
java.lang.Exception
See Also:
MQeCommunicationsAdapter.close()

open

public void open()
          throws java.lang.Exception
Description copied from class: MQeCommunicationsAdapter

Opens an adapter for use. Implementations of this method need to take into account this method may be called more than once in the life-time of the adapter.

Note : This entry point is meant to be used by the WebSphere MQ Everyplace object library not by application programs.

Specified by:
open in class MQeCommunicationsAdapter
Returns:
void
java.lang.Exception
See Also:
MQeCommunicationsAdapter.open()

read

public byte[] read()
            throws java.lang.Exception
Description copied from class: MQeCommunicationsAdapter

Reads data from the adapter. The caller will expect a byte array of data to be returned. Any adapter specific information that has been flowed across with network with the data must be removed prior to returning the byte array.

Note : This entry point is meant to be used by the WebSphere MQ Everyplace object library not by application programs.

Specified by:
read in class MQeCommunicationsAdapter
Returns:
A byte array containing the data bytes read from the network
Throws:
java.lang.Exception - Error ocurred whilst reading from the network
See Also:
MQeCommunicationsAdapter.read()

temporaryClose

public void temporaryClose()
                    throws java.lang.Exception
Description copied from class: MQeCommunicationsAdapter

Closes a non persistent adapter. Implementors should only close the network and system objects if the variable persistentAdapter is false.

Note: This entry point is meant to be used by the WebSphere MQ Everyplace object library not by application programs.

At various times in the communications conversation it is desireable to close an adapter's communications resources, but only if it has not been explicitly stated they should remain open.

Specified by:
temporaryClose in class MQeCommunicationsAdapter
java.lang.Exception
See Also:
MQeCommunicationsAdapter.temporaryClose()

waitForContact

public MQeCommunicationsAdapter waitForContact(MQePropertyProvider info)
                                        throws java.lang.Exception
Description copied from class: MQeCommunicationsAdapter

Used by the listening adapter to wait for incoming data.

On the responder side of a communciations conversation this method is responsible for waiting on a named socket for incoming requests. The method should return an instance of the given adapter to conduct the rest of the conversation whilst leaving the listening adapter free to wait for more requests. Implemenations of this method should use MQeCommunicationsAdapter.createNewAdapter to create the new adapter

Specified by:
waitForContact in class MQeCommunicationsAdapter
Returns:
MQeCommunicationsAdapter a communications adapter
Throws:
java.lang.Exception
See Also:
MQeCommunicationsAdapter.waitForContact(MQePropertyProvider)

writeData

public void writeData(byte[] data)
               throws java.lang.Exception
Description copied from class: MQeCommunicationsAdapter

Writes a request to the adapter stream.

This method is used to write data to the network.

Note : This entry point is meant to be used by the WebSphere MQ Everyplace object library not by application programs.

Specified by:
writeData in class MQeCommunicationsAdapter
Parameters:
data - Byte array containing the data to be written.
Returns:
void
Throws:
java.lang.Exception - Error ocurred whilst writing to the network
See Also:
MQeCommunicationsAdapter.writeData(byte[])

writeResponse

public void writeResponse(byte[] data)
                   throws java.lang.Exception
Description copied from class: MQeCommunicationsAdapter

Writes response information to the adapter stream. Some protocols require specifc header information to be written with the data dependent upon the nature of the data. This method may be used if such a protocol is being used, otherwise, it is suggested that implementors call the writeData(byte[]) method from this method.

This method is used to write data to the network.

Note : This entry point is meant to be used by the WebSphere MQ Everyplace object library not by application programs.

Specified by:
writeResponse in class MQeCommunicationsAdapter
Parameters:
data - Byte array containing the data to be written.
Returns:
void
Throws:
java.lang.Exception - Error ocurred whilst writing to the network.
See Also:
MQeCommunicationsAdapter.writeResponse(byte[])

setSocket

protected void setSocket(java.net.Socket newSocket)
                  throws java.lang.Exception
java.lang.Exception

Websphere MQ Everyplace