1 | |
|
2 | |
|
3 | |
|
4 | |
|
5 | |
|
6 | |
|
7 | |
|
8 | |
|
9 | |
|
10 | |
|
11 | |
package org.mule.construct.builder; |
12 | |
|
13 | |
import org.mule.MessageExchangePattern; |
14 | |
import org.mule.api.MuleContext; |
15 | |
import org.mule.api.MuleException; |
16 | |
import org.mule.api.routing.filter.Filter; |
17 | |
import org.mule.construct.Validator; |
18 | |
import org.mule.util.StringUtils; |
19 | |
|
20 | 0 | public class ValidatorBuilder extends |
21 | |
AbstractFlowConstructWithSingleInboundAndOutboundEndpointBuilder<ValidatorBuilder, Validator> |
22 | |
{ |
23 | |
protected Filter validationFilter; |
24 | |
protected String ackExpression; |
25 | |
protected String nackExpression; |
26 | |
protected String errorExpression; |
27 | |
|
28 | |
public ValidatorBuilder validationFilter(Filter validationFilter) |
29 | |
{ |
30 | 0 | this.validationFilter = validationFilter; |
31 | 0 | return this; |
32 | |
} |
33 | |
|
34 | |
public ValidatorBuilder ackExpression(String ackExpression) |
35 | |
{ |
36 | 0 | this.ackExpression = ackExpression; |
37 | 0 | return this; |
38 | |
} |
39 | |
|
40 | |
public ValidatorBuilder nackExpression(String nackExpression) |
41 | |
{ |
42 | 0 | this.nackExpression = nackExpression; |
43 | 0 | return this; |
44 | |
} |
45 | |
|
46 | |
public ValidatorBuilder errorExpression(String errorExpression) |
47 | |
{ |
48 | 0 | this.errorExpression = errorExpression; |
49 | 0 | return this; |
50 | |
} |
51 | |
|
52 | |
@Override |
53 | |
protected MessageExchangePattern getInboundMessageExchangePattern() |
54 | |
{ |
55 | 0 | return MessageExchangePattern.REQUEST_RESPONSE; |
56 | |
} |
57 | |
|
58 | |
@Override |
59 | |
protected MessageExchangePattern getOutboundMessageExchangePattern() |
60 | |
{ |
61 | 0 | return hasErrorExpression() |
62 | |
? MessageExchangePattern.REQUEST_RESPONSE |
63 | |
: MessageExchangePattern.ONE_WAY; |
64 | |
} |
65 | |
|
66 | |
@Override |
67 | |
protected Validator buildFlowConstruct(MuleContext muleContext) throws MuleException |
68 | |
{ |
69 | 0 | return new Validator(name, muleContext, getOrBuildInboundEndpoint(muleContext), |
70 | |
getOrBuildOutboundEndpoint(muleContext), validationFilter, ackExpression, nackExpression, |
71 | |
errorExpression); |
72 | |
} |
73 | |
|
74 | |
protected boolean hasErrorExpression() |
75 | |
{ |
76 | 0 | return StringUtils.isNotBlank(errorExpression); |
77 | |
} |
78 | |
} |