abdera-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jmsn...@apache.org
Subject svn commit: r619687 - in /incubator/abdera/java/trunk: build/ spring/src/main/java/org/apache/abdera/spring/ spring/src/main/resources/META-INF/schemas/ spring/src/test/java/org/apache/abdera/spring/ spring/src/test/resources/org/apache/abdera/spring/
Date Thu, 07 Feb 2008 23:40:39 GMT
Author: jmsnell
Date: Thu Feb  7 15:40:35 2008
New Revision: 619687

URL: http://svn.apache.org/viewvc?rev=619687&view=rev
Log:
Per https://issues.apache.org/jira/browse/ABDERA-105.. "spring provider definition parser
doesn't load more than one filter"

Modified:
    incubator/abdera/java/trunk/build/build.xml
    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/ProviderDefinitionParserTest.java
    incubator/abdera/java/trunk/spring/src/test/resources/org/apache/abdera/spring/beans.xml

Modified: incubator/abdera/java/trunk/build/build.xml
URL: http://svn.apache.org/viewvc/incubator/abdera/java/trunk/build/build.xml?rev=619687&r1=619686&r2=619687&view=diff
==============================================================================
--- incubator/abdera/java/trunk/build/build.xml (original)
+++ incubator/abdera/java/trunk/build/build.xml Thu Feb  7 15:40:35 2008
@@ -416,6 +416,17 @@
       <arg line="${bouncycastle.provider}" />
     </java>
   </target>
+	
+	<target name="test.spring" depends="compile.spring" if="do.spring">
+		<echo>Running Spring Tests...</echo>
+		<path id="spring.dependencies">
+		      <path refid="jar.dependencies" />
+		      <fileset dir="${basedir}/build/tools/${spring.name}/dist" includes="**/*.jar"
/>
+		      <fileset dir="${basedir}/build/tools/${spring.name}/dist/modules" includes="**/*.jar"
/>
+		    </path>
+		<java classpathref="spring.dependencies" classpath="${core.work}:${parser.work}:${server.work}:${security.work}:${client.work}:${protocol.work}:${spring.work}:${test}"
classname="org.apache.abdera.spring.TestSuite" fork="yes">
+	    </java>
+	</target>
 
   <target name="clean">
     <delete dir="${work}" />

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=619687&r1=619686&r2=619687&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
Thu Feb  7 15:40:35 2008
@@ -18,8 +18,13 @@
  */
 package org.apache.abdera.spring;
 
+import java.util.List;
+
 import org.apache.abdera.protocol.server.Provider;
+import org.springframework.beans.MutablePropertyValues;
+import org.springframework.beans.PropertyValue;
 import org.springframework.beans.factory.BeanDefinitionStoreException;
+import org.springframework.beans.factory.config.RuntimeBeanReference;
 import org.springframework.beans.factory.support.AbstractBeanDefinition;
 import org.springframework.beans.factory.support.BeanDefinitionBuilder;
 import org.springframework.beans.factory.support.ManagedList;
@@ -41,6 +46,7 @@
     }
 
     @Override
+    @SuppressWarnings("unchecked")
     protected void mapElement(ParserContext ctx, BeanDefinitionBuilder bean, Element element,
String name) {
         if (name.equals("workspaceManager")) {
             setFirstChildAsProperty(element, ctx, bean, "workspaceManager");
@@ -48,16 +54,26 @@
             setFirstChildAsProperty(element, ctx, bean, "targetResolver");
         } else if (name.equals("subjectResolver")) {
             setFirstChildAsProperty(element, ctx, bean, name);
-        } else if (name.equals("filter")) {
-            ManagedList filters = new ManagedList();
+        } else if (name.equals("filter")) {        	
+        	MutablePropertyValues values = bean.getBeanDefinition().getPropertyValues();
+        	PropertyValue pv = values.getPropertyValue("filters");
+        	List filters = pv != null?(List) pv.getValue():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;
-                    Object child = ctx.getDelegate().parsePropertySubElement(childElement,
bean.getRawBeanDefinition());
-                    filters.add(child);
-                }
+            Object child = null;
+            if (element.hasAttribute("ref")) {
+            	child = new RuntimeBeanReference(element.getAttribute("ref"));
+    			((RuntimeBeanReference)child).setSource(ctx.extractSource(element));    			
+            } else if (nodes != null) {            	
+	            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;
+	                    child = ctx.getDelegate().parsePropertySubElement(childElement, bean.getRawBeanDefinition());
                    
+	                }
+	            }	            
+            }
+            if (child != null) {
+            	filters.add(child);
             }
             bean.addPropertyValue("filters", filters);
         } else if (name.equals("workspace")) {

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=619687&r1=619686&r2=619687&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
Thu Feb  7 15:40:35 2008
@@ -83,8 +83,9 @@
             <xsd:element ref="beans:bean" minOccurs="0" maxOccurs="unbounded"/>
             <xsd:element ref="beans:ref" minOccurs="0" maxOccurs="unbounded"/>
           </xsd:sequence>
+          <xsd:attribute name="ref" type="xsd:string"/>
         </xsd:extension>
-      </xsd:complexContent>
+      </xsd:complexContent>      
     </xsd:complexType>
   </xsd:element>
 </xsd:schema>

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=619687&r1=619686&r2=619687&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
Thu Feb  7 15:40:35 2008
@@ -54,8 +54,7 @@
         Collection<CollectionInfo> collections = w.getCollections(null);
         assertEquals(2, collections.size());
         
-        assertEquals(1, p.getFilters(null).length); //Parameter isn't used
-        
+        assertEquals(2, p.getFilters(null).length); //Parameter isn't used
     }
     
     @Override

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=619687&r1=619686&r2=619687&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
Thu Feb  7 15:40:35 2008
@@ -25,8 +25,10 @@
     </a:targetResolver>
     <a:filter>
       <bean class="org.apache.abdera.spring.DummyFilter"/>
-    </a:filter>    
+    </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"/>
 
 </beans>



Mime
View raw message