View Javadoc

1   /*
2    * $Id: MessageProcessorDefinitionParser.java 19310 2010-09-02 21:27:48Z 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.config.spring.parsers.delegate.ParentContextDefinitionParser;
14  import org.mule.config.spring.parsers.generic.ChildDefinitionParser;
15  import org.mule.config.spring.parsers.generic.MuleOrphanDefinitionParser;
16  
17  /**
18   * This allows a message processor to be defined globally, or embedded within an endpoint.
19   * (as either a normal or response processor).
20   */
21  public class MessageProcessorDefinitionParser extends ParentContextDefinitionParser
22  {
23  
24      public MessageProcessorDefinitionParser(Class messageProcessor)
25      {
26          super(MuleOrphanDefinitionParser.ROOT_ELEMENT, new MuleOrphanDefinitionParser(messageProcessor, false));
27          and("response", new ChildDefinitionParser("responseMessageProcessor", messageProcessor));
28          otherwise(new ChildDefinitionParser("messageProcessor", messageProcessor));
29      }
30  
31      /**
32       * For custom processors
33       */
34      public MessageProcessorDefinitionParser()
35      {
36          super(MuleOrphanDefinitionParser.ROOT_ELEMENT, new MuleOrphanDefinitionParser(false));
37          and("response", new ChildDefinitionParser("responseMessageProcessor"));
38          otherwise(new ChildDefinitionParser("messageProcessor"));
39      }
40  
41  }