abdera-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jmsn...@apache.org
Subject svn commit: r620313 - in /incubator/abdera/java/trunk/spring/src: main/java/org/apache/abdera/spring/ main/resources/META-INF/schemas/ test/java/org/apache/abdera/spring/ test/resources/org/apache/abdera/spring/
Date Sun, 10 Feb 2008 19:32:51 GMT
Author: jmsnell
Date: Sun Feb 10 11:32:50 2008
New Revision: 620313

URL: http://svn.apache.org/viewvc?rev=620313&view=rev
Log:
Per https://issues.apache.org/jira/browse/ABDERA-106

Added:
    incubator/abdera/java/trunk/spring/src/test/java/org/apache/abdera/spring/ClassicProviderDefinitionParserTest.java
    incubator/abdera/java/trunk/spring/src/test/resources/org/apache/abdera/spring/classicBeansDefinition.xml
Modified:
    incubator/abdera/java/trunk/spring/src/main/java/org/apache/abdera/spring/DefaultProviderDefinitionParser.java
    incubator/abdera/java/trunk/spring/src/main/resources/META-INF/schemas/abdera-spring.xsd
    incubator/abdera/java/trunk/spring/src/test/java/org/apache/abdera/spring/TestSuite.java
    incubator/abdera/java/trunk/spring/src/test/resources/org/apache/abdera/spring/beans.xml

Modified: incubator/abdera/java/trunk/spring/src/main/java/org/apache/abdera/spring/DefaultProviderDefinitionParser.java
URL: http://svn.apache.org/viewvc/incubator/abdera/java/trunk/spring/src/main/java/org/apache/abdera/spring/DefaultProviderDefinitionParser.java?rev=620313&r1=620312&r2=620313&view=diff
==============================================================================
--- incubator/abdera/java/trunk/spring/src/main/java/org/apache/abdera/spring/DefaultProviderDefinitionParser.java
(original)
+++ incubator/abdera/java/trunk/spring/src/main/java/org/apache/abdera/spring/DefaultProviderDefinitionParser.java
Sun Feb 10 11:32:50 2008
@@ -29,6 +29,7 @@
 import org.springframework.beans.factory.support.BeanDefinitionBuilder;
 import org.springframework.beans.factory.support.ManagedList;
 import org.springframework.beans.factory.xml.ParserContext;
+import org.springframework.util.StringUtils;
 import org.w3c.dom.Element;
 import org.w3c.dom.Node;
 import org.w3c.dom.NodeList;
@@ -47,8 +48,8 @@
 
     @Override
     @SuppressWarnings("unchecked")
