[jboss-cvs] jboss-seam/src/main/org/jboss/seam/contexts ...
Gavin King
gavin.king at jboss.com
Thu Dec 14 05:27:00 EST 2006
User: gavin
Date: 06/12/14 05:27:00
Modified: src/main/org/jboss/seam/contexts Contexts.java
Lifecycle.java
Log:
introduce METHOD context, and solve JBSEAM-564
Revision Changes Path
1.45 +54 -13 jboss-seam/src/main/org/jboss/seam/contexts/Contexts.java
(In the diff below, changes in quantity of whitespace are not shown.)
Index: Contexts.java
===================================================================
RCS file: /cvsroot/jboss/jboss-seam/src/main/org/jboss/seam/contexts/Contexts.java,v
retrieving revision 1.44
retrieving revision 1.45
diff -u -b -r1.44 -r1.45
--- Contexts.java 25 Nov 2006 02:56:06 -0000 1.44
+++ Contexts.java 14 Dec 2006 10:27:00 -0000 1.45
@@ -16,74 +16,105 @@
*
* @author Gavin King
* @author <a href="mailto:theute at jboss.org">Thomas Heute</a>
- * @version $Revision: 1.44 $
+ * @version $Revision: 1.45 $
*/
public class Contexts {
private static final Log log = LogFactory.getLog( Contexts.class );
static final ThreadLocal<Context> applicationContext = new ThreadLocal<Context>();
+ static final ThreadLocal<Context> methodContext = new ThreadLocal<Context>();
static final ThreadLocal<Context> eventContext = new ThreadLocal<Context>();
static final ThreadLocal<Context> pageContext = new ThreadLocal<Context>();
static final ThreadLocal<Context> sessionContext = new ThreadLocal<Context>();
static final ThreadLocal<Context> conversationContext = new ThreadLocal<Context>();
static final ThreadLocal<Context> businessProcessContext = new ThreadLocal<Context>();
- public static Context getEventContext() {
+ public static Context getEventContext()
+ {
return eventContext.get();
}
- public static Context getPageContext() {
+ public static Context getMethodContext()
+ {
+ return methodContext.get();
+ }
+
+ public static Context getPageContext()
+ {
return pageContext.get();
}
- public static Context getSessionContext() {
+ public static Context getSessionContext()
+ {
return sessionContext.get();
}
- public static Context getApplicationContext() {
+ public static Context getApplicationContext()
+ {
return applicationContext.get();
}
- public static Context getConversationContext() {
+ public static Context getConversationContext()
+ {
return conversationContext.get();
}
- public static Context getBusinessProcessContext() {
+ public static Context getBusinessProcessContext()
+ {
return businessProcessContext.get();
}
- public static boolean isConversationContextActive() {
+ public static boolean isConversationContextActive()
+ {
return getConversationContext() != null;
}
- public static boolean isEventContextActive() {
+ public static boolean isEventContextActive()
+ {
return eventContext.get() != null;
}
- public static boolean isPageContextActive() {
+ public static boolean isMethodContextActive()
+ {
+ return methodContext.get() != null;
+ }
+
+ public static boolean isPageContextActive()
+ {
return pageContext.get() != null;
}
- public static boolean isSessionContextActive() {
+ public static boolean isSessionContextActive()
+ {
return sessionContext.get() != null;
}
- public static boolean isApplicationContextActive() {
+ public static boolean isApplicationContextActive()
+ {
return applicationContext.get() != null;
}
- public static boolean isBusinessProcessContextActive() {
+ public static boolean isBusinessProcessContextActive()
+ {
return businessProcessContext.get() != null;
}
public static void removeFromAllContexts(String name)
{
log.debug("removing from all contexts: " + name);
+ if (isMethodContextActive())
+ {
+ getMethodContext().remove(name);
+ }
if (isEventContextActive())
{
getEventContext().remove(name);
}
+ if (isPageContextActive())
+ {
+ getPageContext().remove(name);
+ }
if (isConversationContextActive())
{
getConversationContext().remove(name);
@@ -104,6 +135,16 @@
public static Object lookupInStatefulContexts(String name)
{
+ if (isMethodContextActive())
+ {
+ Object result = getMethodContext().get(name);
+ if (result!=null)
+ {
+ log.debug("found in method context: " + name);
+ return result;
+ }
+ }
+
if (isEventContextActive())
{
Object result = getEventContext().get(name);
1.71 +12 -1 jboss-seam/src/main/org/jboss/seam/contexts/Lifecycle.java
(In the diff below, changes in quantity of whitespace are not shown.)
Index: Lifecycle.java
===================================================================
RCS file: /cvsroot/jboss/jboss-seam/src/main/org/jboss/seam/contexts/Lifecycle.java,v
retrieving revision 1.70
retrieving revision 1.71
diff -u -b -r1.70 -r1.71
--- Lifecycle.java 13 Dec 2006 04:54:19 -0000 1.70
+++ Lifecycle.java 14 Dec 2006 10:27:00 -0000 1.71
@@ -31,7 +31,7 @@
/**
* @author Gavin King
* @author <a href="mailto:theute at jboss.org">Thomas Heute</a>
- * @version $Revision: 1.70 $
+ * @version $Revision: 1.71 $
*/
public class Lifecycle
{
@@ -94,6 +94,17 @@
Contexts.applicationContext.set(null);
}
+ public static Context beginMethod()
+ {
+ Context result = Contexts.methodContext.get();
+ Contexts.methodContext.set( new MapContext(ScopeType.METHOD) );
+ return result;
+ }
+
+ public static void endMethod(Context context)
+ {
+ Contexts.methodContext.set(context);
+ }
public static void beginInitialization(ServletContext servletContext)
{
More information about the jboss-cvs-commits
mailing list