/** * Returns the message transformed into its recognised or expected format. The * transformer used is the one configured on the endpoint through which this * event was received. * * @param dataType The dataType required for the return object. This param * just provides a convienient way to manage type casting of * transformed objects * @return the message transformed into it's recognised or expected format. * @throws org.mule.api.transformer.TransformerException if a failure occurs or * if the return type is not the same as the expected type in the * transformer * @see org.mule.api.transformer.Transformer */ public Object transformMessage(DataType dataType) throws TransformerException { return event.transformMessage(dataType); }
/** * Returns the message transformed into it's recognised or expected format and * then into an array of bytes. The transformer used is the one configured on the * endpoint through which this event was received. * * @return the message transformed into it's recognised or expected format as an * array of bytes. * @throws org.mule.api.transformer.TransformerException if a failure occurs in * the transformer * @see org.mule.api.transformer.Transformer * @deprecated use {@link #transformMessage(org.mule.api.transformer.DataType)} instead */ @Deprecated public byte[] transformMessageToBytes() throws TransformerException { return event.transformMessage(DataType.BYTE_ARRAY_DATA_TYPE); }
/** * Returns the message transformed into its recognised or expected format. The * transformer used is the one configured on the endpoint through which this * event was received. * * @param expectedType The class type required for the return object. This param * just provides a convienient way to manage type casting of * transformed objects * @return the message transformed into it's recognised or expected format. * @throws org.mule.api.transformer.TransformerException if a failure occurs or * if the return type is not the same as the expected type in the * transformer * @see org.mule.api.transformer.Transformer */ public Object transformMessage(Class expectedType) throws TransformerException { return event.transformMessage(DataTypeFactory.create(expectedType)); }
/** * Gets the stream representation of the current message. * * @param context the event context * @return The inputstream for the current message * @throws MuleException */ protected InputStream getMessageStream(MuleEvent context) throws MuleException { InputStream is; Object eventMsgPayload = context.getMessage().getPayload(); if (eventMsgPayload instanceof InputStream) { is = (InputStream) eventMsgPayload; } else { is = context.transformMessage(DataTypeFactory.create(InputStream.class)); } return is; }
protected HttpMethod createEntityMethod(MuleEvent event, Object body, EntityEnclosingMethod postMethod) throws TransformerException { HttpMethod httpMethod; if (body instanceof String) { httpMethod = (HttpMethod) sendTransformer.transform(body.toString()); } else if (body instanceof byte[]) { byte[] buffer = event.transformMessage(DataType.BYTE_ARRAY_DATA_TYPE); postMethod.setRequestEntity(new ByteArrayRequestEntity(buffer, event.getEncoding())); httpMethod = postMethod; } else { if (!(body instanceof OutputHandler)) { body = event.transformMessage(DataTypeFactory.create(OutputHandler.class)); } OutputHandler outputHandler = (OutputHandler) body; postMethod.setRequestEntity(new StreamPayloadRequestEntity(outputHandler, event)); postMethod.setContentChunked(true); httpMethod = postMethod; } return httpMethod; }
InputStream is = event.transformMessage(DataTypeFactory.create(InputStream.class)); IOUtils.copyLarge(is, fos); is.close();
@Override protected synchronized void doDispatch(MuleEvent event) throws Exception { DatagramSocket socket = connector.getSocket(endpoint); try { byte[] payload = event.transformMessage(DataType.BYTE_ARRAY_DATA_TYPE); int port = endpoint.getEndpointURI().getPort(); InetAddress inetAddress = null; //TODO, check how expensive this operation is if("null".equalsIgnoreCase(endpoint.getEndpointURI().getHost())) { inetAddress = NetworkUtils.getLocalHost(); } else { inetAddress = InetAddress.getByName(endpoint.getEndpointURI().getHost()); } write(socket, payload, port, inetAddress); } finally { connector.releaseSocket(socket, endpoint); } }
InputStream is = ctx.transformMessage(DataTypeFactory.create(InputStream.class)); m.put(Message.ENCODING, ctx.getEncoding()); m.setContent(InputStream.class, is);