01: /*
02: * $Id: TransformerDefinitionParser.java 11080 2008-02-27 16:25:01Z acooke $
03: * --------------------------------------------------------------------------------------
04: * Copyright (c) MuleSource, Inc. All rights reserved. http://www.mulesource.com
05: *
06: * The software in this package is published under the terms of the CPAL v1.0
07: * license, a copy of which has been included with this distribution in the
08: * LICENSE.txt file.
09: */
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 transformer to be defined globally, or embedded within an endpoint
19: * (as either a normal or response transformer).
20: */
21: public class TransformerDefinitionParser extends
22: ParentContextDefinitionParser {
23:
24: public static final String TRANSFORMER = "transformer";
25: public static final String RESPONSE_TRANSFORMER = "responseTransformer";
26: public static final String RESPONSE_TRANSFORMERS = "response-transformers";
27:
28: public TransformerDefinitionParser(Class transformer) {
29: super (MuleOrphanDefinitionParser.ROOT_ELEMENT,
30: new MuleOrphanDefinitionParser(transformer, false));
31: and(RESPONSE_TRANSFORMERS, new ChildDefinitionParser(
32: RESPONSE_TRANSFORMER, transformer));
33: otherwise(new ChildDefinitionParser(TRANSFORMER, transformer));
34: }
35:
36: /**
37: * For custom transformers
38: */
39: public TransformerDefinitionParser() {
40: super (MuleOrphanDefinitionParser.ROOT_ELEMENT,
41: new MuleOrphanDefinitionParser(false));
42: and(RESPONSE_TRANSFORMERS, new ChildDefinitionParser(
43: RESPONSE_TRANSFORMER));
44: otherwise(new ChildDefinitionParser(TRANSFORMER));
45: }
46:
47: }
|