📄 message.java
字号:
return ConversionHelper.toBytes(momMsg.getCorrelationId()); } catch (MessageValueException mE) { throw new MessageFormatException(mE.getMessage()); } } /** * API method. * * @exception MessageNotWriteableException If the message is read-only. * @exception JMSException If the property name is invalid. */ public void setBooleanProperty(String name, boolean value) throws JMSException { doSetProperty(name, new Boolean(value)); } /** * API method. * * @exception MessageNotWriteableException If the message is read-only. * @exception JMSException If the property name is invalid. */ public void setByteProperty(String name, byte value) throws JMSException { doSetProperty(name, new Byte(value)); } /** * API method. * * @exception MessageNotWriteableException If the message is read-only. * @exception JMSException If the property name is invalid. */// public void setDoubleProperty(String name, double value) throws JMSException// {// doSetProperty(name, new Double(value));// } /** * API method. * * @exception MessageNotWriteableException If the message is read-only. * @exception JMSException If the property name is invalid. */// public void setFloatProperty(String name, float value) throws JMSException// {// doSetProperty(name, new Float(value));// } /** * API method. * * @exception MessageNotWriteableException If the message is read-only. * @exception JMSException If the property name is invalid. */ public void setIntProperty(String name, int value) throws JMSException { doSetProperty(name, new Integer(value)); } /** * API method. * * @exception MessageNotWriteableException If the message is read-only. * @exception JMSException If the property name is invalid. */ public void setLongProperty(String name, long value) throws JMSException { doSetProperty(name, new Long(value)); } /** * API method. * * @exception MessageNotWriteableException If the message is read-only. * @exception JMSException If the property name is invalid, or if the * object is invalid. */ public void setObjectProperty(String name, Object value) throws JMSException { doSetProperty(name, value); } /** * API method. * * @exception MessageNotWriteableException If the message is read-only. * @exception JMSException If the property name is invalid. */ public void setShortProperty(String name, short value) throws JMSException { doSetProperty(name, new Short(value)); } /** * API method. * * @exception MessageNotWriteableException If the message is read-only. * @exception JMSException If the property name is invalid. */ public void setStringProperty(String name, String value) throws JMSException { doSetProperty(name, value); } /** * API method. * * @exception MessageFormatException If the property type is invalid. * @exception JMSException If the name is invalid. */ public boolean getBooleanProperty(String name) throws JMSException { try { return ConversionHelper.toBoolean(doGetProperty(name)); } catch (MessageValueException mE) { throw new MessageFormatException(mE.getMessage()); } } /** * API method. * * @exception MessageFormatException If the property type is invalid. * @exception JMSException If the name is invalid. */ public byte getByteProperty(String name) throws JMSException { try { return ConversionHelper.toByte(doGetProperty(name)); } catch (MessageValueException mE) { throw new MessageFormatException(mE.getMessage()); } } /** * API method. * * @exception MessageFormatException If the property type is invalid. * @exception JMSException If the name is invalid. */// public double getDoubleProperty(String name) throws JMSException// {// try {// return ConversionHelper.toDouble(doGetProperty(name));// }// catch (MessageValueException mE) {// throw new MessageFormatException(mE.getMessage());// }// } /** * API method. * * @exception MessageFormatException If the property type is invalid. * @exception JMSException If the name is invalid. */// public float getFloatProperty(String name) throws JMSException// {// try {// return ConversionHelper.toFloat(doGetProperty(name));// }// catch (MessageValueException mE) {// throw new MessageFormatException(mE.getMessage());// }// } /** * API method. * * @exception MessageFormatException If the property type is invalid. * @exception JMSException If the name is invalid. */ public int getIntProperty(String name) throws JMSException { try { return ConversionHelper.toInt(doGetProperty(name)); } catch (MessageValueException mE) { throw new MessageFormatException(mE.getMessage()); } } /** * API method. * * @exception MessageFormatException If the property type is invalid. * @exception JMSException If the name is invalid. */ public long getLongProperty(String name) throws JMSException { try { return ConversionHelper.toLong(doGetProperty(name)); } catch (MessageValueException mE) { throw new MessageFormatException(mE.getMessage()); } } /** * API method. * * @exception JMSException If the name is invalid. */ public Object getObjectProperty(String name) throws JMSException { return doGetProperty(name); } /** * API method. * * @exception MessageFormatException If the property type is invalid. * @exception JMSException If the name is invalid. */ public short getShortProperty(String name) throws JMSException { try { return ConversionHelper.toShort(doGetProperty(name)); } catch (MessageValueException mE) { throw new MessageFormatException(mE.getMessage()); } } /** * API method. * * @exception JMSException If the name is invalid. */ public String getStringProperty(String name) throws JMSException { return ConversionHelper.toString(doGetProperty(name)); } /** * Method actually setting a new property. * * @param name The property name. * @param value The property value. * * @exception MessageFormatException If the property type is invalid. * @exception MessageNotWriteableException If the message is read-only. * @exception JMSException If the name is invalid. * @exception IllegalArgumentException If the name string is null or empty. */ private void doSetProperty(String name, Object value) throws JMSException { if (name == null || name.equals("")) throw new IllegalArgumentException("Invalid property name: " + name); String upName = name.toUpperCase(); try { if (name.startsWith("JMSX")) { if (name.equals("JMSXGroupID")) momMsg.setOptionalHeader(name, ConversionHelper.toString(value)); else if (name.equals("JMSXGroupSeq")) momMsg.setOptionalHeader(name, new Integer(ConversionHelper.toInt(value))); else throw new JMSException("Property names with prefix 'JMSX' are" + " reserved."); } else if (name.startsWith("JMS_")) throw new JMSException("Property names with prefix 'JMS_' are" + " reserved."); else if (name.startsWith("JMS")) throw new JMSException("Property names with prefix 'JMS' are" + " reserved."); else if (upName.equals("NULL") || upName.equals("TRUE") || upName.equals("FALSE") || upName.equals("NOT") || upName.equals("AND") || upName.equals("OR") || upName.equals("BETWEEN") || upName.equals("LIKE") || upName.equals("IN") || upName.equals("IS") || upName.equals("ESCAPE")) throw new JMSException("Invalid property name: " + name + " is a" + " SQL terminal."); else momMsg.setObjectProperty(name, value); } catch (MessageException mE) { if (mE instanceof MessageValueException) throw new MessageFormatException(mE.getMessage()); if (mE instanceof MessageROException) throw new MessageNotWriteableException(mE.getMessage()); } } /** * Method actually getting a property. * * @param name The property name. */ private Object doGetProperty(String name) { if (name == null || name.equals("")) throw new IllegalArgumentException("Invalid property name: " + name); Object value = null; if (name.startsWith("JMSX")) { if (name.equals("JMSXDeliveryCount")) value = new Integer(momMsg.deliveryCount); else value = momMsg.getOptionalHeader(name); } else if (name.startsWith("JMS_JORAM")) { if (name.equals("JMS_JORAM_DELETEDDEST")) value = new Boolean(momMsg.deletedDest); else if (name.equals("JMS_JORAM_NOTWRITABLE")) value = new Boolean(momMsg.notWriteable); else if (name.equals("JMS_JORAM_EXPIRED")) value = new Boolean(momMsg.expired); else if (name.equals("JMS_JORAM_UNDELIVERABLE")) value = new Boolean(momMsg.undeliverable); } else value = momMsg.getObjectProperty(name); return value; } /** * Method called by message producers for getting the wrapped MOM message * they actually send. * * @exception MessageFormatException If the data could not be serialized. */ com.scalagent.kjoram.messages.Message getMomMessage() throws MessageFormatException { try { prepare(); return momMsg; } catch (Exception e) { MessageFormatException jE = new MessageFormatException("The message body could not be" + " serialized."); jE.setLinkedException(e); throw jE; } } /** * Wraps a given MOM message in the appropriate Joram message. * <p> * This method is actually called by a session consuming a MOM message * for wrapping it in a Joram message before handing it to the consumer. * * @exception JMSException If an error occurs while building the message. */ static Message wrapMomMessage(Session sess, com.scalagent.kjoram.messages.Message momMsg) throws JMSException { Message msg = null; if (momMsg.getType() == MessageType.SIMPLE) msg = new Message(sess, momMsg); else if (momMsg.getType() == MessageType.TEXT) msg = new TextMessage(sess, momMsg); else if (momMsg.getType() == MessageType.MAP) msg = new MapMessage(sess, momMsg); else if (momMsg.getType() == MessageType.BYTES) msg = new BytesMessage(sess, momMsg); return msg; } /** * Converts a non-Joram JMS message into a Joram message. * * @exception JMSException If an error occurs while building the message. */ static Message convertJMSMessage(Message jmsMsg) throws JMSException { Message msg = null; if (jmsMsg instanceof TextMessage) { msg = new TextMessage(); ((TextMessage) msg).setText(((TextMessage)jmsMsg).getText()); } else if (jmsMsg instanceof BytesMessage) { msg = new BytesMessage(); try { while (true) ((BytesMessage) msg).writeByte(((BytesMessage)jmsMsg).readByte()); } catch (MessageEOFException mE) {} } else if (jmsMsg instanceof MapMessage) { msg = new MapMessage(); Enumeration mapNames = ((MapMessage) jmsMsg).getMapNames(); } else msg = new Message(); msg.setJMSCorrelationID(jmsMsg.getJMSCorrelationID()); msg.setJMSReplyTo(jmsMsg.getJMSReplyTo()); msg.setJMSType(jmsMsg.getJMSType()); return msg; } /** * Method preparing the message for sending; resets header values, and * serializes the body (done in subclasses). * * @exception Exception If an error occurs while serializing. */ protected void prepare() throws Exception { momMsg.denied = false; momMsg.deletedDest = false; momMsg.expired = false; momMsg.notWriteable = false; momMsg.undeliverable = false; }}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -