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