Package org.apache.activemq.util

Examples of org.apache.activemq.util.ByteArrayOutputStream.toByteSequence()


    public ByteSequence marshal(Object command) throws IOException {
        ByteArrayOutputStream baos = new ByteArrayOutputStream();
        DataOutputStream dos = new DataOutputStream(baos);
        marshal(command, dos);
        dos.close();
        return baos.toByteSequence();
    }

    public Object unmarshal(ByteSequence packet) throws IOException {
        ByteArrayInputStream stream = new ByteArrayInputStream(packet);
        DataInputStream dis = new DataInputStream(stream);
View Full Code Here


                throw new ProtocolException(errorMessage, true);
            }
            baos.write(b);
        }
        baos.close();
        ByteSequence sequence = baos.toByteSequence();
        return new String(sequence.getData(), sequence.getOffset(), sequence.getLength(), "UTF-8");
    }

    public int getVersion() {
        return version;
View Full Code Here

                    int read;
                    ByteArrayOutputStream bytesOut = new ByteArrayOutputStream();
                    while ((read = inflater.inflate(data)) != 0) {
                        bytesOut.write(data, 0, read);
                    }
                    byteSequence = bytesOut.toByteSequence();
                }
                result.payload(new Buffer(byteSequence.data, byteSequence.offset, byteSequence.length));
            }
        }
        return result;
View Full Code Here

    protected void setContent(Message message, String text) throws Exception {
        ByteArrayOutputStream baos = new ByteArrayOutputStream();
        DataOutputStream dataOut = new DataOutputStream(baos);
        MarshallingSupport.writeUTF8(dataOut, text);
        dataOut.close();
        message.setContent(baos.toByteSequence());
    }
}
View Full Code Here

        {
            ByteArrayOutputStream baos = new ByteArrayOutputStream();
            DataOutputStream dataOut = new DataOutputStream(baos);
            MarshallingSupport.writeUTF8(dataOut, "Content:11");
            dataOut.close();
            info.setContent(baos.toByteSequence());
        }

        {
          Map map = new HashMap();
          map.put("MarshalledProperties", 12);
View Full Code Here

          map.put("MarshalledProperties", 12);
            ByteArrayOutputStream baos = new ByteArrayOutputStream();
            DataOutputStream os = new DataOutputStream(baos);
            MarshallingSupport.marshalPrimitiveMap(map, os);
            os.close();
            info.setMarshalledProperties(baos.toByteSequence());
        }

        info.setDataStructure(createDataStructure("DataStructure:13"));
        info.setTargetConsumerId(createConsumerId("TargetConsumerId:14"));
        info.setCompressed(false);
View Full Code Here

        {
            ByteArrayOutputStream baos = new ByteArrayOutputStream();
            DataOutputStream dataOut = new DataOutputStream(baos);
            MarshallingSupport.writeUTF8(dataOut, "Content:11");
            dataOut.close();
            info.setContent(baos.toByteSequence());
        }
        {
          Map map = new HashMap();
          map.put("MarshalledProperties", 12);
            ByteArrayOutputStream baos = new ByteArrayOutputStream();
View Full Code Here

          map.put("MarshalledProperties", 12);
            ByteArrayOutputStream baos = new ByteArrayOutputStream();
            DataOutputStream os = new DataOutputStream(baos);
            MarshallingSupport.marshalPrimitiveMap(map, os);
            os.close();
            info.setMarshalledProperties(baos.toByteSequence());
        }
        info.setDataStructure(createDataStructure("DataStructure:13"));
        info.setTargetConsumerId(createConsumerId("TargetConsumerId:14"));
        info.setCompressed(false);
        info.setRedeliveryCounter(2);
View Full Code Here

        if (marshalledProperties == null && properties != null) {
            ByteArrayOutputStream baos = new ByteArrayOutputStream();
            DataOutputStream os = new DataOutputStream(baos);
            MarshallingSupport.marshalPrimitiveMap(properties, os);
            os.close();
            marshalledProperties = baos.toByteSequence();
        }
    }

    @Override
  public void afterMarshall(WireFormat wireFormat) throws IOException {
View Full Code Here

        ByteSequence bytes = getContent();
        ByteArrayOutputStream bytesOut = new ByteArrayOutputStream();
        OutputStream os = new DeflaterOutputStream(bytesOut);
        os.write(bytes.data, bytes.offset, bytes.length);
        os.close();
        setContent(bytesOut.toByteSequence());
    }

    @Override
    public String toString() {
        return toString(null);
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.