@Override public void doBeforeReceive() throws Exception { bodyLength = message.getBodySize(); }
/** * Reads the body of a HornetQ {@link ClientMessage} as an Object. * * @param msg the HornetQ {@link ClientMessage}. * @return Object the object read. * @throws Exception if an error occurs while trying to read the body content. */ public Object readObjectFromMessage(final ClientMessage msg) throws Exception { byte[] bytes = new byte[msg.getBodySize()]; final HornetQBuffer bodyBuffer = msg.getBodyBuffer(); bodyBuffer.readBytes(bytes); Object result = null; try { final ObjectInputStream in = new ObjectInputStream(new ByteArrayInputStream(bytes)); result = in.readObject(); } catch (Exception e) { _logger.warn("Caught an Exception during deserializing object. Then trying to read as String"); _logger.debug("",e); result = new String(bytes); } return result; }
/** * Reads the body of a HornetQ {@link ClientMessage} as an Object. * * @param msg the HornetQ {@link ClientMessage}. * @return Object the object read. * @throws Exception if an error occurs while trying to read the body content. */ public Object readObjectFromMessage(final ClientMessage msg) throws Exception { byte[] bytes = new byte[msg.getBodySize()]; final HornetQBuffer bodyBuffer = msg.getBodyBuffer(); bodyBuffer.readBytes(bytes); Object result = null; try { final ObjectInputStream in = new ObjectInputStream(new ByteArrayInputStream(bytes)); result = in.readObject(); } catch (Exception e) { _logger.warn("Caught an Exception during deserializing object. Then trying to read as String"); _logger.debug("",e); result = new String(bytes); } return result; }
@Override public void build(Response.ResponseBuilder builder) { buildHeaders(builder); if (data == null) { int size = message.getBodySize(); if (size > 0) { data = new byte[size]; message.getBodyBuffer().readBytes(data); } else { data = new byte[0]; } } builder.entity(data); } }
int size = message.getBodySize(); if (size > 0)
public void reset() throws JMSException { if (!readOnly) { readOnly = true; bodyLength = message.getBodySize(); getBuffer().resetReaderIndex(); } else { getBuffer().resetReaderIndex(); } }
int size = message.getBodySize(); if (size > 0)
public static <T> T getEntity(ClientMessage msg, Class<T> type, Type genericType, ResteasyProviderFactory factory) int size = msg.getBodySize(); if (size <= 0) return null;