Websphere MQ Everyplace

examples.midp.exampleapp.msgpump
Class NormalClient

java.lang.Object
  |
  +--examples.midp.exampleapp.msgpump.NormalClient
All Implemented Interfaces:
MsgPumpController
Direct Known Subclasses:
NormalServer

public class NormalClient
extends java.lang.Object
implements MsgPumpController

This class acts as the message pump controller for clients on the J2SE java platform. It contains a main() function and so can be run from the commandline.

The main uses of the controller are to get a name for the queue manager and control the pump to suit the user's requests.

An input thread is used to collect user input. This is handled by an InputThread.

The following commandline arguements are accepted:
--security [0 - 2] : Allows you to set the security level of the server. 0 = no security. 1 = message based security. 2 = queue based security.
--serverip [xxx.xxx.xxx.xxx] : The ip of the server (localhost is default)
--serverport [n] : The port to send messages to (default 8082)
--servername [name] : The name of the server to send to
--serverqueuename [queue] : The name of the queue to send to

e.g. java mqeexampleapp.msgpump.NormalClient --security 1 --serverip 10.0.0.101 will send to 10.0.0.101 using message based security


Field Summary
static java.lang.String prompttext
          String used to prompt the user for input.
static java.lang.String starttext
          Initial thing that is displayed to the user after initialization is complete.
static short[] version
           
 
Constructor Summary
NormalClient()
           
 
Method Summary
protected  void deleteDir(java.io.File path)
          Equivilent to dos deltree or linux rm -r .
 void deleteQueueManager()
          Purges the queue manager from the system.
 void displayMsg(java.lang.String msg)
          Displays a status report or other type of message.
 MsgPumpModel getModel()
          Returns the model being used by the controller.
 MsgPumpModel getMsgPump()
          Gets the msgPump.
protected  InputThread getNewInputThread()
          Returns a new inputthread.
 MsgPumpModel getNewModel()
          Returns a new model.
 java.lang.String getQMname()
          The QM name is generated by using the computer's hostname.
 void initialize()
          Sets the prompt and start texts before initializing.
static void main(java.lang.String[] args)
          The function called when the class is run.
 void processInput(java.lang.String input)
          Deals with user input.
 void processMsg(java.lang.String msg)
          Processes a status or error message.
protected  void setPumpProperties(java.lang.String[] args)
          Called when the class is started with commandline arguments.
 void start()
          Starts the controller.
protected  void startInput()
          Starts the input thread.
 
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

starttext

public static final java.lang.String starttext
Initial thing that is displayed to the user after initialization is complete.

See Also:
Constant Field Values

prompttext

public static final java.lang.String prompttext
String used to prompt the user for input.

See Also:
Constant Field Values
Constructor Detail

NormalClient

public NormalClient()
Method Detail

main

public static void main(java.lang.String[] args)
The function called when the class is run. This initializes and starts a new controller.


setPumpProperties

protected void setPumpProperties(java.lang.String[] args)
                          throws java.lang.Exception
Called when the class is started with commandline arguments. This function will set the appropriate properties in the pump

Parameters:
args - The commandline arguments
Returns:
void
java.lang.Exception

deleteQueueManager

public void deleteQueueManager()
Purges the queue manager from the system. On J2SE, this is done by wiping the whole tree structure.

Specified by:
deleteQueueManager in interface MsgPumpController
Returns:
void

deleteDir

protected void deleteDir(java.io.File path)
Equivilent to dos deltree or linux rm -r .
Deletes a directory and all subdirectories and files.

Parameters:
path - the directory to delete
Returns:
void

startInput

protected void startInput()
Starts the input thread.

Returns:
void

getModel

public MsgPumpModel getModel()
Returns the model being used by the controller.

Specified by:
getModel in interface MsgPumpController
Returns:
MsgPumpModel - the model

getNewInputThread

protected InputThread getNewInputThread()
Returns a new inputthread.

Returns:
InputThread - a new inputthread

processMsg

public void processMsg(java.lang.String msg)
Processes a status or error message. In this simple case, this involves merely displaying it

Specified by:
processMsg in interface MsgPumpController
Parameters:
msg - The mesage to display
Returns:
void

getQMname

public java.lang.String getQMname()
The QM name is generated by using the computer's hostname. If all else fails, a default is used.

Specified by:
getQMname in interface MsgPumpController
Returns:
String - the name of the queue manager
See Also:
MsgPumpController.getQMname()

start

public void start()
           throws java.lang.Exception
Starts the controller.

This involves starting the model in a new thread.

Specified by:
start in interface MsgPumpController
Returns:
void
java.lang.Exception

initialize

public void initialize()
                throws java.lang.Exception
Sets the prompt and start texts before initializing.

Specified by:
initialize in interface MsgPumpController
Returns:
void
java.lang.Exception
See Also:
MsgPumpController.initialize()

processInput

public void processInput(java.lang.String input)
Deals with user input.

Parameters:
input - The user input
Returns:
void

displayMsg

public void displayMsg(java.lang.String msg)
Description copied from interface: MsgPumpController
Displays a status report or other type of message.

Specified by:
displayMsg in interface MsgPumpController
Parameters:
msg - The message to display
See Also:
MsgPumpController.displayMsg(String).

getNewModel

public MsgPumpModel getNewModel()
Returns a new model.


getMsgPump

public MsgPumpModel getMsgPump()
Gets the msgPump.

Returns:
Returns a MsgPumpModel

Websphere MQ Everyplace