geronimo-scm mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From gno...@apache.org
Subject svn commit: r412089 - in /geronimo/xbean/branches/spring2/trunk/xbean-spring-common: ./ src/main/java/org/apache/xbean/spring/context/ src/main/java/org/apache/xbean/spring/context/impl/ src/main/java/org/apache/xbean/spring/generator/ src/test/
Date Tue, 06 Jun 2006 11:21:02 GMT
Author: gnodet
Date: Tue Jun  6 04:21:01 2006
New Revision: 412089

URL: http://svn.apache.org/viewvc?rev=412089&view=rev
Log:
Remove tests, create a loose coupling to the xbean implementation depending on spring major
version
Remove implementation specific classes

Added:
    geronimo/xbean/branches/spring2/trunk/xbean-spring-common/src/main/java/org/apache/xbean/spring/context/impl/XBeanHelper.java
Removed:
    geronimo/xbean/branches/spring2/trunk/xbean-spring-common/src/main/java/org/apache/xbean/spring/context/impl/XBeanXmlBeanDefinitionParser.java
    geronimo/xbean/branches/spring2/trunk/xbean-spring-common/src/main/java/org/apache/xbean/spring/context/impl/XBeanXmlBeanDefinitionReader.java
    geronimo/xbean/branches/spring2/trunk/xbean-spring-common/src/test/
Modified:
    geronimo/xbean/branches/spring2/trunk/xbean-spring-common/pom.xml
    geronimo/xbean/branches/spring2/trunk/xbean-spring-common/src/main/java/org/apache/xbean/spring/context/ClassPathXmlApplicationContext.java
    geronimo/xbean/branches/spring2/trunk/xbean-spring-common/src/main/java/org/apache/xbean/spring/context/FileSystemXmlApplicationContext.java
    geronimo/xbean/branches/spring2/trunk/xbean-spring-common/src/main/java/org/apache/xbean/spring/context/ResourceXmlApplicationContext.java
    geronimo/xbean/branches/spring2/trunk/xbean-spring-common/src/main/java/org/apache/xbean/spring/context/XmlWebApplicationContext.java
    geronimo/xbean/branches/spring2/trunk/xbean-spring-common/src/main/java/org/apache/xbean/spring/context/impl/XBeanXmlBeanFactory.java
    geronimo/xbean/branches/spring2/trunk/xbean-spring-common/src/main/java/org/apache/xbean/spring/generator/XmlMetadataGenerator.java

Modified: geronimo/xbean/branches/spring2/trunk/xbean-spring-common/pom.xml
URL: http://svn.apache.org/viewvc/geronimo/xbean/branches/spring2/trunk/xbean-spring-common/pom.xml?rev=412089&r1=412088&r2=412089&view=diff
==============================================================================
--- geronimo/xbean/branches/spring2/trunk/xbean-spring-common/pom.xml (original)
+++ geronimo/xbean/branches/spring2/trunk/xbean-spring-common/pom.xml Tue Jun  6 04:21:01
2006
@@ -5,47 +5,9 @@
     <version>2.4-SNAPSHOT</version>
   </parent>
   <modelVersion>4.0.0</modelVersion>
-  <artifactId>xbean-spring</artifactId>
-  <name>XBean :: Spring</name>
+  <artifactId>xbean-spring-common</artifactId>
+  <name>XBean :: Spring :: Common</name>
   <version>2.4-SNAPSHOT</version>
