use of org.mule.runtime.core.privileged.processor.chain.DefaultMessageProcessorChainBuilder in project mule by mulesoft.
the class MessageProcessors method newChain.
/**
* Creates a new {@link MessageProcessorChain} from a {@link List} of {@link Processor}'s. Note that this performs chains
* construction but will not inject {@link MuleContext} or perform any lifecycle.
*
* @param processingStrategy the processing strategy to use for configuring the chain. It may be {@link Optional#empty()}.
* @param processors list of processors to construct chains from.
* @return new {@link MessageProcessorChain} instance.
*/
public static MessageProcessorChain newChain(Optional<ProcessingStrategy> processingStrategy, List<Processor> processors) {
if (processors.size() == 1 && processors.get(0) instanceof MessageProcessorChain) {
return (MessageProcessorChain) processors.get(0);
} else {
DefaultMessageProcessorChainBuilder defaultMessageProcessorChainBuilder = new DefaultMessageProcessorChainBuilder();
processingStrategy.ifPresent(defaultMessageProcessorChainBuilder::setProcessingStrategy);
return defaultMessageProcessorChainBuilder.chain(processors).build();
}
}
use of org.mule.runtime.core.privileged.processor.chain.DefaultMessageProcessorChainBuilder in project mule by mulesoft.
the class MessageProcessorChainFactoryBean method getBuilderInstance.
protected MessageProcessorChainBuilder getBuilderInstance() {
DefaultMessageProcessorChainBuilder builder = new DefaultMessageProcessorChainBuilder();
builder.setName("processor chain '" + name + "'");
return builder;
}
use of org.mule.runtime.core.privileged.processor.chain.DefaultMessageProcessorChainBuilder in project mule by mulesoft.
the class ResponseMessageProcessorsFactoryBean method doGetObject.
@Override
public ResponseMessageProcessorAdapter doGetObject() throws Exception {
DefaultMessageProcessorChainBuilder builder = new DefaultMessageProcessorChainBuilder();
builder.setName("'response' child processor chain");
for (Object processor : messageProcessors) {
if (processor instanceof Processor) {
builder.chain((Processor) processor);
} else if (processor instanceof MessageProcessorBuilder) {
builder.chain((MessageProcessorBuilder) processor);
} else {
throw new IllegalArgumentException("MessageProcessorBuilder should only have MessageProcessor's or MessageProcessorBuilder's configured");
}
}
ResponseMessageProcessorAdapter responseAdapter = new ResponseMessageProcessorAdapter();
responseAdapter.setProcessor(newLazyProcessorChainBuilder(builder, muleContext, () -> getProcessingStrategy(locator, getRootContainerLocation()).orElse(null)));
responseAdapter.setMuleContext(muleContext);
return responseAdapter;
}
use of org.mule.runtime.core.privileged.processor.chain.DefaultMessageProcessorChainBuilder in project mule by mulesoft.
the class AsyncDelegateMessageProcessorTestCase method createAsyncDelegateMessageProcessor.
private AsyncDelegateMessageProcessor createAsyncDelegateMessageProcessor(Processor listener, FlowConstruct flowConstruct) throws Exception {
DefaultMessageProcessorChainBuilder delegateBuilder = new DefaultMessageProcessorChainBuilder();
delegateBuilder.setProcessingStrategy(flowConstruct.getProcessingStrategy());
delegateBuilder.chain(listener);
AsyncDelegateMessageProcessor mp = new AsyncDelegateMessageProcessor(delegateBuilder, "thread");
mp.setAnnotations(getAppleFlowComponentLocationAnnotations());
initialiseIfNeeded(mp, true, muleContext);
return mp;
}
use of org.mule.runtime.core.privileged.processor.chain.DefaultMessageProcessorChainBuilder in project mule by mulesoft.
the class ResponseMessageProcessorAdapterTestCase method testResponseAdaptorNestedChainReturnsNull.
@Test
public void testResponseAdaptorNestedChainReturnsNull() throws Exception {
DefaultMessageProcessorChainBuilder builder = new DefaultMessageProcessorChainBuilder();
final ResponseMessageProcessorAdapter responseMessageProcessorAdapter = new ResponseMessageProcessorAdapter(new DefaultMessageProcessorChainBuilder().chain(createStringAppendTransformer("a"), createStringAppendTransformer("b"), new ReturnNullMP()).build());
responseMessageProcessorAdapter.setMuleContext(muleContext);
builder.chain(createStringAppendTransformer("1"), responseMessageProcessorAdapter, createStringAppendTransformer("2"));
assertEquals("012", ((PrivilegedEvent) process(builder.build(), eventBuilder(muleContext).message(of("0")).build())).getMessageAsString(muleContext));
}
Aggregations