Author: weaver
Date: Thu Jul 21 11:16:45 2005
New Revision: 220159

URL: http://svn.apache.org/viewcvs?rev=220159&view=rev
Log:
Changed the way we load the primary application context to use a 
XmlWebApplicationContext instead of the file system based one.  This has two 
distinct advantages: 
1.  We do not need to muck around with resolving file pathes, effectively 
cleaning up the code inside of the SpringEngine.
2.  Components, if needed be, can implement the ServletContextAware interface 
and automatically receive an instance of the ServletContext.

Modified:
    
portals/jetspeed-2/trunk/components/cm/src/java/org/apache/jetspeed/components/SpringComponentManager.java
    
portals/jetspeed-2/trunk/components/portal/src/java/org/apache/jetspeed/engine/SpringEngine.java

Modified: 
portals/jetspeed-2/trunk/components/cm/src/java/org/apache/jetspeed/components/SpringComponentManager.java
URL: 
http://svn.apache.org/viewcvs/portals/jetspeed-2/trunk/components/cm/src/java/org/apache/jetspeed/components/SpringComponentManager.java?rev=220159&r1=220158&r2=220159&view=diff
==============================================================================
--- 
portals/jetspeed-2/trunk/components/cm/src/java/org/apache/jetspeed/components/SpringComponentManager.java
 (original)
+++ 
portals/jetspeed-2/trunk/components/cm/src/java/org/apache/jetspeed/components/SpringComponentManager.java
 Thu Jul 21 11:16:45 2005
@@ -19,6 +19,7 @@
 import java.util.Collection;
 
 import org.springframework.context.ApplicationContext;
+import org.springframework.context.ConfigurableApplicationContext;
 import org.springframework.context.support.FileSystemXmlApplicationContext;
 
 /**
@@ -34,18 +35,22 @@
  */
 public class SpringComponentManager implements ComponentManager
 {
-    protected FileSystemXmlApplicationContext appContext;
+    protected ConfigurableApplicationContext appContext;
     
     protected ArrayList factories;
-
-    public SpringComponentManager(String[] springConfigs, ApplicationContext 
parentAppContext)
+    
+    public SpringComponentManager(ConfigurableApplicationContext appContext)
     {
-        factories = new ArrayList();
-        appContext = new FileSystemXmlApplicationContext(springConfigs, 
parentAppContext );
-        
+        this.appContext = appContext;
+        factories = new ArrayList();        
         factories.add(appContext);        
      }
 
+    public SpringComponentManager(String[] springConfigs, ApplicationContext 
parentAppContext)
+    {
+       this(new FileSystemXmlApplicationContext(springConfigs, 
parentAppContext ));    
+    }
+    
     /**
      * <p>
      * getComponent

Modified: 
portals/jetspeed-2/trunk/components/portal/src/java/org/apache/jetspeed/engine/SpringEngine.java
URL: 
http://svn.apache.org/viewcvs/portals/jetspeed-2/trunk/components/portal/src/java/org/apache/jetspeed/engine/SpringEngine.java?rev=220159&r1=220158&r2=220159&view=diff
==============================================================================
--- 
portals/jetspeed-2/trunk/components/portal/src/java/org/apache/jetspeed/engine/SpringEngine.java
 (original)
+++ 
portals/jetspeed-2/trunk/components/portal/src/java/org/apache/jetspeed/engine/SpringEngine.java
 Thu Jul 21 11:16:45 2005
@@ -16,7 +16,6 @@
 package org.apache.jetspeed.engine;
 
 import java.io.File;
-import java.io.FileFilter;
 import java.io.FileNotFoundException;
 import java.io.IOException;
 
@@ -70,51 +69,19 @@
         final String assemblyDir = 
configuration.getString("assembly.dir","/WEB-INF/assembly");
         final String assemblyFileExtension = 
configuration.getString("assembly.extension",".xml");
         
-        FileFilter extFilter = new FileFilter()
-        {
-            public boolean accept( File pathname )
-            {
-                boolean isConfig = 
pathname.getName().endsWith(assemblyFileExtension);
-                if(useInternalJNDI)
-                {
-                    return isConfig;
-                    
-                }
-                else
-                {
-                    return isConfig && 
pathname.getName().indexOf("pooled-datasource-support") < 0;
-                }
-            }
-            
-        };
-        
-        File assemblyDirFile = new File(getRealPath(assemblyDir));
-        if(!assemblyDirFile.exists())
-        {
-            throw new FileNotFoundException("The assembly path 
"+assemblyDirFile.getAbsolutePath()+" does not exist.");
-        }
-        
-        File[] configFiles = assemblyDirFile.listFiles(extFilter);
-        String[] configs = new String[configFiles.length];
-        for(int i=0; i<configFiles.length; i++)
-        {
-            configs[i] = 
configFiles[i].getCanonicalFile().toURL().toExternalForm();
-            if(configs[i].indexOf("pooled-datasource-support") > -1 && i > 0)
-            {  
-                String current0Offset = configs[0];
-                configs[0] = configs[i];
-                configs[i] = current0Offset;
-                
-            }          
-        }
-        
         XmlWebApplicationContext bootCtx = new XmlWebApplicationContext();
         ServletContext servletContext = servletConfig.getServletContext();
         bootCtx.setServletContext(servletContext);
         bootCtx.setConfigLocations(new String[] 
{"/WEB-INF/assembly/boot/*.xml"});
         bootCtx.refresh();
         
-        SpringComponentManager cm = new SpringComponentManager(configs, 
bootCtx);
+        XmlWebApplicationContext appCtx = new XmlWebApplicationContext();
+        appCtx.setParent(bootCtx);
+        appCtx.setServletContext(servletContext);
+        appCtx.setConfigLocations(new String[] 
{assemblyDir+"/*"+assemblyFileExtension});
+        appCtx.refresh();
+        
+        SpringComponentManager cm = new SpringComponentManager(appCtx);
         
servletConfig.getServletContext().setAttribute(WebApplicationContext.ROOT_WEB_APPLICATION_CONTEXT_ATTRIBUTE,
 cm.getApplicationContext());
         
         return cm;



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

Reply via email to