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);
}
}
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);
}
}
}
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);
}
}
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);
}
}
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);
}
}
}
Aggregations