/** * Constructor. */ public SessionMessageHeader(String strQueueName, String strQueueType, Object source, Object objKey) { this(); this.init(strQueueName, strQueueType, source, objKey); } /**
/** * A record with this datasource handle changed, notify any behaviors that are checking. * NOTE: Be very careful as this code is running in an independent thread * (synchronize to the task before calling record calls). * NOTE: For now, you are only notified of the main record changes. * @param message The message to handle. * @return The error code. */ public int handleMessage(BaseMessage message) { System.out.println("---------------------------------------------------------- HotelSession/86"); if (message instanceof BaseMessage) { Double dblRate = (Double)message.get(BookingDetail.TOTAL_COST); if (message.get(HotelRateResponse.PRODUCT_RESPONSE_MESSAGE) instanceof HotelRateResponseMessageData) { dblRate = new Double(((HotelRateResponseMessageData)message.get(HotelRateResponse.PRODUCT_RESPONSE_MESSAGE)).getRoomCost(PaxCategory.DOUBLE_ID)); } MessageManager messageManager = ((Application)this.getTask().getApplication()).getMessageManager(); BaseMessageHeader messageFilter = message.getMessageHeader(); BaseMessageHeader messageHeader = new SessionMessageHeader(null, this); Map<String,Object> properties = new Hashtable<String,Object>(); properties.put("hotelCost", dblRate); BaseMessage messageTableUpdate = new MapMessage(messageHeader, properties); messageManager.sendMessage(messageTableUpdate); } return super.handleMessage(message); }
/** * Does this message header match this filter? * @param messageHeader The message header to check. * @return true if match, false if no match. */ public boolean isFilterMatch(BaseMessageHeader messageHeader) { boolean bMatch = super.isFilterMatch(messageHeader); if (bMatch) { if (m_bPrivate) bMatch = false; // Only a matching SessionMessageHeader will be sent. if ((messageHeader != null) && (this.getObjectKey() != null) && (messageHeader instanceof SessionMessageHeader) && (((SessionMessageHeader)messageHeader).getObjectKey() != null) && (!this.getObjectKey().equals(((SessionMessageHeader)messageHeader).getObjectKey()))) bMatch = false; // No match! else bMatch = true; // Match! } return bMatch; // MATCH!!! } /**
/** * If you are sending a thick message to a thin client, convert it first. * Since BaseMessage is already, so conversion is necessary... return this message. * @return this message. */ public BaseMessage convertToThinMessage() { int iChangeType = ((RecordMessageHeader)this.getMessageHeader()).getRecordMessageType(); // See if this record is currently displayed or buffered, if so, refresh and display. Object data = this.getData(); BaseMessage messageTableUpdate = null; // NOTE: The only way I will send this message to the client is if the ModelMessageHandler.START_INDEX_PARAM has been added to this message by the TableSession // if (properties.get(ModelMessageHandler.START_INDEX_PARAM) != null) { BaseMessageHeader messageHeader = new SessionMessageHeader(this.getMessageHeader().getQueueName(), this.getMessageHeader().getQueueType(), null, this); messageTableUpdate = new MapMessage(messageHeader, data); messageTableUpdate.put(MessageConstants.MESSAGE_TYPE_PARAM, Integer.toString(iChangeType)); } return messageTableUpdate; } }
/** * If you are sending a thick message to a thin client, convert it first. * Since BaseMessage is already, so conversion is necessary... return this message. * @return this message. */ public BaseMessage convertToThinMessage() { int iChangeType = ((RecordMessageHeader)this.getMessageHeader()).getRecordMessageType(); // See if this record is currently displayed or buffered, if so, refresh and display. Object data = this.getData(); BaseMessage messageTableUpdate = null; // NOTE: The only way I will send this message to the client is if the ModelMessageHandler.START_INDEX_PARAM has been added to this message by the TableSession // if (properties.get(ModelMessageHandler.START_INDEX_PARAM) != null) { BaseMessageHeader messageHeader = new SessionMessageHeader(this.getMessageHeader().getQueueName(), this.getMessageHeader().getQueueType(), null, this); messageTableUpdate = new MapMessage(messageHeader, data); messageTableUpdate.put(MessageConstants.MESSAGE_TYPE_PARAM, Integer.toString(iChangeType)); } return messageTableUpdate; } }
/** * Constructor. */ public SessionMessageHeader(Object source, Object objKey) { this(); this.init(MessageConstants.SESSION_QUEUE_NAME, MessageConstants.INTRANET_QUEUE, source, objKey); } /**