Search in sources :

Example 1 with ReflectiveMethodOperationExecutor

use of org.mule.runtime.module.extension.internal.runtime.operation.ReflectiveMethodOperationExecutor in project mule by mulesoft.

the class ReflectiveOperationExecutorFactory method createExecutor.

@Override
public ComponentExecutor<M> createExecutor(M operationModel, Map<String, Object> parameters) {
    DefaultObjectBuilder objectBuilder = new DefaultObjectBuilder(implementationClass);
    parameters.forEach((k, v) -> objectBuilder.addPropertyResolver(k, new StaticValueResolver<>(v)));
    Object delegate;
    CoreEvent initialiserEvent = null;
    try {
        initialiserEvent = getInitialiserEvent();
        delegate = objectBuilder.build(from(initialiserEvent));
    } catch (Exception e) {
        throw new MuleRuntimeException(createStaticMessage("Could not create instance of operation class " + implementationClass.getName()), e);
    } finally {
        if (initialiserEvent != null) {
            ((BaseEventContext) initialiserEvent.getContext()).success();
        }
    }
    return new ReflectiveMethodOperationExecutor(operationModel, operationMethod, delegate);
}
Also used : BaseEventContext(org.mule.runtime.core.privileged.event.BaseEventContext) CoreEvent(org.mule.runtime.core.api.event.CoreEvent) MuleRuntimeException(org.mule.runtime.api.exception.MuleRuntimeException) StaticValueResolver(org.mule.runtime.module.extension.internal.runtime.resolver.StaticValueResolver) ReflectiveMethodOperationExecutor(org.mule.runtime.module.extension.internal.runtime.operation.ReflectiveMethodOperationExecutor) DefaultObjectBuilder(org.mule.runtime.module.extension.internal.runtime.objectbuilder.DefaultObjectBuilder) MuleRuntimeException(org.mule.runtime.api.exception.MuleRuntimeException)

Aggregations

MuleRuntimeException (org.mule.runtime.api.exception.MuleRuntimeException)1 CoreEvent (org.mule.runtime.core.api.event.CoreEvent)1 BaseEventContext (org.mule.runtime.core.privileged.event.BaseEventContext)1 DefaultObjectBuilder (org.mule.runtime.module.extension.internal.runtime.objectbuilder.DefaultObjectBuilder)1 ReflectiveMethodOperationExecutor (org.mule.runtime.module.extension.internal.runtime.operation.ReflectiveMethodOperationExecutor)1 StaticValueResolver (org.mule.runtime.module.extension.internal.runtime.resolver.StaticValueResolver)1