[seam-commits] Seam SVN: r9274 - trunk/ui/src/main/java/org/jboss/seam/ui/facelet.

seam-commits at lists.jboss.org seam-commits at lists.jboss.org
Sun Oct 12 14:19:25 EDT 2008


Author: pete.muir at jboss.org
Date: 2008-10-12 14:19:25 -0400 (Sun, 12 Oct 2008)
New Revision: 9274

Added:
   trunk/ui/src/main/java/org/jboss/seam/ui/facelet/HttpSessionManager.java
   trunk/ui/src/main/java/org/jboss/seam/ui/facelet/ServletContextManager.java
Removed:
   trunk/ui/src/main/java/org/jboss/seam/ui/facelet/MockHttpSessionManager.java
   trunk/ui/src/main/java/org/jboss/seam/ui/facelet/MockServletContextManager.java
Modified:
   trunk/ui/src/main/java/org/jboss/seam/ui/facelet/RendererFacesContextFactory.java
   trunk/ui/src/main/java/org/jboss/seam/ui/facelet/RendererRequest.java
Log:
JBSEAM-3542

Copied: trunk/ui/src/main/java/org/jboss/seam/ui/facelet/HttpSessionManager.java (from rev 9270, trunk/ui/src/main/java/org/jboss/seam/ui/facelet/MockHttpSessionManager.java)
===================================================================
--- trunk/ui/src/main/java/org/jboss/seam/ui/facelet/HttpSessionManager.java	                        (rev 0)
+++ trunk/ui/src/main/java/org/jboss/seam/ui/facelet/HttpSessionManager.java	2008-10-12 18:19:25 UTC (rev 9274)
@@ -0,0 +1,49 @@
+package org.jboss.seam.ui.facelet;
+
+import static org.jboss.seam.ScopeType.SESSION;
+
+import javax.servlet.http.HttpSession;
+
+import org.jboss.seam.Component;
+import org.jboss.seam.annotations.AutoCreate;
+import org.jboss.seam.annotations.Create;
+import org.jboss.seam.annotations.Install;
+import org.jboss.seam.annotations.Name;
+import org.jboss.seam.annotations.Scope;
+import org.jboss.seam.annotations.Unwrap;
+import org.jboss.seam.annotations.intercept.BypassInterceptors;
+import org.jboss.seam.contexts.Contexts;
+import org.jboss.seam.mock.MockHttpSession;
+
+ at Name("org.jboss.seam.ui.facelet.mockHttpSession")
+ at Scope(SESSION)
+ at BypassInterceptors
+ at Install(dependencies="org.jboss.seam.faces.renderer")
+ at AutoCreate
+public class HttpSessionManager
+{
+   
+   private HttpSession session;
+   
+   @Create
+   public void create()
+   {
+      this.session = new MockHttpSession(ServletContextManager.instance());
+   }
+   
+   @Unwrap
+   public HttpSession getSession()
+   {
+      return session;
+   }
+   
+   public static HttpSession instance()
+   {
+      if (!Contexts.isSessionContextActive())
+      {
+         throw new IllegalStateException("Session context is not active");
+      }
+      return (HttpSession) Component.getInstance(HttpSessionManager.class, SESSION);
+   }
+
+}


Property changes on: trunk/ui/src/main/java/org/jboss/seam/ui/facelet/HttpSessionManager.java
___________________________________________________________________
Name: svn:mime-type
   + text/plain