-  <build>
-    <testResources>
-      <testResource>
-        <directory>src/test/resources</directory>
-      </testResource>
-      <testResource>
-        <directory>target/test-generated</directory>
-      </testResource>
-    </testResources>
-    <plugins>
-      <plugin>
-        <artifactId>maven-antrun-plugin</artifactId>
-        <executions>
-          <execution>
-            <phase>process-classes</phase>
-            <goals>
-              <goal>run</goal>
-            </goals>
-            <configuration>
-              <tasks>
-                <taskdef classname="org.apache.xbean.spring.generator.MappingGeneratorTask"
name="mapping">
-                  <classpath>
-                    <pathelement path="${basedir}/target/classes"></pathelement>
-                    <pathelement path="${basedir}/target/test-classes"></pathelement>
-                    <path refid="maven.runtime.classpath"></path>
-                  </classpath>
-                </taskdef>
-                <mapping namespace="http://xbean.apache.org/schemas/pizza" srcdir="src/test/java"
destFile="target/restaurant.xsd" metaInfDir="${basedir}/target/test-generated/"></mapping>
-                <copy todir="${basedir}/target/test-classes">
-                  <fileset dir="${basedir}/target/test-generated"></fileset>
-                </copy>
-              </tasks>
-            </configuration>
-          </execution>
-        </executions>
-      </plugin>
-    </plugins>
-  </build>
   <dependencies>
     <dependency>
       <groupId>mx4j</groupId>

Modified: geronimo/xbean/branches/spring2/trunk/xbean-spring-common/src/main/java/org/apache/xbean/spring/context/ClassPathXmlApplicationContext.java
URL: http://svn.apache.org/viewvc/geronimo/xbean/branches/spring2/trunk/xbean-spring-common/src/main/java/org/apache/xbean/spring/context/ClassPathXmlApplicationContext.java?rev=412089&r1=412088&r2=412089&view=diff
==============================================================================
--- geronimo/xbean/branches/spring2/trunk/xbean-spring-common/src/main/java/org/apache/xbean/spring/context/ClassPathXmlApplicationContext.java
(original)
+++ geronimo/xbean/branches/spring2/trunk/xbean-spring-common/src/main/java/org/apache/xbean/spring/context/ClassPathXmlApplicationContext.java
Tue Jun  6 04:21:01 2006
@@ -17,15 +17,19 @@
  **/
 package org.apache.xbean.spring.context;
 
+import java.io.IOException;
+import java.lang.reflect.Constructor;
+import java.util.Collections;
+import java.util.List;
+
+import org.apache.xbean.spring.context.impl.XBeanHelper;
 import org.springframework.beans.BeansException;
+import org.springframework.beans.factory.support.BeanDefinitionRegistry;
 import org.springframework.beans.factory.support.DefaultListableBeanFactory;
+import org.springframework.beans.factory.xml.ResourceEntityResolver;
 import org.springframework.beans.factory.xml.XmlBeanDefinitionReader;
 import org.springframework.context.ApplicationContext;
-import org.apache.xbean.spring.context.impl.XBeanXmlBeanDefinitionReader;
-
-import java.io.IOException;
-import java.util.Collections;
-import java.util.List;
+import org.springframework.core.SpringVersion;
 
 /**
  * An XBean version of the regular Spring class to provide improved XML handling.
@@ -163,10 +167,18 @@
      * {@inheritDoc}
      */
     protected void loadBeanDefinitions(DefaultListableBeanFactory beanFactory) throws IOException
{
-        XmlBeanDefinitionReader beanDefinitionReader = new XBeanXmlBeanDefinitionReader(this,
beanFactory, xmlPreprocessors);
+        // Create a new XmlBeanDefinitionReader for the given BeanFactory.
+        XmlBeanDefinitionReader beanDefinitionReader = XBeanHelper.createBeanDefinitionReader(this,
beanFactory, xmlPreprocessors);
 
-        initBeanDefinitionReader(beanDefinitionReader);
+        // Configure the bean definition reader with this context's
+        // resource loading environment.
+        beanDefinitionReader.setResourceLoader(this);
+        beanDefinitionReader.setEntityResolver(new ResourceEntityResolver(this));
 
+        // Allow a subclass to provide custom initialization of the reader,
+        // then proceed with actually loading the bean definitions.
+        initBeanDefinitionReader(beanDefinitionReader);
         loadBeanDefinitions(beanDefinitionReader);
     }
