remove scope attribtue for var, always use conversation scope

This commit is contained in:
Scott Andrews
2008-04-04 22:06:26 +00:00
parent 05d332dbd3
commit ec2c4ba105
8 changed files with 4 additions and 65 deletions

View File

@@ -329,7 +329,7 @@ public class FlowModelFlowBuilder extends AbstractFlowBuilder {
Class clazz = (Class) fromStringTo(Class.class).execute(var.getClassName());
VariableValueFactory valueFactory = new BeanFactoryVariableValueFactory(clazz, getFlow()
.getApplicationContext().getAutowireCapableBeanFactory());
ScopeType scope = parseScopeType(var.getScope(), ScopeType.FLOW);
ScopeType scope = ScopeType.CONVERSATION;
return new FlowVariable(var.getName(), valueFactory, scope == ScopeType.FLOW ? true : false);
}

View File

@@ -28,7 +28,6 @@ import org.springframework.util.StringUtils;
public class VarModel extends AbstractModel {
private String name;
private String className;
private String scope;
/**
* Create a variable model
@@ -84,21 +83,4 @@ public class VarModel extends AbstractModel {
}
}
/**
* @return the scope
*/
public String getScope() {
return scope;
}
/**
* @param scope the scope to set
*/
public void setScope(String scope) {
if (StringUtils.hasText(scope)) {
this.scope = scope;
} else {
this.scope = null;
}
}
}

View File

@@ -437,9 +437,7 @@ public class XmlFlowModelBuilder implements FlowModelBuilder {
}
private VarModel parseVar(Element element) {
VarModel var = new VarModel(element.getAttribute("name"), element.getAttribute("class"));
var.setScope(element.getAttribute("scope"));
return var;
return new VarModel(element.getAttribute("name"), element.getAttribute("class"));
}
private InputModel parseInput(Element element) {

View File

@@ -135,41 +135,6 @@ fully-qualified class name (e.g. 'java.lang.Integer'). The class must be a conc
</xsd:documentation>
</xsd:annotation>
</xsd:attribute>
<xsd:attribute name="scope">
<xsd:annotation>
<xsd:documentation>
<![CDATA[
This scope of this variable. The available scope types are:
<ol>
<li>flow - The variable goes out of scope when this flow session ends.
<li>conversation - The variable goes out of scope when the overall conversation governing this flow ends.
</ol>
]]>
</xsd:documentation>
</xsd:annotation>
<xsd:simpleType>
<xsd:restriction base="xsd:string">
<xsd:enumeration value="flow">
<xsd:annotation>
<xsd:documentation>
<![CDATA[
Goes out of scope when this flow ends.
]]>
</xsd:documentation>
</xsd:annotation>
</xsd:enumeration>
<xsd:enumeration value="conversation">
<xsd:annotation>
<xsd:documentation>
<![CDATA[
Goes out of scope when the governing conversation ends.
]]>
</xsd:documentation>
</xsd:annotation>
</xsd:enumeration>
</xsd:restriction>
</xsd:simpleType>
</xsd:attribute>
</xsd:complexType>
</xsd:element>
<xsd:element name="input" type="input" minOccurs="0" maxOccurs="unbounded">

View File

@@ -263,12 +263,11 @@ public class FlowModelFlowBuilderTests extends TestCase {
public void testFlowVariable() {
model.addVar(new VarModel("flow-foo", "org.springframework.webflow.TestBean"));
VarModel var = new VarModel("conversation-foo", "org.springframework.webflow.TestBean");
var.setScope("conversation");
model.addVar(var);
model.addEndState(new EndStateModel("end"));
Flow flow = getFlow(model);
assertEquals("flow-foo", flow.getVariable("flow-foo").getName());
assertEquals(true, flow.getVariable("flow-foo").isLocal());
assertEquals(false, flow.getVariable("flow-foo").isLocal());
assertEquals("conversation-foo", flow.getVariables()[1].getName());
assertEquals(false, flow.getVariables()[1].isLocal());
}

View File

@@ -78,12 +78,9 @@ public class FlowModelTests extends TestCase {
child.addVar(var);
parent.addVar(var);
var = new VarModel("name", "value");
var.setScope("scope");
parent.addVar(var);
child.merge(parent);
assertEquals(3, child.getVars().size());
assertEquals("scope", ((VarModel) child.getVars().get(1)).getScope());
assertEquals("scope", ((VarModel) parent.getVars().get(1)).getScope());
}
public void testMergeMappings() {

View File

@@ -115,9 +115,7 @@ public class XmlFlowModelBuilderTests extends TestCase {
builder.build();
FlowModel flow = builder.getFlowModel();
assertEquals("flow-foo", ((VarModel) flow.getVars().get(0)).getName());
assertEquals(null, ((VarModel) flow.getVars().get(0)).getScope());
assertEquals("conversation-foo", ((VarModel) flow.getVars().get(1)).getName());
assertEquals("conversation", ((VarModel) flow.getVars().get(1)).getScope());
}
public void testViewStateVariable() {

View File

@@ -3,7 +3,7 @@
xsi:schemaLocation="http://www.springframework.org/schema/webflow http://www.springframework.org/schema/webflow/spring-webflow-2.0.xsd">
<var name="flow-foo" class="org.springframework.webflow.TestBean"/>
<var name="conversation-foo" class="org.springframework.webflow.TestBean" scope="conversation"/>
<var name="conversation-foo" class="org.springframework.webflow.TestBean"/>
<end-state id="end"/>