List of usage examples for javax.jms JMSException JMSException
public JMSException(String reason)
From source file:org.skyscreamer.nevado.jms.message.NevadoStreamMessage.java
/** * Reads a 32-bit integer from the stream message. * * @return a 32-bit integer value from the stream message, interpreted as an * <code>int</code>/*from ww w . ja va 2 s . co m*/ * @throws JMSException * if the JMS provider fails to read the message due to some * internal error. * @throws MessageEOFException * if unexpected end of message stream has been reached. * @throws MessageFormatException * if this type conversion is invalid. * @throws MessageNotReadableException * if the message is in write-only mode. */ public int readInt() throws JMSException { initializeReading(); try { this.dataIn.mark(33); int type = this.dataIn.read(); if (type == -1) { throw new MessageEOFException("reached end of data"); } if (type == MarshallingSupport.INTEGER_TYPE) { return this.dataIn.readInt(); } if (type == MarshallingSupport.SHORT_TYPE) { return this.dataIn.readShort(); } if (type == MarshallingSupport.BYTE_TYPE) { return this.dataIn.readByte(); } if (type == MarshallingSupport.STRING_TYPE) { return Integer.valueOf(this.dataIn.readUTF()).intValue(); } if (type == MarshallingSupport.NULL) { this.dataIn.reset(); throw new NullPointerException("Cannot convert NULL value to int."); } else { this.dataIn.reset(); throw new MessageFormatException(" not an int type"); } } catch (NumberFormatException mfe) { try { this.dataIn.reset(); } catch (IOException ioe) { JMSException jmsEx = new MessageFormatException(ioe.getMessage()); jmsEx.setLinkedException(ioe); throw jmsEx; } throw mfe; } catch (EOFException e) { String exMessage = "Reached premature EOF: " + e.getMessage(); _log.error(exMessage, e); throw new JMSException(exMessage); } catch (IOException e) { String exMessage = "Could not read boolean: " + e.getMessage(); _log.error(exMessage, e); throw new JMSException(exMessage); } }
From source file:org.skyscreamer.nevado.jms.message.NevadoStreamMessage.java
/** * Reads a 64-bit integer from the stream message. * * @return a 64-bit integer value from the stream message, interpreted as a * <code>long</code> * @throws JMSException/*w w w . j a v a2 s . co m*/ * if the JMS provider fails to read the message due to some * internal error. * @throws MessageEOFException * if unexpected end of message stream has been reached. * @throws MessageFormatException * if this type conversion is invalid. * @throws MessageNotReadableException * if the message is in write-only mode. */ public long readLong() throws JMSException { initializeReading(); try { this.dataIn.mark(65); int type = this.dataIn.read(); if (type == -1) { throw new MessageEOFException("reached end of data"); } if (type == MarshallingSupport.LONG_TYPE) { return this.dataIn.readLong(); } if (type == MarshallingSupport.INTEGER_TYPE) { return this.dataIn.readInt(); } if (type == MarshallingSupport.SHORT_TYPE) { return this.dataIn.readShort(); } if (type == MarshallingSupport.BYTE_TYPE) { return this.dataIn.readByte(); } if (type == MarshallingSupport.STRING_TYPE) { return Long.valueOf(this.dataIn.readUTF()).longValue(); } if (type == MarshallingSupport.NULL) { this.dataIn.reset(); throw new NullPointerException("Cannot convert NULL value to long."); } else { this.dataIn.reset(); throw new MessageFormatException(" not a long type"); } } catch (NumberFormatException mfe) { try { this.dataIn.reset(); } catch (IOException ioe) { JMSException jmsEx = new MessageFormatException(ioe.getMessage()); jmsEx.setLinkedException(ioe); throw jmsEx; } throw mfe; } catch (EOFException e) { String exMessage = "Reached premature EOF: " + e.getMessage(); _log.error(exMessage, e); throw new JMSException(exMessage); } catch (IOException e) { String exMessage = "Could not read boolean: " + e.getMessage(); _log.error(exMessage, e); throw new JMSException(exMessage); } }
From source file:org.skyscreamer.nevado.jms.message.NevadoStreamMessage.java
/** * Reads a <code>float</code> from the stream message. * * @return a <code>float</code> value from the stream message * @throws JMSException//from w w w . jav a 2 s . c o m * if the JMS provider fails to read the message due to some * internal error. * @throws MessageEOFException * if unexpected end of message stream has been reached. * @throws MessageFormatException * if this type conversion is invalid. * @throws MessageNotReadableException * if the message is in write-only mode. */ public float readFloat() throws JMSException { initializeReading(); try { this.dataIn.mark(33); int type = this.dataIn.read(); if (type == -1) { throw new MessageEOFException("reached end of data"); } if (type == MarshallingSupport.FLOAT_TYPE) { return this.dataIn.readFloat(); } if (type == MarshallingSupport.STRING_TYPE) { return Float.valueOf(this.dataIn.readUTF()).floatValue(); } if (type == MarshallingSupport.NULL) { this.dataIn.reset(); throw new NullPointerException("Cannot convert NULL value to float."); } else { this.dataIn.reset(); throw new MessageFormatException(" not a float type"); } } catch (NumberFormatException mfe) { try { this.dataIn.reset(); } catch (IOException ioe) { JMSException jmsEx = new MessageFormatException(ioe.getMessage()); jmsEx.setLinkedException(ioe); throw jmsEx; } throw mfe; } catch (EOFException e) { String exMessage = "Reached premature EOF: " + e.getMessage(); _log.error(exMessage, e); throw new JMSException(exMessage); } catch (IOException e) { String exMessage = "Could not read boolean: " + e.getMessage(); _log.error(exMessage, e); throw new JMSException(exMessage); } }
From source file:org.skyscreamer.nevado.jms.message.NevadoStreamMessage.java
/** * Reads a <code>double</code> from the stream message. * * @return a <code>double</code> value from the stream message * @throws JMSException/*from w ww .j a v a2 s. c o m*/ * if the JMS provider fails to read the message due to some * internal error. * @throws MessageEOFException * if unexpected end of message stream has been reached. * @throws MessageFormatException * if this type conversion is invalid. * @throws MessageNotReadableException * if the message is in write-only mode. */ public double readDouble() throws JMSException { initializeReading(); try { this.dataIn.mark(65); int type = this.dataIn.read(); if (type == -1) { throw new MessageEOFException("reached end of data"); } if (type == MarshallingSupport.DOUBLE_TYPE) { return this.dataIn.readDouble(); } if (type == MarshallingSupport.FLOAT_TYPE) { return this.dataIn.readFloat(); } if (type == MarshallingSupport.STRING_TYPE) { return Double.valueOf(this.dataIn.readUTF()).doubleValue(); } if (type == MarshallingSupport.NULL) { this.dataIn.reset(); throw new NullPointerException("Cannot convert NULL value to double."); } else { this.dataIn.reset(); throw new MessageFormatException(" not a double type"); } } catch (NumberFormatException mfe) { try { this.dataIn.reset(); } catch (IOException ioe) { JMSException jmsEx = new MessageFormatException(ioe.getMessage()); jmsEx.setLinkedException(ioe); throw jmsEx; } throw mfe; } catch (EOFException e) { String exMessage = "Reached premature EOF: " + e.getMessage(); _log.error(exMessage, e); throw new JMSException(exMessage); } catch (IOException e) { String exMessage = "Could not read boolean: " + e.getMessage(); _log.error(exMessage, e); throw new JMSException(exMessage); } }
From source file:org.skyscreamer.nevado.jms.message.NevadoStreamMessage.java
/** * Reads a <CODE>String</CODE> from the stream message. * * @return a Unicode string from the stream message * @throws JMSException//from w ww. j av a 2s. co m * if the JMS provider fails to read the message due to some * internal error. * @throws MessageEOFException * if unexpected end of message stream has been reached. * @throws MessageFormatException * if this type conversion is invalid. * @throws MessageNotReadableException * if the message is in write-only mode. */ public String readString() throws JMSException { initializeReading(); try { this.dataIn.mark(65); int type = this.dataIn.read(); if (type == -1) { throw new MessageEOFException("reached end of data"); } if (type == MarshallingSupport.NULL) { return null; } if (type == MarshallingSupport.BIG_STRING_TYPE) { return MarshallingSupport.readUTF8(dataIn); } if (type == MarshallingSupport.STRING_TYPE) { return this.dataIn.readUTF(); } if (type == MarshallingSupport.LONG_TYPE) { return new Long(this.dataIn.readLong()).toString(); } if (type == MarshallingSupport.INTEGER_TYPE) { return new Integer(this.dataIn.readInt()).toString(); } if (type == MarshallingSupport.SHORT_TYPE) { return new Short(this.dataIn.readShort()).toString(); } if (type == MarshallingSupport.BYTE_TYPE) { return new Byte(this.dataIn.readByte()).toString(); } if (type == MarshallingSupport.FLOAT_TYPE) { return new Float(this.dataIn.readFloat()).toString(); } if (type == MarshallingSupport.DOUBLE_TYPE) { return new Double(this.dataIn.readDouble()).toString(); } if (type == MarshallingSupport.BOOLEAN_TYPE) { return (this.dataIn.readBoolean() ? Boolean.TRUE : Boolean.FALSE).toString(); } if (type == MarshallingSupport.CHAR_TYPE) { return new Character(this.dataIn.readChar()).toString(); } else { this.dataIn.reset(); throw new MessageFormatException(" not a String type"); } } catch (NumberFormatException mfe) { try { this.dataIn.reset(); } catch (IOException ioe) { JMSException jmsEx = new MessageFormatException(ioe.getMessage()); jmsEx.setLinkedException(ioe); throw jmsEx; } throw mfe; } catch (EOFException e) { String exMessage = "Reached premature EOF: " + e.getMessage(); _log.error(exMessage, e); throw new JMSException(exMessage); } catch (IOException e) { String exMessage = "Could not read boolean: " + e.getMessage(); _log.error(exMessage, e); throw new JMSException(exMessage); } }
From source file:org.skyscreamer.nevado.jms.message.NevadoStreamMessage.java
/** * Writes a <code>boolean</code> to the stream message. The value * <code>true</code> is written as the value <code>(byte)1</code>; the * value <code>false</code> is written as the value <code>(byte)0</code>. * * @param value// w w w . j av a 2 s. c o m * the <code>boolean</code> value to be written * @throws JMSException * if the JMS provider fails to write the message due to some * internal error. * @throws MessageNotWriteableException * if the message is in read-only mode. */ public void writeBoolean(boolean value) throws JMSException { initializeWriting(); try { MarshallingSupport.marshalBoolean(dataOut, value); } catch (IOException e) { String exMessage = "Could not write boolean: " + e.getMessage(); _log.error(exMessage, e); throw new JMSException(exMessage); } }
From source file:org.skyscreamer.nevado.jms.message.NevadoStreamMessage.java
/** * Writes a <code>byte</code> to the stream message. * * @param value/*from ww w . j a v a 2 s. co m*/ * the <code>byte</code> value to be written * @throws JMSException * if the JMS provider fails to write the message due to some * internal error. * @throws MessageNotWriteableException * if the message is in read-only mode. */ public void writeByte(byte value) throws JMSException { initializeWriting(); try { MarshallingSupport.marshalByte(dataOut, value); } catch (IOException e) { String exMessage = "Could not write byte: " + e.getMessage(); _log.error(exMessage, e); throw new JMSException(exMessage); } }
From source file:org.skyscreamer.nevado.jms.message.NevadoStreamMessage.java
/** * Writes a <code>short</code> to the stream message. * * @param value/* w w w .j a va 2 s . com*/ * the <code>short</code> value to be written * @throws JMSException * if the JMS provider fails to write the message due to some * internal error. * @throws MessageNotWriteableException * if the message is in read-only mode. */ public void writeShort(short value) throws JMSException { initializeWriting(); try { MarshallingSupport.marshalShort(dataOut, value); } catch (IOException e) { String exMessage = "Could not write short: " + e.getMessage(); _log.error(exMessage, e); throw new JMSException(exMessage); } }
From source file:org.skyscreamer.nevado.jms.message.NevadoStreamMessage.java
/** * Writes a <code>char</code> to the stream message. * * @param value/* ww w . j a va 2 s . c o m*/ * the <code>char</code> value to be written * @throws JMSException * if the JMS provider fails to write the message due to some * internal error. * @throws MessageNotWriteableException * if the message is in read-only mode. */ public void writeChar(char value) throws JMSException { initializeWriting(); try { MarshallingSupport.marshalChar(dataOut, value); } catch (IOException e) { String exMessage = "Could not write short: " + e.getMessage(); _log.error(exMessage, e); throw new JMSException(exMessage); } }
From source file:org.skyscreamer.nevado.jms.message.NevadoStreamMessage.java
/** * Writes an <code>int</code> to the stream message. * * @param value// w ww . jav a2 s. c o m * the <code>int</code> value to be written * @throws JMSException * if the JMS provider fails to write the message due to some * internal error. * @throws MessageNotWriteableException * if the message is in read-only mode. */ public void writeInt(int value) throws JMSException { initializeWriting(); try { MarshallingSupport.marshalInt(dataOut, value); } catch (IOException e) { String exMessage = "Could not write int: " + e.getMessage(); _log.error(exMessage, e); throw new JMSException(exMessage); } }