+    
 }

Modified: geronimo/xbean/branches/spring2/trunk/xbean-spring-common/src/main/java/org/apache/xbean/spring/context/FileSystemXmlApplicationContext.java
URL: http://svn.apache.org/viewvc/geronimo/xbean/branches/spring2/trunk/xbean-spring-common/src/main/java/org/apache/xbean/spring/context/FileSystemXmlApplicationContext.java?rev=412089&r1=412088&r2=412089&view=diff
==============================================================================
--- geronimo/xbean/branches/spring2/trunk/xbean-spring-common/src/main/java/org/apache/xbean/spring/context/FileSystemXmlApplicationContext.java
(original)
+++ geronimo/xbean/branches/spring2/trunk/xbean-spring-common/src/main/java/org/apache/xbean/spring/context/FileSystemXmlApplicationContext.java
Tue Jun  6 04:21:01 2006
@@ -17,15 +17,16 @@
  **/
 package org.apache.xbean.spring.context;
 
+import java.io.IOException;
+import java.util.Collections;
+import java.util.List;
+
+import org.apache.xbean.spring.context.impl.XBeanHelper;
 import org.springframework.beans.BeansException;
 import org.springframework.beans.factory.support.DefaultListableBeanFactory;
+import org.springframework.beans.factory.xml.ResourceEntityResolver;
 import org.springframework.beans.factory.xml.XmlBeanDefinitionReader;
 import org.springframework.context.ApplicationContext;
-import org.apache.xbean.spring.context.impl.XBeanXmlBeanDefinitionReader;
-
-import java.io.IOException;
-import java.util.Collections;
-import java.util.List;
 
 /**
  * An XBean version of the regular Spring class to provide improved XML
@@ -154,10 +155,18 @@
      * {@inheritDoc}
      */
     protected void loadBeanDefinitions(DefaultListableBeanFactory beanFactory) throws IOException
{
-        XmlBeanDefinitionReader beanDefinitionReader = new XBeanXmlBeanDefinitionReader(this,
beanFactory, xmlPreprocessors);
+        // Create a new XmlBeanDefinitionReader for the given BeanFactory.
+        XmlBeanDefinitionReader beanDefinitionReader = XBeanHelper.createBeanDefinitionReader(this,
beanFactory, xmlPreprocessors);
 
-        initBeanDefinitionReader(beanDefinitionReader);
+        // Configure the bean definition reader with this context's
+        // resource loading environment.
+        beanDefinitionReader.setResourceLoader(this);
+        beanDefinitionReader.setEntityResolver(new ResourceEntityResolver(this));
 
+        // Allow a subclass to provide custom initialization of the reader,
+        // then proceed with actually loading the bean definitions.
+        initBeanDefinitionReader(beanDefinitionReader);
         loadBeanDefinitions(beanDefinitionReader);
     }
+    
 }

Modified: geronimo/xbean/branches/spring2/trunk/xbean-spring-common/src/main/java/org/apache/xbean/spring/context/ResourceXmlApplicationContext.java
URL: http://svn.apache.org/viewvc/geronimo/xbean/branches/spring2/trunk/xbean-spring-common/src/main/java/org/apache/xbean/spring/context/ResourceXmlApplicationContext.java?rev=412089&r1=412088&r2=412089&view=diff
==============================================================================
--- geronimo/xbean/branches/spring2/trunk/xbean-spring-common/src/main/java/org/apache/xbean/spring/context/ResourceXmlApplicationContext.java
(original)
+++ geronimo/xbean/branches/spring2/trunk/xbean-spring-common/src/main/java/org/apache/xbean/spring/context/ResourceXmlApplicationContext.java
Tue Jun  6 04:21:01 2006
@@ -17,19 +17,20 @@
  **/
 package org.apache.xbean.spring.context;
 
