[jboss-cvs] jboss-seam/src/main/org/jboss/seam/core ...
Shane Bryzak
sbryzak at redhat.com
Mon Sep 10 04:53:00 EDT 2007
User: sbryzak2
Date: 07/09/10 04:53:00
Modified: src/main/org/jboss/seam/core ConversationPropagation.java
Manager.java
Added: src/main/org/jboss/seam/core PropagationType.java
Log:
introduce enum for propagation type
Revision Changes Path
1.7 +48 -12 jboss-seam/src/main/org/jboss/seam/core/ConversationPropagation.java
(In the diff below, changes in quantity of whitespace are not shown.)
Index: ConversationPropagation.java
===================================================================
RCS file: /cvsroot/jboss/jboss-seam/src/main/org/jboss/seam/core/ConversationPropagation.java,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -b -r1.6 -r1.7
--- ConversationPropagation.java 22 Jun 2007 15:28:56 -0000 1.6
+++ ConversationPropagation.java 10 Sep 2007 08:53:00 -0000 1.7
@@ -32,7 +32,8 @@
private String conversationId;
private String parentConversationId;
private boolean validateLongRunningConversation;
- private String propagationType; //TODO: make it an enum!
+ private PropagationType propagationType;
+ private String pageflow;
/**
* Initialize the request conversation id, taking
@@ -47,19 +48,19 @@
restoreNaturalConversationId(parameters);
restoreSyntheticConversationId(parameters);
restorePageContextConversationId();
- propagationType = getPropagationFromRequestParameter(parameters);
+ getPropagationFromRequestParameter(parameters);
handlePropagationType(parameters);
}
private void handlePropagationType(Map parameters)
{
- if ( "none".equals(propagationType) )
+ if ( propagationType == PropagationType.NONE )
{
conversationId = null;
parentConversationId = null;
validateLongRunningConversation = false;
}
- else if ( "end".equals(propagationType) )
+ else if ( propagationType == PropagationType.END )
{
validateLongRunningConversation = false;
}
@@ -111,20 +112,51 @@
}
}
- private String getPropagationFromRequestParameter(Map parameters)
+ private void getPropagationFromRequestParameter(Map parameters)
{
Object type = parameters.get("conversationPropagation");
- if (type==null)
+ String value = null;
+
+ if (type == null)
{
- return null;
+ return;
}
else if (type instanceof String)
{
- return (String) type;
+ value = (String) type;
+ }
+ else
+ {
+ value = ((String[]) type)[0];
+ }
+
+ if (value.startsWith("begin"))
+ {
+ propagationType = PropagationType.BEGIN;
+ if ( value.length()>6 )
+ {
+ pageflow = value.substring(6);
+ }
+ }
+ else if (value.startsWith("join"))
+ {
+ propagationType = PropagationType.JOIN;
+ if ( value.length()>5 )
+ {
+ pageflow = value.substring(5);
+ }
+ }
+ else if (value.startsWith("nest"))
+ {
+ propagationType = PropagationType.NEST;
+ if ( value.length()>5 )
+ {
+ pageflow = value.substring(5);
+ }
}
else
{
- return ( (String[]) type )[0];
+ propagationType = PropagationType.valueOf(value.toUpperCase());
}
}
@@ -218,14 +250,18 @@
/**
* @return the conversation propagation type specified in the request
*/
- public String getPropagationType()
+ public PropagationType getPropagationType()
{
return propagationType;
}
- public void setPropagationType(String propagationType)
+ public void setPropagationType(PropagationType propagationType)
{
this.propagationType = propagationType;
}
+ public String getPageflow()
+ {
+ return pageflow;
+ }
}
1.185 +40 -40 jboss-seam/src/main/org/jboss/seam/core/Manager.java
(In the diff below, changes in quantity of whitespace are not shown.)
Index: Manager.java
===================================================================
RCS file: /cvsroot/jboss/jboss-seam/src/main/org/jboss/seam/core/Manager.java,v
retrieving revision 1.184
retrieving revision 1.185
diff -u -b -r1.184 -r1.185
--- Manager.java 25 Jul 2007 19:33:41 -0000 1.184
+++ Manager.java 10 Sep 2007 08:53:00 -0000 1.185
@@ -397,33 +397,34 @@
*/
public void handleConversationPropagation(Map parameters)
{
- String propagation = ConversationPropagation.instance().getPropagationType();
+ ConversationPropagation propagation = ConversationPropagation.instance();
- if ( propagation!=null && propagation.startsWith("begin") )
+ switch (propagation.getPropagationType())
{
+ case BEGIN:
if ( isLongRunningConversation )
{
throw new IllegalStateException("long-running conversation already active");
}
beginConversation();
- if ( propagation.length()>6 )
+
+ if (propagation.getPageflow() != null)
{
- Pageflow.instance().begin( propagation.substring(6) );
- }
+ Pageflow.instance().begin( propagation.getPageflow() );
}
- else if ( propagation!=null && propagation.startsWith("join") )
- {
+ break;
+ case JOIN:
if ( !isLongRunningConversation )
{
beginConversation();
- if ( propagation.length()>5 )
+
+ if (propagation.getPageflow() != null)
{
- Pageflow.instance().begin( propagation.substring(5) );
- }
+ Pageflow.instance().begin( propagation.getPageflow() );
}
}
- else if ( propagation!=null && propagation.startsWith("nest") )
- {
+ break;
+ case NEST:
if ( isLongRunningOrNestedConversation() )
{
beginNestedConversation();
@@ -433,16 +434,15 @@
beginConversation();
}
- if ( propagation.length()>5 )
+ if (propagation.getPageflow() != null)
{
- Pageflow.instance().begin( propagation.substring(5) );
- }
+ Pageflow.instance().begin( propagation.getPageflow() );
}
- else if ( "end".equals(propagation) )
- {
+ break;
+ case END:
endConversation(false);
+ break;
}
-
}
/**
1.1 date: 2007/09/10 08:53:00; author: sbryzak2; state: Exp;jboss-seam/src/main/org/jboss/seam/core/PropagationType.java
Index: PropagationType.java
===================================================================
package org.jboss.seam.core;
/**
* Various options controlling how a conversation is propagated.
*
* @author Shane Bryzak
*/
public enum PropagationType
{
BEGIN,
JOIN,
NEST,
NONE,
END
}
More information about the jboss-cvs-commits
mailing list