private void restoreOldContent() throws JMSException { // For a message that already had a body and was sent we need to restore the content // if the message is used again without having its clearBody method called. if (this.content != null && this.content.length > 0) { try { ByteSequence toRestore = this.content; if (isCompressed()) { toRestore = new ByteSequence(decompress(this.content)); compressed = false; } this.dataOut.write(toRestore.getData(), toRestore.getOffset(), toRestore.getLength()); // Free up the buffer from the old content, will be re-written when // the message is sent again and storeContent() is called. this.content = null; } catch (IOException ioe) { throw JMSExceptionSupport.create(ioe); } } }
private void initializeReading() throws JMSException { checkWriteOnlyBody(); if (dataIn == null) { try { ByteSequence data = getContent(); if (data == null) { data = new ByteSequence(new byte[] {}, 0, 0); } InputStream is = new ByteArrayInputStream(data); if (isCompressed()) { if (data.length != 0) { is = new ByteArrayInputStream(decompress(data)); } } else { length = data.getLength(); } dataIn = new DataInputStream(is); } catch (IOException ioe) { throw JMSExceptionSupport.create(ioe); } } }
private void initializeReading() throws JMSException { checkWriteOnlyBody(); if (dataIn == null) { ByteSequence data = getContent(); if (data == null) { data = new ByteSequence(new byte[] {}, 0, 0); } InputStream is = new ByteArrayInputStream(data); if (isCompressed()) { // keep track of the real length of the content if // we are compressed. try { DataInputStream dis = new DataInputStream(is); length = dis.readInt(); dis.close(); } catch (IOException e) { throw JMSExceptionSupport.create(e); } is = new InflaterInputStream(is); } else { length = data.getLength(); } dataIn = new DataInputStream(is); } }
private void restoreOldContent() throws JMSException { // For a message that already had a body and was sent we need to restore the content // if the message is used again without having its clearBody method called. if (this.content != null && this.content.length > 0) { try { ByteSequence toRestore = this.content; if (isCompressed()) { toRestore = new ByteSequence(decompress(this.content)); compressed = false; } this.dataOut.write(toRestore.getData(), toRestore.getOffset(), toRestore.getLength()); // Free up the buffer from the old content, will be re-written when // the message is sent again and storeContent() is called. this.content = null; } catch (IOException ioe) { throw JMSExceptionSupport.create(ioe); } } }
private void restoreOldContent() throws JMSException { // For a message that already had a body and was sent we need to restore the content // if the message is used again without having its clearBody method called. if (this.content != null && this.content.length > 0) { try { ByteSequence toRestore = this.content; if (isCompressed()) { toRestore = new ByteSequence(decompress(this.content)); compressed = false; } this.dataOut.write(toRestore.getData(), toRestore.getOffset(), toRestore.getLength()); // Free up the buffer from the old content, will be re-written when // the message is sent again and storeContent() is called. this.content = null; } catch (IOException ioe) { throw JMSExceptionSupport.create(ioe); } } }
private void restoreOldContent() throws JMSException { // For a message that already had a body and was sent we need to restore the content // if the message is used again without having its clearBody method called. if (this.content != null && this.content.length > 0) { try { ByteSequence toRestore = this.content; if (isCompressed()) { toRestore = new ByteSequence(decompress(this.content)); compressed = false; } this.dataOut.write(toRestore.getData(), toRestore.getOffset(), toRestore.getLength()); // Free up the buffer from the old content, will be re-written when // the message is sent again and storeContent() is called. this.content = null; } catch (IOException ioe) { throw JMSExceptionSupport.create(ioe); } } }
private void initializeReading() throws JMSException { checkWriteOnlyBody(); if (dataIn == null) { try { ByteSequence data = getContent(); if (data == null) { data = new ByteSequence(new byte[] {}, 0, 0); } InputStream is = new ByteArrayInputStream(data); if (isCompressed()) { if (data.length != 0) { is = new ByteArrayInputStream(decompress(data)); } } else { length = data.getLength(); } dataIn = new DataInputStream(is); } catch (IOException ioe) { throw JMSExceptionSupport.create(ioe); } } }
private void initializeReading() throws JMSException { checkWriteOnlyBody(); if (dataIn == null) { try { ByteSequence data = getContent(); if (data == null) { data = new ByteSequence(new byte[] {}, 0, 0); } InputStream is = new ByteArrayInputStream(data); if (isCompressed()) { if (data.length != 0) { is = new ByteArrayInputStream(decompress(data)); } } else { length = data.getLength(); } dataIn = new DataInputStream(is); } catch (IOException ioe) { throw JMSExceptionSupport.create(ioe); } } }
private void initializeReading() throws JMSException { checkWriteOnlyBody(); if (dataIn == null) { try { ByteSequence data = getContent(); if (data == null) { data = new ByteSequence(new byte[] {}, 0, 0); } InputStream is = new ByteArrayInputStream(data); if (isCompressed()) { if (data.length != 0) { is = new ByteArrayInputStream(decompress(data)); } } else { length = data.getLength(); } dataIn = new DataInputStream(is); } catch (IOException ioe) { throw JMSExceptionSupport.create(ioe); } } }
/** * Return the encoded form of the BytesMessage as an AMQP Binary instance. * * @param message * the Message whose binary encoded body is needed. * * @return a Binary instance containing the encoded message body. * * @throws JMSException if an error occurs while fetching the binary payload. */ public static Binary getBinaryFromMessageBody(ActiveMQBytesMessage message) throws JMSException { Binary result = null; if (message.getContent() != null) { ByteSequence contents = message.getContent(); if (message.isCompressed()) { int length = (int) message.getBodyLength(); byte[] uncompressed = new byte[length]; message.readBytes(uncompressed); result = new Binary(uncompressed); } else { return new Binary(contents.getData(), contents.getOffset(), contents.getLength()); } } return result; }
/** * Return the encoded form of the BytesMessage as an AMQP Binary instance. * * @param message * the Message whose binary encoded body is needed. * * @return a Binary instance containing the encoded message body. * * @throws JMSException if an error occurs while fetching the binary payload. */ public static Binary getBinaryFromMessageBody(ActiveMQBytesMessage message) throws JMSException { Binary result = null; if (message.getContent() != null) { ByteSequence contents = message.getContent(); if (message.isCompressed()) { int length = (int) message.getBodyLength(); byte[] uncompressed = new byte[length]; message.readBytes(uncompressed); result = new Binary(uncompressed); } else { return new Binary(contents.getData(), contents.getOffset(), contents.getLength()); } } return result; }