+import java.io.IOException;
+import java.util.Collections;
+import java.util.Iterator;
+import java.util.List;
+
+import org.apache.xbean.spring.context.impl.XBeanHelper;
 import org.springframework.beans.BeansException;
 import org.springframework.beans.factory.config.BeanFactoryPostProcessor;
 import org.springframework.beans.factory.support.DefaultListableBeanFactory;
+import org.springframework.beans.factory.xml.ResourceEntityResolver;
 import org.springframework.beans.factory.xml.XmlBeanDefinitionReader;
 import org.springframework.context.ApplicationContext;
 import org.springframework.context.support.AbstractXmlApplicationContext;
 import org.springframework.core.io.Resource;
-import org.apache.xbean.spring.context.impl.XBeanXmlBeanDefinitionReader;
-
-import java.io.IOException;
-import java.util.Collections;
-import java.util.Iterator;
-import java.util.List;
 
 /**
  * An XBean version of a regular Spring ApplicationContext which takes a
@@ -84,13 +85,20 @@
     }
 
     protected void loadBeanDefinitions(DefaultListableBeanFactory beanFactory) throws IOException
{
-        XmlBeanDefinitionReader beanDefinitionReader = new XBeanXmlBeanDefinitionReader(this,
beanFactory, xmlPreprocessors);
+        // Create a new XmlBeanDefinitionReader for the given BeanFactory.
+        XmlBeanDefinitionReader beanDefinitionReader = XBeanHelper.createBeanDefinitionReader(this,
beanFactory, xmlPreprocessors);
 
-        initBeanDefinitionReader(beanDefinitionReader);
+        // Configure the bean definition reader with this context's
+        // resource loading environment.
+        beanDefinitionReader.setResourceLoader(this);
+        beanDefinitionReader.setEntityResolver(new ResourceEntityResolver(this));
 
+        // Allow a subclass to provide custom initialization of the reader,
+        // then proceed with actually loading the bean definitions.
+        initBeanDefinitionReader(beanDefinitionReader);
         loadBeanDefinitions(beanDefinitionReader);
     }
-
+    
     /**
      * {@inheritDoc}
      */

Modified: geronimo/xbean/branches/spring2/trunk/xbean-spring-common/src/main/java/org/apache/xbean/spring/context/XmlWebApplicationContext.java
URL: http://svn.apache.org/viewvc/geronimo/xbean/branches/spring2/trunk/xbean-spring-common/src/main/java/org/apache/xbean/spring/context/XmlWebApplicationContext.java?rev=412089&r1=412088&r2=412089&view=diff
==============================================================================
--- geronimo/xbean/branches/spring2/trunk/xbean-spring-common/src/main/java/org/apache/xbean/spring/context/XmlWebApplicationContext.java
(original)
+++ geronimo/xbean/branches/spring2/trunk/xbean-spring-common/src/main/java/org/apache/xbean/spring/context/XmlWebApplicationContext.java
Tue Jun  6 04:21:01 2006
@@ -17,14 +17,17 @@
  **/
 package org.apache.xbean.spring.context;
 
-import org.springframework.beans.factory.support.DefaultListableBeanFactory;
-import org.springframework.beans.factory.xml.XmlBeanDefinitionReader;
-import org.apache.xbean.spring.context.impl.XBeanXmlBeanDefinitionReader;
-
 import java.io.IOException;
+import java.lang.reflect.Constructor;
 import java.util.Collections;
 import java.util.List;
 