Deleted: trunk/ui/src/main/java/org/jboss/seam/ui/facelet/MockHttpSessionManager.java
===================================================================
--- trunk/ui/src/main/java/org/jboss/seam/ui/facelet/MockHttpSessionManager.java	2008-10-12 17:28:12 UTC (rev 9273)
+++ trunk/ui/src/main/java/org/jboss/seam/ui/facelet/MockHttpSessionManager.java	2008-10-12 18:19:25 UTC (rev 9274)
@@ -1,49 +0,0 @@
-package org.jboss.seam.ui.facelet;
-
-import static org.jboss.seam.ScopeType.SESSION;
-
-import javax.servlet.http.HttpSession;
-
-import org.jboss.seam.Component;
-import org.jboss.seam.annotations.AutoCreate;
-import org.jboss.seam.annotations.Create;
-import org.jboss.seam.annotations.Install;
-import org.jboss.seam.annotations.Name;
-import org.jboss.seam.annotations.Scope;
-import org.jboss.seam.annotations.Unwrap;
-import org.jboss.seam.annotations.intercept.BypassInterceptors;
-import org.jboss.seam.contexts.Contexts;
-import org.jboss.seam.mock.MockHttpSession;
-
- at Name("org.jboss.seam.ui.facelet.mockHttpSession")
- at Scope(SESSION)
- at BypassInterceptors
- at Install(dependencies="org.jboss.seam.faces.renderer")
- at AutoCreate
-public class MockHttpSessionManager
-{
-   
-   private HttpSession session;
-   
-   @Create
-   public void create()
-   {
-      this.session = new MockHttpSession(MockServletContextManager.instance());
-   }
-   
-   @Unwrap
-   public HttpSession getSession()
-   {
-      return session;
-   }
-   
-   public static HttpSession instance()
-   {
-      if (!Contexts.isSessionContextActive())
-      {
-         throw new IllegalStateException("Session context is not active");
-      }
-      return (HttpSession) Component.getInstance(MockHttpSessionManager.class, SESSION);
-   }
-
-}

Deleted: trunk/ui/src/main/java/org/jboss/seam/ui/facelet/MockServletContextManager.java
===================================================================
--- trunk/ui/src/main/java/org/jboss/seam/ui/facelet/MockServletContextManager.java	2008-10-12 17:28:12 UTC (rev 9273)
+++ trunk/ui/src/main/java/org/jboss/seam/ui/facelet/MockServletContextManager.java	2008-10-12 18:19:25 UTC (rev 9274)
@@ -1,49 +0,0 @@
-package org.jboss.seam.ui.facelet;
-
-import static org.jboss.seam.ScopeType.APPLICATION;
-
-import javax.servlet.ServletContext;
-
-import org.jboss.seam.Component;
-import org.jboss.seam.annotations.AutoCreate;
-import org.jboss.seam.annotations.Create;
-import org.jboss.seam.annotations.Install;
-import org.jboss.seam.annotations.Name;
-import org.jboss.seam.annotations.Scope;
-import org.jboss.seam.annotations.Unwrap;
-import org.jboss.seam.annotations.intercept.BypassInterceptors;
-import org.jboss.seam.contexts.Contexts;
-import org.jboss.seam.mock.MockServletContext;
-
- at Name("org.jboss.seam.ui.facelet.mockServletContext")
- at Scope(APPLICATION)
- at BypassInterceptors
- at Install(dependencies="org.jboss.seam.faces.renderer")
- at AutoCreate
-public class MockServletContextManager
-{
-   
-   private ServletContext servletContext;
-   
-   @Create
-   public void create()
-   {
-      this.servletContext = new MockServletContext();
-   }
-   
-   @Unwrap
-   public ServletContext getServletContext()
-   {
-      return servletContext;
-   }
-   
-   public static ServletContext instance()
-   {
-      if (!Contexts.isApplicationContextActive())
-      {
-         throw new IllegalStateException("Application context is not active");
-      }
-      return (ServletContext) Component.getInstance(MockServletContextManager.class, APPLICATION);
-   }
-
-}

Modified: trunk/ui/src/main/java/org/jboss/seam/ui/facelet/RendererFacesContextFactory.java
===================================================================
--- trunk/ui/src/main/java/org/jboss/seam/ui/facelet/RendererFacesContextFactory.java	2008-10-12 17:28:12 UTC (rev 9273)
+++ trunk/ui/src/main/java/org/jboss/seam/ui/facelet/RendererFacesContextFactory.java	2008-10-12 18:19:25 UTC (rev 9274)
@@ -53,7 +53,7 @@
 
    public FacesContext getFacesContext(ServletRequest request, ServletResponse response)
    {
-      return facesContextFactory.getFacesContext(MockServletContextManager.instance(), request, response, lifecycle);
+      return facesContextFactory.getFacesContext(ServletContextManager.instance(), request, response, lifecycle);
    }
    
    @Destroy

