geronimo-xbean-scm mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jstrac...@apache.org
Subject svn commit: r551137 - in /geronimo/xbean/trunk/xbean-server/src/main/java/org/apache/xbean/server: deployer/ spring/configuration/ spring/loader/
Date Wed, 27 Jun 2007 12:21:28 GMT
Author: jstrachan
Date: Wed Jun 27 05:21:27 2007
New Revision: 551137

URL: http://svn.apache.org/viewvc?view=rev&rev=551137
Log:
minor refactor to allow pure Spring based XmlApplicationContext classes to be used with xbean-server
to boot up spring applications; basically allowing validation to be enabled etc.

Added:
    geronimo/xbean/trunk/xbean-server/src/main/java/org/apache/xbean/server/spring/loader/PureSpringLoader.java
  (with props)
Modified:
    geronimo/xbean/trunk/xbean-server/src/main/java/org/apache/xbean/server/deployer/FileDeployer.java
    geronimo/xbean/trunk/xbean-server/src/main/java/org/apache/xbean/server/spring/configuration/SpringConfiguration.java
    geronimo/xbean/trunk/xbean-server/src/main/java/org/apache/xbean/server/spring/configuration/SpringConfigurationServiceFactory.java
    geronimo/xbean/trunk/xbean-server/src/main/java/org/apache/xbean/server/spring/loader/SpringLoader.java

Modified: geronimo/xbean/trunk/xbean-server/src/main/java/org/apache/xbean/server/deployer/FileDeployer.java
URL: http://svn.apache.org/viewvc/geronimo/xbean/trunk/xbean-server/src/main/java/org/apache/xbean/server/deployer/FileDeployer.java?view=diff&rev=551137&r1=551136&r2=551137
==============================================================================
--- geronimo/xbean/trunk/xbean-server/src/main/java/org/apache/xbean/server/deployer/FileDeployer.java
(original)
+++ geronimo/xbean/trunk/xbean-server/src/main/java/org/apache/xbean/server/deployer/FileDeployer.java
Wed Jun 27 05:21:27 2007
@@ -31,6 +31,7 @@
 import org.springframework.beans.factory.InitializingBean;
 import org.springframework.context.ApplicationContext;
 import org.springframework.context.ApplicationContextAware;
+import org.springframework.context.support.AbstractXmlApplicationContext;
 import org.springframework.core.io.FileSystemResource;
 
 import java.io.File;
