[jboss-svn-commits] JBL Code SVN: r17480 - labs/jbossrules/branches/4.0.x/drools-core/src/main/java/org/drools/base/mvel.
jboss-svn-commits at lists.jboss.org
jboss-svn-commits at lists.jboss.org
Tue Jan 1 08:04:04 EST 2008
Author: tirelli
Date: 2008-01-01 08:04:04 -0500 (Tue, 01 Jan 2008)
New Revision: 17480
Modified:
labs/jbossrules/branches/4.0.x/drools-core/src/main/java/org/drools/base/mvel/DroolsMVELFactory.java
Log:
JBRULES-1397: fixing bug on 4.0.x branch
Modified: labs/jbossrules/branches/4.0.x/drools-core/src/main/java/org/drools/base/mvel/DroolsMVELFactory.java
===================================================================
--- labs/jbossrules/branches/4.0.x/drools-core/src/main/java/org/drools/base/mvel/DroolsMVELFactory.java 2008-01-01 11:49:30 UTC (rev 17479)
+++ labs/jbossrules/branches/4.0.x/drools-core/src/main/java/org/drools/base/mvel/DroolsMVELFactory.java 2008-01-01 13:04:04 UTC (rev 17480)
@@ -163,7 +163,15 @@
this.knowledgeHelper = knowledgeHelper;
this.object = object;
this.workingMemory = workingMemory;
- this.localVariables = variables;
+ if ( variables == null ) {
+ if ( this.localVariables == null ) {
+ this.localVariables = new HashMap();
+ } else {
+ this.localVariables.clear();
+ }
+ } else {
+ this.localVariables = variables;
+ }
}
public KnowledgeHelper getKnowledgeHelper() {
@@ -192,41 +200,29 @@
public VariableResolver createVariable(String name,
Object value) {
VariableResolver vr = getVariableResolver( name );
- if ( vr != null ) {
- if ( this.localVariables == null ) {
- this.localVariables = new HashMap();
- }
- vr.setValue( value );
- return vr;
- } else {
- if ( this.localVariables == null ) {
- this.localVariables = new HashMap();
- }
+ if ( vr == null ) {
addResolver( name,
vr = new LocalVariableResolver( this,
name ) );
- vr.setValue( value );
- return vr;
}
+
+ vr.setValue( value );
+ return vr;
}
public VariableResolver createVariable(String name,
Object value,
Class type) {
VariableResolver vr = getVariableResolver( name );
- if ( vr != null && vr.getType() != null ) {
- throw new CompileException( "variable already defined within scope: " + vr.getType() + " " + name );
- } else {
- if ( this.localVariables == null ) {
- this.localVariables = new HashMap();
- }
+ if ( vr == null ) {
addResolver( name,
vr = new LocalVariableResolver( this,
name,
type ) );
- vr.setValue( value );
- return vr;
- }
+ }
+
+ vr.setValue( value );
+ return vr;
}
public boolean isResolveable(String name) {
@@ -253,12 +249,7 @@
(Class) this.globals.get( name ),
this ) );
return true;
- } else if ( this.variableResolvers != null && this.variableResolvers.containsKey( name ) ) {
- addResolver( name,
- new LocalVariableResolver( this,
- name ) );
- return true;
- } else if ( nextFactory != null ) {
+ } else if ( nextFactory != null ) {
return nextFactory.isResolveable( name );
}
More information about the jboss-svn-commits
mailing list