01: /*
02: * $Id: MuleOrphanDefinitionParser.java 10901 2008-02-20 13:11:46Z 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: package org.mule.config.spring.parsers.generic;
11:
12: import org.mule.config.spring.parsers.AbstractMuleBeanDefinitionParser;
13: import org.mule.config.spring.util.SpringXMLUtils;
14:
15: import org.springframework.beans.factory.support.AbstractBeanDefinition;
16: import org.springframework.beans.factory.xml.ParserContext;
17: import org.w3c.dom.Element;
18:
19: /**
20: * A parser for direct children of the <mule> element.
21: */
22: public class MuleOrphanDefinitionParser extends OrphanDefinitionParser {
23:
24: /**
25: * This constructor assumes that the class name will be explicitly specified as an attribute on the element.
26: */
27: public MuleOrphanDefinitionParser(boolean singleton) {
28: super (singleton);
29: }
30:
31: public MuleOrphanDefinitionParser(Class beanClass, boolean singleton) {
32: super (beanClass, singleton);
33: }
34:
35: protected AbstractBeanDefinition parseInternal(Element element,
36: ParserContext parserContext) {
37: assertMuleParent(element);
38: return super .parseInternal(element, parserContext);
39: }
40:
41: protected void assertMuleParent(Element element) {
42: if (!isTopLevel(element)) {
43: throw new IllegalStateException(
44: "This element should be embedded inside the Mule <"
45: + ROOT_ELEMENT + "> element: "
46: + SpringXMLUtils.elementToString(element));
47: }
48: }
49:
50: }
|