View Javadoc

1   /*
2    * $Id: ErrorExpressionFilter.java 19026 2010-08-16 07:30:47Z dirk.olmes $
3    * --------------------------------------------------------------------------------------
4    * Copyright (c) MuleSoft, Inc.  All rights reserved.  http://www.mulesoft.com
5    *
6    * The software in this package is published under the terms of the CPAL v1.0
7    * license, a copy of which has been included with this distribution in the
8    * LICENSE.txt file.
9    */
10  package org.mule.module.ibeans.spi;
11  
12  import org.mule.routing.filters.ExpressionFilter;
13  
14  import org.ibeans.api.IBeansException;
15  import org.ibeans.spi.ErrorFilter;
16  
17  /**
18   * An implementation of a {@link org.ibeans.spi.ErrorFilter} that allows for error filter expressions to be configured on
19   * an iBean
20   */
21  public class ErrorExpressionFilter extends ExpressionFilter implements ErrorFilter<MuleResponseMessage>
22  {
23      private String errorCodeExpression;
24  
25      public ErrorExpressionFilter(String evaluator, String customEvaluator, String expression, String errorCodeExpr)
26      {
27          super(evaluator, customEvaluator, expression);
28          if (errorCodeExpr != null && errorCodeExpr.length() > 0)
29          {
30              this.errorCodeExpression = errorCodeExpr;
31          }
32      }
33  
34      public ErrorExpressionFilter(String evaluator, String expression, String errorCodeExpr)
35      {
36          super(evaluator, expression);
37          if (errorCodeExpr != null && errorCodeExpr.length() > 0)
38          {
39              this.errorCodeExpression = errorCodeExpr;
40          }
41      }
42  
43      public ErrorExpressionFilter(String expression)
44      {
45          super(expression);
46      }
47  
48      public ErrorExpressionFilter()
49      {
50          super();
51      }
52  
53      public String getErrorCodeExpression()
54      {
55          return errorCodeExpression;
56      }
57  
58      public String getErrorExpression()
59      {
60          return getExpression();
61      }
62  
63      public String getType()
64      {
65          return getEvaluator();
66      }
67  
68      public boolean accept(MuleResponseMessage object) throws IBeansException
69      {
70          return accept(object.getMessage());
71      }
72  }