Ejemplo n.º 1
0
 /**
  * Converts the message implementation into a String representation
  *
  * @return String representation of the message
  * @throws Exception Implemetation may throw an endpoint specific exception
  */
 public byte[] getPayloadAsBytes() throws Exception {
   if (out instanceof ByteArrayOutputStream) {
     return ((ByteArrayOutputStream) out).toByteArray();
   } else {
     logger.warn("Attempting to get the bytes of a non-ByteArray output stream");
     return StringMessageUtils.getBytes(out.toString());
   }
 }
Ejemplo n.º 2
0
  public OutStreamMessageAdapter(Object message) throws MessageTypeNotSupportedException {
    try {
      if (message instanceof OutputStream) {
        out = (OutputStream) message;
      } else if (message instanceof String) {
        out = new ByteArrayOutputStream(message.toString().length());
        out.write(StringMessageUtils.getBytes(message.toString()));
      } else if (message instanceof byte[]) {
        out = new ByteArrayOutputStream(((byte[]) message).length);
        out.write((byte[]) message);

      } else {
        throw new MessageTypeNotSupportedException(message, getClass());
      }
    } catch (IOException e) {
      throw new MessageTypeNotSupportedException(message, getClass(), e);
    }
  }
Ejemplo n.º 3
0
 public void write(String string, int offset, int len) throws IOException {
   out.write(StringMessageUtils.getBytes(string), offset, len);
 }
Ejemplo n.º 4
0
 public void write(String string) throws IOException {
   out.write(StringMessageUtils.getBytes(string));
 }