protected UMOMessage aggregateEvents(EventGroup events) throws RoutingException { StringBuffer newPayload = new StringBuffer(); UMOEvent event = null; for (Iterator iterator = events.getEvents().iterator(); iterator.hasNext(); ) { event = (UMOEvent) iterator.next(); try { newPayload.append(event.getMessageAsString()).append(" "); } catch (UMOException e) { throw new RoutingException(event.getMessage(), event.getEndpoint(), e); } } return new MuleMessage(newPayload.toString(), event.getProperties()); }
/** * Sets a property associated with the current event. Calling this method is equivilent to calling * <code>event.getMessage().setProperty(..., ...)</code> * * @param name the property name or key * @param value the property value */ public void setProperty(String name, Object value) { event.setProperty(name, value); }
/** * Returns the message transformed into it's recognised or expected format and then into a String. * 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 a Strings. * @throws org.mule.umo.transformer.TransformerException if a failure occurs in the transformer * @see org.mule.umo.transformer.UMOTransformer */ public String getTransformedMessageAsString() throws TransformerException { return event.getTransformedMessageAsString(); }
/** * Returns the message transformed into it's recognised or expected format. 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. * @throws org.mule.umo.transformer.TransformerException if a failure occurs in the transformer * @see org.mule.umo.transformer.UMOTransformer */ public Object getTransformedMessage() throws TransformerException { return event.getTransformedMessage(); }
public UMOEndpointURI getEndpointURI() { return event.getEndpoint().getEndpointURI(); }
/** * Reterns the conents of the message as a byte array. * * @return the conents of the message as a byte array * @throws org.mule.umo.UMOException if the message cannot be converted into an array of bytes */ public byte[] getMessageAsBytes() throws UMOException { return event.getMessageAsBytes(); }
/** * Returns a map of properties associated with the event * * @return a map of properties on the event */ public Map getProperties() { return event.getProperties(); }
/** * Sets a Long property associated with the current event. Calling this method is equivilent to * calling <code>event.getMessage().setLongProperty(..., ...)</code> * * @param name the property name or key * @param value the property value */ public void setLongProperty(String name, long value) { event.setLongProperty(name, value); }
/** * Gets a property associated with the current event. Calling this method is equivilent to calling * <code>event.getMessage().getProperty(...)</code> * * @param name the property name * @return the property value or null if the property does not exist */ public Object getProperty(String name) { return event.getProperty(name); }
/** @return the component descriptor of the component that received this event */ public UMODescriptor getComponentDescriptor() { return event.getComponent().getDescriptor(); }
MuleEventContext(UMOEvent event) { this.event = event; this.session = event.getSession(); }
/** * This will dispatch an event asynchronously via the configured outbound endpoint on the * component for this session * * @param message payload to dispatch * @throws org.mule.umo.UMOException if there is no outbound endpoint configured on the component * or the events fails during dispatch */ public void dispatchEvent(Object message) throws UMOException { session.dispatchEvent(new MuleMessage(message, event.getProperties())); }
/** * Depending on the session state this methods either Passes an event synchronously to the next * available Mule UMO in the pool or via the endpoint configured for the event * * @param message the message payload to send * @return the return Message from the call or null if there was no result * @throws org.mule.umo.UMOException if the event fails to be processed by the component or the * transport for the endpoint */ public UMOMessage sendEvent(UMOMessage message) throws UMOException { // If synchronous receive has not been explicitly set, default it to // true setRemoteSync(message, event.getEndpoint()); return session.sendEvent(message); }
/** * This will send an event via the configured outbound router on the component * * @param message the message to send * @return the result of the send if any * @throws org.mule.umo.UMOException if there is no outbound endpoint configured on the component * or the events fails during dispatch */ public UMOMessage sendEvent(Object message) throws UMOException { return sendEvent(new MuleMessage(message, event.getProperties())); }
/** * Returns the message contents as a string * * @return the message contents as a string * @throws org.mule.umo.UMOException if the message cannot be converted into a string */ public String getMessageAsString() throws UMOException { return event.getMessageAsString(); }
/** * Sets a Boolean property associated with the current event. Calling this method is equivilent to * calling <code>event.getMessage().setBooleanProperty(..., ...)</code> * * @param name the property name or key * @param value the property value */ public void setBooleanProperty(String name, boolean value) { event.setBooleanProperty(name, value); }
/** * Sets an Integer property associated with the current event. Calling this method is equivilent * to calling <code>event.getMessage().setIntProperty(..., ...)</code> * * @param name the property name or key * @param value the property value */ public void setIntProperty(String name, int value) { event.setIntProperty(name, value); }
/** * Gets a property associated with the current event. Calling this method is equivilent to calling * <code>event.getMessage().getProperty(..., ...)</code> * * @param name the property name * @param defaultValue a default value if the property doesn't exist in the event * @return the property value or the defaultValue if the property does not exist */ public Object getProperty(String name, Object defaultValue) { return event.getProperty(name, defaultValue); }
/** * Sets a Double property associated with the current event. Calling this method is equivilent to * calling <code>event.getMessage().setDoubleProperty(..., ...)</code> * * @param name the property name or key * @param value the property value */ public void setDoubleProperty(String name, double value) { event.setDoubleProperty(name, value); }
/** * Gets an Integer property associated with the current event. Calling this method is equivilent * to calling <code>event.getMessage().getIntProperty(..., ...)</code> * * @param name the property name * @param defaultValue a default value if the property doesn't exist in the event * @return the property value or the defaultValue if the property does not exist */ public int getIntProperty(String name, int defaultValue) { return event.getIntProperty(name, defaultValue); }
/** * An outputstream the can optionally be used write response data to an incoming message. * * @return an output strem if one has been made available by the message receiver that received * the message */ public OutputStream getOutputStream() { return event.getOutputStream(); }
/** * Gets a Long property associated with the current event. Calling this method is equivilent to * calling <code>event.getMessage().getLongProperty(..., ...)</code> * * @param name the property name * @param defaultValue a default value if the property doesn't exist in the event * @return the property value or the defaultValue if the property does not exist */ public long getLongProperty(String name, long defaultValue) { return event.getLongProperty(name, defaultValue); }
/** * Determines whether the was sent synchrounously or not * * @return true if the event is synchronous */ public boolean isSynchronous() { return event.isSynchronous(); }
/** * Gets a Double property associated with the current event. Calling this method is equivilent to * calling <code>event.getMessage().getDoubleProperty(..., ...)</code> * * @param name the property name * @param defaultValue a default value if the property doesn't exist in the event * @return the property value or the defaultValue if the property does not exist */ public double getDoubleProperty(String name, double defaultValue) { return event.getDoubleProperty(name, defaultValue); }
/** * Get the timeout value associated with the event * * @return the timeout for the event */ public int getTimeout() { return event.getTimeout(); }
/** * Gets a Boolean property associated with the current event. Calling this method is equivilent to * calling <code>event.getMessage().getbooleanProperty(..., ...)</code> * * @param name the property name * @param defaultValue a default value if the property doesn't exist in the event * @return the property value or the defaultValue if the property does not exist */ public boolean getBooleanProperty(String name, boolean defaultValue) { return event.getBooleanProperty(name, defaultValue); }
/** * Returns the message payload for this event * * @return the message payload for this event */ public UMOMessage getMessage() { return event.getMessage(); }
/** * 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.umo.transformer.TransformerException if a failure occurs in the transformer * @see org.mule.umo.transformer.UMOTransformer */ public byte[] getTransformedMessageAsBytes() throws TransformerException { return event.getTransformedMessageAsBytes(); }