[seam-commits] Seam SVN: r11157 - in branches/community/Seam_2_2: src/main/org/jboss/seam/contexts and 4 other directories.

seam-commits at lists.jboss.org seam-commits at lists.jboss.org
Mon Jun 15 10:57:57 EDT 2009


Author: pete.muir at jboss.org
Date: 2009-06-15 10:57:57 -0400 (Mon, 15 Jun 2009)
New Revision: 11157

Modified:
   branches/community/Seam_2_2/
   branches/community/Seam_2_2/src/main/org/jboss/seam/contexts/Lifecycle.java
   branches/community/Seam_2_2/src/main/org/jboss/seam/contexts/ServletLifecycle.java
   branches/community/Seam_2_2/src/main/org/jboss/seam/core/ResourceLoader.java
   branches/community/Seam_2_2/src/main/org/jboss/seam/core/SeamResourceBundle.java
   branches/community/Seam_2_2/src/main/org/jboss/seam/servlet/SeamFilter.java
   branches/community/Seam_2_2/src/main/org/jboss/seam/servlet/SeamResourceServlet.java
   branches/community/Seam_2_2/src/main/org/jboss/seam/web/WicketFilter.java
   branches/community/Seam_2_2/src/wicket/org/jboss/seam/wicket/web/WicketFilterInstantiator.java
Log:
JBSEAM-3119, thanks to Stuart Douglas


Property changes on: branches/community/Seam_2_2
___________________________________________________________________
Name: svn:ignore
   - *.ipr
*.iws
*.iml
jboss-seam.jar
jboss-seam-ui.jar
jboss-seam-debug.jar
jboss-seam-gen.jar
jboss-seam-pdf.jar
jboss-seam-mail.jar
jboss-seam-remoting.jar
jboss-seam-ioc.jar
jboss-seam-trinidad.jar
test-output
test-report
testng-failures.xml
report
output
classes
lib
.classpath
build.properties
coverage.ec
dvdindexes
coverage-output
blogindexes
.ant-targets-build.xml
dependency-report.txt
lacewikiIndex
jmimemagic.log
dist


   + *.ipr
*.iws
*.iml
jboss-seam.jar
jboss-seam-ui.jar
jboss-seam-debug.jar
jboss-seam-gen.jar
jboss-seam-pdf.jar
jboss-seam-mail.jar
jboss-seam-remoting.jar
jboss-seam-ioc.jar
jboss-seam-trinidad.jar
test-output
test-report
testng-failures.xml
report
output
classes
lib
.classpath
build.properties
coverage.ec
dvdindexes
coverage-output
blogindexes
.ant-targets-build.xml
dependency-report.txt
lacewikiIndex
jmimemagic.log
dist


bin


Modified: branches/community/Seam_2_2/src/main/org/jboss/seam/contexts/Lifecycle.java
===================================================================
--- branches/community/Seam_2_2/src/main/org/jboss/seam/contexts/Lifecycle.java	2009-06-15 14:27:17 UTC (rev 11156)
+++ branches/community/Seam_2_2/src/main/org/jboss/seam/contexts/Lifecycle.java	2009-06-15 14:57:57 UTC (rev 11157)
@@ -112,7 +112,7 @@
    @Deprecated
    public static void mockApplication()
    {
-      setupApplication();
+      setupApplication(null);
    }
    
    /**
@@ -128,6 +128,11 @@
    {
       Contexts.applicationContext.set( new ApplicationContext(getApplication()) );
    }
+   
+   public static void setupApplication(Map<String, Object> appCtx)
+   {
+         Contexts.applicationContext.set(new ApplicationContext(appCtx));
+   }
 
    public static void cleanupApplication()
    {
@@ -175,8 +180,14 @@
       Contexts.destroyConversationContext(session, conversationId);
    }
 
+   @Deprecated
    public static void beginSession(Map<String, Object> session)
    {
+      beginSession(session,null);
+   }
+   
+   public static void beginSession(Map<String, Object> session, Map<String,Object> appCtx)
+   {
       log.debug("Session started");
       
       //Normally called synchronously with a JSF request, but there are some
@@ -188,7 +199,15 @@
 
       if ( !applicationContextActive )
       {
-         Context tempApplicationContext = new ApplicationContext( getApplication() );
+         Context tempApplicationContext = null;
+         if(appCtx == null)
+         {
+            tempApplicationContext= new ApplicationContext( getApplication() );
+         }
+         else
+         {
+            tempApplicationContext = new ApplicationContext(appCtx);
+         }
          Contexts.applicationContext.set(tempApplicationContext);
       }
       Context oldSessionContext = Contexts.sessionContext.get();

Modified: branches/community/Seam_2_2/src/main/org/jboss/seam/contexts/ServletLifecycle.java
===================================================================
--- branches/community/Seam_2_2/src/main/org/jboss/seam/contexts/ServletLifecycle.java	2009-06-15 14:27:17 UTC (rev 11156)
+++ branches/community/Seam_2_2/src/main/org/jboss/seam/contexts/ServletLifecycle.java	2009-06-15 14:57:57 UTC (rev 11157)
@@ -34,6 +34,8 @@
    private static final LogProvider log = Logging.getLogProvider(ServletLifecycle.class);
 
    private static ServletContext servletContext;
+   
+   public static final String SERVLET_CONTEXT_KEY = "seam.contexts.servletContext";
 
    public static ServletContext getServletContext() 
    {
@@ -144,7 +146,7 @@
 
    public static void beginSession(HttpSession session)
    {
-      Lifecycle.beginSession( new ServletSessionMap(session) );
+      Lifecycle.beginSession( new ServletSessionMap(session), new ServletApplicationMap(session.getServletContext()) );
    }
 
    public static void endSession(HttpSession session)
@@ -159,5 +161,19 @@
       Contexts.businessProcessContext.set( new BusinessProcessContext() );
       conversationContext.unflush();
    }
+   /**
+    * Convenience method that retrieves the servlet context from application
+    * scope.
+    * 
+    * @return the current servlet context
+    */
+   public static ServletContext getCurrentServletContext()
+   {
+      if (!Contexts.isApplicationContextActive())
+      {
+         return servletContext;
+      }
+      return (ServletContext) Contexts.getApplicationContext().get(SERVLET_CONTEXT_KEY);
+   }
 
 }

