Websphere MQ Everyplace

examples.midp.exampleapp.msgpump
Class MsgPumpModel

java.lang.Object
  |
  +--examples.midp.exampleapp.msgpump.MsgPumpModel
All Implemented Interfaces:
MessageConsumer, java.lang.Runnable
Direct Known Subclasses:
MsgPumpModelClient, MsgPumpModelServer

public abstract class MsgPumpModel
extends java.lang.Object
implements java.lang.Runnable, MessageConsumer

This is the basic outline of a message pump model. The model is the part of the system that does everything whereas the controller is the part that decides what needs to be done.

The model contains an MQeMessageService, which handles the queue manager, queues and other parts of MQe. It also contains a link to its controller, which is used if a decision needs to be made or if the user eed to be prompted for something.

The model part of the system will not be dependant on whether it is using MIDP, Foundation, J2SE or any other versions of java as it should be independant of these things; the controller will handle all java-version specific things. For this reason, when a message is sent and includes a timestamp, since MIDP does not contain the functions necessary to easily obtain a timestamp, this has been done manually within the model - hence the getTimestamp() and padNumber() functions.


Field Summary
 java.lang.String compressor
          The pump's compressor.
 java.lang.String cryptor
          The pump's cryptor.
static int DEFAULT_SECURITY
          The default security value.
static java.lang.String DEFAULT_SERVER_Q_NAME
          The default name of the server queue being pumped to.
static java.lang.String DEFAULT_SERVER_QM_NAME
          The default name of the server queue manager.
static int MESSAGE_SECURITY
           
static int NO_SECURITY
           
static int QUEUE_SECURITY
           
static java.lang.String SECURITY_KEY
          The key used for encrypting messages with message based security.
 boolean sync
          Shows whether the queues are synchronous or not .
static short[] version
           
 
Constructor Summary
MsgPumpModel()
           
 
Method Summary
 void createMessageAttribute()
          Creates a new message attribute to use.
 void finish()
          Any final actions necessary to finish stopping the model.
protected  MsgPumpController getController()
          Returns the model's controller.
 java.lang.String getLocalQMname()
          Gets the local queue manager name.
 MQeAttribute getMessageAttribute()
          Returns the messsage attribute or, if none exists, creates a new one.
protected  MQeMessageService getMsgService()
          Returns the model's message service ( creating a new one if necessary ).
 java.lang.String getQMrules()
          Gets the rules used to configure the queue manager.
protected  java.lang.String getTimestamp()
          Returns a nicely formatted datetimestamp.
 void initialize(MsgPumpController controller, java.lang.String localQMname)
          Used to initialize a message pump model.
 boolean isSecurity(int security)
          Returns whether the security type being used matches the given type.
protected  java.lang.String padNumber(int size, int number)
          Given a number and a size, this function will return the original number padded with zeroes to fill in the spaces ( as a String ).
abstract  void pause()
          Pauses the model.
protected abstract  void performInitialConfiguration()
          Used to initially set up the queue manager, queues and anything else required by the model ( listeners etc ).
 void processStatus(java.lang.String statusMessage)
          Used to process a message before it is displayed.
abstract  void resume()
          Resumes the model.
protected  void setController(MsgPumpController controller)
          Sets the model's controller.
protected  void setProperty(java.lang.String property, java.lang.String value)
          Sets a property of the pump.
abstract  void stop()
          Called when something wants the model to stop.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface java.lang.Runnable
run
 
Methods inherited from interface examples.midp.exampleapp.messageservice.MessageConsumer
processDataGramMsg, processReplyMsg, processRequestMsg
 

Field Detail

version

public static short[] version

DEFAULT_SERVER_QM_NAME

public static final java.lang.String DEFAULT_SERVER_QM_NAME
The default name of the server queue manager.

See Also:
Constant Field Values

DEFAULT_SERVER_Q_NAME

public static final java.lang.String DEFAULT_SERVER_Q_NAME
The default name of the server queue being pumped to.

See Also:
Constant Field Values

NO_SECURITY

public static final int NO_SECURITY
See Also:
Constant Field Values