@@ -339,7 +340,7 @@
             Thread.currentThread().setContextClassLoader(classLoader);
             log.debug("Loading file: " + file + " using classLoader: " + classLoader);
             try {
-                SpringApplicationContext applicationContext = new ResourceXmlApplicationContext(new
FileSystemResource(file), xmlPreprocessors, parentContext, beanFactoryPostProcessors, false);
+                AbstractXmlApplicationContext applicationContext = new ResourceXmlApplicationContext(new
FileSystemResource(file), xmlPreprocessors, parentContext, beanFactoryPostProcessors, false);
                 applicationContext.setDisplayName(name);
                 applicationContext.setClassLoader(classLoader);
 

Modified: geronimo/xbean/trunk/xbean-server/src/main/java/org/apache/xbean/server/spring/configuration/SpringConfiguration.java
URL: http://svn.apache.org/viewvc/geronimo/xbean/trunk/xbean-server/src/main/java/org/apache/xbean/server/spring/configuration/SpringConfiguration.java?view=diff&rev=551137&r1=551136&r2=551137
==============================================================================
--- geronimo/xbean/trunk/xbean-server/src/main/java/org/apache/xbean/server/spring/configuration/SpringConfiguration.java
(original)
+++ geronimo/xbean/trunk/xbean-server/src/main/java/org/apache/xbean/server/spring/configuration/SpringConfiguration.java
Wed Jun 27 05:21:27 2007
@@ -32,6 +32,7 @@
 import org.apache.xbean.server.spring.loader.SpringLoader;
 import org.springframework.beans.factory.config.BeanDefinition;
 import org.springframework.beans.factory.support.BeanDefinitionRegistry;
+import org.springframework.context.support.AbstractXmlApplicationContext;
 
 /**
  * SpringConfiguration that registers and unregisters services that have been defined in
a SpringApplicationContext.
@@ -41,7 +42,7 @@
  * @since 2.0
  */
 public class SpringConfiguration {
-    private final SpringApplicationContext applicationContext;
+    private final AbstractXmlApplicationContext applicationContext;
     private final Map serviceFactories;
     private final Kernel kernel;
 
@@ -51,7 +52,7 @@
      * @param kernel the kernel in which services are registered and unregistered
      * @throws Exception if a problem occurs while registering the services from the application
context
      */
-    public SpringConfiguration(SpringApplicationContext applicationContext, Kernel kernel)
throws Exception {
+    public SpringConfiguration(AbstractXmlApplicationContext applicationContext, Kernel kernel)
throws Exception {
         this.applicationContext = applicationContext;
         this.kernel = kernel;
 
@@ -143,7 +144,7 @@
         }
     }
 
-    private static Map buildServiceNameIndex(SpringApplicationContext applicationContext)
{
+    private static Map buildServiceNameIndex(AbstractXmlApplicationContext applicationContext)
{
         BeanDefinitionRegistry registry = null;
         if (applicationContext instanceof BeanDefinitionRegistry) {
             registry = (BeanDefinitionRegistry) applicationContext;
@@ -174,7 +175,7 @@
         }
     }
 
-    protected static ClassLoader getClassLoader(SpringApplicationContext applicationContext)
{
+    protected static ClassLoader getClassLoader(AbstractXmlApplicationContext applicationContext)
{
         ClassLoader classLoader = applicationContext.getClassLoader();
         if (classLoader == null) {
             classLoader = Thread.currentThread().getContextClassLoader();

Modified: geronimo/xbean/trunk/xbean-server/src/main/java/org/apache/xbean/server/spring/configuration/SpringConfigurationServiceFactory.java
URL: http://svn.apache.org/viewvc/geronimo/xbean/trunk/xbean-server/src/main/java/org/apache/xbean/server/spring/configuration/SpringConfigurationServiceFactory.java?view=diff&rev=551137&r1=551136&r2=551137
==============================================================================
--- geronimo/xbean/trunk/xbean-server/src/main/java/org/apache/xbean/server/spring/configuration/SpringConfigurationServiceFactory.java
(original)
+++ geronimo/xbean/trunk/xbean-server/src/main/java/org/apache/xbean/server/spring/configuration/SpringConfigurationServiceFactory.java
Wed Jun 27 05:21:27 2007
@@ -30,7 +30,7 @@
 import org.apache.xbean.kernel.ServiceContext;
 import org.apache.xbean.kernel.ServiceFactory;
 import org.apache.xbean.kernel.ServiceName;
-import org.apache.xbean.spring.context.SpringApplicationContext;
+import org.springframework.context.support.AbstractXmlApplicationContext;
 
 /**
  * SpringConfigurationServiceFactory is manages the creation and destruction of a SpringConfiguration.
@@ -40,7 +40,7 @@
  * @since 2.0
  */
 public class SpringConfigurationServiceFactory extends AbstractServiceFactory {
-    private final SpringApplicationContext applicationContext;
+    private final AbstractXmlApplicationContext applicationContext;
     private final ConfigurationStopCondition configurationStopCondition;
     private SpringConfiguration springConfiguration;
 
@@ -48,7 +48,7 @@
      * Creates a SpringConfigurationServiceFactory that wraps the specified application context.
      * @param applicationContext the application context for this configuration
      */
-    public SpringConfigurationServiceFactory(SpringApplicationContext applicationContext)
{
+    public SpringConfigurationServiceFactory(AbstractXmlApplicationContext applicationContext)
{
         this.applicationContext = applicationContext;
         configurationStopCondition = new ConfigurationStopCondition();
         addStopCondition(configurationStopCondition);
@@ -67,7 +67,7 @@
      * effect the running state of services.
      * @return the application context wrapped by this configuration
      */
-    public SpringApplicationContext getApplicationContext() {
+    public AbstractXmlApplicationContext getApplicationContext() {
         return applicationContext;
     }
 

Added: geronimo/xbean/trunk/xbean-server/src/main/java/org/apache/xbean/server/spring/loader/PureSpringLoader.java
URL: http://svn.apache.org/viewvc/geronimo/xbean/trunk/xbean-server/src/main/java/org/apache/xbean/server/spring/loader/PureSpringLoader.java?view=auto&rev=551137
==============================================================================
--- geronimo/xbean/trunk/xbean-server/src/main/java/org/apache/xbean/server/spring/loader/PureSpringLoader.java
(added)
+++ geronimo/xbean/trunk/xbean-server/src/main/java/org/apache/xbean/server/spring/loader/PureSpringLoader.java
Wed Jun 27 05:21:27 2007
@@ -0,0 +1,35 @@
+/**
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.xbean.server.spring.loader;
+
+import org.springframework.context.support.AbstractXmlApplicationContext;
+import org.springframework.context.support.FileSystemXmlApplicationContext;
+
+/**
+ * A derivation of {@link SpringLoader} which does not use the XBean versions of the Spring
ApplicationContext classes
+ * and which so enforces XML validation
+ *
+ * @version $Revision: 1.1 $
+ */
+public class PureSpringLoader extends SpringLoader {
+    
+    @Override
+    protected AbstractXmlApplicationContext createXmlApplicationContext(String configLocation)
{
+        return new FileSystemXmlApplicationContext(new String[]{configLocation}, false);
+    }
+}

Propchange: geronimo/xbean/trunk/xbean-server/src/main/java/org/apache/xbean/server/spring/loader/PureSpringLoader.java
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: geronimo/xbean/trunk/xbean-server/src/main/java/org/apache/xbean/server/spring/loader/SpringLoader.java
URL: http://svn.apache.org/viewvc/geronimo/xbean/trunk/xbean-server/src/main/java/org/apache/xbean/server/spring/loader/SpringLoader.java?view=diff&rev=551137&r1=551136&r2=551137
==============================================================================
--- geronimo/xbean/trunk/xbean-server/src/main/java/org/apache/xbean/server/spring/loader/SpringLoader.java
(original)
+++ geronimo/xbean/trunk/xbean-server/src/main/java/org/apache/xbean/server/spring/loader/SpringLoader.java
Wed Jun 27 05:21:27 2007
@@ -30,7 +30,7 @@
 import org.apache.xbean.spring.context.FileSystemXmlApplicationContext;
 import org.apache.xbean.spring.context.SpringApplicationContext;
 import org.springframework.beans.factory.config.BeanFactoryPostProcessor;
-
+import org.springframework.context.support.AbstractXmlApplicationContext;
 
 /**
  * SpringLoader loads Spring xml configurations into a Kernel.  This service uses the XBean
version of
@@ -130,10 +130,7 @@
     public ServiceName load(String location) throws Exception {
         String resolvedLocation = baseDir.toURI().resolve(location).getPath();
         String configLocation = "/" + resolvedLocation + ".xml";
-        SpringApplicationContext applicationContext = new FileSystemXmlApplicationContext(
-                new String[] {configLocation},
-                false,
-                xmlPreprocessors);
+        AbstractXmlApplicationContext applicationContext = createXmlApplicationContext(configLocation);
 
         for (Iterator iter = beanFactoryPostProcessors.iterator(); iter.hasNext();) {
             BeanFactoryPostProcessor processor = (BeanFactoryPostProcessor) iter.next();
@@ -153,5 +150,15 @@
         ServiceFactory springConfigurationServiceFactory = new SpringConfigurationServiceFactory(applicationContext);
         kernel.registerService(serviceName, springConfigurationServiceFactory);
         return serviceName;
+    }
+
+    /**
+     * A factory method for creating the application context
+     */
+    protected AbstractXmlApplicationContext createXmlApplicationContext(String configLocation)
{
+        return new FileSystemXmlApplicationContext(
+                new String[] {configLocation},
+                false,
+                xmlPreprocessors);
     }
 }



Mime
View raw message