Discussion:
[mule-scm] [mule][23797] branches/mule-3.x: Move invocation properties (flow variables ) up to MuleEvent (MULE-5900)
Pablo La Greca
2012-02-02 16:22:41 UTC
Permalink
Can you define getFlowVariable and getSessionVariable with generics? So
client code do not requiere casting.
**
Revision 23797 <http://fisheye.codehaus.org/changelog/mule/?cs=23797>
Author dfeist Date 2012-02-01 22:07:49 -0600 (Wed, 01 Feb 2012) Log
Message
Move invocation properties (flow variables) up to MuleEvent (MULE-5900)
Modified Paths
- branches/mule-3.x/core/src/main/java/org/mule/DefaultMuleEvent.java<#1353c3f3879fd51f_branchesmule3xcoresrcmainjavaorgmuleDefaultMuleEventjava>
- branches/mule-3.x/core/src/main/java/org/mule/DefaultMuleMessage.java<#1353c3f3879fd51f_branchesmule3xcoresrcmainjavaorgmuleDefaultMuleMessagejava>
-
branches/mule-3.x/core/src/main/java/org/mule/MessagePropertiesContext.java<#1353c3f3879fd51f_branchesmule3xcoresrcmainjavaorgmuleMessagePropertiesContextjava>
- branches/mule-3.x/core/src/main/java/org/mule/api/MuleEvent.java<#1353c3f3879fd51f_branchesmule3xcoresrcmainjavaorgmuleapiMuleEventjava>
- branches/mule-3.x/core/src/main/java/org/mule/api/MuleSession.java<#1353c3f3879fd51f_branchesmule3xcoresrcmainjavaorgmuleapiMuleSessionjava>
-
branches/mule-3.x/core/src/main/java/org/mule/enricher/MessageEnricher.java<#1353c3f3879fd51f_branchesmule3xcoresrcmainjavaorgmuleenricherMessageEnricherjava>
-
branches/mule-3.x/core/src/main/java/org/mule/routing/DefaultRouterResultsHandler.java<#1353c3f3879fd51f_branchesmule3xcoresrcmainjavaorgmuleroutingDefaultRouterResultsHandlerjava>
- branches/mule-3.x/core/src/main/java/org/mule/routing/EventGroup.java<#1353c3f3879fd51f_branchesmule3xcoresrcmainjavaorgmuleroutingEventGroupjava>
- branches/mule-3.x/core/src/main/java/org/mule/routing/WireTap.java<#1353c3f3879fd51f_branchesmule3xcoresrcmainjavaorgmuleroutingWireTapjava>
-
branches/mule-3.x/core/src/main/java/org/mule/routing/correlation/CollectionCorrelatorCallback.java<#1353c3f3879fd51f_branchesmule3xcoresrcmainjavaorgmuleroutingcorrelationCollectionCorrelatorCallbackjava>
-
branches/mule-3.x/core/src/main/java/org/mule/session/DefaultMuleSession.java<#1353c3f3879fd51f_branchesmule3xcoresrcmainjavaorgmulesessionDefaultMuleSessionjava>
-
branches/mule-3.x/core/src/main/java/org/mule/transport/AbstractMessageDispatcher.java<#1353c3f3879fd51f_branchesmule3xcoresrcmainjavaorgmuletransportAbstractMessageDispatcherjava>
-
branches/mule-3.x/core/src/main/java/org/mule/work/AbstractMuleEventWork.java<#1353c3f3879fd51f_branchesmule3xcoresrcmainjavaorgmuleworkAbstractMuleEventWorkjava>
-
branches/mule-3.x/core/src/test/java/org/mule/registry/RequestContextTestCase.java<#1353c3f3879fd51f_branchesmule3xcoresrctestjavaorgmuleregistryRequestContextTestCasejava>
-
branches/mule-3.x/core/src/test/java/org/mule/routing/SimpleCollectionAggregatorTestCase.java<#1353c3f3879fd51f_branchesmule3xcoresrctestjavaorgmuleroutingSimpleCollectionAggregatorTestCasejava>
-
branches/mule-3.x/core/src/test/java/org/mule/routing/outbound/OutboundRoutingTestEvent.java<#1353c3f3879fd51f_branchesmule3xcoresrctestjavaorgmuleroutingoutboundOutboundRoutingTestEventjava>
-
branches/mule-3.x/core/src/test/java/org/mule/session/InvocationPropertiesTestCase.java<#1353c3f3879fd51f_branchesmule3xcoresrctestjavaorgmulesessionInvocationPropertiesTestCasejava>
-
branches/mule-3.x/tests/integration/src/test/java/org/mule/api/annotations/param/InboundHeadersAnnotationTestCase.java<#1353c3f3879fd51f_branchesmule3xtestsintegrationsrctestjavaorgmuleapiannotationsparamInboundHeadersAnnotationTestCasejava>
-
branches/mule-3.x/tests/integration/src/test/java/org/mule/properties/InvocationPropertiesTestCase.java<#1353c3f3879fd51f_branchesmule3xtestsintegrationsrctestjavaorgmulepropertiesInvocationPropertiesTestCasejava>
-
branches/mule-3.x/tests/integration/src/test/java/org/mule/test/properties/PropertiesTestCase.java<#1353c3f3879fd51f_branchesmule3xtestsintegrationsrctestjavaorgmuletestpropertiesPropertiesTestCasejava>
-
branches/mule-3.x/tests/integration/src/test/resources/org/mule/properties/invocation-properties-config.xml<#1353c3f3879fd51f_branchesmule3xtestsintegrationsrctestresourcesorgmulepropertiesinvocationpropertiesconfigxml>
-
branches/mule-3.x/transports/vm/src/main/java/org/mule/transport/vm/VMMessageDispatcher.java<#1353c3f3879fd51f_branchesmule3xtransportsvmsrcmainjavaorgmuletransportvmVMMessageDispatcherjava>
Diff
branches/mule-3.x/core/src/main/java/org/mule/DefaultMuleEvent.java (23796
=> 23797)
--- branches/mule-3.x/core/src/main/java/org/mule/DefaultMuleEvent.java 2012-02-02 02:55:49 UTC (rev 23796)
- {
- ((DefaultMuleMessage) message).setSessionProperties(session.getProperties());
- InboundEndpoint endpoint,
- {
- ((DefaultMuleMessage) message).setSessionProperties(session.getProperties());
- FlowConstruct flowConstruct,
- MuleSession session,
- boolean synchronous)+ MuleEvent rewriteEvent,
+ FlowConstruct flowConstruct,
+ MuleSession session,
- {
- ((DefaultMuleMessage) message).setSessionProperties(session.getProperties());
- }
- {
- ((DefaultMuleMessage) message).setSessionProperties(session.getProperties());
+ {
+ Object value = entry.getValue();
+ if (value != null && !(value instanceof Serializable))
+ {
+ String message = String.format(
+ "Unable to serialize the flow variable %s, which is of type %s ", entry.getKey(), value);
+ logger.error(message);
+ throw new IOException(message);
+ }
+ }
+ public void setMessage(MuleMessage message)
+ {
+ this.message = message;
+ if (message instanceof DefaultMuleMessage)
+ {
+ for (String name : message.getInvocationPropertyNames())
+ {
+ setFlowVariable(name, message.getInvocationProperty(name));
+ }
+ ((DefaultMuleMessage) message).setInvocationProperties(flowVariables);
+ if (session instanceof DefaultMuleSession)
+ {
+ ((DefaultMuleMessage) message).setSessionProperties(((DefaultMuleSession) session).getProperties());
+ }
+ }
+ }
+
+ public static MuleEvent copy(MuleEvent event)
+ {
+ MuleMessage messageCopy = (MuleMessage) ((ThreadSafeAccess) event.getMessage()).newThreadCopy();
+ DefaultMuleEvent eventCopy = new DefaultMuleEvent(messageCopy, event, new DefaultMuleSession(
+ event.getSession()));
+ eventCopy.flowVariables = new CaseInsensitiveHashMap(((DefaultMuleEvent) event).flowVariables);
+ ((DefaultMuleMessage) messageCopy).setInvocationProperties(eventCopy.flowVariables);
+ ((DefaultMuleMessage) messageCopy).resetAccessControl();
+ return eventCopy;
+ }
+
+ public Set<String> getFlowVariableNames()
+ {
+ return flowVariables.keySet();
+ }
+
+ public void clearFlowVariables()
+ {
+ flowVariables.clear();
+ }
+
+ public Object getFlowVariable(String key)
+ {
+ return flowVariables.get(key);
+ }
+
+ public void setFlowVariable(String key, Object value)
+ {
+ flowVariables.put(key, value);
+ }
+
+ public void removeFlowVariable(String key)
+ {
+ flowVariables.remove(key);
+ }
+
+ public Object getSessionVariable(String key)
+ {
+ return session.getProperty(key);
+ }
+
+ public void setSessionVariable(String key, Object value)
+ {
+ session.setProperty(key, value);
+ }
+
+ public void removeSessionVariable(String key)
+ {
+ session.removeProperty(key);
+ }
+
+ public Set<String> getSessionVariableNames()
+ {
+ return session.getPropertyNamesAsSet();
+ }
+
+ public void clearSessionVariables()
+ {
+ session.clearProperties();
+ } }
branches/mule-3.x/core/src/main/java/org/mule/DefaultMuleMessage.java
(23796 => 23797)
--- branches/mule-3.x/core/src/main/java/org/mule/DefaultMuleMessage.java 2012-02-02 02:55:49 UTC (rev 23796)
+ {
+ setInvocationProperties(((DefaultMuleMessage) previous).properties.invocationMap);
+ setSessionProperties(((DefaultMuleMessage) previous).properties.sessionMap);
+ }
+ void setInvocationProperties(Map<String, Object> invocationProperties)
+ {
+ properties.invocationMap = invocationProperties;
+ }
+ }
branches/mule-3.x/core/src/main/java/org/mule/MessagePropertiesContext.java
(23796 => 23797)
--- branches/mule-3.x/core/src/main/java/org/mule/MessagePropertiesContext.java 2012-02-02 02:55:49 UTC (rev 23796)
+ {
+ return invocationMap;
+ {
+ for (Map.Entry<String, Object> entry : invocationMap.entrySet())
+ {
+ Object value = entry.getValue();
+ if (value != null && !(value instanceof Serializable))
+ {
+ String message = String.format(
+ "Unable to serialize the invocation message property %s, which is of type %s ",
+ entry.getKey(), value);
+ logger.error(message);
+ throw new IOException(message);
+ }
+ }
- + "but a MuleEvent hasn't been created useing this message yet. Key/value: %s=%s",+ "Detected an attempt to set a invocation or session property, "
- + "but a MuleEvent hasn't been created useing this message yet. Key: %s", key));+ "Detected an attempt to get a invocation or session property, "
+ + "but a MuleEvent hasn't been created using this message yet. Key: %s", key)); return null; } } + private static class UndefinedInvocationPropertiesMap extends CaseInsensitiveHashMap
+ {
+ private static final long serialVersionUID = 8400889672358403911L;
+
+ }
+ }
branches/mule-3.x/core/src/main/java/org/mule/api/MuleEvent.java (23796 =>
23797)
--- branches/mule-3.x/core/src/main/java/org/mule/api/MuleEvent.java 2012-02-02 02:55:49 UTC (rev 23796)
+
+ Object getFlowVariable(String key);
+
+ void setFlowVariable(String key, Object value);
+
+ void removeFlowVariable(String key);
+
+ Set<String> getFlowVariableNames();
+
+ void clearFlowVariables();
+
+ Object getSessionVariable(String key);
+
+ void setSessionVariable(String key, Object value);
+
+ void removeSessionVariable(String key);
+
+ Set<String> getSessionVariableNames();
+
+ void clearSessionVariables();
+ }
branches/mule-3.x/core/src/main/java/org/mule/api/MuleSession.java (23796
=> 23797)
--- branches/mule-3.x/core/src/main/java/org/mule/api/MuleSession.java 2012-02-02 02:55:49 UTC (rev 23796)
+ }
branches/mule-3.x/core/src/main/java/org/mule/enricher/MessageEnricher.java
(23796 => 23797)
--- branches/mule-3.x/core/src/main/java/org/mule/enricher/MessageEnricher.java 2012-02-02 02:55:49 UTC (rev 23796)
+ OptimizedRequestContext.unsafeSetEvent(enricherEvent);
+ MuleEvent enrichmentEvent = enrichmentProcessor.process(enricherEvent);
branches/mule-3.x/core/src/main/java/org/mule/routing/DefaultRouterResultsHandler.java
(23796 => 23797)
--- branches/mule-3.x/core/src/main/java/org/mule/routing/DefaultRouterResultsHandler.java 2012-02-02 02:55:49 UTC (rev 23796)
- return RequestContext.setEvent(new DefaultMuleEvent(coll, previous, previous.getSession()));+ MuleEvent resultEvent = new DefaultMuleEvent(coll, previous, previous.getSession());
+ for (String name : previous.getFlowVariableNames())
+ {
+ resultEvent.setFlowVariable(name, previous.getFlowVariable(name));
+ }
+ return OptimizedRequestContext.unsafeSetEvent(resultEvent); } }
branches/mule-3.x/core/src/main/java/org/mule/routing/EventGroup.java
(23796 => 23797)
--- branches/mule-3.x/core/src/main/java/org/mule/routing/EventGroup.java 2012-02-02 02:55:49 UTC (rev 23796)
- ((MuleEvent) events.retrieve(events.allKeys().get(i))).getSession().getProperties());+ MuleEvent event = events.retrieve(key);
+ for (String name : event.getSession().getPropertyNamesAsSet())
+ {
+ session.setProperty(name, event.getSession().getProperty(name));
+ } } return session; }
branches/mule-3.x/core/src/main/java/org/mule/routing/WireTap.java (23796
=> 23797)
--- branches/mule-3.x/core/src/main/java/org/mule/routing/WireTap.java 2012-02-02 02:55:49 UTC (rev 23796)
- RequestContext.setEvent(null);
- filteredTap.process(RequestContext.setEvent(event));+ MuleEvent tapEvent = DefaultMuleEvent.copy(event);
+ OptimizedRequestContext.unsafeSetEvent(tapEvent);
+ filteredTap.process(tapEvent);
+ OptimizedRequestContext.unsafeSetEvent(event); } catch (MuleException e) {
branches/mule-3.x/core/src/main/java/org/mule/routing/correlation/CollectionCorrelatorCallback.java
(23796 => 23797)
--- branches/mule-3.x/core/src/main/java/org/mule/routing/correlation/CollectionCorrelatorCallback.java 2012-02-02 02:55:49 UTC (rev 23796)
- * true. Once this method returns an aggregated message, the event group is
- * removed from the router.+ * This method is invoked if the shouldAggregate method is called and returns true. Once this method
- * this scenario the whole event group is removed and passed to the
+ {
+ session.setProperty(name, events[i].getSession().getProperty(name));
branches/mule-3.x/core/src/main/java/org/mule/session/DefaultMuleSession.java
(23796 => 23797)
--- branches/mule-3.x/core/src/main/java/org/mule/session/DefaultMuleSession.java 2012-02-02 02:55:49 UTC (rev 23796)
- * session
- *
- * session+ * Returns an iterater of property keys for the session properties on this session
+ *
+ public void clearProperties()
+ {
+ properties.clear();
+ }
+ }
branches/mule-3.x/core/src/main/java/org/mule/transport/AbstractMessageDispatcher.java
(23796 => 23797)
--- branches/mule-3.x/core/src/main/java/org/mule/transport/AbstractMessageDispatcher.java 2012-02-02 02:55:49 UTC (rev 23796)
- * send messages over over a specific transport. Different implementations may
- * support different Message Exchange Patterns.+ * Abstract implementation of an outbound channel adaptors. Outbound channel adaptors send messages over over
+ * a specific transport. Different implementations may support different Message Exchange Patterns. */-public abstract class AbstractMessageDispatcher extends AbstractTransportMessageHandler implements MessageDispatcher+public abstract class AbstractMessageDispatcher extends AbstractTransportMessageHandler
- defaultResponseTransformers = connector.getDefaultResponseTransformers(endpoint); + defaultOutboundTransformers = connector.getDefaultOutboundTransformers(endpoint);
- boolean disableTransportTransformer = (prop != null && Boolean.parseBoolean(prop)) || endpoint.isDisableTransportTransformer();
- + String prop = event.getMessage().getOutboundProperty(
+ MuleProperties.MULE_DISABLE_TRANSPORT_TRANSFORMER_PROPERTY);
+ boolean disableTransportTransformer = (prop != null && Boolean.parseBoolean(prop))
+ || endpoint.isDisableTransportTransformer();
+ resultMessage); event.getSession().merge(storedSession);- resultEvent = new DefaultMuleEvent(resultMessage, event);+ MuleEvent resultEvent = new DefaultMuleEvent(resultMessage, event); RequestContext.setEvent(resultEvent);- // TODO It seems like this should go here but it causes unwanted behaviour and breaks test cases.
- //if (!disableTransportTransformer)
- //{
- // applyResponseTransformers(resultEvent);
- //}+ return resultEvent; }+ else
+ {
+ return null;
- * to an event on a response channel after it sends the event. The following
- * rules apply:+ * Used to determine if the dispatcher implementation should wait for a response to an event on a response
+ * channel after it sends the event. The following rules apply: * <ol>- * <li>The connector has to support "back-channel" response. Some transports do
- * not have the notion of a response channel.
- * <li>Check if the endpoint is synchronous (outbound synchronicity is not
- * explicit since 2.2 and does not use the remoteSync message property).
- * <li>Or, if the send() method on the dispatcher was used. (This is required
- * because the ChainingRouter uses send() with async endpoints. See MULE-4631).
- * <li>Finally, if the current service has a response router configured, that the
- * router will handle the response channel event and we should not try and
- * receive a response in the Message dispatcher If remotesync should not be used
- * we must remove the REMOTE_SYNC header Note the MuleClient will automatically
- * set the REMOTE_SYNC header when client.send(..) is called so that results are
- * returned from remote invocations too.+ * <li>The connector has to support "back-channel" response. Some transports do not have the notion of a
+ * response channel.
+ * <li>Check if the endpoint is synchronous (outbound synchronicity is not explicit since 2.2 and does not
+ * use the remoteSync message property).
+ * <li>Or, if the send() method on the dispatcher was used. (This is required because the ChainingRouter
+ * uses send() with async endpoints. See MULE-4631).
+ * <li>Finally, if the current service has a response router configured, that the router will handle the
+ * response channel event and we should not try and receive a response in the Message dispatcher If
+ * remotesync should not be used we must remove the REMOTE_SYNC header Note the MuleClient will
+ * automatically set the REMOTE_SYNC header when client.send(..) is called so that results are returned
branches/mule-3.x/core/src/main/java/org/mule/work/AbstractMuleEventWork.java
(23796 => 23797)
--- branches/mule-3.x/core/src/main/java/org/mule/work/AbstractMuleEventWork.java 2012-02-02 02:55:49 UTC (rev 23796)
-import org.mule.api.ThreadSafeAccess;
- DefaultMuleEvent eventCopy = new DefaultMuleEvent(messageCopy, event, new DefaultMuleSession(event.getSession()));
- eventCopy.resetAccessControl();
- this.event = eventCopy;+ this.event = DefaultMuleEvent.copy(event); } public final void run()
branches/mule-3.x/core/src/test/java/org/mule/registry/RequestContextTestCase.java
(23796 => 23797)
--- branches/mule-3.x/core/src/test/java/org/mule/registry/RequestContextTestCase.java 2012-02-02 02:55:49 UTC (rev 23796)
+ public void setMessage(MuleMessage message)
+ {
+ }
+
+ public void clearFlowVariables()
+ {
+ }
+
+ public Object getFlowVariable(String key)
+ {
+ return null;
+ }
+
+ public void setFlowVariable(String key, Object value)
+ {
+ }
+
+ public void removeFlowVariable(String key)
+ {
+ }
+
+ public Set<String> getFlowVariableNames()
+ {
+ return Collections.emptySet();
+ }
+
+ public Object getSessionVariable(String key)
+ {
+ return null;
+ }
+
+ public void setSessionVariable(String key, Object value)
+ {
+ }
+
+ public void removeSessionVariable(String key)
+ {
+ }
+
+ public Set<String> getSessionVariableNames()
+ {
+ return Collections.emptySet();
+ }
+
+ public void clearSessionVariables()
+ {
+ } } }
branches/mule-3.x/core/src/test/java/org/mule/routing/SimpleCollectionAggregatorTestCase.java
(23796 => 23797)
--- branches/mule-3.x/core/src/test/java/org/mule/routing/SimpleCollectionAggregatorTestCase.java 2012-02-02 02:55:49 UTC (rev 23796)
branches/mule-3.x/core/src/test/java/org/mule/routing/outbound/OutboundRoutingTestEvent.java
(23796 => 23797)
--- branches/mule-3.x/core/src/test/java/org/mule/routing/outbound/OutboundRoutingTestEvent.java 2012-02-02 02:55:49 UTC (rev 23796)
+import java.util.Set; -/** An event used for outbound routing tests. It is not fully fleshed out, containing only the information needed for
- * routing.+/**
+ * An event used for outbound routing tests. It is not fully fleshed out, containing only the information
- public OutboundRoutingTestEvent(MuleMessage message, MuleSession session, MuleContext muleContext) throws Exception+
+ public OutboundRoutingTestEvent(MuleMessage message, MuleSession session, MuleContext muleContext)
+ public void setMessage(MuleMessage message)
+ {
+ }
+
+ public Object getFlowVariable(String key)
+ {
+ return null;
+ }
+
+ public void setFlowVariable(String key, Object value)
+ {
+ }
+
+ public void removeFlowVariable(String key)
+ {
+ }
+
+ public Set<String> getFlowVariableNames()
+ {
+ return new HashSet<String>();
+ }
+
+ public void clearFlowVariables()
+ {
+ }
+
+ public Object getSessionVariable(String key)
+ {
+ return null;
+ }
+
+ public void setSessionVariable(String key, Object value)
+ {
+ }
+
+ public void removeSessionVariable(String key)
+ {
+ }
+
+ public Set<String> getSessionVariableNames()
+ {
+ return new HashSet<String>();
+ }
+
+ public void clearSessionVariables()
+ {
+ }
+ }
branches/mule-3.x/core/src/test/java/org/mule/session/InvocationPropertiesTestCase.java
(23796 => 23797)
--- branches/mule-3.x/core/src/test/java/org/mule/session/InvocationPropertiesTestCase.java 2012-02-02 02:55:49 UTC (rev 23796)
-import java.util.List;+import java.util.Collections; import java.util.concurrent.TimeUnit; import org.apache.commons.lang.SerializationException;-import org.junit.Ignore; import org.junit.Test; public class InvocationPropertiesTestCase extends AbstractMuleContextTestCase { - /**
- * Session properties set via message API are lost and unavailable via both message and session API's.
- /** Session properties can be set with no event */
- public void setInvocationPropertyNoEvent() throws Exception+ public void setInvocationPropertyBeforeNewEvent() throws Exception { MuleMessage message = new DefaultMuleMessage("data", muleContext);- try
- {
- message.setProperty("key", "value", PropertyScope.INVOCATION);
- fail("IllegalStateException excepted");
- }
- catch (IllegalStateException e)
- {
- // Expected
- }
- catch (Exception e)
- {
- fail("IllegalStateException excepted");+ message.setProperty("key", "value", PropertyScope.INVOCATION);
+ MuleEvent event = new DefaultMuleEvent(message, MessageExchangePattern.ONE_WAY, getTestService());
+ assertEquals("value", message.getProperty("key", PropertyScope.INVOCATION));
+ assertEquals("value", event.getFlowVariable("key"));
+ } - }
-
- assertNull(message.getProperty("key", PropertyScope.INVOCATION));
+ public void setInvocationPropertyBeforeExistingEvent() throws Exception
+ {
+ MuleMessage message = new DefaultMuleMessage("data", muleContext);
+ message.setProperty("key", "value", PropertyScope.INVOCATION);
+ MuleEvent event = new DefaultMuleEvent(message, MessageExchangePattern.ONE_WAY, getTestService());
+ event.setFlowVariable("key", "VALUE");
+ event.setFlowVariable("key2", "value2");
+ assertEquals("VALUE", message.getProperty("key", PropertyScope.INVOCATION));
+ assertEquals("value2", message.getProperty("key2", PropertyScope.INVOCATION));
+ assertEquals("VALUE", event.getFlowVariable("key"));
+ assertEquals("value2", event.getFlowVariable("key2")); } - /**
- * Properties set via via message api are available via session API. But ONLY if RequestContext.setEvent()
- * is used.
- /** Currently no API to get invocation properties from MuleEvent */
- public void setInvocationPropertyOnMessageGetFromEvent() throws Exception+ public void setInvocationPropertyViaMessageAPI() throws Exception { MuleMessage message = new DefaultMuleMessage("data", muleContext); MuleEvent event = new DefaultMuleEvent(message, MessageExchangePattern.ONE_WAY, getTestService()); Object nonSerializable = new Object();- message.setProperty("key", "value", PropertyScope.SESSION);
- message.setProperty("key2", nonSerializable, PropertyScope.SESSION);
- message.setProperty("key3", "ERROR", PropertyScope.INVOCATION);
- message.setProperty("key4", "ERROR", PropertyScope.INBOUND);
- message.setProperty("key5", "ERROR", PropertyScope.OUTBOUND);+ message.setProperty("key", "value", PropertyScope.INVOCATION);
+ message.setProperty("key2", nonSerializable, PropertyScope.INVOCATION); - assertEquals(2, event.getSession().getPropertyNamesAsSet().size());
- assertEquals("value", event.getSession().getProperty("key"));
- assertEquals(nonSerializable, event.getSession().getProperty("key2"));+ assertEquals(2, event.getFlowVariableNames().size());
+ assertEquals("value", event.getFlowVariable("key"));
+ assertEquals(nonSerializable, event.getFlowVariable("key2")); } - /**
- * Properties set via via session api are available via message API. But ONLY if RequestContext.setEvent()
- * is used.
- /** Currently no API to set invocation properties on MuleEvent */
- public void setInvocationPropertyOnEventGetFromMessage() throws Exception+ public void getInvocationPropertyViaMessageAPI() throws Exception { MuleMessage message = new DefaultMuleMessage("data", muleContext); MuleEvent event = new DefaultMuleEvent(message, MessageExchangePattern.ONE_WAY, getTestService()); Object nonSerializable = new Object();- event.getSession().setProperty("key", "value");
- message.setProperty("key2", nonSerializable, PropertyScope.SESSION);+ event.setFlowVariable("key", "value");
+ event.setFlowVariable("key2", nonSerializable); - assertEquals(2, message.getPropertyNames(PropertyScope.SESSION).size());
- assertEquals("value", message.getProperty("key", PropertyScope.SESSION));
- assertEquals(nonSerializable, message.getProperty("key2", PropertyScope.SESSION));
- assertNull(message.getProperty("key", PropertyScope.INVOCATION));
- assertNull(message.getProperty("key", PropertyScope.INBOUND));
- assertNull(message.getProperty("key", PropertyScope.OUTBOUND));+ assertEquals(2, message.getPropertyNames(PropertyScope.INVOCATION).size());
+ assertEquals("value", message.getInvocationProperty("key"));
- SensingNullMessageProcessor flowListener = new SensingNullMessageProcessor();+ MuleEvent event = new DefaultMuleEvent(message, MessageExchangePattern.REQUEST_RESPONSE,
+ getTestService()); - List<MessageProcessor> processors = new ArrayList<MessageProcessor>();
- processors.add(new MessageProcessor()
- {
-
- public MuleEvent process(MuleEvent event) throws MuleException
- {
- event.getMessage().setInvocationProperty("newKey", "newValue");
- return event;
- }
- });
- processors.add(flowListener);
branches/mule-3.x/tests/integration/src/test/java/org/mule/api/annotations/param/InboundHeadersAnnotationTestCase.java
(23796 => 23797)
--- branches/mule-3.x/tests/integration/src/test/java/org/mule/api/annotations/param/InboundHeadersAnnotationTestCase.java 2012-02-02 02:55:49 UTC (rev 23796)
branches/mule-3.x/tests/integration/src/test/java/org/mule/properties/InvocationPropertiesTestCase.java
(23796 => 23797)
--- branches/mule-3.x/tests/integration/src/test/java/org/mule/properties/InvocationPropertiesTestCase.java 2012-02-02 02:55:49 UTC (rev 23796)
- /** Aggregator drops invocation properties **/ public void aggregationOfPropertiesFromMultipleMessageWithAggregator() throws Exception { List<Fruit> fruitList = new ArrayList<Fruit>();
branches/mule-3.x/tests/integration/src/test/java/org/mule/test/properties/PropertiesTestCase.java
(23796 => 23797)
--- branches/mule-3.x/tests/integration/src/test/java/org/mule/test/properties/PropertiesTestCase.java 2012-02-02 02:55:49 UTC (rev 23796)
+import static org.junit.Assert.assertNull;
-import static org.junit.Assert.assertNull;
- assertNull(response.<Object>getInvocationProperty("invocation2"));+ assertEquals("ja", response.<Object> getInvocationProperty("invocation1"));
+ assertEquals("nein", response.<Object> getInvocationProperty("invocation2")); assertEquals("123", response.getInboundProperty("outbound3")); assertEquals("456", response.getInboundProperty("outbound4"));- assertNull(response.<Object>getInvocationProperty("invocation3"));
- assertNull(response.<Object>getInvocationProperty("invocation4"));+ assertNull(response.<Object> getInvocationProperty("invocation3"));
- assertNull(response.<Object>getInvocationProperty("invocation2"));+ assertNull(response.<Object> getInvocationProperty("invocation1"));
- * by the time the message is received. Invocation properties should have been removed+ * Create a message with outbound and invocation properties. These should have been moved to the
+ * inbound scope by the time the message is received. Invocation properties should have been removed */ public MuleMessage process(Object payload) {
branches/mule-3.x/tests/integration/src/test/resources/org/mule/properties/invocation-properties-config.xml
(23796 => 23797)
--- branches/mule-3.x/tests/integration/src/test/resources/org/mule/properties/invocation-properties-config.xml 2012-02-02 02:55:49 UTC (rev 23796)
branches/mule-3.x/transports/vm/src/main/java/org/mule/transport/vm/VMMessageDispatcher.java
(23796 => 23797)
--- branches/mule-3.x/transports/vm/src/main/java/org/mule/transport/vm/VMMessageDispatcher.java 2012-02-02 02:55:49 UTC (rev 23796)
- getEndpoint());+ throw new DispatchException(CoreMessages.objectIsNull("Endpoint"), event, getEndpoint()); }- MuleMessage newMessage = event.getMessage().createInboundMessage();
- MuleEvent newEvent = new DefaultMuleEvent(newMessage, event);+ MuleEvent eventToDispatch = DefaultMuleEvent.copy(event);
+ eventToDispatch.clearFlowVariables();
- ProcessingTemplate<MuleMessage> processingTemplate = new TransactionalProcessingTemplate<MuleMessage>(event.getMuleContext(),receiver.getEndpoint().getTransactionConfig());+ MuleEvent eventToSend = DefaultMuleEvent.copy(event);
+ final MuleMessage message = eventToSend.getMessage().createInboundMessage();
+ ProcessingTemplate<MuleMessage> processingTemplate = new TransactionalProcessingTemplate<MuleMessage>(
- connector.getMuleContext(), endpoint.getEndpointURI().getAddress(), connector.getQueueManager());+ connector.getQueueProfile().configureQueue(connector.getMuleContext(),
+ endpoint.getEndpointURI().getAddress(), connector.getQueueManager()); } }
------------------------------
http://xircles.codehaus.org/manage_email
Loading...