use of io.fabric8.gateway.handlers.detecting.protocol.openwire.support.OpenwireException in project fabric8 by jboss-fuse.
the class ActiveMQBytesMessage method initializeWriting.
private void initializeWriting() throws OpenwireException {
checkReadOnlyBody();
if (this.dataOut == null) {
this.bytesOut = new ByteArrayOutputStream();
OutputStream os = bytesOut;
if (Settings.enable_compression()) {
// we are compressed.
try {
os.write(new byte[4]);
} catch (IOException e) {
throw new OpenwireException(e);
}
length = 0;
compressed = true;
final Deflater deflater = new Deflater(Deflater.BEST_SPEED);
os = new FilterOutputStream(new DeflaterOutputStream(os, deflater)) {
public void write(byte[] arg0) throws IOException {
length += arg0.length;
out.write(arg0);
}
public void write(byte[] arg0, int arg1, int arg2) throws IOException {
length += arg2;
out.write(arg0, arg1, arg2);
}
public void write(int arg0) throws IOException {
length++;
out.write(arg0);
}
@Override
public void close() throws IOException {
super.close();
deflater.end();
}
};
}
this.dataOut = new DataOutputStream(os);
}
}
use of io.fabric8.gateway.handlers.detecting.protocol.openwire.support.OpenwireException in project fabric8 by jboss-fuse.
the class ActiveMQMapMessage method loadContent.
/**
* Builds the message body from data
*
* @throws OpenwireException
*/
private void loadContent() throws OpenwireException {
try {
if (getContent() != null && map.isEmpty()) {
Buffer content = getContent();
InputStream is = new ByteArrayInputStream(content);
if (isCompressed()) {
is = new InflaterInputStream(is);
}
DataInputStream dataIn = new DataInputStream(is);
map = MarshallingSupport.unmarshalPrimitiveMap(dataIn);
dataIn.close();
}
} 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 BaseDataStreamMarshaller method looseMarshalThrowable.
protected void looseMarshalThrowable(OpenWireFormat wireFormat, Throwable o, DataByteArrayOutputStream dataOut) throws IOException {
dataOut.writeBoolean(o != null);
if (o != null) {
String className = o instanceof OpenwireException ? ((OpenwireException) o).getClassName() : o.getClass().getName();
looseMarshalString(new UTF8Buffer(className), dataOut);
looseMarshalString(new UTF8Buffer(o.getMessage()), dataOut);
if (wireFormat.isStackTraceEnabled()) {
StackTraceElement[] stackTrace = o.getStackTrace();
dataOut.writeShort(stackTrace.length);
for (int i = 0; i < stackTrace.length; i++) {
StackTraceElement element = stackTrace[i];
looseMarshalString(new UTF8Buffer(element.getClassName()), dataOut);
looseMarshalString(new UTF8Buffer(element.getMethodName()), dataOut);
looseMarshalString(new UTF8Buffer(element.getFileName()), dataOut);
dataOut.writeInt(element.getLineNumber());
}
looseMarshalThrowable(wireFormat, o.getCause(), dataOut);
}
}
}
use of io.fabric8.gateway.handlers.detecting.protocol.openwire.support.OpenwireException in project fabric8 by jboss-fuse.
the class BaseDataStreamMarshaller method tightMarshalThrowable2.
protected void tightMarshalThrowable2(OpenWireFormat wireFormat, Throwable o, DataByteArrayOutputStream dataOut, BooleanStream bs) throws IOException {
if (bs.readBoolean()) {
String className = o instanceof OpenwireException ? ((OpenwireException) o).getClassName() : o.getClass().getName();
tightMarshalString2(new UTF8Buffer(className), dataOut, bs);
tightMarshalString2(new UTF8Buffer(o.getMessage()), dataOut, bs);
if (wireFormat.isStackTraceEnabled()) {
StackTraceElement[] stackTrace = o.getStackTrace();
dataOut.writeShort(stackTrace.length);
for (int i = 0; i < stackTrace.length; i++) {
StackTraceElement element = stackTrace[i];
tightMarshalString2(new UTF8Buffer(element.getClassName()), dataOut, bs);
tightMarshalString2(new UTF8Buffer(element.getMethodName()), dataOut, bs);
tightMarshalString2(new UTF8Buffer(element.getFileName()), dataOut, bs);
dataOut.writeInt(element.getLineNumber());
}
tightMarshalThrowable2(wireFormat, o.getCause(), dataOut, bs);
}
}
}
use of io.fabric8.gateway.handlers.detecting.protocol.openwire.support.OpenwireException in project fabric8 by jboss-fuse.
the class ActiveMQStreamMessage method readByte.
public byte readByte() throws OpenwireException {
initializeReading();
try {
this.dataIn.mark(10);
int type = this.dataIn.read();
if (type == -1) {
throw new OpenwireException("reached end of data");
}
if (type == MarshallingSupport.BYTE_TYPE) {
return this.dataIn.readByte();
}
if (type == MarshallingSupport.STRING_TYPE) {
return Byte.valueOf(this.dataIn.readUTF()).byteValue();
}
if (type == MarshallingSupport.NULL) {
this.dataIn.reset();
throw new NullPointerException("Cannot convert NULL value to byte.");
} else {
this.dataIn.reset();
throw new OpenwireException(" not a byte 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);
}
}
Aggregations