Author: pete.muir(a)jboss.org
Date: 2009-06-21 09:37:42 -0400 (Sun, 21 Jun 2009)
New Revision: 11185
Modified:
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
Log:
JBSEAM-4258
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-20
20:48:51 UTC (rev 11184)
+++
branches/community/Seam_2_2/src/main/org/jboss/seam/contexts/ServletLifecycle.java 2009-06-21
13:37:42 UTC (rev 11185)
@@ -7,6 +7,7 @@
package org.jboss.seam.contexts;
import java.lang.ref.WeakReference;
+
import javax.servlet.ServletContext;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;
@@ -30,19 +31,19 @@
*/
public class ServletLifecycle
{
-
+
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()
{
//don't throw an exception if null, because of unit tests
return servletContext;
}
-
+
public static void beginRequest(HttpServletRequest request)
{
log.debug( ">>> Begin web request" );
@@ -51,7 +52,7 @@
Contexts.applicationContext.set(new ApplicationContext( Lifecycle.getApplication()
) );
Contexts.conversationContext.set(null); //in case endRequest() was never called
}
-
+
public static void endRequest(HttpServletRequest request)
{
log.debug("After request, destroying contexts");
@@ -61,7 +62,7 @@
boolean sessionInvalid = session!=null && session.isInvalid();
Contexts.flushAndDestroyContexts();
-
+
if (sessionInvalid)
{
Lifecycle.clearThreadlocals();
@@ -75,7 +76,7 @@
log.debug( "<<< End web request" );
}
}
-
+
public static void beginReinitialization(HttpServletRequest request)
{
log.debug(">>> Begin re-initialization");
@@ -109,13 +110,13 @@
Contexts.eventContext.set( new BasicContext(ScopeType.EVENT) );
Contexts.conversationContext.set( new BasicContext(ScopeType.CONVERSATION) );
}
-
+
public static void endInitialization()
{
Contexts.startup(ScopeType.APPLICATION);
Events.instance().raiseEvent("org.jboss.seam.postInitialization");
-
+
// Clean up contexts used during initialization
Contexts.destroy( Contexts.getConversationContext() );
Contexts.conversationContext.set(null);
@@ -123,37 +124,37 @@
Contexts.eventContext.set(null);
Contexts.sessionContext.set(null);
Contexts.applicationContext.set(null);
-
+
log.debug("<<< End initialization");
}
-
+
public static void beginApplication(ServletContext context)
{
// caching the classloader to servletContext
WeakReference<ClassLoader> ref = new
WeakReference<ClassLoader>(Thread.currentThread().getContextClassLoader());
context.setAttribute("seam.context.classLoader",ref);
log.debug("Cached the context classloader in servletContext as
'seam.context.classLoader'");
-
+ context.setAttribute(SERVLET_CONTEXT_KEY, context);
servletContext = context;
Lifecycle.beginApplication( new ServletApplicationMap(context) );
}
-
+
public static void endApplication()
{
Lifecycle.endApplication();
servletContext=null;
}
-
+
public static void beginSession(HttpSession session)
{
Lifecycle.beginSession( new ServletSessionMap(session), new
ServletApplicationMap(session.getServletContext()) );
}
-
+
public static void endSession(HttpSession session)
{
Lifecycle.endSession( new ServletSessionMap(session) );
}
-
+
public static void resumeConversation(HttpServletRequest request)
{
ServerConversationContext conversationContext = new ServerConversationContext( new
ServletRequestSessionMap(request) );
@@ -175,5 +176,5 @@
}
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-20
20:48:51 UTC (rev 11184)
+++
branches/community/Seam_2_2/src/main/org/jboss/seam/core/ResourceLoader.java 2009-06-21
13:37:42 UTC (rev 11185)
@@ -32,7 +32,7 @@
public class ResourceLoader
{
private static final LogProvider log = Logging.getLogProvider(ResourceLoader.class);
-
+
private String[] bundleNames = {"messages"};
/**
@@ -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()
);
}
/**
@@ -75,7 +75,7 @@
bundleName,
Locale.instance(),
Thread.currentThread().getContextClassLoader()
- );
+ );
log.debug("loaded resource bundle: " + bundleName);
return bundle;
}
@@ -92,14 +92,14 @@
String concat = bundleNames==null ? "" : Strings.toString( ",
", (Object[]) bundleNames );
return "ResourceBundle(" + concat + ")";
}
-
+
public static ResourceLoader instance()
{
- if (!Contexts.isApplicationContextActive()) {
- return new ResourceLoader();
- } else {
- return (ResourceLoader) Component.getInstance(ResourceLoader.class,
ScopeType.STATELESS);
- }
+ if (!Contexts.isApplicationContextActive()) {
+ return new ResourceLoader();
+ } else {
+ return (ResourceLoader) Component.getInstance(ResourceLoader.class,
ScopeType.STATELESS);
+ }
}
}
Show replies by date