geronimo-scm mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From a..@apache.org
Subject svn commit: r398000 - /geronimo/xbean/trunk/xbean-spring/src/main/java/org/apache/xbean/spring/context/impl/XBeanXmlBeanDefinitionParser.java
Date Fri, 28 Apr 2006 20:48:28 GMT
Author: adc
Date: Fri Apr 28 13:48:27 2006
New Revision: 398000

URL: http://svn.apache.org/viewcvs?rev=398000&view=rev
Log:
XBEAN-2: catch misspelt Spring elements

Modified:
    geronimo/xbean/trunk/xbean-spring/src/main/java/org/apache/xbean/spring/context/impl/XBeanXmlBeanDefinitionParser.java

Modified: geronimo/xbean/trunk/xbean-spring/src/main/java/org/apache/xbean/spring/context/impl/XBeanXmlBeanDefinitionParser.java
URL: http://svn.apache.org/viewcvs/geronimo/xbean/trunk/xbean-spring/src/main/java/org/apache/xbean/spring/context/impl/XBeanXmlBeanDefinitionParser.java?rev=398000&r1=397999&r2=398000&view=diff
==============================================================================
--- geronimo/xbean/trunk/xbean-spring/src/main/java/org/apache/xbean/spring/context/impl/XBeanXmlBeanDefinitionParser.java
(original)
+++ geronimo/xbean/trunk/xbean-spring/src/main/java/org/apache/xbean/spring/context/impl/XBeanXmlBeanDefinitionParser.java
Fri Apr 28 13:48:27 2006
@@ -58,7 +58,7 @@
 
 /**
  * An enhanced XML parser capable of handling custom XML schemas.
- * 
+ *
  * @author James Strachan
  * @version $Id$
  * @since 2.0
@@ -75,7 +75,7 @@
     private static final Log log = LogFactory.getLog(XBeanXmlBeanDefinitionParser.class);
 
     private static final String QNAME_ELEMENT = "qname";
-    
+
     /**
      * All the reserved Spring XML element names which cannot be overloaded by
      * an XML extension
@@ -152,7 +152,7 @@
         namedConstructorArgs.processParameters(definition, metadata);
         return definition;
     }
-    
+
     /**
      * Parses the non-standard XML element as a Spring bean definition
      */
@@ -170,7 +170,8 @@
                 throw new BeanDefinitionStoreException("Unrecognized xbean element mapping:
" + localName + " in namespace " + uri);
             }
         } else {
-            throw new BeanDefinitionStoreException("Unrecognized xbean namespace mapping:
" + uri);
+            if (uri == null) throw new BeanDefinitionStoreException("Unrecognized Spring
element: " + localName);
+            else throw new BeanDefinitionStoreException("Unrecognized xbean namespace mapping:
" + uri);
         }
     }
 
@@ -304,7 +305,7 @@
             }
         }
     }
-    
+
     // Fix Spring 1.2.6 to 1.2.7 binary incompatibility.
     // The addPropertyValueMethod has changed to return a
     // value instead of void.
@@ -322,7 +323,7 @@
 
     protected Object getValue(String value) {
         if (value == null)  return null;
-        
+
         boolean reference = false;
         if (value.startsWith(BEAN_REFERENCE_PREFIX)) {
             value = value.substring(BEAN_REFERENCE_PREFIX.length());
@@ -332,7 +333,7 @@
                 reference = true;
             }
         }
-        
+
         if (reference) {
             // TOOD handle custom reference types like local or queries etc
             return new RuntimeBeanReference(value);
@@ -341,7 +342,7 @@
             return value;
         }
     }
-    
+
     protected String getLocalName(Element element) {
         String localName = element.getLocalName();
         if (localName == null) {
@@ -402,17 +403,17 @@
                             }
                         }
                     }
-                    
+
                     if (propertyName == null && metadata.isFlatProperty(getLocalName(element),
localName)) {
                        value = parseBeanFromExtensionElement(childElement, className, localName);
                        propertyName = localName;
                     }
-                    
+
                     if (propertyName == null) {
                         value = tryParseNestedPropertyViaIntrospection(metadata, className,
childElement);
                         propertyName = localName;
                     }
-                    
+
                     if (value != null) {
                         definition.getBeanDefinition().getPropertyValues().addPropertyValue(propertyName,
value);
                     }
@@ -534,14 +535,14 @@
 
     protected Object parseCustomMapElement(MappingMetaData metadata, Element element, String
name) {
         Map map = new HashMap();
-        
+
         Element parent = (Element) element.getParentNode();
         String entryName = metadata.getMapEntryName(getLocalName(parent), name);
         String keyName = metadata.getMapKeyName(getLocalName(parent), name);
-        
+
         if (entryName == null) entryName = "property";
         if (keyName == null) keyName = "key";
-        
+
         // TODO : support further customizations
         //String valueName = "value";
         //boolean keyIsAttr = true;
@@ -551,7 +552,7 @@
             Node node = nl.item(i);
             if (node instanceof Element) {
                 Element childElement = (Element) node;
-                
+
                 String localName = childElement.getLocalName();
                 String uri = childElement.getNamespaceURI();
                 if (localName == null || localName.equals("xmlns") || localName.startsWith("xmlns:"))
{
@@ -563,9 +564,9 @@
                 if (!isEmpty(uri) && localName.equals(entryName)) {
                     String key = childElement.getAttribute(keyName);
                     if (key == null) throw new RuntimeException("No key defined for map "
+ entryName);
-                    
+
                     Object keyValue = getValue(key);
-                    
+
                     Object value = getValue(getElementText(childElement));
 
                     map.put(keyValue, value);
@@ -578,7 +579,7 @@
     protected boolean isMap(Class type) {
         return Map.class.isAssignableFrom(type);
     }
-    
+
     /**
      * Returns true if the given type is a collection type or an array
      */
@@ -616,7 +617,7 @@
     /**
      * Uses META-INF/services discovery to find a Properties file with the XML
      * marshaling configuration
-     * 
+     *
      * @param namespaceURI
      *            the namespace URI of the element
      * @param localName
@@ -721,7 +722,7 @@
     //
     // TODO we could apply the following patches into the Spring code -
     // though who knows if it'll ever make it into a release! :)
-    // 
+    //
     // -------------------------------------------------------------------------
     protected int parseBeanDefinitions(Element root) throws BeanDefinitionStoreException
{
         int beanDefinitionCount = 0;
@@ -798,7 +799,7 @@
         }
         return super.parsePropertySubElement(element, beanName);
     }
-    
+
     protected Object parseQNameElement(Element element) {
         return QNameReflectionHelper.createQName(element, getElementText(element));
     }



Mime
View raw message