abdera-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dand...@apache.org
Subject svn commit: r616132 - in /incubator/abdera/java/trunk/spring/src: main/java/org/apache/abdera/spring/WorkspaceDefinitionParser.java test/java/org/apache/abdera/spring/ProviderDefinitionParserTest.java
Date Tue, 29 Jan 2008 01:37:07 GMT
Author: dandiep
Date: Mon Jan 28 17:37:05 2008
New Revision: 616132

URL: http://svn.apache.org/viewvc?rev=616132&view=rev
Log:
Fix Spring workspace parsing so it actually works with multiple collectionadapters.

Modified:
    incubator/abdera/java/trunk/spring/src/main/java/org/apache/abdera/spring/WorkspaceDefinitionParser.java
    incubator/abdera/java/trunk/spring/src/test/java/org/apache/abdera/spring/ProviderDefinitionParserTest.java

Modified: incubator/abdera/java/trunk/spring/src/main/java/org/apache/abdera/spring/WorkspaceDefinitionParser.java
URL: http://svn.apache.org/viewvc/incubator/abdera/java/trunk/spring/src/main/java/org/apache/abdera/spring/WorkspaceDefinitionParser.java?rev=616132&r1=616131&r2=616132&view=diff
==============================================================================
--- incubator/abdera/java/trunk/spring/src/main/java/org/apache/abdera/spring/WorkspaceDefinitionParser.java
(original)
+++ incubator/abdera/java/trunk/spring/src/main/java/org/apache/abdera/spring/WorkspaceDefinitionParser.java
Mon Jan 28 17:37:05 2008
@@ -18,33 +18,40 @@
  */
 package org.apache.abdera.spring;
 
-import java.util.ArrayList;
-import java.util.List;
-
-import org.apache.abdera.protocol.server.Provider;
-import org.apache.abdera.protocol.server.WorkspaceInfo;
-import org.apache.abdera.protocol.server.impl.DefaultProvider;
 import org.apache.abdera.protocol.server.impl.SimpleWorkspaceInfo;
-import org.springframework.beans.factory.BeanDefinitionStoreException;
-import org.springframework.beans.factory.support.AbstractBeanDefinition;
+import org.springframework.beans.factory.config.BeanDefinitionHolder;
 import org.springframework.beans.factory.support.BeanDefinitionBuilder;
+import org.springframework.beans.factory.support.ManagedList;
 import org.springframework.beans.factory.xml.ParserContext;
 
 import org.w3c.dom.Element;
+import org.w3c.dom.NamedNodeMap;
+import org.w3c.dom.Node;
+import org.w3c.dom.NodeList;
 
 public class WorkspaceDefinitionParser 
     extends org.apache.abdera.spring.AbstractSingleBeanDefinitionParser {
 
     @Override
-    protected void mapAttribute(BeanDefinitionBuilder bean, Element element, String name,
String val) {
-        if (name.equals("title")) {
-            bean.addPropertyValue(name, val);
+    protected void doParse(Element element, ParserContext ctx, BeanDefinitionBuilder bean)
{
+        ManagedList collections = new ManagedList();
+        NodeList nodes = element.getChildNodes();
+        for (int i = 0; i < nodes.getLength(); i++) {
+            Node n = nodes.item(i);
+            if (n.getNodeType() == org.w3c.dom.Node.ELEMENT_NODE) {
+                Element childElement = (Element)n;
+                BeanDefinitionHolder child = ctx.getDelegate().parseBeanDefinitionElement(childElement);
+                collections.add(child);
+            }
+
         }
-    }
+        bean.addPropertyValue("collections", collections);
 
-    @Override
-    protected void mapElement(ParserContext ctx, BeanDefinitionBuilder bean, Element element,
String name) {
-        bean.addPropertyValue("collections", ctx.getDelegate().parseBeanDefinitionElement(element));
+        NamedNodeMap atts = element.getAttributes();
+        Node title = atts.getNamedItem("title");
+        if (title != null) {
+            bean.addPropertyValue("title", title.getNodeValue());
+        }
     }
 
     @Override

Modified: incubator/abdera/java/trunk/spring/src/test/java/org/apache/abdera/spring/ProviderDefinitionParserTest.java
URL: http://svn.apache.org/viewvc/incubator/abdera/java/trunk/spring/src/test/java/org/apache/abdera/spring/ProviderDefinitionParserTest.java?rev=616132&r1=616131&r2=616132&view=diff
==============================================================================
--- incubator/abdera/java/trunk/spring/src/test/java/org/apache/abdera/spring/ProviderDefinitionParserTest.java
(original)
+++ incubator/abdera/java/trunk/spring/src/test/java/org/apache/abdera/spring/ProviderDefinitionParserTest.java
Mon Jan 28 17:37:05 2008
@@ -47,6 +47,7 @@
         assertEquals(1, workspaces.size());
         
         WorkspaceInfo w = workspaces.iterator().next();
+        assertNotNull(w);
         assertEquals("Foo Workspace", w.getTitle(null));
         
         Collection<CollectionInfo> collections = w.getCollections(null);



Mime
View raw message