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.processors;
8   
9   import org.mule.config.spring.parsers.PostProcessor;
10  import org.mule.config.spring.parsers.PreProcessor;
11  import org.mule.config.spring.parsers.assembly.BeanAssembler;
12  import org.mule.config.spring.parsers.assembly.configuration.PropertyConfiguration;
13  
14  import org.w3c.dom.Element;
15  import org.springframework.beans.factory.xml.ParserContext;
16  
17  public class AddAttribute implements PreProcessor, PostProcessor
18  {
19  
20      private String name;
21      private String value;
22  
23      public AddAttribute(String name, String value)
24      {
25          this.name = name;
26          this.value = value;
27      }
28  
29      public void postProcess(ParserContext unused, BeanAssembler assembler, Element element)
30      {
31          element.setAttribute(name, value);
32      }
33  
34      public void preProcess(PropertyConfiguration config, Element element)
35      {
36          element.setAttribute(name, value);
37      }
38  
39  }