Classes in this File | Line Coverage | Branch Coverage | Complexity | ||||
AbstractMessageProcessorChainBuilder |
|
| 1.5;1.5 |
1 | /* | |
2 | * Copyright (c) MuleSoft, Inc. All rights reserved. http://www.mulesoft.com | |
3 | * The software in this package is published under the terms of the CPAL v1.0 | |
4 | * license, a copy of which has been included with this distribution in the | |
5 | * LICENSE.txt file. | |
6 | */ | |
7 | package org.mule.processor.chain; | |
8 | ||
9 | import org.mule.api.MuleException; | |
10 | import org.mule.api.construct.FlowConstruct; | |
11 | import org.mule.api.processor.MessageProcessor; | |
12 | import org.mule.api.processor.MessageProcessorBuilder; | |
13 | import org.mule.api.processor.MessageProcessorChainBuilder; | |
14 | ||
15 | import java.util.ArrayList; | |
16 | import java.util.List; | |
17 | ||
18 | /** | |
19 | * <p> | |
20 | * Constructs a chain of {@link MessageProcessor}s and wraps the invocation of the chain in a composite | |
21 | * MessageProcessor. Both MessageProcessors and InterceptingMessageProcessor's can be chained together | |
22 | * arbitrarily in a single chain. InterceptingMessageProcessors simply intercept the next MessageProcessor in | |
23 | * the chain. When other non-intercepting MessageProcessors are used an adapter is used internally to chain | |
24 | * the MessageProcessor with the next in the chain. | |
25 | * </p> | |
26 | * <p> | |
27 | * The MessageProcessor instance that this builder builds can be nested in other chains as required. | |
28 | * </p> | |
29 | */ | |
30 | public abstract class AbstractMessageProcessorChainBuilder implements MessageProcessorChainBuilder | |
31 | { | |
32 | ||
33 | 0 | protected List processors = new ArrayList(); |
34 | protected String name; | |
35 | protected FlowConstruct flowConstruct; | |
36 | ||
37 | public AbstractMessageProcessorChainBuilder() | |
38 | 0 | { |
39 | // empty | |
40 | 0 | } |
41 | ||
42 | public AbstractMessageProcessorChainBuilder(FlowConstruct flowConstruct) | |
43 | 0 | { |
44 | 0 | this.flowConstruct = flowConstruct; |
45 | 0 | } |
46 | ||
47 | // Argument is of type Object because it could be a MessageProcessor or a MessageProcessorBuilder | |
48 | protected MessageProcessor initializeMessageProcessor(Object processor) throws MuleException | |
49 | { | |
50 | // TODO DF: FlowConstuct should be injected here but there is an issue with spring not have reference | |
51 | // to it. For now we inject it once the MessageProcessor is built and this works, but | |
52 | // MessageProcessorBuilders should have FlowConstuct available when building really. | |
53 | ||
54 | 0 | if (processor instanceof MessageProcessorBuilder) |
55 | { | |
56 | 0 | return ((MessageProcessorBuilder) processor).build(); |
57 | } | |
58 | else | |
59 | { | |
60 | 0 | return (MessageProcessor) processor; |
61 | } | |
62 | } | |
63 | ||
64 | public void setName(String name) | |
65 | { | |
66 | 0 | this.name = name; |
67 | 0 | } |
68 | ||
69 | } |