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