View Javadoc

1   /*
2    * $Id: InterceptorDefinitionParser.java 19641 2010-09-14 01:54:08Z dfeist $
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  
11  package org.mule.config.spring.parsers.specific;
12  
13  import org.mule.api.interceptor.Interceptor;
14  import org.mule.config.spring.parsers.generic.ChildDefinitionParser;
15  
16  import org.w3c.dom.Element;
17  
18  /**
19   * This allows a interceptor to be defined on a global interceptor stack or on a service.
20   */
21  public class InterceptorDefinitionParser extends ChildDefinitionParser
22  {
23  
24      public static final String INTERCEPTOR = "interceptor";
25  
26      public InterceptorDefinitionParser(Class interceptor)
27      {
28          super(INTERCEPTOR, interceptor, Interceptor.class);
29      }
30  
31      /**
32       * For custom transformers
33       */
34      public InterceptorDefinitionParser()
35      {
36          super(INTERCEPTOR, null, Interceptor.class);
37      }
38  
39      @Override
40      public String getPropertyName(Element e)
41      {
42          String parentName = e.getParentNode().getLocalName().toLowerCase();
43          if ("flow".equals(parentName) || "inbound".equals(parentName) || "endpoint".equals(parentName)
44              || "inbound-endpoint".equals(parentName) || "outbound-endpoint".equals(parentName)
45              || "async-reply".equals(parentName) || "processor-chain".equals(parentName))
46          {
47              return "messageProcessor";
48          }
49          else
50          {
51              return super.getPropertyName(e);
52  
53          }
54      }
55  }