View Javadoc

1   /*
2    * $Id: AddAttribute.java 19191 2010-08-25 21:05:23Z tcarlson $
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.processors;
12  
13  import org.mule.config.spring.parsers.PostProcessor;
14  import org.mule.config.spring.parsers.PreProcessor;
15  import org.mule.config.spring.parsers.assembly.BeanAssembler;
16  import org.mule.config.spring.parsers.assembly.configuration.PropertyConfiguration;
17  
18  import org.w3c.dom.Element;
19  import org.springframework.beans.factory.xml.ParserContext;
20  
21  public class AddAttribute implements PreProcessor, PostProcessor
22  {
23  
24      private String name;
25      private String value;
26  
27      public AddAttribute(String name, String value)
28      {
29          this.name = name;
30          this.value = value;
31      }
32  
33      public void postProcess(ParserContext unused, BeanAssembler assembler, Element element)
34      {
35          element.setAttribute(name, value);
36      }
37  
38      public void preProcess(PropertyConfiguration config, Element element)
39      {
40          element.setAttribute(name, value);
41      }
42  
43  }