MESSAGE_SECURITY

public static final int MESSAGE_SECURITY
See Also:
Constant Field Values

QUEUE_SECURITY

public static final int QUEUE_SECURITY
See Also:
Constant Field Values

DEFAULT_SECURITY

public static final int DEFAULT_SECURITY
The default security value.

See Also:
Constant Field Values

SECURITY_KEY

public static final java.lang.String SECURITY_KEY
The key used for encrypting messages with message based security.

See Also:
Constant Field Values

cryptor

public final java.lang.String cryptor
The pump's cryptor.

See Also:
Constant Field Values

compressor

public final java.lang.String compressor
The pump's compressor.


sync

public final boolean sync
Shows whether the queues are synchronous or not .

See Also:
Constant Field Values
Constructor Detail

MsgPumpModel

public MsgPumpModel()
Method Detail

isSecurity

public boolean isSecurity(int security)
Returns whether the security type being used matches the given type.

Parameters:
security - The security type
Returns:
boolean - if the security matches

initialize

public void initialize(MsgPumpController controller,
                       java.lang.String localQMname)
                throws java.lang.Exception
Used to initialize a message pump model.

Parameters:
controller - Link to this model's controller
localQMname - Name of local queue manager
Returns:
void
java.lang.Exception

getMsgService

protected MQeMessageService getMsgService()
Returns the model's message service ( creating a new one if necessary ).

Returns:
MQeMessageService - the message service

finish

public void finish()
            throws java.lang.Exception
Any final actions necessary to finish stopping the model.

Returns:
void
java.lang.Exception

setProperty

protected void setProperty(java.lang.String property,
                           java.lang.String value)
Sets a property of the pump.

Parameters:
property - The property
value - The value to set it to
Returns:
void

processStatus

public void processStatus(java.lang.String statusMessage)
Used to process a message before it is displayed.
Note: this is not used for MQe messages, but simple status or info messages such as 'Initializing Client'.

Specified by:
processStatus in interface MessageConsumer
Parameters:
statusMessage - The message to be displayed
Returns:
void

getTimestamp

protected java.lang.String getTimestamp()
Returns a nicely formatted datetimestamp.

Note - 'nicely' means US format 'hh:mm mm/dd/yy'.

Should only be used to generate a timestamp for a message to be sent.

Returns:
String - a datetimestamp

padNumber

protected java.lang.String padNumber(int size,
                                     int number)
Given a number and a size, this function will return the original number padded with zeroes to fill in the spaces ( as a String ).
i.e. padNumber ( 3, 5 ) -> 005 ( note the order ).

Parameters:
size - The size to pad number out to
number - The number to pad
Returns:
String

getController

protected MsgPumpController getController()
Returns the model's controller.

Returns:
MsgPumpController

setController

protected void setController(MsgPumpController controller)
Sets the model's controller.

Returns:
void

getLocalQMname

public java.lang.String getLocalQMname()
Gets the local queue manager name.

Returns:
String

getQMrules

public java.lang.String getQMrules()
Gets the rules used to configure the queue manager.

Returns:
String

getMessageAttribute

public MQeAttribute getMessageAttribute()
                                 throws java.lang.Exception
Returns the messsage attribute or, if none exists, creates a new one.

Returns:
MQeAttribute - the message attribute
java.lang.Exception

createMessageAttribute

public void createMessageAttribute()
                            throws java.lang.Exception
Creates a new message attribute to use.

Returns:
void
java.lang.Exception

performInitialConfiguration

protected abstract void performInitialConfiguration()
                                             throws java.lang.Exception
Used to initially set up the queue manager, queues and anything else required by the model ( listeners etc ). This is only run if there are no registry file located on the system.

Returns:
void
java.lang.Exception

stop

public abstract void stop()
Called when something wants the model to stop. Returns whether the caller should wait on the model until it is done or not.

Returns:
boolean

pause

public abstract void pause()
Pauses the model.

Returns:
void

resume

public abstract void resume()
Resumes the model.

Returns:
void

Websphere MQ Everyplace