use of org.mule.runtime.core.privileged.event.BaseEventContext in project mule by mulesoft.
the class ComponentMessageProcessor method createComponentExecutor.
private ComponentExecutor<T> createComponentExecutor() {
Map<String, Object> params = new HashMap<>();
LazyValue<Optional<ConfigurationInstance>> staticConfiguration = new LazyValue<>(this::getStaticConfiguration);
LazyValue<ValueResolvingContext> resolvingContext = new LazyValue<>(() -> {
CoreEvent initialiserEvent = null;
try {
initialiserEvent = getInitialiserEvent();
return from(initialiserEvent, staticConfiguration.get());
} finally {
if (initialiserEvent != null) {
((BaseEventContext) initialiserEvent.getContext()).success();
}
}
});
componentModel.getParameterGroupModels().stream().forEach(group -> {
if (group.getName().equals(DEFAULT_GROUP_NAME)) {
group.getParameterModels().stream().filter(p -> p.getModelProperty(FieldOperationParameterModelProperty.class).isPresent()).forEach(p -> {
ValueResolver<?> resolver = resolverSet.getResolvers().get(p.getName());
if (resolver != null) {
try {
params.put(getMemberName(p), resolveValue(resolver, resolvingContext.get()));
} catch (MuleException e) {
throw new MuleRuntimeException(e);
}
}
});
} else {
ParameterGroupDescriptor groupDescriptor = group.getModelProperty(ParameterGroupModelProperty.class).map(g -> g.getDescriptor()).orElse(null);
if (groupDescriptor == null) {
return;
}
List<ParameterModel> fieldParameters = getGroupsOfFieldParameters(group);
if (fieldParameters.isEmpty()) {
return;
}
ObjectBuilder groupBuilder = createFieldParameterGroupBuilder(groupDescriptor, fieldParameters);
try {
params.put(((Field) groupDescriptor.getContainer()).getName(), groupBuilder.build(resolvingContext.get()));
} catch (MuleException e) {
throw new MuleRuntimeException(e);
}
}
});
return getOperationExecutorFactory(componentModel).createExecutor(componentModel, params);
}
use of org.mule.runtime.core.privileged.event.BaseEventContext in project mule by mulesoft.
the class EventContextBenchmark method createEventContextWithFlowAndCompleteWithExternalCompletion.
@Benchmark
public Object[] createEventContextWithFlowAndCompleteWithExternalCompletion() {
CompletableFuture<Void> completableFuture = new CompletableFuture<>();
AtomicReference<CoreEvent> result = new AtomicReference();
AtomicBoolean complete = new AtomicBoolean();
BaseEventContext eventContext = (BaseEventContext) create(flow, CONNECTOR_LOCATION, null, of(completableFuture));
from(from(eventContext.getResponsePublisher())).doOnSuccess(response -> result.set(response)).subscribe();
eventContext.onTerminated((response, throwable) -> complete.set(true));
eventContext.success(event);
completableFuture.complete(null);
return new Object[] { result, complete };
}
use of org.mule.runtime.core.privileged.event.BaseEventContext in project mule by mulesoft.
the class EventContextBenchmark method createEventContextWithFlowAndComplete.
@Benchmark
public Object[] createEventContextWithFlowAndComplete() {
AtomicReference<CoreEvent> result = new AtomicReference();
AtomicBoolean complete = new AtomicBoolean();
BaseEventContext eventContext = (BaseEventContext) create(flow, CONNECTOR_LOCATION);
from(from(eventContext.getResponsePublisher())).doOnSuccess(response -> result.set(response)).subscribe();
eventContext.onTerminated((response, throwable) -> complete.set(true));
eventContext.success(event);
return new Object[] { result, complete };
}
use of org.mule.runtime.core.privileged.event.BaseEventContext in project mule by mulesoft.
the class SingleConfigParserTestCase method configWithExpressionFunctionIsSameInstanceForDifferentEvents.
@Test
public void configWithExpressionFunctionIsSameInstanceForDifferentEvents() throws Exception {
CoreEvent event = null;
try {
event = getHeisenbergEvent();
CoreEvent anotherEvent = testEvent();
HeisenbergExtension config = lookupHeisenberg(HEISENBERG_BYNAME, event);
HeisenbergExtension anotherConfig = lookupHeisenberg(HEISENBERG_BYNAME, anotherEvent);
assertThat(config, is(sameInstance(anotherConfig)));
} finally {
if (event != null) {
((BaseEventContext) event.getContext()).success();
}
}
}
use of org.mule.runtime.core.privileged.event.BaseEventContext in project mule by mulesoft.
the class ExtensionMessageSource method createSource.
private synchronized void createSource() throws Exception {
if (sourceAdapter == null) {
CoreEvent initialiserEvent = null;
try {
initialiserEvent = getInitialiserEvent(muleContext);
sourceAdapter = sourceAdapterFactory.createAdapter(getConfiguration(initialiserEvent), createSourceCallbackFactory(), this, sourceConnectionManager, new MessagingExceptionResolver(this));
muleContext.getInjector().inject(sourceAdapter);
} finally {
if (initialiserEvent != null) {
((BaseEventContext) initialiserEvent.getContext()).success();
}
}
}
}
Aggregations