Modified: trunk/ui/src/main/java/org/jboss/seam/ui/facelet/RendererRequest.java
===================================================================
--- trunk/ui/src/main/java/org/jboss/seam/ui/facelet/RendererRequest.java	2008-10-12 17:28:12 UTC (rev 9273)
+++ trunk/ui/src/main/java/org/jboss/seam/ui/facelet/RendererRequest.java	2008-10-12 18:19:25 UTC (rev 9274)
@@ -26,8 +26,6 @@
    private MockHttpServletRequest request;
    private MockHttpServletResponse response;
    
-   private ClassLoader originalClassLoader;
-   
    private StringWriter writer;
    
    private String viewId;
@@ -39,14 +37,9 @@
    
    private void init()
    {
-      request = new MockHttpServletRequest(MockHttpSessionManager.instance());
+      request = new MockHttpServletRequest(HttpSessionManager.instance());
       response = new MockHttpServletResponse();
       
-      // Make sure we are using the correct ClassLoader
-      // TODO Is this still necessary
-      originalClassLoader = Thread.currentThread().getContextClassLoader();
-      Thread.currentThread().setContextClassLoader(this.getClass().getClassLoader());
-      
       // Generate the FacesContext from the JSF FacesContextFactory
       originalFacesContext = FacesContext.getCurrentInstance();
       facesContext = RendererFacesContextFactory.instance().getFacesContext(request, response);
@@ -67,13 +60,11 @@
       facesContext.release();
       DelegatingFacesContext.setCurrentInstance(originalFacesContext);
       
-      Thread.currentThread().setContextClassLoader(originalClassLoader);
       
       originalFacesContext = null;
       facesContext = null;
       request = null;
       response = null;
-      originalClassLoader = null;
    }
    
    public void run() throws IOException

Copied: trunk/ui/src/main/java/org/jboss/seam/ui/facelet/ServletContextManager.java (from rev 9253, trunk/ui/src/main/java/org/jboss/seam/ui/facelet/MockServletContextManager.java)
===================================================================
--- trunk/ui/src/main/java/org/jboss/seam/ui/facelet/ServletContextManager.java	                        (rev 0)
+++ trunk/ui/src/main/java/org/jboss/seam/ui/facelet/ServletContextManager.java	2008-10-12 18:19:25 UTC (rev 9274)
@@ -0,0 +1,58 @@
+package org.jboss.seam.ui.facelet;
+
+import static org.jboss.seam.ScopeType.APPLICATION;
+
+import javax.servlet.ServletContext;
+
+import org.jboss.seam.Component;
+import org.jboss.seam.annotations.AutoCreate;
+import org.jboss.seam.annotations.Create;
+import org.jboss.seam.annotations.Install;
+import org.jboss.seam.annotations.Name;
+import org.jboss.seam.annotations.Scope;
+import org.jboss.seam.annotations.Unwrap;
+import org.jboss.seam.annotations.intercept.BypassInterceptors;
+import org.jboss.seam.contexts.Contexts;
+import org.jboss.seam.contexts.ServletLifecycle;
+import org.jboss.seam.mock.MockServletContext;
+
+ at Name("org.jboss.seam.ui.facelet.mockServletContext")
+ at Scope(APPLICATION)
+ at BypassInterceptors
+ at Install(dependencies="org.jboss.seam.faces.renderer")
+ at AutoCreate
+public class ServletContextManager
+{
+   
+   private ServletContext servletContext;
+   
+   @Create
+   public void create()
+   {
+      // TODO A bit of a hack, we should store the servlet context properly
+      if (ServletLifecycle.getServletContext() != null)
+      {
+         servletContext = ServletLifecycle.getServletContext();
+      }
+      else
+      {
+         this.servletContext = new MockServletContext();
+      }
+   }
+   
+   @Unwrap
+   public ServletContext getServletContext()
+   {
+      return servletContext;
+   }
+   
+   public static ServletContext instance()
+   {
+      if (!Contexts.isApplicationContextActive())
+      {
+         throw new IllegalStateException("Application context is not active");
+      }
+      return (ServletContext) Component.getInstance(ServletContextManager.class, APPLICATION);
+   }
+
+}


Property changes on: trunk/ui/src/main/java/org/jboss/seam/ui/facelet/ServletContextManager.java
___________________________________________________________________
Name: svn:mime-type
   + text/plain




More information about the seam-commits mailing list