geronimo-scm mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From djen...@apache.org
Subject svn commit: r674643 - in /geronimo/plugins/james/trunk: geronimo-james/src/main/java/org/apache/geronimo/plugins/james/ geronimo-james/src/test/ geronimo-james/src/test/java/org/apache/geronimo/plugins/james/ geronimo-james/src/test/resources/var/james...
Date Mon, 07 Jul 2008 21:19:02 GMT
Author: djencks
Date: Mon Jul  7 14:19:01 2008
New Revision: 674643

URL: http://svn.apache.org/viewvc?rev=674643&view=rev
Log:
update to james trunk, patched with JAMES-842-2.patch

Added:
    geronimo/plugins/james/trunk/geronimo-james/src/main/java/org/apache/geronimo/plugins/james/GeronimoAvalonApplicationContext.java
  (contents, props changed)
      - copied, changed from r667970, geronimo/plugins/james/trunk/geronimo-james/src/main/java/org/apache/geronimo/plugins/james/FileSystemBridge.java
Removed:
    geronimo/plugins/james/trunk/geronimo-james/src/main/java/org/apache/geronimo/plugins/james/FileSystemBridge.java
    geronimo/plugins/james/trunk/geronimo-james/src/test/java/org/apache/geronimo/plugins/james/TestFileSystemBridge.java
Modified:
    geronimo/plugins/james/trunk/geronimo-james/src/main/java/org/apache/geronimo/plugins/james/JamesGBean.java
    geronimo/plugins/james/trunk/geronimo-james/src/test/james-diff
    geronimo/plugins/james/trunk/geronimo-james/src/test/java/org/apache/geronimo/plugins/james/JamesGBeanTest.java
    geronimo/plugins/james/trunk/geronimo-james/src/test/resources/var/james/config/spring-beans.xml
    geronimo/plugins/james/trunk/james/src/main/plan/plan.xml
    geronimo/plugins/james/trunk/james/src/main/resources/var/james/config/spring-beans.xml

Copied: geronimo/plugins/james/trunk/geronimo-james/src/main/java/org/apache/geronimo/plugins/james/GeronimoAvalonApplicationContext.java
(from r667970, geronimo/plugins/james/trunk/geronimo-james/src/main/java/org/apache/geronimo/plugins/james/FileSystemBridge.java)
URL: http://svn.apache.org/viewvc/geronimo/plugins/james/trunk/geronimo-james/src/main/java/org/apache/geronimo/plugins/james/GeronimoAvalonApplicationContext.java?p2=geronimo/plugins/james/trunk/geronimo-james/src/main/java/org/apache/geronimo/plugins/james/GeronimoAvalonApplicationContext.java&p1=geronimo/plugins/james/trunk/geronimo-james/src/main/java/org/apache/geronimo/plugins/james/FileSystemBridge.java&r1=667970&r2=674643&rev=674643&view=diff
==============================================================================
--- geronimo/plugins/james/trunk/geronimo-james/src/main/java/org/apache/geronimo/plugins/james/FileSystemBridge.java
(original)
+++ geronimo/plugins/james/trunk/geronimo-james/src/main/java/org/apache/geronimo/plugins/james/GeronimoAvalonApplicationContext.java
Mon Jul  7 14:19:01 2008
@@ -21,84 +21,82 @@
 package org.apache.geronimo.plugins.james;
 
 import java.io.File;
-import java.io.FileInputStream;
-import java.io.FileNotFoundException;
-import java.io.IOException;
-import java.io.InputStream;
 import java.net.URI;
-import java.util.Collections;
-import java.util.Set;
 
-import org.apache.geronimo.gbean.AbstractName;
-import org.apache.geronimo.gbean.AbstractNameQuery;
-import org.apache.geronimo.kernel.GBeanNotFoundException;
-import org.apache.geronimo.kernel.Kernel;
-import org.apache.geronimo.kernel.KernelRegistry;
 import org.apache.geronimo.system.serverinfo.ServerInfo;
-import org.apache.james.services.FileSystem;
+import org.apache.james.container.spring.beanfactory.AvalonApplicationContext;
+import org.springframework.core.io.ClassPathResource;
+import org.springframework.core.io.FileSystemResource;
+import org.springframework.core.io.Resource;
 
 /**
- * @version $Rev:$ $Date:$
+ * @version $Rev$ $Date$
  */
