[jboss-svn-commits] JBL Code SVN: r14907 - labs/jbossrules/trunk/drools-core/src/main/java/org/drools/reteoo/builder.
jboss-svn-commits at lists.jboss.org
jboss-svn-commits at lists.jboss.org
Wed Sep 5 21:18:48 EDT 2007
Author: mark.proctor at jboss.com
Date: 2007-09-05 21:18:48 -0400 (Wed, 05 Sep 2007)
New Revision: 14907
Modified:
labs/jbossrules/trunk/drools-core/src/main/java/org/drools/reteoo/builder/PatternBuilder.java
Log:
JBRULES-1157 attachObjectTypeNode is not thread safe
-now synchronises on ruleBase.pkgs
Modified: labs/jbossrules/trunk/drools-core/src/main/java/org/drools/reteoo/builder/PatternBuilder.java
===================================================================
--- labs/jbossrules/trunk/drools-core/src/main/java/org/drools/reteoo/builder/PatternBuilder.java 2007-09-05 21:50:26 UTC (rev 14906)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/reteoo/builder/PatternBuilder.java 2007-09-06 01:18:48 UTC (rev 14907)
@@ -94,7 +94,7 @@
} else {
context.setAlphaConstraints( alphaConstraints );
-
+
PatternSource source = pattern.getSource();
ReteooComponentBuilder builder = utils.getBuilderFor( source );
@@ -131,7 +131,7 @@
boolean isAlphaConstraint = true;
for ( int i = 0; isAlphaConstraint && i < declarations.length; i++ ) {
- if ( ! declarations[i].isGlobal() && declarations[i].getPattern() != pattern ) {
+ if ( !declarations[i].isGlobal() && declarations[i].getPattern() != pattern ) {
isAlphaConstraint = false;
}
}
@@ -145,20 +145,23 @@
}
}
}
+
+ public static ObjectTypeNode attachObjectTypeNode(BuildContext context,
+ ObjectType objectType) {
+ synchronized ( context.getRuleBase().getPackagesMap() ) {
+ ObjectTypeNode otn = new ObjectTypeNode( context.getNextId(),
+ objectType,
+ context );
- public static ObjectTypeNode attachObjectTypeNode(BuildContext context, ObjectType objectType) {
- ObjectTypeNode otn = new ObjectTypeNode( context.getNextId(),
- objectType,
- context );
-
- InternalWorkingMemory[] wms = context.getWorkingMemories();
- if ( wms.length > 0 ) {
- otn.attach( wms );
- } else {
- otn.attach();
- }
-
- return otn;
+ InternalWorkingMemory[] wms = context.getWorkingMemories();
+ if ( wms.length > 0 ) {
+ otn.attach( wms );
+ } else {
+ otn.attach();
+ }
+
+ return otn;
+ }
}
public void attachAlphaNodes(final BuildContext context,
@@ -167,17 +170,17 @@
List alphaConstraints) throws InvalidPatternException {
if ( pattern.getObjectType() instanceof ClassObjectType ) {
- if ( DroolsQuery.class ==((ClassObjectType)pattern.getObjectType()).getClassType() ) {
+ if ( DroolsQuery.class == ((ClassObjectType) pattern.getObjectType()).getClassType() ) {
context.setHasLeftMemory( false );
context.setHasObjectTypeMemory( false );
context.setHasTerminalNodeMemory( false );
}
}
-
+
context.setObjectSource( (ObjectSource) utils.attachNode( context,
new ObjectTypeNode( context.getNextId(),
pattern.getObjectType(),
- context) ) );
+ context ) ) );
for ( final Iterator it = alphaConstraints.iterator(); it.hasNext(); ) {
final AlphaNodeFieldConstraint constraint = (AlphaNodeFieldConstraint) it.next();
@@ -223,6 +226,6 @@
*/
public boolean requiresLeftActivation(final BuildUtils utils,
final RuleConditionElement rce) {
- return ((Pattern)rce).getSource() != null;
+ return ((Pattern) rce).getSource() != null;
}
}
More information about the jboss-svn-commits
mailing list