Thank you David,

I don't know how I lost this while committing! Thank you for reviewing!

Stefano

David Jencks ha scritto:
This all looks good but I have to make the following changes to get the build to go:

Index: spring-deployment/pom.xml
===================================================================
--- spring-deployment/pom.xml   (revision 676029)
+++ spring-deployment/pom.xml   (working copy)
@@ -44,5 +44,9 @@
       <groupId>org.apache.james</groupId>
       <artifactId>james-server-core-library</artifactId>
     </dependency>
-  </dependencies>
-</project>
\ No newline at end of file
+    <dependency>
+      <groupId>org.apache.james</groupId>
+      <artifactId>james-server-avalon-spring-bridge-library</artifactId>
+    </dependency>
+   </dependencies>
+</project>
Index: avalon-spring-bridge-library/pom.xml
===================================================================
--- avalon-spring-bridge-library/pom.xml        (revision 676029)
+++ avalon-spring-bridge-library/pom.xml        (working copy)
@@ -61,5 +61,10 @@
       <groupId>log4j</groupId>
       <artifactId>log4j</artifactId>
     </dependency>
-  </dependencies>
-</project>
\ No newline at end of file
+    <dependency>
+      <groupId>junit</groupId>
+      <artifactId>junit</artifactId>
+      <scope>test</scope>
+    </dependency>
+   </dependencies>
+</project>

I'm using maven 2.0.9

thanks
david jencks
On Jul 11, 2008, at 9:09 AM, [EMAIL PROTECTED] wrote:

Author: bago
Date: Fri Jul 11 09:09:41 2008
New Revision: 676012

URL: http://svn.apache.org/viewvc?rev=676012&view=rev
Log:
Second attempt to fix Spring integration for better geronimo integration (JAMES-842)
Based on a patch kindly submitted by David Jencks.

Added:
james/server/trunk/spring-deployment/src/main/java/org/apache/james/container/spring/beanfactory/JamesApplicationContext.java (with props)
Removed:
james/server/trunk/spring-deployment/src/main/java/org/apache/james/container/spring/adaptor/JamesResourceLoader.java
Modified:
james/server/trunk/avalon-spring-bridge-library/src/main/java/org/apache/james/container/spring/beanfactory/AvalonApplicationContext.java
   james/server/trunk/spring-deployment/build.xml
james/server/trunk/spring-deployment/src/main/config/james/spring-beans.xml james/server/trunk/spring-deployment/src/main/java/org/apache/james/container/spring/Main.java james/server/trunk/spring-deployment/src/main/java/org/apache/james/container/spring/adaptor/FileSystemBridge.java

Modified: james/server/trunk/avalon-spring-bridge-library/src/main/java/org/apache/james/container/spring/beanfactory/AvalonApplicationContext.java URL: http://svn.apache.org/viewvc/james/server/trunk/avalon-spring-bridge-library/src/main/java/org/apache/james/container/spring/beanfactory/AvalonApplicationContext.java?rev=676012&r1=676011&r2=676012&view=diff ============================================================================== --- james/server/trunk/avalon-spring-bridge-library/src/main/java/org/apache/james/container/spring/beanfactory/AvalonApplicationContext.java (original) +++ james/server/trunk/avalon-spring-bridge-library/src/main/java/org/apache/james/container/spring/beanfactory/AvalonApplicationContext.java Fri Jul 11 09:09:41 2008
@@ -21,10 +21,10 @@
import org.springframework.beans.BeansException;
import org.springframework.beans.factory.support.DefaultListableBeanFactory;
import org.springframework.beans.factory.xml.XmlBeanDefinitionReader;
-import org.springframework.context.support.AbstractRefreshableApplicationContext;
import org.springframework.context.ApplicationContext;
-import org.springframework.core.io.Resource;
+import org.springframework.context.support.AbstractRefreshableApplicationContext;
import org.springframework.core.io.ClassPathResource;
+import org.springframework.core.io.Resource;

import java.io.IOException;

@@ -46,18 +46,20 @@
    /**
* configuration-by-convention constructor, tries to find default config files on classpath
     */