-public class FileSystemBridge implements FileSystem {
+public class GeronimoAvalonApplicationContext extends AvalonApplicationContext {
 
-    private static final AbstractNameQuery SERVER_INFO_QUERY = new AbstractNameQuery(null,
Collections.EMPTY_MAP, ServerInfo.class.getName());
+//    private static final AbstractNameQuery SERVER_INFO_QUERY = new AbstractNameQuery(null,
Collections.EMPTY_MAP, ServerInfo.class.getName());
     private final ServerInfo serverInfo;
-    private URI baseDir = URI.create("");
+    private final URI baseDir;// = URI.create("");
     private static final String FILE = "file://";
 
-    public FileSystemBridge(ServerInfo serverInfo) {
-        this.serverInfo = serverInfo;
-    }
 
-    public FileSystemBridge() {
-        Kernel kernel = KernelRegistry.getSingleKernel();
-        Set<AbstractName> names = kernel.listGBeans(SERVER_INFO_QUERY);
-        if (names.size() != 1) {
-            throw new IllegalStateException("Wrong number of server infos found: " + names);
-        }
-        try {
-            serverInfo = (ServerInfo) kernel.getGBean(names.iterator().next());
-        } catch (GBeanNotFoundException e) {
-            throw new IllegalStateException("Could not find server info by its name", e);
-        }
+    public static GeronimoAvalonApplicationContext newGeronimoAvalonApplicationContext(Resource
containerConfigurationResource, Resource applicationConfigurationResource, URI baseDir, ServerInfo
serverInfo) {
+        GeronimoAvalonApplicationContext result = new GeronimoAvalonApplicationContext(containerConfigurationResource,
applicationConfigurationResource, baseDir, serverInfo);
+        result.refresh();
+        return result;
     }
 
-    public void setBaseDir(URI baseDir) {
+    public GeronimoAvalonApplicationContext(Resource containerConfigurationResource, Resource
applicationConfigurationResource, URI baseDir, ServerInfo serverInfo) {
+        super(null, containerConfigurationResource, applicationConfigurationResource);
+        if (serverInfo == null) {
+            throw new NullPointerException("no serverInfo");
+        }
+        this.serverInfo = serverInfo;
         this.baseDir = baseDir;
     }
-
-    public InputStream getResource(String url) throws IOException {
-        if (url.startsWith("classpath:")) {
-            String resourceName = url.substring("classpath:".length());
-            InputStream resourceAsStream = getClass().getClassLoader().getResourceAsStream(resourceName);
-            if (resourceAsStream == null) {
-                throw new IOException("Resource '" + resourceName + "' not found in the classpath!");
+//    public GeronimoAvalonApplicationContext() {
+//        Kernel kernel = KernelRegistry.getSingleKernel();
+//        Set<AbstractName> names = kernel.listGBeans(SERVER_INFO_QUERY);
+//        if (names.size() != 1) {
+//            throw new IllegalStateException("Wrong number of server infos found: " + names);
+//        }
+//        try {
+//            serverInfo = (ServerInfo) kernel.getGBean(names.iterator().next());
+//        } catch (GBeanNotFoundException e) {
+//            throw new IllegalStateException("Could not find server info by its name", e);
+//        }
+//    }
+
+//    public void setBaseDir(URI baseDir) {
+//        this.baseDir = baseDir;
+//    }
+
+    public Resource getResource(String fileURL) {
+        Resource r = null;
+        if (fileURL.startsWith("classpath:")) {
+            String resourceName = fileURL.substring("classpath:".length());
+            r = new ClassPathResource(resourceName);
+        } else {
+            String s = fileURL;
+            if (s.startsWith(FILE)) {
+                s = s.substring(FILE.length());
+            }
+            URI relative;
+            if (baseDir != null) {
+                relative = baseDir.resolve(s);
+            } else {
+                relative = URI.create(s);
             }
-            return resourceAsStream;
-        }
-        return new FileInputStream(getFile(url));
-    }
 
-    public File getFile(String s) throws FileNotFoundException {
-        if (s.startsWith(FILE)) {
-            s = s.substring(FILE.length());
-        }
-        URI relative;
-        if (baseDir != null) {
-            relative = baseDir.resolve(s);
-        } else {
-            relative = URI.create(s);
+            File file = new File(serverInfo.resolveServer(relative));
+            if (file.exists()) {
+                r = new FileSystemResource(file);
+            }
         }
-
-        File file = new File(serverInfo.resolveServer(relative));
-        if (!file.exists()) {
-            throw new FileNotFoundException("Could not locate file based on " + s + " at
resolved location: " + file.getAbsolutePath());
+        if (r == null) {
+            r = super.getResource(fileURL);
         }
-        return file;
+        return r;
     }
 
-    public File getBasedir() throws FileNotFoundException {
-        return new File(serverInfo.resolveServer(baseDir));
-    }
-}
+}
\ No newline at end of file

Propchange: geronimo/plugins/james/trunk/geronimo-james/src/main/java/org/apache/geronimo/plugins/james/GeronimoAvalonApplicationContext.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: geronimo/plugins/james/trunk/geronimo-james/src/main/java/org/apache/geronimo/plugins/james/GeronimoAvalonApplicationContext.java
------------------------------------------------------------------------------
    svn:keywords = Date Revision

Propchange: geronimo/plugins/james/trunk/geronimo-james/src/main/java/org/apache/geronimo/plugins/james/GeronimoAvalonApplicationContext.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Modified: geronimo/plugins/james/trunk/geronimo-james/src/main/java/org/apache/geronimo/plugins/james/JamesGBean.java
URL: http://svn.apache.org/viewvc/geronimo/plugins/james/trunk/geronimo-james/src/main/java/org/apache/geronimo/plugins/james/JamesGBean.java?rev=674643&r1=674642&r2=674643&view=diff
==============================================================================
--- geronimo/plugins/james/trunk/geronimo-james/src/main/java/org/apache/geronimo/plugins/james/JamesGBean.java
(original)
+++ geronimo/plugins/james/trunk/geronimo-james/src/main/java/org/apache/geronimo/plugins/james/JamesGBean.java
Mon Jul  7 14:19:01 2008
@@ -20,6 +20,8 @@
 
 package org.apache.geronimo.plugins.james;
 
+import java.net.URI;
+
 import org.apache.geronimo.gbean.GBeanLifecycle;
 import org.apache.geronimo.gbean.annotation.GBean;
 import org.apache.geronimo.gbean.annotation.ParamAttribute;
@@ -29,7 +31,7 @@
 import org.springframework.core.io.FileSystemResource;
 
 /**
- * @version $Rev:$ $Date:$
+ * @version $Rev$ $Date$
  */
 @GBean
 public class JamesGBean implements GBeanLifecycle {
@@ -38,10 +40,11 @@
 
     public JamesGBean(@ParamAttribute(name = "jamesSpringConfig")String jamesSpringConfig,
                       @ParamAttribute(name = "jamesConfigFile")String jamesConfigFile,
+                      @ParamAttribute(name = "baseURI")URI baseURI,
                       @ParamReference(name = "ServerInfo")ServerInfo serverInfo) {
         FileSystemResource jamesConfigResource = new FileSystemResource(serverInfo.resolveServer(jamesConfigFile));
         FileSystemResource jamesSpringConfigResource = new FileSystemResource(serverInfo.resolveServer(jamesSpringConfig));
-        jamesContext = new AvalonApplicationContext(jamesSpringConfigResource, jamesConfigResource);
+        jamesContext = GeronimoAvalonApplicationContext.newGeronimoAvalonApplicationContext(jamesSpringConfigResource,
jamesConfigResource, baseURI, serverInfo);
     }
 
     public void doStart() throws Exception {

Modified: geronimo/plugins/james/trunk/geronimo-james/src/test/james-diff
URL: http://svn.apache.org/viewvc/geronimo/plugins/james/trunk/geronimo-james/src/test/james-diff?rev=674643&r1=674642&r2=674643&view=diff
==============================================================================
--- geronimo/plugins/james/trunk/geronimo-james/src/test/james-diff (original)
+++ geronimo/plugins/james/trunk/geronimo-james/src/test/james-diff Mon Jul  7 14:19:01 2008
@@ -268,7 +268,7 @@
      -->
  
 -    <bean id="fileSystemOverride" class="org.apache.james.container.spring.adaptor.FileSystemBridge"/>
-+    <bean id="fileSystemOverride" class="org.apache.geronimo.plugins.james.TestFileSystemBridge"/>
++    <bean id="fileSystemOverride" class="org.apache.geronimo.plugins.james.TestResourceLoader"/>
           
      <bean id="serviceManager" class="org.apache.james.container.spring.adaptor.DefaultServiceManagerFactory"
>
          <property name="replacements">

Modified: geronimo/plugins/james/trunk/geronimo-james/src/test/java/org/apache/geronimo/plugins/james/JamesGBeanTest.java
URL: http://svn.apache.org/viewvc/geronimo/plugins/james/trunk/geronimo-james/src/test/java/org/apache/geronimo/plugins/james/JamesGBeanTest.java?rev=674643&r1=674642&r2=674643&view=diff
==============================================================================
--- geronimo/plugins/james/trunk/geronimo-james/src/test/java/org/apache/geronimo/plugins/james/JamesGBeanTest.java
(original)
+++ geronimo/plugins/james/trunk/geronimo-james/src/test/java/org/apache/geronimo/plugins/james/JamesGBeanTest.java
Mon Jul  7 14:19:01 2008
@@ -21,13 +21,14 @@
 package org.apache.geronimo.plugins.james;
 
 import java.net.URL;
+import java.net.URI;
 
 import org.apache.geronimo.system.serverinfo.BasicServerInfo;
 import org.apache.geronimo.system.serverinfo.ServerInfo;
 import org.testng.annotations.Test;
 
 /**
- * @version $Rev:$ $Date:$
+ * @version $Rev$ $Date$
  */
 public class JamesGBeanTest {
 
@@ -42,8 +43,7 @@
         path = path.substring(0, path.lastIndexOf("/"));
         ServerInfo serverInfo = new BasicServerInfo(path);
 
-        TestFileSystemBridge.serverInfo = serverInfo;
-        JamesGBean jamesGBean = new JamesGBean("spring-beans.xml", "james-assembly.xml",
serverInfo);
+        JamesGBean jamesGBean = new JamesGBean("spring-beans.xml", "james-assembly.xml",
URI.create(""), serverInfo);
         jamesGBean.doStop();
     }
 }

Modified: geronimo/plugins/james/trunk/geronimo-james/src/test/resources/var/james/config/spring-beans.xml
URL: http://svn.apache.org/viewvc/geronimo/plugins/james/trunk/geronimo-james/src/test/resources/var/james/config/spring-beans.xml?rev=674643&r1=674642&r2=674643&view=diff
==============================================================================
--- geronimo/plugins/james/trunk/geronimo-james/src/test/resources/var/james/config/spring-beans.xml
(original)
+++ geronimo/plugins/james/trunk/geronimo-james/src/test/resources/var/james/config/spring-beans.xml
Mon Jul  7 14:19:01 2008
@@ -26,9 +26,10 @@
     <!--
          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.geronimo.plugins.james.TestFileSystemBridge"/>
-         
     <bean id="serviceManager" class="org.apache.james.container.spring.adaptor.DefaultServiceManagerFactory"
>
         <property name="replacements">
             <!-- replacement map. 
@@ -86,7 +87,6 @@
                 <!--<ref bean="privilegedPortsConfigurationInterceptor" />-->
             </list>
         </property>
-        <property name="fileSystem" ref="fileSystemOverride"/>
     </bean>
 
     <bean id="avalonContext" class="org.apache.james.container.spring.adaptor.AvalonContext"
>

Modified: geronimo/plugins/james/trunk/james/src/main/plan/plan.xml
URL: http://svn.apache.org/viewvc/geronimo/plugins/james/trunk/james/src/main/plan/plan.xml?rev=674643&r1=674642&r2=674643&view=diff
==============================================================================
--- geronimo/plugins/james/trunk/james/src/main/plan/plan.xml (original)
+++ geronimo/plugins/james/trunk/james/src/main/plan/plan.xml Mon Jul  7 14:19:01 2008
@@ -34,6 +34,7 @@
         </reference>
         <attribute name="jamesConfigFile">var/james/config/james-config.xml</attribute>
         <attribute name="jamesSpringConfig">var/james/config/spring-beans.xml</attribute>
+        <attribute name="baseURI">var/james/</attribute>
     </gbean>
 
 </module>

Modified: geronimo/plugins/james/trunk/james/src/main/resources/var/james/config/spring-beans.xml
URL: http://svn.apache.org/viewvc/geronimo/plugins/james/trunk/james/src/main/resources/var/james/config/spring-beans.xml?rev=674643&r1=674642&r2=674643&view=diff
==============================================================================
--- geronimo/plugins/james/trunk/james/src/main/resources/var/james/config/spring-beans.xml
(original)
+++ geronimo/plugins/james/trunk/james/src/main/resources/var/james/config/spring-beans.xml
Mon Jul  7 14:19:01 2008
@@ -26,11 +26,10 @@
     <!--
          beans which replace Avalon specific container logic
     -->
-
-    <bean id="fileSystemOverride" class="org.apache.geronimo.plugins.james.FileSystemBridge">
-        <property name="baseDir" value="var/james/"/>
+    <bean id="fileSystemOverride" class="org.apache.james.container.spring.adaptor.FileSystemBridge">
+    	<!--<property name="resourceLoader" ref="JamesResourceLoader" />-->
     </bean>
-         
+
     <bean id="serviceManager" class="org.apache.james.container.spring.adaptor.DefaultServiceManagerFactory"
>
         <property name="replacements">
             <!-- replacement map. 
@@ -88,7 +87,6 @@
                 <!--<ref bean="privilegedPortsConfigurationInterceptor" />-->
             </list>
         </property>
-        <property name="fileSystem" ref="fileSystemOverride"/>
     </bean>
 
     <bean id="avalonContext" class="org.apache.james.container.spring.adaptor.AvalonContext"
>



Mime
View raw message