+import org.springframework.beans.factory.support.BeanDefinitionRegistry;
+import org.springframework.beans.factory.support.DefaultListableBeanFactory;
+import org.springframework.beans.factory.xml.ResourceEntityResolver;
+import org.springframework.beans.factory.xml.XmlBeanDefinitionReader;
+import org.springframework.core.SpringVersion;
+
 /**
  * An XBean version of the regular Spring class to provide improved XML
  * handling.
@@ -56,10 +59,29 @@
      * {@inheritDoc}
      */
     protected void loadBeanDefinitions(DefaultListableBeanFactory beanFactory) throws IOException
{
-        XmlBeanDefinitionReader beanDefinitionReader = new XBeanXmlBeanDefinitionReader(this,
beanFactory, xmlPreprocessors);
+        // Create a new XmlBeanDefinitionReader for the given BeanFactory.
+        XmlBeanDefinitionReader beanDefinitionReader = createBeanDefinitionReader(beanFactory);
 
-        initBeanDefinitionReader(beanDefinitionReader);
+        // Configure the bean definition reader with this context's
+        // resource loading environment.
+        beanDefinitionReader.setResourceLoader(this);
+        beanDefinitionReader.setEntityResolver(new ResourceEntityResolver(this));
 
+        // Allow a subclass to provide custom initialization of the reader,
+        // then proceed with actually loading the bean definitions.
+        initBeanDefinitionReader(beanDefinitionReader);
         loadBeanDefinitions(beanDefinitionReader);
+    }
+    
+    protected XmlBeanDefinitionReader createBeanDefinitionReader(DefaultListableBeanFactory
beanFactory) {
+        String version = SpringVersion.getVersion();
+        String className = "org.apache.xbean.spring.v" + version.charAt(0) + ".XBeanXmlBeanDefinitionReader";
+        try {
+            Class cl = Class.forName(className);
+            Constructor cstr = cl.getConstructor(new Class[] { SpringApplicationContext.class,
BeanDefinitionRegistry.class, List.class });
+            return (XmlBeanDefinitionReader) cstr.newInstance(new Object[] { this, beanFactory,
xmlPreprocessors });
+        } catch (Exception e) {
+            throw new IllegalStateException("Could not find valid implementation for: " +
version);
+        }
     }
 }

Added: geronimo/xbean/branches/spring2/trunk/xbean-spring-common/src/main/java/org/apache/xbean/spring/context/impl/XBeanHelper.java
URL: http://svn.apache.org/viewvc/geronimo/xbean/branches/spring2/trunk/xbean-spring-common/src/main/java/org/apache/xbean/spring/context/impl/XBeanHelper.java?rev=412089&view=auto
==============================================================================
--- geronimo/xbean/branches/spring2/trunk/xbean-spring-common/src/main/java/org/apache/xbean/spring/context/impl/XBeanHelper.java
(added)
+++ geronimo/xbean/branches/spring2/trunk/xbean-spring-common/src/main/java/org/apache/xbean/spring/context/impl/XBeanHelper.java
Tue Jun  6 04:21:01 2006
@@ -0,0 +1,27 @@
+package org.apache.xbean.spring.context.impl;
+
+import java.lang.reflect.Constructor;
+import java.util.List;
+
+import org.apache.xbean.spring.context.SpringApplicationContext;
+import org.springframework.beans.factory.support.BeanDefinitionRegistry;
+import org.springframework.beans.factory.xml.XmlBeanDefinitionReader;
+import org.springframework.core.SpringVersion;
+
+public class XBeanHelper {
+
+    public static XmlBeanDefinitionReader createBeanDefinitionReader(
+                    SpringApplicationContext applicationContext,
+                    BeanDefinitionRegistry registry,
+                    List xmlPreprocessors) {
+        String version = SpringVersion.getVersion();
+        String className = "org.apache.xbean.spring.context.v" + version.charAt(0) + ".XBeanXmlBeanDefinitionReader";
+        try {
+            Class cl = Class.forName(className);
+            Constructor cstr = cl.getConstructor(new Class[] { SpringApplicationContext.class,
BeanDefinitionRegistry.class, List.class });
+            return (XmlBeanDefinitionReader) cstr.newInstance(new Object[] { applicationContext,
registry, xmlPreprocessors });
+        } catch (Exception e) {
+            throw new IllegalStateException("Could not find valid implementation for: " +
version, e);
+        }
+    }
+}

