Search in sources :

Example 16 with OpenwireException

use of io.fabric8.gateway.handlers.detecting.protocol.openwire.support.OpenwireException in project fabric8 by jboss-fuse.

the class ActiveMQStreamMessage method readInt.

public int readInt() throws OpenwireException {
    initializeReading();
    try {
        this.dataIn.mark(33);
        int type = this.dataIn.read();
        if (type == -1) {
            throw new OpenwireException("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 OpenwireException(" not an int type");
        }
    } catch (NumberFormatException mfe) {
        try {
            this.dataIn.reset();
        } catch (IOException ioe) {
            throw new OpenwireException(ioe);
        }
        throw mfe;
    } catch (EOFException e) {
        throw new OpenwireException(e);
    } catch (IOException e) {
        throw new OpenwireException(e);
    }
}
Also used : OpenwireException(io.fabric8.gateway.handlers.detecting.protocol.openwire.support.OpenwireException)

Example 17 with OpenwireException

use of io.fabric8.gateway.handlers.detecting.protocol.openwire.support.OpenwireException in project fabric8 by jboss-fuse.

the class ActiveMQBlobMessage method onSend.

public void onSend() throws OpenwireException {
    super.onSend();
    // message
    if (blobUploader != null) {
        try {
            URL value = blobUploader.upload(this);
            setURL(value);
        } catch (IOException e) {
            throw new OpenwireException(e);
        }
    }
}
Also used : OpenwireException(io.fabric8.gateway.handlers.detecting.protocol.openwire.support.OpenwireException) IOException(java.io.IOException) URL(java.net.URL)

Example 18 with OpenwireException

use of io.fabric8.gateway.handlers.detecting.protocol.openwire.support.OpenwireException in project fabric8 by jboss-fuse.

the class ActiveMQBytesMessage method readBytes.

public int readBytes(byte[] value, int length) throws OpenwireException {
    initializeReading();
    try {
        int n = 0;
        while (n < length) {
            int count = this.dataIn.read(value, n, length - n);
            if (count < 0) {
                break;
            }
            n += count;
        }
        if (n == 0 && length > 0) {
            n = -1;
        }
        return n;
    } catch (EOFException e) {
        throw new OpenwireException(e);
    } catch (IOException e) {
        throw new OpenwireException(e);
    }
}
Also used : OpenwireException(io.fabric8.gateway.handlers.detecting.protocol.openwire.support.OpenwireException)

Example 19 with OpenwireException

use of io.fabric8.gateway.handlers.detecting.protocol.openwire.support.OpenwireException in project fabric8 by jboss-fuse.

the class ActiveMQBytesMessage method initializeReading.

private void initializeReading() throws OpenwireException {
    checkWriteOnlyBody();
    if (dataIn == null) {
        Buffer data = getContent();
        if (data == null) {
            data = new Buffer(new byte[] {}, 0, 0);
        }
        InputStream is = new ByteArrayInputStream(data);
        if (isCompressed()) {
            // we are compressed.
            try {
                DataInputStream dis = new DataInputStream(is);
                length = dis.readInt();
                dis.close();
            } catch (IOException e) {
                throw new OpenwireException(e);
            }
            is = new InflaterInputStream(is);
        } else {
            length = data.getLength();
        }
        dataIn = new DataInputStream(is);
    }
}
Also used : Buffer(org.fusesource.hawtbuf.Buffer) OpenwireException(io.fabric8.gateway.handlers.detecting.protocol.openwire.support.OpenwireException) ByteArrayInputStream(org.fusesource.hawtbuf.ByteArrayInputStream) ByteArrayInputStream(org.fusesource.hawtbuf.ByteArrayInputStream) InflaterInputStream(java.util.zip.InflaterInputStream) InflaterInputStream(java.util.zip.InflaterInputStream)

Example 20 with OpenwireException

use of io.fabric8.gateway.handlers.detecting.protocol.openwire.support.OpenwireException in project fabric8 by jboss-fuse.

the class ActiveMQMessage method setObjectProperty.

public void setObjectProperty(String name, Object value, boolean checkReadOnly) throws OpenwireException {
    if (checkReadOnly) {
        checkReadOnlyProperties();
    }
    if (name == null || name.equals("")) {
        throw new IllegalArgumentException("Property name cannot be empty or null");
    }
    checkValidObject(value);
    PropertySetter setter = JMS_PROPERTY_SETERS.get(name);
    if (setter != null && value != null) {
        setter.set(this, value);
    } else {
        try {
            this.setProperty(name, value);
        } catch (IOException e) {
            throw new OpenwireException(e);
        }
    }
}
Also used : OpenwireException(io.fabric8.gateway.handlers.detecting.protocol.openwire.support.OpenwireException) IOException(java.io.IOException)

Aggregations

OpenwireException (io.fabric8.gateway.handlers.detecting.protocol.openwire.support.OpenwireException)18 OpenwireException (io.fabric8.gateway.handlers.detecting.protocol.openwire.OpenwireException)3 InflaterInputStream (java.util.zip.InflaterInputStream)3 Buffer (org.fusesource.hawtbuf.Buffer)3 ByteArrayInputStream (org.fusesource.hawtbuf.ByteArrayInputStream)3 IOException (java.io.IOException)2 UTF8Buffer (org.fusesource.hawtbuf.UTF8Buffer)2 Constructor (java.lang.reflect.Constructor)1 URL (java.net.URL)1 Deflater (java.util.zip.Deflater)1 DeflaterOutputStream (java.util.zip.DeflaterOutputStream)1 ByteArrayOutputStream (org.fusesource.hawtbuf.ByteArrayOutputStream)1