Modified: branches/community/Seam_2_2/src/main/org/jboss/seam/core/ResourceLoader.java
===================================================================
--- branches/community/Seam_2_2/src/main/org/jboss/seam/core/ResourceLoader.java	2009-06-15 14:27:17 UTC (rev 11156)
+++ branches/community/Seam_2_2/src/main/org/jboss/seam/core/ResourceLoader.java	2009-06-15 14:57:57 UTC (rev 11157)
@@ -52,12 +52,12 @@
    
    public InputStream getResourceAsStream(String resource)
    {
-      return Resources.getResourceAsStream( resource, ServletLifecycle.getServletContext() );
+      return Resources.getResourceAsStream( resource, ServletLifecycle.getCurrentServletContext() );
    }
 
    public URL getResource(String resource) 
    {
-      return Resources.getResource( resource, ServletLifecycle.getServletContext() );
+      return Resources.getResource( resource, ServletLifecycle.getCurrentServletContext() );
    }
    
    /**

Modified: branches/community/Seam_2_2/src/main/org/jboss/seam/core/SeamResourceBundle.java
===================================================================
--- branches/community/Seam_2_2/src/main/org/jboss/seam/core/SeamResourceBundle.java	2009-06-15 14:27:17 UTC (rev 11156)
+++ branches/community/Seam_2_2/src/main/org/jboss/seam/core/SeamResourceBundle.java	2009-06-15 14:57:57 UTC (rev 11157)
@@ -10,7 +10,9 @@
 import java.util.ResourceBundle;
 import java.util.concurrent.ConcurrentHashMap;
 
+import org.jboss.seam.Seam;
 import org.jboss.seam.contexts.Contexts;
+import org.jboss.seam.contexts.Lifecycle;
 import org.jboss.seam.navigation.Pages;
 import org.jboss.seam.util.EnumerationEnumeration;
 
@@ -25,8 +27,27 @@
  */
 public class SeamResourceBundle extends java.util.ResourceBundle
 {
-   private Map<Locale, List<ResourceBundle>> bundleCache = new ConcurrentHashMap<Locale, List<ResourceBundle>>();
+   private Map<Init,Map<Locale, List<ResourceBundle>>> bundleCache = new ConcurrentHashMap<Init,Map<Locale, List<ResourceBundle>>>();
 
+   private Map<Locale, List<ResourceBundle>> getCachedBundle()
+   {
+      Init init; 
+      if(Contexts.isApplicationContextActive())
+      {
+         init = (Init)Contexts.getApplicationContext().get(Seam.getComponentName(Init.class));
+      }
+      else
+      {
+         //not sure if this is nessesary
+         init = (Init)Lifecycle.getApplication().get(Seam.getComponentName(Init.class));
+      }
+      if(!bundleCache.containsKey(init))
+      {
+         bundleCache.put(init, new ConcurrentHashMap<Locale, List<ResourceBundle>>());
+      }
+      return bundleCache.get(init);
+   }
+   
    /**
     * Get an instance for the current Seam Locale
     * 
@@ -51,11 +72,11 @@
    private List<java.util.ResourceBundle> getBundlesForCurrentLocale()
    {
       Locale instance = org.jboss.seam.core.Locale.instance();
-      List<ResourceBundle> bundles = bundleCache.get(instance);
+      List<ResourceBundle> bundles = getCachedBundle().get(instance);
       if ( bundles==null )
       {
          bundles = loadBundlesForCurrentLocale();
-         bundleCache.put(instance, bundles);
+         getCachedBundle().put(instance, bundles);
       }
       return bundles;
 

Modified: branches/community/Seam_2_2/src/main/org/jboss/seam/servlet/SeamFilter.java
===================================================================
--- branches/community/Seam_2_2/src/main/org/jboss/seam/servlet/SeamFilter.java	2009-06-15 14:27:17 UTC (rev 11156)
+++ branches/community/Seam_2_2/src/main/org/jboss/seam/servlet/SeamFilter.java	2009-06-15 14:57:57 UTC (rev 11157)
@@ -87,7 +87,7 @@
 
    public void init(FilterConfig filterConfig) throws ServletException 
    {
-      Lifecycle.setupApplication();
+      Lifecycle.setupApplication(new ServletApplicationMap(filterConfig.getServletContext()));
       try
       {
          filters = getSortedFilters();

Modified: branches/community/Seam_2_2/src/main/org/jboss/seam/servlet/SeamResourceServlet.java
===================================================================
--- branches/community/Seam_2_2/src/main/org/jboss/seam/servlet/SeamResourceServlet.java	2009-06-15 14:27:17 UTC (rev 11156)
+++ branches/community/Seam_2_2/src/main/org/jboss/seam/servlet/SeamResourceServlet.java	2009-06-15 14:57:57 UTC (rev 11157)
@@ -44,7 +44,7 @@
    {
       try
       {
-         Lifecycle.setupApplication();
+         Lifecycle.setupApplication(new ServletApplicationMap(context));
 
          for (String name : Init.instance().getResourceProviders())
          {         

Modified: branches/community/Seam_2_2/src/main/org/jboss/seam/web/WicketFilter.java
===================================================================
--- branches/community/Seam_2_2/src/main/org/jboss/seam/web/WicketFilter.java	2009-06-15 14:27:17 UTC (rev 11156)
+++ branches/community/Seam_2_2/src/main/org/jboss/seam/web/WicketFilter.java	2009-06-15 14:57:57 UTC (rev 11157)
@@ -75,7 +75,7 @@
       }
       else
       {
-           Init init = (Init) ServletLifecycle.getServletContext().getAttribute( Seam.getComponentName(Init.class) );
+           Init init = (Init) getServletContext().getAttribute( Seam.getComponentName(Init.class) );
                /*
                 * We initialize the delegate on the first actual request and any time the
                 * init timestamp changes, so that the WicketFilter gets reinitialized whenever the

Modified: branches/community/Seam_2_2/src/wicket/org/jboss/seam/wicket/web/WicketFilterInstantiator.java
===================================================================
--- branches/community/Seam_2_2/src/wicket/org/jboss/seam/wicket/web/WicketFilterInstantiator.java	2009-06-15 14:27:17 UTC (rev 11156)
+++ branches/community/Seam_2_2/src/wicket/org/jboss/seam/wicket/web/WicketFilterInstantiator.java	2009-06-15 14:57:57 UTC (rev 11157)
@@ -25,6 +25,7 @@
 import org.jboss.seam.contexts.Lifecycle;
 import org.jboss.seam.log.LogProvider;
 import org.jboss.seam.log.Logging;
+import org.jboss.seam.servlet.ServletApplicationMap;
 import org.jboss.seam.web.FilterConfigWrapper;
 import org.jboss.seam.wicket.WebApplication;
 import org.jboss.seam.wicket.ioc.WicketClassLoader;
@@ -59,7 +60,7 @@
             try 
             { 
                // We need the Application context active in order to lookup the WebApplication component
-               Lifecycle.setupApplication();
+               Lifecycle.setupApplication(new ServletApplicationMap(filterConfig.getServletContext()));
                Map<String, String> parameters = new HashMap<String, String>();
                try
                {




More information about the seam-commits mailing list