Websphere MQ Everyplace

examples.midp.exampleapp.textapp
Class AppModelServer

java.lang.Object
  |
  +--examples.midp.exampleapp.textapp.AppModel
        |
        +--examples.midp.exampleapp.textapp.AppModelServer
All Implemented Interfaces:
MessageConsumer, java.lang.Runnable
Direct Known Subclasses:
AppModelGatewayServer, AppModelRegistrationServer

public abstract class AppModelServer
extends AppModel

A simple layout for a server that the registration server and gateway can extend. This class is abstract as it should not be used as a server model, since it does not implement some abstract classes that are required and will differ between servers.

In general, a server will need to specify its listener port and define what to do when it gets a message as well as how to display it.

The defaults for this are provided within this class, though they may be overridden by classes that extend it. e.g. the registration server listens on port 8083 not the default 8082 to allow it to be present on the same computer as the gateway server.


Field Summary
static short[] version
           
 
Fields inherited from class examples.midp.exampleapp.textapp.AppModel
DEFAULT_CLIENT_QM, DEFAULT_GATEWAY, DEFAULT_GATEWAY_QM, DEFAULT_HOMESERVER_Q, DEFAULT_LISTENER_PORT, DEFAULT_REGISTRATION, DEFAULT_REGISTRATION_LISTENER_PORT, DEFAULT_REGISTRATION_Q, DEFAULT_REGISTRATION_QM, DEFAULT_REGISTRATION_REPLY_Q, DEFAULT_REPLY_Q, DEFAULT_REQUEST_Q, DEFAULT_RULES, GatewayCommand, GatewayOptions, RegistrationCommand, RegistrationOptions
 
Constructor Summary
AppModelServer()
           
 
Method Summary
protected  int getListenerPort()
          Returns the port that the queue manager listens on.
protected  void initialConfiguration()
          Configures the model - servers need a listener.
protected  boolean isServer()
          Used to check whether the model is a client or server.
 void processDataGramMsg(MQeMsgObject message, java.lang.String qMgrName, java.lang.String qName)
          If a datagram is received, simply display it.
 void processMessage(MQeMsgObject message)
          Formats an MQe or MQ message before displaying it.
 
Methods inherited from class examples.midp.exampleapp.textapp.AppModel
chooseConnections, chooseLocalQueues, chooseRemoteQueues, clearLocalQueues, createListener, getController, getLocalQMname, getMsgService, initializeConnections, initializeLocalQueues, initializeOtherQueues, initializeRemoteQueues, monitorLocalQueues, processStatus, registerWithCentral, run, sendNewMessage, setLocalQMname, setMsgService, start, statusReport, stop
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface examples.midp.exampleapp.messageservice.MessageConsumer
processReplyMsg, processRequestMsg
 

Field Detail

version

public static short[] version
Constructor Detail

AppModelServer

public AppModelServer()
Method Detail

isServer

protected boolean isServer()
Description copied from class: AppModel
Used to check whether the model is a client or server. This determines whether a listener should be created and whether the model should register with the central server.

This design has problem with expandability if, in the future, a server that registers with the central server is required.

Specified by:
isServer in class AppModel
Returns:
boolean - true if server, false if client
See Also:
AppModel.isServer()

processDataGramMsg

public void processDataGramMsg(MQeMsgObject message,
                               java.lang.String qMgrName,
                               java.lang.String qName)
If a datagram is received, simply display it.

Parameters:
message - The message to display
qMgrName - The queue manager the message is on
qName - The queue the message is on
Returns:
void
See Also:
MessageConsumer.processDataGramMsg(MQeMsgObject, String, String)

initialConfiguration

protected void initialConfiguration()
                             throws java.lang.Exception
Configures the model - servers need a listener.

Overrides:
initialConfiguration in class AppModel
Returns:
void
java.lang.Exception
See Also:
AppModel.initialConfiguration()

processMessage

public void processMessage(MQeMsgObject message)
Formats an MQe or MQ message before displaying it.

Parameters:
message - The message to display
Returns:
void

getListenerPort

protected int getListenerPort()
Description copied from class: AppModel
Returns the port that the queue manager listens on. (unimportant to clients, as they don't have listeners).

Specified by:
getListenerPort in class AppModel
Returns:
int - port to listen on
See Also:
AppModel.getListenerPort()

Websphere MQ Everyplace