-    public AvalonApplicationContext() {
-        this(SPRING_BEANS_CONF, PHOENIX_ASSEMBLY_CONF);
+ public static AvalonApplicationContext newAvalonApplicationContext() { + return newAvalonApplicationContext(SPRING_BEANS_CONF, PHOENIX_ASSEMBLY_CONF);
    }

- public AvalonApplicationContext(String containerConf, String applicationConf) { - this(new ClassPathResource(containerConf), new ClassPathResource(applicationConf)); + public static AvalonApplicationContext newAvalonApplicationContext(String containerConf, String applicationConf) { + return newAvalonApplicationContext(new ClassPathResource(containerConf), new ClassPathResource(applicationConf));
    }


- public AvalonApplicationContext(Resource containerConfigurationResource, + public static AvalonApplicationContext newAvalonApplicationContext(Resource containerConfigurationResource, Resource applicationConfigurationResource) { - this(null, containerConfigurationResource, applicationConfigurationResource); + AvalonApplicationContext result = new AvalonApplicationContext(null, containerConfigurationResource, applicationConfigurationResource);
+        result.refresh();
+        return result;
    }

    public AvalonApplicationContext(ApplicationContext parent,
@@ -66,7 +68,6 @@
        super(parent);
this.containerConfigurationResource = containerConfigurationResource; this.applicationConfigurationResource = applicationConfigurationResource;
-        refresh();
    }

protected void loadBeanDefinitions(DefaultListableBeanFactory defaultListableBeanFactory) throws IOException, BeansException {

Modified: james/server/trunk/spring-deployment/build.xml
URL: http://svn.apache.org/viewvc/james/server/trunk/spring-deployment/build.xml?rev=676012&r1=676011&r2=676012&view=diff ==============================================================================
--- james/server/trunk/spring-deployment/build.xml (original)
+++ james/server/trunk/spring-deployment/build.xml Fri Jul 11 09:09:41 2008
@@ -405,7 +405,8 @@
<classpathentry combineaccessrules="false" kind="src" path="/core-library"/>; <classpathentry combineaccessrules="false" kind="src" path="/imap-codec-library"/> <classpathentry combineaccessrules="false" kind="src" path="/imap-command-library"/> - <classpathentry combineaccessrules="false" kind="src" path="/imapmailbox-library"/> + <classpathentry combineaccessrules="false" kind="src" path="/imapmailbox-library"/> + <classpathentry combineaccessrules="false" kind="src" path="/avalon-spring-bridge-library"/> <classpathentry combineaccessrules="false" kind="src" path="/mordred-library"/> <classpathentry combineaccessrules="false" kind="src" path="/user-library"/> <classpathentry combineaccessrules="false" kind="src" path="/avalon-user-function"/>

Modified: james/server/trunk/spring-deployment/src/main/config/james/spring-beans.xml URL: http://svn.apache.org/viewvc/james/server/trunk/spring-deployment/src/main/config/james/spring-beans.xml?rev=676012&r1=676011&r2=676012&view=diff ============================================================================== --- james/server/trunk/spring-deployment/src/main/config/james/spring-beans.xml (original) +++ james/server/trunk/spring-deployment/src/main/config/james/spring-beans.xml Fri Jul 11 09:09:41 2008
@@ -26,9 +26,7 @@
    <!--
         beans which replace Avalon specific container logic
    -->
- <bean id="fileSystemOverride" class="org.apache.james.container.spring.adaptor.FileSystemBridge">
-        <property name="resourceLoader" ref="JamesResourceLoader" />
-    </bean>
+ <bean id="fileSystemOverride" class="org.apache.james.container.spring.adaptor.FileSystemBridge" />

<bean id="serviceManager" class="org.apache.james.container.spring.adaptor.DefaultServiceManagerFactory" >
        <property name="replacements">
@@ -89,8 +87,6 @@
        </property>
    </bean>

- <bean id="JamesResourceLoader" class="org.apache.james.container.spring.adaptor.JamesResourceLoader" />
-
<bean id="avalonContext" class="org.apache.james.container.spring.adaptor.AvalonContext" >
        <property name="applicationHome" value="data" />
        <property name="applicationName" value="Apache JAMES Server" />

Modified: james/server/trunk/spring-deployment/src/main/java/org/apache/james/container/spring/Main.java URL: http://svn.apache.org/viewvc/james/server/trunk/spring-deployment/src/main/java/org/apache/james/container/spring/Main.java?rev=676012&r1=676011&r2=676012&view=diff ============================================================================== --- james/server/trunk/spring-deployment/src/main/java/org/apache/james/container/spring/Main.java (original) +++ james/server/trunk/spring-deployment/src/main/java/org/apache/james/container/spring/Main.java Fri Jul 11 09:09:41 2008
@@ -18,7 +18,7 @@
 ****************************************************************/
package org.apache.james.container.spring;

-import org.apache.james.container.spring.beanfactory.AvalonApplicationContext; +import org.apache.james.container.spring.beanfactory.JamesApplicationContext;

/**
 * Bootstraps James using a Spring container
@@ -26,7 +26,7 @@
public class Main {

    public static void main(String[] args) {
- new AvalonApplicationContext("spring-beans.xml", "james-assembly.xml");
+        JamesApplicationContext.newJamesApplicationContext();
    }

}

Modified: james/server/trunk/spring-deployment/src/main/java/org/apache/james/container/spring/adaptor/FileSystemBridge.java URL: http://svn.apache.org/viewvc/james/server/trunk/spring-deployment/src/main/java/org/apache/james/container/spring/adaptor/FileSystemBridge.java?rev=676012&r1=676011&r2=676012&view=diff ============================================================================== --- james/server/trunk/spring-deployment/src/main/java/org/apache/james/container/spring/adaptor/FileSystemBridge.java (original) +++ james/server/trunk/spring-deployment/src/main/java/org/apache/james/container/spring/adaptor/FileSystemBridge.java Fri Jul 11 09:09:41 2008
@@ -19,6 +19,7 @@
package org.apache.james.container.spring.adaptor;

import org.apache.james.services.FileSystem;
+import org.springframework.context.ResourceLoaderAware;
import org.springframework.core.io.ResourceLoader;

import java.io.File;
@@ -26,7 +27,7 @@
import java.io.IOException;
import java.io.InputStream;

-public class FileSystemBridge implements FileSystem {
+public class FileSystemBridge implements FileSystem, ResourceLoaderAware {

    public File getBasedir() throws FileNotFoundException {
        return new File(".");

Added: james/server/trunk/spring-deployment/src/main/java/org/apache/james/container/spring/beanfactory/JamesApplicationContext.java URL: http://svn.apache.org/viewvc/james/server/trunk/spring-deployment/src/main/java/org/apache/james/container/spring/beanfactory/JamesApplicationContext.java?rev=676012&view=auto ============================================================================== --- james/server/trunk/spring-deployment/src/main/java/org/apache/james/container/spring/beanfactory/JamesApplicationContext.java (added) +++ james/server/trunk/spring-deployment/src/main/java/org/apache/james/container/spring/beanfactory/JamesApplicationContext.java Fri Jul 11 09:09:41 2008
@@ -0,0 +1,93 @@
+/****************************************************************
+ * 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.james.container.spring.beanfactory;
+
+import org.springframework.context.ApplicationContext;
+import org.springframework.core.io.ClassPathResource;
+import org.springframework.core.io.FileSystemResource;
+import org.springframework.core.io.Resource;
+
+import java.io.File;
+
+/**
+ * Override the ResourceLoader capabilities from the AvalonApplicationContext + * supporting JAMES' conf/var specific behaviours and the "classpath:" prefix.
+ */
+public class JamesApplicationContext extends AvalonApplicationContext {
+
+    private static final String FILE_PROTOCOL = "file://";
+    private static final String FILE_PROTOCOL_AND_CONF = "file://conf/";
+    private static final String FILE_PROTOCOL_AND_VAR = "file://var/";
+
+ public static final String JAMES_ASSEMBLY_CONF = "james-assembly.xml";
+
+
+    /**
+ * configuration-by-convention constructor, tries to find default config files on classpath
+     */
+    public static JamesApplicationContext newJamesApplicationContext() {
+ return newJamesApplicationContext(SPRING_BEANS_CONF, JAMES_ASSEMBLY_CONF);
+    }
+
+ public static JamesApplicationContext newJamesApplicationContext(String containerConf, String applicationConf) { + return newJamesApplicationContext(new ClassPathResource(containerConf), new ClassPathResource(applicationConf));
+    }
+
+
+ public static JamesApplicationContext newJamesApplicationContext(Resource containerConfigurationResource, + Resource applicationConfigurationResource) { + JamesApplicationContext result = new JamesApplicationContext(null, containerConfigurationResource, applicationConfigurationResource);
+        result.refresh();
+        return result;
+    }
+
+
+    public JamesApplicationContext(ApplicationContext parent,
+            Resource containerConfigurationResource,
+            Resource applicationConfigurationResource) {
+ super(parent, containerConfigurationResource, applicationConfigurationResource);
+    }
+
+    public ClassLoader getClassLoader() {
+        return Thread.currentThread().getContextClassLoader();
+    }
+
+    public Resource getResource(String fileURL) {
+        Resource r = null;
+        if (fileURL.startsWith("classpath:")) {
+ String resourceName = fileURL.substring("classpath:".length());
+            r = new ClassPathResource(resourceName);
+        } else if (fileURL.startsWith(FILE_PROTOCOL)) {
+            File file = null;
+            if (fileURL.startsWith(FILE_PROTOCOL_AND_CONF)) {
+ file = new File("../conf/" + fileURL.substring(FILE_PROTOCOL_AND_CONF.length()));
+            } else if (fileURL.startsWith(FILE_PROTOCOL_AND_VAR)) {
+ file = new File("../var/" + fileURL.substring(FILE_PROTOCOL_AND_VAR.length()));
+            } else {
+ file = new File("./" + fileURL.substring(FILE_PROTOCOL.length()));
+            }
+            r = new FileSystemResource(file);
+        } else {
+            r = super.getResource(fileURL);
+        }
+        return r;
+    }
+
+
+}

Propchange: james/server/trunk/spring-deployment/src/main/java/org/apache/james/container/spring/beanfactory/JamesApplicationContext.java ------------------------------------------------------------------------------
   svn:eol-style = native

Propchange: james/server/trunk/spring-deployment/src/main/java/org/apache/james/container/spring/beanfactory/JamesApplicationContext.java ------------------------------------------------------------------------------
   svn:mime-type = text/plain



---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to