Package org.fusesource.hawtbuf

Examples of org.fusesource.hawtbuf.ByteArrayOutputStream


            public void run() {
                final Task publish = this;
                Buffer message  = body;
                if(prefixCounter) {
                    long id = sent + 1;
                    ByteArrayOutputStream os = new ByteArrayOutputStream(message.length + 15);
                    os.write(new AsciiBuffer(Long.toString(id)));
                    os.write(':');
                    os.write(body);
                    message = os.toBuffer();
                }
                connection.publish(topic, message, qos, retain, new Callback<Void>() {
                    public void onSuccess(Void value) {
                        sent ++;
                        if(debug) {
View Full Code Here


            System.out.println("it was not readable!");
            return;
        }

        if( current==null ) {
            current = new ByteArrayOutputStream();
        }

        int count;
        byte data[] = new byte[1024*4];
        while( (count = receiver.recv(data, 0, data.length)) > 0 ) {
View Full Code Here

            System.out.println("it was not readable!");
            return;
        }

        if( current==null ) {
            current = new ByteArrayOutputStream();
        }

        int count;
        byte data[] = new byte[1024*4];
        while( (count = receiver.recv(data, 0, data.length)) > 0 ) {
View Full Code Here

                LOG.debug("Delivery was not readable!");
                return;
            }

            if (current == null) {
                current = new ByteArrayOutputStream();
            }

            int count;
            while ((count = receiver.recv(recvBuffer, 0, recvBuffer.length)) > 0) {
                current.write(recvBuffer, 0, count);
View Full Code Here

                LOG.debug("Delivery was not readable!");
                return;
            }

            if (current == null) {
                current = new ByteArrayOutputStream();
            }

            int count;
            while ((count = receiver.recv(recvBuffer, 0, recvBuffer.length)) > 0) {
                current.write(recvBuffer, 0, count);
View Full Code Here

    public void beforeMarshall(OpenWireFormat wireFormat) throws IOException {
        super.beforeMarshall(wireFormat);

        Buffer content = getContent();
        if (content == null && text != null) {
            ByteArrayOutputStream bytesOut = new ByteArrayOutputStream();
            OutputStream os = bytesOut;
            if (Settings.enable_compression()) {
                compressed = true;
                os = new DeflaterOutputStream(os);
            }
            DataOutputStream dataOut = new DataOutputStream(os);
            MarshallingSupport.writeUTF8(dataOut, this.text);
            dataOut.close();
            setContent(bytesOut.toBuffer());
        }
    }
View Full Code Here

    }

    private void initializeWriting() throws OpenwireException {
        checkReadOnlyBody();
        if (this.dataOut == null) {
            this.bytesOut = new ByteArrayOutputStream();
            OutputStream os = bytesOut;
            if (Settings.enable_compression()) {
                // keep track of the real length of the content if
                // we are compressed.
                try {
View Full Code Here

    public void storeContent() {
        Buffer bodyAsBytes = getContent();
        if (bodyAsBytes == null && object != null) {
            try {
                ByteArrayOutputStream bytesOut = new ByteArrayOutputStream();
                OutputStream os = bytesOut;
                if (Settings.enable_compression()) {
                    compressed = true;
                    os = new DeflaterOutputStream(os);
                }
                DataOutputStream dataOut = new DataOutputStream(os);
                ObjectOutputStream objOut = new ObjectOutputStream(dataOut);
                objOut.writeObject(object);
                objOut.flush();
                objOut.reset();
                objOut.close();
                setContent(bytesOut.toBuffer());
            } catch (IOException ioe) {
                throw new RuntimeException(ioe.getMessage(), ioe);
            }
        }
    }
View Full Code Here

    }

    public void beforeMarshall(OpenWireFormat wireFormat) throws IOException {
        // Need to marshal the properties.
        if (marshalledProperties == null && properties != null) {
            ByteArrayOutputStream baos = new ByteArrayOutputStream();
            DataOutputStream os = new DataOutputStream(baos);
            MarshallingSupport.marshalPrimitiveMap(properties, os);
            os.close();
            marshalledProperties = baos.toBuffer();
        }
    }
View Full Code Here

    }

    public void beforeMarshall(OpenWireFormat wireFormat) throws IOException {
        // Need to marshal the properties.
        if (marshalledProperties == null && properties != null) {
            ByteArrayOutputStream baos = new ByteArrayOutputStream();
            DataOutputStream os = new DataOutputStream(baos);
            MarshallingSupport.marshalPrimitiveMap(properties, os);
            os.close();
            marshalledProperties = baos.toBuffer();
        }
    }
View Full Code Here

TOP

Related Classes of org.fusesource.hawtbuf.ByteArrayOutputStream

Copyright © 2018 www.massapicom. 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.