use of org.mule.runtime.core.privileged.event.PrivilegedEvent in project mule by mulesoft.
the class VariablesTestCase method sessionVariable.
@Test
public void sessionVariable() throws Exception {
Message message = of("");
PrivilegedEvent event = (PrivilegedEvent) InternalEvent.builder(context).message(message).build();
event.getSession().setProperty("foo", "bar");
assertEquals(event.getSession().getProperty("foo"), evaluate("sessionVars['foo']", event));
}
use of org.mule.runtime.core.privileged.event.PrivilegedEvent in project mule by mulesoft.
the class AsyncRequestReplyRequesterTestCase method testResponseEventsCleanedUp.
@Test
public void testResponseEventsCleanedUp() throws Exception {
RelaxedAsyncReplyMP mp = new RelaxedAsyncReplyMP(muleContext);
try {
CoreEvent event = eventBuilder(muleContext).message(of("message1")).groupCorrelation(Optional.of(GroupCorrelation.of(0, 3))).build();
SensingNullMessageProcessor listener = getSensingNullMessageProcessor();
mp.setListener(listener);
mp.setReplySource(listener.getMessageSource());
mp.process(event);
Map<String, PrivilegedEvent> responseEvents = mp.getResponseEvents();
assertThat(responseEvents.entrySet(), empty());
} finally {
mp.stop();
}
}
use of org.mule.runtime.core.privileged.event.PrivilegedEvent in project mule by mulesoft.
the class MessageEnricher method enrich.
protected PrivilegedEvent enrich(PrivilegedEvent currentEvent, PrivilegedEvent enrichmentEvent, String sourceExpressionArg, String targetExpressionArg, ExtendedExpressionManager expressionManager) {
if (StringUtils.isEmpty(sourceExpressionArg)) {
sourceExpressionArg = "#[mel:payload:]";
}
TypedValue typedValue = expressionManager.evaluate(sourceExpressionArg, enrichmentEvent, getLocation());
if (typedValue.getValue() instanceof Message) {
Message muleMessage = (Message) typedValue.getValue();
typedValue = new TypedValue(muleMessage.getPayload().getValue(), muleMessage.getPayload().getDataType());
}
if (!StringUtils.isEmpty(targetExpressionArg)) {
PrivilegedEvent.Builder eventBuilder = PrivilegedEvent.builder(currentEvent);
expressionManager.enrich(targetExpressionArg, currentEvent, eventBuilder, getLocation(), typedValue);
return eventBuilder.build();
} else {
return PrivilegedEvent.builder(currentEvent).message(Message.builder(currentEvent.getMessage()).value(typedValue.getValue()).mediaType(typedValue.getDataType().getMediaType()).build()).build();
}
}
use of org.mule.runtime.core.privileged.event.PrivilegedEvent in project mule by mulesoft.
the class MVELExpressionLanguage method enrich.
@Override
public void enrich(String expression, CoreEvent event, CoreEvent.Builder eventBuilder, ComponentLocation componentLocation, TypedValue typedValue) {
expression = removeExpressionMarker(expression);
expression = createEnrichmentExpression(expression);
evaluateUntyped(expression, (PrivilegedEvent) event, (PrivilegedEvent.Builder) eventBuilder, componentLocation, singletonMap(OBJECT_FOR_ENRICHMENT, typedValue.getValue()));
final Serializable compiledExpression = expressionExecutor.getCompiledExpression(expression);
event = eventBuilder.build();
dataTypePropagator.propagate(typedValue, (PrivilegedEvent) event, (PrivilegedEvent.Builder) eventBuilder, compiledExpression);
}
use of org.mule.runtime.core.privileged.event.PrivilegedEvent in project mule by mulesoft.
the class OperationPolicyProcessor method manageError.
private void manageError(PolicyStateId policyStateId, PrivilegedEvent operationEvent, MessagingException messagingException) {
policyStateHandler.updateState(policyStateId, messagingException.getEvent());
PrivilegedEvent newEvent = policyEventConverter.createEvent((PrivilegedEvent) messagingException.getEvent(), operationEvent);
messagingException.setProcessedEvent(newEvent);
}
Aggregations