Websphere MQ Everyplace

examples.midp.exampleapp.msgpump
Class MidpClient

java.lang.Object
  |
  +--javax.microedition.midlet.MIDlet
        |
        +--examples.midp.exampleapp.msgpump.MidpClient
All Implemented Interfaces:
javax.microedition.lcdui.CommandListener, MsgPumpController

public class MidpClient
extends javax.microedition.midlet.MIDlet
implements javax.microedition.lcdui.CommandListener, MsgPumpController

This class acts as both controller and user interface for a MIDP pump client.

Textboxes and Forms are used to interact with users as well as display information about the current state of the client.

The client can be viewed as being in one of the following states:
- Initializing - in the process of initializing the client
- WaitingForQMname - occurs while initializing and waiting for the user to enter the name of the QM
- Running - in the process of pumping messages
- DisplayingStatus - displaying the status of the client to the user
- DisplayingOptions - displaying the options screen to the user
- ShuttingDown - in the process of shutting down

The following jad properties are available:

      Pump_SecurityLevel
        Specifies the security level that the app should use.
          0 for no security
          1 for message based security
          2 for queue based security

      Pump_ServerQueue
        Specifies the name of the queue that messages should be sent to.

      Pump_ServerIP
        Specifies the IP of the server that will sent messages.

      Pump_ServerPort
        Specifies the port that the server will be listening on.

      Pump_ServerQueueManager
        Specifies the name of the queue manager that messages will be sent to.
 


Field Summary
protected  MsgPumpModel msgPump
           
protected  java.lang.Thread thread
           
static short[] version
           
 
Constructor Summary
MidpClient()
          Constructor for MidpClient
 
Method Summary
protected  void acquiredQMName(java.lang.String name)
          This function is run once the name of the queuemanager has been acquired.
protected  void changeDisplay(javax.microedition.lcdui.Screen newDisplayable)
          Changes the current display.
 void commandAction(javax.microedition.lcdui.Command c, javax.microedition.lcdui.Displayable d)
          This is called if the user clicks a button.
 void deleteQueueManager()
          Completely removes the queue manager from the system.
 void destroyApp(boolean arg0)
          See javax.microedition.midlet#destroyApp.
 void displayMsg(java.lang.String msg)
          For the Midpclient, messages are displayed by updating the output screen.
 MsgPumpModel getModel()
          Returns the model or, if one doesnt currently exist, create a new one.
protected  javax.microedition.lcdui.Form getOptionScreen()
          Generates a new options form ( it has to fill in the default values ) and then returns it.
protected  javax.microedition.lcdui.TextBox getOutputScreen()
          Returns the default screen used to output information to the user.
 java.lang.String getQMname()
          Checks the local record stores for signs of a client having been run previously.
protected  javax.microedition.lcdui.TextBox getStatusScreen()
          Generates and returns a status report screen.
 void initialize()
          This class initializes the controller.
 void initializeMidlet()
          The equivilant of initialize.
 void pauseApp()
          See javax.microedition.midlet#pauseApp.
 void processMsg(java.lang.String msg)
          Processes a message to be displayed.
protected  void promptForQMName()
          Creates and displays a prompt to the user for a new QM name.
protected  void setPumpProperties()
          Uses properties set within the JAD file of this app to set properties of the model.
protected  void setQMName(java.lang.String name)
          This writes the name of the QM to a record store, allowing it to be used in the future.
 void start()
          Starts the controller running - this involves putting the model in a new thread and starting it.
 void startApp()
          See javax.microedition.midlet#startApp.
 
Methods inherited from class javax.microedition.midlet.MIDlet
getAppProperty, notifyDestroyed, notifyPaused, resumeRequest
 
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

msgPump

protected MsgPumpModel msgPump

thread

protected java.lang.Thread thread
Constructor Detail

MidpClient

public MidpClient()
Constructor for MidpClient

Method Detail

initialize

public void initialize()
                throws java.lang.Exception
This class initializes the controller.

Initialization involves trying to get the name of the queue manager from the RMS store. If no name is found, the user is prompted for one.

When the name is received, control will continue from commandAction()

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

deleteQueueManager

public void deleteQueueManager()
Completely removes the queue manager from the system. This involves indiscriminately purging all record stores that the MIDlet / MIDlet suite has access to.

This will of course mean that if you have both the textapp and the message pump in the same MIDlet suite, wiping one queue manager will also remove the other.

Specified by:
deleteQueueManager in interface MsgPumpController
Returns:
void

getQMname

public java.lang.String getQMname()
Checks the local record stores for signs of a client having been run previously. If this is the case, the name of the client is returned, otherwise null.

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

getModel

public MsgPumpModel getModel()
Returns the model or, if one doesnt currently exist, create a new one.

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

processMsg

public void processMsg(java.lang.String msg)
Processes a message to be displayed.

Specified by:
processMsg in interface MsgPumpController
Parameters:
msg - The message to be displayed
Returns:
void

start

public void start()
           throws java.lang.Exception
Starts the controller running - this involves putting the model in a new thread and starting it.

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

displayMsg

public void displayMsg(java.lang.String msg)
For the Midpclient, messages are displayed by updating the output screen.

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

setQMName

protected void setQMName(java.lang.String name)
This writes the name of the QM to a record store, allowing it to be used in the future.

Returns:
void

acquiredQMName

protected void acquiredQMName(java.lang.String name)
This function is run once the name of the queuemanager has been acquired. It continues the initialization of the controller.

Returns:
void

startApp

public void startApp()
              throws javax.microedition.midlet.MIDletStateChangeException
See javax.microedition.midlet#startApp.

Specified by:
startApp in class javax.microedition.midlet.MIDlet
javax.microedition.midlet.MIDletStateChangeException

pauseApp

public void pauseApp()
See javax.microedition.midlet#pauseApp.

Specified by:
pauseApp in class javax.microedition.midlet.MIDlet

destroyApp

public void destroyApp(boolean arg0)
                throws javax.microedition.midlet.MIDletStateChangeException
See javax.microedition.midlet#destroyApp.

Specified by:
destroyApp in class javax.microedition.midlet.MIDlet
javax.microedition.midlet.MIDletStateChangeException

setPumpProperties

protected void setPumpProperties()
Uses properties set within the JAD file of this app to set properties of the model. If the properties do not exist within the JAD, defaults will be used

Returns:
void

getOptionScreen

protected javax.microedition.lcdui.Form getOptionScreen()
Generates a new options form ( it has to fill in the default values ) and then returns it.

Returns:
Form - the options form

getStatusScreen

protected javax.microedition.lcdui.TextBox getStatusScreen()
Generates and returns a status report screen.

Returns:
TextBox - The status report

getOutputScreen

protected javax.microedition.lcdui.TextBox getOutputScreen()
Returns the default screen used to output information to the user.

Returns:
TextBox - default screen

initializeMidlet

public void initializeMidlet()
The equivilant of initialize. This function sets up the main display screen and te controller.

Returns:
void

promptForQMName

protected void promptForQMName()
Creates and displays a prompt to the user for a new QM name.

Returns:
void

commandAction

public void commandAction(javax.microedition.lcdui.Command c,
                          javax.microedition.lcdui.Displayable d)
This is called if the user clicks a button.

See CommandListener#commandAction for more details.

Specified by:
commandAction in interface javax.microedition.lcdui.CommandListener

changeDisplay

protected void changeDisplay(javax.microedition.lcdui.Screen newDisplayable)
Changes the current display.

Parameters:
newDisplayable - The new screen to be displayed
Returns:
void

Websphere MQ Everyplace