Modified: geronimo/xbean/branches/spring2/trunk/xbean-spring-common/src/main/java/org/apache/xbean/spring/context/impl/XBeanXmlBeanFactory.java
URL: http://svn.apache.org/viewvc/geronimo/xbean/branches/spring2/trunk/xbean-spring-common/src/main/java/org/apache/xbean/spring/context/impl/XBeanXmlBeanFactory.java?rev=412089&r1=412088&r2=412089&view=diff
==============================================================================
--- geronimo/xbean/branches/spring2/trunk/xbean-spring-common/src/main/java/org/apache/xbean/spring/context/impl/XBeanXmlBeanFactory.java
(original)
+++ geronimo/xbean/branches/spring2/trunk/xbean-spring-common/src/main/java/org/apache/xbean/spring/context/impl/XBeanXmlBeanFactory.java
Tue Jun  6 04:21:01 2006
@@ -16,14 +16,15 @@
  */
 package org.apache.xbean.spring.context.impl;
 
+import java.util.Collections;
+import java.util.List;
+
 import org.springframework.beans.BeansException;
 import org.springframework.beans.factory.BeanFactory;
 import org.springframework.beans.factory.support.DefaultListableBeanFactory;
+import org.springframework.beans.factory.xml.XmlBeanDefinitionReader;
 import org.springframework.core.io.Resource;
 
-import java.util.Collections;
-import java.util.List;
-
 public class XBeanXmlBeanFactory extends DefaultListableBeanFactory {
 
     /**
@@ -68,7 +69,7 @@
      */
     public XBeanXmlBeanFactory(Resource resource, BeanFactory parentBeanFactory, List xmlPreprocessors)
throws BeansException {
         super(parentBeanFactory);
-        XBeanXmlBeanDefinitionReader reader = new XBeanXmlBeanDefinitionReader(null, this,
xmlPreprocessors);
+        XmlBeanDefinitionReader reader = XBeanHelper.createBeanDefinitionReader(null, this,
xmlPreprocessors);
         reader.loadBeanDefinitions(resource);
     }
 

Modified: geronimo/xbean/branches/spring2/trunk/xbean-spring-common/src/main/java/org/apache/xbean/spring/generator/XmlMetadataGenerator.java
URL: http://svn.apache.org/viewvc/geronimo/xbean/branches/spring2/trunk/xbean-spring-common/src/main/java/org/apache/xbean/spring/generator/XmlMetadataGenerator.java?rev=412089&r1=412088&r2=412089&view=diff
==============================================================================
--- geronimo/xbean/branches/spring2/trunk/xbean-spring-common/src/main/java/org/apache/xbean/spring/generator/XmlMetadataGenerator.java
(original)
+++ geronimo/xbean/branches/spring2/trunk/xbean-spring-common/src/main/java/org/apache/xbean/spring/generator/XmlMetadataGenerator.java
Tue Jun  6 04:21:01 2006
@@ -36,6 +36,8 @@
 public class XmlMetadataGenerator implements GeneratorPlugin {
     private final String metaInfDir;
     private final LogFacade log;
+    
+    public static final String NAMESPACE_HANDLER = "org.apache.xbean.spring.context.v2.XBeanNamespaceHandler";
 
     public XmlMetadataGenerator(LogFacade log, String metaInfDir) {
         this.metaInfDir = metaInfDir;
@@ -54,6 +56,16 @@
         PrintWriter out = new PrintWriter(new FileWriter(file));
         try {
             generatePropertiesFile(out, namespaceMapping.getElements());
+        } finally {
+            out.close();
+        }
+        
+        // Generate spring 2.0 mapping
+        file = new File(metaInfDir, "META-INF/spring.handlers");
+        log.log("Generating Spring 2.0 handler mapping: " + file + " for namespace: " + namespace);
+        out = new PrintWriter(new FileWriter(file));
+        try {
+            out.println(namespace.replace(":", "\\:") + "=" + NAMESPACE_HANDLER);
         } finally {
             out.close();
         }



Mime
View raw message