-    protected void mapElement(ParserContext ctx, BeanDefinitionBuilder bean, Element element,
String name) {
-        if (name.equals("workspaceManager")) {
+    protected void mapElement(ParserContext ctx, BeanDefinitionBuilder bean, Element element,
String name) {    	
+    	if (name.equals("workspaceManager")) {
             setFirstChildAsProperty(element, ctx, bean, "workspaceManager");
         } else if (name.equals("targetResolver")) {
             setFirstChildAsProperty(element, ctx, bean, "targetResolver");
@@ -61,11 +62,14 @@
             NodeList nodes = element.getChildNodes();
             Object child = null;
             if (element.hasAttribute("ref")) {
+            	if (!StringUtils.hasText(element.getAttribute("ref"))) {
+            		ctx.getReaderContext().error(name + " contains empty 'ref' attribute", element);
           		
+            	}
             	child = new RuntimeBeanReference(element.getAttribute("ref"));
-    			((RuntimeBeanReference)child).setSource(ctx.extractSource(element));    			
+        		((RuntimeBeanReference)child).setSource(ctx.extractSource(element));
             } else if (nodes != null) {            	
 	            for (int i = 0; i < nodes.getLength(); i++) {
-	                Node n = nodes.item(i);
+	                Node n = nodes.item(i);	                
 	                if (n.getNodeType() == org.w3c.dom.Node.ELEMENT_NODE) {
 	                    Element childElement = (Element)n;
 	                    child = ctx.getDelegate().parsePropertySubElement(childElement, bean.getRawBeanDefinition());
                    
@@ -77,9 +81,10 @@
             }
             bean.addPropertyValue("filters", filters);
         } else if (name.equals("workspace")) {
-            String id = getAndRegister(ctx, bean, element);
-            
+            String id = getAndRegister(ctx, bean, element);            
             bean.addPropertyReference("workspaces", id);
+        } else if (name.equals("property")) {
+        	ctx.getDelegate().parsePropertyElement(element, bean.getRawBeanDefinition());
         }
     }
 

Modified: incubator/abdera/java/trunk/spring/src/main/resources/META-INF/schemas/abdera-spring.xsd
URL: http://svn.apache.org/viewvc/incubator/abdera/java/trunk/spring/src/main/resources/META-INF/schemas/abdera-spring.xsd?rev=620313&r1=620312&r2=620313&view=diff
==============================================================================
--- incubator/abdera/java/trunk/spring/src/main/resources/META-INF/schemas/abdera-spring.xsd
(original)
+++ incubator/abdera/java/trunk/spring/src/main/resources/META-INF/schemas/abdera-spring.xsd
Sun Feb 10 11:32:50 2008
@@ -32,7 +32,8 @@
       <xsd:complexContent>
         <xsd:extension base="beans:identifiedType">
           <xsd:sequence>
-            <xsd:element name="workspace" type="xsd:anyType" minOccurs="0" maxOccurs="unbounded"/>
+          	<xsd:element ref="beans:property" minOccurs="0" maxOccurs="unbounded"/>
+          	<xsd:element name="workspace" type="xsd:anyType" minOccurs="0" maxOccurs="unbounded"/>
             <xsd:element name="workspaceManager" type="xsd:anyType" minOccurs="0"/>
             <xsd:element name="targetResolver" type="xsd:anyType" minOccurs="0"/>
             <xsd:element name="subjectResolver" type="xsd:anyType" minOccurs="0"/>

Added: incubator/abdera/java/trunk/spring/src/test/java/org/apache/abdera/spring/ClassicProviderDefinitionParserTest.java
URL: http://svn.apache.org/viewvc/incubator/abdera/java/trunk/spring/src/test/java/org/apache/abdera/spring/ClassicProviderDefinitionParserTest.java?rev=620313&view=auto
==============================================================================
--- incubator/abdera/java/trunk/spring/src/test/java/org/apache/abdera/spring/ClassicProviderDefinitionParserTest.java
(added)
+++ incubator/abdera/java/trunk/spring/src/test/java/org/apache/abdera/spring/ClassicProviderDefinitionParserTest.java
Sun Feb 10 11:32:50 2008
@@ -0,0 +1,10 @@
+package org.apache.abdera.spring;
+
+
+public class ClassicProviderDefinitionParserTest extends ProviderDefinitionParserTest {
+			
+	@Override
+    protected String getConfigPath() {
+        return "/org/apache/abdera/spring/classicBeansDefinition.xml";
+    }
+}

Modified: incubator/abdera/java/trunk/spring/src/test/java/org/apache/abdera/spring/TestSuite.java
URL: http://svn.apache.org/viewvc/incubator/abdera/java/trunk/spring/src/test/java/org/apache/abdera/spring/TestSuite.java?rev=620313&r1=620312&r2=620313&view=diff
==============================================================================
--- incubator/abdera/java/trunk/spring/src/test/java/org/apache/abdera/spring/TestSuite.java
(original)
+++ incubator/abdera/java/trunk/spring/src/test/java/org/apache/abdera/spring/TestSuite.java
Sun Feb 10 11:32:50 2008
@@ -25,7 +25,7 @@
   public static void main(String[] args) {
     JUnitCore runner = new JUnitCore();
     runner.addListener(new TextListener(System.out));
-    runner.run(
-      ProviderDefinitionParserTest.class);
+    runner.run(ProviderDefinitionParserTest.class);
+    runner.run(ClassicProviderDefinitionParserTest.class);
   }
 }

Modified: incubator/abdera/java/trunk/spring/src/test/resources/org/apache/abdera/spring/beans.xml
URL: http://svn.apache.org/viewvc/incubator/abdera/java/trunk/spring/src/test/resources/org/apache/abdera/spring/beans.xml?rev=620313&r1=620312&r2=620313&view=diff
==============================================================================
--- incubator/abdera/java/trunk/spring/src/test/resources/org/apache/abdera/spring/beans.xml
(original)
+++ incubator/abdera/java/trunk/spring/src/test/resources/org/apache/abdera/spring/beans.xml
Sun Feb 10 11:32:50 2008
@@ -8,10 +8,9 @@
 
   <!-- Abdera -->
   <a:provider>
-  
     <a:workspace title="Foo Workspace">
       <!-- These are our collections -->
-      <bean class="org.apache.abdera.spring.TestAdapter"/>
+      <bean class="org.apache.abdera.spring.TestAdapter"/>      
       <ref bean="referencedAdapter"/>
     </a:workspace>
     
@@ -28,6 +27,7 @@
     </a:filter>
     <a:filter ref="referencedFilter"/>
   </a:provider>
+  
   <bean id="referencedAdapter" class="org.apache.abdera.spring.TestAdapter"/>
   <bean id="referencedFilter" class="org.apache.abdera.spring.DummyFilter"/>
 

Added: incubator/abdera/java/trunk/spring/src/test/resources/org/apache/abdera/spring/classicBeansDefinition.xml
URL: http://svn.apache.org/viewvc/incubator/abdera/java/trunk/spring/src/test/resources/org/apache/abdera/spring/classicBeansDefinition.xml?rev=620313&view=auto
==============================================================================
--- incubator/abdera/java/trunk/spring/src/test/resources/org/apache/abdera/spring/classicBeansDefinition.xml
(added)
+++ incubator/abdera/java/trunk/spring/src/test/resources/org/apache/abdera/spring/classicBeansDefinition.xml
Sun Feb 10 11:32:50 2008
@@ -0,0 +1,44 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<beans xmlns="http://www.springframework.org/schema/beans"
+  xmlns:a="http://abdera.apache.org"
+  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+  xsi:schemaLocation="
+    http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd
+    http://abdera.apache.org http://abdera.apache.org/schemas/abdera-spring.xsd">
+
+  <!-- Abdera -->
+  <a:provider>
+  	<property name="filters">
+  		<list>
+  			<ref bean="referencedFilter"/>
+  			<bean class="org.apache.abdera.spring.DummyFilter"/>
+  		</list>
+  	</property>
+    <property name="workspaces">
+    	<ref bean="simpleWorkspace"/>
+    </property>
+     
+    <!-- It is not necessary to specify this, but we're testing it -->
+    <a:targetResolver>
+      <a:regexTargetResolver>
+        <a:collection>/atom/feed(\?[^#]*)?</a:collection>
+        <a:entry>/atom/feed/([^/#?]+)(\?[^#]*)?</a:entry>
+        <a:service>/atom(\?[^#]*)?</a:service>
+      </a:regexTargetResolver>
+    </a:targetResolver>    
+  </a:provider>
+  
+  <bean id="referencedAdapter" class="org.apache.abdera.spring.TestAdapter"/>
+  <bean id="referencedFilter" class="org.apache.abdera.spring.DummyFilter"/>
+
+  <bean id="simpleWorkspace" class="org.apache.abdera.protocol.server.impl.SimpleWorkspaceInfo">
+  	<property name="title" value="Foo Workspace"/>
+  	<property name="collections">
+  		<list>
+  			<bean class="org.apache.abdera.spring.TestAdapter"/>      
+      		<ref bean="referencedAdapter"/>
+  		</list>
+  	</property>
+  </bean>
+
+</beans>
\ No newline at end of file



Mime
View raw message