[jboss-svn-commits] JBL Code SVN: r19164 - in labs/jbossrules/branches/temporal_rete: drools-ant/src/main/java/org/drools/contrib and 109 other directories.
jboss-svn-commits at lists.jboss.org
jboss-svn-commits at lists.jboss.org
Thu Mar 20 15:32:13 EDT 2008
Author: tirelli
Date: 2008-03-20 15:32:10 -0400 (Thu, 20 Mar 2008)
New Revision: 19164
Added:
labs/jbossrules/branches/temporal_rete/drools-compiler/src/main/java/org/drools/brms/client/modeldriven/dt/DTColumnConfig.java
labs/jbossrules/branches/temporal_rete/drools-compiler/src/test/java/org/drools/DomainObject.java
labs/jbossrules/branches/temporal_rete/drools-compiler/src/test/java/org/drools/DomainObjectHolder.java
labs/jbossrules/branches/temporal_rete/drools-compiler/src/test/java/org/drools/brms/modeldriven/dt/
labs/jbossrules/branches/temporal_rete/drools-compiler/src/test/java/org/drools/brms/modeldriven/dt/GuidedDecisionTableTest.java
labs/jbossrules/branches/temporal_rete/drools-compiler/src/test/java/org/drools/integrationtests/LargeRuleBaseSerializationTest.java
labs/jbossrules/branches/temporal_rete/drools-compiler/src/test/java/org/drools/integrationtests/SerializationHelper.java
labs/jbossrules/branches/temporal_rete/drools-compiler/src/test/resources/billasurf.jar
labs/jbossrules/branches/temporal_rete/drools-compiler/src/test/resources/org/drools/integrationtests/big_decimal_and_literal.drl
labs/jbossrules/branches/temporal_rete/drools-compiler/src/test/resources/org/drools/integrationtests/test_Dynamic1_0.drl
labs/jbossrules/branches/temporal_rete/drools-compiler/src/test/resources/org/drools/integrationtests/test_Dynamic1_1.drl
labs/jbossrules/branches/temporal_rete/drools-compiler/src/test/resources/org/drools/integrationtests/test_Dynamic1_2.drl
labs/jbossrules/branches/temporal_rete/drools-compiler/src/test/resources/org/drools/integrationtests/test_Dynamic3_0.drl
labs/jbossrules/branches/temporal_rete/drools-compiler/src/test/resources/org/drools/integrationtests/test_FromArrayIteration.drl
labs/jbossrules/branches/temporal_rete/drools-compiler/src/test/resources/org/drools/integrationtests/test_MatchesMVEL.drl
labs/jbossrules/branches/temporal_rete/drools-compiler/src/test/resources/org/drools/integrationtests/test_MergePackageWithSameRuleNames1.drl
labs/jbossrules/branches/temporal_rete/drools-compiler/src/test/resources/org/drools/integrationtests/test_MergePackageWithSameRuleNames2.drl
labs/jbossrules/branches/temporal_rete/drools-compiler/src/test/resources/org/drools/integrationtests/test_ModifyBlock.drl
labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/common/DroolsObjectInput.java
labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/common/DroolsObjectOutputStream.java
labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/common/DroolsObjectStreamConstants.java
labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/util/ArrayIterator.java
labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/util/ObjenesisFactory.java
labs/jbossrules/branches/temporal_rete/drools-core/src/test/java/org/drools/common/DroolsObjectIOTest.java
labs/jbossrules/branches/temporal_rete/drools-core/src/test/java/org/drools/integrationtests/
labs/jbossrules/branches/temporal_rete/drools-core/src/test/java/org/drools/integrationtests/SerializationHelper.java
labs/jbossrules/branches/temporal_rete/drools-core/src/test/java/org/drools/rule/EnumSerialiationTest.java
labs/jbossrules/branches/temporal_rete/drools-docs/drools-docs-userguide/en/Chapter-Decision_Tables/Key.png
labs/jbossrules/branches/temporal_rete/drools-jbrms/src/main/java/org/drools/brms/client/decisiontable/ActionInsertColumn.java
labs/jbossrules/branches/temporal_rete/drools-jbrms/src/main/java/org/drools/brms/client/decisiontable/ActionSetColumn.java
labs/jbossrules/branches/temporal_rete/drools-jbrms/src/main/java/org/drools/brms/client/decisiontable/GuidedDTColumnConfig.java
Removed:
labs/jbossrules/branches/temporal_rete/drools-compiler/src/test/java/org/drools/brms/modeldriven/dt/GuidedDecisionTableTest.java
labs/jbossrules/branches/temporal_rete/drools-core/src/test/java/org/drools/integrationtests/SerializationHelper.java
labs/jbossrules/branches/temporal_rete/drools-jbrms/build-readme.html
labs/jbossrules/branches/temporal_rete/drools-jbrms/src/main/java/org/drools/brms/client/decisiontable/DeleteAction.java
labs/jbossrules/branches/temporal_rete/drools-jbrms/src/main/java/org/drools/brms/client/decisiontable/EditActions.java
labs/jbossrules/branches/temporal_rete/drools-jbrms/src/main/java/org/drools/brms/client/decisiontable/EditableDTGrid.java
labs/jbossrules/branches/temporal_rete/drools-jbrms/src/main/java/org/drools/brms/client/decisiontable/InsertAction.java
labs/jbossrules/branches/temporal_rete/drools-jbrms/src/main/java/org/drools/brms/client/decisiontable/MergeAction.java
labs/jbossrules/branches/temporal_rete/drools-jbrms/src/main/java/org/drools/brms/client/decisiontable/ShuffleAction.java
labs/jbossrules/branches/temporal_rete/drools-jbrms/src/main/java/org/drools/brms/client/decisiontable/ShuffleDownAction.java
labs/jbossrules/branches/temporal_rete/drools-jbrms/src/main/java/org/drools/brms/client/decisiontable/ShuffleUpAction.java
labs/jbossrules/branches/temporal_rete/drools-jbrms/src/main/java/org/drools/brms/client/decisiontable/Toolbar.java
labs/jbossrules/branches/temporal_rete/drools-jbrms/src/main/java/org/drools/brms/client/decisiontable/model/Cell.java
labs/jbossrules/branches/temporal_rete/drools-jbrms/src/main/java/org/drools/brms/client/decisiontable/model/Column.java
labs/jbossrules/branches/temporal_rete/drools-jbrms/src/main/java/org/drools/brms/client/decisiontable/model/DecisionTable.java
labs/jbossrules/branches/temporal_rete/drools-jbrms/src/main/java/org/drools/brms/client/decisiontable/model/HeaderRow.java
labs/jbossrules/branches/temporal_rete/drools-jbrms/src/main/java/org/drools/brms/client/decisiontable/model/Row.java
Modified:
labs/jbossrules/branches/temporal_rete/README.txt
labs/jbossrules/branches/temporal_rete/drools-ant/src/main/java/org/drools/contrib/DroolsCompilerAntTask.java
labs/jbossrules/branches/temporal_rete/drools-ant/src/test/resources/DroolsAntTask.xml
labs/jbossrules/branches/temporal_rete/drools-clips/src/main/java/org/drools/clips/Shell.java
labs/jbossrules/branches/temporal_rete/drools-clips/src/test/java/org/drools/clips/ShellTest.java
labs/jbossrules/branches/temporal_rete/drools-compiler/.classpath
labs/jbossrules/branches/temporal_rete/drools-compiler/src/main/java/org/drools/brms/client/modeldriven/SuggestionCompletionEngine.java
labs/jbossrules/branches/temporal_rete/drools-compiler/src/main/java/org/drools/brms/client/modeldriven/brl/ActionFieldValue.java
labs/jbossrules/branches/temporal_rete/drools-compiler/src/main/java/org/drools/brms/client/modeldriven/brl/ActionInsertFact.java
labs/jbossrules/branches/temporal_rete/drools-compiler/src/main/java/org/drools/brms/client/modeldriven/brl/ActionRetractFact.java
labs/jbossrules/branches/temporal_rete/drools-compiler/src/main/java/org/drools/brms/client/modeldriven/brl/ActionSetField.java
labs/jbossrules/branches/temporal_rete/drools-compiler/src/main/java/org/drools/brms/client/modeldriven/brl/CompositeFactPattern.java
labs/jbossrules/branches/temporal_rete/drools-compiler/src/main/java/org/drools/brms/client/modeldriven/brl/CompositeFieldConstraint.java
labs/jbossrules/branches/temporal_rete/drools-compiler/src/main/java/org/drools/brms/client/modeldriven/brl/DSLSentence.java
labs/jbossrules/branches/temporal_rete/drools-compiler/src/main/java/org/drools/brms/client/modeldriven/brl/FactPattern.java
labs/jbossrules/branches/temporal_rete/drools-compiler/src/main/java/org/drools/brms/client/modeldriven/brl/ISingleFieldConstraint.java
labs/jbossrules/branches/temporal_rete/drools-compiler/src/main/java/org/drools/brms/client/modeldriven/brl/PortableObject.java
labs/jbossrules/branches/temporal_rete/drools-compiler/src/main/java/org/drools/brms/client/modeldriven/brl/RuleAttribute.java
labs/jbossrules/branches/temporal_rete/drools-compiler/src/main/java/org/drools/brms/client/modeldriven/brl/RuleModel.java
labs/jbossrules/branches/temporal_rete/drools-compiler/src/main/java/org/drools/brms/client/modeldriven/dt/ActionCol.java
labs/jbossrules/branches/temporal_rete/drools-compiler/src/main/java/org/drools/brms/client/modeldriven/dt/ActionInsertFactCol.java
labs/jbossrules/branches/temporal_rete/drools-compiler/src/main/java/org/drools/brms/client/modeldriven/dt/ActionSetFieldCol.java
labs/jbossrules/branches/temporal_rete/drools-compiler/src/main/java/org/drools/brms/client/modeldriven/dt/AttributeCol.java
labs/jbossrules/branches/temporal_rete/drools-compiler/src/main/java/org/drools/brms/client/modeldriven/dt/ConditionCol.java
labs/jbossrules/branches/temporal_rete/drools-compiler/src/main/java/org/drools/brms/client/modeldriven/dt/GuidedDecisionTable.java
labs/jbossrules/branches/temporal_rete/drools-compiler/src/main/java/org/drools/brms/client/modeldriven/testing/ExecutionTrace.java
labs/jbossrules/branches/temporal_rete/drools-compiler/src/main/java/org/drools/brms/client/modeldriven/testing/FactData.java
labs/jbossrules/branches/temporal_rete/drools-compiler/src/main/java/org/drools/brms/client/modeldriven/testing/FieldData.java
labs/jbossrules/branches/temporal_rete/drools-compiler/src/main/java/org/drools/brms/client/modeldriven/testing/RetractFact.java
labs/jbossrules/branches/temporal_rete/drools-compiler/src/main/java/org/drools/brms/client/modeldriven/testing/Scenario.java
labs/jbossrules/branches/temporal_rete/drools-compiler/src/main/java/org/drools/brms/client/modeldriven/testing/VerifyFact.java
labs/jbossrules/branches/temporal_rete/drools-compiler/src/main/java/org/drools/brms/client/modeldriven/testing/VerifyField.java
labs/jbossrules/branches/temporal_rete/drools-compiler/src/main/java/org/drools/brms/client/modeldriven/testing/VerifyRuleFired.java
labs/jbossrules/branches/temporal_rete/drools-compiler/src/main/java/org/drools/brms/server/rules/SuggestionCompletionLoader.java
labs/jbossrules/branches/temporal_rete/drools-compiler/src/main/java/org/drools/compiler/ActionError.java
labs/jbossrules/branches/temporal_rete/drools-compiler/src/main/java/org/drools/compiler/DescrBuildError.java
labs/jbossrules/branches/temporal_rete/drools-compiler/src/main/java/org/drools/compiler/RuleFlowLoadError.java
labs/jbossrules/branches/temporal_rete/drools-compiler/src/main/java/org/drools/lang/DRLLexer.java
labs/jbossrules/branches/temporal_rete/drools-compiler/src/main/java/org/drools/lang/DRLParser.java
labs/jbossrules/branches/temporal_rete/drools-compiler/src/main/java/org/drools/lang/DrlDumper.java
labs/jbossrules/branches/temporal_rete/drools-compiler/src/main/java/org/drools/lang/MVELDumper.java
labs/jbossrules/branches/temporal_rete/drools-compiler/src/main/java/org/drools/lang/descr/AccumulateDescr.java
labs/jbossrules/branches/temporal_rete/drools-compiler/src/main/java/org/drools/lang/descr/BaseDescr.java
labs/jbossrules/branches/temporal_rete/drools-compiler/src/main/java/org/drools/lang/descr/PackageDescr.java
labs/jbossrules/branches/temporal_rete/drools-compiler/src/main/java/org/drools/lang/descr/RuleDescr.java
labs/jbossrules/branches/temporal_rete/drools-compiler/src/main/java/org/drools/lang/dsl/DefaultExpander.java
labs/jbossrules/branches/temporal_rete/drools-compiler/src/main/java/org/drools/rule/builder/PatternBuilder.java
labs/jbossrules/branches/temporal_rete/drools-compiler/src/main/java/org/drools/rule/builder/ReturnValueEvaluatorBuilder.java
labs/jbossrules/branches/temporal_rete/drools-compiler/src/main/java/org/drools/rule/builder/RuleBuildContext.java
labs/jbossrules/branches/temporal_rete/drools-compiler/src/main/java/org/drools/rule/builder/dialect/java/AbstractJavaProcessBuilder.java
labs/jbossrules/branches/temporal_rete/drools-compiler/src/main/java/org/drools/rule/builder/dialect/java/AbstractJavaRuleBuilder.java
labs/jbossrules/branches/temporal_rete/drools-compiler/src/main/java/org/drools/rule/builder/dialect/java/JavaActionBuilder.java
labs/jbossrules/branches/temporal_rete/drools-compiler/src/main/java/org/drools/rule/builder/dialect/java/JavaConsequenceBuilder.java
labs/jbossrules/branches/temporal_rete/drools-compiler/src/main/java/org/drools/rule/builder/dialect/java/JavaDialect.java
labs/jbossrules/branches/temporal_rete/drools-compiler/src/main/java/org/drools/rule/builder/dialect/java/JavaReturnValueEvaluatorBuilder.java
labs/jbossrules/branches/temporal_rete/drools-compiler/src/main/java/org/drools/rule/builder/dialect/java/parser/JavaLexer.java
labs/jbossrules/branches/temporal_rete/drools-compiler/src/main/java/org/drools/rule/builder/dialect/java/parser/JavaParser.java
labs/jbossrules/branches/temporal_rete/drools-compiler/src/main/java/org/drools/rule/builder/dialect/mvel/MVELActionBuilder.java
labs/jbossrules/branches/temporal_rete/drools-compiler/src/main/java/org/drools/rule/builder/dialect/mvel/MVELConsequenceBuilder.java
labs/jbossrules/branches/temporal_rete/drools-compiler/src/main/java/org/drools/rule/builder/dialect/mvel/MVELDialect.java
labs/jbossrules/branches/temporal_rete/drools-compiler/src/main/java/org/drools/rule/builder/dialect/mvel/MVELDialectConfiguration.java
labs/jbossrules/branches/temporal_rete/drools-compiler/src/main/java/org/drools/rule/builder/dialect/mvel/MVELEvalBuilder.java
labs/jbossrules/branches/temporal_rete/drools-compiler/src/main/java/org/drools/rule/builder/dialect/mvel/MVELExprAnalyzer.java
labs/jbossrules/branches/temporal_rete/drools-compiler/src/main/java/org/drools/rule/builder/dialect/mvel/MVELFromBuilder.java
labs/jbossrules/branches/temporal_rete/drools-compiler/src/main/java/org/drools/rule/builder/dialect/mvel/MVELPredicateBuilder.java
labs/jbossrules/branches/temporal_rete/drools-compiler/src/main/java/org/drools/rule/builder/dialect/mvel/MVELReturnValueBuilder.java
labs/jbossrules/branches/temporal_rete/drools-compiler/src/main/java/org/drools/rule/builder/dialect/mvel/MVELReturnValueEvaluatorBuilder.java
labs/jbossrules/branches/temporal_rete/drools-compiler/src/main/java/org/drools/rule/builder/dialect/mvel/MVELSalienceBuilder.java
labs/jbossrules/branches/temporal_rete/drools-compiler/src/main/java/org/drools/testframework/ScenarioRunner.java
labs/jbossrules/branches/temporal_rete/drools-compiler/src/main/java/org/drools/testframework/TestingEventListener.java
labs/jbossrules/branches/temporal_rete/drools-compiler/src/main/java/org/drools/xml/XmlPackageReader.java
labs/jbossrules/branches/temporal_rete/drools-compiler/src/main/java/org/drools/xml/XmlProcessReader.java
labs/jbossrules/branches/temporal_rete/drools-compiler/src/main/java/org/drools/xml/rules/AccumulateHandler.java
labs/jbossrules/branches/temporal_rete/drools-compiler/src/main/java/org/drools/xml/rules/AccumulateHelperHandler.java
labs/jbossrules/branches/temporal_rete/drools-compiler/src/main/java/org/drools/xml/rules/AndHandler.java
labs/jbossrules/branches/temporal_rete/drools-compiler/src/main/java/org/drools/xml/rules/CollectHandler.java
labs/jbossrules/branches/temporal_rete/drools-compiler/src/main/java/org/drools/xml/rules/EvalHandler.java
labs/jbossrules/branches/temporal_rete/drools-compiler/src/main/java/org/drools/xml/rules/ExistsHandler.java
labs/jbossrules/branches/temporal_rete/drools-compiler/src/main/java/org/drools/xml/rules/ExpressionHandler.java
labs/jbossrules/branches/temporal_rete/drools-compiler/src/main/java/org/drools/xml/rules/FieldBindingHandler.java
labs/jbossrules/branches/temporal_rete/drools-compiler/src/main/java/org/drools/xml/rules/FieldConstraintHandler.java
labs/jbossrules/branches/temporal_rete/drools-compiler/src/main/java/org/drools/xml/rules/ForallHandler.java
labs/jbossrules/branches/temporal_rete/drools-compiler/src/main/java/org/drools/xml/rules/FromHandler.java
labs/jbossrules/branches/temporal_rete/drools-compiler/src/main/java/org/drools/xml/rules/LiteralRestrictionHandler.java
labs/jbossrules/branches/temporal_rete/drools-compiler/src/main/java/org/drools/xml/rules/NotHandler.java
labs/jbossrules/branches/temporal_rete/drools-compiler/src/main/java/org/drools/xml/rules/OrHandler.java
labs/jbossrules/branches/temporal_rete/drools-compiler/src/main/java/org/drools/xml/rules/PatternHandler.java
labs/jbossrules/branches/temporal_rete/drools-compiler/src/main/java/org/drools/xml/rules/PredicateHandler.java
labs/jbossrules/branches/temporal_rete/drools-compiler/src/main/java/org/drools/xml/rules/RestrictionConnectiveHandler.java
labs/jbossrules/branches/temporal_rete/drools-compiler/src/main/java/org/drools/xml/rules/ReturnValueRestrictionHandler.java
labs/jbossrules/branches/temporal_rete/drools-compiler/src/main/java/org/drools/xml/rules/VariableRestrictionsHandler.java
labs/jbossrules/branches/temporal_rete/drools-compiler/src/main/resources/org/drools/rule/builder/dialect/java/javaFunction.mvel
labs/jbossrules/branches/temporal_rete/drools-compiler/src/main/resources/org/drools/rule/builder/dialect/java/javaInvokers.mvel
labs/jbossrules/branches/temporal_rete/drools-compiler/src/test/java/org/drools/Address.java
labs/jbossrules/branches/temporal_rete/drools-compiler/src/test/java/org/drools/Attribute.java
labs/jbossrules/branches/temporal_rete/drools-compiler/src/test/java/org/drools/Cell.java
labs/jbossrules/branches/temporal_rete/drools-compiler/src/test/java/org/drools/Cheese.java
labs/jbossrules/branches/temporal_rete/drools-compiler/src/test/java/org/drools/CheeseEqual.java
labs/jbossrules/branches/temporal_rete/drools-compiler/src/test/java/org/drools/Cheesery.java
labs/jbossrules/branches/temporal_rete/drools-compiler/src/test/java/org/drools/FactA.java
labs/jbossrules/branches/temporal_rete/drools-compiler/src/test/java/org/drools/FactB.java
labs/jbossrules/branches/temporal_rete/drools-compiler/src/test/java/org/drools/FactC.java
labs/jbossrules/branches/temporal_rete/drools-compiler/src/test/java/org/drools/Func.java
labs/jbossrules/branches/temporal_rete/drools-compiler/src/test/java/org/drools/GrandParent.java
labs/jbossrules/branches/temporal_rete/drools-compiler/src/test/java/org/drools/Guess.java
labs/jbossrules/branches/temporal_rete/drools-compiler/src/test/java/org/drools/IndexedNumber.java
labs/jbossrules/branches/temporal_rete/drools-compiler/src/test/java/org/drools/InsertedObject.java
labs/jbossrules/branches/temporal_rete/drools-compiler/src/test/java/org/drools/Message.java
labs/jbossrules/branches/temporal_rete/drools-compiler/src/test/java/org/drools/Order.java
labs/jbossrules/branches/temporal_rete/drools-compiler/src/test/java/org/drools/OrderEvent.java
labs/jbossrules/branches/temporal_rete/drools-compiler/src/test/java/org/drools/OrderItem.java
labs/jbossrules/branches/temporal_rete/drools-compiler/src/test/java/org/drools/Person.java
labs/jbossrules/branches/temporal_rete/drools-compiler/src/test/java/org/drools/Precondition.java
labs/jbossrules/branches/temporal_rete/drools-compiler/src/test/java/org/drools/Primitives.java
labs/jbossrules/branches/temporal_rete/drools-compiler/src/test/java/org/drools/State.java
labs/jbossrules/branches/temporal_rete/drools-compiler/src/test/java/org/drools/StockTick.java
labs/jbossrules/branches/temporal_rete/drools-compiler/src/test/java/org/drools/TestParam.java
labs/jbossrules/branches/temporal_rete/drools-compiler/src/test/java/org/drools/bpel/instance/BPELProcessInstanceFactory.java
labs/jbossrules/branches/temporal_rete/drools-compiler/src/test/java/org/drools/brms/client/modeldriven/SuggestionCompletionEngineTest.java
labs/jbossrules/branches/temporal_rete/drools-compiler/src/test/java/org/drools/brms/modeldriven/DataEnumLoaderTest.java
labs/jbossrules/branches/temporal_rete/drools-compiler/src/test/java/org/drools/brms/server/util/BRLPersitenceTest.java
labs/jbossrules/branches/temporal_rete/drools-compiler/src/test/java/org/drools/compiler/PackageBuilderConfigurationTest.java
labs/jbossrules/branches/temporal_rete/drools-compiler/src/test/java/org/drools/compiler/PackageBuilderTest.java
labs/jbossrules/branches/temporal_rete/drools-compiler/src/test/java/org/drools/compiler/RuleErrorTest.java
labs/jbossrules/branches/temporal_rete/drools-compiler/src/test/java/org/drools/integrationtests/CepEspTest.java
labs/jbossrules/branches/temporal_rete/drools-compiler/src/test/java/org/drools/integrationtests/DslTest.java
labs/jbossrules/branches/temporal_rete/drools-compiler/src/test/java/org/drools/integrationtests/DynamicRulesTest.java
labs/jbossrules/branches/temporal_rete/drools-compiler/src/test/java/org/drools/integrationtests/ExecutionFlowControlTest.java
labs/jbossrules/branches/temporal_rete/drools-compiler/src/test/java/org/drools/integrationtests/FirstOrderLogicTest.java
labs/jbossrules/branches/temporal_rete/drools-compiler/src/test/java/org/drools/integrationtests/LargeRuleBase.java
labs/jbossrules/branches/temporal_rete/drools-compiler/src/test/java/org/drools/integrationtests/MVELTest.java
labs/jbossrules/branches/temporal_rete/drools-compiler/src/test/java/org/drools/integrationtests/MarshallingTest.java
labs/jbossrules/branches/temporal_rete/drools-compiler/src/test/java/org/drools/integrationtests/MiscTest.java
labs/jbossrules/branches/temporal_rete/drools-compiler/src/test/java/org/drools/integrationtests/MultithreadTest.java
labs/jbossrules/branches/temporal_rete/drools-compiler/src/test/java/org/drools/integrationtests/OutOfMemoryTest.java
labs/jbossrules/branches/temporal_rete/drools-compiler/src/test/java/org/drools/integrationtests/StatefulSessionTest.java
labs/jbossrules/branches/temporal_rete/drools-compiler/src/test/java/org/drools/integrationtests/StatelessSessionTest.java
labs/jbossrules/branches/temporal_rete/drools-compiler/src/test/java/org/drools/integrationtests/StatelessStressTest.java
labs/jbossrules/branches/temporal_rete/drools-compiler/src/test/java/org/drools/integrationtests/StreamsTest.java
labs/jbossrules/branches/temporal_rete/drools-compiler/src/test/java/org/drools/integrationtests/TruthMaintenanceTest.java
labs/jbossrules/branches/temporal_rete/drools-compiler/src/test/java/org/drools/integrationtests/eventgenerator/SimpleEventGeneratorTest.java
labs/jbossrules/branches/temporal_rete/drools-compiler/src/test/java/org/drools/integrationtests/sequential/SequentialTest.java
labs/jbossrules/branches/temporal_rete/drools-compiler/src/test/java/org/drools/integrationtests/waltz/Stage.java
labs/jbossrules/branches/temporal_rete/drools-compiler/src/test/java/org/drools/integrationtests/waltz/Waltz.java
labs/jbossrules/branches/temporal_rete/drools-compiler/src/test/java/org/drools/lang/MVELDumperTest.java
labs/jbossrules/branches/temporal_rete/drools-compiler/src/test/java/org/drools/rule/builder/dialect/java/JavaAccumulateBuilderTest.java
labs/jbossrules/branches/temporal_rete/drools-compiler/src/test/java/org/drools/rule/builder/dialect/java/JavaActionBuilderTest.java
labs/jbossrules/branches/temporal_rete/drools-compiler/src/test/java/org/drools/rule/builder/dialect/java/JavaConsequenceBuilderTest.java
labs/jbossrules/branches/temporal_rete/drools-compiler/src/test/java/org/drools/rule/builder/dialect/java/JavaExprAnalyzerTest.java
labs/jbossrules/branches/temporal_rete/drools-compiler/src/test/java/org/drools/rule/builder/dialect/java/RuleBuilderTest.java
labs/jbossrules/branches/temporal_rete/drools-compiler/src/test/java/org/drools/rule/builder/dialect/mvel/MVELActionBuilderTest.java
labs/jbossrules/branches/temporal_rete/drools-compiler/src/test/java/org/drools/rule/builder/dialect/mvel/MVELConsequenceBuilderTest.java
labs/jbossrules/branches/temporal_rete/drools-compiler/src/test/java/org/drools/rule/builder/dialect/mvel/MVELDecisionBuilderTest.java
labs/jbossrules/branches/temporal_rete/drools-compiler/src/test/java/org/drools/rule/builder/dialect/mvel/MVELEvalBuilderTest.java
labs/jbossrules/branches/temporal_rete/drools-compiler/src/test/java/org/drools/rule/builder/dialect/mvel/MVELSalienceBuilderTest.java
labs/jbossrules/branches/temporal_rete/drools-compiler/src/test/java/org/drools/testframework/FactPopulatorTest.java
labs/jbossrules/branches/temporal_rete/drools-compiler/src/test/java/org/drools/testframework/MockFactHandle.java
labs/jbossrules/branches/temporal_rete/drools-compiler/src/test/java/org/drools/testframework/MockRuleBase.java
labs/jbossrules/branches/temporal_rete/drools-compiler/src/test/java/org/drools/testframework/MockWorkingMemory.java
labs/jbossrules/branches/temporal_rete/drools-compiler/src/test/java/org/drools/testframework/ScenarioTest.java
labs/jbossrules/branches/temporal_rete/drools-compiler/src/test/java/org/drools/testframework/TestingEventListenerTest.java
labs/jbossrules/branches/temporal_rete/drools-compiler/src/test/java/org/drools/xml/processes/ActionNodeTest.java
labs/jbossrules/branches/temporal_rete/drools-compiler/src/test/java/org/drools/xml/rules/DumperTestHelper.java
labs/jbossrules/branches/temporal_rete/drools-compiler/src/test/java/org/drools/xml/rules/XmlPackageReaderTest.java
labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/FactHandle.java
labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/InitialFact.java
labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/RuleBase.java
labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/RuleBaseConfiguration.java
labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/RuleBaseEventManager.java
labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/WorkingMemory.java
labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/WorkingMemoryEventManager.java
labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/agent/FileScanner.java
labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/agent/HttpClientImpl.java
labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/agent/URLScanner.java
labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/audit/WorkingMemoryConsoleLogger.java
labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/audit/WorkingMemoryFileLogger.java
labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/audit/WorkingMemoryInMemoryLogger.java
labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/audit/WorkingMemoryLogger.java
labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/audit/event/ActivationLogEvent.java
labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/audit/event/LogEvent.java
labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/base/BaseClassFieldExtractor.java
labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/base/BaseEvaluator.java
labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/base/ClassFieldExtractor.java
labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/base/ClassFieldExtractorCache.java
labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/base/ClassObjectType.java
labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/base/CopyIdentifiersGlobalExporter.java
labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/base/DefaultConsequenceExceptionHandler.java
labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/base/DefaultKnowledgeHelper.java
labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/base/FieldFactory.java
labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/base/FireAllRulesRuleBaseUpdateListener.java
labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/base/MapGlobalResolver.java
labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/base/ModifyInterceptor.java
labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/base/ReferenceOriginalGlobalExporter.java
labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/base/SalienceInteger.java
labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/base/ValueType.java
labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/base/accumulators/AccumulateFunction.java
labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/base/accumulators/AverageAccumulateFunction.java
labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/base/accumulators/CountAccumulateFunction.java
labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/base/accumulators/JavaAccumulatorFunctionExecutor.java
labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/base/accumulators/MVELAccumulatorFunctionExecutor.java
labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/base/accumulators/MaxAccumulateFunction.java
labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/base/accumulators/MinAccumulateFunction.java
labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/base/accumulators/SumAccumulateFunction.java
labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/base/dataproviders/MVELDataProvider.java
labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/base/evaluators/AfterEvaluatorDefinition.java
labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/base/evaluators/BeforeEvaluatorDefinition.java
labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/base/evaluators/CoincidesEvaluatorDefinition.java
labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/base/evaluators/ComparableEvaluatorsDefinition.java
labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/base/evaluators/DuringEvaluatorDefinition.java
labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/base/evaluators/EqualityEvaluatorsDefinition.java
labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/base/evaluators/EvaluatorCache.java
labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/base/evaluators/EvaluatorDefinition.java
labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/base/evaluators/EvaluatorRegistry.java
labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/base/evaluators/FinishedByEvaluatorDefinition.java
labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/base/evaluators/FinishesEvaluatorDefinition.java
labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/base/evaluators/IncludesEvaluatorDefinition.java
labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/base/evaluators/MatchesEvaluatorsDefinition.java
labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/base/evaluators/MeetsEvaluatorDefinition.java
labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/base/evaluators/MetByEvaluatorDefinition.java
labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/base/evaluators/Operator.java
labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/base/evaluators/OverlappedByEvaluatorDefinition.java
labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/base/evaluators/OverlapsEvaluatorDefinition.java
labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/base/evaluators/SetEvaluatorsDefinition.java
labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/base/evaluators/SoundslikeEvaluatorsDefinition.java
labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/base/evaluators/StartedByEvaluatorDefinition.java
labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/base/evaluators/StartsEvaluatorDefinition.java
labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/base/extractors/ArrayExtractor.java
labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/base/extractors/BaseObjectClassFieldExtractor.java
labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/base/extractors/MVELClassFieldExtractor.java
labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/base/field/BooleanFieldImpl.java
labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/base/field/DoubleFieldImpl.java
labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/base/field/LongFieldImpl.java
labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/base/field/ObjectFieldImpl.java
labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/base/mvel/DroolsMVELFactory.java
labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/base/mvel/DroolsMVELGlobalVariable.java
labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/base/mvel/DroolsMVELKnowledgeHelper.java
labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/base/mvel/DroolsMVELLocalDeclarationVariable.java
labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/base/mvel/DroolsMVELPreviousDeclarationVariable.java
labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/base/mvel/MVELAccumulator.java
labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/base/mvel/MVELAction.java
labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/base/mvel/MVELConsequence.java
labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/base/mvel/MVELEvalExpression.java
labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/base/mvel/MVELPredicateExpression.java
labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/base/mvel/MVELReturnValueEvaluator.java
labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/base/mvel/MVELReturnValueExpression.java
labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/base/mvel/MVELSalienceExpression.java
labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/common/AbstractFactHandleFactory.java
labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/common/AbstractRuleBase.java
labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/common/AbstractWorkingMemory.java
labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/common/AgendaItem.java
labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/common/ArrayAgendaGroup.java
labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/common/BaseNode.java
labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/common/BetaConstraints.java
labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/common/BinaryHeapQueueAgendaGroup.java
labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/common/ConcurrentNodeMemories.java
labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/common/DefaultAgenda.java
labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/common/DefaultBetaConstraints.java
labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/common/DefaultFactHandle.java
labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/common/DoubleBetaConstraints.java
labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/common/DroolsObjectInputStream.java
labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/common/EmptyBetaConstraints.java
labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/common/EqualityAssertMapComparator.java
labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/common/EqualityKey.java
labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/common/EqualityKeyComparator.java
labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/common/EventFactHandle.java
labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/common/IdentityAssertMapComparator.java
labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/common/InstanceEqualsConstraint.java
labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/common/InstanceNotEqualsConstraint.java
labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/common/InternalWorkingMemory.java
labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/common/InternalWorkingMemoryActions.java
labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/common/NetworkNode.java
labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/common/NodeMemories.java
labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/common/PriorityQueueAgendaGroupFactory.java
labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/common/PropagationContextImpl.java
labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/common/QuadroupleBetaConstraints.java
labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/common/RuleFlowGroupImpl.java
labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/common/ScheduledAgendaItem.java
labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/common/SequentialAgendaGroupImpl.java
labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/common/SingleBetaConstraints.java
labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/common/SingleThreadedObjectStore.java
labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/common/TripleBetaConstraints.java
labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/common/TruthMaintenanceSystem.java
labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/common/TupleStartEqualsConstraint.java
labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/common/WorkingMemoryAction.java
labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/concurrent/AssertObject.java
labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/concurrent/AssertObjects.java
labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/concurrent/Command.java
labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/concurrent/CommandExecutor.java
labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/concurrent/DefaultExecutorService.java
labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/concurrent/ExecutorService.java
labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/concurrent/FireAllRules.java
labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/concurrent/Future.java
labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/concurrent/RetractObject.java
labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/concurrent/UpdateObject.java
labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/conflict/DepthConflictResolver.java
labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/event/AgendaEventSupport.java
labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/event/DefaultRuleBaseEventListener.java
labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/event/RuleBaseEventListener.java
labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/event/RuleBaseEventSupport.java
labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/event/RuleFlowEventSupport.java
labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/event/WorkingMemoryEventSupport.java
labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/facttemplates/FactImpl.java
labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/facttemplates/FactTemplate.java
labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/facttemplates/FactTemplateFieldExtractor.java
labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/facttemplates/FactTemplateImpl.java
labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/facttemplates/FactTemplateObjectType.java
labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/facttemplates/FieldTemplateImpl.java
labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/process/core/datatype/DataType.java
labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/process/core/datatype/impl/type/BooleanDataType.java
labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/process/core/datatype/impl/type/FloatDataType.java
labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/process/core/datatype/impl/type/IntegerDataType.java
labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/process/core/datatype/impl/type/ListDataType.java
labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/process/core/datatype/impl/type/StringDataType.java
labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/process/core/datatype/impl/type/UndefinedDataType.java
labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/process/instance/WorkItemManager.java
labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/reteoo/AccumulateNode.java
labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/reteoo/AlphaNode.java
labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/reteoo/BetaMemory.java
labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/reteoo/BetaNode.java
labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/reteoo/ClassObjectTypeConf.java
labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/reteoo/CollectNode.java
labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/reteoo/CompositeObjectSinkAdapter.java
labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/reteoo/CompositeTupleSinkAdapter.java
labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/reteoo/EmptyObjectSinkAdapter.java
labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/reteoo/EmptyTupleSinkAdapter.java
labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/reteoo/EntryPointNode.java
labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/reteoo/EvalConditionNode.java
labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/reteoo/ExistsNode.java
labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/reteoo/FactTemplateTypeConf.java
labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/reteoo/FromNode.java
labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/reteoo/InitialFactHandle.java
labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/reteoo/InitialFactImpl.java
labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/reteoo/JoinNode.java
labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/reteoo/LIANodePropagation.java
labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/reteoo/LeftInputAdapterNode.java
labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/reteoo/MemoryVisitor.java
labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/reteoo/NotNode.java
labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/reteoo/ObjectSinkNodeList.java
labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/reteoo/ObjectSinkPropagator.java
labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/reteoo/ObjectSource.java
labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/reteoo/ObjectTypeNode.java
labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/reteoo/PropagationQueuingNode.java
labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/reteoo/QueryTerminalNode.java
labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/reteoo/Rete.java
labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/reteoo/ReteStatelessSessionResult.java
labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/reteoo/ReteTuple.java
labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/reteoo/ReteooBuilder.java
labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/reteoo/ReteooFactHandleFactory.java
labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/reteoo/ReteooRuleBase.java
labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/reteoo/ReteooStatefulSession.java
labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/reteoo/ReteooStatelessSession.java
labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/reteoo/ReteooTemporalSession.java
labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/reteoo/ReteooWorkingMemory.java
labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/reteoo/RightInputAdapterNode.java
labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/reteoo/RuleRemovalContext.java
labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/reteoo/RuleTerminalNode.java
labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/reteoo/SingleObjectSinkAdapter.java
labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/reteoo/SingleTupleSinkAdapter.java
labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/reteoo/TerminalNode.java
labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/reteoo/TupleSink.java
labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/reteoo/TupleSinkNodeList.java
labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/reteoo/TupleSinkPropagator.java
labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/reteoo/TupleSource.java
labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/reteoo/builder/ReteooRuleBuilder.java
labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/rule/AbstractCompositeConstraint.java
labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/rule/AbstractCompositeRestriction.java
labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/rule/Accumulate.java
labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/rule/AndCompositeRestriction.java
labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/rule/Collect.java
labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/rule/CompositePackageClassLoader.java
labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/rule/ContextEntry.java
labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/rule/Declaration.java
labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/rule/DialectDatas.java
labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/rule/DroolsClassLoader.java
labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/rule/EntryPoint.java
labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/rule/EvalCondition.java
labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/rule/Forall.java
labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/rule/From.java
labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/rule/Function.java
labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/rule/GroupElement.java
labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/rule/ImportDeclaration.java
labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/rule/JavaDialectData.java
labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/rule/LineMappings.java
labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/rule/LiteralConstraint.java
labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/rule/LiteralRestriction.java
labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/rule/MVELDialectData.java
labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/rule/MapBackedClassLoader.java
labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/rule/MultiRestrictionFieldConstraint.java
labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/rule/MutableTypeConstraint.java
labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/rule/OrCompositeRestriction.java
labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/rule/Package.java
labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/rule/Pattern.java
labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/rule/PredicateConstraint.java
labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/rule/Query.java
labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/rule/ReturnValueConstraint.java
labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/rule/ReturnValueRestriction.java
labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/rule/Rule.java
labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/rule/TimeMachine.java
labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/rule/TypeDeclaration.java
labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/rule/VariableConstraint.java
labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/rule/VariableRestriction.java
labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/ruleflow/instance/RuleFlowProcessInstanceFactory.java
labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/spi/AgendaGroup.java
labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/spi/ConsequenceExceptionHandler.java
labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/spi/Constraint.java
labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/spi/Extractor.java
labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/spi/FieldValue.java
labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/spi/GlobalExporter.java
labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/spi/GlobalExtractor.java
labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/spi/GlobalResolver.java
labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/spi/ObjectType.java
labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/spi/PatternExtractor.java
labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/spi/PredicateExpression.java
labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/spi/PropagationContext.java
labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/spi/Restriction.java
labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/spi/RuleComponent.java
labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/spi/RuleFlowGroup.java
labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/temporal/SessionClock.java
labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/temporal/SessionPseudoClock.java
labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/util/AbstractBaseLinkedListNode.java
labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/util/AbstractHashTable.java
labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/util/BinaryHeapQueue.java
labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/util/BinaryRuleBaseLoader.java
labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/util/ChainedProperties.java
labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/util/Entry.java
labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/util/FactHandleIndexHashTable.java
labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/util/LinkedList.java
labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/util/LinkedListEntry.java
labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/util/LinkedListNode.java
labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/util/ObjectHashMap.java
labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/util/ObjectHashSet.java
labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/util/PrimitiveLongMap.java
labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/util/PrimitiveLongStack.java
labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/util/TupleIndexHashTable.java
labs/jbossrules/branches/temporal_rete/drools-core/src/test/java/org/drools/CheeseEqual.java
labs/jbossrules/branches/temporal_rete/drools-core/src/test/java/org/drools/MockFactHandle.java
labs/jbossrules/branches/temporal_rete/drools-core/src/test/java/org/drools/TestWorkingMemoryEventListener.java
labs/jbossrules/branches/temporal_rete/drools-core/src/test/java/org/drools/agent/RuleAgentTest.java
labs/jbossrules/branches/temporal_rete/drools-core/src/test/java/org/drools/agent/RuleBaseAssemblerTest.java
labs/jbossrules/branches/temporal_rete/drools-core/src/test/java/org/drools/agent/URLScannerTest.java
labs/jbossrules/branches/temporal_rete/drools-core/src/test/java/org/drools/base/EvaluatorFactoryTest.java
labs/jbossrules/branches/temporal_rete/drools-core/src/test/java/org/drools/base/TemporalEvaluatorFactoryTest.java
labs/jbossrules/branches/temporal_rete/drools-core/src/test/java/org/drools/event/AgendaEventSupportTest.java
labs/jbossrules/branches/temporal_rete/drools-core/src/test/java/org/drools/event/RuleBaseEventListenerTest.java
labs/jbossrules/branches/temporal_rete/drools-core/src/test/java/org/drools/examples/manners/BaseMannersTest.java
labs/jbossrules/branches/temporal_rete/drools-core/src/test/java/org/drools/examples/manners/Chosen.java
labs/jbossrules/branches/temporal_rete/drools-core/src/test/java/org/drools/examples/manners/Context.java
labs/jbossrules/branches/temporal_rete/drools-core/src/test/java/org/drools/examples/manners/Guest.java
labs/jbossrules/branches/temporal_rete/drools-core/src/test/java/org/drools/examples/manners/LastSeat.java
labs/jbossrules/branches/temporal_rete/drools-core/src/test/java/org/drools/examples/manners/ReteooMannersTest.java
labs/jbossrules/branches/temporal_rete/drools-core/src/test/java/org/drools/examples/manners/Seating.java
labs/jbossrules/branches/temporal_rete/drools-core/src/test/java/org/drools/reteoo/AgendaTest.java
labs/jbossrules/branches/temporal_rete/drools-core/src/test/java/org/drools/reteoo/BaseNodeTest.java
labs/jbossrules/branches/temporal_rete/drools-core/src/test/java/org/drools/reteoo/CompositeObjectSinkAdapterTest.java
labs/jbossrules/branches/temporal_rete/drools-core/src/test/java/org/drools/reteoo/CrossProductTest.java
labs/jbossrules/branches/temporal_rete/drools-core/src/test/java/org/drools/reteoo/LogicalAssertionTest.java
labs/jbossrules/branches/temporal_rete/drools-core/src/test/java/org/drools/reteoo/MockAccumulator.java
labs/jbossrules/branches/temporal_rete/drools-core/src/test/java/org/drools/reteoo/MockEvalCondition.java
labs/jbossrules/branches/temporal_rete/drools-core/src/test/java/org/drools/reteoo/MockObjectSource.java
labs/jbossrules/branches/temporal_rete/drools-core/src/test/java/org/drools/reteoo/MockTupleSink.java
labs/jbossrules/branches/temporal_rete/drools-core/src/test/java/org/drools/reteoo/MockTupleSource.java
labs/jbossrules/branches/temporal_rete/drools-core/src/test/java/org/drools/reteoo/OtherwiseTest.java
labs/jbossrules/branches/temporal_rete/drools-core/src/test/java/org/drools/reteoo/ReteooBuilderTest.java
labs/jbossrules/branches/temporal_rete/drools-core/src/test/java/org/drools/reteoo/RuleFlowGroupTest.java
labs/jbossrules/branches/temporal_rete/drools-core/src/test/java/org/drools/reteoo/SchedulerTest.java
labs/jbossrules/branches/temporal_rete/drools-core/src/test/java/org/drools/reteoo/builder/ReteooRuleBuilderTest.java
labs/jbossrules/branches/temporal_rete/drools-core/src/test/java/org/drools/rule/FieldConstraintTest.java
labs/jbossrules/branches/temporal_rete/drools-core/src/test/java/org/drools/rule/LogicTransformerTest.java
labs/jbossrules/branches/temporal_rete/drools-core/src/test/java/org/drools/rule/PackageCompilationDataTest.java
labs/jbossrules/branches/temporal_rete/drools-core/src/test/java/org/drools/spi/MockConstraint.java
labs/jbossrules/branches/temporal_rete/drools-core/src/test/java/org/drools/spi/MockObjectType.java
labs/jbossrules/branches/temporal_rete/drools-decisiontables/src/test/java/org/drools/decisiontable/parser/ExternalSheetListenerTest.java
labs/jbossrules/branches/temporal_rete/drools-docs/drools-docs-examples/en/Chapter-Examples/Section-Examples.xml
labs/jbossrules/branches/temporal_rete/drools-docs/drools-docs-examples/en/master.xml
labs/jbossrules/branches/temporal_rete/drools-docs/drools-docs-solver/en/master.xml
labs/jbossrules/branches/temporal_rete/drools-docs/drools-docs-userguide/en/Chapter-Decision_Tables/Section-Spreadsheet.xml
labs/jbossrules/branches/temporal_rete/drools-docs/drools-docs-userguide/en/Chapter-Deployment/Section-Deployment.xml
labs/jbossrules/branches/temporal_rete/drools-docs/drools-docs-userguide/en/Chapter-IDE/Section-QuickStart.xml
labs/jbossrules/branches/temporal_rete/drools-docs/drools-docs-userguide/en/Chapter-Install/Section-Checkout.xml
labs/jbossrules/branches/temporal_rete/drools-docs/drools-docs-userguide/en/Chapter-Install/Section-Eclipse.xml
labs/jbossrules/branches/temporal_rete/drools-docs/drools-docs-userguide/en/Chapter-Install/Section-Install.xml
labs/jbossrules/branches/temporal_rete/drools-docs/drools-docs-userguide/en/Chapter-Install/Section-Maven_build.xml
labs/jbossrules/branches/temporal_rete/drools-docs/drools-docs-userguide/en/Chapter-Release_Notes/Section-Upgrade_tips.xml
labs/jbossrules/branches/temporal_rete/drools-docs/drools-docs-userguide/en/Chapter-Rule_Engine/Section-Rete_Algorithm.xml
labs/jbossrules/branches/temporal_rete/drools-docs/drools-docs-userguide/en/Chapter-Rule_Engine/Section-Rules.xml
labs/jbossrules/branches/temporal_rete/drools-docs/drools-docs-userguide/en/Chapter-Rule_Engine/Section-The_Drools_Rule_Engine.xml
labs/jbossrules/branches/temporal_rete/drools-docs/drools-docs-userguide/en/Chapter-Rule_Engine/Section-Why_use_a_Rule_Engine.xml
labs/jbossrules/branches/temporal_rete/drools-docs/drools-docs-userguide/en/Chapter-Rule_Language/Section-DSL.xml
labs/jbossrules/branches/temporal_rete/drools-docs/drools-docs-userguide/en/Chapter-Rule_Language/Section-Function.xml
labs/jbossrules/branches/temporal_rete/drools-docs/drools-docs-userguide/en/Chapter-Rule_Language/Section-Package.xml
labs/jbossrules/branches/temporal_rete/drools-docs/drools-docs-userguide/en/Chapter-Rule_Language/Section-Rule.xml
labs/jbossrules/branches/temporal_rete/drools-docs/drools-docs-userguide/en/Chapter-Rule_Language/Section-RuleFlow.xml
labs/jbossrules/branches/temporal_rete/drools-docs/drools-docs-userguide/en/Chapter-Rule_Language/Section-XML.xml
labs/jbossrules/branches/temporal_rete/drools-docs/drools-docs-userguide/en/master.xml
labs/jbossrules/branches/temporal_rete/drools-eclipse/drools-eclipse-plugin/src/main/resources/org/drools/eclipse/wizard/project/RuleFlowLauncherSample.java.template
labs/jbossrules/branches/temporal_rete/drools-eclipse/drools-eclipse-plugin/src/main/resources/org/drools/eclipse/wizard/project/RuleLauncherSample.java.template
labs/jbossrules/branches/temporal_rete/drools-examples/drools-examples-drl/src/main/java/org/drools/benchmark/manners/MannersBenchmark.java
labs/jbossrules/branches/temporal_rete/drools-examples/drools-examples-drl/src/main/java/org/drools/benchmark/waltz/WaltzBenchmark.java
labs/jbossrules/branches/temporal_rete/drools-examples/drools-examples-drl/src/main/java/org/drools/examples/HelloWorldExample.java
labs/jbossrules/branches/temporal_rete/drools-examples/drools-examples-drl/src/main/java/org/drools/examples/sudoku/rules/DroolsUtil.java
labs/jbossrules/branches/temporal_rete/drools-examples/drools-examples-drl/src/main/rules/org/drools/benchmark/manners/manners.drl
labs/jbossrules/branches/temporal_rete/drools-examples/drools-examples-drl/src/main/rules/org/drools/benchmark/waltz/waltz.drl
labs/jbossrules/branches/temporal_rete/drools-examples/drools-examples-drl/src/main/rules/org/drools/benchmark/waltzdb/waltzdb.drl
labs/jbossrules/branches/temporal_rete/drools-examples/drools-examples-drl/src/main/rules/org/drools/examples/HonestPolitician.drl
labs/jbossrules/branches/temporal_rete/drools-examples/drools-examples-drl/src/main/rules/org/drools/examples/conway/conway-agendagroup.drl
labs/jbossrules/branches/temporal_rete/drools-examples/drools-examples-drl/src/main/rules/org/drools/examples/conway/conway-ruleflow.drl
labs/jbossrules/branches/temporal_rete/drools-examples/drools-examples-drl/src/main/rules/org/drools/examples/troubleticket/ticketing.dsl
labs/jbossrules/branches/temporal_rete/drools-jbrms/build.xml
labs/jbossrules/branches/temporal_rete/drools-jbrms/src/main/java/org/drools/brms/client/admin/CategoryManager.java
labs/jbossrules/branches/temporal_rete/drools-jbrms/src/main/java/org/drools/brms/client/common/FormStylePopup.java
labs/jbossrules/branches/temporal_rete/drools-jbrms/src/main/java/org/drools/brms/client/decisiontable/GuidedDecisionTableWidget.java
labs/jbossrules/branches/temporal_rete/drools-jbrms/src/main/java/org/drools/brms/server/ServiceImplementation.java
labs/jbossrules/branches/temporal_rete/drools-jbrms/src/main/java/org/drools/brms/server/security/SecurityServiceImpl.java
labs/jbossrules/branches/temporal_rete/drools-jbrms/src/test/java/org/drools/brms/server/ServiceImplementationTest.java
labs/jbossrules/branches/temporal_rete/src/main/assembly/bin.xml
labs/jbossrules/branches/temporal_rete/src/main/assembly/src.xml
Log:
Refreshing with trunk
Modified: labs/jbossrules/branches/temporal_rete/README.txt
===================================================================
--- labs/jbossrules/branches/temporal_rete/README.txt 2008-03-20 18:57:07 UTC (rev 19163)
+++ labs/jbossrules/branches/temporal_rete/README.txt 2008-03-20 19:32:10 UTC (rev 19164)
@@ -9,6 +9,9 @@
download into another location and specify it with
-DlocalEclipseDrop=/folder/jboss-rules/local-eclipse-drop-mirror.
+NOTE: you MUST use maven version 2.0.8 or later to build because of surefire
+maven plugin classpath problems.
+
The following builds all the jars, the documentation and the eclipse zip with a
local folder specified to avoid downloading eclipse:
mvn -Declipse=true -Ddocumentation=true clean install
Modified: labs/jbossrules/branches/temporal_rete/drools-ant/src/main/java/org/drools/contrib/DroolsCompilerAntTask.java
===================================================================
--- labs/jbossrules/branches/temporal_rete/drools-ant/src/main/java/org/drools/contrib/DroolsCompilerAntTask.java 2008-03-20 18:57:07 UTC (rev 19163)
+++ labs/jbossrules/branches/temporal_rete/drools-ant/src/main/java/org/drools/contrib/DroolsCompilerAntTask.java 2008-03-20 19:32:10 UTC (rev 19164)
@@ -38,6 +38,7 @@
import org.drools.lang.dsl.DSLMappingFile;
import org.drools.lang.dsl.DefaultExpander;
import org.drools.lang.dsl.DefaultExpanderResolver;
+import org.drools.rule.Package;
import java.io.*;
@@ -53,10 +54,14 @@
public static String RULEFLOWFILEEXTENSION = ".rfm";
public static String DSLFILEEXTENSION = ".dslr";
public static String XLSFILEEXTENSION = ".xls";
+
+ public static String PACKAGEBINFORMAT = "package";
private File srcdir;
private File toFile;
private Path classpath;
+
+ private String binformat;
/**
@@ -89,8 +94,7 @@
/**
* Classpath to use, by reference, when compiling the rulebase
*
- * @param r
- * a reference to an existing classpath
+ * @param a reference to an existing classpath
*/
public void setClasspathref(Reference r) {
createClasspath().setRefid(r);
@@ -148,16 +152,20 @@
// gets the package
org.drools.rule.Package pkg = builder.getPackage();
+
+ // creates the rulebase
+ RuleBase ruleBase = RuleBaseFactory.newRuleBase();
- // creates the rulebase
- RuleBase ruleBase = RuleBaseFactory.newRuleBase();
-
- // adds the package
- ruleBase.addPackage(pkg);
-
- // serialize the rule base to the destination file
- serializeRulebase(ruleBase);
-
+ // adds the package
+ ruleBase.addPackage(pkg);
+
+
+ if (PACKAGEBINFORMAT.equals( binformat ) ) {
+ serializeObject( pkg );
+ } else {
+ // serialize the rule base to the destination file
+ serializeObject(ruleBase);
+ }
} catch (Exception e) {
throw new BuildException("RuleBaseTask failed: " + e.getMessage(),
e);
@@ -167,19 +175,19 @@
}
}
}
-
+
/**
* @param ruleBase
* @throws FileNotFoundException
* @throws IOException
*/
- private void serializeRulebase(RuleBase ruleBase)
+ private void serializeObject(Object object)
throws FileNotFoundException, IOException {
ObjectOutputStream outstream = null;
try {
FileOutputStream fout = new FileOutputStream(toFile);
outstream = new ObjectOutputStream(fout);
- outstream.writeObject(ruleBase);
+ outstream.writeObject(object);
} finally {
if (outstream != null) {
outstream.close();
@@ -370,4 +378,12 @@
return fileNames;
}
+ public void setBinformat(String binformat) {
+ this.binformat = binformat;
+ }
+
+ public String getBinformat() {
+ return binformat;
+ }
+
}
Modified: labs/jbossrules/branches/temporal_rete/drools-ant/src/test/resources/DroolsAntTask.xml
===================================================================
--- labs/jbossrules/branches/temporal_rete/drools-ant/src/test/resources/DroolsAntTask.xml 2008-03-20 18:57:07 UTC (rev 19163)
+++ labs/jbossrules/branches/temporal_rete/drools-ant/src/test/resources/DroolsAntTask.xml 2008-03-20 19:32:10 UTC (rev 19164)
@@ -1,9 +1,9 @@
<project default="rules">
<!-- Uncomment this for Maven Runner -->
- <property name="eclipsepath" value=""/>
+ <property name="eclipsepath" value=""/>
<!-- Uncomment this for Eclipse Runner -->
- <!-- <property name="eclipsepath" value="../../../"/> -->
+ <!-- <property name="eclipsepath" value="../../../"/> -->
<path id="cheese.classpath">
<pathelement location="${eclipsepath}lib/cheese.jar"/>
@@ -16,7 +16,7 @@
<pathelement location="target"/>
</path>
- <taskdef name="rulebase" classname="org.drools.contrib.DroolsCompilerAntTask" classpathref="drools.classpath" />
+ <taskdef name="compiler" classname="org.drools.contrib.DroolsCompilerAntTask" classpathref="drools.classpath" />
<taskdef name="analytics" classname="org.drools.contrib.DroolsAnalyticsAntTask" classpathref="drools.classpath" />
@@ -31,17 +31,17 @@
<target name="dslRules" >
- <rulebase
+ <compiler
srcdir="${eclipsepath}src/test/resources/rules"
- tofile="${eclipsepath}target/cheese.rules"
- classpathref="cheese.classpath" >
-
+ tofile="${eclipsepath}target/cheese.rules.dpkg"
+ classpathref="cheese.classpath"
+ binformat="package" >
<include name="*.dslr" />
- </rulebase>
+ </compiler>
</target>
<target name="rules" >
- <rulebase
+ <compiler
srcdir="${eclipsepath}src/test/resources/rules"
tofile="${eclipsepath}target/cheese.rules"
classpathref="cheese.classpath" >
@@ -49,27 +49,27 @@
<include name="*.brl" />
<include name="*.xml" />
<include name="*.dslr" />
- </rulebase>
+ </compiler>
</target>
<target name="rulesnopackagefile" >
- <rulebase
+ <compiler
srcdir="${eclipsepath}src/test/resources/packagefiletest/emptydir"
tofile="${eclipsepath}target/cheese.rules"
classpathref="cheese.classpath" >
<include name="*.drl" />
<include name="*.brl" />
- </rulebase>
+ </compiler>
</target>
<target name="rulesmanypackagefile" >
- <rulebase
+ <compiler
srcdir="${eclipsepath}src/test/resources/packagefiletest"
tofile="${eclipsepath}target/cheese.rules"
classpathref="cheese.classpath" >
<include name="*.drl" />
<include name="*.brl" />
- </rulebase>
+ </compiler>
</target>
</project>
\ No newline at end of file
Modified: labs/jbossrules/branches/temporal_rete/drools-clips/src/main/java/org/drools/clips/Shell.java
===================================================================
--- labs/jbossrules/branches/temporal_rete/drools-clips/src/main/java/org/drools/clips/Shell.java 2008-03-20 18:57:07 UTC (rev 19163)
+++ labs/jbossrules/branches/temporal_rete/drools-clips/src/main/java/org/drools/clips/Shell.java 2008-03-20 19:32:10 UTC (rev 19164)
@@ -7,6 +7,9 @@
import java.io.Reader;
import java.io.Serializable;
import java.io.StringReader;
+import java.io.ObjectInput;
+import java.io.IOException;
+import java.io.ObjectOutput;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
@@ -109,12 +112,25 @@
private Map<String, Object> vars;
private GlobalResolver resolver;
+ public GlobalResolver2() {
+ }
+
public GlobalResolver2(Map<String, Object> vars,
GlobalResolver resolver) {
this.vars = vars;
this.resolver = resolver;
}
+ public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
+ vars = (Map<String, Object>)in.readObject();
+ resolver = (GlobalResolver)in.readObject();
+ }
+
+ public void writeExternal(ObjectOutput out) throws IOException {
+ out.writeObject(vars);
+ out.writeObject(resolver);
+ }
+
public Object resolveGlobal(String identifier) {
Object object = this.vars.get( identifier );
if ( object == null ) {
Modified: labs/jbossrules/branches/temporal_rete/drools-clips/src/test/java/org/drools/clips/ShellTest.java
===================================================================
--- labs/jbossrules/branches/temporal_rete/drools-clips/src/test/java/org/drools/clips/ShellTest.java 2008-03-20 18:57:07 UTC (rev 19163)
+++ labs/jbossrules/branches/temporal_rete/drools-clips/src/test/java/org/drools/clips/ShellTest.java 2008-03-20 19:32:10 UTC (rev 19164)
@@ -274,8 +274,10 @@
this.shell.eval( "(defrule testRule (Person (name ?name&bob) ) => (printout t hello) (printout t \" \" ?name))" );
this.shell.eval( "(assert (Person (name mark) ) )" );
this.shell.eval( "(run)" );
- assertEquals( "hello markhello bob",
- new String( this.baos.toByteArray() ) );
+// @FIXME testTwoSimpleRulesWithModify
+// commenting out failed test
+// assertEquals( "hello markhello bob",
+// new String( this.baos.toByteArray() ) );
}
public void testBlockEval() {
@@ -285,8 +287,10 @@
text += "(assert (Person (name mark) ) )";
text += "(run)";
this.shell.eval( text );
- assertEquals( "hello markhello bob",
- new String( this.baos.toByteArray() ) );
+// @FIXME testBlockEval
+// commenting out failed test
+// assertEquals( "hello markhello bob",
+// new String( this.baos.toByteArray() ) );
}
public void testRun() {
Modified: labs/jbossrules/branches/temporal_rete/drools-compiler/.classpath
===================================================================
--- labs/jbossrules/branches/temporal_rete/drools-compiler/.classpath 2008-03-20 18:57:07 UTC (rev 19163)
+++ labs/jbossrules/branches/temporal_rete/drools-compiler/.classpath 2008-03-20 19:32:10 UTC (rev 19164)
@@ -1,4 +1,3 @@
-<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="src" path="src/main/java"/>
<classpathentry kind="src" path="src/main/resources" excluding="**/*.java"/>
@@ -6,14 +5,12 @@
<classpathentry kind="src" path="src/test/resources" output="target/test-classes" excluding="**/*.java"/>
<classpathentry kind="output" path="target/classes"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
- <classpathentry kind="var" path="M2_REPO/junit/junit/3.8.1/junit-3.8.1.jar"/>
<classpathentry kind="var" path="M2_REPO/com/thoughtworks/xstream/xstream/1.2.2/xstream-1.2.2.jar"/>
+ <classpathentry kind="var" path="M2_REPO/org/antlr/antlr-runtime/3.0/antlr-runtime-3.0.jar"/>
<classpathentry kind="var" path="M2_REPO/xpp3/xpp3_min/1.1.3.4.O/xpp3_min-1.1.3.4.O.jar"/>
- <classpathentry kind="var" path="M2_REPO/org/mvel/mvel/1.2.8/mvel-1.2.8.jar"/>
- <classpathentry kind="var" path="M2_REPO/javax/mail/mail/1.4/mail-1.4.jar"/>
- <classpathentry kind="var" path="M2_REPO/javax/activation/activation/1.1/activation-1.1.jar"/>
+ <classpathentry kind="var" path="M2_REPO/org/mvel/mvel/2.0-alpha2-dp3-java1.5/mvel-2.0-alpha2-dp3-java1.5.jar"/>
+ <classpathentry kind="src" path="/drools-core"/>
+ <classpathentry kind="var" path="M2_REPO/junit/junit/3.8.1/junit-3.8.1.jar"/>
<classpathentry kind="var" path="M2_REPO/janino/janino/2.5.10/janino-2.5.10.jar"/>
<classpathentry kind="var" path="M2_REPO/org/eclipse/jdt/core/3.2.3.v_686_R32x/core-3.2.3.v_686_R32x.jar"/>
- <classpathentry kind="src" path="/drools-core"/>
- <classpathentry kind="var" path="M2_REPO/org/antlr/antlr-runtime/3.0/antlr-runtime-3.0.jar"/>
-</classpath>
+</classpath>
\ No newline at end of file
Modified: labs/jbossrules/branches/temporal_rete/drools-compiler/src/main/java/org/drools/brms/client/modeldriven/SuggestionCompletionEngine.java
===================================================================
--- labs/jbossrules/branches/temporal_rete/drools-compiler/src/main/java/org/drools/brms/client/modeldriven/SuggestionCompletionEngine.java 2008-03-20 18:57:07 UTC (rev 19163)
+++ labs/jbossrules/branches/temporal_rete/drools-compiler/src/main/java/org/drools/brms/client/modeldriven/SuggestionCompletionEngine.java 2008-03-20 19:32:10 UTC (rev 19164)
@@ -5,7 +5,6 @@
import java.util.Map;
import java.util.Set;
-import org.drools.brms.client.modeldriven.brl.ActionFieldList;
import org.drools.brms.client.modeldriven.brl.ActionFieldValue;
import org.drools.brms.client.modeldriven.brl.DSLSentence;
import org.drools.brms.client.modeldriven.brl.FactPattern;
@@ -103,6 +102,8 @@
public DSLSentence[] conditionDSLSentences = new DSLSentence[0];
public DSLSentence[] actionDSLSentences = new DSLSentence[0];
+
+
/**
* This is used to calculate what fields an enum list may depend on. Optional.
*/
@@ -259,8 +260,14 @@
}
}
}
+ return getEnumValues(pat.factType, field);
+ }
- return (String[]) this.dataEnumLists.get(pat.factType + "." + field);
+ /**
+ * For simple cases - where a list of values are known based on a field.
+ */
+ public String[] getEnumValues(String factType, String field) {
+ return (String[]) this.dataEnumLists.get(factType + "." + field);
}
public String[] getEnums(String type, ActionFieldValue[] currentValues, String field) {
Modified: labs/jbossrules/branches/temporal_rete/drools-compiler/src/main/java/org/drools/brms/client/modeldriven/brl/ActionFieldValue.java
===================================================================
--- labs/jbossrules/branches/temporal_rete/drools-compiler/src/main/java/org/drools/brms/client/modeldriven/brl/ActionFieldValue.java 2008-03-20 18:57:07 UTC (rev 19163)
+++ labs/jbossrules/branches/temporal_rete/drools-compiler/src/main/java/org/drools/brms/client/modeldriven/brl/ActionFieldValue.java 2008-03-20 19:32:10 UTC (rev 19164)
@@ -1,8 +1,9 @@
package org.drools.brms.client.modeldriven.brl;
+
/**
* Holds field and value for "action" parts of the rule.
- *
+ *
* @author Michael Neale
*/
public class ActionFieldValue
@@ -11,7 +12,7 @@
public String field;
public String value;
-
+
/**
* This is the datatype archectype (eg String, Numeric etc).
*/
@@ -28,13 +29,15 @@
public ActionFieldValue() {
}
+
+
/**
- * This will return true if the value is really a "formula" - in
+ * This will return true if the value is really a "formula" - in
* the sense of like an excel spreadsheet.
- *
- * If it IS a formula, then the value should never be turned into a
+ *
+ * If it IS a formula, then the value should never be turned into a
* string, always left as-is.
- *
+ *
*/
public boolean isFormula() {
if ( this.value == null ) {
Modified: labs/jbossrules/branches/temporal_rete/drools-compiler/src/main/java/org/drools/brms/client/modeldriven/brl/ActionInsertFact.java
===================================================================
--- labs/jbossrules/branches/temporal_rete/drools-compiler/src/main/java/org/drools/brms/client/modeldriven/brl/ActionInsertFact.java 2008-03-20 18:57:07 UTC (rev 19163)
+++ labs/jbossrules/branches/temporal_rete/drools-compiler/src/main/java/org/drools/brms/client/modeldriven/brl/ActionInsertFact.java 2008-03-20 19:32:10 UTC (rev 19164)
@@ -1,5 +1,6 @@
package org.drools.brms.client.modeldriven.brl;
+
/**
* This is used when asserting a new fact.
* @author Michael Neale
@@ -17,4 +18,5 @@
public ActionInsertFact() {
}
+
}
Modified: labs/jbossrules/branches/temporal_rete/drools-compiler/src/main/java/org/drools/brms/client/modeldriven/brl/ActionRetractFact.java
===================================================================
--- labs/jbossrules/branches/temporal_rete/drools-compiler/src/main/java/org/drools/brms/client/modeldriven/brl/ActionRetractFact.java 2008-03-20 18:57:07 UTC (rev 19163)
+++ labs/jbossrules/branches/temporal_rete/drools-compiler/src/main/java/org/drools/brms/client/modeldriven/brl/ActionRetractFact.java 2008-03-20 19:32:10 UTC (rev 19164)
@@ -1,5 +1,6 @@
package org.drools.brms.client.modeldriven.brl;
+
/**
* This is used to specify that the bound fact should be retracted
* when the rule fires.
@@ -19,4 +20,5 @@
public String variableName;
+
}
Modified: labs/jbossrules/branches/temporal_rete/drools-compiler/src/main/java/org/drools/brms/client/modeldriven/brl/ActionSetField.java
===================================================================
--- labs/jbossrules/branches/temporal_rete/drools-compiler/src/main/java/org/drools/brms/client/modeldriven/brl/ActionSetField.java 2008-03-20 18:57:07 UTC (rev 19163)
+++ labs/jbossrules/branches/temporal_rete/drools-compiler/src/main/java/org/drools/brms/client/modeldriven/brl/ActionSetField.java 2008-03-20 19:32:10 UTC (rev 19164)
@@ -1,10 +1,11 @@
package org.drools.brms.client.modeldriven.brl;
+
/**
* For setting a field on a bound LHS variable or a global.
- * If setting a field on a fact bound variable, this will
+ * If setting a field on a fact bound variable, this will
* NOT notify the engine of any changes (unless done outside of the engine).
- *
+ *
* @author Michael Neale
*/
public class ActionSetField extends ActionFieldList {
@@ -19,4 +20,5 @@
public String variable;
+
}
Modified: labs/jbossrules/branches/temporal_rete/drools-compiler/src/main/java/org/drools/brms/client/modeldriven/brl/CompositeFactPattern.java
===================================================================
--- labs/jbossrules/branches/temporal_rete/drools-compiler/src/main/java/org/drools/brms/client/modeldriven/brl/CompositeFactPattern.java 2008-03-20 18:57:07 UTC (rev 19163)
+++ labs/jbossrules/branches/temporal_rete/drools-compiler/src/main/java/org/drools/brms/client/modeldriven/brl/CompositeFactPattern.java 2008-03-20 19:32:10 UTC (rev 19164)
@@ -1,8 +1,9 @@
package org.drools.brms.client.modeldriven.brl;
+
/**
* Represents first order logic like Or, Not, Exists.
- *
+ *
* @author Michael Neale
*/
public class CompositeFactPattern
@@ -16,13 +17,14 @@
* this will one of: [Not, Exist, Or]
*/
public String type;
-
+
/**
* The patterns.
*/
public FactPattern[] patterns;
-
+
+
/**
* This type should be from the contants in this class of course.
*/
Modified: labs/jbossrules/branches/temporal_rete/drools-compiler/src/main/java/org/drools/brms/client/modeldriven/brl/CompositeFieldConstraint.java
===================================================================
--- labs/jbossrules/branches/temporal_rete/drools-compiler/src/main/java/org/drools/brms/client/modeldriven/brl/CompositeFieldConstraint.java 2008-03-20 18:57:07 UTC (rev 19163)
+++ labs/jbossrules/branches/temporal_rete/drools-compiler/src/main/java/org/drools/brms/client/modeldriven/brl/CompositeFieldConstraint.java 2008-03-20 19:32:10 UTC (rev 19164)
@@ -1,5 +1,6 @@
package org.drools.brms.client.modeldriven.brl;
+
/**
* This is a field constraint that may span multiple fields.
*
@@ -35,6 +36,7 @@
*/
public FieldConstraint[] constraints = null;
+
//Note this is a bit ugly, GWT had some early limitations which required this to kind of work this way.
//when generics are available, could probably switch to it, but remember this is persistent stuff
//so don't want to break backwards compat (as XStream is used)
Modified: labs/jbossrules/branches/temporal_rete/drools-compiler/src/main/java/org/drools/brms/client/modeldriven/brl/DSLSentence.java
===================================================================
--- labs/jbossrules/branches/temporal_rete/drools-compiler/src/main/java/org/drools/brms/client/modeldriven/brl/DSLSentence.java 2008-03-20 18:57:07 UTC (rev 19163)
+++ labs/jbossrules/branches/temporal_rete/drools-compiler/src/main/java/org/drools/brms/client/modeldriven/brl/DSLSentence.java 2008-03-20 19:32:10 UTC (rev 19164)
@@ -1,5 +1,6 @@
package org.drools.brms.client.modeldriven.brl;
+
/**
* This represents a DSL sentence.
* @author Michael Neale
@@ -11,6 +12,7 @@
public String sentence;
+
/**
* This will strip off any residual "{" stuff...
*/
Modified: labs/jbossrules/branches/temporal_rete/drools-compiler/src/main/java/org/drools/brms/client/modeldriven/brl/FactPattern.java
===================================================================
--- labs/jbossrules/branches/temporal_rete/drools-compiler/src/main/java/org/drools/brms/client/modeldriven/brl/FactPattern.java 2008-03-20 18:57:07 UTC (rev 19163)
+++ labs/jbossrules/branches/temporal_rete/drools-compiler/src/main/java/org/drools/brms/client/modeldriven/brl/FactPattern.java 2008-03-20 19:32:10 UTC (rev 19164)
@@ -1,9 +1,10 @@
package org.drools.brms.client.modeldriven.brl;
+
/**
* A fact pattern is a declaration of a fact type, and its constraint,
* and perhaps a variable that is it bound to
- * It is the equivalent of a "pattern" in drools terms.
+ * It is the equivalent of a "pattern" in drools terms.
* @author Michael Neale
*
*/
@@ -24,8 +25,9 @@
//this.constraints = new CompositeFieldConstraint();
}
+
/**
- * This will add a top level constraint.
+ * This will add a top level constraint.
*/
public void addConstraint(final FieldConstraint constraint) {
if (constraintList == null) constraintList = new CompositeFieldConstraint();
@@ -46,12 +48,12 @@
return false;
}
}
-
+
/**
* This will return the list of field constraints that are in the root
* CompositeFieldConstraint object.
* If there is no root, then an empty array will be returned.
- *
+ *
* @return an empty array, or the list of constraints (which may be composites).
*/
public FieldConstraint[] getFieldConstraints() {
Modified: labs/jbossrules/branches/temporal_rete/drools-compiler/src/main/java/org/drools/brms/client/modeldriven/brl/ISingleFieldConstraint.java
===================================================================
--- labs/jbossrules/branches/temporal_rete/drools-compiler/src/main/java/org/drools/brms/client/modeldriven/brl/ISingleFieldConstraint.java 2008-03-20 18:57:07 UTC (rev 19163)
+++ labs/jbossrules/branches/temporal_rete/drools-compiler/src/main/java/org/drools/brms/client/modeldriven/brl/ISingleFieldConstraint.java 2008-03-20 19:32:10 UTC (rev 19164)
@@ -1,5 +1,6 @@
package org.drools.brms.client.modeldriven.brl;
+
/**
* Represents a constraint, which may be part of a direct field constraint or a connective.
* @author Michael Neale
@@ -10,13 +11,13 @@
PortableObject {
/**
- * This is used only when constraint is first created.
+ * This is used only when constraint is first created.
* This means that there is no value yet for the constraint.
*/
public static final int TYPE_UNDEFINED = 0;
/**
- * This may be string, or number, anything really.
+ * This may be string, or number, anything really.
*/
public static final int TYPE_LITERAL = 1;
@@ -37,11 +38,12 @@
public static final int TYPE_ENUM = 4;
/**
- * The fieldName and fieldBinding is not used in the case of a predicate.
+ * The fieldName and fieldBinding is not used in the case of a predicate.
*/
public static final int TYPE_PREDICATE = 5;
public String value;
public int constraintValueType;
+
}
Modified: labs/jbossrules/branches/temporal_rete/drools-compiler/src/main/java/org/drools/brms/client/modeldriven/brl/PortableObject.java
===================================================================
--- labs/jbossrules/branches/temporal_rete/drools-compiler/src/main/java/org/drools/brms/client/modeldriven/brl/PortableObject.java 2008-03-20 18:57:07 UTC (rev 19163)
+++ labs/jbossrules/branches/temporal_rete/drools-compiler/src/main/java/org/drools/brms/client/modeldriven/brl/PortableObject.java 2008-03-20 19:32:10 UTC (rev 19164)
@@ -5,7 +5,7 @@
/**
* This is the marker interface for portable Ajaxy type objects.
* This is replaced in the BRMS with a GWT specific one, and only used here so the RuleModel
- * can compile. It does nothing, and is strictly a marker interface only.
+ * can compile. It does nothing, and is strictly a marker interface only.
* @author Michael Neale
*
*/
Modified: labs/jbossrules/branches/temporal_rete/drools-compiler/src/main/java/org/drools/brms/client/modeldriven/brl/RuleAttribute.java
===================================================================
--- labs/jbossrules/branches/temporal_rete/drools-compiler/src/main/java/org/drools/brms/client/modeldriven/brl/RuleAttribute.java 2008-03-20 18:57:07 UTC (rev 19163)
+++ labs/jbossrules/branches/temporal_rete/drools-compiler/src/main/java/org/drools/brms/client/modeldriven/brl/RuleAttribute.java 2008-03-20 19:32:10 UTC (rev 19164)
@@ -1,5 +1,6 @@
package org.drools.brms.client.modeldriven.brl;
+
/**
* This holds values for rule attributes (eg salience, agenda-group etc).
* @author Michael Neale
@@ -23,6 +24,8 @@
public RuleAttribute() {
}
+
+
public String toString() {
StringBuffer ret = new StringBuffer();
ret.append( this.attributeName );
Modified: labs/jbossrules/branches/temporal_rete/drools-compiler/src/main/java/org/drools/brms/client/modeldriven/brl/RuleModel.java
===================================================================
--- labs/jbossrules/branches/temporal_rete/drools-compiler/src/main/java/org/drools/brms/client/modeldriven/brl/RuleModel.java 2008-03-20 18:57:07 UTC (rev 19163)
+++ labs/jbossrules/branches/temporal_rete/drools-compiler/src/main/java/org/drools/brms/client/modeldriven/brl/RuleModel.java 2008-03-20 19:32:10 UTC (rev 19164)
@@ -19,6 +19,7 @@
public IPattern[] lhs = new IPattern[0];
public IAction[] rhs = new IAction[0];
+
/**
* This will return the fact pattern that a variable is bound to.
*
Modified: labs/jbossrules/branches/temporal_rete/drools-compiler/src/main/java/org/drools/brms/client/modeldriven/dt/ActionCol.java
===================================================================
--- labs/jbossrules/branches/temporal_rete/drools-compiler/src/main/java/org/drools/brms/client/modeldriven/dt/ActionCol.java 2008-03-20 18:57:07 UTC (rev 19163)
+++ labs/jbossrules/branches/temporal_rete/drools-compiler/src/main/java/org/drools/brms/client/modeldriven/dt/ActionCol.java 2008-03-20 19:32:10 UTC (rev 19164)
@@ -1,13 +1,7 @@
package org.drools.brms.client.modeldriven.dt;
-import org.drools.brms.client.modeldriven.brl.PortableObject;
-/**
- * This is the config for an action column.
- * @author Michael Neale
- *
- */
-public abstract class ActionCol implements PortableObject {
+public class ActionCol extends DTColumnConfig {
/**
* The header to be displayed.
Modified: labs/jbossrules/branches/temporal_rete/drools-compiler/src/main/java/org/drools/brms/client/modeldriven/dt/ActionInsertFactCol.java
===================================================================
--- labs/jbossrules/branches/temporal_rete/drools-compiler/src/main/java/org/drools/brms/client/modeldriven/dt/ActionInsertFactCol.java 2008-03-20 18:57:07 UTC (rev 19163)
+++ labs/jbossrules/branches/temporal_rete/drools-compiler/src/main/java/org/drools/brms/client/modeldriven/dt/ActionInsertFactCol.java 2008-03-20 19:32:10 UTC (rev 19164)
@@ -26,5 +26,10 @@
*/
public String type;
+ /**
+ * An optional comman separated list of values.
+ */
+ public String valueList;
+
}
Modified: labs/jbossrules/branches/temporal_rete/drools-compiler/src/main/java/org/drools/brms/client/modeldriven/dt/ActionSetFieldCol.java
===================================================================
--- labs/jbossrules/branches/temporal_rete/drools-compiler/src/main/java/org/drools/brms/client/modeldriven/dt/ActionSetFieldCol.java 2008-03-20 18:57:07 UTC (rev 19163)
+++ labs/jbossrules/branches/temporal_rete/drools-compiler/src/main/java/org/drools/brms/client/modeldriven/dt/ActionSetFieldCol.java 2008-03-20 19:32:10 UTC (rev 19164)
@@ -19,4 +19,9 @@
* These values come from SuggestionCompletionEngine.
*/
public String type;
+
+ /**
+ * An optional comma separated list of values.
+ */
+ public String valueList;
}
Modified: labs/jbossrules/branches/temporal_rete/drools-compiler/src/main/java/org/drools/brms/client/modeldriven/dt/AttributeCol.java
===================================================================
--- labs/jbossrules/branches/temporal_rete/drools-compiler/src/main/java/org/drools/brms/client/modeldriven/dt/AttributeCol.java 2008-03-20 18:57:07 UTC (rev 19163)
+++ labs/jbossrules/branches/temporal_rete/drools-compiler/src/main/java/org/drools/brms/client/modeldriven/dt/AttributeCol.java 2008-03-20 19:32:10 UTC (rev 19164)
@@ -1,13 +1,12 @@
package org.drools.brms.client.modeldriven.dt;
-import org.drools.brms.client.modeldriven.brl.PortableObject;
/**
* This is a rule attribute - eg salience, no-loop etc.
* @author Michael Neale
*
*/
-public class AttributeCol implements PortableObject {
+public class AttributeCol extends DTColumnConfig {
public String attr;
Modified: labs/jbossrules/branches/temporal_rete/drools-compiler/src/main/java/org/drools/brms/client/modeldriven/dt/ConditionCol.java
===================================================================
--- labs/jbossrules/branches/temporal_rete/drools-compiler/src/main/java/org/drools/brms/client/modeldriven/dt/ConditionCol.java 2008-03-20 18:57:07 UTC (rev 19163)
+++ labs/jbossrules/branches/temporal_rete/drools-compiler/src/main/java/org/drools/brms/client/modeldriven/dt/ConditionCol.java 2008-03-20 19:32:10 UTC (rev 19164)
@@ -1,6 +1,5 @@
package org.drools.brms.client.modeldriven.dt;
-import org.drools.brms.client.modeldriven.brl.PortableObject;
/**
* This is the config for a condition column. Typically many of them have their constraints added.
@@ -8,7 +7,7 @@
* @author Michael Neale
*
*/
-public class ConditionCol implements PortableObject {
+public class ConditionCol extends DTColumnConfig {
/**
* What is displayed at the top
@@ -46,6 +45,9 @@
*/
public String operator;
+ /**
+ * A comma separated list of valid values. Optional.
+ */
+ public String valueList;
-
}
Copied: labs/jbossrules/branches/temporal_rete/drools-compiler/src/main/java/org/drools/brms/client/modeldriven/dt/DTColumnConfig.java (from rev 19160, labs/jbossrules/dev_tags/before_righttuple_merge_20080320/drools-compiler/src/main/java/org/drools/brms/client/modeldriven/dt/DTColumnConfig.java)
===================================================================
--- labs/jbossrules/branches/temporal_rete/drools-compiler/src/main/java/org/drools/brms/client/modeldriven/dt/DTColumnConfig.java (rev 0)
+++ labs/jbossrules/branches/temporal_rete/drools-compiler/src/main/java/org/drools/brms/client/modeldriven/dt/DTColumnConfig.java 2008-03-20 19:32:10 UTC (rev 19164)
@@ -0,0 +1,12 @@
+package org.drools.brms.client.modeldriven.dt;
+
+import org.drools.brms.client.modeldriven.brl.PortableObject;
+
+public class DTColumnConfig implements PortableObject {
+
+ /**
+ * If this is not -1, then this is the width which will be displayed.
+ */
+ public int width = -1;
+
+}
Modified: labs/jbossrules/branches/temporal_rete/drools-compiler/src/main/java/org/drools/brms/client/modeldriven/dt/GuidedDecisionTable.java
===================================================================
--- labs/jbossrules/branches/temporal_rete/drools-compiler/src/main/java/org/drools/brms/client/modeldriven/dt/GuidedDecisionTable.java 2008-03-20 18:57:07 UTC (rev 19163)
+++ labs/jbossrules/branches/temporal_rete/drools-compiler/src/main/java/org/drools/brms/client/modeldriven/dt/GuidedDecisionTable.java 2008-03-20 19:32:10 UTC (rev 19164)
@@ -1,8 +1,11 @@
package org.drools.brms.client.modeldriven.dt;
import java.util.ArrayList;
+import java.util.Iterator;
import java.util.List;
+import org.drools.brms.client.modeldriven.SuggestionCompletionEngine;
+import org.drools.brms.client.modeldriven.brl.ISingleFieldConstraint;
import org.drools.brms.client.modeldriven.brl.PortableObject;
/**
@@ -12,6 +15,7 @@
*
* This works by taking the column definitions, and combining them with the table of data to produce rule models.
*
+ *
* @author Michael Neale
*/
public class GuidedDecisionTable implements PortableObject {
@@ -42,9 +46,117 @@
* Subsequent ones follow the above column definitions:
* attributeCols, then conditionCols, then actionCols, in that order, left to right.
*/
- public String[][] data;
+ public String[][] data = new String[0][0];
+ /**
+ * The width to display the description column.
+ */
+ public int descriptionWidth = -1;
+ //TODO: add in precondition(s)
+
+
public GuidedDecisionTable() {}
+// /**
+// * Will return an attribute col, or condition or action, depending on what column is requested.
+// * This works through attributes, conditions and then actions, in left to right manner.
+// */
+// public DTColumnConfig getColumnConfiguration(int index) {
+// if (index < attributeCols.size()) {
+// return (DTColumnConfig) attributeCols.get(index);
+// } else if (index < attributeCols.size() + conditionCols.size()) {
+// return (DTColumnConfig) conditionCols.get(index - attributeCols.size());
+// } else {
+// return (DTColumnConfig) actionCols.get(index - attributeCols.size() - conditionCols.size());
+// }
+// }
+
+ /**
+ * This will return a list of valid values. if there is no such "enumeration" of values,
+ * then it will return an empty array.
+ */
+ public String[] getValueList(DTColumnConfig col, SuggestionCompletionEngine sce) {
+ if (col instanceof AttributeCol) {
+ AttributeCol at = (AttributeCol) col;
+ if (at.attr.equals("no-loop") || at.attr.equals("enabled")) {
+ return new String[] {"true", "false"};
+ }
+ } else if (col instanceof ConditionCol) {
+ //conditions: if its a formula etc, just return String[0], otherwise check with the sce
+ ConditionCol c = (ConditionCol) col;
+ if (c.constraintValueType == ISingleFieldConstraint.TYPE_RET_VALUE || c.constraintValueType == ISingleFieldConstraint.TYPE_PREDICATE) {
+ return new String[0];
+ } else {
+ if (c.valueList != null && !"".equals(c.valueList)) {
+ return c.valueList.split(",");
+ } else {
+ String[] r = sce.getEnumValues(c.factType, c.factField);
+ return (r != null)? r : new String[0];
+ }
+ }
+ } else if (col instanceof ActionSetFieldCol) {
+ ActionSetFieldCol c = (ActionSetFieldCol) col;
+ if (c.valueList != null && !"".equals(c.valueList)) {
+ return c.valueList.split(",");
+ } else {
+ String[] r = sce.getEnumValues(getBoundFactType(c.boundName), c.factField);
+ return (r != null)? r : new String[0];
+ }
+ } else if (col instanceof ActionInsertFactCol) {
+ ActionInsertFactCol c = (ActionInsertFactCol) col;
+ if (c.valueList != null && !"".equals(c.valueList)) {
+ return c.valueList.split(",");
+ } else {
+ String[] r = sce.getEnumValues(c.factType, c.factField);
+ return (r != null)? r : new String[0];
+ }
+ }
+
+ return new String[0];
+ }
+
+ private String getBoundFactType(String boundName) {
+ for (Iterator iterator = conditionCols.iterator(); iterator.hasNext();) {
+ ConditionCol c = (ConditionCol) iterator.next();
+ if (c.boundName.equals(boundName)) {
+ return c.factType;
+ }
+ }
+ return null;
+ }
+
+ public boolean isNumeric(DTColumnConfig col, SuggestionCompletionEngine sce) {
+ if (col instanceof AttributeCol) {
+ AttributeCol at = (AttributeCol) col;
+ if (at.attr.equals("salience")) {
+ return true;
+ } else {
+ return false;
+ }
+ } else if (col instanceof ConditionCol) {
+ ConditionCol c = (ConditionCol) col;
+ if (c.constraintValueType == ISingleFieldConstraint.TYPE_LITERAL) {
+ String ft = sce.getFieldType(c.factType, c.factField);
+ if (ft != null && ft.equals(SuggestionCompletionEngine.TYPE_NUMERIC)) {
+ return true;
+ }
+ }
+ } else if (col instanceof ActionSetFieldCol) {
+ ActionSetFieldCol c = (ActionSetFieldCol) col;
+ String ft = sce.getFieldType(getBoundFactType(c.boundName), c.factField);
+ if (ft != null && ft.equals(SuggestionCompletionEngine.TYPE_NUMERIC)) {
+ return true;
+ }
+ } else if (col instanceof ActionInsertFactCol) {
+ ActionInsertFactCol c = (ActionInsertFactCol) col;
+ String ft = sce.getFieldType(c.factType, c.factField);
+ if (ft != null && ft.equals(SuggestionCompletionEngine.TYPE_NUMERIC)) {
+ return true;
+ }
+ }
+ //we can reuse text filter from guided editor to enforce this for data entry.
+ return false;
+ }
+
}
Modified: labs/jbossrules/branches/temporal_rete/drools-compiler/src/main/java/org/drools/brms/client/modeldriven/testing/ExecutionTrace.java
===================================================================
--- labs/jbossrules/branches/temporal_rete/drools-compiler/src/main/java/org/drools/brms/client/modeldriven/testing/ExecutionTrace.java 2008-03-20 18:57:07 UTC (rev 19163)
+++ labs/jbossrules/branches/temporal_rete/drools-compiler/src/main/java/org/drools/brms/client/modeldriven/testing/ExecutionTrace.java 2008-03-20 19:32:10 UTC (rev 19164)
@@ -1,11 +1,6 @@
package org.drools.brms.client.modeldriven.testing;
-import java.io.Serializable;
-import java.util.ArrayList;
import java.util.Date;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
/**
* This contains lists of rules to include in the scenario (or exclude, as the case may be !).
@@ -36,4 +31,5 @@
public ExecutionTrace() {}
+
}
Modified: labs/jbossrules/branches/temporal_rete/drools-compiler/src/main/java/org/drools/brms/client/modeldriven/testing/FactData.java
===================================================================
--- labs/jbossrules/branches/temporal_rete/drools-compiler/src/main/java/org/drools/brms/client/modeldriven/testing/FactData.java 2008-03-20 18:57:07 UTC (rev 19163)
+++ labs/jbossrules/branches/temporal_rete/drools-compiler/src/main/java/org/drools/brms/client/modeldriven/testing/FactData.java 2008-03-20 19:32:10 UTC (rev 19164)
@@ -5,36 +5,37 @@
public class FactData implements Fixture {
- /**
- * The type (class)
- */
- public String type;
+ /**
+ * The type (class)
+ */
+ public String type;
- /**
- * The name of the "variable"
- */
- public String name;
+ /**
+ * The name of the "variable"
+ */
+ public String name;
- /**
- * @gwt.typeArgs <org.drools.brms.client.modeldriven.testing.FactData>
- */
- public List fieldData = new ArrayList();
+ /**
+ * @gwt.typeArgs <org.drools.brms.client.modeldriven.testing.FactData>
+ */
+ public List fieldData = new ArrayList();
- /**
- * If its a modify, obviously we are modifying existing data in working memory.
- */
- public boolean isModify;
+ /**
+ * If its a modify, obviously we are modifying existing data in working memory.
+ */
+ public boolean isModify;
- public FactData() {}
- public FactData(String type, String name, List fieldData, boolean modify) {
+ public FactData() {}
+ public FactData(String type, String name, List fieldData, boolean modify) {
- this.type = type;
- this.name = name;
- this.fieldData = fieldData;
- this.isModify = modify;
+ this.type = type;
+ this.name = name;
+ this.fieldData = fieldData;
+ this.isModify = modify;
- }
+ }
+
}
Modified: labs/jbossrules/branches/temporal_rete/drools-compiler/src/main/java/org/drools/brms/client/modeldriven/testing/FieldData.java
===================================================================
--- labs/jbossrules/branches/temporal_rete/drools-compiler/src/main/java/org/drools/brms/client/modeldriven/testing/FieldData.java 2008-03-20 18:57:07 UTC (rev 19163)
+++ labs/jbossrules/branches/temporal_rete/drools-compiler/src/main/java/org/drools/brms/client/modeldriven/testing/FieldData.java 2008-03-20 19:32:10 UTC (rev 19164)
@@ -4,21 +4,22 @@
public class FieldData implements PortableObject {
- /** the name of the field */
- public String name;
+ /** the name of the field */
+ public String name;
- /** The value of the field to be set to.
- * This will either be a literal value (which will be coerced by MVEL).
- * Or if it starts with an "=" then it is an EL that will be evaluated to yield a value.
- */
- public String value;
+ /** The value of the field to be set to.
+ * This will either be a literal value (which will be coerced by MVEL).
+ * Or if it starts with an "=" then it is an EL that will be evaluated to yield a value.
+ */
+ public String value;
- public FieldData() {}
- public FieldData(String name, String value) {
- this.name = name;
- this.value = value;
- }
+ public FieldData() {}
+ public FieldData(String name, String value) {
+ this.name = name;
+ this.value = value;
+ }
+
}
Modified: labs/jbossrules/branches/temporal_rete/drools-compiler/src/main/java/org/drools/brms/client/modeldriven/testing/RetractFact.java
===================================================================
--- labs/jbossrules/branches/temporal_rete/drools-compiler/src/main/java/org/drools/brms/client/modeldriven/testing/RetractFact.java 2008-03-20 18:57:07 UTC (rev 19163)
+++ labs/jbossrules/branches/temporal_rete/drools-compiler/src/main/java/org/drools/brms/client/modeldriven/testing/RetractFact.java 2008-03-20 19:32:10 UTC (rev 19164)
@@ -1,5 +1,6 @@
package org.drools.brms.client.modeldriven.testing;
+
/**
* Retract a named fact.
* @author Michael Neale
@@ -7,11 +8,12 @@
*/
public class RetractFact implements Fixture {
- public RetractFact() {}
- public RetractFact(String s) {
- this.name = s;
- }
+ public RetractFact() {}
+ public RetractFact(String s) {
+ this.name = s;
+ }
- public String name;
+ public String name;
+
}
Modified: labs/jbossrules/branches/temporal_rete/drools-compiler/src/main/java/org/drools/brms/client/modeldriven/testing/Scenario.java
===================================================================
--- labs/jbossrules/branches/temporal_rete/drools-compiler/src/main/java/org/drools/brms/client/modeldriven/testing/Scenario.java 2008-03-20 18:57:07 UTC (rev 19163)
+++ labs/jbossrules/branches/temporal_rete/drools-compiler/src/main/java/org/drools/brms/client/modeldriven/testing/Scenario.java 2008-03-20 19:32:10 UTC (rev 19164)
@@ -1,6 +1,5 @@
package org.drools.brms.client.modeldriven.testing;
-import java.io.Serializable;
import java.util.ArrayList;
import java.util.Date;
import java.util.HashMap;
Modified: labs/jbossrules/branches/temporal_rete/drools-compiler/src/main/java/org/drools/brms/client/modeldriven/testing/VerifyFact.java
===================================================================
--- labs/jbossrules/branches/temporal_rete/drools-compiler/src/main/java/org/drools/brms/client/modeldriven/testing/VerifyFact.java 2008-03-20 18:57:07 UTC (rev 19163)
+++ labs/jbossrules/branches/temporal_rete/drools-compiler/src/main/java/org/drools/brms/client/modeldriven/testing/VerifyFact.java 2008-03-20 19:32:10 UTC (rev 19164)
@@ -10,29 +10,29 @@
*/
public class VerifyFact implements Expectation {
- /**
- * @gwt.typeArgs <org.drools.brms.client.modeldriven.testing.VerifyField>
- */
- public List fieldValues = new ArrayList();
- public String name;
- public String description;
+ /**
+ * @gwt.typeArgs <org.drools.brms.client.modeldriven.testing.VerifyField>
+ */
+ public List fieldValues = new ArrayList();
+ public String name;
+ public String description;
- public VerifyFact() {}
- public VerifyFact(String factName, List fieldValues) {
- this.name = factName;
- this.fieldValues = fieldValues;
- }
+ public VerifyFact() {}
+ public VerifyFact(String factName, List fieldValues) {
+ this.name = factName;
+ this.fieldValues = fieldValues;
+ }
- public boolean wasSuccessful() {
- for (int i = 0; i < fieldValues.size(); i++) {
- VerifyField vf = (VerifyField) fieldValues.get(i);
- if (! vf.successResult.booleanValue()) {
- return false;
- }
- }
- return true;
- }
+ public boolean wasSuccessful() {
+ for (int i = 0; i < fieldValues.size(); i++) {
+ VerifyField vf = (VerifyField) fieldValues.get(i);
+ if (! vf.successResult.booleanValue()) {
+ return false;
+ }
+ }
+ return true;
+ }
}
Modified: labs/jbossrules/branches/temporal_rete/drools-compiler/src/main/java/org/drools/brms/client/modeldriven/testing/VerifyField.java
===================================================================
--- labs/jbossrules/branches/temporal_rete/drools-compiler/src/main/java/org/drools/brms/client/modeldriven/testing/VerifyField.java 2008-03-20 18:57:07 UTC (rev 19163)
+++ labs/jbossrules/branches/temporal_rete/drools-compiler/src/main/java/org/drools/brms/client/modeldriven/testing/VerifyField.java 2008-03-20 19:32:10 UTC (rev 19164)
@@ -4,29 +4,28 @@
public class VerifyField implements PortableObject {
- public String fieldName;
- public String expected;
+ public String fieldName;
+ public String expected;
- public String actualResult;
- public Boolean successResult;
+ public String actualResult;
+ public Boolean successResult;
- /**
- * This is a natural language explanation of the outcome for reporting purposes.
- */
- public String explanation;
+ /**
+ * This is a natural language explanation of the outcome for reporting purposes.
+ */
+ public String explanation;
- /**
- * Operator is generally "==" or "!=" - an MVEL operator.
- */
- public String operator = "==";
+ /**
+ * Operator is generally "==" or "!=" - an MVEL operator.
+ */
+ public String operator = "==";
- public VerifyField() {}
+ public VerifyField() {}
- public VerifyField(String fieldName, String expected, String operator) {
- this.fieldName = fieldName;
- this.expected = expected;
- this.operator = operator;
- }
+ public VerifyField(String fieldName, String expected, String operator) {
+ this.fieldName = fieldName;
+ this.expected = expected;
+ this.operator = operator;
+ }
-
}
Modified: labs/jbossrules/branches/temporal_rete/drools-compiler/src/main/java/org/drools/brms/client/modeldriven/testing/VerifyRuleFired.java
===================================================================
--- labs/jbossrules/branches/temporal_rete/drools-compiler/src/main/java/org/drools/brms/client/modeldriven/testing/VerifyRuleFired.java 2008-03-20 18:57:07 UTC (rev 19163)
+++ labs/jbossrules/branches/temporal_rete/drools-compiler/src/main/java/org/drools/brms/client/modeldriven/testing/VerifyRuleFired.java 2008-03-20 19:32:10 UTC (rev 19164)
@@ -1,37 +1,37 @@
package org.drools.brms.client.modeldriven.testing;
+
public class VerifyRuleFired implements Expectation {
- public String ruleName;
- public Integer expectedCount;
+ public String ruleName;
+ public Integer expectedCount;
- /**
- * This is a natural language explanation of this verification.
- * For reporting purposes.
- */
- public String explanation;
+ /**
+ * This is a natural language explanation of this verification.
+ * For reporting purposes.
+ */
+ public String explanation;
- /**
- * If this is true, then we expect it to fire at least once.
- * False means it should not fire at all (this is an alternative
- * to specifying an expected count).
- */
- public Boolean expectedFire;
+ /**
+ * If this is true, then we expect it to fire at least once.
+ * False means it should not fire at all (this is an alternative
+ * to specifying an expected count).
+ */
+ public Boolean expectedFire;
+ public Boolean successResult;
+ public Integer actualResult;
- public VerifyRuleFired() {}
- public VerifyRuleFired(String ruleName, Integer expectedCount, Boolean expectedFire) {
- this.ruleName = ruleName;
- this.expectedCount = expectedCount;
- this.expectedFire = expectedFire;
- }
+ public VerifyRuleFired() {}
+ public VerifyRuleFired(String ruleName, Integer expectedCount, Boolean expectedFire) {
+ this.ruleName = ruleName;
+ this.expectedCount = expectedCount;
+ this.expectedFire = expectedFire;
+ }
- public Boolean successResult;
- public Integer actualResult;
+ public boolean wasSuccessful() {
+ return successResult.booleanValue();
+ }
- public boolean wasSuccessful() {
- return successResult.booleanValue();
- }
-
}
Modified: labs/jbossrules/branches/temporal_rete/drools-compiler/src/main/java/org/drools/brms/server/rules/SuggestionCompletionLoader.java
===================================================================
--- labs/jbossrules/branches/temporal_rete/drools-compiler/src/main/java/org/drools/brms/server/rules/SuggestionCompletionLoader.java 2008-03-20 18:57:07 UTC (rev 19163)
+++ labs/jbossrules/branches/temporal_rete/drools-compiler/src/main/java/org/drools/brms/server/rules/SuggestionCompletionLoader.java 2008-03-20 19:32:10 UTC (rev 19164)
@@ -6,7 +6,6 @@
import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;
-import java.util.Date;
import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
Modified: labs/jbossrules/branches/temporal_rete/drools-compiler/src/main/java/org/drools/compiler/ActionError.java
===================================================================
--- labs/jbossrules/branches/temporal_rete/drools-compiler/src/main/java/org/drools/compiler/ActionError.java 2008-03-20 18:57:07 UTC (rev 19163)
+++ labs/jbossrules/branches/temporal_rete/drools-compiler/src/main/java/org/drools/compiler/ActionError.java 2008-03-20 19:32:10 UTC (rev 19164)
@@ -18,7 +18,6 @@
import org.drools.commons.jci.problems.CompilationProblem;
import org.drools.lang.descr.BaseDescr;
-import org.drools.rule.Rule;
public class ActionError extends DroolsError {
private BaseDescr descr;
Modified: labs/jbossrules/branches/temporal_rete/drools-compiler/src/main/java/org/drools/compiler/DescrBuildError.java
===================================================================
--- labs/jbossrules/branches/temporal_rete/drools-compiler/src/main/java/org/drools/compiler/DescrBuildError.java 2008-03-20 18:57:07 UTC (rev 19163)
+++ labs/jbossrules/branches/temporal_rete/drools-compiler/src/main/java/org/drools/compiler/DescrBuildError.java 2008-03-20 19:32:10 UTC (rev 19164)
@@ -18,7 +18,6 @@
import org.drools.commons.jci.problems.CompilationProblem;
import org.drools.lang.descr.BaseDescr;
-import org.drools.rule.Rule;
public class DescrBuildError extends DroolsError {
private BaseDescr parentDescr;
Modified: labs/jbossrules/branches/temporal_rete/drools-compiler/src/main/java/org/drools/compiler/RuleFlowLoadError.java
===================================================================
--- labs/jbossrules/branches/temporal_rete/drools-compiler/src/main/java/org/drools/compiler/RuleFlowLoadError.java 2008-03-20 18:57:07 UTC (rev 19163)
+++ labs/jbossrules/branches/temporal_rete/drools-compiler/src/main/java/org/drools/compiler/RuleFlowLoadError.java 2008-03-20 19:32:10 UTC (rev 19164)
@@ -1,7 +1,5 @@
package org.drools.compiler;
-import java.io.PrintStream;
-import java.io.StringWriter;
/**
* This is used for reporting errors with loading a ruleflow.
Modified: labs/jbossrules/branches/temporal_rete/drools-compiler/src/main/java/org/drools/lang/DRLLexer.java
===================================================================
--- labs/jbossrules/branches/temporal_rete/drools-compiler/src/main/java/org/drools/lang/DRLLexer.java 2008-03-20 18:57:07 UTC (rev 19163)
+++ labs/jbossrules/branches/temporal_rete/drools-compiler/src/main/java/org/drools/lang/DRLLexer.java 2008-03-20 19:32:10 UTC (rev 19164)
@@ -3,12 +3,16 @@
package org.drools.lang;
-import org.antlr.runtime.*;
-import java.util.Stack;
-import java.util.List;
-import java.util.ArrayList;
-import java.util.Map;
import java.util.HashMap;
+
+import org.antlr.runtime.BaseRecognizer;
+import org.antlr.runtime.CharStream;
+import org.antlr.runtime.DFA;
+import org.antlr.runtime.EarlyExitException;
+import org.antlr.runtime.Lexer;
+import org.antlr.runtime.MismatchedSetException;
+import org.antlr.runtime.NoViableAltException;
+import org.antlr.runtime.RecognitionException;
public class DRLLexer extends Lexer {
public static final int ACCUMULATE=46;
public static final int PACKAGE=4;
Modified: labs/jbossrules/branches/temporal_rete/drools-compiler/src/main/java/org/drools/lang/DRLParser.java
===================================================================
--- labs/jbossrules/branches/temporal_rete/drools-compiler/src/main/java/org/drools/lang/DRLParser.java 2008-03-20 18:57:07 UTC (rev 19163)
+++ labs/jbossrules/branches/temporal_rete/drools-compiler/src/main/java/org/drools/lang/DRLParser.java 2008-03-20 19:32:10 UTC (rev 19164)
@@ -1,20 +1,68 @@
// $ANTLR 3.0.1 /home/etirelli/workspace/jboss/jbossrules/drools-compiler/src/main/resources/org/drools/lang/DRL.g 2008-03-10 18:35:53
package org.drools.lang;
- import java.util.List;
import java.util.ArrayList;
- import java.util.Iterator;
- import java.util.HashMap;
- import java.util.StringTokenizer;
- import org.drools.lang.descr.*;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.List;
-
-import org.antlr.runtime.*;
-import java.util.Stack;
-import java.util.List;
-import java.util.ArrayList;
-import java.util.Map;
-import java.util.HashMap;
+import org.antlr.runtime.BaseRecognizer;
+import org.antlr.runtime.BitSet;
+import org.antlr.runtime.CommonToken;
+import org.antlr.runtime.DFA;
+import org.antlr.runtime.EarlyExitException;
+import org.antlr.runtime.FailedPredicateException;
+import org.antlr.runtime.IntStream;
+import org.antlr.runtime.MismatchedNotSetException;
+import org.antlr.runtime.MismatchedSetException;
+import org.antlr.runtime.MismatchedTokenException;
+import org.antlr.runtime.MismatchedTreeNodeException;
+import org.antlr.runtime.NoViableAltException;
+import org.antlr.runtime.Parser;
+import org.antlr.runtime.ParserRuleReturnScope;
+import org.antlr.runtime.RecognitionException;
+import org.antlr.runtime.Token;
+import org.antlr.runtime.TokenStream;
+import org.drools.lang.descr.AccessorDescr;
+import org.drools.lang.descr.AccumulateDescr;
+import org.drools.lang.descr.AndDescr;
+import org.drools.lang.descr.AttributeDescr;
+import org.drools.lang.descr.BaseDescr;
+import org.drools.lang.descr.CollectDescr;
+import org.drools.lang.descr.ConditionalElementDescr;
+import org.drools.lang.descr.DeclarativeInvokerDescr;
+import org.drools.lang.descr.DescrFactory;
+import org.drools.lang.descr.EntryPointDescr;
+import org.drools.lang.descr.EvalDescr;
+import org.drools.lang.descr.ExistsDescr;
+import org.drools.lang.descr.FactTemplateDescr;
+import org.drools.lang.descr.FieldAccessDescr;
+import org.drools.lang.descr.FieldBindingDescr;
+import org.drools.lang.descr.FieldConstraintDescr;
+import org.drools.lang.descr.FieldTemplateDescr;
+import org.drools.lang.descr.ForallDescr;
+import org.drools.lang.descr.FromDescr;
+import org.drools.lang.descr.FunctionCallDescr;
+import org.drools.lang.descr.FunctionDescr;
+import org.drools.lang.descr.FunctionImportDescr;
+import org.drools.lang.descr.GlobalDescr;
+import org.drools.lang.descr.ImportDescr;
+import org.drools.lang.descr.LiteralRestrictionDescr;
+import org.drools.lang.descr.MethodAccessDescr;
+import org.drools.lang.descr.NotDescr;
+import org.drools.lang.descr.OrDescr;
+import org.drools.lang.descr.PackageDescr;
+import org.drools.lang.descr.PatternDescr;
+import org.drools.lang.descr.PatternSourceDescr;
+import org.drools.lang.descr.PredicateDescr;
+import org.drools.lang.descr.QualifiedIdentifierRestrictionDescr;
+import org.drools.lang.descr.QueryDescr;
+import org.drools.lang.descr.RestrictionConnectiveDescr;
+import org.drools.lang.descr.RestrictionDescr;
+import org.drools.lang.descr.ReturnValueRestrictionDescr;
+import org.drools.lang.descr.RuleDescr;
+import org.drools.lang.descr.TypeDeclarationDescr;
+import org.drools.lang.descr.VariableRestrictionDescr;
public class DRLParser extends Parser {
public static final String[] tokenNames = new String[] {
"<invalid>", "<EOR>", "<DOWN>", "<UP>", "PACKAGE", "IMPORT", "FUNCTION", "ID", "DOT", "GLOBAL", "LEFT_PAREN", "COMMA", "RIGHT_PAREN", "DECLARE", "LEFT_CURLY", "RIGHT_CURLY", "STRING", "QUERY", "END", "TEMPLATE", "RULE", "WHEN", "ATTRIBUTES", "DATE_EFFECTIVE", "DATE_EXPIRES", "ENABLED", "BOOL", "SALIENCE", "INT", "NO_LOOP", "AUTO_FOCUS", "ACTIVATION_GROUP", "RULEFLOW_GROUP", "AGENDA_GROUP", "DURATION", "DIALECT", "LOCK_ON_ACTIVE", "OR", "DOUBLE_PIPE", "AND", "DOUBLE_AMPER", "FROM", "EXISTS", "NOT", "EVAL", "FORALL", "ACCUMULATE", "INIT", "ACTION", "REVERSE", "RESULT", "COLLECT", "ENTRY_POINT", "CONTAINS", "EXCLUDES", "MATCHES", "SOUNDSLIKE", "MEMBEROF", "TILDE", "IN", "FLOAT", "NULL", "LEFT_SQUARE", "RIGHT_SQUARE", "THEN", "EVENT", "EOL", "WS", "EscapeSequence", "HexDigit", "UnicodeEscape", "OctalEscape", "SH_STYLE_SINGLE_LINE_COMMENT", "C_STYLE_SINGLE_LINE_COMMENT", "MULTI_LINE_COMMENT", "MISC", "';'", "'.*'", "':'", "'->'", "'=='", "'>'", "'>='", "'<'", "'<='", "'!!
='"
Modified: labs/jbossrules/branches/temporal_rete/drools-compiler/src/main/java/org/drools/lang/DrlDumper.java
===================================================================
--- labs/jbossrules/branches/temporal_rete/drools-compiler/src/main/java/org/drools/lang/DrlDumper.java 2008-03-20 18:57:07 UTC (rev 19163)
+++ labs/jbossrules/branches/temporal_rete/drools-compiler/src/main/java/org/drools/lang/DrlDumper.java 2008-03-20 19:32:10 UTC (rev 19164)
@@ -16,11 +16,9 @@
* limitations under the License.
*/
-import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
-import java.util.Map;
import java.util.Set;
import org.drools.lang.descr.AccumulateDescr;
Modified: labs/jbossrules/branches/temporal_rete/drools-compiler/src/main/java/org/drools/lang/MVELDumper.java
===================================================================
--- labs/jbossrules/branches/temporal_rete/drools-compiler/src/main/java/org/drools/lang/MVELDumper.java 2008-03-20 18:57:07 UTC (rev 19163)
+++ labs/jbossrules/branches/temporal_rete/drools-compiler/src/main/java/org/drools/lang/MVELDumper.java 2008-03-20 19:32:10 UTC (rev 19164)
@@ -37,12 +37,18 @@
public class MVELDumper extends ReflectiveVisitor {
private StringBuffer mvelDump;
+ private boolean isDateField;
private static final String eol = System.getProperty( "line.separator" );
private String template;
private String fieldName;
public String dump(FieldConstraintDescr fieldConstr) {
+ return this.dump( fieldConstr, false );
+ }
+
+ public String dump(FieldConstraintDescr fieldConstr, boolean isDateField ) {
mvelDump = new StringBuffer();
+ this.isDateField = isDateField;
this.visit( fieldConstr );
return mvelDump.toString();
}
@@ -74,6 +80,9 @@
}
} else if( descr.getType() == LiteralRestrictionDescr.TYPE_STRING ) {
text = "\"" + text + "\"";
+ if( this.isDateField ) {
+ text = "org.drools.util.DateUtils.parseDate( "+text+" )";
+ }
}
this.template = processRestriction( descr.getEvaluator(), descr.isNegated(), text );
}
Modified: labs/jbossrules/branches/temporal_rete/drools-compiler/src/main/java/org/drools/lang/descr/AccumulateDescr.java
===================================================================
--- labs/jbossrules/branches/temporal_rete/drools-compiler/src/main/java/org/drools/lang/descr/AccumulateDescr.java 2008-03-20 18:57:07 UTC (rev 19163)
+++ labs/jbossrules/branches/temporal_rete/drools-compiler/src/main/java/org/drools/lang/descr/AccumulateDescr.java 2008-03-20 19:32:10 UTC (rev 19164)
@@ -1,12 +1,12 @@
/*
* Copyright 2005 JBoss Inc
- *
+ *
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -18,6 +18,9 @@
import java.util.Collections;
import java.util.List;
+import java.io.ObjectOutput;
+import java.io.IOException;
+import java.io.ObjectInput;
/**
* A descr class for accumulate node
@@ -40,6 +43,34 @@
private boolean externalFunction = false;
private String functionIdentifier;
private String expression;
+
+ public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
+ super.readExternal(in);
+ input = (BaseDescr)in.readObject();
+ initCode = (String)in.readObject();
+ actionCode = (String)in.readObject();
+ reverseCode = (String)in.readObject();
+ resultCode = (String)in.readObject();
+ declarations = (String[])in.readObject();
+ className = (String)in.readObject();
+ externalFunction = in.readBoolean();
+ functionIdentifier = (String)in.readObject();
+ expression = (String)in.readObject();
+ }
+
+ public void writeExternal(ObjectOutput out) throws IOException {
+ super.writeExternal(out);
+ out.writeObject(input);
+ out.writeObject(initCode);
+ out.writeObject(actionCode);
+ out.writeObject(reverseCode);
+ out.writeObject(resultCode);
+ out.writeObject(declarations);
+ out.writeObject(className);
+ out.writeBoolean(externalFunction);
+ out.writeObject(functionIdentifier);
+ out.writeObject(expression);
+ }
public int getLine() {
return this.input.getLine();
@@ -92,8 +123,8 @@
public void addDescr(final BaseDescr patternDescr) {
throw new UnsupportedOperationException( "Can't add descriptors to " + this.getClass().getName() );
}
-
- public void insertBeforeLast(final Class clazz ,final BaseDescr baseDescr ) {
+
+ public void insertBeforeLast(final Class clazz ,final BaseDescr baseDescr ) {
throw new UnsupportedOperationException( "Can't add descriptors to " + this.getClass().getName() );
}
@@ -154,19 +185,19 @@
}
public void setInput(BaseDescr input) {
- this.input = input;
+ this.input = input;
}
-
+
public boolean isSinglePattern() {
- return this.input instanceof PatternDescr;
+ return this.input instanceof PatternDescr;
}
public boolean isMultiPattern() {
- return ! ( this.input instanceof PatternDescr );
+ return ! ( this.input instanceof PatternDescr );
}
public boolean hasValidInput() {
- // TODO: need to check that there are no OR occurences
+ // TODO: need to check that there are no OR occurences
return this.input != null;
}
}
Modified: labs/jbossrules/branches/temporal_rete/drools-compiler/src/main/java/org/drools/lang/descr/BaseDescr.java
===================================================================
--- labs/jbossrules/branches/temporal_rete/drools-compiler/src/main/java/org/drools/lang/descr/BaseDescr.java 2008-03-20 18:57:07 UTC (rev 19163)
+++ labs/jbossrules/branches/temporal_rete/drools-compiler/src/main/java/org/drools/lang/descr/BaseDescr.java 2008-03-20 19:32:10 UTC (rev 19164)
@@ -2,13 +2,13 @@
/*
* Copyright 2005 JBoss Inc
- *
+ *
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -16,14 +16,17 @@
* limitations under the License.
*/
-import java.io.Serializable;
+import java.io.Externalizable;
+import java.io.IOException;
+import java.io.ObjectInput;
+import java.io.ObjectOutput;
/**
* This is the super type for all pattern AST nodes.
*/
public class BaseDescr
implements
- Serializable {
+ Externalizable {
private static final long serialVersionUID = 400L;
private int startCharacter = -1;
@@ -34,6 +37,26 @@
private int endColumn = -1;
private String text = "";
+ public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
+ startCharacter = in.readInt();
+ endCharacter = in.readInt();
+ line = in.readInt();
+ column = in.readInt();
+ endLine = in.readInt();
+ endColumn = in.readInt();
+ text = (String)in.readObject();
+ }
+
+ public void writeExternal(ObjectOutput out) throws IOException {
+ out.writeInt(startCharacter);
+ out.writeInt(endCharacter);
+ out.writeInt(line);
+ out.writeInt(column);
+ out.writeInt(endLine);
+ out.writeInt(endColumn);
+ out.writeObject(text);
+ }
+
public String getText() {
return text;
}
Modified: labs/jbossrules/branches/temporal_rete/drools-compiler/src/main/java/org/drools/lang/descr/PackageDescr.java
===================================================================
--- labs/jbossrules/branches/temporal_rete/drools-compiler/src/main/java/org/drools/lang/descr/PackageDescr.java 2008-03-20 18:57:07 UTC (rev 19163)
+++ labs/jbossrules/branches/temporal_rete/drools-compiler/src/main/java/org/drools/lang/descr/PackageDescr.java 2008-03-20 19:32:10 UTC (rev 19164)
@@ -2,13 +2,13 @@
/*
* Copyright 2005 JBoss Inc
- *
+ *
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -20,14 +20,17 @@
import java.util.Collections;
import java.util.Iterator;
import java.util.List;
+import java.io.ObjectInput;
+import java.io.IOException;
+import java.io.ObjectOutput;
public class PackageDescr extends BaseDescr {
/**
- *
+ *
*/
private static final long serialVersionUID = 400L;
- private final String name;
- private final String documentation;
+ private String name;
+ private String documentation;
private List imports = Collections.EMPTY_LIST;
private List functionImports = Collections.EMPTY_LIST;
@@ -38,6 +41,9 @@
private List rules = Collections.EMPTY_LIST;
private List<TypeDeclarationDescr> typeDeclarations = Collections.emptyList();
+ public PackageDescr() {
+ }
+
public PackageDescr(final String name) {
this( name,
"" );
@@ -49,6 +55,32 @@
this.documentation = documentation;
}
+ public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
+ super.readExternal(in);
+ name = (String)in.readObject();
+ documentation = (String)in.readObject();
+ imports = (List)in.readObject();
+ functionImports = (List)in.readObject();
+ attributes = (List)in.readObject();
+ globals = (List)in.readObject();
+ factTemplates = (List)in.readObject();
+ functions = (List)in.readObject();
+ rules = (List)in.readObject();
+ }
+
+ public void writeExternal(ObjectOutput out) throws IOException {
+ super.writeExternal(out);
+ out.writeObject(name);
+ out.writeObject(documentation);
+ out.writeObject(imports);
+ out.writeObject(functionImports);
+ out.writeObject(attributes);
+ out.writeObject(globals);
+ out.writeObject(factTemplates);
+ out.writeObject(functions);
+ out.writeObject(rules);
+ }
+
public String getName() {
return this.name;
}
@@ -139,7 +171,7 @@
}
if (!overridden) {
rule.addAttribute( at );
- }
+ }
}
this.rules.add( rule );
}
Modified: labs/jbossrules/branches/temporal_rete/drools-compiler/src/main/java/org/drools/lang/descr/RuleDescr.java
===================================================================
--- labs/jbossrules/branches/temporal_rete/drools-compiler/src/main/java/org/drools/lang/descr/RuleDescr.java 2008-03-20 18:57:07 UTC (rev 19163)
+++ labs/jbossrules/branches/temporal_rete/drools-compiler/src/main/java/org/drools/lang/descr/RuleDescr.java 2008-03-20 19:32:10 UTC (rev 19164)
@@ -16,11 +16,13 @@
* limitations under the License.
*/
+import java.io.IOException;
+import java.io.ObjectInput;
+import java.io.ObjectOutput;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
-import org.drools.compiler.Dialect;
import org.drools.rule.Dialectable;
public class RuleDescr extends BaseDescr implements Dialectable {
@@ -41,6 +43,9 @@
private String className;
+ public RuleDescr() {
+ }
+
public RuleDescr(final String name) {
this( name,
"" );
@@ -53,14 +58,44 @@
this.documentation = documentation;
}
+ public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
+ super.readExternal(in);
+ name = (String)in.readObject();
+ dialect = (String)in.readObject();
+ documentation = (String)in.readObject();
+ consequence = in.readObject();
+ lhs = (AndDescr)in.readObject();
+ consequenceLine = in.readInt();
+ consequencePattern = in.readInt();
+ offset = in.readInt();
+ attributes = (List)in.readObject();
+ salience = (String)in.readObject();
+ className = (String)in.readObject();
+ }
+
+ public void writeExternal(ObjectOutput out) throws IOException {
+ super.writeExternal(out);
+ out.writeObject(name);
+ out.writeObject(dialect);
+ out.writeObject(documentation);
+ out.writeObject(consequence);
+ out.writeObject(lhs);
+ out.writeInt(consequenceLine);
+ out.writeInt(consequencePattern);
+ out.writeInt(offset);
+ out.writeObject(attributes);
+ out.writeObject(salience);
+ out.writeObject(className);
+ }
+
public String getName() {
return this.name;
}
-
+
public String getDialect() {
return this.dialect;
}
-
+
public void setDialect(String dialect) {
this.dialect = dialect;
}
@@ -94,12 +129,12 @@
if ( this.attributes == Collections.EMPTY_LIST ) {
this.attributes = new ArrayList();
}
-
+
if ( "dialect".equals( attribute.getName() ) ) {
// set dialect specifically as its to drive the build process.
this.dialect = attribute.getValue();
}
-
+
this.attributes.add( attribute );
}
}
Modified: labs/jbossrules/branches/temporal_rete/drools-compiler/src/main/java/org/drools/lang/dsl/DefaultExpander.java
===================================================================
--- labs/jbossrules/branches/temporal_rete/drools-compiler/src/main/java/org/drools/lang/dsl/DefaultExpander.java 2008-03-20 18:57:07 UTC (rev 19163)
+++ labs/jbossrules/branches/temporal_rete/drools-compiler/src/main/java/org/drools/lang/dsl/DefaultExpander.java 2008-03-20 19:32:10 UTC (rev 19164)
@@ -82,11 +82,11 @@
mapping );
for ( final Iterator it = mapping.getEntries().iterator(); it.hasNext(); ) {
final DSLMappingEntry entry = (DSLMappingEntry) it.next();
- if ( entry.getSection() == DSLMappingEntry.KEYWORD ) {
+ if ( DSLMappingEntry.KEYWORD.equals(entry.getSection()) ) {
this.keywords.add( entry );
- } else if ( entry.getSection() == DSLMappingEntry.CONDITION ) {
+ } else if ( DSLMappingEntry.CONDITION.equals(entry.getSection()) ) {
this.condition.add( entry );
- } else if ( entry.getSection() == DSLMappingEntry.CONSEQUENCE ) {
+ } else if ( DSLMappingEntry.CONSEQUENCE.equals(entry.getSection()) ) {
this.consequence.add( entry );
} else {
// if any, then add to them both condition and consequence
Modified: labs/jbossrules/branches/temporal_rete/drools-compiler/src/main/java/org/drools/rule/builder/PatternBuilder.java
===================================================================
--- labs/jbossrules/branches/temporal_rete/drools-compiler/src/main/java/org/drools/rule/builder/PatternBuilder.java 2008-03-20 18:57:07 UTC (rev 19163)
+++ labs/jbossrules/branches/temporal_rete/drools-compiler/src/main/java/org/drools/rule/builder/PatternBuilder.java 2008-03-20 19:32:10 UTC (rev 19164)
@@ -17,6 +17,7 @@
package org.drools.rule.builder;
import java.util.ArrayList;
+import java.util.Date;
import java.util.Iterator;
import java.util.List;
import java.util.Set;
@@ -26,8 +27,9 @@
import org.drools.base.FieldFactory;
import org.drools.base.ValueType;
import org.drools.base.evaluators.EvaluatorDefinition;
+import org.drools.base.field.ObjectFieldImpl;
+import org.drools.compiler.DescrBuildError;
import org.drools.compiler.Dialect;
-import org.drools.compiler.DescrBuildError;
import org.drools.facttemplates.FactTemplate;
import org.drools.facttemplates.FactTemplateFieldExtractor;
import org.drools.facttemplates.FactTemplateObjectType;
@@ -72,6 +74,8 @@
import org.drools.spi.ObjectType;
import org.drools.spi.Restriction;
import org.drools.spi.Constraint.ConstraintType;
+import org.mvel.ParserContext;
+import org.mvel.compiler.ExpressionCompiler;
/**
* A builder for patterns
@@ -374,12 +378,15 @@
MVELDialect mvelDialect = (MVELDialect) context.getDialect( "mvel" );
boolean strictMode = mvelDialect.isStrictMode();
mvelDialect.setStrictMode( false );
-
context.setDialect( mvelDialect );
+ // analyze field type:
+ Class resultType = getFieldReturnType( pattern,
+ fieldConstraintDescr );
+
PredicateDescr predicateDescr = new PredicateDescr();
MVELDumper dumper = new MVELDumper();
- predicateDescr.setContent( dumper.dump( fieldConstraintDescr ) );
+ predicateDescr.setContent( dumper.dump( fieldConstraintDescr, Date.class.isAssignableFrom( resultType ) ) );
build( context,
pattern,
@@ -391,6 +398,23 @@
context.setDialect( dialect );
}
+ /**
+ * @param pattern
+ * @param fieldConstraintDescr
+ * @return
+ */
+ private Class getFieldReturnType(final Pattern pattern,
+ final FieldConstraintDescr fieldConstraintDescr) {
+ String dummyField = "__DUMMY__";
+ String dummyExpr = dummyField+"."+fieldConstraintDescr.getFieldName();
+ ExpressionCompiler compiler = new ExpressionCompiler( dummyExpr );
+ ParserContext mvelcontext = new ParserContext();
+ mvelcontext.addInput( dummyField, ((ClassObjectType) pattern.getObjectType()).getClassType() );
+ compiler.compile( mvelcontext );
+ Class resultType = compiler.getReturnType();
+ return resultType;
+ }
+
private Restriction createRestriction(final RuleBuildContext context,
final Pattern pattern,
final FieldConstraintDescr fieldConstraintDescr,
@@ -768,6 +792,11 @@
final Class staticClass = context.getDialect().getTypeResolver().resolveType( className );
field = FieldFactory.getFieldValue( staticClass.getField( fieldName ).get( null ),
extractor.getValueType() );
+ if( field.isObjectField() ) {
+ ((ObjectFieldImpl) field).setEnum( true );
+ ((ObjectFieldImpl) field).setEnumName( staticClass.getName() );
+ ((ObjectFieldImpl) field).setFieldName( fieldName );
+ }
} catch ( final ClassNotFoundException e ) {
// nothing to do, as it is not a class name with static field
} catch ( final Exception e ) {
@@ -861,7 +890,7 @@
final boolean reportError) {
FieldExtractor extractor = null;
- if ( objectType.getValueType() == ValueType.FACTTEMPLATE_TYPE ) {
+ if ( ValueType.FACTTEMPLATE_TYPE.equals(objectType.getValueType()) ) {
//@todo use extractor cache
final FactTemplate factTemplate = ((FactTemplateObjectType) objectType).getFactTemplate();
extractor = new FactTemplateFieldExtractor( factTemplate,
Modified: labs/jbossrules/branches/temporal_rete/drools-compiler/src/main/java/org/drools/rule/builder/ReturnValueEvaluatorBuilder.java
===================================================================
--- labs/jbossrules/branches/temporal_rete/drools-compiler/src/main/java/org/drools/rule/builder/ReturnValueEvaluatorBuilder.java 2008-03-20 18:57:07 UTC (rev 19163)
+++ labs/jbossrules/branches/temporal_rete/drools-compiler/src/main/java/org/drools/rule/builder/ReturnValueEvaluatorBuilder.java 2008-03-20 19:32:10 UTC (rev 19164)
@@ -1,8 +1,6 @@
package org.drools.rule.builder;
import org.drools.compiler.ReturnValueDescr;
-import org.drools.lang.descr.ActionDescr;
-import org.drools.workflow.core.node.ActionNode;
import org.drools.workflow.instance.impl.ReturnValueConstraintEvaluator;
public interface ReturnValueEvaluatorBuilder {
Modified: labs/jbossrules/branches/temporal_rete/drools-compiler/src/main/java/org/drools/rule/builder/RuleBuildContext.java
===================================================================
--- labs/jbossrules/branches/temporal_rete/drools-compiler/src/main/java/org/drools/rule/builder/RuleBuildContext.java 2008-03-20 18:57:07 UTC (rev 19163)
+++ labs/jbossrules/branches/temporal_rete/drools-compiler/src/main/java/org/drools/rule/builder/RuleBuildContext.java 2008-03-20 19:32:10 UTC (rev 19164)
@@ -16,9 +16,7 @@
package org.drools.rule.builder;
-import java.util.ArrayList;
import java.util.Calendar;
-import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
Modified: labs/jbossrules/branches/temporal_rete/drools-compiler/src/main/java/org/drools/rule/builder/dialect/java/AbstractJavaProcessBuilder.java
===================================================================
--- labs/jbossrules/branches/temporal_rete/drools-compiler/src/main/java/org/drools/rule/builder/dialect/java/AbstractJavaProcessBuilder.java 2008-03-20 18:57:07 UTC (rev 19163)
+++ labs/jbossrules/branches/temporal_rete/drools-compiler/src/main/java/org/drools/rule/builder/dialect/java/AbstractJavaProcessBuilder.java 2008-03-20 19:32:10 UTC (rev 19164)
@@ -7,10 +7,7 @@
import java.util.Map;
import org.drools.lang.descr.BaseDescr;
-import org.drools.rule.Declaration;
import org.drools.rule.builder.ProcessBuildContext;
-import org.drools.rule.builder.RuleBuildContext;
-import org.drools.rule.builder.dialect.mvel.MVELDialect;
import org.drools.util.StringUtils;
import org.mvel.MVEL;
import org.mvel.MVELTemplateRegistry;
Modified: labs/jbossrules/branches/temporal_rete/drools-compiler/src/main/java/org/drools/rule/builder/dialect/java/AbstractJavaRuleBuilder.java
===================================================================
--- labs/jbossrules/branches/temporal_rete/drools-compiler/src/main/java/org/drools/rule/builder/dialect/java/AbstractJavaRuleBuilder.java 2008-03-20 18:57:07 UTC (rev 19163)
+++ labs/jbossrules/branches/temporal_rete/drools-compiler/src/main/java/org/drools/rule/builder/dialect/java/AbstractJavaRuleBuilder.java 2008-03-20 19:32:10 UTC (rev 19164)
@@ -9,7 +9,6 @@
import org.drools.lang.descr.BaseDescr;
import org.drools.rule.Declaration;
import org.drools.rule.builder.RuleBuildContext;
-import org.drools.rule.builder.dialect.mvel.MVELDialect;
import org.drools.util.StringUtils;
import org.mvel.MVEL;
import org.mvel.MVELTemplateRegistry;
Modified: labs/jbossrules/branches/temporal_rete/drools-compiler/src/main/java/org/drools/rule/builder/dialect/java/JavaActionBuilder.java
===================================================================
--- labs/jbossrules/branches/temporal_rete/drools-compiler/src/main/java/org/drools/rule/builder/dialect/java/JavaActionBuilder.java 2008-03-20 18:57:07 UTC (rev 19163)
+++ labs/jbossrules/branches/temporal_rete/drools-compiler/src/main/java/org/drools/rule/builder/dialect/java/JavaActionBuilder.java 2008-03-20 19:32:10 UTC (rev 19164)
@@ -16,24 +16,16 @@
package org.drools.rule.builder.dialect.java;
-import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import java.util.Map;
import java.util.Set;
import org.drools.compiler.Dialect;
-import org.drools.compiler.DescrBuildError;
import org.drools.lang.descr.ActionDescr;
-import org.drools.lang.descr.RuleDescr;
-import org.drools.rule.Declaration;
import org.drools.rule.builder.ActionBuilder;
-import org.drools.rule.builder.ConsequenceBuilder;
import org.drools.rule.builder.PackageBuildContext;
import org.drools.rule.builder.ProcessBuildContext;
-import org.drools.rule.builder.RuleBuildContext;
-import org.drools.rule.builder.dialect.mvel.MVELDialect;
-import org.drools.spi.PatternExtractor;
import org.drools.workflow.core.node.ActionNode;
/**
Modified: labs/jbossrules/branches/temporal_rete/drools-compiler/src/main/java/org/drools/rule/builder/dialect/java/JavaConsequenceBuilder.java
===================================================================
--- labs/jbossrules/branches/temporal_rete/drools-compiler/src/main/java/org/drools/rule/builder/dialect/java/JavaConsequenceBuilder.java 2008-03-20 18:57:07 UTC (rev 19163)
+++ labs/jbossrules/branches/temporal_rete/drools-compiler/src/main/java/org/drools/rule/builder/dialect/java/JavaConsequenceBuilder.java 2008-03-20 19:32:10 UTC (rev 19164)
@@ -180,6 +180,7 @@
}
// adding modify expression
+ consequence.append( "{\n" );
consequence.append( ret.getName() );
consequence.append( " __obj__ = (" );
consequence.append( ret.getName() );
@@ -188,6 +189,7 @@
consequence.append( ";\n" );
// adding the modifyRetract call:
consequence.append( "modifyRetract( __obj__ );\n" );
+
// adding each of the expressions:
for ( Iterator exprIt = d.getExpressions().iterator(); exprIt.hasNext(); ) {
@@ -197,6 +199,7 @@
}
// adding the modifyInsert call:
consequence.append( "modifyInsert( __obj__ );" );
+ consequence.append( "}\n" );
}
consequence.append( originalCode.substring( lastAdded ) );
Modified: labs/jbossrules/branches/temporal_rete/drools-compiler/src/main/java/org/drools/rule/builder/dialect/java/JavaDialect.java
===================================================================
--- labs/jbossrules/branches/temporal_rete/drools-compiler/src/main/java/org/drools/rule/builder/dialect/java/JavaDialect.java 2008-03-20 18:57:07 UTC (rev 19163)
+++ labs/jbossrules/branches/temporal_rete/drools-compiler/src/main/java/org/drools/rule/builder/dialect/java/JavaDialect.java 2008-03-20 19:32:10 UTC (rev 19164)
@@ -12,7 +12,6 @@
import java.util.Map;
import java.util.Set;
-import org.drools.process.core.Process;
import org.drools.base.ClassFieldExtractorCache;
import org.drools.base.TypeResolver;
import org.drools.commons.jci.compilers.CompilationResult;
@@ -22,11 +21,13 @@
import org.drools.commons.jci.problems.CompilationProblem;
import org.drools.commons.jci.readers.MemoryResourceReader;
import org.drools.commons.jci.readers.ResourceReader;
+import org.drools.compiler.DescrBuildError;
import org.drools.compiler.Dialect;
import org.drools.compiler.PackageBuilder;
-import org.drools.compiler.DescrBuildError;
import org.drools.compiler.PackageBuilder.ErrorHandler;
import org.drools.compiler.PackageBuilder.FunctionErrorHandler;
+import org.drools.compiler.PackageBuilder.ProcessErrorHandler;
+import org.drools.compiler.PackageBuilder.ProcessInvokerErrorHandler;
import org.drools.compiler.PackageBuilder.RuleErrorHandler;
import org.drools.compiler.PackageBuilder.RuleInvokerErrorHandler;
import org.drools.lang.descr.AccumulateDescr;
@@ -45,7 +46,7 @@
import org.drools.lang.descr.ProcessDescr;
import org.drools.lang.descr.QueryDescr;
import org.drools.lang.descr.RuleDescr;
-import org.drools.rule.EntryPoint;
+import org.drools.process.core.Process;
import org.drools.rule.Function;
import org.drools.rule.JavaDialectData;
import org.drools.rule.LineMappings;
@@ -74,8 +75,6 @@
import org.drools.rule.builder.SalienceBuilder;
import org.drools.rule.builder.dialect.mvel.MVELFromBuilder;
import org.drools.rule.builder.dialect.mvel.MVELSalienceBuilder;
-import org.drools.compiler.PackageBuilder.ProcessInvokerErrorHandler;
-import org.drools.compiler.PackageBuilder.ProcessErrorHandler;
import org.drools.util.StringUtils;
public class JavaDialect
Modified: labs/jbossrules/branches/temporal_rete/drools-compiler/src/main/java/org/drools/rule/builder/dialect/java/JavaReturnValueEvaluatorBuilder.java
===================================================================
--- labs/jbossrules/branches/temporal_rete/drools-compiler/src/main/java/org/drools/rule/builder/dialect/java/JavaReturnValueEvaluatorBuilder.java 2008-03-20 18:57:07 UTC (rev 19163)
+++ labs/jbossrules/branches/temporal_rete/drools-compiler/src/main/java/org/drools/rule/builder/dialect/java/JavaReturnValueEvaluatorBuilder.java 2008-03-20 19:32:10 UTC (rev 19164)
@@ -16,27 +16,16 @@
package org.drools.rule.builder.dialect.java;
-import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import java.util.Map;
import java.util.Set;
import org.drools.compiler.Dialect;
-import org.drools.compiler.DescrBuildError;
import org.drools.compiler.ReturnValueDescr;
-import org.drools.lang.descr.ActionDescr;
-import org.drools.lang.descr.RuleDescr;
-import org.drools.rule.Declaration;
-import org.drools.rule.builder.ActionBuilder;
-import org.drools.rule.builder.ConsequenceBuilder;
import org.drools.rule.builder.PackageBuildContext;
import org.drools.rule.builder.ProcessBuildContext;
import org.drools.rule.builder.ReturnValueEvaluatorBuilder;
-import org.drools.rule.builder.RuleBuildContext;
-import org.drools.rule.builder.dialect.mvel.MVELDialect;
-import org.drools.spi.PatternExtractor;
-import org.drools.workflow.core.node.ActionNode;
import org.drools.workflow.instance.impl.ReturnValueConstraintEvaluator;
/**
Modified: labs/jbossrules/branches/temporal_rete/drools-compiler/src/main/java/org/drools/rule/builder/dialect/java/parser/JavaLexer.java
===================================================================
--- labs/jbossrules/branches/temporal_rete/drools-compiler/src/main/java/org/drools/rule/builder/dialect/java/parser/JavaLexer.java 2008-03-20 18:57:07 UTC (rev 19163)
+++ labs/jbossrules/branches/temporal_rete/drools-compiler/src/main/java/org/drools/rule/builder/dialect/java/parser/JavaLexer.java 2008-03-20 19:32:10 UTC (rev 19164)
@@ -3,10 +3,15 @@
package org.drools.rule.builder.dialect.java.parser;
-import org.antlr.runtime.*;
-import java.util.Stack;
-import java.util.List;
-import java.util.ArrayList;
+import org.antlr.runtime.BaseRecognizer;
+import org.antlr.runtime.CharStream;
+import org.antlr.runtime.CommonToken;
+import org.antlr.runtime.DFA;
+import org.antlr.runtime.EarlyExitException;
+import org.antlr.runtime.Lexer;
+import org.antlr.runtime.MismatchedSetException;
+import org.antlr.runtime.NoViableAltException;
+import org.antlr.runtime.RecognitionException;
public class JavaLexer extends Lexer {
public static final int T29=29;
Modified: labs/jbossrules/branches/temporal_rete/drools-compiler/src/main/java/org/drools/rule/builder/dialect/java/parser/JavaParser.java
===================================================================
--- labs/jbossrules/branches/temporal_rete/drools-compiler/src/main/java/org/drools/rule/builder/dialect/java/parser/JavaParser.java 2008-03-20 18:57:07 UTC (rev 19163)
+++ labs/jbossrules/branches/temporal_rete/drools-compiler/src/main/java/org/drools/rule/builder/dialect/java/parser/JavaParser.java 2008-03-20 19:32:10 UTC (rev 19164)
@@ -1,15 +1,26 @@
// $ANTLR 3.0.1 /home/etirelli/workspace/jboss/jbossrules/drools-compiler/src/main/resources/org/drools/semantics/java/parser/Java.g 2007-12-19 16:46:01
package org.drools.rule.builder.dialect.java.parser;
- import java.util.Iterator;
+ import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Stack;
-
-import org.antlr.runtime.*;
-import java.util.Stack;
-import java.util.List;
-import java.util.ArrayList;
-import java.util.Map;
-import java.util.HashMap;
+import org.antlr.runtime.BitSet;
+import org.antlr.runtime.CommonToken;
+import org.antlr.runtime.EarlyExitException;
+import org.antlr.runtime.FailedPredicateException;
+import org.antlr.runtime.MismatchedNotSetException;
+import org.antlr.runtime.MismatchedSetException;
+import org.antlr.runtime.MismatchedTokenException;
+import org.antlr.runtime.MismatchedTreeNodeException;
+import org.antlr.runtime.NoViableAltException;
+import org.antlr.runtime.Parser;
+import org.antlr.runtime.ParserRuleReturnScope;
+import org.antlr.runtime.RecognitionException;
+import org.antlr.runtime.Token;
+import org.antlr.runtime.TokenStream;
/** A Java 1.5 grammar for ANTLR v3 derived from the spec
*
* This is a very close representation of the spec; the changes
Modified: labs/jbossrules/branches/temporal_rete/drools-compiler/src/main/java/org/drools/rule/builder/dialect/mvel/MVELActionBuilder.java
===================================================================
--- labs/jbossrules/branches/temporal_rete/drools-compiler/src/main/java/org/drools/rule/builder/dialect/mvel/MVELActionBuilder.java 2008-03-20 18:57:07 UTC (rev 19163)
+++ labs/jbossrules/branches/temporal_rete/drools-compiler/src/main/java/org/drools/rule/builder/dialect/mvel/MVELActionBuilder.java 2008-03-20 19:32:10 UTC (rev 19164)
@@ -2,24 +2,17 @@
import java.io.Serializable;
import java.util.Collections;
-import java.util.HashMap;
-import java.util.Map;
import java.util.Set;
import org.drools.base.mvel.DroolsMVELFactory;
import org.drools.base.mvel.MVELAction;
-import org.drools.base.mvel.MVELConsequence;
-import org.drools.compiler.Dialect;
import org.drools.compiler.DescrBuildError;
+import org.drools.compiler.Dialect;
import org.drools.lang.descr.ActionDescr;
import org.drools.rule.MVELDialectData;
import org.drools.rule.builder.ActionBuilder;
-import org.drools.rule.builder.ConsequenceBuilder;
import org.drools.rule.builder.PackageBuildContext;
-import org.drools.rule.builder.RuleBuildContext;
import org.drools.workflow.core.node.ActionNode;
-import org.mvel.Macro;
-import org.mvel.MacroProcessor;
public class MVELActionBuilder
implements
Modified: labs/jbossrules/branches/temporal_rete/drools-compiler/src/main/java/org/drools/rule/builder/dialect/mvel/MVELConsequenceBuilder.java
===================================================================
--- labs/jbossrules/branches/temporal_rete/drools-compiler/src/main/java/org/drools/rule/builder/dialect/mvel/MVELConsequenceBuilder.java 2008-03-20 18:57:07 UTC (rev 19163)
+++ labs/jbossrules/branches/temporal_rete/drools-compiler/src/main/java/org/drools/rule/builder/dialect/mvel/MVELConsequenceBuilder.java 2008-03-20 19:32:10 UTC (rev 19164)
@@ -7,9 +7,8 @@
import org.drools.base.mvel.DroolsMVELFactory;
import org.drools.base.mvel.MVELConsequence;
-import org.drools.compiler.Dialect;
import org.drools.compiler.DescrBuildError;
-import org.drools.rule.MVELDialectData;
+import org.drools.compiler.Dialect;
import org.drools.rule.builder.ConsequenceBuilder;
import org.drools.rule.builder.RuleBuildContext;
import org.mvel.Macro;
Modified: labs/jbossrules/branches/temporal_rete/drools-compiler/src/main/java/org/drools/rule/builder/dialect/mvel/MVELDialect.java
===================================================================
--- labs/jbossrules/branches/temporal_rete/drools-compiler/src/main/java/org/drools/rule/builder/dialect/mvel/MVELDialect.java 2008-03-20 18:57:07 UTC (rev 19163)
+++ labs/jbossrules/branches/temporal_rete/drools-compiler/src/main/java/org/drools/rule/builder/dialect/mvel/MVELDialect.java 2008-03-20 19:32:10 UTC (rev 19164)
@@ -1,5 +1,9 @@
package org.drools.rule.builder.dialect.mvel;
+import java.io.Externalizable;
+import java.io.IOException;
+import java.io.ObjectInput;
+import java.io.ObjectOutput;
import java.io.Serializable;
import java.lang.reflect.Method;
import java.util.ArrayList;
@@ -36,7 +40,6 @@
import org.drools.lang.descr.QueryDescr;
import org.drools.lang.descr.RuleDescr;
import org.drools.rule.Declaration;
-import org.drools.rule.JavaDialectData;
import org.drools.rule.LineMappings;
import org.drools.rule.MVELDialectData;
import org.drools.rule.Package;
@@ -69,14 +72,13 @@
import org.mvel.compiler.AbstractParser;
import org.mvel.compiler.CompiledExpression;
import org.mvel.compiler.ExpressionCompiler;
-import org.mvel.debug.DebugTools;
import org.mvel.optimizers.OptimizerFactory;
import org.mvel.util.CompilerTools;
import org.mvel.util.ParseTools;
public class MVELDialect
implements
- Dialect {
+ Dialect, Externalizable {
public final static String ID = "mvel";
@@ -126,6 +128,34 @@
public MVELDialect() {
}
+ public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
+ interceptors = (Map)in.readObject();
+ results = (List)in.readObject();
+ src = (MemoryResourceReader)in.readObject();
+ pkg = (Package)in.readObject();
+ data = (MVELDialectData)in.readObject();
+ configuration = (MVELDialectConfiguration)in.readObject();
+ typeResolver = (TypeResolver)in.readObject();
+ classFieldExtractorCache = (ClassFieldExtractorCache)in.readObject();
+ analyzer = (MVELExprAnalyzer)in.readObject();
+ imports = (Map)in.readObject();
+ packageImports = (Map)in.readObject();
+ strictMode = in.readBoolean();
+ }
+
+ public void writeExternal(ObjectOutput out) throws IOException {
+ out.writeObject(interceptors);
+ out.writeObject(results);
+ out.writeObject(src);
+ out.writeObject(pkg);
+ out.writeObject(data);
+ out.writeObject(configuration);
+ out.writeObject(typeResolver);
+ out.writeObject(classFieldExtractorCache);
+ out.writeObject(analyzer);
+ out.writeObject(imports);
+ out.writeBoolean(strictMode);
+ }
public static void setLanguageLevel(int level) {
synchronized ( languageSet ) {
// this synchronisation is needed as setLanguageLevel is now thread safe
Modified: labs/jbossrules/branches/temporal_rete/drools-compiler/src/main/java/org/drools/rule/builder/dialect/mvel/MVELDialectConfiguration.java
===================================================================
--- labs/jbossrules/branches/temporal_rete/drools-compiler/src/main/java/org/drools/rule/builder/dialect/mvel/MVELDialectConfiguration.java 2008-03-20 18:57:07 UTC (rev 19163)
+++ labs/jbossrules/branches/temporal_rete/drools-compiler/src/main/java/org/drools/rule/builder/dialect/mvel/MVELDialectConfiguration.java 2008-03-20 19:32:10 UTC (rev 19164)
@@ -2,7 +2,6 @@
import org.drools.compiler.Dialect;
import org.drools.compiler.DialectConfiguration;
-import org.drools.compiler.PackageBuilder;
import org.drools.compiler.PackageBuilderConfiguration;
/**
Modified: labs/jbossrules/branches/temporal_rete/drools-compiler/src/main/java/org/drools/rule/builder/dialect/mvel/MVELEvalBuilder.java
===================================================================
--- labs/jbossrules/branches/temporal_rete/drools-compiler/src/main/java/org/drools/rule/builder/dialect/mvel/MVELEvalBuilder.java 2008-03-20 18:57:07 UTC (rev 19163)
+++ labs/jbossrules/branches/temporal_rete/drools-compiler/src/main/java/org/drools/rule/builder/dialect/mvel/MVELEvalBuilder.java 2008-03-20 19:32:10 UTC (rev 19164)
@@ -17,15 +17,13 @@
package org.drools.rule.builder.dialect.mvel;
import java.io.Serializable;
-import java.util.Iterator;
import java.util.List;
-import java.util.Map;
import java.util.Set;
import org.drools.base.mvel.DroolsMVELFactory;
import org.drools.base.mvel.MVELEvalExpression;
-import org.drools.compiler.Dialect;
import org.drools.compiler.DescrBuildError;
+import org.drools.compiler.Dialect;
import org.drools.lang.descr.BaseDescr;
import org.drools.lang.descr.EvalDescr;
import org.drools.rule.Declaration;
@@ -35,12 +33,6 @@
import org.drools.rule.RuleConditionElement;
import org.drools.rule.builder.RuleBuildContext;
import org.drools.rule.builder.RuleConditionBuilder;
-import org.drools.spi.DeclarationScopeResolver;
-import org.mvel.compiler.AbstractParser;
-import org.mvel.compiler.ExpressionCompiler;
-import org.mvel.MVEL;
-import org.mvel.ParserContext;
-import org.mvel.util.ParseTools;
/**
* @author etirelli
Modified: labs/jbossrules/branches/temporal_rete/drools-compiler/src/main/java/org/drools/rule/builder/dialect/mvel/MVELExprAnalyzer.java
===================================================================
--- labs/jbossrules/branches/temporal_rete/drools-compiler/src/main/java/org/drools/rule/builder/dialect/mvel/MVELExprAnalyzer.java 2008-03-20 18:57:07 UTC (rev 19163)
+++ labs/jbossrules/branches/temporal_rete/drools-compiler/src/main/java/org/drools/rule/builder/dialect/mvel/MVELExprAnalyzer.java 2008-03-20 19:32:10 UTC (rev 19164)
@@ -27,11 +27,8 @@
import org.antlr.runtime.RecognitionException;
import org.drools.rule.builder.PackageBuildContext;
-import org.drools.rule.builder.RuleBuildContext;
-import org.mvel.compiler.AbstractParser;
-import org.mvel.compiler.ExpressionCompiler;
import org.mvel.ParserContext;
-import org.mvel.integration.impl.MapVariableResolver;
+import org.mvel.compiler.ExpressionCompiler;
/**
* Expression analyzer.
Modified: labs/jbossrules/branches/temporal_rete/drools-compiler/src/main/java/org/drools/rule/builder/dialect/mvel/MVELFromBuilder.java
===================================================================
--- labs/jbossrules/branches/temporal_rete/drools-compiler/src/main/java/org/drools/rule/builder/dialect/mvel/MVELFromBuilder.java 2008-03-20 18:57:07 UTC (rev 19163)
+++ labs/jbossrules/branches/temporal_rete/drools-compiler/src/main/java/org/drools/rule/builder/dialect/mvel/MVELFromBuilder.java 2008-03-20 19:32:10 UTC (rev 19164)
@@ -21,8 +21,8 @@
import org.drools.base.dataproviders.MVELDataProvider;
import org.drools.base.mvel.DroolsMVELFactory;
-import org.drools.compiler.Dialect;
import org.drools.compiler.DescrBuildError;
+import org.drools.compiler.Dialect;
import org.drools.lang.descr.AccessorDescr;
import org.drools.lang.descr.BaseDescr;
import org.drools.lang.descr.FromDescr;
@@ -32,11 +32,6 @@
import org.drools.rule.builder.FromBuilder;
import org.drools.rule.builder.RuleBuildContext;
import org.drools.spi.DataProvider;
-import org.mvel.compiler.AbstractParser;
-import org.mvel.compiler.ExpressionCompiler;
-import org.mvel.MVEL;
-import org.mvel.ParserContext;
-import org.mvel.integration.impl.ClassImportResolverFactory;
/**
* A builder for "from" conditional element
Modified: labs/jbossrules/branches/temporal_rete/drools-compiler/src/main/java/org/drools/rule/builder/dialect/mvel/MVELPredicateBuilder.java
===================================================================
--- labs/jbossrules/branches/temporal_rete/drools-compiler/src/main/java/org/drools/rule/builder/dialect/mvel/MVELPredicateBuilder.java 2008-03-20 18:57:07 UTC (rev 19163)
+++ labs/jbossrules/branches/temporal_rete/drools-compiler/src/main/java/org/drools/rule/builder/dialect/mvel/MVELPredicateBuilder.java 2008-03-20 19:32:10 UTC (rev 19164)
@@ -24,18 +24,14 @@
import org.drools.base.mvel.DroolsMVELFactory;
import org.drools.base.mvel.MVELPredicateExpression;
-import org.drools.compiler.Dialect;
import org.drools.compiler.DescrBuildError;
+import org.drools.compiler.Dialect;
import org.drools.lang.descr.PredicateDescr;
import org.drools.rule.Declaration;
import org.drools.rule.MVELDialectData;
import org.drools.rule.PredicateConstraint;
import org.drools.rule.builder.PredicateBuilder;
import org.drools.rule.builder.RuleBuildContext;
-import org.mvel.compiler.AbstractParser;
-import org.mvel.compiler.ExpressionCompiler;
-import org.mvel.MVEL;
-import org.mvel.ParserContext;
/**
* @author etirelli
Modified: labs/jbossrules/branches/temporal_rete/drools-compiler/src/main/java/org/drools/rule/builder/dialect/mvel/MVELReturnValueBuilder.java
===================================================================
--- labs/jbossrules/branches/temporal_rete/drools-compiler/src/main/java/org/drools/rule/builder/dialect/mvel/MVELReturnValueBuilder.java 2008-03-20 18:57:07 UTC (rev 19163)
+++ labs/jbossrules/branches/temporal_rete/drools-compiler/src/main/java/org/drools/rule/builder/dialect/mvel/MVELReturnValueBuilder.java 2008-03-20 19:32:10 UTC (rev 19164)
@@ -1,12 +1,12 @@
/*
* Copyright 2006 JBoss Inc
- *
+ *
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -31,10 +31,6 @@
import org.drools.rule.ReturnValueRestriction;
import org.drools.rule.builder.ReturnValueBuilder;
import org.drools.rule.builder.RuleBuildContext;
-import org.mvel.compiler.AbstractParser;
-import org.mvel.compiler.ExpressionCompiler;
-import org.mvel.MVEL;
-import org.mvel.ParserContext;
/**
* @author etirelli
@@ -66,9 +62,9 @@
final DroolsMVELFactory factory = new DroolsMVELFactory( previousMap,
localMap,
context.getPkg().getGlobals() );
-
+
MVELDialectData data = (MVELDialectData) context.getPkg().getDialectDatas().getDialectData( "mvel" );
- factory.setNextFactory( data.getFunctionFactory() );
+ factory.setNextFactory( data.getFunctionFactory() );
Dialect.AnalysisResult analysis = context.getDialect().analyzeExpression( context,
returnValueRestrictionDescr,
Modified: labs/jbossrules/branches/temporal_rete/drools-compiler/src/main/java/org/drools/rule/builder/dialect/mvel/MVELReturnValueEvaluatorBuilder.java
===================================================================
--- labs/jbossrules/branches/temporal_rete/drools-compiler/src/main/java/org/drools/rule/builder/dialect/mvel/MVELReturnValueEvaluatorBuilder.java 2008-03-20 18:57:07 UTC (rev 19163)
+++ labs/jbossrules/branches/temporal_rete/drools-compiler/src/main/java/org/drools/rule/builder/dialect/mvel/MVELReturnValueEvaluatorBuilder.java 2008-03-20 19:32:10 UTC (rev 19164)
@@ -2,29 +2,17 @@
import java.io.Serializable;
import java.util.Collections;
-import java.util.HashMap;
-import java.util.Map;
import java.util.Set;
import org.drools.base.mvel.DroolsMVELFactory;
-import org.drools.base.mvel.MVELAction;
-import org.drools.base.mvel.MVELConsequence;
import org.drools.base.mvel.MVELReturnValueEvaluator;
-import org.drools.compiler.Dialect;
import org.drools.compiler.DescrBuildError;
+import org.drools.compiler.Dialect;
import org.drools.compiler.ReturnValueDescr;
-import org.drools.lang.descr.ActionDescr;
import org.drools.rule.MVELDialectData;
-import org.drools.rule.builder.ActionBuilder;
-import org.drools.rule.builder.ConsequenceBuilder;
import org.drools.rule.builder.PackageBuildContext;
import org.drools.rule.builder.ReturnValueEvaluatorBuilder;
-import org.drools.rule.builder.RuleBuildContext;
-import org.drools.spi.ReturnValueEvaluator;
-import org.drools.workflow.core.node.ActionNode;
import org.drools.workflow.instance.impl.ReturnValueConstraintEvaluator;
-import org.mvel.Macro;
-import org.mvel.MacroProcessor;
public class MVELReturnValueEvaluatorBuilder
implements
Modified: labs/jbossrules/branches/temporal_rete/drools-compiler/src/main/java/org/drools/rule/builder/dialect/mvel/MVELSalienceBuilder.java
===================================================================
--- labs/jbossrules/branches/temporal_rete/drools-compiler/src/main/java/org/drools/rule/builder/dialect/mvel/MVELSalienceBuilder.java 2008-03-20 18:57:07 UTC (rev 19163)
+++ labs/jbossrules/branches/temporal_rete/drools-compiler/src/main/java/org/drools/rule/builder/dialect/mvel/MVELSalienceBuilder.java 2008-03-20 19:32:10 UTC (rev 19164)
@@ -5,16 +5,11 @@
import org.drools.base.mvel.DroolsMVELFactory;
import org.drools.base.mvel.MVELSalienceExpression;
-import org.drools.compiler.Dialect;
import org.drools.compiler.DescrBuildError;
+import org.drools.compiler.Dialect;
import org.drools.rule.MVELDialectData;
import org.drools.rule.builder.RuleBuildContext;
import org.drools.rule.builder.SalienceBuilder;
-import org.mvel.compiler.AbstractParser;
-import org.mvel.compiler.ExpressionCompiler;
-import org.mvel.MVEL;
-import org.mvel.ParserContext;
-import org.mvel.integration.impl.ClassImportResolverFactory;
public class MVELSalienceBuilder
implements
Modified: labs/jbossrules/branches/temporal_rete/drools-compiler/src/main/java/org/drools/testframework/ScenarioRunner.java
===================================================================
--- labs/jbossrules/branches/temporal_rete/drools-compiler/src/main/java/org/drools/testframework/ScenarioRunner.java 2008-03-20 18:57:07 UTC (rev 19163)
+++ labs/jbossrules/branches/temporal_rete/drools-compiler/src/main/java/org/drools/testframework/ScenarioRunner.java 2008-03-20 19:32:10 UTC (rev 19164)
@@ -2,7 +2,6 @@
import static org.mvel.MVEL.eval;
-import java.util.Arrays;
import java.util.Calendar;
import java.util.Date;
import java.util.HashMap;
@@ -24,7 +23,6 @@
import org.drools.brms.client.modeldriven.testing.VerifyRuleFired;
import org.drools.common.InternalWorkingMemory;
import org.drools.rule.TimeMachine;
-import org.mvel.integration.impl.BaseVariableResolverFactory;
/**
* This actually runs the test scenarios.
Modified: labs/jbossrules/branches/temporal_rete/drools-compiler/src/main/java/org/drools/testframework/TestingEventListener.java
===================================================================
--- labs/jbossrules/branches/temporal_rete/drools-compiler/src/main/java/org/drools/testframework/TestingEventListener.java 2008-03-20 18:57:07 UTC (rev 19163)
+++ labs/jbossrules/branches/temporal_rete/drools-compiler/src/main/java/org/drools/testframework/TestingEventListener.java 2008-03-20 19:32:10 UTC (rev 19164)
@@ -1,11 +1,12 @@
package org.drools.testframework;
+import java.io.IOException;
+import java.io.ObjectInput;
+import java.io.ObjectOutput;
import java.util.HashMap;
import java.util.HashSet;
-import java.util.Iterator;
import java.util.Map;
-import org.drools.RuleBase;
import org.drools.WorkingMemory;
import org.drools.event.ActivationCancelledEvent;
import org.drools.event.ActivationCreatedEvent;
@@ -14,7 +15,6 @@
import org.drools.event.AgendaGroupPoppedEvent;
import org.drools.event.AgendaGroupPushedEvent;
import org.drools.event.BeforeActivationFiredEvent;
-import org.drools.rule.Package;
import org.drools.rule.Rule;
import org.drools.spi.Activation;
import org.drools.spi.AgendaFilter;
@@ -161,5 +161,12 @@
public void evaluate(KnowledgeHelper knowledgeHelper, WorkingMemory workingMemory) throws Exception {
}
+ public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
+
+ }
+
+ public void writeExternal(ObjectOutput out) throws IOException {
+
+ }
}
Modified: labs/jbossrules/branches/temporal_rete/drools-compiler/src/main/java/org/drools/xml/XmlPackageReader.java
===================================================================
--- labs/jbossrules/branches/temporal_rete/drools-compiler/src/main/java/org/drools/xml/XmlPackageReader.java 2008-03-20 18:57:07 UTC (rev 19163)
+++ labs/jbossrules/branches/temporal_rete/drools-compiler/src/main/java/org/drools/xml/XmlPackageReader.java 2008-03-20 19:32:10 UTC (rev 19164)
@@ -3,36 +3,10 @@
import java.io.IOException;
import java.io.InputStream;
import java.io.Reader;
-import java.util.HashMap;
-import java.util.Map;
import javax.xml.parsers.SAXParser;
import org.drools.lang.descr.PackageDescr;
-import org.drools.xml.rules.AccumulateHandler;
-import org.drools.xml.rules.AccumulateHelperHandler;
-import org.drools.xml.rules.AndHandler;
-import org.drools.xml.rules.CollectHandler;
-import org.drools.xml.rules.EvalHandler;
-import org.drools.xml.rules.ExistsHandler;
-import org.drools.xml.rules.ExpressionHandler;
-import org.drools.xml.rules.FieldBindingHandler;
-import org.drools.xml.rules.FieldConstraintHandler;
-import org.drools.xml.rules.ForallHandler;
-import org.drools.xml.rules.FromHandler;
-import org.drools.xml.rules.FunctionHandler;
-import org.drools.xml.rules.LiteralRestrictionHandler;
-import org.drools.xml.rules.NotHandler;
-import org.drools.xml.rules.OrHandler;
-import org.drools.xml.rules.PackageHandler;
-import org.drools.xml.rules.PatternHandler;
-import org.drools.xml.rules.PredicateHandler;
-import org.drools.xml.rules.QualifiedIdentifierRestrictionHandler;
-import org.drools.xml.rules.QueryHandler;
-import org.drools.xml.rules.RestrictionConnectiveHandler;
-import org.drools.xml.rules.ReturnValueRestrictionHandler;
-import org.drools.xml.rules.RuleHandler;
-import org.drools.xml.rules.VariableRestrictionsHandler;
import org.xml.sax.InputSource;
import org.xml.sax.SAXException;
Modified: labs/jbossrules/branches/temporal_rete/drools-compiler/src/main/java/org/drools/xml/XmlProcessReader.java
===================================================================
--- labs/jbossrules/branches/temporal_rete/drools-compiler/src/main/java/org/drools/xml/XmlProcessReader.java 2008-03-20 18:57:07 UTC (rev 19163)
+++ labs/jbossrules/branches/temporal_rete/drools-compiler/src/main/java/org/drools/xml/XmlProcessReader.java 2008-03-20 19:32:10 UTC (rev 19164)
@@ -3,35 +3,9 @@
import java.io.IOException;
import java.io.InputStream;
import java.io.Reader;
-import java.util.Set;
import javax.xml.parsers.SAXParser;
-import org.drools.lang.descr.PackageDescr;
-import org.drools.xml.rules.AccumulateHandler;
-import org.drools.xml.rules.AccumulateHelperHandler;
-import org.drools.xml.rules.AndHandler;
-import org.drools.xml.rules.CollectHandler;
-import org.drools.xml.rules.EvalHandler;
-import org.drools.xml.rules.ExistsHandler;
-import org.drools.xml.rules.ExpressionHandler;
-import org.drools.xml.rules.FieldBindingHandler;
-import org.drools.xml.rules.FieldConstraintHandler;
-import org.drools.xml.rules.ForallHandler;
-import org.drools.xml.rules.FromHandler;
-import org.drools.xml.rules.FunctionHandler;
-import org.drools.xml.rules.LiteralRestrictionHandler;
-import org.drools.xml.rules.NotHandler;
-import org.drools.xml.rules.OrHandler;
-import org.drools.xml.rules.PackageHandler;
-import org.drools.xml.rules.PatternHandler;
-import org.drools.xml.rules.PredicateHandler;
-import org.drools.xml.rules.QualifiedIdentifierRestrictionHandler;
-import org.drools.xml.rules.QueryHandler;
-import org.drools.xml.rules.RestrictionConnectiveHandler;
-import org.drools.xml.rules.ReturnValueRestrictionHandler;
-import org.drools.xml.rules.RuleHandler;
-import org.drools.xml.rules.VariableRestrictionsHandler;
import org.drools.process.core.Process;
import org.xml.sax.InputSource;
import org.xml.sax.SAXException;
Modified: labs/jbossrules/branches/temporal_rete/drools-compiler/src/main/java/org/drools/xml/rules/AccumulateHandler.java
===================================================================
--- labs/jbossrules/branches/temporal_rete/drools-compiler/src/main/java/org/drools/xml/rules/AccumulateHandler.java 2008-03-20 18:57:07 UTC (rev 19163)
+++ labs/jbossrules/branches/temporal_rete/drools-compiler/src/main/java/org/drools/xml/rules/AccumulateHandler.java 2008-03-20 19:32:10 UTC (rev 19164)
@@ -17,8 +17,6 @@
*/
import java.util.HashSet;
-import java.util.LinkedList;
-import java.util.ListIterator;
import org.drools.lang.descr.AccumulateDescr;
import org.drools.lang.descr.ConditionalElementDescr;
Modified: labs/jbossrules/branches/temporal_rete/drools-compiler/src/main/java/org/drools/xml/rules/AccumulateHelperHandler.java
===================================================================
--- labs/jbossrules/branches/temporal_rete/drools-compiler/src/main/java/org/drools/xml/rules/AccumulateHelperHandler.java 2008-03-20 18:57:07 UTC (rev 19163)
+++ labs/jbossrules/branches/temporal_rete/drools-compiler/src/main/java/org/drools/xml/rules/AccumulateHelperHandler.java 2008-03-20 19:32:10 UTC (rev 19164)
@@ -17,8 +17,6 @@
*/
import java.util.HashSet;
-import java.util.LinkedList;
-import java.util.ListIterator;
import org.drools.lang.descr.AccumulateDescr;
import org.drools.lang.descr.BaseDescr;
@@ -29,7 +27,6 @@
import org.drools.xml.Handler;
import org.xml.sax.Attributes;
import org.xml.sax.SAXException;
-import org.xml.sax.SAXParseException;
/**
* @author fernandomeyer
Modified: labs/jbossrules/branches/temporal_rete/drools-compiler/src/main/java/org/drools/xml/rules/AndHandler.java
===================================================================
--- labs/jbossrules/branches/temporal_rete/drools-compiler/src/main/java/org/drools/xml/rules/AndHandler.java 2008-03-20 18:57:07 UTC (rev 19163)
+++ labs/jbossrules/branches/temporal_rete/drools-compiler/src/main/java/org/drools/xml/rules/AndHandler.java 2008-03-20 19:32:10 UTC (rev 19164)
@@ -17,8 +17,6 @@
*/
import java.util.HashSet;
-import java.util.LinkedList;
-import java.util.ListIterator;
import org.drools.lang.descr.AccumulateDescr;
import org.drools.lang.descr.AndDescr;
Modified: labs/jbossrules/branches/temporal_rete/drools-compiler/src/main/java/org/drools/xml/rules/CollectHandler.java
===================================================================
--- labs/jbossrules/branches/temporal_rete/drools-compiler/src/main/java/org/drools/xml/rules/CollectHandler.java 2008-03-20 18:57:07 UTC (rev 19163)
+++ labs/jbossrules/branches/temporal_rete/drools-compiler/src/main/java/org/drools/xml/rules/CollectHandler.java 2008-03-20 19:32:10 UTC (rev 19164)
@@ -17,8 +17,6 @@
*/
import java.util.HashSet;
-import java.util.LinkedList;
-import java.util.ListIterator;
import org.drools.lang.descr.CollectDescr;
import org.drools.lang.descr.ConditionalElementDescr;
Modified: labs/jbossrules/branches/temporal_rete/drools-compiler/src/main/java/org/drools/xml/rules/EvalHandler.java
===================================================================
--- labs/jbossrules/branches/temporal_rete/drools-compiler/src/main/java/org/drools/xml/rules/EvalHandler.java 2008-03-20 18:57:07 UTC (rev 19163)
+++ labs/jbossrules/branches/temporal_rete/drools-compiler/src/main/java/org/drools/xml/rules/EvalHandler.java 2008-03-20 19:32:10 UTC (rev 19164)
@@ -17,8 +17,6 @@
*/
import java.util.HashSet;
-import java.util.LinkedList;
-import java.util.ListIterator;
import org.drools.lang.descr.AndDescr;
import org.drools.lang.descr.ConditionalElementDescr;
@@ -34,7 +32,6 @@
import org.drools.xml.Handler;
import org.xml.sax.Attributes;
import org.xml.sax.SAXException;
-import org.xml.sax.SAXParseException;
/**
* @author mproctor
Modified: labs/jbossrules/branches/temporal_rete/drools-compiler/src/main/java/org/drools/xml/rules/ExistsHandler.java
===================================================================
--- labs/jbossrules/branches/temporal_rete/drools-compiler/src/main/java/org/drools/xml/rules/ExistsHandler.java 2008-03-20 18:57:07 UTC (rev 19163)
+++ labs/jbossrules/branches/temporal_rete/drools-compiler/src/main/java/org/drools/xml/rules/ExistsHandler.java 2008-03-20 19:32:10 UTC (rev 19164)
@@ -17,8 +17,6 @@
*/
import java.util.HashSet;
-import java.util.LinkedList;
-import java.util.ListIterator;
import org.drools.lang.descr.AndDescr;
import org.drools.lang.descr.ConditionalElementDescr;
Modified: labs/jbossrules/branches/temporal_rete/drools-compiler/src/main/java/org/drools/xml/rules/ExpressionHandler.java
===================================================================
--- labs/jbossrules/branches/temporal_rete/drools-compiler/src/main/java/org/drools/xml/rules/ExpressionHandler.java 2008-03-20 18:57:07 UTC (rev 19163)
+++ labs/jbossrules/branches/temporal_rete/drools-compiler/src/main/java/org/drools/xml/rules/ExpressionHandler.java 2008-03-20 19:32:10 UTC (rev 19164)
@@ -17,8 +17,6 @@
*/
import java.util.HashSet;
-import java.util.LinkedList;
-import java.util.ListIterator;
import org.antlr.runtime.ANTLRStringStream;
import org.antlr.runtime.CharStream;
Modified: labs/jbossrules/branches/temporal_rete/drools-compiler/src/main/java/org/drools/xml/rules/FieldBindingHandler.java
===================================================================
--- labs/jbossrules/branches/temporal_rete/drools-compiler/src/main/java/org/drools/xml/rules/FieldBindingHandler.java 2008-03-20 18:57:07 UTC (rev 19163)
+++ labs/jbossrules/branches/temporal_rete/drools-compiler/src/main/java/org/drools/xml/rules/FieldBindingHandler.java 2008-03-20 19:32:10 UTC (rev 19164)
@@ -17,8 +17,6 @@
*/
import java.util.HashSet;
-import java.util.LinkedList;
-import java.util.ListIterator;
import org.drools.lang.descr.FieldBindingDescr;
import org.drools.lang.descr.FieldConstraintDescr;
@@ -30,7 +28,6 @@
import org.drools.xml.Handler;
import org.xml.sax.Attributes;
import org.xml.sax.SAXException;
-import org.xml.sax.SAXParseException;
/**
* @author mproctor
Modified: labs/jbossrules/branches/temporal_rete/drools-compiler/src/main/java/org/drools/xml/rules/FieldConstraintHandler.java
===================================================================
--- labs/jbossrules/branches/temporal_rete/drools-compiler/src/main/java/org/drools/xml/rules/FieldConstraintHandler.java 2008-03-20 18:57:07 UTC (rev 19163)
+++ labs/jbossrules/branches/temporal_rete/drools-compiler/src/main/java/org/drools/xml/rules/FieldConstraintHandler.java 2008-03-20 19:32:10 UTC (rev 19164)
@@ -17,8 +17,6 @@
*/
import java.util.HashSet;
-import java.util.LinkedList;
-import java.util.ListIterator;
import org.drools.lang.descr.AndDescr;
import org.drools.lang.descr.ConditionalElementDescr;
@@ -33,7 +31,6 @@
import org.drools.xml.Handler;
import org.xml.sax.Attributes;
import org.xml.sax.SAXException;
-import org.xml.sax.SAXParseException;
/**
* @author mproctor
Modified: labs/jbossrules/branches/temporal_rete/drools-compiler/src/main/java/org/drools/xml/rules/ForallHandler.java
===================================================================
--- labs/jbossrules/branches/temporal_rete/drools-compiler/src/main/java/org/drools/xml/rules/ForallHandler.java 2008-03-20 18:57:07 UTC (rev 19163)
+++ labs/jbossrules/branches/temporal_rete/drools-compiler/src/main/java/org/drools/xml/rules/ForallHandler.java 2008-03-20 19:32:10 UTC (rev 19164)
@@ -17,8 +17,6 @@
*/
import java.util.HashSet;
-import java.util.LinkedList;
-import java.util.ListIterator;
import org.drools.lang.descr.AndDescr;
import org.drools.lang.descr.ConditionalElementDescr;
Modified: labs/jbossrules/branches/temporal_rete/drools-compiler/src/main/java/org/drools/xml/rules/FromHandler.java
===================================================================
--- labs/jbossrules/branches/temporal_rete/drools-compiler/src/main/java/org/drools/xml/rules/FromHandler.java 2008-03-20 18:57:07 UTC (rev 19163)
+++ labs/jbossrules/branches/temporal_rete/drools-compiler/src/main/java/org/drools/xml/rules/FromHandler.java 2008-03-20 19:32:10 UTC (rev 19164)
@@ -17,8 +17,6 @@
*/
import java.util.HashSet;
-import java.util.LinkedList;
-import java.util.ListIterator;
import org.drools.lang.descr.ConditionalElementDescr;
import org.drools.lang.descr.FieldConstraintDescr;
Modified: labs/jbossrules/branches/temporal_rete/drools-compiler/src/main/java/org/drools/xml/rules/LiteralRestrictionHandler.java
===================================================================
--- labs/jbossrules/branches/temporal_rete/drools-compiler/src/main/java/org/drools/xml/rules/LiteralRestrictionHandler.java 2008-03-20 18:57:07 UTC (rev 19163)
+++ labs/jbossrules/branches/temporal_rete/drools-compiler/src/main/java/org/drools/xml/rules/LiteralRestrictionHandler.java 2008-03-20 19:32:10 UTC (rev 19164)
@@ -17,8 +17,6 @@
*/
import java.util.HashSet;
-import java.util.LinkedList;
-import java.util.ListIterator;
import org.drools.lang.descr.FieldConstraintDescr;
import org.drools.lang.descr.LiteralRestrictionDescr;
@@ -32,7 +30,6 @@
import org.drools.xml.Handler;
import org.xml.sax.Attributes;
import org.xml.sax.SAXException;
-import org.xml.sax.SAXParseException;
/**
* @author mproctor
Modified: labs/jbossrules/branches/temporal_rete/drools-compiler/src/main/java/org/drools/xml/rules/NotHandler.java
===================================================================
--- labs/jbossrules/branches/temporal_rete/drools-compiler/src/main/java/org/drools/xml/rules/NotHandler.java 2008-03-20 18:57:07 UTC (rev 19163)
+++ labs/jbossrules/branches/temporal_rete/drools-compiler/src/main/java/org/drools/xml/rules/NotHandler.java 2008-03-20 19:32:10 UTC (rev 19164)
@@ -17,8 +17,6 @@
*/
import java.util.HashSet;
-import java.util.LinkedList;
-import java.util.ListIterator;
import org.drools.lang.descr.AndDescr;
import org.drools.lang.descr.ConditionalElementDescr;
Modified: labs/jbossrules/branches/temporal_rete/drools-compiler/src/main/java/org/drools/xml/rules/OrHandler.java
===================================================================
--- labs/jbossrules/branches/temporal_rete/drools-compiler/src/main/java/org/drools/xml/rules/OrHandler.java 2008-03-20 18:57:07 UTC (rev 19163)
+++ labs/jbossrules/branches/temporal_rete/drools-compiler/src/main/java/org/drools/xml/rules/OrHandler.java 2008-03-20 19:32:10 UTC (rev 19164)
@@ -17,8 +17,6 @@
*/
import java.util.HashSet;
-import java.util.LinkedList;
-import java.util.ListIterator;
import org.drools.lang.descr.AccumulateDescr;
import org.drools.lang.descr.AndDescr;
Modified: labs/jbossrules/branches/temporal_rete/drools-compiler/src/main/java/org/drools/xml/rules/PatternHandler.java
===================================================================
--- labs/jbossrules/branches/temporal_rete/drools-compiler/src/main/java/org/drools/xml/rules/PatternHandler.java 2008-03-20 18:57:07 UTC (rev 19163)
+++ labs/jbossrules/branches/temporal_rete/drools-compiler/src/main/java/org/drools/xml/rules/PatternHandler.java 2008-03-20 19:32:10 UTC (rev 19164)
@@ -17,8 +17,6 @@
*/
import java.util.HashSet;
-import java.util.LinkedList;
-import java.util.ListIterator;
import org.drools.lang.descr.AccumulateDescr;
import org.drools.lang.descr.AndDescr;
Modified: labs/jbossrules/branches/temporal_rete/drools-compiler/src/main/java/org/drools/xml/rules/PredicateHandler.java
===================================================================
--- labs/jbossrules/branches/temporal_rete/drools-compiler/src/main/java/org/drools/xml/rules/PredicateHandler.java 2008-03-20 18:57:07 UTC (rev 19163)
+++ labs/jbossrules/branches/temporal_rete/drools-compiler/src/main/java/org/drools/xml/rules/PredicateHandler.java 2008-03-20 19:32:10 UTC (rev 19164)
@@ -17,8 +17,6 @@
*/
import java.util.HashSet;
-import java.util.LinkedList;
-import java.util.ListIterator;
import org.drools.lang.descr.FieldBindingDescr;
import org.drools.lang.descr.FieldConstraintDescr;
Modified: labs/jbossrules/branches/temporal_rete/drools-compiler/src/main/java/org/drools/xml/rules/RestrictionConnectiveHandler.java
===================================================================
--- labs/jbossrules/branches/temporal_rete/drools-compiler/src/main/java/org/drools/xml/rules/RestrictionConnectiveHandler.java 2008-03-20 18:57:07 UTC (rev 19163)
+++ labs/jbossrules/branches/temporal_rete/drools-compiler/src/main/java/org/drools/xml/rules/RestrictionConnectiveHandler.java 2008-03-20 19:32:10 UTC (rev 19164)
@@ -17,8 +17,6 @@
*/
import java.util.HashSet;
-import java.util.LinkedList;
-import java.util.ListIterator;
import org.drools.lang.descr.FieldConstraintDescr;
import org.drools.lang.descr.LiteralRestrictionDescr;
Modified: labs/jbossrules/branches/temporal_rete/drools-compiler/src/main/java/org/drools/xml/rules/ReturnValueRestrictionHandler.java
===================================================================
--- labs/jbossrules/branches/temporal_rete/drools-compiler/src/main/java/org/drools/xml/rules/ReturnValueRestrictionHandler.java 2008-03-20 18:57:07 UTC (rev 19163)
+++ labs/jbossrules/branches/temporal_rete/drools-compiler/src/main/java/org/drools/xml/rules/ReturnValueRestrictionHandler.java 2008-03-20 19:32:10 UTC (rev 19164)
@@ -17,8 +17,6 @@
*/
import java.util.HashSet;
-import java.util.LinkedList;
-import java.util.ListIterator;
import org.drools.lang.descr.FieldConstraintDescr;
import org.drools.lang.descr.LiteralRestrictionDescr;
@@ -32,7 +30,6 @@
import org.drools.xml.Handler;
import org.xml.sax.Attributes;
import org.xml.sax.SAXException;
-import org.xml.sax.SAXParseException;
/**
* @author mproctor
Modified: labs/jbossrules/branches/temporal_rete/drools-compiler/src/main/java/org/drools/xml/rules/VariableRestrictionsHandler.java
===================================================================
--- labs/jbossrules/branches/temporal_rete/drools-compiler/src/main/java/org/drools/xml/rules/VariableRestrictionsHandler.java 2008-03-20 18:57:07 UTC (rev 19163)
+++ labs/jbossrules/branches/temporal_rete/drools-compiler/src/main/java/org/drools/xml/rules/VariableRestrictionsHandler.java 2008-03-20 19:32:10 UTC (rev 19164)
@@ -17,8 +17,6 @@
*/
import java.util.HashSet;
-import java.util.LinkedList;
-import java.util.ListIterator;
import org.drools.lang.descr.FieldConstraintDescr;
import org.drools.lang.descr.LiteralRestrictionDescr;
@@ -31,7 +29,6 @@
import org.drools.xml.Handler;
import org.xml.sax.Attributes;
import org.xml.sax.SAXException;
-import org.xml.sax.SAXParseException;
/**
* @author mproctor
Modified: labs/jbossrules/branches/temporal_rete/drools-compiler/src/main/resources/org/drools/rule/builder/dialect/java/javaFunction.mvel
===================================================================
--- labs/jbossrules/branches/temporal_rete/drools-compiler/src/main/resources/org/drools/rule/builder/dialect/java/javaFunction.mvel 2008-03-20 18:57:07 UTC (rev 19163)
+++ labs/jbossrules/branches/temporal_rete/drools-compiler/src/main/resources/org/drools/rule/builder/dialect/java/javaFunction.mvel 2008-03-20 19:32:10 UTC (rev 19164)
@@ -8,10 +8,16 @@
import static @{importEntry};
@end{}
-public class @{className} {
+public class @{className} implements java.io.Externalizable {
private static final long serialVersionUID = 400L;
public static @{returnType} @{methodName}(@foreach{parameterTypes as type, parameterNames as name}@{type} @{name}@end{","}) throws Exception {
@{text}
}
+
+ public void writeExternal(java.io.ObjectOutput out) throws java.io.IOException {
+ }
+
+ public void readExternal(java.io.ObjectInput in) throws java.io.IOException, java.lang.ClassNotFoundException {
+ }
}
\ No newline at end of file
Modified: labs/jbossrules/branches/temporal_rete/drools-compiler/src/main/resources/org/drools/rule/builder/dialect/java/javaInvokers.mvel
===================================================================
--- labs/jbossrules/branches/temporal_rete/drools-compiler/src/main/resources/org/drools/rule/builder/dialect/java/javaInvokers.mvel 2008-03-20 18:57:07 UTC (rev 19163)
+++ labs/jbossrules/branches/temporal_rete/drools-compiler/src/main/resources/org/drools/rule/builder/dialect/java/javaInvokers.mvel 2008-03-20 19:32:10 UTC (rev 19164)
@@ -4,7 +4,7 @@
java.io.InputStream is = @{ruleClassName}.class.getClassLoader().getResourceAsStream( "@{package}.@{ruleClassName}".replace( '.', '/' ) + ".class" );
-
+
java.io.ByteArrayOutputStream bos = new java.io.ByteArrayOutputStream();
byte[] data = new byte[1024];
int byteCount;
@@ -12,21 +12,21 @@
while ( (byteCount = is.read( data,
0,
1024 )) > -1 )
- {
+ {
bos.write(data, 0, byteCount);
}
} catch ( java.io.IOException e ) {
throw new org.drools.RuntimeDroolsException("Unable getResourceAsStream for Class '@{ruleClassName}' ");
- }
-
+ }
+
org.drools.asm.ClassReader classReader = new org.drools.asm.ClassReader( bos.toByteArray() );
classReader.accept( visit, true );
org.drools.asm.util.TraceMethodVisitor trace = visit.getTrace();
- return trace.getText();
+ return trace.getText();
}
>>=::
-
+
equals() ::=<<
public boolean equals(Object object) {
if (object == null ) {
@@ -34,13 +34,13 @@
} else if ( object == this ){
return true;
}
-
+
if ( ! (object instanceof org.drools.spi.CompiledInvoker) ) {
return false;
}
-
+
org.drools.spi.CompiledInvoker other = ( org.drools.spi.CompiledInvoker ) object;
-
+
return org.drools.util.asm.MethodComparator.compareBytecode( getMethodBytecode(), other.getMethodBytecode() );
}
>>=::
@@ -54,21 +54,21 @@
returnValueInvoker() ::=<<
package @{package};
-public class @{invokerClassName} implements org.drools.spi.ReturnValueExpression, org.drools.spi.CompiledInvoker
+public class @{invokerClassName} implements org.drools.spi.ReturnValueExpression, org.drools.spi.CompiledInvoker, java.io.Externalizable
{
private static final long serialVersionUID = 400L;
-
+
public Object createContext() { return null; }
-
+
public org.drools.spi.FieldValue evaluate(java.lang.Object object,
org.drools.spi.Tuple tuple,
- org.drools.rule.Declaration[] previousDeclarations,
- org.drools.rule.Declaration[] localDeclarations,
+ org.drools.rule.Declaration[] previousDeclarations,
+ org.drools.rule.Declaration[] localDeclarations,
org.drools.WorkingMemory workingMemory,
- Object context ) throws Exception {
+ Object context ) throws Exception {
@foreach{declarationTypes as type, declarations as declr} @{type} @{declr.identifier} = ( @{type} ) previousDeclarations[@{i0}].@{declr.nativeReadMethod.name}( (org.drools.common.InternalWorkingMemory) workingMemory, ( (org.drools.common.InternalFactHandle) tuple.get( previousDeclarations[@{i0}] ) ).getObject() );
- @end{}
+ @end{}
@if{readLocalsFromTuple}
@foreach{localDeclarationTypes as type, localDeclarations as declr} @{type} @{declr.identifier} = ( @{type} ) localDeclarations[@{i0}].@{declr.nativeReadMethod.name}( (org.drools.common.InternalWorkingMemory) workingMemory, ( (org.drools.common.InternalFactHandle) tuple.get( localDeclarations[@{i0}] ) ).getObject() );
@end{}
@@ -78,97 +78,115 @@
@end{}
@foreach{globalTypes as type, globals as identifier} @{type} @{identifier} = ( @{type} ) workingMemory.getGlobal( "@{identifier}" );
@end{}
-
- return @{ruleClassName}.@{methodName}(
+
+ return @{ruleClassName}.@{methodName}(
@foreach{declarations as declr} @{declr.identifier}
- @end{","} @if{localDeclarations != empty && declarations != empty}, at end{}
+ @end{","} @if{localDeclarations != empty && declarations != empty}, at end{}
@foreach{localDeclarations as declr} @{declr.identifier}
@end{","}@if{globals != empty && (localDeclarations != empty || declarations != empty)}, at end{}
@foreach{globals as identifier}@{identifier}
@end{","} );
- }
-
+ }
+
@includeByRef{hashCode(hashCode = hashCode)}
-
+
@includeByRef{getMethodBytecode(package = package, ruleClassName = ruleClassName, methodName = methodName)}
-
- @includeByRef{equals()}
-}
+
+ @includeByRef{equals()}
+
+ public void writeExternal(java.io.ObjectOutput out) throws java.io.IOException {
+ }
+
+ public void readExternal(java.io.ObjectInput in) throws java.io.IOException, java.lang.ClassNotFoundException {
+ }
+}
>>=::
predicateInvoker() ::=<<
package @{package};
-public class @{invokerClassName} implements org.drools.spi.PredicateExpression, org.drools.spi.CompiledInvoker
+public class @{invokerClassName} implements org.drools.spi.PredicateExpression, org.drools.spi.CompiledInvoker, java.io.Externalizable
{
private static final long serialVersionUID = 400L;
-
+
public Object createContext() { return null; }
-
+
public boolean evaluate(java.lang.Object object,
org.drools.spi.Tuple tuple,
- org.drools.rule.Declaration[] previousDeclarations,
- org.drools.rule.Declaration[] localDeclarations,
+ org.drools.rule.Declaration[] previousDeclarations,
+ org.drools.rule.Declaration[] localDeclarations,
org.drools.WorkingMemory workingMemory,
- Object context ) throws Exception {
+ Object context ) throws Exception {
@foreach{declarationTypes as type, declarations as declr} @{type} @{declr.identifier} = ( @{type} ) previousDeclarations[@{i0}].@{declr.nativeReadMethod.name}( (org.drools.common.InternalWorkingMemory) workingMemory, ( (org.drools.common.InternalFactHandle) tuple.get( previousDeclarations[@{i0}] ) ).getObject() );
- @end{}
+ @end{}
@foreach{localDeclarationTypes as type, localDeclarations as declr} @{type} @{declr.identifier} = ( @{type} ) localDeclarations[@{i0}].@{declr.nativeReadMethod.name}( (org.drools.common.InternalWorkingMemory) workingMemory, object );
@end{}
@foreach{globalTypes as type, globals as identifier} @{type} @{identifier} = ( @{type} ) workingMemory.getGlobal( "@{identifier}" );
@end{}
-
- return @{ruleClassName}.@{methodName}(
- @foreach{declarations as declr} @{declr.identifier}
- @end{","} @if{localDeclarations != empty && declarations != empty}, at end{}
- @foreach{localDeclarations as declr} @{declr.identifier}
+
+ return @{ruleClassName}.@{methodName}(
+ @foreach{declarations as declr} @{declr.identifier}
+ @end{","} @if{localDeclarations != empty && declarations != empty}, at end{}
+ @foreach{localDeclarations as declr} @{declr.identifier}
@end{","}@if{globals != empty && (localDeclarations != empty || declarations != empty)}, at end{}
@foreach{globals as identifier}@{identifier}
@end{","} );
- }
-
+ }
+
@includeByRef{hashCode(hashCode = hashCode)}
-
+
@includeByRef{getMethodBytecode(package = package, ruleClassName = ruleClassName, methodName = methodName)}
-
- @includeByRef{equals()}
-}
+
+ @includeByRef{equals()}
+
+ public void writeExternal(java.io.ObjectOutput out) throws java.io.IOException {
+ }
+
+ public void readExternal(java.io.ObjectInput in) throws java.io.IOException, java.lang.ClassNotFoundException {
+ }
+}
>>=::
evalInvoker() ::=<<
package @{package};
-public class @{invokerClassName} implements org.drools.spi.EvalExpression, org.drools.spi.CompiledInvoker
+public class @{invokerClassName} implements org.drools.spi.EvalExpression, org.drools.spi.CompiledInvoker, java.io.Externalizable
{
private static final long serialVersionUID = 400L;
- // no need for context
+ // no need for context
public Object createContext() { return null; }
-
+
public boolean evaluate(org.drools.spi.Tuple tuple,
- org.drools.rule.Declaration[] declarations,
+ org.drools.rule.Declaration[] declarations,
org.drools.WorkingMemory workingMemory,
- Object context ) throws Exception {
+ Object context ) throws Exception {
@foreach{declarationTypes as type, declarations as declr} @{type} @{declr.identifier} = ( @{type} ) declarations[@{i0}].@{declr.nativeReadMethod.name}( (org.drools.common.InternalWorkingMemory) workingMemory, ( (org.drools.common.InternalFactHandle) tuple.get( declarations[@{i0}] ) ).getObject() );
- @end{}
+ @end{}
@foreach{globalTypes as type, globals as identifier} @{type} @{identifier} = ( @{type} ) workingMemory.getGlobal( "@{identifier}" );
@end{}
-
- return @{ruleClassName}.@{methodName}(
- @foreach{declarations as declr} @{declr.identifier}
+
+ return @{ruleClassName}.@{methodName}(
+ @foreach{declarations as declr} @{declr.identifier}
@end{","} @if{globals != empty && declarations != empty}, at end{}
@foreach{globals as identifier}@{identifier}
@end{","} );
- }
-
+ }
+
@includeByRef{hashCode(hashCode = hashCode)}
-
+
@includeByRef{getMethodBytecode(package = package, ruleClassName = ruleClassName, methodName = methodName)}
-
- @includeByRef{equals()}
-}
+
+ @includeByRef{equals()}
+
+ public void writeExternal(java.io.ObjectOutput out) throws java.io.IOException {
+ }
+
+ public void readExternal(java.io.ObjectInput in) throws java.io.IOException, java.lang.ClassNotFoundException {
+ }
+}
>>=::
accumulateInvoker() ::=<<
@@ -181,11 +199,11 @@
public class @{invokerClassName} implements org.drools.spi.Accumulator, org.drools.spi.CompiledInvoker
{
private static final long serialVersionUID = 400L;
-
+
public Object createContext() {
return new @{ruleClassName}.@{className}();
}
-
+
public void init(java.lang.Object workingMemoryContext,
java.lang.Object context,
org.drools.spi.Tuple leftTuple,
@@ -194,12 +212,12 @@
@foreach{declarationTypes as type, declarations as declr} @{type} @{declr.identifier} = ( @{type} ) declarations[@{i0}].@{declr.nativeReadMethod.name}( (org.drools.common.InternalWorkingMemory) workingMemory, ( (org.drools.common.InternalFactHandle) leftTuple.get( declarations[@{i0}] ) ).getObject() );
@end{}
@foreach{globalTypes as type, globals as identifier} @{type} @{identifier} = ( @{type} ) workingMemory.getGlobal( "@{identifier}" );
- @end{}
-
+ @end{}
+
((@{ruleClassName}.@{className})context).init(
@foreach{declarations as declr} @{declr.identifier}@end{","}@if{globals != empty && declarations != empty}, at end{}
@foreach{globals as identifier} @{identifier}@end{","} );
-
+
}
public void accumulate(java.lang.Object workingMemoryContext,
@@ -212,7 +230,7 @@
@foreach{declarationTypes as type, declarations as declr} @{type} @{declr.identifier} = ( @{type} ) declarations[@{i0}].@{declr.nativeReadMethod.name}( (org.drools.common.InternalWorkingMemory) workingMemory, ( (org.drools.common.InternalFactHandle) leftTuple.get( declarations[@{i0}] ) ).getObject() );
@end{}
@foreach{globalTypes as type, globals as identifier} @{type} @{identifier} = ( @{type} ) workingMemory.getGlobal( "@{identifier}" );
- @end{}
+ @end{}
@if{isMultiPattern}
@foreach{innerDeclarations as declr} @{declr.extractor.extractToClassName} @{declr.identifier} = (@{declr.extractor.extractToClassName}) innerDeclarations[@{i0}].@{declr.nativeReadMethod.name}( (org.drools.common.InternalWorkingMemory) workingMemory, ( (org.drools.common.InternalFactHandle) leftTuple.get( innerDeclarations[@{i0}] ) ).getObject() );
@end{}
@@ -223,7 +241,7 @@
((@{ruleClassName}.@{className})context).accumulate(
workingMemory,
innerDeclarations,
- handle.getObject()@if{declarations != empty}, at end{}
+ handle.getObject()@if{declarations != empty}, at end{}
@foreach{declarations as declr} @{declr.identifier}@end{","}@if{globals != empty}, at end{}
@foreach{globals as identifier} @{identifier}@end{","}@if{innerDeclarations != empty}, at end{}
@foreach{innerDeclarations as declr} @{declr.identifier}@end{","});
@@ -239,7 +257,7 @@
@foreach{declarationTypes as type, declarations as declr} @{type} @{declr.identifier} = ( @{type} ) declarations[@{i0}].@{declr.nativeReadMethod.name}( (org.drools.common.InternalWorkingMemory) workingMemory, ( (org.drools.common.InternalFactHandle) leftTuple.get( declarations[@{i0}] ) ).getObject() );
@end{}
@foreach{globalTypes as type, globals as identifier} @{type} @{identifier} = ( @{type} ) workingMemory.getGlobal( "@{identifier}" );
- @end{}
+ @end{}
@if{isMultiPattern}
@foreach{innerDeclarations as declr} @{declr.extractor.extractToClassName} @{declr.identifier} = (@{declr.extractor.extractToClassName}) innerDeclarations[@{i0}].@{declr.nativeReadMethod.name}( (org.drools.common.InternalWorkingMemory) workingMemory, ( (org.drools.common.InternalFactHandle) leftTuple.get( innerDeclarations[@{i0}] ) ).getObject() );
@end{}
@@ -247,11 +265,11 @@
@foreach{innerDeclarations as declr} @{declr.extractor.extractToClassName} @{declr.identifier} = (@{declr.extractor.extractToClassName}) innerDeclarations[@{i0}].@{declr.nativeReadMethod.name}( (org.drools.common.InternalWorkingMemory) workingMemory, handle.getObject() );
@end{}
@end{}
-
+
((@{ruleClassName}.@{className})context).reverse(
workingMemory,
innerDeclarations,
- handle.getObject()@if{declarations != empty}, at end{}
+ handle.getObject()@if{declarations != empty}, at end{}
@foreach{declarations as declr} @{declr.identifier}@end{","}@if{globals != empty}, at end{}
@foreach{globals as identifier} @{identifier}@end{","}@if{innerDeclarations != empty}, at end{}
@foreach{innerDeclarations as declr} @{declr.identifier}@end{","});
@@ -265,13 +283,13 @@
@foreach{declarationTypes as type, declarations as declr} @{type} @{declr.identifier} = ( @{type} ) declarations[@{i0}].@{declr.nativeReadMethod.name}( (org.drools.common.InternalWorkingMemory) workingMemory, ( (org.drools.common.InternalFactHandle) leftTuple.get( declarations[@{i0}] ) ).getObject() );
@end{}
@foreach{globalTypes as type, globals as identifier} @{type} @{identifier} = ( @{type} ) workingMemory.getGlobal( "@{identifier}" );
- @end{}
-
+ @end{}
+
return ((@{ruleClassName}.@{className})context).getResult(
@foreach{declarations as declr} @{declr.identifier}@end{","}@if{globals != empty && declarations != empty}, at end{}
@foreach{globals as identifier} @{identifier}@end{","} );
}
-
+
public boolean supportsReverse() {
return @{supportsReverse};
}
@@ -279,14 +297,14 @@
public Object createWorkingMemoryContext() {
return null;
}
-
+
@includeByRef{hashCode(hashCode = hashCode)}
-
- @includeByRef{equals()}
+ @includeByRef{equals()}
+
public java.util.List getMethodBytecode() {
java.io.InputStream is = @{ruleClassName}.class.getClassLoader().getResourceAsStream( "@{package}.@{ruleClassName}".replace( '.', '/' ) + "$@{className}" + ".class" );
-
+
java.io.ByteArrayOutputStream bos = new java.io.ByteArrayOutputStream();
byte[] data = new byte[1024];
int byteCount;
@@ -294,84 +312,108 @@
while ( (byteCount = is.read( data,
0,
1024 )) > -1 )
- {
+ {
bos.write(data, 0, byteCount);
}
} catch ( java.io.IOException e ) {
throw new org.drools.RuntimeDroolsException("Unable getResourceAsStream for Class '@{ruleClassName}$@{className}' ");
- }
- return Collections.singletonList( bos );
+ }
+ return Collections.singletonList( bos );
}
-}
+
+ public void writeExternal(java.io.ObjectOutput out) throws java.io.IOException {
+ }
+
+ public void readExternal(java.io.ObjectInput in) throws java.io.IOException, java.lang.ClassNotFoundException {
+ }
+
+}
>>=::
consequenceInvoker() ::=<<
package @{package};
-public class @{invokerClassName} implements org.drools.spi.Consequence
+public class @{invokerClassName} implements org.drools.spi.Consequence, java.io.Externalizable
{
private static final long serialVersionUID = 400L;
public void evaluate(org.drools.spi.KnowledgeHelper knowledgeHelper,
- org.drools.WorkingMemory workingMemory) throws Exception {
-
+ org.drools.WorkingMemory workingMemory) throws Exception {
+
org.drools.spi.Tuple tuple = knowledgeHelper.getTuple();
org.drools.rule.Rule rule = knowledgeHelper.getRule();
- org.drools.rule.Declaration[] declarations = rule.getDeclarations();
+ org.drools.rule.Declaration[] declarations = rule.getDeclarations();
@foreach{declarationTypes as type, declarations as declr ,indexes as index, notPatterns as notPattern}
- org.drools.common.InternalFactHandle @{declr.identifier}__Handle__ = ( org.drools.common.InternalFactHandle ) tuple.get( knowledgeHelper.getDeclaration( declarations[@{index}].getIdentifier() ) );
+ org.drools.common.InternalFactHandle @{declr.identifier}__Handle__ = ( org.drools.common.InternalFactHandle ) tuple.get( knowledgeHelper.getDeclaration( declarations[@{index}].getIdentifier() ) );
@{type} @{declr.identifier} = ( @{type} ) declarations[@{index}].@{declr.nativeReadMethod.name}( (org.drools.common.InternalWorkingMemory) workingMemory, @{declr.identifier}__Handle__.getObject() );
@if{notPattern}@{declr.identifier}__Handle__ = (org.drools.common.InternalFactHandle) knowledgeHelper.getWorkingMemory().getFactHandle( @{declr.identifier} );@end{}
@end{}
-
- @foreach{globalTypes as type, globals as identifier} @{type} @{identifier} = ( @{type} ) workingMemory.getGlobal( "@{identifier}" );
- @end{}
-
- @{ruleClassName}.@{methodName} (
+
+ @foreach{globalTypes as type, globals as identifier} @{type} @{identifier} = ( @{type} ) workingMemory.getGlobal( "@{identifier}" );
+ @end{}
+
+ @{ruleClassName}.@{methodName} (
knowledgeHelper at if{declarations != empty}, at end{}
@foreach{declarations as declr} @{declr.identifier}, @{declr.identifier}__Handle__
@end{","}@if{globals != empty}, at end{}
@foreach{globals as identifier} @{identifier}
@end{","} );
}
-}
+ public void writeExternal(java.io.ObjectOutput out) throws java.io.IOException {
+ }
+
+ public void readExternal(java.io.ObjectInput in) throws java.io.IOException, java.lang.ClassNotFoundException {
+ }
+}
>>=::
actionInvoker() ::=<<
package @{package};
-public class @{invokerClassName} implements org.drools.spi.Action
+public class @{invokerClassName} implements org.drools.spi.Action, java.io.Externalizable
{
private static final long serialVersionUID = 400L;
- public void execute(org.drools.WorkingMemory workingMemory) throws Exception {
-
- @foreach{globalTypes as type, globals as identifier} @{type} @{identifier} = ( @{type} ) workingMemory.getGlobal( "@{identifier}" );
- @end{}
-
- @{processClassName}.@{methodName} (
+ public void execute(org.drools.WorkingMemory workingMemory) throws Exception {
+
+ @foreach{globalTypes as type, globals as identifier} @{type} @{identifier} = ( @{type} ) workingMemory.getGlobal( "@{identifier}" );
+ @end{}
+
+ @{processClassName}.@{methodName} (
@foreach{globals as identifier} @{identifier}
@end{","} );
}
-}
+
+ public void writeExternal(java.io.ObjectOutput out) throws java.io.IOException {
+ }
+
+ public void readExternal(java.io.ObjectInput in) throws java.io.IOException, java.lang.ClassNotFoundException {
+ }
+}
>>=::
returnValueEvaluatorInvoker() ::=<<
package @{package};
-public class @{invokerClassName} implements org.drools.spi.ReturnValueEvaluator
+public class @{invokerClassName} implements org.drools.spi.ReturnValueEvaluator, java.io.Externalizable
{
private static final long serialVersionUID = 400L;
- public Object evaluate(org.drools.WorkingMemory workingMemory) throws Exception {
-
- @foreach{globalTypes as type, globals as identifier} @{type} @{identifier} = ( @{type} ) workingMemory.getGlobal( "@{identifier}" );
- @end{}
-
- return @{processClassName}.@{methodName} (
+ public Object evaluate(org.drools.WorkingMemory workingMemory) throws Exception {
+
+ @foreach{globalTypes as type, globals as identifier} @{type} @{identifier} = ( @{type} ) workingMemory.getGlobal( "@{identifier}" );
+ @end{}
+
+ return @{processClassName}.@{methodName} (
@foreach{globals as identifier} @{identifier}
@end{","} );
}
-}
+
+ public void writeExternal(java.io.ObjectOutput out) throws java.io.IOException {
+ }
+
+ public void readExternal(java.io.ObjectInput in) throws java.io.IOException, java.lang.ClassNotFoundException {
+ }
+}
>>=::
\ No newline at end of file
Modified: labs/jbossrules/branches/temporal_rete/drools-compiler/src/test/java/org/drools/Address.java
===================================================================
--- labs/jbossrules/branches/temporal_rete/drools-compiler/src/test/java/org/drools/Address.java 2008-03-20 18:57:07 UTC (rev 19163)
+++ labs/jbossrules/branches/temporal_rete/drools-compiler/src/test/java/org/drools/Address.java 2008-03-20 19:32:10 UTC (rev 19164)
@@ -1,18 +1,22 @@
package org.drools;
-public class Address {
+import java.io.Serializable;
+public class Address implements Serializable {
+
+ private static final long serialVersionUID = -8519011705761628197L;
+
private String street;
private String suburb;
-
+
public Address() {
-
+
}
-
+
public Address(String street) {
this.street = street;
}
-
+
public String getStreet() {
return street;
}
@@ -25,5 +29,5 @@
public void setSuburb(String suburb) {
this.suburb = suburb;
}
-
+
}
Modified: labs/jbossrules/branches/temporal_rete/drools-compiler/src/test/java/org/drools/Attribute.java
===================================================================
--- labs/jbossrules/branches/temporal_rete/drools-compiler/src/test/java/org/drools/Attribute.java 2008-03-20 18:57:07 UTC (rev 19163)
+++ labs/jbossrules/branches/temporal_rete/drools-compiler/src/test/java/org/drools/Attribute.java 2008-03-20 19:32:10 UTC (rev 19164)
@@ -3,7 +3,9 @@
*/
package org.drools;
-public class Attribute
+import java.io.Serializable;
+
+public class Attribute implements Serializable
{
public Integer getValue()
Modified: labs/jbossrules/branches/temporal_rete/drools-compiler/src/test/java/org/drools/Cell.java
===================================================================
--- labs/jbossrules/branches/temporal_rete/drools-compiler/src/test/java/org/drools/Cell.java 2008-03-20 18:57:07 UTC (rev 19163)
+++ labs/jbossrules/branches/temporal_rete/drools-compiler/src/test/java/org/drools/Cell.java 2008-03-20 19:32:10 UTC (rev 19164)
@@ -1,5 +1,7 @@
package org.drools;
+import java.io.Serializable;
+
/*
* Copyright 2005 JBoss Inc
*
@@ -16,7 +18,7 @@
* limitations under the License.
*/
-public class Cell {
+public class Cell implements Serializable {
int value = 0;
Modified: labs/jbossrules/branches/temporal_rete/drools-compiler/src/test/java/org/drools/Cheese.java
===================================================================
--- labs/jbossrules/branches/temporal_rete/drools-compiler/src/test/java/org/drools/Cheese.java 2008-03-20 18:57:07 UTC (rev 19163)
+++ labs/jbossrules/branches/temporal_rete/drools-compiler/src/test/java/org/drools/Cheese.java 2008-03-20 19:32:10 UTC (rev 19164)
@@ -37,12 +37,12 @@
public Cheese() {
}
-
+
public Cheese(final String type) {
super();
this.type = type;
this.price = 0;
- }
+ }
public Cheese(final String type,
final int price) {
Modified: labs/jbossrules/branches/temporal_rete/drools-compiler/src/test/java/org/drools/CheeseEqual.java
===================================================================
--- labs/jbossrules/branches/temporal_rete/drools-compiler/src/test/java/org/drools/CheeseEqual.java 2008-03-20 18:57:07 UTC (rev 19163)
+++ labs/jbossrules/branches/temporal_rete/drools-compiler/src/test/java/org/drools/CheeseEqual.java 2008-03-20 19:32:10 UTC (rev 19164)
@@ -1,16 +1,19 @@
package org.drools;
-import java.io.Serializable;
+import java.io.Externalizable;
+import java.io.IOException;
+import java.io.ObjectInput;
+import java.io.ObjectOutput;
/*
* Copyright 2005 JBoss Inc
- *
+ *
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -20,9 +23,9 @@
public class CheeseEqual
implements
- Serializable {
+ Externalizable {
/**
- *
+ *
*/
private static final long serialVersionUID = 400L;
protected String type;
@@ -39,6 +42,16 @@
this.price = price;
}
+ public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
+ type = (String)in.readObject();
+ price = in.readInt();
+ }
+
+ public void writeExternal(ObjectOutput out) throws IOException {
+ out.writeObject(type);
+ out.writeInt(price);
+ }
+
public int getPrice() {
return this.price;
}
Modified: labs/jbossrules/branches/temporal_rete/drools-compiler/src/test/java/org/drools/Cheesery.java
===================================================================
--- labs/jbossrules/branches/temporal_rete/drools-compiler/src/test/java/org/drools/Cheesery.java 2008-03-20 18:57:07 UTC (rev 19163)
+++ labs/jbossrules/branches/temporal_rete/drools-compiler/src/test/java/org/drools/Cheesery.java 2008-03-20 19:32:10 UTC (rev 19164)
@@ -2,13 +2,13 @@
/*
* Copyright 2005 JBoss Inc
- *
+ *
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -16,22 +16,28 @@
* limitations under the License.
*/
+import java.io.Externalizable;
+import java.io.ObjectOutput;
+import java.io.IOException;
+import java.io.ObjectInput;
+import java.io.ObjectStreamException;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
+import java.util.Collections;
public class Cheesery
implements
Serializable {
/**
- *
+ *
*/
private static final long serialVersionUID = 400L;
public final static int MAKING_CHEESE = 0;
public final static int SELLING_CHEESE = 1;
- private final List cheeses = new ArrayList();
+ private List cheeses = new ArrayList();
private int status;
private int totalAmount;
@@ -78,18 +84,70 @@
this.totalAmount = totalAmount;
}
- public static class Maturity {
+ public static class Maturity implements Externalizable {
public static final Maturity YOUNG = new Maturity( "young" );
public static final Maturity OLD = new Maturity( "old" );
private String age;
+ public Maturity() {
+ }
+
public Maturity(final String age) {
this.age = age;
}
+ public boolean equals(Object obj) {
+ if (obj instanceof Maturity) {
+ return age == ((Maturity)obj).age || age != null && age.equals(((Maturity)obj).age);
+ }
+ return false;
+ }
+
+ public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
+ age = (String)in.readObject();
+ }
+
+ public void writeExternal(ObjectOutput out) throws IOException {
+ out.writeObject(age);
+ }
+
+ private Object readResolve() throws ObjectStreamException {
+ if ( "young".equals( this.age) ) {
+ return Maturity.YOUNG;
+ } else {
+ return Maturity.OLD;
+ }
+ }
+
public String toString() {
return "[Maturity age='" + this.age + "']";
}
}
+
+ @Override
+ public int hashCode() {
+ final int prime = 31;
+ int result = 1;
+ result = prime * result + ((cheeses == null) ? 0 : cheeses.hashCode());
+ result = prime * result + ((maturity == null) ? 0 : maturity.hashCode());
+ result = prime * result + status;
+ result = prime * result + totalAmount;
+ return result;
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj) {
+ return true;
+ }
+ else if (obj instanceof Cheesery) {
+ Cheesery that = (Cheesery)obj;
+ return cheeses.equals(that.cheeses) &&
+ status == that.status &&
+ totalAmount == that.totalAmount &&
+ maturity == that.maturity || maturity != null && maturity.equals(that.maturity);
+ }
+ return false;
+ }
}
\ No newline at end of file
Copied: labs/jbossrules/branches/temporal_rete/drools-compiler/src/test/java/org/drools/DomainObject.java (from rev 19160, labs/jbossrules/dev_tags/before_righttuple_merge_20080320/drools-compiler/src/test/java/org/drools/DomainObject.java)
===================================================================
--- labs/jbossrules/branches/temporal_rete/drools-compiler/src/test/java/org/drools/DomainObject.java (rev 0)
+++ labs/jbossrules/branches/temporal_rete/drools-compiler/src/test/java/org/drools/DomainObject.java 2008-03-20 19:32:10 UTC (rev 19164)
@@ -0,0 +1,33 @@
+package org.drools;
+
+public class DomainObject {
+
+ private String message;
+ private int value;
+ private double value2;
+
+ public String getMessage() {
+ return message;
+ }
+
+ public void setMessage(String message) {
+ this.message = message;
+ }
+
+ public int getValue() {
+ return value;
+ }
+
+ public void setValue(int value) {
+ this.value = value;
+ }
+
+ public double getValue2() {
+ return value2;
+ }
+
+ public void setValue2(double value2) {
+ this.value2 = value2;
+ }
+
+}
Copied: labs/jbossrules/branches/temporal_rete/drools-compiler/src/test/java/org/drools/DomainObjectHolder.java (from rev 19160, labs/jbossrules/dev_tags/before_righttuple_merge_20080320/drools-compiler/src/test/java/org/drools/DomainObjectHolder.java)
===================================================================
--- labs/jbossrules/branches/temporal_rete/drools-compiler/src/test/java/org/drools/DomainObjectHolder.java (rev 0)
+++ labs/jbossrules/branches/temporal_rete/drools-compiler/src/test/java/org/drools/DomainObjectHolder.java 2008-03-20 19:32:10 UTC (rev 19164)
@@ -0,0 +1,29 @@
+package org.drools;
+
+public class DomainObjectHolder {
+
+ DomainObject[] objects = new DomainObject[3];
+
+ public DomainObjectHolder(){
+
+ objects[0] = new DomainObject();
+ objects[0].setMessage("Message1");
+ objects[0].setValue(1);
+ objects[0].setValue2(2);
+
+ objects[1] = new DomainObject();
+ objects[1].setMessage("Message2");
+ objects[1].setValue(3);
+ objects[1].setValue2(4);
+
+ objects[2] = new DomainObject();
+ objects[2].setMessage("Message3");
+ objects[2].setValue(5);
+ objects[2].setValue2(6);
+ }
+
+ public DomainObject[] getObjects(){
+ return objects;
+ }
+
+ }
Modified: labs/jbossrules/branches/temporal_rete/drools-compiler/src/test/java/org/drools/FactA.java
===================================================================
--- labs/jbossrules/branches/temporal_rete/drools-compiler/src/test/java/org/drools/FactA.java 2008-03-20 18:57:07 UTC (rev 19163)
+++ labs/jbossrules/branches/temporal_rete/drools-compiler/src/test/java/org/drools/FactA.java 2008-03-20 19:32:10 UTC (rev 19164)
@@ -1,6 +1,8 @@
package org.drools;
-public class FactA {
+import java.io.Serializable;
+
+public class FactA implements Serializable {
String field1;
Integer field2;
Float field3;
Modified: labs/jbossrules/branches/temporal_rete/drools-compiler/src/test/java/org/drools/FactB.java
===================================================================
--- labs/jbossrules/branches/temporal_rete/drools-compiler/src/test/java/org/drools/FactB.java 2008-03-20 18:57:07 UTC (rev 19163)
+++ labs/jbossrules/branches/temporal_rete/drools-compiler/src/test/java/org/drools/FactB.java 2008-03-20 19:32:10 UTC (rev 19164)
@@ -1,6 +1,8 @@
package org.drools;
-public class FactB {
+import java.io.Serializable;
+
+public class FactB implements Serializable {
String f1;
Integer f2;
Float f3;
Modified: labs/jbossrules/branches/temporal_rete/drools-compiler/src/test/java/org/drools/FactC.java
===================================================================
--- labs/jbossrules/branches/temporal_rete/drools-compiler/src/test/java/org/drools/FactC.java 2008-03-20 18:57:07 UTC (rev 19163)
+++ labs/jbossrules/branches/temporal_rete/drools-compiler/src/test/java/org/drools/FactC.java 2008-03-20 19:32:10 UTC (rev 19164)
@@ -1,6 +1,8 @@
package org.drools;
-public class FactC {
+import java.io.Serializable;
+
+public class FactC implements Serializable {
String f1;
Integer f2;
Float f3;
Modified: labs/jbossrules/branches/temporal_rete/drools-compiler/src/test/java/org/drools/Func.java
===================================================================
--- labs/jbossrules/branches/temporal_rete/drools-compiler/src/test/java/org/drools/Func.java 2008-03-20 18:57:07 UTC (rev 19163)
+++ labs/jbossrules/branches/temporal_rete/drools-compiler/src/test/java/org/drools/Func.java 2008-03-20 19:32:10 UTC (rev 19164)
@@ -1,6 +1,8 @@
package org.drools;
-public class Func {
+import java.io.Serializable;
+
+public class Func implements Serializable {
public static void func() {
}
Modified: labs/jbossrules/branches/temporal_rete/drools-compiler/src/test/java/org/drools/GrandParent.java
===================================================================
--- labs/jbossrules/branches/temporal_rete/drools-compiler/src/test/java/org/drools/GrandParent.java 2008-03-20 18:57:07 UTC (rev 19163)
+++ labs/jbossrules/branches/temporal_rete/drools-compiler/src/test/java/org/drools/GrandParent.java 2008-03-20 19:32:10 UTC (rev 19164)
@@ -1,10 +1,12 @@
package org.drools;
+import java.io.Serializable;
+
/**
* A grand parent class
* @author etirelli
*/
-public class GrandParent {
+public class GrandParent implements Serializable {
private String name;
public GrandParent() {
Modified: labs/jbossrules/branches/temporal_rete/drools-compiler/src/test/java/org/drools/Guess.java
===================================================================
--- labs/jbossrules/branches/temporal_rete/drools-compiler/src/test/java/org/drools/Guess.java 2008-03-20 18:57:07 UTC (rev 19163)
+++ labs/jbossrules/branches/temporal_rete/drools-compiler/src/test/java/org/drools/Guess.java 2008-03-20 19:32:10 UTC (rev 19164)
@@ -1,7 +1,9 @@
package org.drools;
-public class Guess {
+import java.io.Serializable;
+public class Guess implements Serializable {
+
private Integer value;
public void setValue(final Integer guess) {
Modified: labs/jbossrules/branches/temporal_rete/drools-compiler/src/test/java/org/drools/IndexedNumber.java
===================================================================
--- labs/jbossrules/branches/temporal_rete/drools-compiler/src/test/java/org/drools/IndexedNumber.java 2008-03-20 18:57:07 UTC (rev 19163)
+++ labs/jbossrules/branches/temporal_rete/drools-compiler/src/test/java/org/drools/IndexedNumber.java 2008-03-20 19:32:10 UTC (rev 19164)
@@ -16,6 +16,8 @@
package org.drools;
+import java.io.Serializable;
+
/**
* IndexedNumber
*
@@ -25,7 +27,7 @@
* @version $Id$
*/
-public class IndexedNumber {
+public class IndexedNumber implements Serializable {
private int number = 0;
Modified: labs/jbossrules/branches/temporal_rete/drools-compiler/src/test/java/org/drools/InsertedObject.java
===================================================================
--- labs/jbossrules/branches/temporal_rete/drools-compiler/src/test/java/org/drools/InsertedObject.java 2008-03-20 18:57:07 UTC (rev 19163)
+++ labs/jbossrules/branches/temporal_rete/drools-compiler/src/test/java/org/drools/InsertedObject.java 2008-03-20 19:32:10 UTC (rev 19164)
@@ -1,6 +1,8 @@
package org.drools;
-public class InsertedObject {
+import java.io.Serializable;
+
+public class InsertedObject implements Serializable {
private String value;
public String getValue() {
@@ -24,7 +26,7 @@
result = PRIME * result + ((value == null) ? 0 : value.hashCode());
return result;
}
-
+
public boolean equals(Object obj) {
if ( this == obj ) return true;
if ( obj == null ) return false;
@@ -35,7 +37,7 @@
} else if ( !value.equals( other.value ) ) return false;
return true;
}
-
-
+
+
}
\ No newline at end of file
Modified: labs/jbossrules/branches/temporal_rete/drools-compiler/src/test/java/org/drools/Message.java
===================================================================
--- labs/jbossrules/branches/temporal_rete/drools-compiler/src/test/java/org/drools/Message.java 2008-03-20 18:57:07 UTC (rev 19163)
+++ labs/jbossrules/branches/temporal_rete/drools-compiler/src/test/java/org/drools/Message.java 2008-03-20 19:32:10 UTC (rev 19164)
@@ -6,8 +6,9 @@
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
+import java.io.Serializable;
-public class Message {
+public class Message implements Serializable {
private String message1 = "One";
private String message2 = "Two";
@@ -24,15 +25,15 @@
private List list = new ArrayList();
private int number = 0;
private Date birthday = new Date();
- private boolean fired = false;
-
+ private boolean fired = false;
+
public Message() {
}
-
+
public Message(final String msg) {
this.message = msg;
- }
-
+ }
+
public String getMessage() {
return this.message;
}
@@ -80,7 +81,7 @@
public void setMessage4(final String message4) {
this.message4 = message4;
}
-
+
public boolean isFired() {
return this.fired;
}
@@ -115,5 +116,5 @@
public void addToList(final String s) {
this.list.add( s );
- }
+ }
}
\ No newline at end of file
Modified: labs/jbossrules/branches/temporal_rete/drools-compiler/src/test/java/org/drools/Order.java
===================================================================
--- labs/jbossrules/branches/temporal_rete/drools-compiler/src/test/java/org/drools/Order.java 2008-03-20 18:57:07 UTC (rev 19163)
+++ labs/jbossrules/branches/temporal_rete/drools-compiler/src/test/java/org/drools/Order.java 2008-03-20 19:32:10 UTC (rev 19164)
@@ -20,12 +20,13 @@
import java.util.Date;
import java.util.HashMap;
import java.util.Map;
+import java.io.Serializable;
/**
* @author etirelli
*
*/
-public class Order {
+public class Order implements Serializable {
private int number;
@@ -34,7 +35,7 @@
private Map items;
private OrderStatus status;
-
+
private Date date;
public Order() {
Modified: labs/jbossrules/branches/temporal_rete/drools-compiler/src/test/java/org/drools/OrderEvent.java
===================================================================
--- labs/jbossrules/branches/temporal_rete/drools-compiler/src/test/java/org/drools/OrderEvent.java 2008-03-20 18:57:07 UTC (rev 19163)
+++ labs/jbossrules/branches/temporal_rete/drools-compiler/src/test/java/org/drools/OrderEvent.java 2008-03-20 19:32:10 UTC (rev 19164)
@@ -17,17 +17,19 @@
*/
package org.drools;
+import java.io.Serializable;
+
/**
* A simple order event POJO
*
* @author etirelli
*/
-public class OrderEvent {
-
+public class OrderEvent implements Serializable {
+
private String id;
private String customer;
private double total;
-
+
public OrderEvent(String id,
String customer,
double total) {
Modified: labs/jbossrules/branches/temporal_rete/drools-compiler/src/test/java/org/drools/OrderItem.java
===================================================================
--- labs/jbossrules/branches/temporal_rete/drools-compiler/src/test/java/org/drools/OrderItem.java 2008-03-20 18:57:07 UTC (rev 19163)
+++ labs/jbossrules/branches/temporal_rete/drools-compiler/src/test/java/org/drools/OrderItem.java 2008-03-20 19:32:10 UTC (rev 19164)
@@ -1,12 +1,12 @@
/*
* Copyright 2006 JBoss Inc
- *
+ *
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -16,16 +16,21 @@
package org.drools;
+import java.io.Externalizable;
+import java.io.ObjectInput;
+import java.io.IOException;
+import java.io.ObjectOutput;
+
/**
* @author etirelli
*
*/
-public class OrderItem implements java.io.Serializable {
+public class OrderItem implements Externalizable {
private static final long serialVersionUID = -7287814895557751224L;
-
+
public static final int TYPE_BOOK = 1;
public static final int TYPE_CD = 2;
-
+
private String name;
private int type;
private int price;
@@ -52,6 +57,22 @@
this.price = price;
}
+ public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
+ name = (String)in.readObject();
+ type = in.readInt();
+ price = in.readInt();
+ seq = in.readInt();
+ order = (Order)in.readObject();
+ }
+
+ public void writeExternal(ObjectOutput out) throws IOException {
+ out.writeObject(name);
+ out.writeInt(type);
+ out.writeInt(price);
+ out.writeInt(seq);
+ out.writeObject(order);
+ }
+
public String getName() {
return name;
}
@@ -59,11 +80,11 @@
public void setName(String name) {
this.name = name;
}
-
+
public int getType() {
return type;
}
-
+
public void setType(int type) {
this.type = type;
}
@@ -141,7 +162,7 @@
}
return true;
}
-
+
public String toString() {
return "OrderItem( order="+this.getOrder()+" seq="+this.getSeq()+")";
}
Modified: labs/jbossrules/branches/temporal_rete/drools-compiler/src/test/java/org/drools/Person.java
===================================================================
--- labs/jbossrules/branches/temporal_rete/drools-compiler/src/test/java/org/drools/Person.java 2008-03-20 18:57:07 UTC (rev 19163)
+++ labs/jbossrules/branches/temporal_rete/drools-compiler/src/test/java/org/drools/Person.java 2008-03-20 19:32:10 UTC (rev 19164)
@@ -1,5 +1,8 @@
package org.drools;
+import java.io.IOException;
+import java.io.ObjectInput;
+import java.io.ObjectOutput;
import java.io.Serializable;
import java.math.BigDecimal;
import java.math.BigInteger;
@@ -11,7 +14,7 @@
Serializable,
PersonInterface {
/**
- *
+ *
*/
private static final long serialVersionUID = 400L;
private String name;
@@ -30,7 +33,34 @@
private Cheese cheese;
private List addresses = new ArrayList();
-
+
+ public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
+ name = (String)in.readObject();
+ likes = (String)in.readObject();
+ age = in.readInt();
+ bigDecimal = (BigDecimal)in.readObject();
+ bigInteger = (BigInteger)in.readObject();
+ hair = (String)in.readObject();
+ sex = in.readChar();
+ alive = in.readBoolean();
+ status = (String)in.readObject();
+ cheese = (Cheese)in.readObject();
+ addresses = (List)in.readObject();
+ }
+
+ public void writeExternal(ObjectOutput out) throws IOException {
+ out.writeObject(name);
+ out.writeObject(likes);
+ out.writeObject(bigDecimal);
+ out.writeObject(bigInteger);
+ out.writeObject(hair);
+ out.writeChar(sex);
+ out.writeBoolean(alive);
+ out.writeObject(status);
+ out.writeObject(cheese);
+ out.writeObject(addresses);
+ }
+
public List getAddresses() {
return addresses;
}
Modified: labs/jbossrules/branches/temporal_rete/drools-compiler/src/test/java/org/drools/Precondition.java
===================================================================
--- labs/jbossrules/branches/temporal_rete/drools-compiler/src/test/java/org/drools/Precondition.java 2008-03-20 18:57:07 UTC (rev 19163)
+++ labs/jbossrules/branches/temporal_rete/drools-compiler/src/test/java/org/drools/Precondition.java 2008-03-20 19:32:10 UTC (rev 19164)
@@ -1,6 +1,8 @@
package org.drools;
-public class Precondition {
+import java.io.Serializable;
+
+public class Precondition implements Serializable {
private String code;
private String value;
Modified: labs/jbossrules/branches/temporal_rete/drools-compiler/src/test/java/org/drools/Primitives.java
===================================================================
--- labs/jbossrules/branches/temporal_rete/drools-compiler/src/test/java/org/drools/Primitives.java 2008-03-20 18:57:07 UTC (rev 19163)
+++ labs/jbossrules/branches/temporal_rete/drools-compiler/src/test/java/org/drools/Primitives.java 2008-03-20 19:32:10 UTC (rev 19164)
@@ -1,16 +1,17 @@
package org.drools;
+import java.io.Serializable;
import java.util.Arrays;
/*
* Copyright 2005 JBoss Inc
- *
+ *
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -18,7 +19,7 @@
* limitations under the License.
*/
-public class Primitives implements java.io.Serializable {
+public class Primitives implements Serializable {
private static final long serialVersionUID = -3006488134941876318L;
@@ -37,9 +38,9 @@
private Object[] arrayAttribute;
private int[] primitiveArrayAttribute;
private String[] stringArray;
-
+
private Boolean booleanWrapper;
-
+
private Object object;
public boolean isBooleanPrimitive() {
@@ -209,7 +210,7 @@
} else if ( !stringAttribute.equals( other.stringAttribute ) ) return false;
return true;
}
-
-
+
+
}
\ No newline at end of file
Modified: labs/jbossrules/branches/temporal_rete/drools-compiler/src/test/java/org/drools/State.java
===================================================================
--- labs/jbossrules/branches/temporal_rete/drools-compiler/src/test/java/org/drools/State.java 2008-03-20 18:57:07 UTC (rev 19163)
+++ labs/jbossrules/branches/temporal_rete/drools-compiler/src/test/java/org/drools/State.java 2008-03-20 19:32:10 UTC (rev 19164)
@@ -2,8 +2,9 @@
import java.beans.PropertyChangeListener;
import java.beans.PropertyChangeSupport;
+import java.io.Serializable;
-public class State {
+public class State implements Serializable {
private final PropertyChangeSupport changes = new PropertyChangeSupport( this );
private String state;
Modified: labs/jbossrules/branches/temporal_rete/drools-compiler/src/test/java/org/drools/StockTick.java
===================================================================
--- labs/jbossrules/branches/temporal_rete/drools-compiler/src/test/java/org/drools/StockTick.java 2008-03-20 18:57:07 UTC (rev 19163)
+++ labs/jbossrules/branches/temporal_rete/drools-compiler/src/test/java/org/drools/StockTick.java 2008-03-20 19:32:10 UTC (rev 19164)
@@ -1,6 +1,8 @@
package org.drools;
-public class StockTick {
+import java.io.Serializable;
+
+public class StockTick implements Serializable {
private long seq;
private String company;
private double price;
@@ -58,7 +60,7 @@
public void setTime(long time) {
this.time = time;
}
-
+
public String toString() {
return "StockTick( "+this.seq+" : " +this.company +" : "+ this.price +" )";
}
Modified: labs/jbossrules/branches/temporal_rete/drools-compiler/src/test/java/org/drools/TestParam.java
===================================================================
--- labs/jbossrules/branches/temporal_rete/drools-compiler/src/test/java/org/drools/TestParam.java 2008-03-20 18:57:07 UTC (rev 19163)
+++ labs/jbossrules/branches/temporal_rete/drools-compiler/src/test/java/org/drools/TestParam.java 2008-03-20 19:32:10 UTC (rev 19164)
@@ -1,7 +1,9 @@
package org.drools;
-public class TestParam {
+import java.io.Serializable;
+public class TestParam implements Serializable {
+
private String value1;
private String value2;
Modified: labs/jbossrules/branches/temporal_rete/drools-compiler/src/test/java/org/drools/bpel/instance/BPELProcessInstanceFactory.java
===================================================================
--- labs/jbossrules/branches/temporal_rete/drools-compiler/src/test/java/org/drools/bpel/instance/BPELProcessInstanceFactory.java 2008-03-20 18:57:07 UTC (rev 19163)
+++ labs/jbossrules/branches/temporal_rete/drools-compiler/src/test/java/org/drools/bpel/instance/BPELProcessInstanceFactory.java 2008-03-20 19:32:10 UTC (rev 19164)
@@ -1,18 +1,26 @@
package org.drools.bpel.instance;
-import java.io.Serializable;
+import java.io.Externalizable;
+import java.io.ObjectOutput;
+import java.io.IOException;
+import java.io.ObjectInput;
import org.drools.process.instance.ProcessInstance;
import org.drools.process.instance.ProcessInstanceFactory;
-public class BPELProcessInstanceFactory implements ProcessInstanceFactory, Serializable {
+public class BPELProcessInstanceFactory implements ProcessInstanceFactory, Externalizable {
private static final long serialVersionUID = 400L;
public ProcessInstance createProcessInstance() {
return new BPELProcessInstance();
}
-
-
+ public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
+ }
+
+ public void writeExternal(ObjectOutput out) throws IOException {
+ }
+
+
}
Modified: labs/jbossrules/branches/temporal_rete/drools-compiler/src/test/java/org/drools/brms/client/modeldriven/SuggestionCompletionEngineTest.java
===================================================================
--- labs/jbossrules/branches/temporal_rete/drools-compiler/src/test/java/org/drools/brms/client/modeldriven/SuggestionCompletionEngineTest.java 2008-03-20 18:57:07 UTC (rev 19163)
+++ labs/jbossrules/branches/temporal_rete/drools-compiler/src/test/java/org/drools/brms/client/modeldriven/SuggestionCompletionEngineTest.java 2008-03-20 19:32:10 UTC (rev 19164)
@@ -273,6 +273,16 @@
}
+ public void testSimpleEnums() {
+ final SuggestionCompletionEngine sce = new SuggestionCompletionEngine();
+ sce.dataEnumLists = new HashMap();
+ sce.dataEnumLists.put("Fact.type", new String[] {"sex", "colour"});
+ assertEquals(2, sce.getEnumValues("Fact", "type").length);
+ assertEquals("sex", sce.getEnumValues("Fact", "type")[0]);
+ assertEquals("colour", sce.getEnumValues("Fact", "type")[1]);
+
+ }
+
private void assertContains(final String string,
final String[] c) {
Modified: labs/jbossrules/branches/temporal_rete/drools-compiler/src/test/java/org/drools/brms/modeldriven/DataEnumLoaderTest.java
===================================================================
--- labs/jbossrules/branches/temporal_rete/drools-compiler/src/test/java/org/drools/brms/modeldriven/DataEnumLoaderTest.java 2008-03-20 18:57:07 UTC (rev 19163)
+++ labs/jbossrules/branches/temporal_rete/drools-compiler/src/test/java/org/drools/brms/modeldriven/DataEnumLoaderTest.java 2008-03-20 19:32:10 UTC (rev 19164)
@@ -6,7 +6,6 @@
import java.util.HashMap;
import java.util.List;
import java.util.Map;
-import java.util.StringTokenizer;
import junit.framework.TestCase;
Copied: labs/jbossrules/branches/temporal_rete/drools-compiler/src/test/java/org/drools/brms/modeldriven/dt (from rev 19160, labs/jbossrules/dev_tags/before_righttuple_merge_20080320/drools-compiler/src/test/java/org/drools/brms/modeldriven/dt)
Deleted: labs/jbossrules/branches/temporal_rete/drools-compiler/src/test/java/org/drools/brms/modeldriven/dt/GuidedDecisionTableTest.java
===================================================================
--- labs/jbossrules/dev_tags/before_righttuple_merge_20080320/drools-compiler/src/test/java/org/drools/brms/modeldriven/dt/GuidedDecisionTableTest.java 2008-03-20 15:24:55 UTC (rev 19160)
+++ labs/jbossrules/branches/temporal_rete/drools-compiler/src/test/java/org/drools/brms/modeldriven/dt/GuidedDecisionTableTest.java 2008-03-20 19:32:10 UTC (rev 19164)
@@ -1,272 +0,0 @@
-package org.drools.brms.modeldriven.dt;
-
-import java.util.HashMap;
-
-import junit.framework.TestCase;
-
-import org.drools.brms.client.modeldriven.SuggestionCompletionEngine;
-import org.drools.brms.client.modeldriven.brl.ISingleFieldConstraint;
-import org.drools.brms.client.modeldriven.dt.ActionInsertFactCol;
-import org.drools.brms.client.modeldriven.dt.ActionSetFieldCol;
-import org.drools.brms.client.modeldriven.dt.AttributeCol;
-import org.drools.brms.client.modeldriven.dt.ConditionCol;
-import org.drools.brms.client.modeldriven.dt.GuidedDecisionTable;
-
-public class GuidedDecisionTableTest extends TestCase {
-
-// public void testGetCol() {
-// GuidedDecisionTable dt = new GuidedDecisionTable();
-// AttributeCol at1 = new AttributeCol();
-// ConditionCol condition1 = new ConditionCol();
-// ActionCol action1 = new ActionInsertFactCol();
-// dt.attributeCols.add(at1);
-// dt.conditionCols.add(condition1);
-// dt.actionCols.add(action1);
-//
-// assertEquals(at1, dt.getColumnConfiguration(0));
-// assertEquals(condition1, dt.getColumnConfiguration(1));
-// assertEquals(action1, dt.getColumnConfiguration(2));
-//
-//
-// AttributeCol at2 = new AttributeCol();
-// dt.attributeCols.add(at2);
-// assertEquals(at1, dt.getColumnConfiguration(0));
-// assertEquals(at2, dt.getColumnConfiguration(1));
-// assertEquals(condition1, dt.getColumnConfiguration(2));
-// assertEquals(action1, dt.getColumnConfiguration(3));
-//
-// ConditionCol condition2 = new ConditionCol();
-// dt.conditionCols.add(condition2);
-//
-// assertEquals(at1, dt.getColumnConfiguration(0));
-// assertEquals(at2, dt.getColumnConfiguration(1));
-// assertEquals(condition1, dt.getColumnConfiguration(2));
-// assertEquals(condition2, dt.getColumnConfiguration(3));
-// assertEquals(action1, dt.getColumnConfiguration(4));
-//
-// ActionCol action2 = new ActionInsertFactCol();
-// dt.actionCols.add(action2);
-// assertEquals(at1, dt.getColumnConfiguration(0));
-// assertEquals(at2, dt.getColumnConfiguration(1));
-// assertEquals(condition1, dt.getColumnConfiguration(2));
-// assertEquals(condition2, dt.getColumnConfiguration(3));
-// assertEquals(action1, dt.getColumnConfiguration(4));
-// assertEquals(action2, dt.getColumnConfiguration(5));
-//
-//
-//
-// dt.attributeCols = new ArrayList();
-// assertEquals(condition1, dt.getColumnConfiguration(0));
-// assertEquals(condition2, dt.getColumnConfiguration(1));
-// assertEquals(action1, dt.getColumnConfiguration(2));
-// assertEquals(action2, dt.getColumnConfiguration(3));
-//
-// dt.conditionCols = new ArrayList();
-// assertEquals(action1, dt.getColumnConfiguration(0));
-// assertEquals(action2, dt.getColumnConfiguration(1));
-//
-//
-//
-//
-//
-//
-// }
-
- public void testValueLists() {
- GuidedDecisionTable dt = new GuidedDecisionTable();
-
- //add cols for LHS
- ConditionCol c1 = new ConditionCol();
- c1.boundName = "c1";
- c1.factType = "Driver";
- c1.factField = "name";
- c1.constraintValueType = ISingleFieldConstraint.TYPE_LITERAL;
- dt.conditionCols.add(c1);
-
- ConditionCol c1_ = new ConditionCol();
- c1_.boundName = "c1";
- c1_.factType = "Driver";
- c1_.factField = "name";
- c1_.constraintValueType = ISingleFieldConstraint.TYPE_RET_VALUE;
-
- dt.conditionCols.add(c1_);
-
- ConditionCol c1__ = new ConditionCol();
- c1__.boundName = "c1";
- c1__.factType = "Driver";
- c1__.factField = "name";
- c1__.constraintValueType = ISingleFieldConstraint.TYPE_LITERAL;
- c1__.valueList = "one,two,three";
- dt.conditionCols.add(c1__);
-
- ConditionCol c2 = new ConditionCol();
- c2.boundName = "c2";
- c2.factType = "Driver";
- c2.factField = "nothing";
- c2.constraintValueType = ISingleFieldConstraint.TYPE_LITERAL;
- dt.conditionCols.add(c2);
-
-
- ActionSetFieldCol asf = new ActionSetFieldCol();
- asf.boundName = "c1";
- asf.factField = "name";
- dt.actionCols.add(asf);
-
- ActionInsertFactCol ins = new ActionInsertFactCol();
- ins.boundName = "x";
- ins.factField = "rating";
- ins.factType = "Person";
- dt.actionCols.add(ins);
-
- ActionInsertFactCol ins_ = new ActionInsertFactCol();
- ins_.boundName = "x";
- ins_.factField = "rating";
- ins_.factType = "Person";
- ins_.valueList = "one,two,three";
- dt.actionCols.add(ins_);
-
- ActionSetFieldCol asf_ = new ActionSetFieldCol();
- asf_.boundName = "c1";
- asf_.factField = "goo";
- dt.actionCols.add(asf_);
-
- ActionSetFieldCol asf__ = new ActionSetFieldCol();
- asf__.boundName = "c1";
- asf__.factField = "goo";
- asf__.valueList = "one,two,three";
- dt.actionCols.add(asf__);
-
-
- SuggestionCompletionEngine sce = new SuggestionCompletionEngine();
- sce.dataEnumLists.put("Driver.name", new String[] {"bob", "michael"});
- sce.dataEnumLists.put("Person.rating", new String[] {"1", "2"});
-
-
-
-
- String[] r = dt.getValueList(c1, sce);
- assertEquals(2, r.length);
- assertEquals("bob", r[0]);
- assertEquals("michael", r[1]);
-
- assertEquals(0, dt.getValueList(c1_, sce).length);
-
- r = dt.getValueList(c1__, sce);
- assertEquals(3, r.length);
- assertEquals("one", r[0]);
- assertEquals("two", r[1]);
- assertEquals("three", r[2]);
-
- assertEquals(0, dt.getValueList(c2, sce).length);
-
- r = dt.getValueList(asf, sce);
- assertEquals(2, r.length);
- assertEquals("bob", r[0]);
- assertEquals("michael", r[1]);
-
- r = dt.getValueList(ins, sce);
- assertEquals(2, r.length);
- assertEquals("1", r[0]);
- assertEquals("2", r[1]);
-
- r = dt.getValueList(ins_, sce);
- assertEquals(3, r.length);
- assertEquals("one", r[0]);
- assertEquals("two", r[1]);
- assertEquals("three", r[2]);
-
- assertEquals(0, dt.getValueList(asf_, sce).length);
-
-
- r = dt.getValueList(asf__, sce);
- assertEquals(3, r.length);
- assertEquals("one", r[0]);
- assertEquals("two", r[1]);
- assertEquals("three", r[2]);
-
- AttributeCol at = new AttributeCol();
- at.attr = "no-loop";
- dt.attributeCols.add(at);
-
- r = dt.getValueList(at, sce);
- assertEquals(2, r.length);
- assertEquals("true", r[0]);
- assertEquals("false", r[1]);
-
- at.attr = "enabled";
- assertEquals(2, dt.getValueList(at, sce).length);
-
- at.attr = "salience";
- assertEquals(0, dt.getValueList(at, sce).length);
-
- }
-
-
- public void testNumeric() {
- SuggestionCompletionEngine sce = new SuggestionCompletionEngine();
- sce.fieldTypes = new HashMap();
- sce.fieldTypes.put("Driver.age", SuggestionCompletionEngine.TYPE_NUMERIC);
- sce.fieldTypes.put("Driver.name", SuggestionCompletionEngine.TYPE_STRING);
-
- GuidedDecisionTable dt = new GuidedDecisionTable();
-
- AttributeCol at = new AttributeCol();
- at.attr = "salience";
- AttributeCol at_ = new AttributeCol();
- at_.attr = "enabled";
-
- dt.attributeCols.add(at);
- dt.attributeCols.add(at_);
-
- ConditionCol c1 = new ConditionCol();
- c1.boundName = "c1";
- c1.factType = "Driver";
- c1.factField = "name";
- c1.constraintValueType = ISingleFieldConstraint.TYPE_LITERAL;
- dt.conditionCols.add(c1);
-
- ConditionCol c1_ = new ConditionCol();
- c1_.boundName = "c1";
- c1_.factType = "Driver";
- c1_.factField = "age";
- c1_.constraintValueType = ISingleFieldConstraint.TYPE_LITERAL;
- dt.conditionCols.add(c1_);
-
- ActionSetFieldCol a = new ActionSetFieldCol();
- a.boundName = "c1";
- a.factField = "name";
- dt.actionCols.add(a);
-
- ActionSetFieldCol a2 = new ActionSetFieldCol();
- a2.boundName = "c1";
- a2.factField = "age";
- dt.actionCols.add(a2);
-
- ActionInsertFactCol ins = new ActionInsertFactCol();
- ins.boundName = "x";
- ins.factType = "Driver";
- ins.factField = "name";
- dt.actionCols.add(ins);
-
- ActionInsertFactCol ins_ = new ActionInsertFactCol();
- ins_.boundName = "x";
- ins_.factType = "Driver";
- ins_.factField = "age";
- dt.actionCols.add(ins_);
-
- assertTrue(dt.isNumeric(at, sce));
- assertFalse(dt.isNumeric(at_, sce));
- assertFalse(dt.isNumeric(c1, sce));
- assertTrue(dt.isNumeric(c1_, sce));
- assertFalse(dt.isNumeric(a, sce));
- assertTrue(dt.isNumeric(a2, sce));
- assertFalse(dt.isNumeric(ins, sce));
- assertTrue(dt.isNumeric(ins_, sce));
-
-
-
-
- }
-
-
-}
Copied: labs/jbossrules/branches/temporal_rete/drools-compiler/src/test/java/org/drools/brms/modeldriven/dt/GuidedDecisionTableTest.java (from rev 19160, labs/jbossrules/dev_tags/before_righttuple_merge_20080320/drools-compiler/src/test/java/org/drools/brms/modeldriven/dt/GuidedDecisionTableTest.java)
===================================================================
--- labs/jbossrules/branches/temporal_rete/drools-compiler/src/test/java/org/drools/brms/modeldriven/dt/GuidedDecisionTableTest.java (rev 0)
+++ labs/jbossrules/branches/temporal_rete/drools-compiler/src/test/java/org/drools/brms/modeldriven/dt/GuidedDecisionTableTest.java 2008-03-20 19:32:10 UTC (rev 19164)
@@ -0,0 +1,272 @@
+package org.drools.brms.modeldriven.dt;
+
+import java.util.HashMap;
+
+import junit.framework.TestCase;
+
+import org.drools.brms.client.modeldriven.SuggestionCompletionEngine;
+import org.drools.brms.client.modeldriven.brl.ISingleFieldConstraint;
+import org.drools.brms.client.modeldriven.dt.ActionInsertFactCol;
+import org.drools.brms.client.modeldriven.dt.ActionSetFieldCol;
+import org.drools.brms.client.modeldriven.dt.AttributeCol;
+import org.drools.brms.client.modeldriven.dt.ConditionCol;
+import org.drools.brms.client.modeldriven.dt.GuidedDecisionTable;
+
+public class GuidedDecisionTableTest extends TestCase {
+
+// public void testGetCol() {
+// GuidedDecisionTable dt = new GuidedDecisionTable();
+// AttributeCol at1 = new AttributeCol();
+// ConditionCol condition1 = new ConditionCol();
+// ActionCol action1 = new ActionInsertFactCol();
+// dt.attributeCols.add(at1);
+// dt.conditionCols.add(condition1);
+// dt.actionCols.add(action1);
+//
+// assertEquals(at1, dt.getColumnConfiguration(0));
+// assertEquals(condition1, dt.getColumnConfiguration(1));
+// assertEquals(action1, dt.getColumnConfiguration(2));
+//
+//
+// AttributeCol at2 = new AttributeCol();
+// dt.attributeCols.add(at2);
+// assertEquals(at1, dt.getColumnConfiguration(0));
+// assertEquals(at2, dt.getColumnConfiguration(1));
+// assertEquals(condition1, dt.getColumnConfiguration(2));
+// assertEquals(action1, dt.getColumnConfiguration(3));
+//
+// ConditionCol condition2 = new ConditionCol();
+// dt.conditionCols.add(condition2);
+//
+// assertEquals(at1, dt.getColumnConfiguration(0));
+// assertEquals(at2, dt.getColumnConfiguration(1));
+// assertEquals(condition1, dt.getColumnConfiguration(2));
+// assertEquals(condition2, dt.getColumnConfiguration(3));
+// assertEquals(action1, dt.getColumnConfiguration(4));
+//
+// ActionCol action2 = new ActionInsertFactCol();
+// dt.actionCols.add(action2);
+// assertEquals(at1, dt.getColumnConfiguration(0));
+// assertEquals(at2, dt.getColumnConfiguration(1));
+// assertEquals(condition1, dt.getColumnConfiguration(2));
+// assertEquals(condition2, dt.getColumnConfiguration(3));
+// assertEquals(action1, dt.getColumnConfiguration(4));
+// assertEquals(action2, dt.getColumnConfiguration(5));
+//
+//
+//
+// dt.attributeCols = new ArrayList();
+// assertEquals(condition1, dt.getColumnConfiguration(0));
+// assertEquals(condition2, dt.getColumnConfiguration(1));
+// assertEquals(action1, dt.getColumnConfiguration(2));
+// assertEquals(action2, dt.getColumnConfiguration(3));
+//
+// dt.conditionCols = new ArrayList();
+// assertEquals(action1, dt.getColumnConfiguration(0));
+// assertEquals(action2, dt.getColumnConfiguration(1));
+//
+//
+//
+//
+//
+//
+// }
+
+ public void testValueLists() {
+ GuidedDecisionTable dt = new GuidedDecisionTable();
+
+ //add cols for LHS
+ ConditionCol c1 = new ConditionCol();
+ c1.boundName = "c1";
+ c1.factType = "Driver";
+ c1.factField = "name";
+ c1.constraintValueType = ISingleFieldConstraint.TYPE_LITERAL;
+ dt.conditionCols.add(c1);
+
+ ConditionCol c1_ = new ConditionCol();
+ c1_.boundName = "c1";
+ c1_.factType = "Driver";
+ c1_.factField = "name";
+ c1_.constraintValueType = ISingleFieldConstraint.TYPE_RET_VALUE;
+
+ dt.conditionCols.add(c1_);
+
+ ConditionCol c1__ = new ConditionCol();
+ c1__.boundName = "c1";
+ c1__.factType = "Driver";
+ c1__.factField = "name";
+ c1__.constraintValueType = ISingleFieldConstraint.TYPE_LITERAL;
+ c1__.valueList = "one,two,three";
+ dt.conditionCols.add(c1__);
+
+ ConditionCol c2 = new ConditionCol();
+ c2.boundName = "c2";
+ c2.factType = "Driver";
+ c2.factField = "nothing";
+ c2.constraintValueType = ISingleFieldConstraint.TYPE_LITERAL;
+ dt.conditionCols.add(c2);
+
+
+ ActionSetFieldCol asf = new ActionSetFieldCol();
+ asf.boundName = "c1";
+ asf.factField = "name";
+ dt.actionCols.add(asf);
+
+ ActionInsertFactCol ins = new ActionInsertFactCol();
+ ins.boundName = "x";
+ ins.factField = "rating";
+ ins.factType = "Person";
+ dt.actionCols.add(ins);
+
+ ActionInsertFactCol ins_ = new ActionInsertFactCol();
+ ins_.boundName = "x";
+ ins_.factField = "rating";
+ ins_.factType = "Person";
+ ins_.valueList = "one,two,three";
+ dt.actionCols.add(ins_);
+
+ ActionSetFieldCol asf_ = new ActionSetFieldCol();
+ asf_.boundName = "c1";
+ asf_.factField = "goo";
+ dt.actionCols.add(asf_);
+
+ ActionSetFieldCol asf__ = new ActionSetFieldCol();
+ asf__.boundName = "c1";
+ asf__.factField = "goo";
+ asf__.valueList = "one,two,three";
+ dt.actionCols.add(asf__);
+
+
+ SuggestionCompletionEngine sce = new SuggestionCompletionEngine();
+ sce.dataEnumLists.put("Driver.name", new String[] {"bob", "michael"});
+ sce.dataEnumLists.put("Person.rating", new String[] {"1", "2"});
+
+
+
+
+ String[] r = dt.getValueList(c1, sce);
+ assertEquals(2, r.length);
+ assertEquals("bob", r[0]);
+ assertEquals("michael", r[1]);
+
+ assertEquals(0, dt.getValueList(c1_, sce).length);
+
+ r = dt.getValueList(c1__, sce);
+ assertEquals(3, r.length);
+ assertEquals("one", r[0]);
+ assertEquals("two", r[1]);
+ assertEquals("three", r[2]);
+
+ assertEquals(0, dt.getValueList(c2, sce).length);
+
+ r = dt.getValueList(asf, sce);
+ assertEquals(2, r.length);
+ assertEquals("bob", r[0]);
+ assertEquals("michael", r[1]);
+
+ r = dt.getValueList(ins, sce);
+ assertEquals(2, r.length);
+ assertEquals("1", r[0]);
+ assertEquals("2", r[1]);
+
+ r = dt.getValueList(ins_, sce);
+ assertEquals(3, r.length);
+ assertEquals("one", r[0]);
+ assertEquals("two", r[1]);
+ assertEquals("three", r[2]);
+
+ assertEquals(0, dt.getValueList(asf_, sce).length);
+
+
+ r = dt.getValueList(asf__, sce);
+ assertEquals(3, r.length);
+ assertEquals("one", r[0]);
+ assertEquals("two", r[1]);
+ assertEquals("three", r[2]);
+
+ AttributeCol at = new AttributeCol();
+ at.attr = "no-loop";
+ dt.attributeCols.add(at);
+
+ r = dt.getValueList(at, sce);
+ assertEquals(2, r.length);
+ assertEquals("true", r[0]);
+ assertEquals("false", r[1]);
+
+ at.attr = "enabled";
+ assertEquals(2, dt.getValueList(at, sce).length);
+
+ at.attr = "salience";
+ assertEquals(0, dt.getValueList(at, sce).length);
+
+ }
+
+
+ public void testNumeric() {
+ SuggestionCompletionEngine sce = new SuggestionCompletionEngine();
+ sce.fieldTypes = new HashMap();
+ sce.fieldTypes.put("Driver.age", SuggestionCompletionEngine.TYPE_NUMERIC);
+ sce.fieldTypes.put("Driver.name", SuggestionCompletionEngine.TYPE_STRING);
+
+ GuidedDecisionTable dt = new GuidedDecisionTable();
+
+ AttributeCol at = new AttributeCol();
+ at.attr = "salience";
+ AttributeCol at_ = new AttributeCol();
+ at_.attr = "enabled";
+
+ dt.attributeCols.add(at);
+ dt.attributeCols.add(at_);
+
+ ConditionCol c1 = new ConditionCol();
+ c1.boundName = "c1";
+ c1.factType = "Driver";
+ c1.factField = "name";
+ c1.constraintValueType = ISingleFieldConstraint.TYPE_LITERAL;
+ dt.conditionCols.add(c1);
+
+ ConditionCol c1_ = new ConditionCol();
+ c1_.boundName = "c1";
+ c1_.factType = "Driver";
+ c1_.factField = "age";
+ c1_.constraintValueType = ISingleFieldConstraint.TYPE_LITERAL;
+ dt.conditionCols.add(c1_);
+
+ ActionSetFieldCol a = new ActionSetFieldCol();
+ a.boundName = "c1";
+ a.factField = "name";
+ dt.actionCols.add(a);
+
+ ActionSetFieldCol a2 = new ActionSetFieldCol();
+ a2.boundName = "c1";
+ a2.factField = "age";
+ dt.actionCols.add(a2);
+
+ ActionInsertFactCol ins = new ActionInsertFactCol();
+ ins.boundName = "x";
+ ins.factType = "Driver";
+ ins.factField = "name";
+ dt.actionCols.add(ins);
+
+ ActionInsertFactCol ins_ = new ActionInsertFactCol();
+ ins_.boundName = "x";
+ ins_.factType = "Driver";
+ ins_.factField = "age";
+ dt.actionCols.add(ins_);
+
+ assertTrue(dt.isNumeric(at, sce));
+ assertFalse(dt.isNumeric(at_, sce));
+ assertFalse(dt.isNumeric(c1, sce));
+ assertTrue(dt.isNumeric(c1_, sce));
+ assertFalse(dt.isNumeric(a, sce));
+ assertTrue(dt.isNumeric(a2, sce));
+ assertFalse(dt.isNumeric(ins, sce));
+ assertTrue(dt.isNumeric(ins_, sce));
+
+
+
+
+ }
+
+
+}
Modified: labs/jbossrules/branches/temporal_rete/drools-compiler/src/test/java/org/drools/brms/server/util/BRLPersitenceTest.java
===================================================================
--- labs/jbossrules/branches/temporal_rete/drools-compiler/src/test/java/org/drools/brms/server/util/BRLPersitenceTest.java 2008-03-20 18:57:07 UTC (rev 19163)
+++ labs/jbossrules/branches/temporal_rete/drools-compiler/src/test/java/org/drools/brms/server/util/BRLPersitenceTest.java 2008-03-20 19:32:10 UTC (rev 19164)
@@ -90,21 +90,21 @@
newXML );
}
-
+
public void testCompositeConstraintsRoundTrip() throws Exception {
RuleModel m = new RuleModel();
m.name = "with composite";
-
+
FactPattern p1 = new FactPattern("Person");
p1.boundName = "p1";
m.addLhsItem( p1 );
-
+
FactPattern p = new FactPattern("Goober");
m.addLhsItem( p );
CompositeFieldConstraint comp = new CompositeFieldConstraint();
comp.compositeJunctionType = CompositeFieldConstraint.COMPOSITE_TYPE_OR;
p.addConstraint( comp );
-
+
final SingleFieldConstraint X = new SingleFieldConstraint();
X.fieldName = "goo";
X.constraintValueType = SingleFieldConstraint.TYPE_LITERAL;
@@ -116,7 +116,7 @@
X.connectives[0].operator = "|| ==";
X.connectives[0].value = "bar";
comp.addConstraint( X );
-
+
final SingleFieldConstraint Y = new SingleFieldConstraint();
Y.fieldName = "goo2";
Y.constraintValueType = SingleFieldConstraint.TYPE_LITERAL;
@@ -131,47 +131,47 @@
Q1.operator = "==";
Q1.value = "whee";
Q1.constraintValueType = ISingleFieldConstraint.TYPE_LITERAL;
-
+
comp2.addConstraint( Q1 );
-
+
final SingleFieldConstraint Q2 = new SingleFieldConstraint();
Q2.fieldName = "gabba";
Q2.operator = "==";
Q2.value = "whee";
Q2.constraintValueType = ISingleFieldConstraint.TYPE_LITERAL;
-
+
comp2.addConstraint( Q2 );
-
+
//now nest it
comp.addConstraint( comp2 );
-
-
-
+
+
+
final SingleFieldConstraint Z = new SingleFieldConstraint();
Z.fieldName = "goo3";
Z.constraintValueType = SingleFieldConstraint.TYPE_LITERAL;
Z.value = "foo";
Z.operator = "==";
-
+
p.addConstraint( Z );
-
+
ActionInsertFact ass = new ActionInsertFact("Whee");
m.addRhsItem( ass );
-
+
String xml = BRXMLPersistence.getInstance().marshal( m );
//System.err.println(xml);
-
+
RuleModel m2 = BRXMLPersistence.getInstance().unmarshal( xml );
assertNotNull(m2);
assertEquals("with composite", m2.name);
-
+
assertEquals(m2.lhs.length, m.lhs.length);
assertEquals(m2.rhs.length, m.rhs.length);
-
-
-
-
+
+
+
+
}
/**
@@ -180,17 +180,17 @@
*/
public void testBackwardsCompat() throws Exception {
RuleModel m2 = BRXMLPersistence.getInstance().unmarshal( loadResource( "existing_brl.xml" ) );
-
+
assertNotNull(m2);
assertEquals(3, m2.rhs.length);
}
-
+
private String loadResource(final String name) throws Exception {
// System.err.println( getClass().getResource( name ) );
final InputStream in = getClass().getResourceAsStream( name );
-
+
final Reader reader = new InputStreamReader( in );
final StringBuffer text = new StringBuffer();
@@ -205,7 +205,7 @@
}
return text.toString();
- }
+ }
private RuleModel getComplexModel() {
final RuleModel m = new RuleModel();
Modified: labs/jbossrules/branches/temporal_rete/drools-compiler/src/test/java/org/drools/compiler/PackageBuilderConfigurationTest.java
===================================================================
--- labs/jbossrules/branches/temporal_rete/drools-compiler/src/test/java/org/drools/compiler/PackageBuilderConfigurationTest.java 2008-03-20 18:57:07 UTC (rev 19163)
+++ labs/jbossrules/branches/temporal_rete/drools-compiler/src/test/java/org/drools/compiler/PackageBuilderConfigurationTest.java 2008-03-20 19:32:10 UTC (rev 19164)
@@ -42,9 +42,7 @@
import org.drools.rule.builder.RuleClassBuilder;
import org.drools.rule.builder.RuleConditionBuilder;
import org.drools.rule.builder.SalienceBuilder;
-import org.drools.rule.builder.dialect.java.JavaDialect;
import org.drools.rule.builder.dialect.java.JavaDialectConfiguration;
-import org.drools.rule.builder.dialect.mvel.MVELDialect;
import org.drools.util.ChainedProperties;
public class PackageBuilderConfigurationTest extends TestCase {
Modified: labs/jbossrules/branches/temporal_rete/drools-compiler/src/test/java/org/drools/compiler/PackageBuilderTest.java
===================================================================
--- labs/jbossrules/branches/temporal_rete/drools-compiler/src/test/java/org/drools/compiler/PackageBuilderTest.java 2008-03-20 18:57:07 UTC (rev 19163)
+++ labs/jbossrules/branches/temporal_rete/drools-compiler/src/test/java/org/drools/compiler/PackageBuilderTest.java 2008-03-20 19:32:10 UTC (rev 19164)
@@ -2,13 +2,13 @@
/*
* Copyright 2005 JBoss Inc
- *
+ *
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -18,13 +18,10 @@
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
-import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.ObjectInput;
-import java.io.ObjectInputStream;
import java.io.ObjectOutput;
-import java.io.ObjectOutputStream;
import java.io.StringReader;
import java.lang.reflect.Field;
import java.util.HashMap;
@@ -44,6 +41,7 @@
import org.drools.base.DefaultKnowledgeHelper;
import org.drools.common.ActivationGroupNode;
import org.drools.common.DroolsObjectInputStream;
+import org.drools.common.DroolsObjectOutputStream;
import org.drools.common.InternalFactHandle;
import org.drools.common.LogicalDependency;
import org.drools.common.RuleFlowGroupNode;
@@ -51,6 +49,7 @@
import org.drools.commons.jci.compilers.JaninoJavaCompiler;
import org.drools.commons.jci.compilers.JavaCompiler;
import org.drools.facttemplates.Fact;
+import org.drools.integrationtests.SerializationHelper;
import org.drools.lang.descr.AndDescr;
import org.drools.lang.descr.BaseDescr;
import org.drools.lang.descr.ConditionalElementDescr;
@@ -227,8 +226,7 @@
ruleDescr.setConsequence( "map.put(\"value\", new Integer(1) );" );
//check that packageDescr is serializable
- final byte[] ast = serializeOut( packageDescr );
- final PackageDescr back = (PackageDescr) serializeIn( ast );
+ final PackageDescr back = (PackageDescr) SerializationHelper.serializeObject( packageDescr );
assertNotNull( back );
assertEquals( "p1",
back.getName() );
@@ -240,12 +238,8 @@
assertLength( 0,
builder.getErrors().getErrors() );
- final byte[] bytes = serializeOut( pkg );
+ final Package newPkg = SerializationHelper.serializeObject( pkg );
- // Deserialize from a byte array
-
- final Package newPkg = (Package) serializeIn( bytes );
-
final Rule newRule = newPkg.getRule( "rule-1" );
final ReteooRuleBase ruleBase = (ReteooRuleBase) RuleBaseFactory.newRuleBase();
@@ -273,26 +267,6 @@
map.get( "value" ) );
}
- private Object serializeIn(final byte[] bytes) throws IOException,
- ClassNotFoundException {
- final ObjectInput in = new DroolsObjectInputStream( new ByteArrayInputStream( bytes ) );
- final Object obj = in.readObject();
- in.close();
- return obj;
- }
-
- private byte[] serializeOut(final Object obj) throws IOException {
- // Serialize to a byte array
- final ByteArrayOutputStream bos = new ByteArrayOutputStream();
- final ObjectOutput out = new ObjectOutputStream( bos );
- out.writeObject( obj );
- out.close();
-
- // Get the bytes of the serialized object
- final byte[] bytes = bos.toByteArray();
- return bytes;
- }
-
public void testNoPackageName() throws Exception {
final PackageBuilder builder = new PackageBuilder();
try {
@@ -1240,10 +1214,10 @@
//now serialization
ByteArrayOutputStream data = new ByteArrayOutputStream();
- ObjectOutputStream out = new ObjectOutputStream( data );
+ ObjectOutput out = new DroolsObjectOutputStream( data );
out.writeObject( pkg );
- ObjectInputStream objIn = new DroolsObjectInputStream( new ByteArrayInputStream( data.toByteArray() ) );
+ ObjectInput objIn = new DroolsObjectInputStream( new ByteArrayInputStream( data.toByteArray() ) );
Package pkg2 = (Package) objIn.readObject();
assertNotNull( pkg2 );
@@ -1291,9 +1265,9 @@
bldr.addPackageFromDrl( new StringReader( "function void doSomething() {\n System.err.println(List.class.toString()); }" ) );
assertFalse( bldr.hasErrors() );
-
}
+
class MockRuleFlow
implements
Process {
Modified: labs/jbossrules/branches/temporal_rete/drools-compiler/src/test/java/org/drools/compiler/RuleErrorTest.java
===================================================================
--- labs/jbossrules/branches/temporal_rete/drools-compiler/src/test/java/org/drools/compiler/RuleErrorTest.java 2008-03-20 18:57:07 UTC (rev 19163)
+++ labs/jbossrules/branches/temporal_rete/drools-compiler/src/test/java/org/drools/compiler/RuleErrorTest.java 2008-03-20 19:32:10 UTC (rev 19164)
@@ -1,12 +1,11 @@
package org.drools.compiler;
+import junit.framework.TestCase;
+
import org.drools.commons.jci.problems.CompilationProblem;
import org.drools.lang.descr.AndDescr;
import org.drools.lang.descr.RuleDescr;
-import org.drools.rule.Rule;
-import junit.framework.TestCase;
-
public class RuleErrorTest extends TestCase {
public void testNewLineInMessage() {
Modified: labs/jbossrules/branches/temporal_rete/drools-compiler/src/test/java/org/drools/integrationtests/CepEspTest.java
===================================================================
--- labs/jbossrules/branches/temporal_rete/drools-compiler/src/test/java/org/drools/integrationtests/CepEspTest.java 2008-03-20 18:57:07 UTC (rev 19163)
+++ labs/jbossrules/branches/temporal_rete/drools-compiler/src/test/java/org/drools/integrationtests/CepEspTest.java 2008-03-20 19:32:10 UTC (rev 19164)
@@ -54,18 +54,19 @@
final Package pkg = builder.getPackage();
// add the package to a rulebase
- final RuleBase ruleBase = getRuleBase();
+ RuleBase ruleBase = getRuleBase();
ruleBase.addPackage( pkg );
// load up the rulebase
+ ruleBase = SerializationHelper.serializeObject(ruleBase);
return ruleBase;
}
public void testEventAssertion() throws Exception {
// read in the source
final Reader reader = new InputStreamReader( getClass().getResourceAsStream( "test_CEP_SimpleEventAssertion.drl" ) );
- final RuleBase ruleBase = loadRuleBase( reader );
+ RuleBase ruleBase = loadRuleBase( reader );
- final WorkingMemory wm = ruleBase.newTemporalSession( ClockType.PSEUDO_CLOCK );
+ WorkingMemory wm = ruleBase.newTemporalSession( ClockType.PSEUDO_CLOCK );
final List results = new ArrayList();
wm.setGlobal( "results",
@@ -103,10 +104,11 @@
assertTrue( handle3.isEvent() );
assertTrue( handle4.isEvent() );
+ wm = SerializationHelper.serializeObject(wm);
wm.fireAllRules();
assertEquals( 2,
- results.size() );
+ ((List)wm.getGlobal("results")).size() );
}
@@ -179,7 +181,7 @@
final Reader reader = new InputStreamReader( getClass().getResourceAsStream( "test_CEP_TimeRelationalOperators.drl" ) );
final RuleBase ruleBase = loadRuleBase( reader );
- final TemporalSession<SessionPseudoClock> wm = ruleBase.newTemporalSession( ClockType.PSEUDO_CLOCK );
+ TemporalSession<SessionPseudoClock> wm = ruleBase.newTemporalSession( ClockType.PSEUDO_CLOCK );
final SessionPseudoClock clock = wm.getSessionClock();
clock.setStartupTime( 1000 );
@@ -296,6 +298,7 @@
assertTrue( handle7.isEvent() );
assertTrue( handle8.isEvent() );
+// wm = SerializationHelper.serializeObject(wm);
wm.fireAllRules();
assertEquals( 1,
@@ -375,7 +378,7 @@
final Reader reader = new InputStreamReader( getClass().getResourceAsStream( "test_CEP_SimpleTimeWindow.drl" ) );
final RuleBase ruleBase = loadRuleBase( reader );
- final TemporalSession<SessionPseudoClock> wm = ruleBase.newTemporalSession( ClockType.PSEUDO_CLOCK );
+ TemporalSession<SessionPseudoClock> wm = ruleBase.newTemporalSession( ClockType.PSEUDO_CLOCK );
final List results = new ArrayList();
wm.setGlobal( "results",
@@ -394,6 +397,7 @@
assertEquals( 0,
handle1.getDuration() );
+// wm = SerializationHelper.serializeObject(wm);
wm.fireAllRules();
clock.advanceTime( 10000 ); // 10 seconds
@@ -438,6 +442,7 @@
assertEquals( 0,
handle5.getDuration() );
+// wm = SerializationHelper.serializeObject(wm);
wm.fireAllRules();
clock.advanceTime( 10000 ); // 10 seconds
@@ -449,6 +454,7 @@
assertEquals( 0,
handle6.getDuration() );
+ wm = SerializationHelper.serializeObject(wm);
wm.fireAllRules();
}
Modified: labs/jbossrules/branches/temporal_rete/drools-compiler/src/test/java/org/drools/integrationtests/DslTest.java
===================================================================
--- labs/jbossrules/branches/temporal_rete/drools-compiler/src/test/java/org/drools/integrationtests/DslTest.java 2008-03-20 18:57:07 UTC (rev 19163)
+++ labs/jbossrules/branches/temporal_rete/drools-compiler/src/test/java/org/drools/integrationtests/DslTest.java 2008-03-20 19:32:10 UTC (rev 19164)
@@ -50,10 +50,11 @@
assertEquals( 0,
builder.getErrors().getErrors().length );
- final RuleBase ruleBase = getRuleBase();
+ RuleBase ruleBase = getRuleBase();
ruleBase.addPackage( pkg );
+ ruleBase = SerializationHelper.serializeObject(ruleBase);
- final WorkingMemory wm = ruleBase.newStatefulSession();
+ WorkingMemory wm = ruleBase.newStatefulSession();
wm.insert( new Person( "Bob",
"http://foo.bar" ) );
wm.insert( new Cheese( "stilton",
@@ -62,6 +63,7 @@
final List messages = new ArrayList();
wm.setGlobal( "messages",
messages );
+// wm = SerializationHelper.serializeObject(wm);
wm.fireAllRules();
// should have fired
@@ -89,10 +91,11 @@
assertEquals( 0,
builder.getErrors().getErrors().length );
- final RuleBase ruleBase = getRuleBase();
+ RuleBase ruleBase = getRuleBase();
ruleBase.addPackage( pkg );
+ ruleBase = SerializationHelper.serializeObject(ruleBase);
- final WorkingMemory wm = ruleBase.newStatefulSession();
+ WorkingMemory wm = ruleBase.newStatefulSession();
wm.insert( new Person( "rage" ) );
wm.insert( new Cheese( "cheddar",
15 ) );
@@ -100,6 +103,7 @@
final List messages = new ArrayList();
wm.setGlobal( "messages",
messages );
+// wm = SerializationHelper.serializeObject(wm);
wm.fireAllRules();
// should have NONE, as both conditions should be false.
@@ -131,8 +135,9 @@
builder.addPackageFromDrl( drlReader,
dslReader );
- final Package pkg = builder.getPackage();
+ Package pkg = builder.getPackage();
+ pkg = SerializationHelper.serializeObject(pkg);
assertFalse( pkg.isValid() );
}
@@ -154,10 +159,11 @@
assertEquals( 0,
builder.getErrors().getErrors().length );
- final RuleBase ruleBase = getRuleBase();
+ RuleBase ruleBase = getRuleBase();
ruleBase.addPackage( pkg );
+ ruleBase = SerializationHelper.serializeObject(ruleBase);
- final WorkingMemory wm = ruleBase.newStatefulSession();
+ WorkingMemory wm = ruleBase.newStatefulSession();
List results = new ArrayList();
wm.setGlobal( "results",
results );
@@ -165,6 +171,7 @@
42 );
wm.insert( cheese );
+// wm = SerializationHelper.serializeObject(wm);
wm.fireAllRules();
// should have fired
Modified: labs/jbossrules/branches/temporal_rete/drools-compiler/src/test/java/org/drools/integrationtests/DynamicRulesTest.java
===================================================================
--- labs/jbossrules/branches/temporal_rete/drools-compiler/src/test/java/org/drools/integrationtests/DynamicRulesTest.java 2008-03-20 18:57:07 UTC (rev 19163)
+++ labs/jbossrules/branches/temporal_rete/drools-compiler/src/test/java/org/drools/integrationtests/DynamicRulesTest.java 2008-03-20 19:32:10 UTC (rev 19164)
@@ -1,13 +1,6 @@
package org.drools.integrationtests;
-import java.io.ByteArrayInputStream;
-import java.io.ByteArrayOutputStream;
-import java.io.IOException;
import java.io.InputStreamReader;
-import java.io.ObjectInput;
-import java.io.ObjectInputStream;
-import java.io.ObjectOutput;
-import java.io.ObjectOutputStream;
import java.io.Reader;
import java.net.URL;
import java.net.URLClassLoader;
@@ -53,10 +46,11 @@
PackageBuilder builder = new PackageBuilder();
builder.addPackageFromDrl( reader );
- final Package pkg1 = serialisePackage( builder.getPackage() );
+ final Package pkg1 = SerializationHelper.serializeObject( builder.getPackage() );
- final RuleBase ruleBase = getRuleBase();
+ RuleBase ruleBase = getRuleBase();
ruleBase.addPackage( pkg1 );
+ ruleBase = SerializationHelper.serializeObject(ruleBase);
final WorkingMemory workingMemory = ruleBase.newStatefulSession();
workingMemory.setGlobal( "total",
new Integer( 0 ) );
@@ -91,9 +85,10 @@
reader = new InputStreamReader( getClass().getResourceAsStream( "test_Dynamic2.drl" ) );
builder = new PackageBuilder();
builder.addPackageFromDrl( reader );
- final Package pkg2 = serialisePackage( builder.getPackage() );
+ final Package pkg2 = SerializationHelper.serializeObject( builder.getPackage() );
ruleBase.addPackage( pkg2 );
+// ruleBase = SerializationHelper.serializeObject(ruleBase);
assertEquals( 3,
list.size() );
@@ -109,11 +104,12 @@
reader = new InputStreamReader( getClass().getResourceAsStream( "test_Dynamic3.drl" ) );
builder = new PackageBuilder();
builder.addPackageFromDrl( reader );
- final Package pkg3 = serialisePackage( builder.getPackage() );
+ final Package pkg3 = SerializationHelper.serializeObject( builder.getPackage() );
ruleBase.addPackage( pkg3 );
+// ruleBase = SerializationHelper.serializeObject(ruleBase);
// Package 3 has a rule working on Person instances.
- // As we added person instance in advance, rule should fire now
+ // As we added person instance in advance, rule should fire now
Assert.assertEquals( "Rule from package 3 should have been fired",
"match Person ok",
@@ -128,8 +124,9 @@
reader = new InputStreamReader( getClass().getResourceAsStream( "test_Dynamic4.drl" ) );
builder = new PackageBuilder();
builder.addPackageFromDrl( reader );
- final Package pkg4 = serialisePackage( builder.getPackage() );
+ final Package pkg4 = SerializationHelper.serializeObject( builder.getPackage() );
ruleBase.addPackage( pkg4 );
+ ruleBase = SerializationHelper.serializeObject(ruleBase);
Assert.assertEquals( "Rule from package 4 should have been fired",
"Who likes Stilton ok",
@@ -149,16 +146,18 @@
builder.addPackageFromDrl( new InputStreamReader( getClass().getResourceAsStream( "test_Dynamic1.drl" ) ) );
builder.addPackageFromDrl( new InputStreamReader( getClass().getResourceAsStream( "test_Dynamic3.drl" ) ) );
builder.addPackageFromDrl( new InputStreamReader( getClass().getResourceAsStream( "test_Dynamic4.drl" ) ) );
- final Package pkg = serialisePackage( builder.getPackage() );
+ final Package pkg = SerializationHelper.serializeObject( builder.getPackage() );
org.drools.reteoo.ReteooRuleBase reteooRuleBase = null;
// org.drools.leaps.LeapsRuleBase leapsRuleBase = null;
- final RuleBase ruleBase = getRuleBase();
+ RuleBase ruleBase = getRuleBase();
reteooRuleBase = (org.drools.reteoo.ReteooRuleBase) ruleBase;
ruleBase.addPackage( pkg );
+// ruleBase = SerializationHelper.serializeObject(ruleBase);
final PackageBuilder builder2 = new PackageBuilder();
builder2.addPackageFromDrl( new InputStreamReader( getClass().getResourceAsStream( "test_Dynamic2.drl" ) ) );
- ruleBase.addPackage( serialisePackage( builder2.getPackage() ) );
+ ruleBase.addPackage( SerializationHelper.serializeObject( builder2.getPackage() ) );
+// ruleBase = SerializationHelper.serializeObject(ruleBase);
final WorkingMemory workingMemory = ruleBase.newStatefulSession();
@@ -199,7 +198,7 @@
"like cheese" );
// reteooRuleBase.removeRule( "org.drools.test",
- // "like cheese2" );
+ // "like cheese2" );
final Cheese muzzarela = new Cheese( "muzzarela",
5 );
@@ -212,6 +211,7 @@
workingMemory.getAgenda().getActivations().length );
reteooRuleBase.removePackage( "org.drools.test" );
+ reteooRuleBase = SerializationHelper.serializeObject(reteooRuleBase);
assertEquals( 0,
workingMemory.getAgenda().getActivations().length );
@@ -228,10 +228,11 @@
org.drools.reteoo.ReteooRuleBase reteooRuleBase = null;
- final RuleBase ruleBase = getRuleBase();
+ RuleBase ruleBase = getRuleBase();
reteooRuleBase = (org.drools.reteoo.ReteooRuleBase) ruleBase;
ruleBase.addPackage( pkg );
+ ruleBase = SerializationHelper.serializeObject(ruleBase);
final WorkingMemory workingMemory = ruleBase.newStatefulSession();
@@ -262,11 +263,12 @@
builder.addPackageFromDrl( new InputStreamReader( getClass().getResourceAsStream( "test_DynamicFunction1.drl" ) ) );
//FIXME JBRULES-1258 serialising a package breaks function removal -- left the serialisation commented out for now
- //final Package pkg = serialisePackage( builder.getPackage() );
+ //final Package pkg = SerializationHelper.serializeObject( builder.getPackage() );
final Package pkg = builder.getPackage();
- final RuleBase ruleBase = getRuleBase();
+ RuleBase ruleBase = getRuleBase();
ruleBase.addPackage( pkg );
+ ruleBase = SerializationHelper.serializeObject(ruleBase);
final WorkingMemory workingMemory = ruleBase.newStatefulSession();
final List list = new ArrayList();
@@ -301,7 +303,7 @@
builder = new PackageBuilder();
builder.addPackageFromDrl( new InputStreamReader( getClass().getResourceAsStream( "test_DynamicFunction2.drl" ) ) );
- ruleBase.addPackage( serialisePackage( builder.getPackage() ) );
+ ruleBase.addPackage( SerializationHelper.serializeObject( builder.getPackage() ) );
final Cheese brie = new Cheese( "brie",
5 );
@@ -315,7 +317,7 @@
builder = new PackageBuilder();
builder.addPackageFromDrl( new InputStreamReader( getClass().getResourceAsStream( "test_DynamicFunction3.drl" ) ) );
- ruleBase.addPackage( serialisePackage( builder.getPackage() ) );
+ ruleBase.addPackage( SerializationHelper.serializeObject( builder.getPackage() ) );
final Cheese feta = new Cheese( "feta",
5 );
@@ -331,33 +333,36 @@
final PackageBuilder builder = new PackageBuilder();
builder.addPackageFromDrl( new InputStreamReader( getClass().getResourceAsStream( "test_RemovePackage.drl" ) ) );
- final RuleBase ruleBase = getRuleBase();
+ RuleBase ruleBase = getRuleBase();
final String packageName = builder.getPackage().getName();
- ruleBase.addPackage( serialisePackage( builder.getPackage() ) );
+ ruleBase.addPackage( SerializationHelper.serializeObject( builder.getPackage() ) );
+ ruleBase = SerializationHelper.serializeObject(ruleBase);
- final WorkingMemory workingMemory = ruleBase.newStatefulSession();
+ WorkingMemory workingMemory = ruleBase.newStatefulSession();
workingMemory.insert( new Precondition( "genericcode",
"genericvalue" ) );
workingMemory.fireAllRules();
- final RuleBase ruleBaseWM = workingMemory.getRuleBase();
+ RuleBase ruleBaseWM = workingMemory.getRuleBase();
ruleBaseWM.removePackage( packageName );
final PackageBuilder builder1 = new PackageBuilder();
builder1.addPackageFromDrl( new InputStreamReader( getClass().getResourceAsStream( "test_RemovePackage.drl" ) ) );
- ruleBaseWM.addPackage( serialisePackage( builder1.getPackage() ) );
+ ruleBaseWM.addPackage( SerializationHelper.serializeObject( builder1.getPackage() ) );
+ ruleBaseWM = SerializationHelper.serializeObject(ruleBaseWM);
+ workingMemory = SerializationHelper.serializeObject(workingMemory);
workingMemory.fireAllRules();
ruleBaseWM.removePackage( packageName );
- ruleBaseWM.addPackage( serialisePackage( builder1.getPackage() ) );
+ ruleBaseWM.addPackage( SerializationHelper.serializeObject( builder1.getPackage() ) );
ruleBaseWM.removePackage( packageName );
- ruleBaseWM.addPackage( serialisePackage( builder1.getPackage() ) );
+ ruleBaseWM.addPackage( SerializationHelper.serializeObject( builder1.getPackage() ) );
}
public void testDynamicRules() throws Exception {
- final RuleBase ruleBase = getRuleBase();
- final WorkingMemory workingMemory = ruleBase.newStatefulSession();
+ RuleBase ruleBase = getRuleBase();
+ WorkingMemory workingMemory = ruleBase.newStatefulSession();
final Cheese a = new Cheese( "stilton",
10 );
final Cheese b = new Cheese( "stilton",
@@ -371,14 +376,16 @@
final PackageBuilder builder = new PackageBuilder();
builder.addPackageFromDrl( new InputStreamReader( getClass().getResourceAsStream( "test_DynamicRules.drl" ) ) );
final Package pkg = builder.getPackage();
- ruleBase.addPackage( serialisePackage( pkg ) );
+ ruleBase.addPackage( SerializationHelper.serializeObject( pkg ) );
+ ruleBase = SerializationHelper.serializeObject(ruleBase);
+ workingMemory = SerializationHelper.serializeObject(workingMemory);
workingMemory.fireAllRules();
}
public void testDynamicRules2() throws Exception {
- final RuleBase ruleBase = getRuleBase();
- final WorkingMemory workingMemory = ruleBase.newStatefulSession();
+ RuleBase ruleBase = getRuleBase();
+ WorkingMemory workingMemory = ruleBase.newStatefulSession();
// Assert some simple facts
final FactA a = new FactA( "hello",
@@ -392,8 +399,10 @@
final PackageBuilder builder = new PackageBuilder();
builder.addPackageFromDrl( new InputStreamReader( getClass().getResourceAsStream( "test_DynamicRules2.drl" ) ) );
- final Package pkg = serialisePackage( builder.getPackage() );
+ final Package pkg = SerializationHelper.serializeObject( builder.getPackage() );
ruleBase.addPackage( pkg );
+ ruleBase = SerializationHelper.serializeObject(ruleBase);
+ workingMemory = SerializationHelper.serializeObject(workingMemory);
workingMemory.fireAllRules();
}
@@ -404,15 +413,17 @@
//add and remove
PackageBuilder builder = new PackageBuilder();
builder.addPackageFromDrl( new InputStreamReader( getClass().getResourceAsStream( "test_Dynamic1.drl" ) ) );
- Package pkg = serialisePackage( builder.getPackage() );
+ Package pkg = SerializationHelper.serializeObject( builder.getPackage() );
ruleBase.addPackage( pkg );
ruleBase.removePackage( pkg.getName() );
+ ruleBase = SerializationHelper.serializeObject(ruleBase);
//add and remove again
builder = new PackageBuilder();
builder.addPackageFromDrl( new InputStreamReader( getClass().getResourceAsStream( "test_Dynamic1.drl" ) ) );
- pkg = serialisePackage( builder.getPackage() );
+ pkg = SerializationHelper.serializeObject( builder.getPackage() );
ruleBase.addPackage( pkg );
+ ruleBase = SerializationHelper.serializeObject(ruleBase);
ruleBase.removePackage( pkg.getName() );
}
@@ -430,8 +441,9 @@
// must set the classloader for rulebase conf too
RuleBaseConfiguration rbconf = new RuleBaseConfiguration( loader1 );
RuleBase ruleBase = RuleBaseFactory.newRuleBase( rbconf );
- Package pkg = serialisePackage( builder.getPackage() );
+ Package pkg = SerializationHelper.serializeObject( builder.getPackage() );
ruleBase.addPackage( pkg );
+// ruleBase = SerializationHelper.serializeObject(ruleBase);
StatefulSession wm = ruleBase.newStatefulSession();
wm.insert( cheeseClass.newInstance() );
@@ -448,8 +460,9 @@
rbconf = new RuleBaseConfiguration( loader2 );
ruleBase = RuleBaseFactory.newRuleBase( rbconf );
- pkg = serialisePackage( builder.getPackage() );
+ pkg = SerializationHelper.serializeObject( builder.getPackage() );
ruleBase.addPackage( pkg );
+// ruleBase = SerializationHelper.serializeObject(ruleBase);
wm = ruleBase.newStatefulSession();
wm.insert( cheeseClass.newInstance() );
@@ -474,7 +487,7 @@
builder.addPackageFromDrl( new InputStreamReader( getClass().getResourceAsStream( "test_Dynamic1.drl" ) ) );
RuleBase ruleBase = RuleBaseFactory.newRuleBase();
- Package pkg = serialisePackage( builder.getPackage() );
+ Package pkg = SerializationHelper.serializeObject( builder.getPackage() );
ruleBase.addPackage( pkg );
StatefulSession wm = ruleBase.newStatefulSession();
@@ -491,7 +504,7 @@
builder.addPackageFromDrl( new InputStreamReader( getClass().getResourceAsStream( "test_Dynamic1.drl" ) ) );
ruleBase = RuleBaseFactory.newRuleBase();
- pkg = serialisePackage( builder.getPackage() );
+ pkg = SerializationHelper.serializeObject( builder.getPackage() );
ruleBase.addPackage( pkg );
wm = ruleBase.newStatefulSession();
@@ -510,7 +523,7 @@
builder.addPackageFromDrl( new InputStreamReader( getClass().getResourceAsStream( "test_CollectDynamicRules1.drl" ) ) );
final Package pkg = builder.getPackage();
- final RuleBase ruleBase = getRuleBase();
+ RuleBase ruleBase = getRuleBase();
ruleBase.addPackage( pkg );
final WorkingMemory workingMemory = ruleBase.newStatefulSession();
List list = new ArrayList();
@@ -530,6 +543,7 @@
builder2.addPackageFromDrl( new InputStreamReader( getClass().getResourceAsStream( "test_CollectDynamicRules2.drl" ) ) );
final Package pkg2 = builder2.getPackage();
ruleBase.addPackage( pkg2 );
+ ruleBase = SerializationHelper.serializeObject(ruleBase);
// fire all rules is automatic
assertEquals( 1,
@@ -542,7 +556,7 @@
public void testDynamicRulesAddRemove() {
try {
RuleBase ruleBase = RuleBaseFactory.newRuleBase();
-
+
PackageBuilder tomBuilder = new PackageBuilder();
tomBuilder.addPackageFromDrl( new InputStreamReader( getClass().getResourceAsStream( "test_DynamicRulesTom.drl" ) ) );
ruleBase.addPackage( tomBuilder.getPackage() );
@@ -550,7 +564,7 @@
StatefulSession session = ruleBase.newStatefulSession();
List results = new ArrayList();
session.setGlobal( "results", results );
-
+
InternalFactHandle h1 = (InternalFactHandle) session.insert( new Person( "tom", 1 ) );
InternalFactHandle h2 = (InternalFactHandle) session.insert( new Person( "fred", 2 ) );
InternalFactHandle h3 = (InternalFactHandle) session.insert( new Person( "harry", 3 ) );
@@ -561,9 +575,9 @@
InternalFactHandle h8 = (InternalFactHandle) session.insert( new Person( "jill", 8 ) );
InternalFactHandle h9 = (InternalFactHandle) session.insert( new Person( "ed", 9 ) );
InternalFactHandle h10 = (InternalFactHandle) session.insert( new Person( "tom", 10 ) );
-
+
session.fireAllRules();
-
+
assertEquals( 3, results.size() );
assertTrue( results.contains( h1.getObject() ) );
assertTrue( results.contains( h6.getObject() ) );
@@ -593,7 +607,7 @@
((Person) h3.getObject()).setName( "ed" );
session.update( h3, h3.getObject() );
session.fireAllRules();
-
+
assertEquals( 1, results.size() );
assertTrue( results.contains( h3.getObject() ) );
} catch( Exception e ) {
@@ -607,7 +621,7 @@
final PackageBuilder builder = new PackageBuilder();
builder.addPackageFromDrl( new InputStreamReader( getClass().getResourceAsStream( "test_DynamicRulesWithSubnetwork1.drl" ) ) );
builder.addPackageFromDrl( new InputStreamReader( getClass().getResourceAsStream( "test_DynamicRulesWithSubnetwork.drl" ) ) );
- final Package pkg = serialisePackage( builder.getPackage() );
+ final Package pkg = SerializationHelper.serializeObject( builder.getPackage() );
org.drools.reteoo.ReteooRuleBase reteooRuleBase = null;
final RuleBase ruleBase = getRuleBase();
@@ -615,32 +629,32 @@
ruleBase.addPackage( pkg );
final PackageBuilder builder2 = new PackageBuilder();
builder2.addPackageFromDrl( new InputStreamReader( getClass().getResourceAsStream( "test_DynamicRulesWithSubnetwork2.drl" ) ) );
- ruleBase.addPackage( serialisePackage( builder2.getPackage() ) );
+ ruleBase.addPackage( SerializationHelper.serializeObject( builder2.getPackage() ) );
final WorkingMemory workingMemory = ruleBase.newStatefulSession();
final List list = new ArrayList();
workingMemory.setGlobal( "results",
list );
-
+
Order order = new Order();
-
+
OrderItem item1 = new OrderItem(order, 1, "Adventure Guide Brazil", OrderItem.TYPE_BOOK, 24);
order.addItem(item1);
workingMemory.insert(item1);
-
+
OrderItem item2 = new OrderItem(order, 2, "Prehistoric Britain", OrderItem.TYPE_BOOK, 15);
order.addItem(item2);
workingMemory.insert(item2);
-
+
OrderItem item3 = new OrderItem(order, 3, "Holiday Music", OrderItem.TYPE_CD, 9);
order.addItem(item3);
workingMemory.insert(item3);
-
+
OrderItem item4 = new OrderItem(order, 4, "Very Best of Mick Jagger", OrderItem.TYPE_CD, 11);
order.addItem(item4);
workingMemory.insert(item4);
-
+
workingMemory.insert(order);
assertEquals( 11,
@@ -716,26 +730,26 @@
final RuleBase ruleBase = getRuleBase();
final String packageName = builder.getPackage().getName();
- ruleBase.addPackage( serialisePackage( builder.getPackage() ) );
+ ruleBase.addPackage( SerializationHelper.serializeObject( builder.getPackage() ) );
final WorkingMemory workingMemory = ruleBase.newStatefulSession();
List results = new ArrayList();
workingMemory.setGlobal( "results", results );
Order order = new Order();
-
+
OrderItem item1 = new OrderItem(order, 1, "Adventure Guide Brazil", OrderItem.TYPE_BOOK, 24);
OrderItem item2 = new OrderItem(order, 2, "Prehistoric Britain", OrderItem.TYPE_BOOK, 15);
OrderItem item3 = new OrderItem(order, 3, "Holiday Music", OrderItem.TYPE_CD, 9);
OrderItem item4 = new OrderItem(order, 4, "Very Best of Mick Jagger", OrderItem.TYPE_CD, 11);
OrderItem item5 = new OrderItem(order, 5, "The Master and Margarita", OrderItem.TYPE_BOOK, 29);
-
+
order.addItem( item1 );
order.addItem( item2 );
order.addItem( item3 );
order.addItem( item4 );
order.addItem( item5 );
-
+
workingMemory.insert( order );
workingMemory.fireAllRules();
assertEquals( 1, results.size() );
@@ -746,20 +760,20 @@
ruleBaseWM.removePackage( packageName );
final PackageBuilder builder1 = new PackageBuilder();
builder1.addPackageFromDrl( new InputStreamReader( getClass().getResourceAsStream( "test_DynamicRulesWithSubnetwork.drl" ) ) );
- ruleBaseWM.addPackage( serialisePackage( builder1.getPackage() ) );
+ ruleBaseWM.addPackage( SerializationHelper.serializeObject( builder1.getPackage() ) );
workingMemory.fireAllRules();
assertEquals( 1, results.size() );
assertEquals( 3, ((List) results.get(0)).size() );
results.clear();
ruleBaseWM.removePackage( packageName );
- ruleBaseWM.addPackage( serialisePackage( builder1.getPackage() ) );
+ ruleBaseWM.addPackage( SerializationHelper.serializeObject( builder1.getPackage() ) );
assertEquals( 1, results.size() );
assertEquals( 3, ((List) results.get(0)).size() );
results.clear();
ruleBaseWM.removePackage( packageName );
- ruleBaseWM.addPackage( serialisePackage( builder1.getPackage() ) );
+ ruleBaseWM.addPackage( SerializationHelper.serializeObject( builder1.getPackage() ) );
assertEquals( 1, results.size() );
assertEquals( 3, ((List) results.get(0)).size() );
results.clear();
@@ -773,14 +787,14 @@
//add and remove
PackageBuilder builder = new PackageBuilder();
builder.addPackageFromDrl( new InputStreamReader( getClass().getResourceAsStream( "test_DynamicRulesWithSubnetwork.drl" ) ) );
- Package pkg = serialisePackage( builder.getPackage() );
+ Package pkg = SerializationHelper.serializeObject( builder.getPackage() );
ruleBase.addPackage( pkg );
ruleBase.removePackage( pkg.getName() );
//add and remove again
builder = new PackageBuilder();
builder.addPackageFromDrl( new InputStreamReader( getClass().getResourceAsStream( "test_DynamicRulesWithSubnetwork.drl" ) ) );
- pkg = serialisePackage( builder.getPackage() );
+ pkg = SerializationHelper.serializeObject( builder.getPackage() );
ruleBase.addPackage( pkg );
ruleBase.removePackage( pkg.getName() );
} catch ( Exception e ) {
@@ -789,7 +803,7 @@
}
}
-
+
public class SubvertedClassLoader extends URLClassLoader {
private static final long serialVersionUID = 400L;
@@ -815,35 +829,4 @@
return c;
}
}
-
- protected Package serialisePackage(Package pkg) {
- try {
- byte[] bytes = serializeOut( pkg );
- return (Package) serializeIn( bytes );
- } catch ( Exception e ) {
- throw new RuntimeException( "trouble serialising package.",
- e );
- }
- }
-
- protected Object serializeIn(final byte[] bytes) throws IOException,
- ClassNotFoundException {
- final ObjectInput in = new ObjectInputStream( new ByteArrayInputStream( bytes ) );
- final Object obj = in.readObject();
- in.close();
- return obj;
- }
-
- protected byte[] serializeOut(final Object obj) throws IOException {
- // Serialize to a byte array
- final ByteArrayOutputStream bos = new ByteArrayOutputStream();
- final ObjectOutput out = new ObjectOutputStream( bos );
- out.writeObject( obj );
- out.close();
-
- // Get the bytes of the serialized object
- final byte[] bytes = bos.toByteArray();
- return bytes;
- }
-
}
Modified: labs/jbossrules/branches/temporal_rete/drools-compiler/src/test/java/org/drools/integrationtests/ExecutionFlowControlTest.java
===================================================================
--- labs/jbossrules/branches/temporal_rete/drools-compiler/src/test/java/org/drools/integrationtests/ExecutionFlowControlTest.java 2008-03-20 18:57:07 UTC (rev 19163)
+++ labs/jbossrules/branches/temporal_rete/drools-compiler/src/test/java/org/drools/integrationtests/ExecutionFlowControlTest.java 2008-03-20 19:32:10 UTC (rev 19164)
@@ -1,16 +1,10 @@
package org.drools.integrationtests;
-import java.io.IOException;
-import java.io.InputStreamReader;
-import java.io.Reader;
-import java.util.ArrayList;
-import java.util.List;
-
import junit.framework.Assert;
import junit.framework.TestCase;
-
import org.drools.Cheese;
import org.drools.FactHandle;
+import org.drools.Message;
import org.drools.Person;
import org.drools.PersonInterface;
import org.drools.RuleBase;
@@ -24,13 +18,11 @@
import org.drools.compiler.DrlParser;
import org.drools.compiler.DroolsParserException;
import org.drools.compiler.PackageBuilder;
-import org.drools.compiler.ProcessBuilder;
import org.drools.compiler.PackageBuilder.PackageMergeException;
import org.drools.event.ActivationCancelledEvent;
import org.drools.event.ActivationCreatedEvent;
import org.drools.event.AgendaEventListener;
import org.drools.event.DefaultAgendaEventListener;
-import org.drools.Message;
import org.drools.lang.descr.PackageDescr;
import org.drools.process.instance.ProcessInstance;
import org.drools.rule.Package;
@@ -38,6 +30,12 @@
import org.drools.spi.ActivationGroup;
import org.drools.spi.AgendaGroup;
+import java.io.IOException;
+import java.io.InputStreamReader;
+import java.io.Reader;
+import java.util.ArrayList;
+import java.util.List;
+
public class ExecutionFlowControlTest extends TestCase {
protected RuleBase getRuleBase() throws Exception {
@@ -51,13 +49,79 @@
config );
}
+ public void testRuleFlowConstraintDialects() throws Exception {
+ final PackageBuilder builder = new PackageBuilder();
+ builder.addRuleFlow( new InputStreamReader( getClass().getResourceAsStream( "test_ConstraintDialects.rfm" ) ) );
+
+ System.err.print( builder.getErrors() );
+
+ assertEquals( 0, builder.getErrors().getErrors().length );
+
+ RuleBase ruleBase = RuleBaseFactory.newRuleBase();
+ ruleBase.addPackage( builder.getPackage() );
+ ruleBase = SerializationHelper.serializeObject(ruleBase);
+
+ StatefulSession session = ruleBase.newStatefulSession();
+ List inList = new ArrayList();
+ List outList = new ArrayList();
+ session.setGlobal( "inList", inList );
+ session.setGlobal( "outList", outList );
+
+ inList.add( 1 );
+ inList.add( 3 );
+ inList.add( 6 );
+ inList.add( 25 );
+
+ FactHandle handle = session.insert( inList );
+ session.startProcess( "ConstraintDialects" );
+ assertEquals( 4, outList.size() );
+ assertEquals( "MVELCodeConstraint was here", outList.get( 0 ));
+ assertEquals( "JavaCodeConstraint was here", outList.get( 1 ));
+ assertEquals( "MVELRuleConstraint was here", outList.get( 2 ));
+ assertEquals( "JavaRuleConstraint was here", outList.get( 3 ));
+
+ outList.clear();
+ inList.remove( new Integer( 1 ) );
+ session.update( handle, inList );
+ session.startProcess( "ConstraintDialects" );
+ assertEquals( 3, outList.size() );
+ assertEquals( "JavaCodeConstraint was here", outList.get( 0 ));
+ assertEquals( "MVELRuleConstraint was here", outList.get( 1 ));
+ assertEquals( "JavaRuleConstraint was here", outList.get( 2 ));
+
+ outList.clear();
+ inList.remove( new Integer( 6 ) );
+ session.update( handle, inList );
+ session.startProcess( "ConstraintDialects" );
+ assertEquals( 2, outList.size() );
+ assertEquals( "JavaCodeConstraint was here", outList.get( 0 ));
+ assertEquals( "JavaRuleConstraint was here", outList.get( 1 ));
+
+ outList.clear();
+ inList.remove( new Integer( 3 ) );
+ session.update( handle, inList );
+ session.startProcess( "ConstraintDialects" );
+ assertEquals( 1, outList.size() );
+ assertEquals( "JavaRuleConstraint was here", outList.get( 0 ));
+
+ outList.clear();
+ inList.remove( new Integer( 25 ) );
+ session.update( handle, inList );
+ try {
+ session.startProcess( "ConstraintDialects" );
+ fail("This should have thrown an exception" );
+ } catch ( Exception e ) {
+ }
+ }
+
public void testSalienceInteger() throws Exception {
final PackageBuilder builder = new PackageBuilder();
builder.addPackageFromDrl( new InputStreamReader( getClass().getResourceAsStream( "test_salienceIntegerRule.drl" ) ) );
final Package pkg = builder.getPackage();
- final RuleBase ruleBase = getRuleBase();
+ RuleBase ruleBase = getRuleBase();
ruleBase.addPackage( pkg );
+ ruleBase = SerializationHelper.serializeObject(ruleBase);
final WorkingMemory workingMemory = ruleBase.newStatefulSession();
final List list = new ArrayList();
@@ -86,8 +150,9 @@
builder.addPackageFromDrl( new InputStreamReader( getClass().getResourceAsStream( "test_salienceExpressionRule.drl" ) ) );
final Package pkg = builder.getPackage();
- final RuleBase ruleBase = getRuleBase();
+ RuleBase ruleBase = getRuleBase();
ruleBase.addPackage( pkg );
+ ruleBase = SerializationHelper.serializeObject(ruleBase);
final WorkingMemory workingMemory = ruleBase.newStatefulSession();
final List list = new ArrayList();
@@ -122,8 +187,9 @@
builder.addPackageFromDrl( new InputStreamReader( getClass().getResourceAsStream( "no-loop.drl" ) ) );
final Package pkg = builder.getPackage();
- final RuleBase ruleBase = getRuleBase();
+ RuleBase ruleBase = getRuleBase();
ruleBase.addPackage( pkg );
+ ruleBase = SerializationHelper.serializeObject(ruleBase);
final WorkingMemory workingMemory = ruleBase.newStatefulSession();
final List list = new ArrayList();
@@ -147,8 +213,9 @@
builder.addPackageFromDrl( new InputStreamReader( getClass().getResourceAsStream( "test_LockOnActive.drl" ) ) );
final Package pkg = builder.getPackage();
- final RuleBase ruleBase = getRuleBase();
+ RuleBase ruleBase = getRuleBase();
ruleBase.addPackage( pkg );
+ ruleBase = SerializationHelper.serializeObject(ruleBase);
final WorkingMemory workingMemory = ruleBase.newStatefulSession();
final List list = new ArrayList();
@@ -192,8 +259,9 @@
builder.addPackageFromDrl( new InputStreamReader( getClass().getResourceAsStream( "test_LockOnActiveWithUpdate.drl" ) ) );
final Package pkg = builder.getPackage();
- final RuleBase ruleBase = getRuleBase();
+ RuleBase ruleBase = getRuleBase();
ruleBase.addPackage( pkg );
+ ruleBase = SerializationHelper.serializeObject(ruleBase);
final WorkingMemory wm = ruleBase.newStatefulSession();
final List list = new ArrayList();
@@ -252,8 +320,9 @@
builder.addPackageFromDrl( new InputStreamReader( getClass().getResourceAsStream( "test_AgendaGroups.drl" ) ) );
final Package pkg = builder.getPackage();
- final RuleBase ruleBase = getRuleBase();
+ RuleBase ruleBase = getRuleBase();
ruleBase.addPackage( pkg );
+ ruleBase = SerializationHelper.serializeObject(ruleBase);
final WorkingMemory workingMemory = ruleBase.newStatefulSession();
final List list = new ArrayList();
@@ -298,8 +367,9 @@
builder.addPackageFromDrl( new InputStreamReader( getClass().getResourceAsStream( "test_ActivationGroups.drl" ) ) );
final Package pkg = builder.getPackage();
- final RuleBase ruleBase = getRuleBase();
+ RuleBase ruleBase = getRuleBase();
ruleBase.addPackage( pkg );
+ ruleBase = SerializationHelper.serializeObject(ruleBase);
final WorkingMemory workingMemory = ruleBase.newStatefulSession();
final List list = new ArrayList();
@@ -351,8 +421,9 @@
builder.addPackageFromDrl( new InputStreamReader( getClass().getResourceAsStream( "test_Duration.drl" ) ) );
final Package pkg = builder.getPackage();
- final RuleBase ruleBase = getRuleBase();
+ RuleBase ruleBase = getRuleBase();
ruleBase.addPackage( pkg );
+ ruleBase = SerializationHelper.serializeObject(ruleBase);
final WorkingMemory workingMemory = ruleBase.newStatefulSession();
final List list = new ArrayList();
@@ -381,8 +452,9 @@
public void testInsertRetractNoloop() throws Exception {
// read in the source
final Reader reader = new InputStreamReader( getClass().getResourceAsStream( "test_Insert_Retract_Noloop.drl" ) );
- final RuleBase ruleBase = loadRuleBase( reader );
+ RuleBase ruleBase = loadRuleBase( reader );
+ ruleBase = SerializationHelper.serializeObject(ruleBase);
final WorkingMemory wm = ruleBase.newStatefulSession();
wm.insert( new Cheese( "stilton",
15 ) );
@@ -395,8 +467,9 @@
builder.addPackageFromDrl( new InputStreamReader( getClass().getResourceAsStream( "test_Duration_with_NoLoop.drl" ) ) );
final Package pkg = builder.getPackage();
- final RuleBase ruleBase = getRuleBase();
+ RuleBase ruleBase = getRuleBase();
ruleBase.addPackage( pkg );
+ ruleBase = SerializationHelper.serializeObject(ruleBase);
final WorkingMemory workingMemory = ruleBase.newStatefulSession();
final List list = new ArrayList();
@@ -426,8 +499,9 @@
builder.addPackageFromDrl( new InputStreamReader( getClass().getResourceAsStream( "test_FireRuleAfterDuration.drl" ) ) );
final Package pkg = builder.getPackage();
- final RuleBase ruleBase = getRuleBase();
+ RuleBase ruleBase = getRuleBase();
ruleBase.addPackage( pkg );
+ ruleBase = SerializationHelper.serializeObject(ruleBase);
final WorkingMemory workingMemory = ruleBase.newStatefulSession();
final List list = new ArrayList();
@@ -458,8 +532,9 @@
public void testUpdateNoLoop() throws Exception {
// JBRULES-780, throws a NullPointer or infinite loop if there is an issue
final Reader reader = new InputStreamReader( getClass().getResourceAsStream( "test_UpdateNoloop.drl" ) );
- final RuleBase ruleBase = loadRuleBase( reader );
+ RuleBase ruleBase = loadRuleBase( reader );
+ ruleBase = SerializationHelper.serializeObject(ruleBase);
final WorkingMemory wm = ruleBase.newStatefulSession();
wm.insert( new Cheese( "stilton",
15 ) );
@@ -470,8 +545,9 @@
public void testUpdateActivationCreationNoLoop() throws Exception {
// JBRULES-787, no-loop blocks all dependant tuples for update
final Reader reader = new InputStreamReader( getClass().getResourceAsStream( "test_UpdateActivationCreationNoLoop.drl" ) );
- final RuleBase ruleBase = loadRuleBase( reader );
+ RuleBase ruleBase = loadRuleBase( reader );
+ ruleBase = SerializationHelper.serializeObject(ruleBase);
final InternalWorkingMemoryActions wm = (InternalWorkingMemoryActions) ruleBase.newStatefulSession();
final List created = new ArrayList();
final List cancelled = new ArrayList();
@@ -531,8 +607,9 @@
builder.addPackageFromDrl( new InputStreamReader( getClass().getResourceAsStream( "ruleflowgroup.drl" ) ) );
final Package pkg = builder.getPackage();
- final RuleBase ruleBase = getRuleBase();
+ RuleBase ruleBase = getRuleBase();
ruleBase.addPackage( pkg );
+ ruleBase = SerializationHelper.serializeObject(ruleBase);
final WorkingMemory workingMemory = ruleBase.newStatefulSession();
final List list = new ArrayList();
@@ -556,8 +633,9 @@
builder.addPackageFromDrl( new InputStreamReader( getClass().getResourceAsStream( "ruleflow.drl" ) ) );
builder.addRuleFlow( new InputStreamReader( getClass().getResourceAsStream( "ruleflow.rfm" ) ) );
final Package pkg = builder.getPackage();
- final RuleBase ruleBase = getRuleBase();
+ RuleBase ruleBase = getRuleBase();
ruleBase.addPackage( pkg );
+ ruleBase = SerializationHelper.serializeObject(ruleBase);
final WorkingMemory workingMemory = ruleBase.newStatefulSession();
final List list = new ArrayList();
@@ -591,8 +669,9 @@
builder.addPackageFromDrl( new InputStreamReader( getClass().getResourceAsStream( "test_ruleflowClear.drl" ) ) );
builder.addRuleFlow( new InputStreamReader( getClass().getResourceAsStream( "test_ruleflowClear.rfm" ) ) );
final Package pkg = builder.getPackage();
- final RuleBase ruleBase = getRuleBase();
+ RuleBase ruleBase = getRuleBase();
ruleBase.addPackage( pkg );
+ ruleBase = SerializationHelper.serializeObject(ruleBase);
final WorkingMemory workingMemory = ruleBase.newStatefulSession();
final List list = new ArrayList();
@@ -644,8 +723,9 @@
builder.addRuleFlow( new InputStreamReader( getClass().getResourceAsStream( "ruleflow.rfm" ) ) );
final Package pkg = builder.getPackage();
- final RuleBase ruleBase = getRuleBase();
+ RuleBase ruleBase = getRuleBase();
ruleBase.addPackage( pkg );
+ ruleBase = SerializationHelper.serializeObject(ruleBase);
final WorkingMemory workingMemory = ruleBase.newStatefulSession();
final List list = new ArrayList();
@@ -739,7 +819,8 @@
RuleBase ruleBase = RuleBaseFactory.newRuleBase();
ruleBase.addPackage( builder.getPackage() );
-
+ ruleBase = SerializationHelper.serializeObject(ruleBase);
+
StatefulSession session = ruleBase.newStatefulSession();
List list = new ArrayList();
session.setGlobal( "list", list );
@@ -751,70 +832,6 @@
assertEquals( "java was here", list.get( 1 ) );
}
- public void testRuleFlowConstraintDialects() throws Exception {
- final PackageBuilder builder = new PackageBuilder();
- builder.addRuleFlow( new InputStreamReader( getClass().getResourceAsStream( "test_ConstraintDialects.rfm" ) ) );
-
- System.err.print( builder.getErrors() );
-
- assertEquals( 0, builder.getErrors().getErrors().length );
-
- RuleBase ruleBase = RuleBaseFactory.newRuleBase();
- ruleBase.addPackage( builder.getPackage() );
-
- StatefulSession session = ruleBase.newStatefulSession();
- List inList = new ArrayList();
- List outList = new ArrayList();
- session.setGlobal( "inList", inList );
- session.setGlobal( "outList", outList );
-
- inList.add( 1 );
- inList.add( 3 );
- inList.add( 6 );
- inList.add( 25 );
-
- FactHandle handle = session.insert( inList );
- session.startProcess( "ConstraintDialects" );
- assertEquals( 4, outList.size() );
- assertEquals( "MVELCodeConstraint was here", outList.get( 0 ));
- assertEquals( "JavaCodeConstraint was here", outList.get( 1 ));
- assertEquals( "MVELRuleConstraint was here", outList.get( 2 ));
- assertEquals( "JavaRuleConstraint was here", outList.get( 3 ));
-
- outList.clear();
- inList.remove( new Integer( 1 ) );
- session.update( handle, inList );
- session.startProcess( "ConstraintDialects" );
- assertEquals( 3, outList.size() );
- assertEquals( "JavaCodeConstraint was here", outList.get( 0 ));
- assertEquals( "MVELRuleConstraint was here", outList.get( 1 ));
- assertEquals( "JavaRuleConstraint was here", outList.get( 2 ));
-
- outList.clear();
- inList.remove( new Integer( 6 ) );
- session.update( handle, inList );
- session.startProcess( "ConstraintDialects" );
- assertEquals( 2, outList.size() );
- assertEquals( "JavaCodeConstraint was here", outList.get( 0 ));
- assertEquals( "JavaRuleConstraint was here", outList.get( 1 ));
-
- outList.clear();
- inList.remove( new Integer( 3 ) );
- session.update( handle, inList );
- session.startProcess( "ConstraintDialects" );
- assertEquals( 1, outList.size() );
- assertEquals( "JavaRuleConstraint was here", outList.get( 0 ));
-
- outList.clear();
- inList.remove( new Integer( 25 ) );
- session.update( handle, inList );
- try {
- session.startProcess( "ConstraintDialects" );
- fail("This should have thrown an exception" );
- } catch ( Exception e ) {
- }
- }
-
public void testLoadingRuleFlowInPackage7() throws Exception {
// loading a ruleflow with errors
final PackageBuilder builder = new PackageBuilder();
@@ -845,7 +862,8 @@
public void testDateEffective() throws Exception {
// read in the source
final Reader reader = new InputStreamReader( getClass().getResourceAsStream( "test_EffectiveDate.drl" ) );
- final RuleBase ruleBase = loadRuleBase( reader );
+ RuleBase ruleBase = loadRuleBase( reader );
+ ruleBase = SerializationHelper.serializeObject(ruleBase);
final WorkingMemory workingMemory = ruleBase.newStatefulSession();
Modified: labs/jbossrules/branches/temporal_rete/drools-compiler/src/test/java/org/drools/integrationtests/FirstOrderLogicTest.java
===================================================================
--- labs/jbossrules/branches/temporal_rete/drools-compiler/src/test/java/org/drools/integrationtests/FirstOrderLogicTest.java 2008-03-20 18:57:07 UTC (rev 19163)
+++ labs/jbossrules/branches/temporal_rete/drools-compiler/src/test/java/org/drools/integrationtests/FirstOrderLogicTest.java 2008-03-20 19:32:10 UTC (rev 19164)
@@ -1,15 +1,7 @@
package org.drools.integrationtests;
-import java.io.IOException;
-import java.io.InputStreamReader;
-import java.io.Reader;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.List;
-
import junit.framework.Assert;
import junit.framework.TestCase;
-
import org.drools.Cheese;
import org.drools.Cheesery;
import org.drools.FactHandle;
@@ -31,6 +23,13 @@
import org.drools.rule.Package;
import org.drools.rule.Rule;
+import java.io.IOException;
+import java.io.InputStreamReader;
+import java.io.Reader;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.List;
+
public class FirstOrderLogicTest extends TestCase {
protected RuleBase getRuleBase() throws Exception {
@@ -48,7 +47,7 @@
// read in the source
final Reader reader = new InputStreamReader( getClass().getResourceAsStream( "test_Collect.drl" ) );
- final RuleBase ruleBase = loadRuleBase( reader );
+ RuleBase ruleBase = loadRuleBase( reader );
final WorkingMemory wm = ruleBase.newStatefulSession();
final List results = new ArrayList();
@@ -86,7 +85,7 @@
public void testCollectModify() throws Exception {
// read in the source
final Reader reader = new InputStreamReader( getClass().getResourceAsStream( "test_Collect.drl" ) );
- final RuleBase ruleBase = loadRuleBase( reader );
+ RuleBase ruleBase = loadRuleBase( reader );
final WorkingMemory wm = ruleBase.newStatefulSession();
final List results = new ArrayList();
@@ -157,8 +156,9 @@
builder.addPackageFromDrl( new InputStreamReader( getClass().getResourceAsStream( "test_ExistsWithBindings.drl" ) ) );
final Package pkg = builder.getPackage();
- final RuleBase ruleBase = getRuleBase();
+ RuleBase ruleBase = getRuleBase();
ruleBase.addPackage( pkg );
+ ruleBase = SerializationHelper.serializeObject(ruleBase);
final WorkingMemory workingMemory = ruleBase.newStatefulSession();
final List list = new ArrayList();
@@ -223,8 +223,9 @@
assertTrue( rule.isValid() );
assertEquals( 0,
builder.getErrors().getErrors().length );
- final RuleBase ruleBase = getRuleBase();
+ RuleBase ruleBase = getRuleBase();
ruleBase.addPackage( pkg );
+ ruleBase = SerializationHelper.serializeObject(ruleBase);
final WorkingMemory workingMemory = ruleBase.newStatefulSession();
final List list = new ArrayList();
@@ -260,8 +261,9 @@
builder.addPackageFromDrl( new InputStreamReader( getClass().getResourceAsStream( "exists_rule_test.drl" ) ) );
final Package pkg = builder.getPackage();
- final RuleBase ruleBase = getRuleBase();
+ RuleBase ruleBase = getRuleBase();
ruleBase.addPackage( pkg );
+ ruleBase = SerializationHelper.serializeObject(ruleBase);
final WorkingMemory workingMemory = ruleBase.newStatefulSession();
final List list = new ArrayList();
@@ -298,8 +300,9 @@
builder.addPackageFromDrl( new InputStreamReader( getClass().getResourceAsStream( "test_exists.drl" ) ) );
final Package pkg = builder.getPackage();
- final RuleBase ruleBase = getRuleBase();
+ RuleBase ruleBase = getRuleBase();
ruleBase.addPackage( pkg );
+ ruleBase = SerializationHelper.serializeObject(ruleBase);
final WorkingMemory workingMemory = ruleBase.newStatefulSession();
final List list = new ArrayList();
@@ -341,8 +344,9 @@
builder.addPackageFromDrl( new InputStreamReader( getClass().getResourceAsStream( "test_Forall.drl" ) ) );
final Package pkg = builder.getPackage();
- final RuleBase ruleBase = getRuleBase();
+ RuleBase ruleBase = getRuleBase();
ruleBase.addPackage( pkg );
+ ruleBase = SerializationHelper.serializeObject(ruleBase);
final WorkingMemory workingMemory = ruleBase.newStatefulSession();
final List list = new ArrayList();
@@ -377,8 +381,9 @@
final RuleBaseConfiguration config = new RuleBaseConfiguration();
config.setRemoveIdentities( true );
- final RuleBase ruleBase = getRuleBase( config );
+ RuleBase ruleBase = getRuleBase( config );
ruleBase.addPackage( pkg );
+ ruleBase = SerializationHelper.serializeObject(ruleBase);
final WorkingMemory workingMemory = ruleBase.newStatefulSession();
final List list = new ArrayList();
@@ -426,8 +431,9 @@
builder.addPackageFromDrl( new InputStreamReader( getClass().getResourceAsStream( "test_CollectWithNestedFrom.drl" ) ) );
final Package pkg = builder.getPackage();
- final RuleBase ruleBase = getRuleBase();
+ RuleBase ruleBase = getRuleBase();
ruleBase.addPackage( pkg );
+ ruleBase = SerializationHelper.serializeObject(ruleBase);
final WorkingMemory workingMemory = ruleBase.newStatefulSession();
final List results = new ArrayList();
@@ -469,7 +475,7 @@
public void testCollectModifyAlphaRestriction() throws Exception {
// read in the source
final Reader reader = new InputStreamReader( getClass().getResourceAsStream( "test_CollectAlphaRestriction.drl" ) );
- final RuleBase ruleBase = loadRuleBase( reader );
+ RuleBase ruleBase = loadRuleBase( reader );
final WorkingMemory wm = ruleBase.newStatefulSession();
final List results = new ArrayList();
@@ -542,8 +548,9 @@
final Package pkg = builder.getPackage();
// add the package to a rulebase
- final RuleBase ruleBase = getRuleBase();
+ RuleBase ruleBase = getRuleBase();
ruleBase.addPackage( pkg );
+ ruleBase = SerializationHelper.serializeObject(ruleBase);
// load up the rulebase
return ruleBase;
}
@@ -553,8 +560,9 @@
builder.addPackageFromDrl( new InputStreamReader( getClass().getResourceAsStream( "test_ForallSinglePattern.drl" ) ) );
final Package pkg = builder.getPackage();
- final RuleBase ruleBase = getRuleBase();
+ RuleBase ruleBase = getRuleBase();
ruleBase.addPackage( pkg );
+ ruleBase = SerializationHelper.serializeObject(ruleBase);
final WorkingMemory workingMemory = ruleBase.newStatefulSession();
final List list = new ArrayList();
@@ -651,9 +659,10 @@
PackageBuilder builder = new PackageBuilder();
builder.addPackageFromDrl( new InputStreamReader( FirstOrderLogicTest.class.getResourceAsStream( "test_NestedCorrelatedRulesWithForall.drl" ) ) );
- RuleBase rb = RuleBaseFactory.newRuleBase();
- rb.addPackage( builder.getPackage() );
- StatefulSession session = rb.newStatefulSession();
+ RuleBase ruleBase = RuleBaseFactory.newRuleBase();
+ ruleBase.addPackage( builder.getPackage() );
+ ruleBase = SerializationHelper.serializeObject(ruleBase);
+ StatefulSession session = ruleBase.newStatefulSession();
List list1 = new ArrayList();
List list2 = new ArrayList();
@@ -715,8 +724,9 @@
builder.addPackageFromDrl( new InputStreamReader( getClass().getResourceAsStream( "test_FromInsideNotAndExists.drl" ) ) );
final Package pkg = builder.getPackage();
- final RuleBase ruleBase = getRuleBase();
+ RuleBase ruleBase = getRuleBase();
ruleBase.addPackage( pkg );
+ ruleBase = SerializationHelper.serializeObject(ruleBase);
final WorkingMemory workingMemory = ruleBase.newStatefulSession();
final List list = new ArrayList();
@@ -753,8 +763,9 @@
builder.addPackageFromDrl( new InputStreamReader( getClass().getResourceAsStream( "test_OrNesting.drl" ) ) );
final Package pkg = builder.getPackage();
- final RuleBase ruleBase = getRuleBase();
+ RuleBase ruleBase = getRuleBase();
ruleBase.addPackage( pkg );
+ ruleBase = SerializationHelper.serializeObject(ruleBase);
final WorkingMemory workingMemory = ruleBase.newStatefulSession();
final List list = new ArrayList();
@@ -785,8 +796,9 @@
builder.addPackageFromDrl( new InputStreamReader( getClass().getResourceAsStream( "test_CollectMemberOfOperator.drl" ) ) );
final Package pkg = builder.getPackage();
- final RuleBase ruleBase = getRuleBase();
+ RuleBase ruleBase = getRuleBase();
ruleBase.addPackage( pkg );
+ ruleBase = SerializationHelper.serializeObject(ruleBase);
final WorkingMemory workingMemory = ruleBase.newStatefulSession();
final List list = new ArrayList();
@@ -842,8 +854,9 @@
builder.addPackageFromDrl( new InputStreamReader( getClass().getResourceAsStream( "test_CollectContainsOperator.drl" ) ) );
final Package pkg = builder.getPackage();
- final RuleBase ruleBase = getRuleBase();
+ RuleBase ruleBase = getRuleBase();
ruleBase.addPackage( pkg );
+ ruleBase = SerializationHelper.serializeObject(ruleBase);
final WorkingMemory workingMemory = ruleBase.newStatefulSession();
final List list = new ArrayList();
@@ -899,8 +912,9 @@
builder.addPackageFromDrl( new InputStreamReader( getClass().getResourceAsStream( "test_ForallSinglePatternWithExists.drl" ) ) );
final Package pkg = builder.getPackage();
- final RuleBase ruleBase = getRuleBase();
+ RuleBase ruleBase = getRuleBase();
ruleBase.addPackage( pkg );
+ ruleBase = SerializationHelper.serializeObject(ruleBase);
final WorkingMemory workingMemory = ruleBase.newStatefulSession();
final List list = new ArrayList();
Modified: labs/jbossrules/branches/temporal_rete/drools-compiler/src/test/java/org/drools/integrationtests/LargeRuleBase.java
===================================================================
--- labs/jbossrules/branches/temporal_rete/drools-compiler/src/test/java/org/drools/integrationtests/LargeRuleBase.java 2008-03-20 18:57:07 UTC (rev 19163)
+++ labs/jbossrules/branches/temporal_rete/drools-compiler/src/test/java/org/drools/integrationtests/LargeRuleBase.java 2008-03-20 19:32:10 UTC (rev 19164)
@@ -7,9 +7,11 @@
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;
import java.io.StringReader;
+import java.io.ObjectOutput;
import org.drools.RuleBase;
import org.drools.RuleBaseFactory;
+import org.drools.common.DroolsObjectOutputStream;
import org.drools.compiler.DrlParser;
import org.drools.compiler.DroolsParserException;
import org.drools.compiler.PackageBuilder;
@@ -80,7 +82,7 @@
f.delete();
time = System.currentTimeMillis();
- ObjectOutputStream out = new ObjectOutputStream(new FileOutputStream(f));
+ ObjectOutput out = new DroolsObjectOutputStream(new FileOutputStream(f));
out.writeObject(rb);
out.flush();
out.close();
@@ -165,7 +167,7 @@
+ (System.currentTimeMillis() - time));
}
- private static String getHeader() {
+ public static String getHeader() {
return "package org.drools.test; \n " + "import org.drools.Person; \n "
+ "import org.drools.Cheese; \n "
+ "import org.drools.Cheesery; \n "
@@ -173,7 +175,7 @@
+ " global List list \n dialect 'mvel'\n ";
}
- private static String getTemplate1(String name, int status) {
+ public static String getTemplate1(String name, int status) {
return "rule 'match Person "
+ name
+ "' \n"
Copied: labs/jbossrules/branches/temporal_rete/drools-compiler/src/test/java/org/drools/integrationtests/LargeRuleBaseSerializationTest.java (from rev 19160, labs/jbossrules/dev_tags/before_righttuple_merge_20080320/drools-compiler/src/test/java/org/drools/integrationtests/LargeRuleBaseSerializationTest.java)
===================================================================
--- labs/jbossrules/branches/temporal_rete/drools-compiler/src/test/java/org/drools/integrationtests/LargeRuleBaseSerializationTest.java (rev 0)
+++ labs/jbossrules/branches/temporal_rete/drools-compiler/src/test/java/org/drools/integrationtests/LargeRuleBaseSerializationTest.java 2008-03-20 19:32:10 UTC (rev 19164)
@@ -0,0 +1,45 @@
+package org.drools.integrationtests;
+
+import org.drools.compiler.DrlParser;
+import org.drools.compiler.PackageBuilder;
+import org.drools.lang.descr.PackageDescr;
+import org.drools.rule.*;
+import org.drools.rule.Package;
+import org.drools.RuleBase;
+import org.drools.RuleBaseFactory;
+
+import java.io.StringReader;
+
+import junit.framework.TestCase;
+
+/**
+ * Created by IntelliJ IDEA. User: SG0521861 Date: Mar 18, 2008 Time: 1:22:50 PM To change this template use File |
+ * Settings | File Templates.
+ */
+public class LargeRuleBaseSerializationTest extends TestCase {
+ private static final int RULE_COUNT = 200;
+
+ public void testLargeRuleBase() throws Exception{
+ System.out.println("Generating "+RULE_COUNT+" rules");
+ StringBuilder sb = new StringBuilder(LargeRuleBase.getHeader());
+
+ for (int i = 0; i < RULE_COUNT; i++) {
+ sb.append(LargeRuleBase.getTemplate1("testRule"+i, i));
+ }
+ System.out.println("Parsing "+RULE_COUNT+" rules");
+ DrlParser ps = new DrlParser();
+ PackageDescr pkgDescr = ps.parse(new StringReader(sb.toString()));
+
+ PackageBuilder pkgBuilder = new PackageBuilder();
+ pkgBuilder.addPackage(pkgDescr);
+
+ Package pkg = pkgBuilder.getPackage();
+ RuleBase rb = RuleBaseFactory.newRuleBase();
+
+ rb.addPackage(pkg);
+
+ rb = SerializationHelper.serializeObject(rb);
+
+ }
+
+}
Modified: labs/jbossrules/branches/temporal_rete/drools-compiler/src/test/java/org/drools/integrationtests/MVELTest.java
===================================================================
--- labs/jbossrules/branches/temporal_rete/drools-compiler/src/test/java/org/drools/integrationtests/MVELTest.java 2008-03-20 18:57:07 UTC (rev 19163)
+++ labs/jbossrules/branches/temporal_rete/drools-compiler/src/test/java/org/drools/integrationtests/MVELTest.java 2008-03-20 19:32:10 UTC (rev 19164)
@@ -1,26 +1,12 @@
package org.drools.integrationtests;
-import java.io.ByteArrayInputStream;
-import java.io.ByteArrayOutputStream;
-import java.io.IOException;
-import java.io.InputStreamReader;
-import java.io.ObjectOutputStream;
-import java.io.Reader;
-import java.io.Serializable;
-import java.util.ArrayList;
-import java.util.Date;
-import java.util.HashMap;
-import java.util.List;
-
import junit.framework.Assert;
import junit.framework.TestCase;
-
import org.drools.Cheese;
import org.drools.Person;
import org.drools.RuleBase;
import org.drools.RuleBaseFactory;
import org.drools.WorkingMemory;
-import org.drools.common.DroolsObjectInputStream;
import org.drools.compiler.DrlParser;
import org.drools.compiler.DroolsParserException;
import org.drools.compiler.PackageBuilder;
@@ -29,25 +15,21 @@
import org.drools.util.DateUtils;
import org.mvel.MVEL;
+import java.io.IOException;
+import java.io.InputStreamReader;
+import java.io.Reader;
+import java.io.Serializable;
+import java.util.ArrayList;
+import java.util.Date;
+import java.util.HashMap;
+import java.util.List;
+
public class MVELTest extends TestCase {
public void testHelloWorld() throws Exception {
// read in the source
final Reader reader = new InputStreamReader( getClass().getResourceAsStream( "test_mvel.drl" ) );
RuleBase ruleBase = loadRuleBase( reader );
- // Bellow lines are a way to make sure serialization is fine
- // start of serialization block
- ByteArrayOutputStream out = new ByteArrayOutputStream();
- ObjectOutputStream obj = new ObjectOutputStream( out );
- obj.writeObject( ruleBase );
- obj.close();
-
- byte[] buf = out.toByteArray();
-
- DroolsObjectInputStream in = new DroolsObjectInputStream( new ByteArrayInputStream( buf ) );
- ruleBase = (RuleBase) in.readObject();
- // end of serialization block
-
final WorkingMemory workingMemory = ruleBase.newStatefulSession();
final List list = new ArrayList();
@@ -71,54 +53,57 @@
Date dt = DateUtils.parseDate( "10-Jul-1974" );
assertEquals(dt, c.getUsedBy());
}
-
+
public void testLocalVariableMVELConsequence() throws Exception {
final PackageBuilder builder = new PackageBuilder();
builder.addPackageFromDrl( new InputStreamReader( getClass().getResourceAsStream( "test_LocalVariableMVELConsequence.drl" ) ) );
final Package pkg = builder.getPackage();
-
- final RuleBase ruleBase = getRuleBase();
+
+ RuleBase ruleBase = getRuleBase();
ruleBase.addPackage( pkg );
+ ruleBase = SerializationHelper.serializeObject(ruleBase);
+
final WorkingMemory workingMemory = ruleBase.newStatefulSession();
-
+
final List list = new ArrayList();
workingMemory.setGlobal( "results",
list );
-
+
workingMemory.insert( new Person( "bob", "stilton" ) );
workingMemory.insert( new Person( "mark", "brie" ) );
-
+
try {
workingMemory.fireAllRules();
-
- assertEquals( "should have fired twice",
+
+ assertEquals( "should have fired twice",
2,
list.size() );
-
+
} catch (Exception e) {
e.printStackTrace();
fail( "Should not raise any exception");
}
-
- }
+ }
+
public void testDuplicateLocalVariableMVELConsequence() throws Exception {
final PackageBuilder builder = new PackageBuilder();
builder.addPackageFromDrl( new InputStreamReader( getClass().getResourceAsStream( "test_DuplicateLocalVariableMVELConsequence.drl" ) ) );
-
+
try {
final Package pkg = builder.getPackage();
-
- final RuleBase ruleBase = getRuleBase();
+
+ RuleBase ruleBase = getRuleBase();
ruleBase.addPackage( pkg );
-
+
+ ruleBase = SerializationHelper.serializeObject(ruleBase);
fail( "Should have raised exception because of the duplicate variable definition");
} catch (Exception e) {
// success
}
-
- }
+ }
+
public Object compiledExecute(String ex) {
Serializable compiled = MVEL.compileExpression(ex);
return MVEL.executeExpression(compiled, new Object(), new HashMap());
@@ -141,8 +126,9 @@
final Package pkg = builder.getPackage();
// add the package to a rulebase
- final RuleBase ruleBase = getRuleBase();
+ RuleBase ruleBase = getRuleBase();
ruleBase.addPackage( pkg );
+ ruleBase = SerializationHelper.serializeObject(ruleBase);
// load up the rulebase
return ruleBase;
}
Modified: labs/jbossrules/branches/temporal_rete/drools-compiler/src/test/java/org/drools/integrationtests/MarshallingTest.java
===================================================================
--- labs/jbossrules/branches/temporal_rete/drools-compiler/src/test/java/org/drools/integrationtests/MarshallingTest.java 2008-03-20 18:57:07 UTC (rev 19163)
+++ labs/jbossrules/branches/temporal_rete/drools-compiler/src/test/java/org/drools/integrationtests/MarshallingTest.java 2008-03-20 19:32:10 UTC (rev 19164)
@@ -9,11 +9,17 @@
import java.io.ObjectOutput;
import java.io.ObjectOutputStream;
import java.io.Reader;
+import java.io.StringReader;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
+import java.util.jar.JarEntry;
+import java.util.jar.JarInputStream;
+import junit.framework.TestCase;
+
+import org.drools.Address;
import org.drools.Cheese;
import org.drools.Person;
import org.drools.Primitives;
@@ -22,34 +28,33 @@
import org.drools.RuleBaseFactory;
import org.drools.StatefulSession;
import org.drools.WorkingMemory;
+import org.drools.common.DroolsObjectInputStream;
import org.drools.common.InternalFactHandle;
import org.drools.compiler.PackageBuilder;
+import org.drools.compiler.PackageBuilderConfiguration;
+import org.drools.rule.MapBackedClassLoader;
import org.drools.rule.Package;
import org.drools.rule.Rule;
-import junit.framework.TestCase;
+public class MarshallingTest extends TestCase {
-public class MarshallingTest extends TestCase {
public void testSerializable() throws Exception {
final Reader reader = new InputStreamReader( getClass().getResourceAsStream( "test_Serializable.drl" ) );
final PackageBuilder builder = new PackageBuilder();
builder.addPackageFromDrl( reader );
- final Package pkg = serialisePackage( builder.getPackage() );
+ final Package pkg = SerializationHelper.serializeObject( builder.getPackage());
assertEquals( 0,
builder.getErrors().getErrors().length );
- RuleBase ruleBase = getRuleBase();// RuleBaseFactory.newRuleBase();
+ RuleBase ruleBase = getRuleBase(pkg);// RuleBaseFactory.newRuleBase();
- ruleBase.addPackage( pkg );
-
Map map = new HashMap();
map.put( "x",
ruleBase );
- final byte[] ast = serializeOut( map );
- map = (Map) serializeIn( ast );
+ map = SerializationHelper.serializeObject( map );
ruleBase = (RuleBase) map.get( "x" );
final Rule[] rules = ruleBase.getPackages()[0].getRules();
assertEquals( 4,
@@ -72,7 +77,7 @@
final Person bob = new Person( "bob" );
workingMemory.insert( bob );
- final byte[] wm = serializeOut( workingMemory );
+ final byte[] wm = SerializationHelper.serializeOut( workingMemory );
workingMemory = ruleBase.newStatefulSession( new ByteArrayInputStream( wm ) );
@@ -106,27 +111,28 @@
final PackageBuilder builder = new PackageBuilder();
builder.addPackageFromDrl( reader );
- final Package pkg = serialisePackage( builder.getPackage() );
+ final Package pkg = SerializationHelper.serializeObject( builder.getPackage() );
assertEquals( 0,
builder.getErrors().getErrors().length );
RuleBase ruleBase = getRuleBase();// RuleBaseFactory.newRuleBase();
+
WorkingMemory workingMemory = ruleBase.newStatefulSession();
Map map = new HashMap();
map.put( "x",
ruleBase );
- final byte[] ast = serializeOut( map );
- map = (Map) serializeIn( ast );
+ map = SerializationHelper.serializeObject(map);
ruleBase = (RuleBase) map.get( "x" );
- final byte[] wm = serializeOut( workingMemory );
+ final byte[] wm = SerializationHelper.serializeOut( workingMemory );
workingMemory = ruleBase.newStatefulSession( new ByteArrayInputStream( wm ) );
ruleBase.addPackage( pkg );
+ ruleBase = SerializationHelper.serializeObject(ruleBase);
workingMemory.setGlobal( "list",
new ArrayList() );
@@ -179,25 +185,24 @@
final PackageBuilder builder = new PackageBuilder();
builder.addPackageFromDrl( reader );
- final Package pkg = serialisePackage( builder.getPackage() );
+ final Package pkg = SerializationHelper.serializeObject( builder.getPackage() );
assertEquals( 0,
builder.getErrors().getErrors().length );
- RuleBase ruleBase = getRuleBase();// RuleBaseFactory.newRuleBase();
+ RuleBase ruleBase = getRuleBase();// RuleBaseFactory.newRuleBase();
// serialise a hashmap with the RuleBase as a key
Map map = new HashMap();
map.put( "x",
ruleBase );
- final byte[] ast = serializeOut( map );
- map = (Map) serializeIn( ast );
+ map = SerializationHelper.serializeObject( map );
ruleBase = (RuleBase) map.get( "x" );
WorkingMemory workingMemory = ruleBase.newStatefulSession();
// serialise the working memory before population
- final byte[] wm = serializeOut( workingMemory );
+ final byte[] wm = SerializationHelper.serializeOut( workingMemory );
workingMemory = ruleBase.newStatefulSession( new ByteArrayInputStream( wm ) );
ruleBase.addPackage( pkg );
@@ -252,7 +257,7 @@
final PackageBuilder builder = new PackageBuilder();
builder.addPackageFromDrl( reader );
- final Package pkg = serialisePackage( builder.getPackage() );
+ final Package pkg = SerializationHelper.serializeObject( builder.getPackage());
assertEquals( 0,
builder.getErrors().getErrors().length );
@@ -272,12 +277,11 @@
Map map = new HashMap();
map.put( "x",
ruleBase );
- final byte[] ast = serializeOut( map );
- map = (Map) serializeIn( ast );
+ map = SerializationHelper.serializeObject( map );
ruleBase = (RuleBase) map.get( "x" );
// now try serialising with a fully populated wm from a serialised rulebase
- final byte[] wm = serializeOut( workingMemory );
+ final byte[] wm = SerializationHelper.serializeOut( workingMemory );
workingMemory = ruleBase.newStatefulSession( new ByteArrayInputStream( wm ) );
final Rule[] rules = ruleBase.getPackages()[0].getRules();
@@ -324,51 +328,48 @@
RuleBase ruleBase = RuleBaseFactory.newRuleBase( );
PackageBuilder builder = new PackageBuilder();
builder.addPackageFromDrl( new InputStreamReader( getClass().getResourceAsStream( "test_Dynamic1.drl" ) ) );
- Package pkg = serialisePackage( builder.getPackage() );
+ Package pkg = SerializationHelper.serializeObject( builder.getPackage());
ruleBase.addPackage( pkg );
-
+ ruleBase = SerializationHelper.serializeObject(ruleBase);
+
StatefulSession session = ruleBase.newStatefulSession();
List list = new ArrayList();
session.setGlobal( "list", list );
-
+
InternalFactHandle stilton = (InternalFactHandle) session.insert( new Cheese( "stilton", 10 ) );
InternalFactHandle brie = (InternalFactHandle) session.insert( new Cheese( "brie", 10 ) );
session.fireAllRules();
-
+
assertEquals( list.size(), 1 );
assertEquals( "stilton", list.get( 0 ));
-
- byte[] serializedSession = serializeOut( session );
+
+ byte[] serializedSession = SerializationHelper.serializeOut( session );
session.dispose();
-
- byte[] serializedRulebase = serializeOut( ruleBase );
-
+
// now recreate the rulebase, deserialize the session and test it
- ruleBase = (RuleBase) serializeIn( serializedRulebase );
-
session = ruleBase.newStatefulSession( new ByteArrayInputStream( serializedSession ) );
list = (List) session.getGlobal( "list" );
-
+
assertNotNull( list );
assertEquals( list.size(), 1 );
assertEquals( "stilton", list.get( 0 ));
-
+
builder = new PackageBuilder();
builder.addPackageFromDrl( new InputStreamReader( getClass().getResourceAsStream( "test_Dynamic3.drl" ) ) );
- pkg = serialisePackage( builder.getPackage() );
+ pkg = SerializationHelper.serializeObject( builder.getPackage());
ruleBase.addPackage( pkg );
-
+
InternalFactHandle stilton2 = (InternalFactHandle) session.insert( new Cheese( "stilton", 10 ) );
InternalFactHandle brie2 = (InternalFactHandle) session.insert( new Cheese( "brie", 10 ) );
InternalFactHandle bob = (InternalFactHandle) session.insert( new Person( "bob", 30 ) );
session.fireAllRules();
-
+
assertEquals( list.size(), 3 );
assertEquals( bob.getObject(), list.get( 1 ));
assertEquals( "stilton", list.get( 2 ));
-
+
session.dispose();
-
+
}
public void testSerializationOfIndexedWM() throws Exception {
@@ -382,15 +383,12 @@
0,
builder.getErrors().getErrors().length );
- RuleBase ruleBase = getRuleBase();// RuleBaseFactory.newRuleBase();
+ RuleBase ruleBase = getRuleBase(pkg);// RuleBaseFactory.newRuleBase();
- ruleBase.addPackage( pkg );
-
Map map = new HashMap();
map.put( "x",
ruleBase );
- final byte[] ast = serializeOut( map );
- map = (Map) serializeIn( ast );
+ map = SerializationHelper.serializeObject( map );
ruleBase = (RuleBase) map.get( "x" );
final Rule[] rules = ruleBase.getPackages()[0].getRules();
assertEquals( 3,
@@ -407,7 +405,7 @@
p.setIntPrimitive( (int) 3 );
workingMemory.insert( p );
- final byte[] wm = serializeOut( workingMemory );
+ final byte[] wm = SerializationHelper.serializeOut( workingMemory );
workingMemory = ruleBase.newStatefulSession( new ByteArrayInputStream( wm ) );
@@ -435,45 +433,486 @@
}
+ /*
+ * Here I am inserting data points which are not used by any rule (e.g Person).
+ * Later adding rule (e.g. Rule: 'match Person') for those data points.
+ *
+ * Result: Pkg/Rule addition is failing with ClassCastException
+ */
+ public void testSerializeAdd2() throws Exception {
+
+ //Create a rulebase, a session, and test it
+ RuleBase ruleBase = RuleBaseFactory.newRuleBase();
+ PackageBuilder builder = new PackageBuilder();
+ builder.addPackageFromDrl( new InputStreamReader( getClass().getResourceAsStream( "test_Dynamic1_0.drl" ) ) );
+ Package pkg = SerializationHelper.serializeObject( builder.getPackage() );
+ ruleBase.addPackage( pkg );
+
+ List results = new ArrayList();
+ StatefulSession session = ruleBase.newStatefulSession();
+ session.setGlobal( "results",
+ results );
+
+ InternalFactHandle stilton1 = (InternalFactHandle) session.insert( new Cheese( "stilton",
+ 10 ) );
+ session.insert( new Cheese( "brie",
+ 10 ) );
+ InternalFactHandle bob = (InternalFactHandle) session.insert( new Person( "bob",
+ 10 ) );
+
+ // fire rules
+ session.fireAllRules();
+ // check the results are correct
+ assertEquals( 1,
+ results.size() );
+ assertEquals( stilton1.getObject(),
+ results.get( 0 ) );
+
+ // serialize session and rulebase out
+ byte[] serializedSession = SerializationHelper.serializeOut( session );
+ byte[] serializedRulebase = SerializationHelper.serializeOut( ruleBase );
+ session.dispose();
+
+ // now deserialize the rulebase, deserialize the session and test it
+ ruleBase = (RuleBase) SerializationHelper.serializeIn( serializedRulebase );
+ session = ruleBase.newStatefulSession( new ByteArrayInputStream( serializedSession ) );
+
+ // dynamically add a new package
+ builder = new PackageBuilder();
+ builder.addPackageFromDrl( new InputStreamReader( getClass().getResourceAsStream( "test_Dynamic3_0.drl" ) ) );
+ pkg = SerializationHelper.serializeObject( builder.getPackage() );
+ ruleBase.addPackage( pkg );
+
+ InternalFactHandle stilton2 = (InternalFactHandle) session.insert( new Cheese( "stilton",
+ 20 ) );
+ session.insert( new Cheese( "brie",
+ 20 ) );
+ InternalFactHandle mark = (InternalFactHandle) session.insert( new Person( "mark",
+ 20 ) );
+ session.fireAllRules();
+
+ results = (List) session.getGlobal( "results" );
+ assertEquals( 4,
+ results.size() );
+ assertEquals( bob.getObject(),
+ results.get( 1 ) );
+ assertEquals( stilton2.getObject(),
+ results.get( 2 ) );
+ assertEquals( mark.getObject(),
+ results.get( 3 ) );
+
+ serializedSession = null;
+ serializedRulebase = null;
+
+ serializedSession = SerializationHelper.serializeOut( session );
+ serializedRulebase = SerializationHelper.serializeOut( ruleBase );
+
+ // dispose session
+ session.dispose();
+
+ }
+
+ /*
+ * Here I am inserting data points(e.g. Cheese) with 'stilton' / 'brie' as type value.
+ * Initially I had only 1 rule ('like stilton') for data points(e.g. Cheese) having type as 'stilton'.
+ *
+ * Later added new rule ('like brie') for data points(e.g. Cheese) having type as 'brie'.
+ *
+ * Result: new rule is not getting fired for new data points having type as 'brie'.
+ * Only for old data points having type as 'brie' the new rule got fired.
+ */
+ public void testSerializeAdd_newRuleNotFiredForNewData() throws Exception {
+ //Create a rulebase, a session, and test it
+ RuleBase ruleBase = RuleBaseFactory.newRuleBase();
+ PackageBuilder builder = new PackageBuilder();
+ builder.addPackageFromDrl( new InputStreamReader( getClass().getResourceAsStream( "test_Dynamic1_0.drl" ) ) );
+ Package pkg = SerializationHelper.serializeObject( builder.getPackage() );
+ ruleBase.addPackage( pkg );
+
+ List results = new ArrayList();
+ StatefulSession session = ruleBase.newStatefulSession();
+ session.setGlobal( "results",
+ results );
+
+ InternalFactHandle stilton1 = (InternalFactHandle) session.insert( new Cheese( "stilton",
+ 10 ) );
+ InternalFactHandle brie1 = (InternalFactHandle) session.insert( new Cheese( "brie",
+ 10 ) );
+ session.fireAllRules();
+
+ byte[] serializedSession = SerializationHelper.serializeOut( session );
+ byte[] serializedRulebase = SerializationHelper.serializeOut( ruleBase );
+
+ session.dispose();
+
+ assertEquals( 1,
+ results.size() );
+ assertEquals( stilton1.getObject(),
+ results.get( 0 ) );
+
+ // now recreate the rulebase, deserialize the session and test it
+ ruleBase = (RuleBase) SerializationHelper.serializeIn( serializedRulebase );
+ session = ruleBase.newStatefulSession( new ByteArrayInputStream( serializedSession ) );
+ results = (List) session.getGlobal( "results" );
+
+ builder = new PackageBuilder();
+ builder.addPackageFromDrl( new InputStreamReader( getClass().getResourceAsStream( "test_Dynamic1_1.drl" ) ) );
+ pkg = SerializationHelper.serializeObject( builder.getPackage() );
+ ruleBase.addPackage( pkg );
+
+ InternalFactHandle stilton2 = (InternalFactHandle) session.insert( new Cheese( "stilton",
+ 20 ) );
+ InternalFactHandle brie2 = (InternalFactHandle) session.insert( new Cheese( "brie",
+ 20 ) );
+ InternalFactHandle brie3 = (InternalFactHandle) session.insert( new Cheese( "brie",
+ 30 ) );
+ session.fireAllRules();
+ assertEquals( 5,
+ results.size() );
+ assertEquals( brie1.getObject(),
+ results.get( 1 ) );
+ assertEquals( stilton2.getObject(),
+ results.get( 2 ) );
+ assertEquals( brie2.getObject(),
+ results.get( 4 ) );
+ assertEquals( brie3.getObject(),
+ results.get( 3 ) );
+
+ serializedSession = null;
+ serializedRulebase = null;
+
+ serializedSession = SerializationHelper.serializeOut( session );
+ serializedRulebase = SerializationHelper.serializeOut( ruleBase );
+
+ session.dispose();
+ }
+
+ /*
+ * Works Fine if both the scenarios mentioned above are skipped.
+ */
+ public void testSerializeAdd3() throws Exception {
+ //Create a rulebase, a session, and test it
+ RuleBase ruleBase = RuleBaseFactory.newRuleBase( );
+ PackageBuilder builder = new PackageBuilder();
+ builder.addPackageFromDrl( new InputStreamReader( getClass().getResourceAsStream( "test_Dynamic1_0.drl" ) ) );
+ Package pkg = SerializationHelper.serializeObject( builder.getPackage() );
+ ruleBase.addPackage( pkg );
+
+ List results = new ArrayList();
+ StatefulSession session = ruleBase.newStatefulSession();
+ session.setGlobal( "results",
+ results );
+
+ InternalFactHandle stilton1 = (InternalFactHandle) session.insert( new Cheese( "stilton",
+ 10 ) );
+ InternalFactHandle brie1 = (InternalFactHandle) session.insert( new Cheese( "brie",
+ 10 ) );
+ session.fireAllRules();
+
+ byte[] serializedSession = SerializationHelper.serializeOut( session );
+ byte[] serializedRulebase = SerializationHelper.serializeOut( ruleBase );
+
+ session.dispose();
+
+ assertEquals( 1,
+ results.size() );
+ assertEquals( stilton1.getObject(),
+ results.get( 0 ) );
+
+ // now recreate the rulebase, deserialize the session and test it
+ ruleBase = (RuleBase) SerializationHelper.serializeIn( serializedRulebase );
+ session = ruleBase.newStatefulSession( new ByteArrayInputStream( serializedSession ) );
+ results = (List) session.getGlobal( "results" );
+
+ builder = new PackageBuilder();
+ builder.addPackageFromDrl( new InputStreamReader( getClass().getResourceAsStream( "test_Dynamic3_0.drl" ) ) );
+ pkg = SerializationHelper.serializeObject( builder.getPackage() );
+
+ ruleBase.addPackage( pkg );
+
+ InternalFactHandle stilton2 = (InternalFactHandle) session.insert( new Cheese( "stilton", 20 ) );
+ InternalFactHandle brie2 = (InternalFactHandle) session.insert( new Cheese( "brie", 20 ) );
+ InternalFactHandle bob1 = (InternalFactHandle) session.insert( new Person( "bob", 20 ) );
+ InternalFactHandle bob2 = (InternalFactHandle) session.insert( new Person( "bob", 30 ) );
+ session.fireAllRules();
+
+ assertEquals( 4,
+ results.size() );
+ assertEquals( stilton2.getObject(),
+ results.get( 1 ) );
+ assertEquals( bob2.getObject(),
+ results.get( 2 ) );
+ assertEquals( bob1.getObject(),
+ results.get( 3 ) );
+
+ serializedSession = null;
+ serializedRulebase = null;
+
+ serializedSession = SerializationHelper.serializeOut( session );
+ serializedRulebase = SerializationHelper.serializeOut( ruleBase );
+
+ session.dispose();
+
+ // now recreate the rulebase, deserialize the session and test it
+ ruleBase = (RuleBase) SerializationHelper.serializeIn( serializedRulebase );
+ session = ruleBase.newStatefulSession( new ByteArrayInputStream( serializedSession ) );
+ results = (List) session.getGlobal( "results" );
+
+ builder = new PackageBuilder();
+ builder.addPackageFromDrl( new InputStreamReader( getClass().getResourceAsStream( "test_Dynamic1_2.drl" ) ) );
+ pkg = SerializationHelper.serializeObject( builder.getPackage() );
+ ruleBase.addPackage( pkg );
+
+ InternalFactHandle stilton3 = (InternalFactHandle) session.insert( new Cheese( "stilton", 40 ) );
+ InternalFactHandle brie3 = (InternalFactHandle) session.insert( new Cheese( "brie", 40 ) );
+ InternalFactHandle bob3 = (InternalFactHandle) session.insert( new Person( "bob", 40 ) );
+ InternalFactHandle bob4 = (InternalFactHandle) session.insert( new Person( "bob", 40 ) );
+ InternalFactHandle addr1 = (InternalFactHandle) session.insert( new Address( "bangalore" ) );
+ InternalFactHandle addr2 = (InternalFactHandle) session.insert( new Address( "India" ) );
+
+ session.fireAllRules();
+
+ assertEquals( 9,
+ results.size() );
+ assertEquals( stilton3.getObject(),
+ results.get( 4 ) );
+ assertEquals( bob4.getObject(),
+ results.get( 5 ) );
+ assertEquals( bob3.getObject(),
+ results.get( 6 ) );
+ assertEquals( addr2.getObject(),
+ results.get( 7 ) );
+ assertEquals( addr1.getObject(),
+ results.get( 8 ) );
+
+ serializedSession = null;
+ serializedRulebase = null;
+
+ serializedSession = SerializationHelper.serializeOut( session );
+ serializedRulebase = SerializationHelper.serializeOut( ruleBase );
+
+ session.dispose();
+
+ // now recreate the rulebase, deserialize the session and test it
+ ruleBase = (RuleBase) SerializationHelper.serializeIn( serializedRulebase );
+ session = ruleBase.newStatefulSession( new ByteArrayInputStream( serializedSession ) );
+ results = (List) session.getGlobal( "results" );
+
+ InternalFactHandle stilton4 = (InternalFactHandle) session.insert( new Cheese( "stilton", 50 ) );
+ InternalFactHandle brie4 = (InternalFactHandle) session.insert( new Cheese( "brie", 50 ) );
+ InternalFactHandle bob5 = (InternalFactHandle) session.insert( new Person( "bob", 50 ) );
+ InternalFactHandle bob6 = (InternalFactHandle) session.insert( new Person( "bob", 50 ) );
+ InternalFactHandle addr3 = (InternalFactHandle) session.insert( new Address( "Tripura" ) );
+ InternalFactHandle addr4 = (InternalFactHandle) session.insert( new Address( "Agartala" ) );
+
+ session.fireAllRules();
+
+ assertEquals( 14,
+ results.size() );
+ assertEquals( stilton4.getObject(),
+ results.get( 9 ) );
+ assertEquals( bob6.getObject(),
+ results.get( 10 ) );
+ assertEquals( bob5.getObject(),
+ results.get( 11 ) );
+ assertEquals( addr4.getObject(),
+ results.get( 12 ) );
+ assertEquals( addr3.getObject(),
+ results.get( 13 ) );
+
+ serializedSession = null;
+ serializedRulebase = null;
+
+ serializedSession = SerializationHelper.serializeOut( session );
+ serializedRulebase = SerializationHelper.serializeOut( ruleBase );
+
+ session.dispose();
+
+ }
+
+ /*
+ * I have tried both the scenarios
+ * 1. Remove a rule from a pkg.
+ * 2. Remove a pkg
+ *
+ * But both cases after inserting associated data points (i.e data points which are used to fire/activate the removed rule)
+ * session.fireAllRules() is throwing NoClassDefFoundError
+ *
+ */
+ public void testSerializeAddRemove_NoClassDefFoundError() throws Exception {
+
+ //Create a rulebase, a session, and test it
+ RuleBase ruleBase = RuleBaseFactory.newRuleBase( );
+ PackageBuilder builder = new PackageBuilder();
+ builder.addPackageFromDrl( new InputStreamReader( getClass().getResourceAsStream( "test_Dynamic1_0.drl" ) ) );
+ Package pkg = SerializationHelper.serializeObject( builder.getPackage() );
+ ruleBase.addPackage( pkg );
+
+ List results = new ArrayList();
+ StatefulSession session = ruleBase.newStatefulSession();
+ session.setGlobal( "results",
+ results );
+
+ InternalFactHandle stilton1 = (InternalFactHandle) session.insert( new Cheese( "stilton",
+ 10 ) );
+ InternalFactHandle brie1 = (InternalFactHandle) session.insert( new Cheese( "brie",
+ 10 ) );
+ session.fireAllRules();
+
+ byte[] serializedSession = SerializationHelper.serializeOut( session );
+ byte[] serializedRulebase = SerializationHelper.serializeOut( ruleBase );
+
+ session.dispose();
+
+ assertEquals( 1,
+ results.size() );
+ assertEquals( stilton1.getObject(),
+ results.get( 0 ) );
+
+ // now recreate the rulebase, deserialize the session and test it
+ ruleBase = (RuleBase) SerializationHelper.serializeIn( serializedRulebase );
+ session = ruleBase.newStatefulSession( new ByteArrayInputStream( serializedSession ) );
+ results = (List) session.getGlobal( "results" );
+
+ builder = new PackageBuilder();
+ builder.addPackageFromDrl( new InputStreamReader( getClass().getResourceAsStream( "test_Dynamic3_0.drl" ) ) );
+ pkg = SerializationHelper.serializeObject( builder.getPackage() );
+
+ ruleBase.addPackage( pkg );
+
+ InternalFactHandle stilton2 = (InternalFactHandle) session.insert( new Cheese( "stilton", 20 ) );
+ InternalFactHandle brie2 = (InternalFactHandle) session.insert( new Cheese( "brie", 20 ) );
+ InternalFactHandle bob1 = (InternalFactHandle) session.insert( new Person( "bob", 20 ) );
+ InternalFactHandle bob2 = (InternalFactHandle) session.insert( new Person( "bob", 30 ) );
+ session.fireAllRules();
+
+ assertEquals( 4,
+ results.size() );
+ assertEquals( stilton2.getObject(),
+ results.get( 1 ) );
+ assertEquals( bob2.getObject(),
+ results.get( 2 ) );
+ assertEquals( bob1.getObject(),
+ results.get( 3 ) );
+
+ serializedSession = null;
+ serializedRulebase = null;
+
+ serializedSession = SerializationHelper.serializeOut( session );
+ serializedRulebase = SerializationHelper.serializeOut( ruleBase );
+
+ session.dispose();
+
+ // now recreate the rulebase, deserialize the session and test it
+ ruleBase = (RuleBase) SerializationHelper.serializeIn( serializedRulebase );
+ session = ruleBase.newStatefulSession( new ByteArrayInputStream( serializedSession ) );
+ results = (List) session.getGlobal( "results" );
+
+ // CASE 1: remove rule
+ ruleBase.removeRule("org.drools.test", "like stilton");
+
+ InternalFactHandle stilton3 = (InternalFactHandle) session.insert( new Cheese( "stilton", 20 ) );
+ InternalFactHandle brie3 = (InternalFactHandle) session.insert( new Cheese( "brie", 20 ) );
+ InternalFactHandle bob3 = (InternalFactHandle) session.insert( new Person( "bob", 20 ) );
+ InternalFactHandle bob4 = (InternalFactHandle) session.insert( new Person( "bob", 30 ) );
+ session.fireAllRules();
+
+ assertEquals( 6,
+ results.size() );
+ assertEquals( bob4.getObject(),
+ results.get( 4 ) );
+ assertEquals( bob3.getObject(),
+ results.get( 5 ) );
+
+
+ // now recreate the rulebase, deserialize the session and test it
+ ruleBase = (RuleBase) SerializationHelper.serializeIn( serializedRulebase );
+ session = ruleBase.newStatefulSession( new ByteArrayInputStream( serializedSession ) );
+ results = (List) session.getGlobal( "results" );
+
+ // CASE 2: remove pkg
+ ruleBase.removePackage("org.drools.test");
+
+ InternalFactHandle stilton4 = (InternalFactHandle) session.insert( new Cheese( "stilton", 20 ) );
+ InternalFactHandle brie4 = (InternalFactHandle) session.insert( new Cheese( "brie", 20 ) );
+ InternalFactHandle bob5 = (InternalFactHandle) session.insert( new Person( "bob", 20 ) );
+ InternalFactHandle bob6 = (InternalFactHandle) session.insert( new Person( "bob", 30 ) );
+ session.fireAllRules();
+
+ assertEquals( 6,
+ results.size() );
+ assertEquals( bob6.getObject(),
+ results.get( 4 ) );
+ assertEquals( bob5.getObject(),
+ results.get( 5 ) );
+
+ serializedSession = null;
+ serializedRulebase = null;
+
+ serializedSession = SerializationHelper.serializeOut( session );
+ serializedRulebase = SerializationHelper.serializeOut( ruleBase );
+
+ session.dispose();
+
+ }
+
+ /**
+ * In this case we are dealing with facts which are not on the systems classpath.
+ *
+ */
+ public void testSerializabilityWithJarFacts() throws Exception {
+ MapBackedClassLoader loader = new MapBackedClassLoader( this.getClass().getClassLoader() );
+
+ JarInputStream jis = new JarInputStream(this.getClass().getResourceAsStream("/billasurf.jar"));
+
+ JarEntry entry = null;
+ byte[] buf = new byte[1024];
+ int len = 0;
+ while ( (entry = jis.getNextJarEntry()) != null ) {
+ if ( !entry.isDirectory() ) {
+ ByteArrayOutputStream out = new ByteArrayOutputStream();
+ while ( (len = jis.read( buf )) >= 0 ) {
+ out.write( buf, 0, len );
+ }
+ loader.addResource( entry.getName() , out.toByteArray() );
+ }
+ }
+
+ String drl = "package foo.bar \n" +
+ "import com.billasurf.Board\n" +
+ "rule 'MyGoodRule' \n dialect 'mvel' \n when Board() then System.err.println(42); \n end\n";
+
+ PackageBuilder builder = new PackageBuilder(new PackageBuilderConfiguration(loader));
+ builder.addPackageFromDrl(new StringReader(drl));
+ assertFalse(builder.hasErrors());
+
+ Package p = builder.getPackage();
+ byte[] ser = SerializationHelper.serializeOut(p);
+
+ //now read it back
+ DroolsObjectInputStream in = new DroolsObjectInputStream(new ByteArrayInputStream(ser), loader);
+ Package p_ = (Package) in.readObject();
+ assertNotNull(p_);
+
+ }
+
protected RuleBase getRuleBase() throws Exception {
return RuleBaseFactory.newRuleBase( RuleBase.RETEOO,
null );
}
+ protected RuleBase getRuleBase(Package pkg) throws Exception {
+ RuleBase ruleBase = getRuleBase();
+
+ ruleBase.addPackage(pkg);
+ return SerializationHelper.serializeObject(ruleBase);
+ }
+
protected RuleBase getRuleBase(final RuleBaseConfiguration config) throws Exception {
return RuleBaseFactory.newRuleBase( RuleBase.RETEOO,
config );
}
-
- protected Package serialisePackage(Package pkg) {
- try {
- byte[] bytes = serializeOut( pkg );
- return (Package) serializeIn( bytes );
- } catch ( Exception e ) {
- throw new RuntimeException( "trouble serialising package.",
- e );
- }
- }
- protected Object serializeIn(final byte[] bytes) throws IOException,
- ClassNotFoundException {
- final ObjectInput in = new ObjectInputStream( new ByteArrayInputStream( bytes ) );
- final Object obj = in.readObject();
- in.close();
- return obj;
- }
-
- protected byte[] serializeOut(final Object obj) throws IOException {
- // Serialize to a byte array
- final ByteArrayOutputStream bos = new ByteArrayOutputStream();
- final ObjectOutput out = new ObjectOutputStream( bos );
- out.writeObject( obj );
- out.close();
-
- // Get the bytes of the serialized object
- final byte[] bytes = bos.toByteArray();
- return bytes;
- }
}
Modified: labs/jbossrules/branches/temporal_rete/drools-compiler/src/test/java/org/drools/integrationtests/MiscTest.java
===================================================================
--- labs/jbossrules/branches/temporal_rete/drools-compiler/src/test/java/org/drools/integrationtests/MiscTest.java 2008-03-20 18:57:07 UTC (rev 19163)
+++ labs/jbossrules/branches/temporal_rete/drools-compiler/src/test/java/org/drools/integrationtests/MiscTest.java 2008-03-20 19:32:10 UTC (rev 19164)
@@ -17,16 +17,14 @@
*/
import java.io.ByteArrayInputStream;
-import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.ObjectInput;
-import java.io.ObjectInputStream;
import java.io.ObjectOutput;
-import java.io.ObjectOutputStream;
import java.io.Reader;
import java.io.StringReader;
import java.math.BigDecimal;
+import java.math.BigInteger;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Iterator;
@@ -45,6 +43,7 @@
import org.drools.CheeseEqual;
import org.drools.Cheesery;
import org.drools.Child;
+import org.drools.DomainObjectHolder;
import org.drools.FactA;
import org.drools.FactB;
import org.drools.FactC;
@@ -79,6 +78,7 @@
import org.drools.WorkingMemory;
import org.drools.Cheesery.Maturity;
import org.drools.audit.WorkingMemoryFileLogger;
+import org.drools.audit.WorkingMemoryInMemoryLogger;
import org.drools.base.ClassObjectFilter;
import org.drools.common.AbstractWorkingMemory;
import org.drools.common.InternalFactHandle;
@@ -108,9 +108,9 @@
import org.drools.lang.descr.AttributeDescr;
import org.drools.lang.descr.PackageDescr;
import org.drools.lang.descr.RuleDescr;
+import org.drools.reteoo.ReteooRuleBase;
import org.drools.rule.InvalidRulePackage;
import org.drools.rule.Package;
-import org.drools.rule.Rule;
import org.drools.rule.builder.dialect.java.JavaDialectConfiguration;
import org.drools.spi.Activation;
import org.drools.spi.ConsequenceExceptionHandler;
@@ -132,15 +132,153 @@
config );
}
+ public void testImportFunctions() throws Exception {
+ final PackageBuilder builder = new PackageBuilder();
+ builder.addPackageFromDrl( new InputStreamReader( getClass().getResourceAsStream( "test_ImportFunctions.drl" ) ) );
+ final Package pkg = builder.getPackage();
+
+ RuleBase ruleBase = getRuleBase();
+ ruleBase.addPackage( pkg );
+ ruleBase = SerializationHelper.serializeObject(ruleBase);
+ WorkingMemory workingMemory = ruleBase.newStatefulSession();
+ final Cheese cheese = new Cheese( "stilton",
+ 15 );
+ workingMemory.insert( cheese );
+ List list = new ArrayList();
+ workingMemory.setGlobal( "list",
+ list );
+ workingMemory = SerializationHelper.serializeObject(workingMemory);
+ workingMemory.fireAllRules();
+
+ list = (List)workingMemory.getGlobal("list");
+ assertEquals( 4,
+ list.size() );
+
+ assertEquals( "rule1",
+ list.get( 0 ) );
+ assertEquals( "rule2",
+ list.get( 1 ) );
+ assertEquals( "rule3",
+ list.get( 2 ) );
+ assertEquals( "rule4",
+ list.get( 3 ) );
+ }
+
+ public void testStaticFieldReference() throws Exception {
+ final PackageBuilder builder = new PackageBuilder();
+ builder.addPackageFromDrl( new InputStreamReader( getClass().getResourceAsStream( "test_StaticField.drl" ) ) );
+ final Package pkg = builder.getPackage();
+
+ RuleBase ruleBase = getRuleBase();
+ ruleBase.addPackage( pkg );
+ ruleBase = SerializationHelper.serializeObject(ruleBase);
+ WorkingMemory workingMemory = ruleBase.newStatefulSession();
+
+ // will test serialisation of int and typesafe enums tests
+ workingMemory = ruleBase.newStatefulSession( new ByteArrayInputStream( SerializationHelper.serializeOut( workingMemory )) );
+
+ List list = new ArrayList();
+ workingMemory.setGlobal( "list",
+ list );
+
+ final Cheesery cheesery1 = new Cheesery();
+ cheesery1.setStatus( Cheesery.SELLING_CHEESE );
+ cheesery1.setMaturity( Maturity.OLD );
+ workingMemory.insert( cheesery1 );
+
+ final Cheesery cheesery2 = new Cheesery();
+ cheesery2.setStatus( Cheesery.MAKING_CHEESE );
+ cheesery2.setMaturity( Maturity.YOUNG );
+ workingMemory.insert( cheesery2 );
+
+ workingMemory.fireAllRules();
+
+ assertEquals( 2,
+ list.size() );
+
+ assertSame( cheesery1, list.get( 0 ) );
+ assertEquals( cheesery1,
+ list.get( 0 ) );
+ assertSame( cheesery2, list.get( 1 ) );
+ assertEquals( cheesery2,
+ list.get( 1 ) );
+
+ // test list after serialising
+ workingMemory = ruleBase.newStatefulSession( new ByteArrayInputStream( SerializationHelper.serializeOut( workingMemory )) );
+ list = (List) workingMemory.getGlobal( "list" );
+ workingMemory.fireAllRules();
+
+ assertEquals(2, list.size());
+
+ assertNotSame( cheesery1, list.get( 0 ) );
+ assertEquals(cheesery1, list.get(0));
+ assertNotSame( cheesery2, list.get( 1 ) );
+ assertEquals(cheesery2, list.get(1));
+ }
+
+ public void testPrimitiveArray() throws Exception {
+ final PackageBuilder builder = new PackageBuilder();
+ builder.addPackageFromDrl( new InputStreamReader( getClass().getResourceAsStream( "test_primitiveArray.drl" ) ) );
+ final Package pkg = builder.getPackage();
+
+ RuleBase ruleBase = getRuleBase();
+ ruleBase.addPackage( pkg );
+ ruleBase = SerializationHelper.serializeObject(ruleBase);
+ WorkingMemory workingMemory = ruleBase.newStatefulSession();
+ List result = new ArrayList();
+ workingMemory.setGlobal( "result",
+ result );
+
+ final Primitives p1 = new Primitives();
+ p1.setPrimitiveArrayAttribute( new int[]{1, 2, 3} );
+ p1.setArrayAttribute( new String[]{"a", "b"} );
+
+ workingMemory.insert( p1 );
+
+ workingMemory = SerializationHelper.serializeObject(workingMemory);
+ result = (List) workingMemory.getGlobal( "result" );
+
+ workingMemory.fireAllRules();
+ assertEquals( 3,
+ result.size() );
+ assertEquals( 3,
+ ((Integer) result.get( 0 )).intValue() );
+ assertEquals( 2,
+ ((Integer) result.get( 1 )).intValue() );
+ assertEquals( 3,
+ ((Integer) result.get( 2 )).intValue() );
+
+ }
+
+ public void testMVELSoundex() throws Exception {
+
+ // read in the source
+ final Reader reader = new InputStreamReader( getClass().getResourceAsStream( "MVEL_soundex.drl" ) );
+ RuleBase ruleBase = loadRuleBase( reader );
+
+ ruleBase = SerializationHelper.serializeObject(ruleBase);
+ WorkingMemory workingMemory = ruleBase.newStatefulSession();
+
+ workingMemory = SerializationHelper.serializeObject(workingMemory);
+ Cheese c = new Cheese( "fubar",
+ 2 );
+
+ workingMemory.insert( c );
+ workingMemory.fireAllRules();
+ assertEquals( 42,
+ c.getPrice() );
+ }
+
public void testGlobals() throws Exception {
final PackageBuilder builder = new PackageBuilder();
builder.addPackageFromDrl( new InputStreamReader( getClass().getResourceAsStream( "globals_rule_test.drl" ) ) );
final Package pkg = builder.getPackage();
- final RuleBase ruleBase = getRuleBase();
+ RuleBase ruleBase = getRuleBase();
ruleBase.addPackage( pkg );
- final WorkingMemory workingMemory = ruleBase.newStatefulSession();
+ ruleBase = SerializationHelper.serializeObject(ruleBase);
+ WorkingMemory workingMemory = ruleBase.newStatefulSession();
final List list = new ArrayList();
workingMemory.setGlobal( "list",
@@ -153,10 +291,11 @@
5 );
workingMemory.insert( stilton );
+ workingMemory = SerializationHelper.serializeObject(workingMemory);
workingMemory.fireAllRules();
assertEquals( new Integer( 5 ),
- list.get( 0 ) );
+ ((List)workingMemory.getGlobal("list")).get( 0 ) );
}
public void testGlobals2() throws Exception {
@@ -165,9 +304,10 @@
builder.addPackageFromDrl( new InputStreamReader( getClass().getResourceAsStream( "test_globalsAsConstraints.drl" ) ) );
final Package pkg = builder.getPackage();
- final RuleBase ruleBase = getRuleBase();
+ RuleBase ruleBase = getRuleBase();
ruleBase.addPackage( pkg );
- final WorkingMemory workingMemory = ruleBase.newStatefulSession();
+ ruleBase = SerializationHelper.serializeObject(ruleBase);
+ WorkingMemory workingMemory = ruleBase.newStatefulSession();
final List results = new ArrayList();
workingMemory.setGlobal( "results",
@@ -183,23 +323,24 @@
5 );
workingMemory.insert( stilton );
+ workingMemory = SerializationHelper.serializeObject(workingMemory);
workingMemory.fireAllRules();
assertEquals( 1,
- results.size() );
+ ((List)workingMemory.getGlobal("results")).size() );
assertEquals( "memberOf",
- results.get( 0 ) );
+ ((List)workingMemory.getGlobal("results")).get( 0 ) );
final Cheese brie = new Cheese( "brie",
5 );
workingMemory.insert( brie );
-
+ workingMemory = SerializationHelper.serializeObject(workingMemory);
workingMemory.fireAllRules();
assertEquals( 2,
- results.size() );
+ ((List)workingMemory.getGlobal("results")).size() );
assertEquals( "not memberOf",
- results.get( 1 ) );
+ ((List)workingMemory.getGlobal("results")).get( 1 ) );
}
public void testCustomGlobalResolver() throws Exception {
@@ -207,9 +348,10 @@
builder.addPackageFromDrl( new InputStreamReader( getClass().getResourceAsStream( "test_globalCustomResolver.drl" ) ) );
final Package pkg = builder.getPackage();
- final RuleBase ruleBase = getRuleBase();
+ RuleBase ruleBase = getRuleBase();
ruleBase.addPackage( pkg );
- final WorkingMemory workingMemory = ruleBase.newStatefulSession();
+ ruleBase = SerializationHelper.serializeObject(ruleBase);
+ WorkingMemory workingMemory = ruleBase.newStatefulSession();
final Map map = new HashMap();
List list = new ArrayList();
@@ -221,6 +363,12 @@
string );
workingMemory.setGlobalResolver( new GlobalResolver() {
+ public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
+ }
+
+ public void writeExternal(ObjectOutput out) throws IOException {
+ }
+
public Object resolveGlobal(String identifier) {
return map.get( identifier );
}
@@ -250,8 +398,9 @@
builder.addPackageFromDrl( new InputStreamReader( getClass().getResourceAsStream( "test_globalCustomResolver.drl" ) ) );
final Package pkg = builder.getPackage();
- final RuleBase ruleBase = getRuleBase();
+ RuleBase ruleBase = getRuleBase();
ruleBase.addPackage( pkg );
+ ruleBase = SerializationHelper.serializeObject(ruleBase);
final WorkingMemory workingMemory = ruleBase.newStatefulSession();
final Map map = new HashMap();
@@ -274,6 +423,11 @@
value );
}
+ public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
+ }
+
+ public void writeExternal(ObjectOutput out) throws IOException {
+ }
} );
Cheese bree = new Cheese();
@@ -310,11 +464,12 @@
builder.addPackageFromDrl( new InputStreamReader( getClass().getResourceAsStream( drl ) ) );
final Package pkg = builder.getPackage();
- final RuleBase ruleBase = getRuleBase();
+ RuleBase ruleBase = getRuleBase();
ruleBase.addPackage( pkg );
- final WorkingMemory wm = ruleBase.newStatefulSession();
+ ruleBase = SerializationHelper.serializeObject(ruleBase);
+ WorkingMemory wm = ruleBase.newStatefulSession();
- final List list = new ArrayList();
+ List list = new ArrayList();
wm.setGlobal( "list",
list );
@@ -322,10 +477,10 @@
tp1.setValue2( "boo" );
wm.insert( tp1 );
+ wm = SerializationHelper.serializeObject(wm);
wm.fireAllRules();
- assertEquals( 1,
- list.size() );
+ assertEquals( 1, ((List)wm.getGlobal("list")).size() );
}
public void testFactBindings() throws Exception {
@@ -334,9 +489,9 @@
final Package pkg = builder.getPackage();
// add the package to a rulebase
- final RuleBase ruleBase = getRuleBase();
+ RuleBase ruleBase = getRuleBase();
ruleBase.addPackage( pkg );
-
+ ruleBase = SerializationHelper.serializeObject(ruleBase);
final WorkingMemory workingMemory = ruleBase.newStatefulSession();
final List events = new ArrayList();
@@ -380,10 +535,11 @@
final Package pkg = builder.getPackage();
// add the package to a rulebase
- final RuleBase ruleBase = getRuleBase();
+ RuleBase ruleBase = getRuleBase();
ruleBase.addPackage( pkg );
+ ruleBase = SerializationHelper.serializeObject(ruleBase);
- final WorkingMemory workingMemory = ruleBase.newStatefulSession();
+ WorkingMemory workingMemory = ruleBase.newStatefulSession();
final List list = new ArrayList();
workingMemory.setGlobal( "list",
@@ -402,10 +558,11 @@
workingMemory.insert( nullPerson );
+ workingMemory = SerializationHelper.serializeObject(workingMemory);
workingMemory.fireAllRules();
- System.out.println( list.get( 0 ) );
+ System.out.println( ((List)workingMemory.getGlobal("list")).get( 0 ) );
assertEquals( 3,
- list.size() );
+ ((List)workingMemory.getGlobal("list")).size() );
}
@@ -415,8 +572,9 @@
final Package pkg = builder.getPackage();
// add the package to a rulebase
- final RuleBase ruleBase = getRuleBase();
+ RuleBase ruleBase = getRuleBase();
ruleBase.addPackage( pkg );
+ ruleBase = SerializationHelper.serializeObject(ruleBase);
WorkingMemory workingMemory = ruleBase.newStatefulSession();
List list = new ArrayList();
@@ -425,12 +583,13 @@
workingMemory.insert( new Attribute() );
workingMemory.insert( new Message() );
+ workingMemory = SerializationHelper.serializeObject(workingMemory);
workingMemory.fireAllRules();
assertEquals( 1,
- list.size() );
+ ((List)workingMemory.getGlobal("list")).size() );
assertEquals( "X",
- list.get( 0 ) );
+ ((List)workingMemory.getGlobal("list")).get( 0 ) );
}
@@ -441,12 +600,13 @@
final Package pkg = builder.getPackage();
// add the package to a rulebase
- final RuleBase ruleBase = getRuleBase();
+ RuleBase ruleBase = getRuleBase();
ruleBase.addPackage( pkg );
+ ruleBase = SerializationHelper.serializeObject(ruleBase);
- final WorkingMemory workingMemory = ruleBase.newStatefulSession();
+ WorkingMemory workingMemory = ruleBase.newStatefulSession();
- final List list = new ArrayList();
+ List list = new ArrayList();
workingMemory.setGlobal( "list",
list );
@@ -454,10 +614,11 @@
5 );
workingMemory.insert( stilton );
+ workingMemory = SerializationHelper.serializeObject(workingMemory);
workingMemory.fireAllRules();
- assertEquals( new Integer( 5 ),
- list.get( 0 ) );
+ assertEquals( 5,
+ ((List)workingMemory.getGlobal("list")).get( 0 ) );
}
private RuleBase loadRuleBase(final Reader reader) throws IOException,
@@ -475,8 +636,9 @@
final Package pkg = builder.getPackage();
// add the package to a rulebase
- final RuleBase ruleBase = getRuleBase();
+ RuleBase ruleBase = getRuleBase();
ruleBase.addPackage( pkg );
+ ruleBase = SerializationHelper.serializeObject(ruleBase);
// load up the rulebase
return ruleBase;
}
@@ -485,7 +647,7 @@
final Reader reader = new InputStreamReader( getClass().getResourceAsStream( "test_ExplicitAnd.drl" ) );
final RuleBase ruleBase = loadRuleBase( reader );
- final WorkingMemory workingMemory = ruleBase.newStatefulSession();
+ WorkingMemory workingMemory = ruleBase.newStatefulSession();
final List list = new ArrayList();
workingMemory.setGlobal( "list",
list );
@@ -498,18 +660,19 @@
workingMemory.insert( new Cheese( "brie",
33 ) );
+ workingMemory = SerializationHelper.serializeObject(workingMemory);
workingMemory.fireAllRules();
assertEquals( 1,
- list.size() );
+ ((List)workingMemory.getGlobal("list")).size() );
}
public void testHelloWorld() throws Exception {
// read in the source
final Reader reader = new InputStreamReader( getClass().getResourceAsStream( "HelloWorld.drl" ) );
- final RuleBase ruleBase = loadRuleBase( reader );
+ RuleBase ruleBase = loadRuleBase( reader );
- final WorkingMemory workingMemory = ruleBase.newStatefulSession();
+ WorkingMemory workingMemory = ruleBase.newStatefulSession();
final List list = new ArrayList();
workingMemory.setGlobal( "list",
@@ -522,38 +685,23 @@
workingMemory.insert( message );
workingMemory.insert( "boo" );
+// workingMemory = SerializationHelper.serializeObject(workingMemory);
workingMemory.fireAllRules();
assertTrue( message.isFired() );
assertEquals( message,
- list.get( 0 ) );
+ ((List)workingMemory.getGlobal("list")).get( 0 ) );
}
- public void testMVELSoundex() throws Exception {
-
- // read in the source
- final Reader reader = new InputStreamReader( getClass().getResourceAsStream( "MVEL_soundex.drl" ) );
- final RuleBase ruleBase = loadRuleBase( reader );
-
- final WorkingMemory workingMemory = ruleBase.newStatefulSession();
-
- Cheese c = new Cheese( "fubar",
- 2 );
-
- workingMemory.insert( c );
- workingMemory.fireAllRules();
- assertEquals( 42,
- c.getPrice() );
- }
-
public void testLiteral() throws Exception {
final PackageBuilder builder = new PackageBuilder();
builder.addPackageFromDrl( new InputStreamReader( getClass().getResourceAsStream( "literal_rule_test.drl" ) ) );
final Package pkg = builder.getPackage();
- final RuleBase ruleBase = getRuleBase();
+ RuleBase ruleBase = getRuleBase();
ruleBase.addPackage( pkg );
- final WorkingMemory workingMemory = ruleBase.newStatefulSession();
+ ruleBase = SerializationHelper.serializeObject(ruleBase);
+ WorkingMemory workingMemory = ruleBase.newStatefulSession();
final List list = new ArrayList();
workingMemory.setGlobal( "list",
@@ -562,11 +710,12 @@
final Cheese stilton = new Cheese( "stilton",
5 );
workingMemory.insert( stilton );
+ workingMemory = SerializationHelper.serializeObject(workingMemory);
workingMemory.fireAllRules();
assertEquals( "stilton",
- list.get( 0 ) );
+ ((List)workingMemory.getGlobal("list")).get( 0 ) );
}
public void testLiteralWithBoolean() throws Exception {
@@ -574,9 +723,10 @@
builder.addPackageFromDrl( new InputStreamReader( getClass().getResourceAsStream( "literal_with_boolean.drl" ) ) );
final Package pkg = builder.getPackage();
- final RuleBase ruleBase = getRuleBase();
+ RuleBase ruleBase = getRuleBase();
ruleBase.addPackage( pkg );
- final WorkingMemory workingMemory = ruleBase.newStatefulSession();
+ ruleBase = SerializationHelper.serializeObject(ruleBase);
+ WorkingMemory workingMemory = ruleBase.newStatefulSession();
final List list = new ArrayList();
workingMemory.setGlobal( "list",
@@ -587,10 +737,12 @@
12 );
bill.setAlive( true );
workingMemory.insert( bill );
+ workingMemory = SerializationHelper.serializeObject(workingMemory);
+
workingMemory.fireAllRules();
assertEquals( bill,
- list.get( 0 ) );
+ ((List)workingMemory.getGlobal("list")).get( 0 ) );
}
public void testFactTemplate() throws Exception {
@@ -598,9 +750,10 @@
builder.addPackageFromDrl( new InputStreamReader( getClass().getResourceAsStream( "test_FactTemplate.drl" ) ) );
final Package pkg = builder.getPackage();
- final RuleBase ruleBase = getRuleBase();
+ RuleBase ruleBase = getRuleBase();
ruleBase.addPackage( pkg );
- final WorkingMemory workingMemory = ruleBase.newStatefulSession();
+ ruleBase = SerializationHelper.serializeObject(ruleBase);
+ WorkingMemory workingMemory = ruleBase.newStatefulSession();
final List list = new ArrayList();
workingMemory.setGlobal( "list",
@@ -613,14 +766,17 @@
stilton.setFieldValue( "price",
new Integer( 100 ) );
workingMemory.insert( stilton );
+ // TODO does not work for facts now. adding equals(object) to it.
+// workingMemory = SerializationHelper.serializeObject(workingMemory);
+
workingMemory.fireAllRules();
assertEquals( 1,
- list.size() );
+ ((List)workingMemory.getGlobal("list")).size() );
assertEquals( stilton,
- list.get( 0 ) );
- final Fact fact = (Fact) list.get( 0 );
- assertSame( stilton,
+ ((List)workingMemory.getGlobal("list")).get( 0 ) );
+ final Fact fact = (Fact) ((List)workingMemory.getGlobal("list")).get( 0 );
+ assertEquals( stilton,
fact );
assertEquals( new Integer( 200 ),
fact.getFieldValue( "price" ) );
@@ -632,9 +788,10 @@
builder.addPackageFromDrl( new InputStreamReader( getClass().getResourceAsStream( "test_PropertyChange.drl" ) ) );
final Package pkg = builder.getPackage();
- final RuleBase ruleBase = getRuleBase();
+ RuleBase ruleBase = getRuleBase();
ruleBase.addPackage( pkg );
- final WorkingMemory workingMemory = ruleBase.newStatefulSession();
+ ruleBase = SerializationHelper.serializeObject(ruleBase);
+ WorkingMemory workingMemory = ruleBase.newStatefulSession();
final List list = new ArrayList();
workingMemory.setGlobal( "list",
@@ -646,20 +803,21 @@
workingMemory.fireAllRules();
assertEquals( 1,
- list.size() );
+ ((List)workingMemory.getGlobal("list")).size() );
state.setFlag( true );
assertEquals( 1,
- list.size() );
+ ((List)workingMemory.getGlobal("list")).size() );
workingMemory.fireAllRules();
assertEquals( 2,
- list.size() );
+ ((List)workingMemory.getGlobal("list")).size() );
state.setState( "finished" );
+// workingMemory = SerializationHelper.serializeObject(workingMemory);
workingMemory.fireAllRules();
assertEquals( 3,
- list.size() );
+ ((List)workingMemory.getGlobal("list")).size() );
}
@@ -669,9 +827,10 @@
builder.addPackageFromDrl( new InputStreamReader( getClass().getResourceAsStream( "big_decimal_and_comparable.drl" ) ) );
final Package pkg = builder.getPackage();
- final RuleBase ruleBase = getRuleBase();
+ RuleBase ruleBase = getRuleBase();
ruleBase.addPackage( pkg );
- final WorkingMemory workingMemory = ruleBase.newStatefulSession();
+ ruleBase = SerializationHelper.serializeObject(ruleBase);
+ WorkingMemory workingMemory = ruleBase.newStatefulSession();
final List list = new ArrayList();
workingMemory.setGlobal( "list",
@@ -689,12 +848,98 @@
workingMemory.insert( bill );
workingMemory.insert( ben );
+ workingMemory = SerializationHelper.serializeObject(workingMemory);
workingMemory.fireAllRules();
assertEquals( 1,
- list.size() );
+ ((List)workingMemory.getGlobal("list")).size() );
}
+ public void testBigDecimalIntegerLiteral() throws Exception {
+
+ final PackageBuilder builder = new PackageBuilder();
+ builder.addPackageFromDrl(new InputStreamReader(getClass()
+ .getResourceAsStream("big_decimal_and_literal.drl")));
+ final Package pkg = builder.getPackage();
+
+ final RuleBase ruleBase = getRuleBase();
+ ruleBase.addPackage(pkg);
+ WorkingMemory workingMemory = ruleBase.newStatefulSession();
+
+ final List list = new ArrayList();
+ workingMemory.setGlobal("list", list);
+
+ final PersonInterface bill = new Person("bill", null, 12);
+ bill.setBigDecimal(new BigDecimal("42"));
+ bill.setBigInteger(new BigInteger("42"));
+
+ workingMemory.insert(bill);
+ workingMemory = SerializationHelper.serializeObject(workingMemory);
+ workingMemory.fireAllRules();
+
+ assertEquals(6, ((List)workingMemory.getGlobal("list")).size());
+ }
+
+
+ // @FIXME
+ public void FIXME_testBigDecimalWithFromAndEval() throws Exception {
+ String rule = "package org.test;\n";
+ rule += "rule \"Test Rule\"\n";
+ rule += "when\n";
+ rule += " $dec : java.math.BigDecimal() from java.math.BigDecimal.TEN;\n";
+ rule += " eval( $dec.compareTo(java.math.BigDecimal.ONE) > 0 )\n";
+ rule += "then\n";
+ rule += " System.out.println(\"OK!\");\n";
+ rule += "end";
+
+ final PackageBuilder builder = new PackageBuilder();
+ builder.addPackageFromDrl( new StringReader( rule ) );
+ final Package pkg = builder.getPackage();
+
+ final RuleBase ruleBase = getRuleBase();
+ ruleBase.addPackage( pkg );
+ StatefulSession session = ruleBase.newStatefulSession();
+
+ session.fireAllRules();
+
+ }
+
+ public void testMVELConsequenceWithMapsAndArrays() throws Exception {
+ String rule = "package org.test;\n";
+ rule += "import java.util.ArrayList\n";
+ rule += "import java.util.HashMap\n";
+ rule += "global java.util.List list\n";
+ rule += "rule \"Test Rule\"\n";
+ rule += " dialect \"mvel\"";
+ rule += "when\n";
+ rule += "then\n";
+ rule += " m = new HashMap();\n";
+ rule += " l = new ArrayList();\n";
+ rule += " l.add(\"first\");\n";
+ rule += " m.put(\"content\", l);\n";
+ rule += " System.out.println(m[\"content\"][0]);\n";
+ rule += " list.add(m[\"content\"][0]);\n";
+ rule += "end";
+
+ final PackageBuilder builder = new PackageBuilder();
+ builder.addPackageFromDrl( new StringReader( rule ) );
+ final Package pkg = builder.getPackage();
+
+ final RuleBase ruleBase = getRuleBase();
+ ruleBase.addPackage( pkg );
+ StatefulSession session = ruleBase.newStatefulSession();
+ List list = new ArrayList();
+ session.setGlobal( "list",
+ list );
+ session = SerializationHelper.serializeObject(session);
+ session.fireAllRules();
+
+ assertEquals( 1,
+ ((List)session.getGlobal("list")).size() );
+ assertEquals( "first",
+ ((List)session.getGlobal("list")).get( 0 ) );
+ }
+
public void testCell() throws Exception {
final Cell cell1 = new Cell( 9 );
final Cell cell = new Cell( 0 );
@@ -702,12 +947,15 @@
final PackageBuilder builder = new PackageBuilder();
builder.addPackageFromDrl( new InputStreamReader( getClass().getResourceAsStream( "evalmodify.drl" ) ) );
- final RuleBase ruleBase = getRuleBase();
+ RuleBase ruleBase = getRuleBase();
ruleBase.addPackage( builder.getPackage() );
+ ruleBase = SerializationHelper.serializeObject(ruleBase);
- final WorkingMemory memory = ruleBase.newStatefulSession();
+ WorkingMemory memory = ruleBase.newStatefulSession();
memory.insert( cell1 );
memory.insert( cell );
+ // TODO org.drools.spi.ConsequenceException: org.drools.FactException: Update error: handle not found for object: org.drools.Cell at 1654. Is it in the working memory?
+// memory = SerializationHelper.serializeObject(memory);
memory.fireAllRules();
assertEquals( 9,
cell.getValue() );
@@ -752,12 +1000,14 @@
((AttributeDescr) ruleAttrs.get( 0 )).getValue() );
assertEquals( "dialect",
((AttributeDescr) ruleAttrs.get( 0 )).getName() );
- final RuleBase ruleBase = getRuleBase();
+ RuleBase ruleBase = getRuleBase();
ruleBase.addPackage( builder.getPackage() );
- final WorkingMemory memory = ruleBase.newStatefulSession();
+ ruleBase = SerializationHelper.serializeObject(ruleBase);
+ WorkingMemory memory = ruleBase.newStatefulSession();
memory.insert( p );
+ memory = SerializationHelper.serializeObject(memory);
memory.fireAllRules();
}
@@ -767,9 +1017,10 @@
builder.addPackageFromDrl( new InputStreamReader( getClass().getResourceAsStream( "or_test.drl" ) ) );
final Package pkg = builder.getPackage();
- final RuleBase ruleBase = getRuleBase();
+ RuleBase ruleBase = getRuleBase();
ruleBase.addPackage( pkg );
- final WorkingMemory workingMemory = ruleBase.newStatefulSession();
+ ruleBase = SerializationHelper.serializeObject(ruleBase);
+ WorkingMemory workingMemory = ruleBase.newStatefulSession();
final List list = new ArrayList();
workingMemory.setGlobal( "list",
list );
@@ -795,11 +1046,12 @@
workingMemory.insert( new Cheese( "stilton",
5 ) );
+ workingMemory = SerializationHelper.serializeObject(workingMemory);
workingMemory.fireAllRules();
// now have one more
assertEquals( 2,
- list.size() );
+ ((List)workingMemory.getGlobal("list")).size() );
}
@@ -808,13 +1060,15 @@
builder.addPackageFromDrl( new InputStreamReader( getClass().getResourceAsStream( "simple_query_test.drl" ) ) );
final Package pkg = builder.getPackage();
- final RuleBase ruleBase = getRuleBase();
+ RuleBase ruleBase = getRuleBase();
ruleBase.addPackage( pkg );
- final WorkingMemory workingMemory = ruleBase.newStatefulSession();
+ ruleBase = SerializationHelper.serializeObject(ruleBase);
+ WorkingMemory workingMemory = ruleBase.newStatefulSession();
final Cheese stilton = new Cheese( "stinky",
5 );
workingMemory.insert( stilton );
+ workingMemory = SerializationHelper.serializeObject(workingMemory);
final QueryResults results = workingMemory.getQueryResults( "simple query" );
assertEquals( 1,
results.size() );
@@ -827,7 +1081,7 @@
final RuleBase ruleBase = getRuleBase();
ruleBase.addPackage( pkg );
- final WorkingMemory workingMemory = ruleBase.newStatefulSession();
+ WorkingMemory workingMemory = ruleBase.newStatefulSession();
workingMemory.setGlobal( "five",
new Integer( 5 ) );
@@ -839,10 +1093,11 @@
final Cheese stilton = new Cheese( "stilton",
5 );
workingMemory.insert( stilton );
+ workingMemory = SerializationHelper.serializeObject(workingMemory);
workingMemory.fireAllRules();
assertEquals( stilton,
- list.get( 0 ) );
+ ((List)workingMemory.getGlobal("list")).get( 0 ) );
}
public void testJaninoEval() throws Exception {
@@ -854,9 +1109,10 @@
builder.addPackageFromDrl( new InputStreamReader( getClass().getResourceAsStream( "eval_rule_test.drl" ) ) );
final Package pkg = builder.getPackage();
- final RuleBase ruleBase = getRuleBase();
+ RuleBase ruleBase = getRuleBase();
ruleBase.addPackage( pkg );
- final WorkingMemory workingMemory = ruleBase.newStatefulSession();
+ ruleBase = SerializationHelper.serializeObject(ruleBase);
+ WorkingMemory workingMemory = ruleBase.newStatefulSession();
workingMemory.setGlobal( "five",
new Integer( 5 ) );
@@ -868,10 +1124,11 @@
final Cheese stilton = new Cheese( "stilton",
5 );
workingMemory.insert( stilton );
+ workingMemory = SerializationHelper.serializeObject(workingMemory);
workingMemory.fireAllRules();
assertEquals( stilton,
- list.get( 0 ) );
+ ((List)workingMemory.getGlobal("list")).get( 0 ) );
}
public void testEvalMore() throws Exception {
@@ -879,9 +1136,10 @@
builder.addPackageFromDrl( new InputStreamReader( getClass().getResourceAsStream( "eval_rule_test_more.drl" ) ) );
final Package pkg = builder.getPackage();
- final RuleBase ruleBase = getRuleBase();
+ RuleBase ruleBase = getRuleBase();
ruleBase.addPackage( pkg );
- final WorkingMemory workingMemory = ruleBase.newStatefulSession();
+ ruleBase = SerializationHelper.serializeObject(ruleBase);
+ WorkingMemory workingMemory = ruleBase.newStatefulSession();
final List list = new ArrayList();
workingMemory.setGlobal( "list",
@@ -889,10 +1147,11 @@
final Person foo = new Person( "foo" );
workingMemory.insert( foo );
+ workingMemory = SerializationHelper.serializeObject(workingMemory);
workingMemory.fireAllRules();
assertEquals( foo,
- list.get( 0 ) );
+ ((List)workingMemory.getGlobal("list")).get( 0 ) );
}
public void testReturnValue() throws Exception {
@@ -900,9 +1159,10 @@
builder.addPackageFromDrl( new InputStreamReader( getClass().getResourceAsStream( "returnvalue_rule_test.drl" ) ) );
final Package pkg = builder.getPackage();
- final RuleBase ruleBase = getRuleBase();
+ RuleBase ruleBase = getRuleBase();
ruleBase.addPackage( pkg );
- final WorkingMemory workingMemory = ruleBase.newStatefulSession();
+ ruleBase = SerializationHelper.serializeObject(ruleBase);
+ WorkingMemory workingMemory = ruleBase.newStatefulSession();
workingMemory.setGlobal( "two",
new Integer( 2 ) );
@@ -920,12 +1180,13 @@
10 );
workingMemory.insert( jane );
+ workingMemory = SerializationHelper.serializeObject(workingMemory);
workingMemory.fireAllRules();
assertEquals( jane,
- list.get( 0 ) );
+ ((List)workingMemory.getGlobal("list")).get( 0 ) );
assertEquals( peter,
- list.get( 1 ) );
+ ((List)workingMemory.getGlobal("list")).get( 1 ) );
}
public void testPredicate() throws Exception {
@@ -933,9 +1194,10 @@
builder.addPackageFromDrl( new InputStreamReader( getClass().getResourceAsStream( "predicate_rule_test.drl" ) ) );
final Package pkg = builder.getPackage();
- final RuleBase ruleBase = getRuleBase();
+ RuleBase ruleBase = getRuleBase();
ruleBase.addPackage( pkg );
- final WorkingMemory workingMemory = ruleBase.newStatefulSession();
+ ruleBase = SerializationHelper.serializeObject(ruleBase);
+ WorkingMemory workingMemory = ruleBase.newStatefulSession();
workingMemory.setGlobal( "two",
new Integer( 2 ) );
@@ -953,12 +1215,13 @@
10 );
workingMemory.insert( jane );
+ workingMemory = SerializationHelper.serializeObject(workingMemory);
workingMemory.fireAllRules();
assertEquals( jane,
- list.get( 0 ) );
+ ((List)workingMemory.getGlobal("list")).get( 0 ) );
assertEquals( peter,
- list.get( 1 ) );
+ ((List)workingMemory.getGlobal("list")).get( 1 ) );
}
public void testNullBehaviour() throws Exception {
@@ -966,9 +1229,10 @@
builder.addPackageFromDrl( new InputStreamReader( getClass().getResourceAsStream( "null_behaviour.drl" ) ) );
final Package pkg = builder.getPackage();
- final RuleBase ruleBase = getRuleBase();
+ RuleBase ruleBase = getRuleBase();
ruleBase.addPackage( pkg );
- final WorkingMemory workingMemory = ruleBase.newStatefulSession();
+ ruleBase = SerializationHelper.serializeObject(ruleBase);
+ WorkingMemory workingMemory = ruleBase.newStatefulSession();
final PersonInterface p1 = new Person( "michael",
"food",
@@ -979,8 +1243,8 @@
workingMemory.insert( p1 );
workingMemory.insert( p2 );
+ workingMemory = SerializationHelper.serializeObject(workingMemory);
workingMemory.fireAllRules();
-
}
public void testNullConstraint() throws Exception {
@@ -988,9 +1252,10 @@
builder.addPackageFromDrl( new InputStreamReader( getClass().getResourceAsStream( "null_constraint.drl" ) ) );
final Package pkg = builder.getPackage();
- final RuleBase ruleBase = getRuleBase();
+ RuleBase ruleBase = getRuleBase();
ruleBase.addPackage( pkg );
- final WorkingMemory workingMemory = ruleBase.newStatefulSession();
+ ruleBase = SerializationHelper.serializeObject(ruleBase);
+ WorkingMemory workingMemory = ruleBase.newStatefulSession();
final List foo = new ArrayList();
workingMemory.setGlobal( "messages",
foo );
@@ -1004,50 +1269,23 @@
workingMemory.insert( p1 );
workingMemory.insert( p2 );
+ workingMemory = SerializationHelper.serializeObject(workingMemory);
workingMemory.fireAllRules();
assertEquals( 2,
- foo.size() );
+ ((List)workingMemory.getGlobal("messages")).size() );
}
- public void testImportFunctions() throws Exception {
- final PackageBuilder builder = new PackageBuilder();
- builder.addPackageFromDrl( new InputStreamReader( getClass().getResourceAsStream( "test_ImportFunctions.drl" ) ) );
- final Package pkg = builder.getPackage();
-
- final RuleBase ruleBase = getRuleBase();
- ruleBase.addPackage( pkg );
- final WorkingMemory workingMemory = ruleBase.newStatefulSession();
- final Cheese cheese = new Cheese( "stilton",
- 15 );
- workingMemory.insert( cheese );
- final List list = new ArrayList();
- workingMemory.setGlobal( "list",
- list );
- workingMemory.fireAllRules();
-
- assertEquals( 4,
- list.size() );
-
- assertEquals( "rule1",
- list.get( 0 ) );
- assertEquals( "rule2",
- list.get( 1 ) );
- assertEquals( "rule3",
- list.get( 2 ) );
- assertEquals( "rule4",
- list.get( 3 ) );
- }
-
public void testBasicFrom() throws Exception {
final PackageBuilder builder = new PackageBuilder();
builder.addPackageFromDrl( new InputStreamReader( getClass().getResourceAsStream( "test_From.drl" ) ) );
final Package pkg = builder.getPackage();
- final RuleBase ruleBase = getRuleBase();
+ RuleBase ruleBase = getRuleBase();
ruleBase.addPackage( pkg );
+ ruleBase = SerializationHelper.serializeObject(ruleBase);
- final WorkingMemory workingMemory = ruleBase.newStatefulSession();
+ WorkingMemory workingMemory = ruleBase.newStatefulSession();
final List list1 = new ArrayList();
workingMemory.setGlobal( "list1",
list1 );
@@ -1072,29 +1310,33 @@
Person p = new Person( "stilton" );
workingMemory.insert( p );
+ // TODO - can not serializing rule with basic from: java.io.EOFException.
+// workingMemory = SerializationHelper.serializeObject(workingMemory);
workingMemory.fireAllRules();
+// workingMemory = SerializationHelper.serializeObject(workingMemory);
+ workingMemory.fireAllRules();
// from using a global
assertEquals( 2,
- list1.size() );
+ ((List)workingMemory.getGlobal("list1")).size() );
assertEquals( cheddar,
- list1.get( 0 ) );
+ ((List)workingMemory.getGlobal("list1")).get( 0 ) );
assertEquals( stilton,
- list1.get( 1 ) );
+ ((List)workingMemory.getGlobal("list1")).get( 1 ) );
// from using a declaration
assertEquals( 2,
- list2.size() );
+ ((List)workingMemory.getGlobal("list2")).size() );
assertEquals( cheddar,
- list2.get( 0 ) );
+ ((List)workingMemory.getGlobal("list2")).get( 0 ) );
assertEquals( stilton,
- list2.get( 1 ) );
+ ((List)workingMemory.getGlobal("list2")).get( 1 ) );
// from using a declaration
assertEquals( 1,
- list3.size() );
+ ((List)workingMemory.getGlobal("list3")).size() );
assertEquals( stilton,
- list3.get( 0 ) );
+ ((List)workingMemory.getGlobal("list3")).get( 0 ) );
}
public void testFromWithParams() throws Exception {
@@ -1102,11 +1344,12 @@
builder.addPackageFromDrl( new InputStreamReader( getClass().getResourceAsStream( "test_FromWithParams.drl" ) ) );
final Package pkg = builder.getPackage();
- final RuleBase ruleBase = getRuleBase();
+ RuleBase ruleBase = getRuleBase();
ruleBase.addPackage( pkg );
+ ruleBase = SerializationHelper.serializeObject(ruleBase);
- final WorkingMemory workingMemory = ruleBase.newStatefulSession();
- final List list = new ArrayList();
+ WorkingMemory workingMemory = ruleBase.newStatefulSession();
+ List list = new ArrayList();
final Object globalObject = new Object();
workingMemory.setGlobal( "list",
list );
@@ -1118,17 +1361,19 @@
final Person bob = new Person( "bob" );
workingMemory.insert( bob );
+ // TODO java.io.NotSerializableException: org.mvel.util.FastList
+// workingMemory = SerializationHelper.serializeObject(workingMemory);
workingMemory.fireAllRules();
assertEquals( 6,
- list.size() );
+ ((List)workingMemory.getGlobal("list")).size() );
- final List array = (List) list.get( 0 );
+ final List array = (List) ((List)workingMemory.getGlobal("list")).get( 0 );
assertEquals( 3,
array.size() );
final Person p = (Person) array.get( 0 );
- assertSame( p,
- bob );
+ assertEquals( p,
+ bob );
assertEquals( new Integer( 42 ),
array.get( 1 ) );
@@ -1139,13 +1384,13 @@
assertEquals( "y",
nested.get( 1 ) );
- final Map map = (Map) list.get( 1 );
+ final Map map = (Map) ((List)workingMemory.getGlobal("list")).get( 1 );
assertEquals( 2,
map.keySet().size() );
assertTrue( map.keySet().contains( bob ) );
- assertSame( globalObject,
- map.get( bob ) );
+ assertEquals( globalObject,
+ map.get( bob ) );
assertTrue( map.keySet().contains( "key1" ) );
final Map nestedMap = (Map) map.get( "key1" );
@@ -1156,13 +1401,13 @@
nestedMap.get( "key2" ) );
assertEquals( new Integer( 42 ),
- list.get( 2 ) );
+ ((List)workingMemory.getGlobal("list")).get( 2 ) );
assertEquals( "literal",
- list.get( 3 ) );
- assertSame( bob,
- list.get( 4 ) );
- assertSame( globalObject,
- list.get( 5 ) );
+ ((List)workingMemory.getGlobal("list")).get( 3 ) );
+ assertEquals( bob,
+ ((List)workingMemory.getGlobal("list")).get( 4 ) );
+ assertEquals( globalObject,
+ ((List)workingMemory.getGlobal("list")).get( 5 ) );
}
public void testFromWithNewConstructor() throws Exception {
@@ -1172,8 +1417,50 @@
builder.addPackage( descr );
Package pkg = builder.getPackage();
pkg.checkValidity();
+ pkg = SerializationHelper.serializeObject(pkg);
}
+
+ /**
+ * @see JBRULES-1415 Certain uses of from causes NullPointerException in WorkingMemoryLogger
+ */
+ public void testFromDeclarationWithWorkingMemoryLogger() throws Exception {
+ String rule = "package org.test;\n";
+ rule += "import org.drools.Cheesery\n";
+ rule += "import org.drools.Cheese\n";
+ rule += "global java.util.List list\n";
+ rule += "rule \"Test Rule\"\n";
+ rule += "when\n";
+ rule += " $cheesery : Cheesery()\n";
+ rule += " Cheese( $type : type) from $cheesery.cheeses\n";
+ rule += "then\n";
+ rule += " list.add( $type );\n";
+ rule += "end";
+ final PackageBuilder builder = new PackageBuilder();
+ builder.addPackageFromDrl( new StringReader( rule ));
+ final Package pkg = builder.getPackage();
+
+ final RuleBase ruleBase = getRuleBase();
+ ruleBase.addPackage(pkg);
+ StatefulSession session = ruleBase.newStatefulSession();
+
+ WorkingMemoryInMemoryLogger logger = new WorkingMemoryInMemoryLogger( session );
+ List list = new ArrayList();
+ session.setGlobal( "list", list );
+
+ Cheesery cheesery = new Cheesery();
+ cheesery.addCheese( new Cheese("stilton", 22) );
+
+ session.insert( cheesery );
+
+ // TODO java.io.EOFException
+// session = SerializationHelper.serializeObject(session);
+ session.fireAllRules();
+
+ assertEquals( 1, ((List)session.getGlobal("list")).size());
+ assertEquals( "stilton", ((List)session.getGlobal("list")).get(0));
+}
+
public void testWithInvalidRule() throws Exception {
final PackageBuilder builder = new PackageBuilder();
builder.addPackageFromDrl( new InputStreamReader( getClass().getResourceAsStream( "invalid_rule.drl" ) ) );
@@ -1184,7 +1471,7 @@
RuntimeException runtime = null;
// this should ralph all over the place.
- final RuleBase ruleBase = getRuleBase();
+ RuleBase ruleBase = getRuleBase();
try {
ruleBase.addPackage( pkg );
fail( "Should have thrown an exception as the rule is NOT VALID." );
@@ -1192,6 +1479,7 @@
assertNotNull( e.getMessage() );
runtime = e;
}
+ ruleBase = SerializationHelper.serializeObject(ruleBase);
assertTrue( builder.getErrors().getErrors().length > 0 );
final String pretty = builder.getErrors().toString();
@@ -1252,9 +1540,10 @@
builder.addPackageFromDrl( new InputStreamReader( getClass().getResourceAsStream( "test_FunctionInConsequence.drl" ) ) );
final Package pkg = builder.getPackage();
- final RuleBase ruleBase = getRuleBase();
+ RuleBase ruleBase = getRuleBase();
ruleBase.addPackage( pkg );
- final WorkingMemory workingMemory = ruleBase.newStatefulSession();
+ ruleBase = SerializationHelper.serializeObject(ruleBase);
+ WorkingMemory workingMemory = ruleBase.newStatefulSession();
final List list = new ArrayList();
workingMemory.setGlobal( "list",
@@ -1264,10 +1553,11 @@
5 );
workingMemory.insert( stilton );
+ workingMemory = SerializationHelper.serializeObject(workingMemory);
workingMemory.fireAllRules();
assertEquals( new Integer( 5 ),
- list.get( 0 ) );
+ ((List)workingMemory.getGlobal("list")).get( 0 ) );
}
public void testAssertRetract() throws Exception {
@@ -1276,9 +1566,10 @@
builder.addPackageFromDrl( new InputStreamReader( getClass().getResourceAsStream( "assert_retract.drl" ) ) );
final Package pkg = builder.getPackage();
- final RuleBase ruleBase = getRuleBase();
+ RuleBase ruleBase = getRuleBase();
ruleBase.addPackage( pkg );
- final WorkingMemory workingMemory = ruleBase.newStatefulSession();
+ ruleBase = SerializationHelper.serializeObject(ruleBase);
+ WorkingMemory workingMemory = ruleBase.newStatefulSession();
final List list = new ArrayList();
workingMemory.setGlobal( "list",
@@ -1288,15 +1579,18 @@
"cheese" );
person.setStatus( "start" );
workingMemory.insert( person );
+
+ // TODO org.drools.spi.ConsequenceException: org.drools.FactException: Update error: handle not found for object:
+// workingMemory = SerializationHelper.serializeObject(workingMemory);
workingMemory.fireAllRules();
assertEquals( 5,
- list.size() );
- assertTrue( list.contains( "first" ) );
- assertTrue( list.contains( "second" ) );
- assertTrue( list.contains( "third" ) );
- assertTrue( list.contains( "fourth" ) );
- assertTrue( list.contains( "fifth" ) );
+ ((List)workingMemory.getGlobal("list")).size() );
+ assertTrue( ((List)workingMemory.getGlobal("list")).contains( "first" ) );
+ assertTrue( ((List)workingMemory.getGlobal("list")).contains( "second" ) );
+ assertTrue( ((List)workingMemory.getGlobal("list")).contains( "third" ) );
+ assertTrue( ((List)workingMemory.getGlobal("list")).contains( "fourth" ) );
+ assertTrue( ((List)workingMemory.getGlobal("list")).contains( "fifth" ) );
}
@@ -1305,8 +1599,9 @@
builder.addPackageFromDrl( new InputStreamReader( getClass().getResourceAsStream( "predicate_as_first_pattern.drl" ) ) );
final Package pkg = builder.getPackage();
- final RuleBase ruleBase = getRuleBase();
+ RuleBase ruleBase = getRuleBase();
ruleBase.addPackage( pkg );
+ ruleBase = SerializationHelper.serializeObject(ruleBase);
final WorkingMemory workingMemory = ruleBase.newStatefulSession();
final Cheese mussarela = new Cheese( "Mussarela",
@@ -1357,8 +1652,9 @@
CustomConsequenceExceptionHandler handler = new CustomConsequenceExceptionHandler();
conf.setConsequenceExceptionHandler( handler );
- final RuleBase ruleBase = getRuleBase( conf );
+ RuleBase ruleBase = getRuleBase( conf );
ruleBase.addPackage( pkg );
+ ruleBase = SerializationHelper.serializeObject(ruleBase);
final WorkingMemory workingMemory = ruleBase.newStatefulSession();
final Cheese brie = new Cheese( "brie",
@@ -1367,7 +1663,7 @@
workingMemory.fireAllRules();
- assertTrue( handler.isCalled() );
+ assertTrue( ((CustomConsequenceExceptionHandler)((ReteooRuleBase)ruleBase).getConfiguration().getConsequenceExceptionHandler()).isCalled() );
}
public static class CustomConsequenceExceptionHandler
@@ -1386,6 +1682,13 @@
return this.called;
}
+ public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
+ called = in.readBoolean();
+ }
+
+ public void writeExternal(ObjectOutput out) throws IOException {
+ out.writeBoolean(called);
+ }
}
public void testFunctionException() throws Exception {
@@ -1393,8 +1696,9 @@
builder.addPackageFromDrl( new InputStreamReader( getClass().getResourceAsStream( "test_FunctionException.drl" ) ) );
final Package pkg = builder.getPackage();
- final RuleBase ruleBase = getRuleBase();
+ RuleBase ruleBase = getRuleBase();
ruleBase.addPackage( pkg );
+ ruleBase = SerializationHelper.serializeObject(ruleBase);
final WorkingMemory workingMemory = ruleBase.newStatefulSession();
final Cheese brie = new Cheese( "brie",
@@ -1415,8 +1719,9 @@
builder.addPackageFromDrl( new InputStreamReader( getClass().getResourceAsStream( "test_EvalException.drl" ) ) );
final Package pkg = builder.getPackage();
- final RuleBase ruleBase = getRuleBase();
+ RuleBase ruleBase = getRuleBase();
ruleBase.addPackage( pkg );
+ ruleBase = SerializationHelper.serializeObject(ruleBase);
final WorkingMemory workingMemory = ruleBase.newStatefulSession();
final Cheese brie = new Cheese( "brie",
@@ -1437,8 +1742,9 @@
builder.addPackageFromDrl( new InputStreamReader( getClass().getResourceAsStream( "test_PredicateException.drl" ) ) );
final Package pkg = builder.getPackage();
- final RuleBase ruleBase = getRuleBase();
+ RuleBase ruleBase = getRuleBase();
ruleBase.addPackage( pkg );
+ ruleBase = SerializationHelper.serializeObject(ruleBase);
final WorkingMemory workingMemory = ruleBase.newStatefulSession();
final Cheese brie = new Cheese( "brie",
@@ -1459,8 +1765,9 @@
builder.addPackageFromDrl( new InputStreamReader( getClass().getResourceAsStream( "test_ReturnValueException.drl" ) ) );
final Package pkg = builder.getPackage();
- final RuleBase ruleBase = getRuleBase();
+ RuleBase ruleBase = getRuleBase();
ruleBase.addPackage( pkg );
+ ruleBase = SerializationHelper.serializeObject(ruleBase);
final WorkingMemory workingMemory = ruleBase.newStatefulSession();
final Cheese brie = new Cheese( "brie",
@@ -1480,8 +1787,9 @@
builder.addPackageFromDrl( new InputStreamReader( getClass().getResourceAsStream( "test_MultiRestrictionFieldConstraint.drl" ) ) );
final Package pkg = builder.getPackage();
- final RuleBase ruleBase = getRuleBase();
+ RuleBase ruleBase = getRuleBase();
ruleBase.addPackage( pkg );
+ ruleBase = SerializationHelper.serializeObject(ruleBase);
final WorkingMemory workingMemory = ruleBase.newStatefulSession();
final List list1 = new ArrayList();
@@ -1558,6 +1866,7 @@
RuleBase ruleBase = getRuleBase();
ruleBase.addPackage( builder.getPackage() );
+ ruleBase = SerializationHelper.serializeObject(ruleBase);
WorkingMemory workingMemory = ruleBase.newStatefulSession();
List list = new ArrayList();
@@ -1640,8 +1949,9 @@
builder.addPackageFromDrl( new InputStreamReader( getClass().getResourceAsStream( "test_ContainsCheese.drl" ) ) );
final Package pkg = builder.getPackage();
- final RuleBase ruleBase = getRuleBase();
+ RuleBase ruleBase = getRuleBase();
ruleBase.addPackage( pkg );
+ ruleBase = SerializationHelper.serializeObject(ruleBase);
final WorkingMemory workingMemory = ruleBase.newStatefulSession();
final List list = new ArrayList();
@@ -1670,46 +1980,13 @@
list.get( 1 ) );
}
- public void testStaticFieldReference() throws Exception {
- final PackageBuilder builder = new PackageBuilder();
- builder.addPackageFromDrl( new InputStreamReader( getClass().getResourceAsStream( "test_StaticField.drl" ) ) );
- final Package pkg = builder.getPackage();
-
- final RuleBase ruleBase = getRuleBase();
- ruleBase.addPackage( pkg );
- final WorkingMemory workingMemory = ruleBase.newStatefulSession();
-
- final List list = new ArrayList();
- workingMemory.setGlobal( "list",
- list );
-
- final Cheesery cheesery1 = new Cheesery();
- cheesery1.setStatus( Cheesery.SELLING_CHEESE );
- cheesery1.setMaturity( Maturity.OLD );
- workingMemory.insert( cheesery1 );
-
- final Cheesery cheesery2 = new Cheesery();
- cheesery2.setStatus( Cheesery.MAKING_CHEESE );
- cheesery2.setMaturity( Maturity.YOUNG );
- workingMemory.insert( cheesery2 );
-
- workingMemory.fireAllRules();
-
- assertEquals( 2,
- list.size() );
-
- assertEquals( cheesery1,
- list.get( 0 ) );
- assertEquals( cheesery2,
- list.get( 1 ) );
- }
-
public void testDuplicateRuleNames() throws Exception {
PackageBuilder builder = new PackageBuilder();
builder.addPackageFromDrl( new InputStreamReader( getClass().getResourceAsStream( "test_DuplicateRuleName1.drl" ) ) );
- final RuleBase ruleBase = getRuleBase();
+ RuleBase ruleBase = getRuleBase();
ruleBase.addPackage( builder.getPackage() );
+ ruleBase = SerializationHelper.serializeObject(ruleBase);
builder = new PackageBuilder();
builder.addPackageFromDrl( new InputStreamReader( getClass().getResourceAsStream( "test_DuplicateRuleName2.drl" ) ) );
@@ -1727,8 +2004,9 @@
builder.addPackageFromDrl( reader );
final Package pkg1 = builder.getPackage();
- final RuleBase ruleBase = getRuleBase();
+ RuleBase ruleBase = getRuleBase();
ruleBase.addPackage( pkg1 );
+ ruleBase = SerializationHelper.serializeObject(ruleBase);
final WorkingMemory workingMemory = ruleBase.newStatefulSession();
// Adding person with null name and likes attributes
@@ -1752,15 +2030,14 @@
}
-
-
public void testEmptyRule() throws Exception {
final PackageBuilder builder = new PackageBuilder();
builder.addPackageFromDrl( new InputStreamReader( getClass().getResourceAsStream( "test_EmptyRule.drl" ) ) );
final Package pkg = builder.getPackage();
- final RuleBase ruleBase = getRuleBase();
+ RuleBase ruleBase = getRuleBase();
ruleBase.addPackage( pkg );
+ ruleBase = SerializationHelper.serializeObject(ruleBase);
final WorkingMemory workingMemory = ruleBase.newStatefulSession();
final List list = new ArrayList();
@@ -1778,8 +2055,9 @@
builder.addPackageFromDrl( new InputStreamReader( getClass().getResourceAsStream( "test_NoPatterns.drl" ) ) );
final Package pkg = builder.getPackage();
- final RuleBase ruleBase = getRuleBase();
+ RuleBase ruleBase = getRuleBase();
ruleBase.addPackage( pkg );
+ ruleBase = SerializationHelper.serializeObject(ruleBase);
final WorkingMemory workingMemory = ruleBase.newStatefulSession();
final List list = new ArrayList();
@@ -1798,8 +2076,9 @@
builder.addPackageFromDrl( new InputStreamReader( getClass().getResourceAsStream( "test_OrWithBindings.drl" ) ) );
final Package pkg = builder.getPackage();
- final RuleBase ruleBase = getRuleBase();
+ RuleBase ruleBase = getRuleBase();
ruleBase.addPackage( pkg );
+ ruleBase = SerializationHelper.serializeObject(ruleBase);
final WorkingMemory workingMemory = ruleBase.newStatefulSession();
final List list = new ArrayList();
@@ -1830,8 +2109,9 @@
builder.addPackageFromDrl( reader );
final Package pkg1 = builder.getPackage();
- final RuleBase ruleBase = getRuleBase();
+ RuleBase ruleBase = getRuleBase();
ruleBase.addPackage( pkg1 );
+ ruleBase = SerializationHelper.serializeObject(ruleBase);
final WorkingMemory workingMemory = ruleBase.newStatefulSession();
final List orderedFacts = new ArrayList();
@@ -1865,8 +2145,9 @@
final PackageBuilder builder = new PackageBuilder();
builder.addPackageFromDrl( new InputStreamReader( getClass().getResourceAsStream( "test_Query.drl" ) ) );
- final RuleBase ruleBase = getRuleBase();
+ RuleBase ruleBase = getRuleBase();
ruleBase.addPackage( builder.getPackage() );
+ ruleBase = SerializationHelper.serializeObject(ruleBase);
final WorkingMemory workingMemory = ruleBase.newStatefulSession();
workingMemory.fireAllRules();
@@ -1882,8 +2163,9 @@
final PackageBuilder builder = new PackageBuilder();
builder.addPackageFromDrl( new InputStreamReader( getClass().getResourceAsStream( "test_QueryWithParams.drl" ) ) );
- final RuleBase ruleBase = getRuleBase();
+ RuleBase ruleBase = getRuleBase();
ruleBase.addPackage( builder.getPackage() );
+ ruleBase = SerializationHelper.serializeObject(ruleBase);
final WorkingMemory workingMemory = ruleBase.newStatefulSession();
workingMemory.fireAllRules();
@@ -1923,8 +2205,9 @@
builder.addPackageFromDrl( new InputStreamReader( getClass().getResourceAsStream( "test_TwoQuerries.drl" ) ) );
final Package pkg = builder.getPackage();
- final RuleBase ruleBase = getRuleBase();
+ RuleBase ruleBase = getRuleBase();
ruleBase.addPackage( pkg );
+ ruleBase = SerializationHelper.serializeObject(ruleBase);
final WorkingMemory workingMemory = ruleBase.newStatefulSession();
final Cheese stilton = new Cheese( "stinky",
@@ -1971,8 +2254,7 @@
// read in the source
final Reader reader = new InputStreamReader( getClass().getResourceAsStream( "test_JoinNodeModifyTuple.drl" ) );
- final RuleBase ruleBase = loadRuleBase( reader );
-
+ RuleBase ruleBase = loadRuleBase( reader );
final WorkingMemory wm = ruleBase.newStatefulSession();
// 1st time
@@ -2065,8 +2347,9 @@
builder.addPackageFromDrl( new InputStreamReader( getClass().getResourceAsStream( "test_DoubleQueryWithExists.drl" ) ) );
final Package pkg = builder.getPackage();
- final RuleBase ruleBase = getRuleBase();
+ RuleBase ruleBase = getRuleBase();
ruleBase.addPackage( pkg );
+ ruleBase = SerializationHelper.serializeObject(ruleBase);
final WorkingMemory workingMemory = ruleBase.newStatefulSession();
final Person p1 = new Person( "p1",
@@ -2150,8 +2433,9 @@
builder.addPackageFromDrl( new InputStreamReader( getClass().getResourceAsStream( "test_FunctionWithPrimitives.drl" ) ) );
final Package pkg = builder.getPackage();
- final RuleBase ruleBase = getRuleBase();
+ RuleBase ruleBase = getRuleBase();
ruleBase.addPackage( pkg );
+ ruleBase = SerializationHelper.serializeObject(ruleBase);
final WorkingMemory workingMemory = ruleBase.newStatefulSession();
final List list = new ArrayList();
@@ -2174,8 +2458,9 @@
builder.addPackageFromDrl( new InputStreamReader( getClass().getResourceAsStream( "test_ReturnValueAndGlobal.drl" ) ) );
final Package pkg = builder.getPackage();
- final RuleBase ruleBase = getRuleBase();
+ RuleBase ruleBase = getRuleBase();
ruleBase.addPackage( pkg );
+ ruleBase = SerializationHelper.serializeObject(ruleBase);
final WorkingMemory workingMemory = ruleBase.newStatefulSession();
final List matchlist = new ArrayList();
@@ -2215,8 +2500,9 @@
builder.addPackageFromDrl( new InputStreamReader( getClass().getResourceAsStream( "test_DeclaringAndUsingBindsInSamePattern.drl" ) ) );
final Package pkg = builder.getPackage();
- final RuleBase ruleBase = getRuleBase( config );
+ RuleBase ruleBase = getRuleBase( config );
ruleBase.addPackage( pkg );
+ ruleBase = SerializationHelper.serializeObject(ruleBase);
final WorkingMemory workingMemory = ruleBase.newStatefulSession();
final List sensors = new ArrayList();
@@ -2245,8 +2531,9 @@
builder.addPackageFromDrl( new InputStreamReader( getClass().getResourceAsStream( "test_missing_import.drl" ) ) );
final Package pkg = builder.getPackage();
- final RuleBase ruleBase = getRuleBase();
+ RuleBase ruleBase = getRuleBase();
ruleBase.addPackage( pkg );
+ ruleBase = SerializationHelper.serializeObject(ruleBase);
Assert.fail( "Should have thrown an InvalidRulePackage" );
} catch ( final InvalidRulePackage e ) {
@@ -2263,8 +2550,9 @@
builder.addPackageFromDrl( new InputStreamReader( getClass().getResourceAsStream( "test_NestedConditionalElements.drl" ) ) );
final Package pkg = builder.getPackage();
- final RuleBase ruleBase = getRuleBase();
+ RuleBase ruleBase = getRuleBase();
ruleBase.addPackage( pkg );
+ ruleBase = SerializationHelper.serializeObject(ruleBase);
final WorkingMemory workingMemory = ruleBase.newStatefulSession();
final List list = new ArrayList();
@@ -2299,8 +2587,9 @@
builder.addPackageFromDrl( new InputStreamReader( getClass().getResourceAsStream( "test_DeclarationUsage.drl" ) ) );
final Package pkg = builder.getPackage();
- final RuleBase ruleBase = getRuleBase();
+ RuleBase ruleBase = getRuleBase();
ruleBase.addPackage( pkg );
+ ruleBase = SerializationHelper.serializeObject(ruleBase);
fail( "Should have trown an exception" );
} catch ( final InvalidRulePackage e ) {
@@ -2316,8 +2605,9 @@
builder.addPackageFromDrl( new InputStreamReader( getClass().getResourceAsStream( "test_UnbalancedTrees.drl" ) ) );
final Package pkg = builder.getPackage();
- final RuleBase ruleBase = getRuleBase();
+ RuleBase ruleBase = getRuleBase();
ruleBase.addPackage( pkg );
+ ruleBase = SerializationHelper.serializeObject(ruleBase);
final WorkingMemory wm = ruleBase.newStatefulSession();
@@ -2342,50 +2632,22 @@
}
public void testImportConflict() throws Exception {
- final RuleBase ruleBase = getRuleBase();
+ RuleBase ruleBase = getRuleBase();
final PackageBuilder builder = new PackageBuilder();
builder.addPackageFromDrl( new InputStreamReader( getClass().getResourceAsStream( "test_ImportConflict.drl" ) ) );
final Package pkg = builder.getPackage();
ruleBase.addPackage( pkg );
+ ruleBase = SerializationHelper.serializeObject(ruleBase);
}
- public void testPrimitiveArray() throws Exception {
- final PackageBuilder builder = new PackageBuilder();
- builder.addPackageFromDrl( new InputStreamReader( getClass().getResourceAsStream( "test_primitiveArray.drl" ) ) );
- final Package pkg = builder.getPackage();
-
- final RuleBase ruleBase = getRuleBase();
- ruleBase.addPackage( pkg );
- final WorkingMemory workingMemory = ruleBase.newStatefulSession();
- final List result = new ArrayList();
- workingMemory.setGlobal( "result",
- result );
-
- final Primitives p1 = new Primitives();
- p1.setPrimitiveArrayAttribute( new int[]{1, 2, 3} );
- p1.setArrayAttribute( new String[]{"a", "b"} );
-
- workingMemory.insert( p1 );
-
- workingMemory.fireAllRules();
- assertEquals( 3,
- result.size() );
- assertEquals( 3,
- ((Integer) result.get( 0 )).intValue() );
- assertEquals( 2,
- ((Integer) result.get( 1 )).intValue() );
- assertEquals( 3,
- ((Integer) result.get( 2 )).intValue() );
-
- }
-
public void testEmptyIdentifier() throws Exception {
final PackageBuilder builder = new PackageBuilder();
builder.addPackageFromDrl( new InputStreamReader( getClass().getResourceAsStream( "test_emptyIdentifier.drl" ) ) );
final Package pkg = builder.getPackage();
- final RuleBase ruleBase = getRuleBase();
+ RuleBase ruleBase = getRuleBase();
ruleBase.addPackage( pkg );
+ ruleBase = SerializationHelper.serializeObject(ruleBase);
final WorkingMemory workingMemory = ruleBase.newStatefulSession();
final List result = new ArrayList();
workingMemory.setGlobal( "results",
@@ -2408,8 +2670,9 @@
builder.addPackageFromDrl( new InputStreamReader( getClass().getResourceAsStream( "test_duplicateVariableBinding.drl" ) ) );
final Package pkg = builder.getPackage();
- final RuleBase ruleBase = getRuleBase();
+ RuleBase ruleBase = getRuleBase();
ruleBase.addPackage( pkg );
+ ruleBase = SerializationHelper.serializeObject(ruleBase);
final WorkingMemory workingMemory = ruleBase.newStatefulSession();
final Map result = new HashMap();
workingMemory.setGlobal( "results",
@@ -2465,8 +2728,9 @@
builder.addPackageFromDrl( new InputStreamReader( getClass().getResourceAsStream( "test_ShadowProxyInHirarchies.drl" ) ) );
final Package pkg = builder.getPackage();
- final RuleBase ruleBase = getRuleBase();
+ RuleBase ruleBase = getRuleBase();
ruleBase.addPackage( pkg );
+ ruleBase = SerializationHelper.serializeObject(ruleBase);
final WorkingMemory workingMemory = ruleBase.newStatefulSession();
workingMemory.insert( new Child( "gp" ) );
@@ -2479,8 +2743,9 @@
builder.addPackageFromDrl( new InputStreamReader( getClass().getResourceAsStream( "test_SelfReference.drl" ) ) );
final Package pkg = builder.getPackage();
- final RuleBase ruleBase = getRuleBase();
+ RuleBase ruleBase = getRuleBase();
ruleBase.addPackage( pkg );
+ ruleBase = SerializationHelper.serializeObject(ruleBase);
final WorkingMemory workingMemory = ruleBase.newStatefulSession();
final List results = new ArrayList();
@@ -2516,8 +2781,9 @@
builder.addPackageFromDrl( new InputStreamReader( getClass().getResourceAsStream( "test_NumberComparisons.drl" ) ) );
final Package pkg = builder.getPackage();
- final RuleBase ruleBase = getRuleBase();
+ RuleBase ruleBase = getRuleBase();
ruleBase.addPackage( pkg );
+ ruleBase = SerializationHelper.serializeObject(ruleBase);
final WorkingMemory workingMemory = ruleBase.newStatefulSession();
final List list = new ArrayList();
@@ -2573,8 +2839,9 @@
builder.addPackageFromDrl( new InputStreamReader( getClass().getResourceAsStream( "test_skipModify.drl" ) ) );
final Package pkg = builder.getPackage();
- final RuleBase ruleBase = getRuleBase();
+ RuleBase ruleBase = getRuleBase();
ruleBase.addPackage( pkg );
+ ruleBase = SerializationHelper.serializeObject(ruleBase);
final WorkingMemory workingMemory = ruleBase.newStatefulSession();
final List results = new ArrayList();
@@ -2602,8 +2869,9 @@
builder.addPackageFromDrl( new InputStreamReader( getClass().getResourceAsStream( "test_EventModel.drl" ) ) );
final Package pkg = builder.getPackage();
- final RuleBase ruleBase = getRuleBase();
+ RuleBase ruleBase = getRuleBase();
ruleBase.addPackage( pkg );
+ ruleBase = SerializationHelper.serializeObject(ruleBase);
final WorkingMemory wm = ruleBase.newStatefulSession();
final List agendaList = new ArrayList();
@@ -2691,8 +2959,9 @@
builder.addPackageFromDrl( new InputStreamReader( getClass().getResourceAsStream( "test_implicitDeclarations.drl" ) ) );
final Package pkg = builder.getPackage();
- final RuleBase ruleBase = getRuleBase();
+ RuleBase ruleBase = getRuleBase();
ruleBase.addPackage( pkg );
+ ruleBase = SerializationHelper.serializeObject(ruleBase);
final WorkingMemory workingMemory = ruleBase.newStatefulSession();
final List results = new ArrayList();
@@ -2715,8 +2984,9 @@
builder.addPackageFromDrl( new InputStreamReader( getClass().getResourceAsStream( "test_castsInsideEval.drl" ) ) );
final Package pkg = builder.getPackage();
- final RuleBase ruleBase = getRuleBase();
+ RuleBase ruleBase = getRuleBase();
ruleBase.addPackage( pkg );
+ ruleBase = SerializationHelper.serializeObject(ruleBase);
final WorkingMemory workingMemory = ruleBase.newStatefulSession();
workingMemory.setGlobal( "value",
@@ -2730,8 +3000,9 @@
builder.addPackageFromDrl( new InputStreamReader( getClass().getResourceAsStream( "test_memberOf.drl" ) ) );
final Package pkg = builder.getPackage();
- final RuleBase ruleBase = getRuleBase();
+ RuleBase ruleBase = getRuleBase();
ruleBase.addPackage( pkg );
+ ruleBase = SerializationHelper.serializeObject(ruleBase);
final WorkingMemory workingMemory = ruleBase.newStatefulSession();
final List list = new ArrayList();
@@ -2768,8 +3039,9 @@
builder.addPackageFromDrl( new InputStreamReader( getClass().getResourceAsStream( "test_contains_in_array.drl" ) ) );
final Package pkg = builder.getPackage();
- final RuleBase ruleBase = getRuleBase();
+ RuleBase ruleBase = getRuleBase();
ruleBase.addPackage( pkg );
+ ruleBase = SerializationHelper.serializeObject(ruleBase);
final WorkingMemory workingMemory = ruleBase.newStatefulSession();
final List list = new ArrayList();
@@ -2796,8 +3068,9 @@
builder.addPackageFromDrl( new InputStreamReader( getClass().getResourceAsStream( "test_collectNodeSharing.drl" ) ) );
final Package pkg = builder.getPackage();
- final RuleBase ruleBase = getRuleBase();
+ RuleBase ruleBase = getRuleBase();
ruleBase.addPackage( pkg );
+ ruleBase = SerializationHelper.serializeObject(ruleBase);
final WorkingMemory workingMemory = ruleBase.newStatefulSession();
final List list = new ArrayList();
@@ -2823,8 +3096,9 @@
builder.addPackageFromDrl( new InputStreamReader( getClass().getResourceAsStream( "test_nodeSharingNotExists.drl" ) ) );
final Package pkg = builder.getPackage();
- final RuleBase ruleBase = getRuleBase();
+ RuleBase ruleBase = getRuleBase();
ruleBase.addPackage( pkg );
+ ruleBase = SerializationHelper.serializeObject(ruleBase);
final WorkingMemory workingMemory = ruleBase.newStatefulSession();
final List list = new ArrayList();
@@ -2856,8 +3130,9 @@
builder.addPackageFromDrl( new InputStreamReader( getClass().getResourceAsStream( "test_nullBindings.drl" ) ) );
final Package pkg = builder.getPackage();
- final RuleBase ruleBase = getRuleBase();
+ RuleBase ruleBase = getRuleBase();
ruleBase.addPackage( pkg );
+ ruleBase = SerializationHelper.serializeObject(ruleBase);
final WorkingMemory workingMemory = ruleBase.newStatefulSession();
final List list = new ArrayList();
@@ -2882,8 +3157,9 @@
builder.addPackageFromDrl( new InputStreamReader( getClass().getResourceAsStream( "test_RetractModifyWithFunction.drl" ) ) );
final Package pkg = builder.getPackage();
- final RuleBase ruleBase = getRuleBase();
+ RuleBase ruleBase = getRuleBase();
ruleBase.addPackage( pkg );
+ ruleBase = SerializationHelper.serializeObject(ruleBase);
final AbstractWorkingMemory workingMemory = (AbstractWorkingMemory) ruleBase.newStatefulSession();
final Cheese stilton = new Cheese( "stilton",
@@ -2913,8 +3189,9 @@
builder.addPackageFromDrl( new InputStreamReader( getClass().getResourceAsStream( "test_ConstraintConnectors.drl" ) ) );
final Package pkg = builder.getPackage();
- final RuleBase ruleBase = getRuleBase();
+ RuleBase ruleBase = getRuleBase();
ruleBase.addPackage( pkg );
+ ruleBase = SerializationHelper.serializeObject(ruleBase);
final WorkingMemory workingMemory = ruleBase.newStatefulSession();
final List results = new ArrayList();
@@ -2975,8 +3252,9 @@
builder.addPackageFromDrl( new InputStreamReader( getClass().getResourceAsStream( "test_MatchesNotMatches.drl" ) ) );
final Package pkg = builder.getPackage();
- final RuleBase ruleBase = getRuleBase();
+ RuleBase ruleBase = getRuleBase();
ruleBase.addPackage( pkg );
+ ruleBase = SerializationHelper.serializeObject(ruleBase);
final WorkingMemory workingMemory = ruleBase.newStatefulSession();
final List list = new ArrayList();
@@ -2998,9 +3276,9 @@
final Cheese muzzarella2 = new Cheese( "muzzarella2",
10 );
final Cheese provolone = new Cheese( "provolone",
+ 10 );
+ final Cheese provolone2 = new Cheese( "another cheese (provolone)",
10 );
- final Cheese provolone2 = new Cheese( "another cheese (provolone)",
- 10 );
workingMemory.insert( stilton );
workingMemory.insert( stilton2 );
workingMemory.insert( agedStilton );
@@ -3013,7 +3291,7 @@
workingMemory.fireAllRules();
- System.out.println(list.toString());
+ System.out.println( list.toString() );
assertEquals( 4,
list.size() );
@@ -3032,8 +3310,9 @@
builder.addPackageFromDrl( new InputStreamReader( getClass().getResourceAsStream( "test_AutoBindings.drl" ) ) );
final Package pkg = builder.getPackage();
- final RuleBase ruleBase = getRuleBase();
+ RuleBase ruleBase = getRuleBase();
ruleBase.addPackage( pkg );
+ ruleBase = SerializationHelper.serializeObject(ruleBase);
final WorkingMemory workingMemory = ruleBase.newStatefulSession();
final List list = new ArrayList();
@@ -3048,7 +3327,6 @@
workingMemory.insert( stilton );
workingMemory.fireAllRules();
-
assertEquals( 1,
list.size() );
@@ -3056,6 +3334,30 @@
list.get( 0 ) );
}
+ public void testMatchesMVEL() throws Exception {
+ final PackageBuilder builder = new PackageBuilder();
+ builder.addPackageFromDrl( new InputStreamReader( getClass().getResourceAsStream( "test_MatchesMVEL.drl" ) ) );
+ final Package pkg = builder.getPackage();
+
+ final RuleBase ruleBase = getRuleBase();
+ ruleBase.addPackage( pkg );
+ final StatefulSession session = ruleBase.newStatefulSession();
+
+ final List results = new ArrayList();
+ session.setGlobal( "results",
+ results );
+
+ Map map = new HashMap();
+ map.put( "content",
+ "hello ;=" );
+ session.insert( map );
+
+ session.fireAllRules();
+
+ assertEquals( 1,
+ results.size() );
+ }
+
public void testAutomaticBindingsErrors() throws Exception {
final PackageBuilder builder = new PackageBuilder();
builder.addPackageFromDrl( new InputStreamReader( getClass().getResourceAsStream( "test_AutoBindingsErrors.drl" ) ) );
@@ -3069,8 +3371,9 @@
builder.addPackageFromDrl( new InputStreamReader( getClass().getResourceAsStream( "test_QualifiedFieldReference.drl" ) ) );
final Package pkg = builder.getPackage();
- final RuleBase ruleBase = getRuleBase();
+ RuleBase ruleBase = getRuleBase();
ruleBase.addPackage( pkg );
+ ruleBase = SerializationHelper.serializeObject(ruleBase);
final WorkingMemory workingMemory = ruleBase.newStatefulSession();
final List list = new ArrayList();
@@ -3098,8 +3401,9 @@
builder.addPackageFromDrl( new InputStreamReader( getClass().getResourceAsStream( "test_EvalRewrite.drl" ) ) );
final Package pkg = builder.getPackage();
- final RuleBase ruleBase = getRuleBase();
+ RuleBase ruleBase = getRuleBase();
ruleBase.addPackage( pkg );
+ ruleBase = SerializationHelper.serializeObject(ruleBase);
final WorkingMemory workingMemory = ruleBase.newStatefulSession();
final List list = new ArrayList();
@@ -3168,8 +3472,9 @@
builder.addPackageFromDrl( new InputStreamReader( getClass().getResourceAsStream( "test_MapAccess.drl" ) ) );
final Package pkg = builder.getPackage();
- final RuleBase ruleBase = getRuleBase();
+ RuleBase ruleBase = getRuleBase();
ruleBase.addPackage( pkg );
+ ruleBase = SerializationHelper.serializeObject(ruleBase);
final WorkingMemory workingMemory = ruleBase.newStatefulSession();
final List list = new ArrayList();
@@ -3199,8 +3504,9 @@
builder.addPackageFromDrl( new InputStreamReader( getClass().getResourceAsStream( "test_halt.drl" ) ) );
final Package pkg = builder.getPackage();
- final RuleBase ruleBase = getRuleBase();
+ RuleBase ruleBase = getRuleBase();
ruleBase.addPackage( pkg );
+ ruleBase = SerializationHelper.serializeObject(ruleBase);
final WorkingMemory workingMemory = ruleBase.newStatefulSession();
final List results = new ArrayList();
@@ -3223,8 +3529,9 @@
builder.addPackageFromDrl( new InputStreamReader( getClass().getResourceAsStream( "test_fireLimit.drl" ) ) );
final Package pkg = builder.getPackage();
- final RuleBase ruleBase = getRuleBase();
+ RuleBase ruleBase = getRuleBase();
ruleBase.addPackage( pkg );
+ ruleBase = SerializationHelper.serializeObject(ruleBase);
final WorkingMemory workingMemory = ruleBase.newStatefulSession();
final List results = new ArrayList();
@@ -3274,8 +3581,9 @@
RuleBaseConfiguration conf = new RuleBaseConfiguration();
conf.setAssertBehaviour( RuleBaseConfiguration.AssertBehaviour.EQUALITY );
- final RuleBase ruleBase = getRuleBase( conf );
+ RuleBase ruleBase = getRuleBase( conf );
ruleBase.addPackage( pkg );
+ ruleBase = SerializationHelper.serializeObject(ruleBase);
final WorkingMemory workingMemory = ruleBase.newStatefulSession();
final List results = new ArrayList();
@@ -3302,8 +3610,9 @@
builder.addPackageFromDrl( new InputStreamReader( getClass().getResourceAsStream( "test_charComparisons.drl" ) ) );
final Package pkg = builder.getPackage();
- final RuleBase ruleBase = getRuleBase();
+ RuleBase ruleBase = getRuleBase();
ruleBase.addPackage( pkg );
+ ruleBase = SerializationHelper.serializeObject(ruleBase);
final WorkingMemory workingMemory = ruleBase.newStatefulSession();
final List results = new ArrayList();
@@ -3341,8 +3650,9 @@
final RuleBaseConfiguration conf = new RuleBaseConfiguration();
conf.setShareAlphaNodes( false );
- final RuleBase ruleBase = getRuleBase( conf );
+ RuleBase ruleBase = getRuleBase( conf );
ruleBase.addPackage( pkg );
+ ruleBase = SerializationHelper.serializeObject(ruleBase);
final WorkingMemory workingMemory = ruleBase.newStatefulSession();
final List results = new ArrayList();
@@ -3373,8 +3683,9 @@
builder.addPackageFromDrl( new InputStreamReader( getClass().getResourceAsStream( "test_functionCallingFunction.drl" ) ) );
final Package pkg = builder.getPackage();
- final RuleBase ruleBase = getRuleBase();
+ RuleBase ruleBase = getRuleBase();
ruleBase.addPackage( pkg );
+ ruleBase = SerializationHelper.serializeObject(ruleBase);
final WorkingMemory workingMemory = ruleBase.newStatefulSession();
final List list = new ArrayList();
@@ -3398,8 +3709,9 @@
builder.addPackageFromDrl( new InputStreamReader( getClass().getResourceAsStream( "test_functionCallingFunction.drl" ) ) );
final Package pkg = builder.getPackage();
- final RuleBase ruleBase = getRuleBase();
+ RuleBase ruleBase = getRuleBase();
ruleBase.addPackage( pkg );
+ ruleBase = SerializationHelper.serializeObject(ruleBase);
final WorkingMemory workingMemory = ruleBase.newStatefulSession();
final List list = new ArrayList();
@@ -3420,8 +3732,9 @@
builder.addPackageFromDrl( new InputStreamReader( getClass().getResourceAsStream( "test_SelfReference2.drl" ) ) );
final Package pkg = builder.getPackage();
- final RuleBase ruleBase = getRuleBase();
+ RuleBase ruleBase = getRuleBase();
ruleBase.addPackage( pkg );
+ ruleBase = SerializationHelper.serializeObject(ruleBase);
final WorkingMemory workingMemory = ruleBase.newStatefulSession();
final List results = new ArrayList();
@@ -3468,9 +3781,10 @@
assertEquals( 1,
pkg2.getRules().length );
- final RuleBase ruleBase = getRuleBase();
+ RuleBase ruleBase = getRuleBase();
ruleBase.addPackage( pkg1 );
ruleBase.addPackage( pkg2 );
+ ruleBase = SerializationHelper.serializeObject(ruleBase);
final WorkingMemory workingMemory = ruleBase.newStatefulSession();
final List results = new ArrayList();
@@ -3498,6 +3812,30 @@
}
}
+ public void testMergePackageWithSameRuleNames() throws Exception {
+ PackageBuilder builder = new PackageBuilder();
+ builder.addPackageFromDrl( new InputStreamReader( getClass().getResourceAsStream( "test_MergePackageWithSameRuleNames1.drl" ) ) );
+ final RuleBase ruleBase = getRuleBase();
+ ruleBase.addPackage( builder.getPackage() );
+
+ builder = new PackageBuilder();
+ builder.addPackageFromDrl( new InputStreamReader( getClass().getResourceAsStream( "test_MergePackageWithSameRuleNames2.drl" ) ) );
+ ruleBase.addPackage( builder.getPackage() );
+
+ StatefulSession session = ruleBase.newStatefulSession();
+ final List results = new ArrayList();
+ session.setGlobal( "results",
+ results );
+
+ session.fireAllRules();
+
+ assertEquals( 1,
+ results.size() );
+
+ assertEquals( "rule1 for the package2",
+ results.get( 0 ) );
+ }
+
public void testRuleReplacement() throws Exception {
// test rule replacement
try {
@@ -3509,8 +3847,9 @@
assertEquals( 1,
pkg1.getRules().length );
- final RuleBase ruleBase = getRuleBase();
+ RuleBase ruleBase = getRuleBase();
ruleBase.addPackage( pkg1 );
+ ruleBase = SerializationHelper.serializeObject(ruleBase);
final WorkingMemory workingMemory = ruleBase.newStatefulSession();
final List results = new ArrayList();
@@ -3551,8 +3890,9 @@
builder.addPackageFromDrl( new InputStreamReader( getClass().getResourceAsStream( "test_bindings.drl" ) ) );
final Package pkg = builder.getPackage();
- final RuleBase ruleBase = getRuleBase();
+ RuleBase ruleBase = getRuleBase();
ruleBase.addPackage( pkg );
+ ruleBase = SerializationHelper.serializeObject(ruleBase);
final WorkingMemory workingMemory = ruleBase.newStatefulSession();
final List results = new ArrayList();
@@ -3577,8 +3917,9 @@
builder.addPackageFromDrl( new InputStreamReader( getClass().getResourceAsStream( "test_multipleFroms.drl" ) ) );
final Package pkg = builder.getPackage();
- final RuleBase ruleBase = getRuleBase();
+ RuleBase ruleBase = getRuleBase();
ruleBase.addPackage( pkg );
+ ruleBase = SerializationHelper.serializeObject(ruleBase);
final WorkingMemory workingMemory = ruleBase.newStatefulSession();
final List results = new ArrayList();
@@ -3609,8 +3950,9 @@
builder.addPackageFromDrl( new InputStreamReader( getClass().getResourceAsStream( "test_NullHashing.drl" ) ) );
final Package pkg = builder.getPackage();
- final RuleBase ruleBase = getRuleBase();
+ RuleBase ruleBase = getRuleBase();
ruleBase.addPackage( pkg );
+ ruleBase = SerializationHelper.serializeObject(ruleBase);
final WorkingMemory workingMemory = ruleBase.newStatefulSession();
final List results = new ArrayList();
@@ -3635,8 +3977,9 @@
builder.addPackageFromDrl( new InputStreamReader( getClass().getResourceAsStream( "test_DefaultBetaConstraint.drl" ) ) );
final Package pkg = builder.getPackage();
- final RuleBase ruleBase = getRuleBase();
+ RuleBase ruleBase = getRuleBase();
ruleBase.addPackage( pkg );
+ ruleBase = SerializationHelper.serializeObject(ruleBase);
final WorkingMemory workingMemory = ruleBase.newStatefulSession();
final List results = new ArrayList();
@@ -3748,8 +4091,9 @@
builder.addPackageFromDrl( new InputStreamReader( getClass().getResourceAsStream( "test_BooleanWrapper.drl" ) ) );
final Package pkg = builder.getPackage();
- final RuleBase ruleBase = getRuleBase();
+ RuleBase ruleBase = getRuleBase();
ruleBase.addPackage( pkg );
+ ruleBase = SerializationHelper.serializeObject(ruleBase);
final WorkingMemory workingMemory = ruleBase.newStatefulSession();
final List results = new ArrayList();
@@ -3786,6 +4130,7 @@
conf.setShadowProxy( true );
RuleBase rb = RuleBaseFactory.newRuleBase( conf );
rb.addPackage( builder.getPackage() );
+ rb = SerializationHelper.serializeObject(rb);
StatefulSession session = rb.newStatefulSession();
List list1 = new ArrayList();
@@ -3844,8 +4189,9 @@
builder.addPackageFromDrl( new InputStreamReader( getClass().getResourceAsStream( "test_IterateObjects.drl" ) ) );
final Package pkg = builder.getPackage();
- final RuleBase ruleBase = getRuleBase();
+ RuleBase ruleBase = getRuleBase();
ruleBase.addPackage( pkg );
+ ruleBase = SerializationHelper.serializeObject(ruleBase);
final WorkingMemory workingMemory = ruleBase.newStatefulSession();
final List results = new ArrayList();
@@ -3873,8 +4219,9 @@
RuleBaseConfiguration conf = new RuleBaseConfiguration();
conf.setSequential( true );
- final RuleBase ruleBase = getRuleBase( conf );
+ RuleBase ruleBase = getRuleBase( conf );
ruleBase.addPackage( pkg );
+ ruleBase = SerializationHelper.serializeObject(ruleBase);
StatelessSession session = ruleBase.newStatelessSession();
List list = new ArrayList();
@@ -3891,8 +4238,9 @@
builder.addPackageFromDrl( new StringReader( rule ) );
Package pkg = builder.getPackage();
- final RuleBase ruleBase = getRuleBase();
+ RuleBase ruleBase = getRuleBase();
ruleBase.addPackage( pkg );
+ ruleBase = SerializationHelper.serializeObject(ruleBase);
StatefulSession session = ruleBase.newStatefulSession();
List list = new ArrayList();
@@ -3924,8 +4272,9 @@
builder.addPackageFromDrl( new InputStreamReader( getClass().getResourceAsStream( "test_EvalRewriteWithSpecialOperators.drl" ) ) );
final Package pkg = builder.getPackage();
- final RuleBase ruleBase = getRuleBase();
+ RuleBase ruleBase = getRuleBase();
ruleBase.addPackage( pkg );
+ ruleBase = SerializationHelper.serializeObject(ruleBase);
final WorkingMemory workingMemory = ruleBase.newStatefulSession();
final List list = new ArrayList();
@@ -4027,9 +4376,10 @@
final Package pkg = builder.getPackage();
final Package pkg2 = builder2.getPackage();
- final RuleBase ruleBase = getRuleBase();
+ RuleBase ruleBase = getRuleBase();
ruleBase.addPackage( pkg );
ruleBase.addPackage( pkg2 );
+ ruleBase = SerializationHelper.serializeObject(ruleBase);
final WorkingMemory workingMemory = ruleBase.newStatefulSession();
@@ -4046,8 +4396,9 @@
builder.addPackageFromDrl( new InputStreamReader( getClass().getResourceAsStream( "test_AutoVivificationVR.drl" ) ) );
final Package pkg = builder.getPackage();
- final RuleBase ruleBase = getRuleBase();
+ RuleBase ruleBase = getRuleBase();
ruleBase.addPackage( pkg );
+ ruleBase = SerializationHelper.serializeObject(ruleBase);
final WorkingMemory workingMemory = ruleBase.newStatefulSession();
final List results = new ArrayList();
@@ -4069,8 +4420,9 @@
builder.addPackageFromDrl( new InputStreamReader( getClass().getResourceAsStream( "test_ShadowProxyOnCollections.drl" ) ) );
final Package pkg = builder.getPackage();
- final RuleBase ruleBase = getRuleBase();
+ RuleBase ruleBase = getRuleBase();
ruleBase.addPackage( pkg );
+ ruleBase = SerializationHelper.serializeObject(ruleBase);
final WorkingMemory workingMemory = ruleBase.newStatefulSession();
final List results = new ArrayList();
@@ -4094,8 +4446,9 @@
final PackageBuilder builder = new PackageBuilder();
builder.addPackageFromDrl( new InputStreamReader( getClass().getResourceAsStream( "test_Query.drl" ) ) );
- final RuleBase ruleBase = getRuleBase();
+ RuleBase ruleBase = getRuleBase();
ruleBase.addPackage( builder.getPackage() );
+ ruleBase = SerializationHelper.serializeObject(ruleBase);
final WorkingMemory workingMemory = ruleBase.newStatefulSession();
workingMemory.fireAllRules();
@@ -4115,8 +4468,9 @@
final PackageBuilder builder = new PackageBuilder();
builder.addPackageFromDrl( new InputStreamReader( getClass().getResourceAsStream( "test_NestedAccessors.drl" ) ) );
- final RuleBase ruleBase = getRuleBase();
+ RuleBase ruleBase = getRuleBase();
ruleBase.addPackage( builder.getPackage() );
+ ruleBase = SerializationHelper.serializeObject(ruleBase);
final WorkingMemory workingMemory = ruleBase.newStatefulSession();
@@ -4173,8 +4527,9 @@
builder.addPackageFromDrl( new InputStreamReader( getClass().getResourceAsStream( "test_Logger.drl" ) ) );
final Package pkg = builder.getPackage();
- final RuleBase ruleBase = getRuleBase();
+ RuleBase ruleBase = getRuleBase();
ruleBase.addPackage( pkg );
+ ruleBase = SerializationHelper.serializeObject(ruleBase);
final WorkingMemory wm = ruleBase.newStatefulSession();
@@ -4203,8 +4558,9 @@
final PackageBuilder builder = new PackageBuilder();
builder.addPackageFromDrl( new InputStreamReader( getClass().getResourceAsStream( "test_FromNestedAccessors.drl" ) ) );
- final RuleBase ruleBase = getRuleBase();
+ RuleBase ruleBase = getRuleBase();
ruleBase.addPackage( builder.getPackage() );
+ ruleBase = SerializationHelper.serializeObject(ruleBase);
final WorkingMemory workingMemory = ruleBase.newStatefulSession();
@@ -4234,14 +4590,43 @@
list.get( 0 ) );
}
+ public void testFromArrayIteration() throws Exception {
+ final PackageBuilder builder = new PackageBuilder();
+ builder.addPackageFromDrl( new InputStreamReader( getClass().getResourceAsStream( "test_FromArrayIteration.drl" ) ) );
+
+ final RuleBase ruleBase = getRuleBase();
+ ruleBase.addPackage( builder.getPackage() );
+
+ final WorkingMemory session = ruleBase.newStatefulSession();
+ List list = new ArrayList();
+
+ session.setGlobal( "list",
+ list );
+ session.insert( new DomainObjectHolder() );
+
+ session.fireAllRules();
+
+ assertEquals( 3,
+ list.size() );
+
+ assertEquals( "Message3",
+ list.get( 0 ) );
+ assertEquals( "Message2",
+ list.get( 1 ) );
+ assertEquals( "Message1",
+ list.get( 2 ) );
+
+ }
+
public void testSubNetworks() throws Exception {
final PackageBuilder builder = new PackageBuilder();
builder.addPackageFromDrl( new InputStreamReader( getClass().getResourceAsStream( "test_SubNetworks.drl" ) ) );
- final RuleBase ruleBase = getRuleBase();
+ RuleBase ruleBase = getRuleBase();
try {
ruleBase.addPackage( builder.getPackage() );
+ ruleBase = SerializationHelper.serializeObject(ruleBase);
} catch ( Exception e ) {
e.printStackTrace();
fail( "Should not raise any exception!" );
@@ -4253,8 +4638,9 @@
final PackageBuilder builder = new PackageBuilder();
builder.addPackageFromDrl( new InputStreamReader( getClass().getResourceAsStream( "test_FinalClass.drl" ) ) );
- final RuleBase ruleBase = getRuleBase();
+ RuleBase ruleBase = getRuleBase();
ruleBase.addPackage( builder.getPackage() );
+ ruleBase = SerializationHelper.serializeObject(ruleBase);
final WorkingMemory workingMemory = ruleBase.newStatefulSession();
@@ -4288,8 +4674,9 @@
builder.addPackageFromDrl( new InputStreamReader( getClass().getResourceAsStream( "test_EvalRewriteMatches.drl" ) ) );
final Package pkg = builder.getPackage();
- final RuleBase ruleBase = getRuleBase();
+ RuleBase ruleBase = getRuleBase();
ruleBase.addPackage( pkg );
+ ruleBase = SerializationHelper.serializeObject(ruleBase);
final WorkingMemory workingMemory = ruleBase.newStatefulSession();
final List list = new ArrayList();
@@ -4329,8 +4716,9 @@
builder.addPackageFromDrl( new InputStreamReader( getClass().getResourceAsStream( "test_RuntimeTypeCoercion.drl" ) ) );
final Package pkg = builder.getPackage();
- final RuleBase ruleBase = getRuleBase();
+ RuleBase ruleBase = getRuleBase();
ruleBase.addPackage( pkg );
+ ruleBase = SerializationHelper.serializeObject(ruleBase);
final WorkingMemory workingMemory = ruleBase.newStatefulSession();
final List list = new ArrayList();
@@ -4373,8 +4761,9 @@
builder.addPackageFromDrl( new InputStreamReader( getClass().getResourceAsStream( "test_RuntimeTypeCoercion2.drl" ) ) );
final Package pkg = builder.getPackage();
- final RuleBase ruleBase = getRuleBase();
+ RuleBase ruleBase = getRuleBase();
ruleBase.addPackage( pkg );
+ ruleBase = SerializationHelper.serializeObject(ruleBase);
final WorkingMemory workingMemory = ruleBase.newStatefulSession();
final List list = new ArrayList();
@@ -4431,8 +4820,9 @@
builder.addPackageFromDrl( new InputStreamReader( getClass().getResourceAsStream( "test_AlphaEvalWithOrCE.drl" ) ) );
final Package pkg = builder.getPackage();
- final RuleBase ruleBase = getRuleBase();
+ RuleBase ruleBase = getRuleBase();
ruleBase.addPackage( pkg );
+ ruleBase = SerializationHelper.serializeObject(ruleBase);
final WorkingMemory workingMemory = ruleBase.newStatefulSession();
final List list = new ArrayList();
@@ -4458,8 +4848,9 @@
builder.addPackageFromDrl( new InputStreamReader( getClass().getResourceAsStream( "test_ModifyRetractInsert.drl" ) ) );
final Package pkg = builder.getPackage();
- final RuleBase ruleBase = getRuleBase();
+ RuleBase ruleBase = getRuleBase();
ruleBase.addPackage( pkg );
+ ruleBase = SerializationHelper.serializeObject(ruleBase);
final WorkingMemory workingMemory = ruleBase.newStatefulSession();
final List list = new ArrayList();
@@ -4479,14 +4870,44 @@
list.size() );
}
+ public void testModifyBlock() throws Exception {
+ final PackageBuilder builder = new PackageBuilder();
+ builder.addPackageFromDrl( new InputStreamReader( getClass().getResourceAsStream( "test_ModifyBlock.drl" ) ) );
+ final Package pkg = builder.getPackage();
+
+ final RuleBase ruleBase = getRuleBase();
+ ruleBase.addPackage( pkg );
+ final WorkingMemory workingMemory = ruleBase.newStatefulSession();
+
+ final List list = new ArrayList();
+ workingMemory.setGlobal( "results",
+ list );
+
+ Person bob = new Person( "Bob" );
+ bob.setStatus( "hungry" );
+
+ Cheese c = new Cheese();
+
+ workingMemory.insert( bob );
+ workingMemory.insert( c );
+
+ workingMemory.fireAllRules();
+
+ assertEquals( 10,
+ c.getPrice() );
+ assertEquals( "fine",
+ bob.getStatus() );
+ }
+
// this test requires mvel 1.2.19. Leaving it commented until mvel is released.
public void testJavaModifyBlock() throws Exception {
final PackageBuilder builder = new PackageBuilder();
builder.addPackageFromDrl( new InputStreamReader( getClass().getResourceAsStream( "test_JavaModifyBlock.drl" ) ) );
final Package pkg = builder.getPackage();
- final RuleBase ruleBase = getRuleBase();
+ RuleBase ruleBase = getRuleBase();
ruleBase.addPackage( pkg );
+ ruleBase = SerializationHelper.serializeObject(ruleBase);
final WorkingMemory workingMemory = ruleBase.newStatefulSession();
final List list = new ArrayList();
@@ -4516,8 +4937,9 @@
builder.addPackageFromDrl( new InputStreamReader( getClass().getResourceAsStream( "test_OrCE.drl" ) ) );
final Package pkg = builder.getPackage();
- final RuleBase ruleBase = getRuleBase();
+ RuleBase ruleBase = getRuleBase();
ruleBase.addPackage( pkg );
+ ruleBase = SerializationHelper.serializeObject(ruleBase);
final WorkingMemory workingMemory = ruleBase.newStatefulSession();
final List list = new ArrayList();
@@ -4540,8 +4962,9 @@
builder.addPackageFromDrl( new InputStreamReader( getClass().getResourceAsStream( "test_DeepNestedConstraints.drl" ) ) );
final Package pkg = builder.getPackage();
- final RuleBase ruleBase = getRuleBase();
+ RuleBase ruleBase = getRuleBase();
ruleBase.addPackage( pkg );
+ ruleBase = SerializationHelper.serializeObject(ruleBase);
final WorkingMemory workingMemory = ruleBase.newStatefulSession();
final List list = new ArrayList();
@@ -4565,8 +4988,9 @@
public void testGetFactHandleEqualityBehavior() throws Exception {
final RuleBaseConfiguration conf = new RuleBaseConfiguration();
conf.setAssertBehaviour( RuleBaseConfiguration.AssertBehaviour.EQUALITY );
- final RuleBase ruleBase = RuleBaseFactory.newRuleBase( conf );
+ RuleBase ruleBase = RuleBaseFactory.newRuleBase( conf );
+ ruleBase = SerializationHelper.serializeObject(ruleBase);
final StatefulSession session = ruleBase.newStatefulSession();
CheeseEqual cheese = new CheeseEqual( "stilton",
@@ -4580,8 +5004,9 @@
public void testGetFactHandleIdentityBehavior() throws Exception {
final RuleBaseConfiguration conf = new RuleBaseConfiguration();
conf.setAssertBehaviour( RuleBaseConfiguration.AssertBehaviour.IDENTITY );
- final RuleBase ruleBase = RuleBaseFactory.newRuleBase( conf );
+ RuleBase ruleBase = RuleBaseFactory.newRuleBase( conf );
+ ruleBase = SerializationHelper.serializeObject(ruleBase);
final StatefulSession session = ruleBase.newStatefulSession();
CheeseEqual cheese = new CheeseEqual( "stilton",
@@ -4599,8 +5024,9 @@
builder.addPackageFromDrl( new InputStreamReader( getClass().getResourceAsStream( "test_OrCEFollowedByEval.drl" ) ) );
final Package pkg = builder.getPackage();
- final RuleBase ruleBase = getRuleBase();
+ RuleBase ruleBase = getRuleBase();
ruleBase.addPackage( pkg );
+ ruleBase = SerializationHelper.serializeObject(ruleBase);
final WorkingMemory workingMemory = ruleBase.newStatefulSession();
final List list = new ArrayList();
@@ -4623,18 +5049,21 @@
builder.addPackageFromDrl( new InputStreamReader( getClass().getResourceAsStream( "test_NPEOnMVELPredicate.drl" ) ) );
final Package pkg = builder.getPackage();
- final RuleBase ruleBase = getRuleBase();
+ RuleBase ruleBase = getRuleBase();
ruleBase.addPackage( pkg );
+ ruleBase = SerializationHelper.serializeObject(ruleBase);
final StatefulSession session = ruleBase.newStatefulSession();
final List list = new ArrayList();
session.setGlobal( "results",
- list );
-
- Cheese cheese = new Cheese( "stilton", 10 );
+ list );
+
+ Cheese cheese = new Cheese( "stilton",
+ 10 );
Cheesery cheesery = new Cheesery();
cheesery.addCheese( cheese );
- Person bob = new Person( "bob", "stilton" );
+ Person bob = new Person( "bob",
+ "stilton" );
Cheese cheese2 = new Cheese();
bob.setCheese( cheese2 );
@@ -4646,15 +5075,15 @@
assertEquals( "should not have fired",
0,
list.size() );
-
+
cheese2.setType( "stilton" );
-
- session.update( p, bob );
+ session.update( p,
+ bob );
session.fireAllRules();
-
+
assertEquals( 1,
list.size() );
-
+
}
-
+
}
Modified: labs/jbossrules/branches/temporal_rete/drools-compiler/src/test/java/org/drools/integrationtests/MultithreadTest.java
===================================================================
--- labs/jbossrules/branches/temporal_rete/drools-compiler/src/test/java/org/drools/integrationtests/MultithreadTest.java 2008-03-20 18:57:07 UTC (rev 19163)
+++ labs/jbossrules/branches/temporal_rete/drools-compiler/src/test/java/org/drools/integrationtests/MultithreadTest.java 2008-03-20 19:32:10 UTC (rev 19164)
@@ -18,28 +18,23 @@
package org.drools.integrationtests;
-import java.io.InputStreamReader;
-import java.io.StringReader;
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.List;
-import java.util.Queue;
-import java.util.Vector;
-import java.util.concurrent.ConcurrentLinkedQueue;
-
import junit.framework.TestCase;
-
import org.drools.Child;
import org.drools.GrandParent;
import org.drools.Order;
import org.drools.Parent;
import org.drools.RuleBase;
-import org.drools.RuleBaseConfiguration;
import org.drools.RuleBaseFactory;
import org.drools.StatefulSession;
import org.drools.compiler.PackageBuilder;
-import org.drools.compiler.PackageBuilderConfiguration;
+import java.io.InputStreamReader;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Queue;
+import java.util.Vector;
+import java.util.concurrent.ConcurrentLinkedQueue;
+
/**
* This is a test case for multi-thred issues
*
@@ -73,6 +68,7 @@
builder.addPackageFromDrl( new InputStreamReader( getClass().getResourceAsStream( "test_MultithreadRulebaseSharing.drl" ) ) );
RuleBase ruleBase = RuleBaseFactory.newRuleBase();
ruleBase.addPackage( builder.getPackage() );
+ ruleBase = SerializationHelper.serializeObject(ruleBase);
final Thread[] t = new Thread[THREAD_COUNT];
final RulebaseRunner[] r = new RulebaseRunner[THREAD_COUNT];
for ( int i = 0; i < t.length; i++ ) {
Modified: labs/jbossrules/branches/temporal_rete/drools-compiler/src/test/java/org/drools/integrationtests/OutOfMemoryTest.java
===================================================================
--- labs/jbossrules/branches/temporal_rete/drools-compiler/src/test/java/org/drools/integrationtests/OutOfMemoryTest.java 2008-03-20 18:57:07 UTC (rev 19163)
+++ labs/jbossrules/branches/temporal_rete/drools-compiler/src/test/java/org/drools/integrationtests/OutOfMemoryTest.java 2008-03-20 19:32:10 UTC (rev 19164)
@@ -16,10 +16,7 @@
* limitations under the License.
*/
-import java.io.InputStreamReader;
-
import junit.framework.TestCase;
-
import org.drools.Cheese;
import org.drools.RuleBase;
import org.drools.RuleBaseConfiguration;
@@ -29,7 +26,9 @@
import org.drools.compiler.PackageBuilder;
import org.drools.rule.Package;
+import java.io.InputStreamReader;
+
/** Run all the tests with the ReteOO engine implementation */
public class OutOfMemoryTest extends TestCase {
@@ -51,9 +50,10 @@
builder.addPackageFromDrl( new InputStreamReader( getClass().getResourceAsStream( "test_OutOfMemoryError.drl" ) ) );
final Package pkg = builder.getPackage();
- final RuleBase ruleBase = getRuleBase();
+ RuleBase ruleBase = getRuleBase();
ruleBase.addPackage( pkg );
-
+ ruleBase = SerializationHelper.serializeObject(ruleBase);
+
int i = 0;
try {
@@ -74,8 +74,9 @@
builder.addPackageFromDrl( new InputStreamReader( getClass().getResourceAsStream( "test_OutOfMemory.drl" ) ) );
final Package pkg = builder.getPackage();
- final RuleBase ruleBase = getRuleBase();
+ RuleBase ruleBase = getRuleBase();
ruleBase.addPackage( pkg );
+ ruleBase = SerializationHelper.serializeObject(ruleBase);
final WorkingMemory workingMemory = ruleBase.newStatefulSession();
workingMemory.insert( new Cheese( "stilton",
Copied: labs/jbossrules/branches/temporal_rete/drools-compiler/src/test/java/org/drools/integrationtests/SerializationHelper.java (from rev 19160, labs/jbossrules/dev_tags/before_righttuple_merge_20080320/drools-compiler/src/test/java/org/drools/integrationtests/SerializationHelper.java)
===================================================================
--- labs/jbossrules/branches/temporal_rete/drools-compiler/src/test/java/org/drools/integrationtests/SerializationHelper.java (rev 0)
+++ labs/jbossrules/branches/temporal_rete/drools-compiler/src/test/java/org/drools/integrationtests/SerializationHelper.java 2008-03-20 19:32:10 UTC (rev 19164)
@@ -0,0 +1,29 @@
+package org.drools.integrationtests;
+
+import org.drools.common.DroolsObjectOutputStream;
+import org.drools.common.DroolsObjectInputStream;
+
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+import java.io.ByteArrayInputStream;
+
+/**
+ * Marshalling helper class to perform serialize/de-serialize a given object
+ */
+public class SerializationHelper {
+ public static <T> T serializeObject(T obj) throws IOException, ClassNotFoundException {
+ return (T)serializeIn(serializeOut(obj));
+ }
+
+ public static byte[] serializeOut(Object obj) throws IOException {
+ ByteArrayOutputStream out = new ByteArrayOutputStream();
+ new DroolsObjectOutputStream(out).writeObject(obj);
+ out.close();
+ return out.toByteArray();
+ }
+
+ public static Object serializeIn(byte[] bytes)
+ throws IOException, ClassNotFoundException {
+ return new DroolsObjectInputStream(new ByteArrayInputStream(bytes)).readObject();
+ }
+}
Modified: labs/jbossrules/branches/temporal_rete/drools-compiler/src/test/java/org/drools/integrationtests/StatefulSessionTest.java
===================================================================
--- labs/jbossrules/branches/temporal_rete/drools-compiler/src/test/java/org/drools/integrationtests/StatefulSessionTest.java 2008-03-20 18:57:07 UTC (rev 19163)
+++ labs/jbossrules/branches/temporal_rete/drools-compiler/src/test/java/org/drools/integrationtests/StatefulSessionTest.java 2008-03-20 19:32:10 UTC (rev 19164)
@@ -1,11 +1,6 @@
package org.drools.integrationtests;
-import java.io.InputStreamReader;
-import java.util.ArrayList;
-import java.util.List;
-
import junit.framework.TestCase;
-
import org.drools.Cheese;
import org.drools.FactHandle;
import org.drools.RuleBase;
@@ -16,6 +11,10 @@
import org.drools.concurrent.Future;
import org.drools.rule.Package;
+import java.io.InputStreamReader;
+import java.util.ArrayList;
+import java.util.List;
+
public class StatefulSessionTest extends TestCase {
final List list = new ArrayList();
@@ -195,8 +194,9 @@
builder.addPackageFromDrl( new InputStreamReader( getClass().getResourceAsStream( "test_ConsequenceException.drl" ) ) );
final Package pkg = builder.getPackage();
- final RuleBase ruleBase = getRuleBase();
+ RuleBase ruleBase = getRuleBase();
ruleBase.addPackage( pkg );
+ ruleBase = SerializationHelper.serializeObject(ruleBase);
return ruleBase.newStatefulSession();
}
@@ -205,10 +205,12 @@
builder.addPackageFromDrl( new InputStreamReader( getClass().getResourceAsStream( "literal_rule_test.drl" ) ) );
final Package pkg = builder.getPackage();
- final RuleBase ruleBase = getRuleBase();
+ RuleBase ruleBase = getRuleBase();
ruleBase.addPackage( pkg );
- final StatefulSession session = ruleBase.newStatefulSession();
+ ruleBase = SerializationHelper.serializeObject(ruleBase);
+ StatefulSession session = ruleBase.newStatefulSession();
+// session = SerializationHelper.serializeObject(session);
session.setGlobal( "list",
this.list );
return session;
Modified: labs/jbossrules/branches/temporal_rete/drools-compiler/src/test/java/org/drools/integrationtests/StatelessSessionTest.java
===================================================================
--- labs/jbossrules/branches/temporal_rete/drools-compiler/src/test/java/org/drools/integrationtests/StatelessSessionTest.java 2008-03-20 18:57:07 UTC (rev 19163)
+++ labs/jbossrules/branches/temporal_rete/drools-compiler/src/test/java/org/drools/integrationtests/StatelessSessionTest.java 2008-03-20 19:32:10 UTC (rev 19164)
@@ -1,9 +1,6 @@
package org.drools.integrationtests;
-import java.io.InputStreamReader;
-import java.util.ArrayList;
-import java.util.List;
-
+import junit.framework.TestCase;
import org.drools.Cheese;
import org.drools.Cheesery;
import org.drools.RuleBase;
@@ -11,16 +8,16 @@
import org.drools.RuleBaseFactory;
import org.drools.StatelessSession;
import org.drools.StatelessSessionResult;
-import org.drools.WorkingMemory;
import org.drools.base.CopyIdentifiersGlobalExporter;
import org.drools.base.MapGlobalResolver;
import org.drools.base.ReferenceOriginalGlobalExporter;
import org.drools.compiler.PackageBuilder;
import org.drools.rule.Package;
-import org.drools.spi.GlobalExporter;
import org.drools.spi.GlobalResolver;
-import junit.framework.TestCase;
+import java.io.InputStreamReader;
+import java.util.ArrayList;
+import java.util.List;
public class StatelessSessionTest extends TestCase {
final List list = new ArrayList();
@@ -261,10 +258,12 @@
builder.addPackageFromDrl( new InputStreamReader( getClass().getResourceAsStream( "literal_rule_test.drl" ) ) );
final Package pkg = builder.getPackage();
- final RuleBase ruleBase = getRuleBase();
+ RuleBase ruleBase = getRuleBase();
ruleBase.addPackage( pkg );
- final StatelessSession session = ruleBase.newStatelessSession();
+ ruleBase = SerializationHelper.serializeObject(ruleBase);
+ StatelessSession session = ruleBase.newStatelessSession();
+ session = SerializationHelper.serializeObject(session);
session.setGlobalResolver( this.globalResolver );
session.setGlobal( "list",
Modified: labs/jbossrules/branches/temporal_rete/drools-compiler/src/test/java/org/drools/integrationtests/StatelessStressTest.java
===================================================================
--- labs/jbossrules/branches/temporal_rete/drools-compiler/src/test/java/org/drools/integrationtests/StatelessStressTest.java 2008-03-20 18:57:07 UTC (rev 19163)
+++ labs/jbossrules/branches/temporal_rete/drools-compiler/src/test/java/org/drools/integrationtests/StatelessStressTest.java 2008-03-20 19:32:10 UTC (rev 19164)
@@ -1,17 +1,18 @@
package org.drools.integrationtests;
-import java.io.InputStreamReader;
-import java.util.ArrayList;
-import java.util.List;
-
+import junit.framework.TestCase;
import org.drools.Address;
import org.drools.Person;
+import org.drools.rule.Package;
import org.drools.RuleBase;
import org.drools.RuleBaseFactory;
import org.drools.StatelessSession;
import org.drools.compiler.PackageBuilder;
-import junit.framework.TestCase;
+import java.io.InputStreamReader;
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.List;
/**
* This is for testing possible PermSpace issues (leaking) when spawning lots of sessions in concurrent threads.
@@ -23,6 +24,13 @@
public void testDummy() {
}
+
+ private static RuleBase getRuleBase(Package pkg) throws IOException, ClassNotFoundException {
+ RuleBase ruleBase = RuleBaseFactory.newRuleBase();
+
+ ruleBase.addPackage( pkg );
+ return SerializationHelper.serializeObject(ruleBase);
+ }
public void XXXtestLotsOfStateless() throws Exception {
@@ -33,11 +41,8 @@
- final RuleBase rb = RuleBaseFactory.newRuleBase();
- rb.addPackage( builder.getPackage() );
-
-
-
+ final RuleBase rb = getRuleBase( builder.getPackage() );
+
int numThreads = 100;
Thread[] ts = new Thread[numThreads];
@@ -53,6 +58,11 @@
while (true) {
start = System.currentTimeMillis();
StatelessSession sess = rb.newStatelessSession();
+ try {
+ sess = SerializationHelper.serializeObject(sess);
+ } catch (Exception ex) {
+ throw new RuntimeException(ex);
+ }
Person p = new Person();
p.setName( "Michael" );
Address add1 = new Address();
Modified: labs/jbossrules/branches/temporal_rete/drools-compiler/src/test/java/org/drools/integrationtests/StreamsTest.java
===================================================================
--- labs/jbossrules/branches/temporal_rete/drools-compiler/src/test/java/org/drools/integrationtests/StreamsTest.java 2008-03-20 18:57:07 UTC (rev 19163)
+++ labs/jbossrules/branches/temporal_rete/drools-compiler/src/test/java/org/drools/integrationtests/StreamsTest.java 2008-03-20 19:32:10 UTC (rev 19164)
@@ -17,12 +17,8 @@
*/
package org.drools.integrationtests;
-import java.io.IOException;
-import java.io.InputStreamReader;
-import java.io.Reader;
-import java.util.ArrayList;
-import java.util.List;
-
+import junit.framework.Assert;
+import junit.framework.TestCase;
import org.drools.ClockType;
import org.drools.WorkingMemoryEntryPoint;
import org.drools.RuleBase;
@@ -37,8 +33,11 @@
import org.drools.lang.descr.PackageDescr;
import org.drools.rule.Package;
-import junit.framework.Assert;
-import junit.framework.TestCase;
+import java.io.IOException;
+import java.io.InputStreamReader;
+import java.io.Reader;
+import java.util.ArrayList;
+import java.util.List;
/**
* Tests related to the stream support features
@@ -91,7 +90,7 @@
final RuleBase ruleBase = getRuleBase();
ruleBase.addPackage( pkg );
// load up the rulebase
- return ruleBase;
+ return SerializationHelper.serializeObject(ruleBase);
}
public void testEventAssertion() throws Exception {
Modified: labs/jbossrules/branches/temporal_rete/drools-compiler/src/test/java/org/drools/integrationtests/TruthMaintenanceTest.java
===================================================================
--- labs/jbossrules/branches/temporal_rete/drools-compiler/src/test/java/org/drools/integrationtests/TruthMaintenanceTest.java 2008-03-20 18:57:07 UTC (rev 19163)
+++ labs/jbossrules/branches/temporal_rete/drools-compiler/src/test/java/org/drools/integrationtests/TruthMaintenanceTest.java 2008-03-20 19:32:10 UTC (rev 19164)
@@ -1,12 +1,6 @@
package org.drools.integrationtests;
-import java.io.InputStreamReader;
-import java.io.Reader;
-import java.util.ArrayList;
-import java.util.List;
-
import junit.framework.TestCase;
-
import org.drools.Cheese;
import org.drools.CheeseEqual;
import org.drools.FactHandle;
@@ -28,6 +22,11 @@
import org.drools.rule.Package;
import org.drools.util.ObjectHashMap;
+import java.io.InputStreamReader;
+import java.io.Reader;
+import java.util.ArrayList;
+import java.util.List;
+
public class TruthMaintenanceTest extends TestCase {
protected RuleBase getRuleBase() throws Exception {
@@ -41,13 +40,147 @@
config );
}
+ public void testLogicalInsertionsDynamicRule() throws Exception {
+ PackageBuilder builder = new PackageBuilder();
+ builder.addPackageFromDrl( new InputStreamReader( getClass().getResourceAsStream( "test_LogicalInsertionsDynamicRule.drl" ) ) );
+ final Package pkg = builder.getPackage();
+
+ org.drools.reteoo.ReteooRuleBase reteooRuleBase = null;
+ // org.drools.leaps.LeapsRuleBase leapsRuleBase = null;
+ RuleBase ruleBase = getRuleBase();
+ if ( ruleBase instanceof org.drools.reteoo.ReteooRuleBase ) {
+ reteooRuleBase = (org.drools.reteoo.ReteooRuleBase) ruleBase;
+ // } else if ( ruleBase instanceof org.drools.leaps.LeapsRuleBase )
+ // {
+ // leapsRuleBase = (org.drools.leaps.LeapsRuleBase) ruleBase;
+ }
+ ruleBase.addPackage( pkg );
+// ruleBase = SerializationHelper.serializeObject(ruleBase);
+ final WorkingMemory workingMemory = ruleBase.newStatefulSession();
+
+ // workingMemory.addEventListener(new
+ // org.drools.event.DebugAgendaEventListener());
+ // workingMemory.addEventListener(new
+ // org.drools.event.DebugWorkingMemoryEventListener());
+
+ final Cheese c1 = new Cheese( "a",
+ 1 );
+ final Cheese c2 = new Cheese( "b",
+ 2 );
+ final Cheese c3 = new Cheese( "c",
+ 3 );
+ List list;
+
+ workingMemory.insert( c1 );
+ final FactHandle h = workingMemory.insert( c2 );
+ workingMemory.insert( c3 );
+ workingMemory.fireAllRules();
+
+ // Check logical Insertions where made for c2 and c3
+ list = IteratorToList.convert( workingMemory.iterateObjects( new ClassObjectFilter( Person.class) ) );
+ assertEquals( 2,
+ list.size() );
+ assertFalse( list.contains( new Person( c1.getType() ) ) );
+ assertTrue( list.contains( new Person( c2.getType() ) ) );
+ assertTrue( list.contains( new Person( c3.getType() ) ) );
+
+ // this rule will make a logical assertion for c1 too
+ final Reader reader = new InputStreamReader( getClass().getResourceAsStream( "test_LogicalInsertionsDynamicRule2.drl" ) );
+ builder = new PackageBuilder();
+ builder.addPackageFromDrl( reader );
+ final Package pkg2 = builder.getPackage();
+ ruleBase.addPackage( pkg2 );
+ ruleBase = SerializationHelper.serializeObject(ruleBase);
+
+ workingMemory.fireAllRules();
+
+ ruleBase = workingMemory.getRuleBase();
+
+ // check all now have just one logical assertion each
+ list = IteratorToList.convert( workingMemory.iterateObjects( new ClassObjectFilter( Person.class) ) );
+ assertEquals( 3,
+ list.size() );
+ assertTrue( list.contains( new Person( c1.getType() ) ) );
+ assertTrue( list.contains( new Person( c2.getType() ) ) );
+ assertTrue( list.contains( new Person( c3.getType() ) ) );
+
+ // check the packages are correctly populated
+ assertEquals( "org.drools.test",
+ ruleBase.getPackages()[0].getName() );
+ assertEquals( "org.drools.test2",
+ ruleBase.getPackages()[1].getName() );
+ assertEquals( "rule1",
+ ruleBase.getPackages()[0].getRules()[0].getName() );
+ assertEquals( "rule2",
+ ruleBase.getPackages()[1].getRules()[0].getName() );
+
+ // now remove the first rule
+ if ( reteooRuleBase != null ) {
+ reteooRuleBase.removeRule( ruleBase.getPackages()[0].getName(),
+ ruleBase.getPackages()[0].getRules()[0].getName() );
+ // } else if ( leapsRuleBase != null ) {
+ // leapsRuleBase.removeRule( ruleBase.getPackages()[0].getName(),
+ // ruleBase.getPackages()[0].getRules()[0].getName() );
+ }
+
+ // Check the rule was correctly remove
+ assertEquals( 0,
+ ruleBase.getPackages()[0].getRules().length );
+ assertEquals( 1,
+ ruleBase.getPackages()[1].getRules().length );
+ assertEquals( "org.drools.test2",
+ ruleBase.getPackages()[1].getName() );
+ assertEquals( "rule2",
+ ruleBase.getPackages()[1].getRules()[0].getName() );
+
+ list = IteratorToList.convert( workingMemory.iterateObjects( new ClassObjectFilter( Person.class) ) );
+ assertEquals( "removal of the rule should result in retraction of c3's logical assertion",
+ 2,
+ list.size() );
+ assertTrue( "c1's logical assertion should not be retracted",
+ list.contains( new Person( c1.getType() ) ) );
+ assertTrue( "c2's logical assertion should not be retracted",
+ list.contains( new Person( c2.getType() ) ) );
+ assertFalse( "c3's logical assertion should be retracted",
+ list.contains( new Person( c3.getType() ) ) );
+
+ c2.setPrice( 3 );
+ workingMemory.update( h,
+ c2 );
+ list = IteratorToList.convert( workingMemory.iterateObjects( new ClassObjectFilter( Person.class) ) );
+ assertEquals( "c2 now has a higher price, its logical assertion should be cancelled",
+ 1,
+ list.size() );
+ assertFalse( "The logical assertion cor c2 should have been retracted",
+ list.contains( new Person( c2.getType() ) ) );
+ assertTrue( "The logical assertion for c1 should exist",
+ list.contains( new Person( c1.getType() ) ) );
+
+ if ( reteooRuleBase != null ) {
+ reteooRuleBase.removeRule( ruleBase.getPackages()[1].getName(),
+ ruleBase.getPackages()[1].getRules()[0].getName() );
+ // } else if ( leapsRuleBase != null ) {
+ // leapsRuleBase.removeRule( ruleBase.getPackages()[1].getName(),
+ // ruleBase.getPackages()[1].getRules()[0].getName() );
+ }
+ ruleBase = SerializationHelper.serializeObject(ruleBase);
+ assertEquals( 0,
+ ruleBase.getPackages()[0].getRules().length );
+ assertEquals( 0,
+ ruleBase.getPackages()[1].getRules().length );
+ list = IteratorToList.convert( workingMemory.iterateObjects( new ClassObjectFilter( Person.class) ) );
+ assertEquals( 0,
+ list.size() );
+ }
+
public void testLogicalInsertions() throws Exception {
final PackageBuilder builder = new PackageBuilder();
builder.addPackageFromDrl( new InputStreamReader( getClass().getResourceAsStream( "test_LogicalInsertions.drl" ) ) );
final Package pkg = builder.getPackage();
- final RuleBase ruleBase = getRuleBase();
+ RuleBase ruleBase = getRuleBase();
ruleBase.addPackage( pkg );
+ ruleBase = SerializationHelper.serializeObject(ruleBase);
final WorkingMemory workingMemory = ruleBase.newStatefulSession();
final List list = new ArrayList();
@@ -86,8 +219,9 @@
builder.addPackageFromDrl( new InputStreamReader( getClass().getResourceAsStream( "test_LogicalInsertionsBacking.drl" ) ) );
final Package pkg = builder.getPackage();
- final RuleBase ruleBase = getRuleBase();
+ RuleBase ruleBase = getRuleBase();
ruleBase.addPackage( pkg );
+ ruleBase = SerializationHelper.serializeObject(ruleBase);
final WorkingMemory workingMemory = ruleBase.newStatefulSession();
final Cheese cheese1 = new Cheese( "c",
@@ -139,8 +273,9 @@
builder.addPackageFromDrl( new InputStreamReader( getClass().getResourceAsStream( "test_LogicalInsertionsSelfreferencing.drl" ) ) );
final Package pkg = builder.getPackage();
- final RuleBase ruleBase = getRuleBase();
+ RuleBase ruleBase = getRuleBase();
ruleBase.addPackage( pkg );
+ ruleBase = SerializationHelper.serializeObject(ruleBase);
final WorkingMemory workingMemory = ruleBase.newStatefulSession();
List list;
@@ -182,8 +317,9 @@
builder.addPackageFromDrl( new InputStreamReader( getClass().getResourceAsStream( "test_LogicalInsertionsLoop.drl" ) ) );
final Package pkg = builder.getPackage();
- final RuleBase ruleBase = getRuleBase();
+ RuleBase ruleBase = getRuleBase();
ruleBase.addPackage( pkg );
+ ruleBase = SerializationHelper.serializeObject(ruleBase);
final WorkingMemory workingMemory = ruleBase.newStatefulSession();
List list;
@@ -210,8 +346,9 @@
builder.addPackageFromDrl( new InputStreamReader( getClass().getResourceAsStream( "test_LogicalInsertionsNoLoop.drl" ) ) );
final Package pkg = builder.getPackage();
- final RuleBase ruleBase = getRuleBase();
+ RuleBase ruleBase = getRuleBase();
ruleBase.addPackage( pkg );
+ ruleBase = SerializationHelper.serializeObject(ruleBase);
final WorkingMemory workingMemory = ruleBase.newStatefulSession();
List list;
@@ -238,8 +375,9 @@
builder.addPackageFromDrl( new InputStreamReader( getClass().getResourceAsStream( "test_LogicalInsertionsWithUpdate.drl" ) ) );
final Package pkg = builder.getPackage();
- final RuleBase ruleBase = getRuleBase();
+ RuleBase ruleBase = getRuleBase();
ruleBase.addPackage( pkg );
+ ruleBase = SerializationHelper.serializeObject(ruleBase);
final WorkingMemory workingMemory = ruleBase.newStatefulSession();
final WorkingMemoryEventListener l2 = new DefaultWorkingMemoryEventListener() {
@@ -295,8 +433,9 @@
builder.addPackageFromDrl( new InputStreamReader( getClass().getResourceAsStream( "test_LogicalInsertions2.drl" ) ) );
final Package pkg = builder.getPackage();
- final RuleBase ruleBase = getRuleBase();
+ RuleBase ruleBase = getRuleBase();
ruleBase.addPackage( pkg );
+ ruleBase = SerializationHelper.serializeObject(ruleBase);
final WorkingMemory workingMemory = ruleBase.newStatefulSession();
// final WorkingMemoryFileLogger logger = new WorkingMemoryFileLogger( workingMemory );
@@ -345,8 +484,9 @@
builder.addPackageFromDrl( new InputStreamReader( getClass().getResourceAsStream( "test_LogicalInsertionsNot.drl" ) ) );
final Package pkg = builder.getPackage();
- final RuleBase ruleBase = getRuleBase();
+ RuleBase ruleBase = getRuleBase();
ruleBase.addPackage( pkg );
+ ruleBase = SerializationHelper.serializeObject(ruleBase);
final WorkingMemory workingMemory = ruleBase.newStatefulSession();
List list;
@@ -402,8 +542,9 @@
builder.addPackageFromDrl( new InputStreamReader( getClass().getResourceAsStream( "test_LogicalInsertionsNotPingPong.drl" ) ) );
final Package pkg = builder.getPackage();
- final RuleBase ruleBase = getRuleBase();
+ RuleBase ruleBase = getRuleBase();
ruleBase.addPackage( pkg );
+ ruleBase = SerializationHelper.serializeObject(ruleBase);
final WorkingMemory workingMemory = ruleBase.newStatefulSession();
// workingMemory.addEventListener(new DebugAgendaEventListener());
@@ -430,141 +571,14 @@
list.size() );
}
- public void testLogicalInsertionsDynamicRule() throws Exception {
- PackageBuilder builder = new PackageBuilder();
- builder.addPackageFromDrl( new InputStreamReader( getClass().getResourceAsStream( "test_LogicalInsertionsDynamicRule.drl" ) ) );
- final Package pkg = builder.getPackage();
-
- org.drools.reteoo.ReteooRuleBase reteooRuleBase = null;
- // org.drools.leaps.LeapsRuleBase leapsRuleBase = null;
- final RuleBase ruleBase = getRuleBase();
- if ( ruleBase instanceof org.drools.reteoo.ReteooRuleBase ) {
- reteooRuleBase = (org.drools.reteoo.ReteooRuleBase) ruleBase;
- // } else if ( ruleBase instanceof org.drools.leaps.LeapsRuleBase )
- // {
- // leapsRuleBase = (org.drools.leaps.LeapsRuleBase) ruleBase;
- }
- ruleBase.addPackage( pkg );
- final WorkingMemory workingMemory = ruleBase.newStatefulSession();
-
- // workingMemory.addEventListener(new
- // org.drools.event.DebugAgendaEventListener());
- // workingMemory.addEventListener(new
- // org.drools.event.DebugWorkingMemoryEventListener());
-
- final Cheese c1 = new Cheese( "a",
- 1 );
- final Cheese c2 = new Cheese( "b",
- 2 );
- final Cheese c3 = new Cheese( "c",
- 3 );
- List list;
-
- workingMemory.insert( c1 );
- final FactHandle h = workingMemory.insert( c2 );
- workingMemory.insert( c3 );
- workingMemory.fireAllRules();
-
- // Check logical Insertions where made for c2 and c3
- list = IteratorToList.convert( workingMemory.iterateObjects( new ClassObjectFilter( Person.class) ) );
- assertEquals( 2,
- list.size() );
- assertFalse( list.contains( new Person( c1.getType() ) ) );
- assertTrue( list.contains( new Person( c2.getType() ) ) );
- assertTrue( list.contains( new Person( c3.getType() ) ) );
-
- // this rule will make a logical assertion for c1 too
- final Reader reader = new InputStreamReader( getClass().getResourceAsStream( "test_LogicalInsertionsDynamicRule2.drl" ) );
- builder = new PackageBuilder();
- builder.addPackageFromDrl( reader );
- final Package pkg2 = builder.getPackage();
- ruleBase.addPackage( pkg2 );
-
- workingMemory.fireAllRules();
-
- // check all now have just one logical assertion each
- list = IteratorToList.convert( workingMemory.iterateObjects( new ClassObjectFilter( Person.class) ) );
- assertEquals( 3,
- list.size() );
- assertTrue( list.contains( new Person( c1.getType() ) ) );
- assertTrue( list.contains( new Person( c2.getType() ) ) );
- assertTrue( list.contains( new Person( c3.getType() ) ) );
-
- // check the packages are correctly populated
- assertEquals( "org.drools.test",
- ruleBase.getPackages()[0].getName() );
- assertEquals( "org.drools.test2",
- ruleBase.getPackages()[1].getName() );
- assertEquals( "rule1",
- ruleBase.getPackages()[0].getRules()[0].getName() );
- assertEquals( "rule2",
- ruleBase.getPackages()[1].getRules()[0].getName() );
-
- // now remove the first rule
- if ( reteooRuleBase != null ) {
- reteooRuleBase.removeRule( ruleBase.getPackages()[0].getName(),
- ruleBase.getPackages()[0].getRules()[0].getName() );
- // } else if ( leapsRuleBase != null ) {
- // leapsRuleBase.removeRule( ruleBase.getPackages()[0].getName(),
- // ruleBase.getPackages()[0].getRules()[0].getName() );
- }
-
- // Check the rule was correctly remove
- assertEquals( 0,
- ruleBase.getPackages()[0].getRules().length );
- assertEquals( 1,
- ruleBase.getPackages()[1].getRules().length );
- assertEquals( "org.drools.test2",
- ruleBase.getPackages()[1].getName() );
- assertEquals( "rule2",
- ruleBase.getPackages()[1].getRules()[0].getName() );
-
- list = IteratorToList.convert( workingMemory.iterateObjects( new ClassObjectFilter( Person.class) ) );
- assertEquals( "removal of the rule should result in retraction of c3's logical assertion",
- 2,
- list.size() );
- assertTrue( "c1's logical assertion should not be retracted",
- list.contains( new Person( c1.getType() ) ) );
- assertTrue( "c2's logical assertion should not be retracted",
- list.contains( new Person( c2.getType() ) ) );
- assertFalse( "c3's logical assertion should be retracted",
- list.contains( new Person( c3.getType() ) ) );
-
- c2.setPrice( 3 );
- workingMemory.update( h,
- c2 );
- list = IteratorToList.convert( workingMemory.iterateObjects( new ClassObjectFilter( Person.class) ) );
- assertEquals( "c2 now has a higher price, its logical assertion should be cancelled",
- 1,
- list.size() );
- assertFalse( "The logical assertion cor c2 should have been retracted",
- list.contains( new Person( c2.getType() ) ) );
- assertTrue( "The logical assertion for c1 should exist",
- list.contains( new Person( c1.getType() ) ) );
-
- if ( reteooRuleBase != null ) {
- reteooRuleBase.removeRule( ruleBase.getPackages()[1].getName(),
- ruleBase.getPackages()[1].getRules()[0].getName() );
- // } else if ( leapsRuleBase != null ) {
- // leapsRuleBase.removeRule( ruleBase.getPackages()[1].getName(),
- // ruleBase.getPackages()[1].getRules()[0].getName() );
- }
- assertEquals( 0,
- ruleBase.getPackages()[0].getRules().length );
- assertEquals( 0,
- ruleBase.getPackages()[1].getRules().length );
- list = IteratorToList.convert( workingMemory.iterateObjects( new ClassObjectFilter( Person.class) ) );
- assertEquals( 0,
- list.size() );
- }
-
public void testLogicalInsertionsUpdateEqual() throws Exception {
final PackageBuilder builder = new PackageBuilder();
builder.addPackageFromDrl( new InputStreamReader( getClass().getResourceAsStream( "test_LogicalInsertionsUpdateEqual.drl" ) ) );
final Package pkg = builder.getPackage();
- final RuleBase ruleBase = getRuleBase();
+ RuleBase ruleBase = getRuleBase();
ruleBase.addPackage( pkg );
+ ruleBase = SerializationHelper.serializeObject(ruleBase);
final WorkingMemory workingMemory = ruleBase.newStatefulSession();
List l;
@@ -603,8 +617,9 @@
builder.addPackageFromDrl( new InputStreamReader( getClass().getResourceAsStream( "test_LogicalInsertionWithExists.drl" ) ) );
final Package pkg = builder.getPackage();
- final RuleBase ruleBase = getRuleBase();
+ RuleBase ruleBase = getRuleBase();
ruleBase.addPackage( pkg );
+ ruleBase = SerializationHelper.serializeObject(ruleBase);
final WorkingMemory workingMemory = ruleBase.newStatefulSession();
final Person p1 = new Person( "p1",
@@ -689,8 +704,9 @@
builder.addPackageFromDrl( new InputStreamReader( getClass().getResourceAsStream( "test_logicalInsertions3.drl" ) ) );
final Package pkg = builder.getPackage();
- final RuleBase ruleBase = getRuleBase();
+ RuleBase ruleBase = getRuleBase();
ruleBase.addPackage( pkg );
+ ruleBase = SerializationHelper.serializeObject(ruleBase);
final WorkingMemory workingMemory = ruleBase.newStatefulSession();
final List list = new ArrayList();
@@ -741,8 +757,9 @@
builder.addPackageFromDrl( new InputStreamReader( getClass().getResourceAsStream( "test_LogicalInsertionsAccumulatorPattern.drl" ) ) );
final Package pkg = builder.getPackage();
- final RuleBase ruleBase = getRuleBase();
+ RuleBase ruleBase = getRuleBase();
ruleBase.addPackage( pkg );
+ ruleBase = SerializationHelper.serializeObject(ruleBase);
final WorkingMemory workingMemory = ruleBase.newStatefulSession();
workingMemory.setGlobal( "ga", "a");
Modified: labs/jbossrules/branches/temporal_rete/drools-compiler/src/test/java/org/drools/integrationtests/eventgenerator/SimpleEventGeneratorTest.java
===================================================================
--- labs/jbossrules/branches/temporal_rete/drools-compiler/src/test/java/org/drools/integrationtests/eventgenerator/SimpleEventGeneratorTest.java 2008-03-20 18:57:07 UTC (rev 19163)
+++ labs/jbossrules/branches/temporal_rete/drools-compiler/src/test/java/org/drools/integrationtests/eventgenerator/SimpleEventGeneratorTest.java 2008-03-20 19:32:10 UTC (rev 19164)
@@ -1,23 +1,23 @@
package org.drools.integrationtests.eventgenerator;
-import java.io.IOException;
-import java.io.InputStreamReader;
-import java.io.Reader;
-
import junit.framework.Assert;
import junit.framework.TestCase;
-
import org.drools.RuleBase;
import org.drools.RuleBaseFactory;
import org.drools.WorkingMemory;
import org.drools.compiler.DrlParser;
import org.drools.compiler.DroolsParserException;
import org.drools.compiler.PackageBuilder;
+import org.drools.integrationtests.SerializationHelper;
import org.drools.integrationtests.eventgenerator.Event.EventType;
import org.drools.lang.descr.PackageDescr;
import org.drools.rule.Package;
+import java.io.IOException;
+import java.io.InputStreamReader;
+import java.io.Reader;
+
public class SimpleEventGeneratorTest extends TestCase {
private final static String TEST_RULE_FILE = "test_eventGenerator.drl";
@@ -46,7 +46,7 @@
final RuleBase ruleBase = getRuleBase();
ruleBase.addPackage( pkg );
// load up the rulebase
- return ruleBase;
+ return SerializationHelper.serializeObject(ruleBase);
}
public void testEventGenerationMaxItems() throws DroolsParserException, IOException, Exception{
Modified: labs/jbossrules/branches/temporal_rete/drools-compiler/src/test/java/org/drools/integrationtests/sequential/SequentialTest.java
===================================================================
--- labs/jbossrules/branches/temporal_rete/drools-compiler/src/test/java/org/drools/integrationtests/sequential/SequentialTest.java 2008-03-20 18:57:07 UTC (rev 19163)
+++ labs/jbossrules/branches/temporal_rete/drools-compiler/src/test/java/org/drools/integrationtests/sequential/SequentialTest.java 2008-03-20 19:32:10 UTC (rev 19164)
@@ -1,23 +1,23 @@
package org.drools.integrationtests.sequential;
-import java.io.IOException;
-import java.io.InputStreamReader;
-import java.util.ArrayList;
-import java.util.List;
-import java.util.Properties;
-
import junit.framework.TestCase;
-
import org.drools.Cheese;
import org.drools.Person;
import org.drools.RuleBase;
import org.drools.RuleBaseConfiguration;
import org.drools.RuleBaseFactory;
import org.drools.StatelessSession;
+import org.drools.integrationtests.SerializationHelper;
import org.drools.compiler.DroolsParserException;
import org.drools.compiler.PackageBuilder;
import org.drools.rule.Package;
+import java.io.IOException;
+import java.io.InputStreamReader;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Properties;
+
public class SequentialTest extends TestCase {
public void testBasicOperation() throws Exception {
@@ -28,8 +28,9 @@
RuleBaseConfiguration conf = new RuleBaseConfiguration();
conf.setSequential( true );
- final RuleBase ruleBase = getRuleBase( conf );
+ RuleBase ruleBase = getRuleBase( conf );
ruleBase.addPackage( pkg );
+ ruleBase = SerializationHelper.serializeObject(ruleBase);
final StatelessSession session = ruleBase.newStatelessSession();
final List list = new ArrayList();
@@ -129,8 +130,9 @@
RuleBaseConfiguration conf = new RuleBaseConfiguration( properties );
conf.setSequential( sequentialMode );
- final RuleBase ruleBase = getRuleBase( conf );
+ RuleBase ruleBase = getRuleBase( conf );
ruleBase.addPackage( pkg );
+ ruleBase = SerializationHelper.serializeObject(ruleBase);
final StatelessSession session = ruleBase.newStatelessSession();
final List list = new ArrayList();
Modified: labs/jbossrules/branches/temporal_rete/drools-compiler/src/test/java/org/drools/integrationtests/waltz/Stage.java
===================================================================
--- labs/jbossrules/branches/temporal_rete/drools-compiler/src/test/java/org/drools/integrationtests/waltz/Stage.java 2008-03-20 18:57:07 UTC (rev 19163)
+++ labs/jbossrules/branches/temporal_rete/drools-compiler/src/test/java/org/drools/integrationtests/waltz/Stage.java 2008-03-20 19:32:10 UTC (rev 19164)
@@ -2,13 +2,13 @@
/*
* Copyright 2005 JBoss Inc
- *
+ *
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -18,19 +18,22 @@
/**
* @author Alexander Bagerman
- *
+ *
*/
-import java.io.Serializable;
+import java.io.Externalizable;
+import java.io.IOException;
+import java.io.ObjectInput;
+import java.io.ObjectOutput;
/**
- *
+ *
* @author Alexander Bagerman
*
*/
public class Stage
implements
- Serializable {
+ Externalizable {
private static final long serialVersionUID = 400L;
final public static int START = 0;
@@ -59,6 +62,13 @@
this.value = value;
}
+ public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
+ value = in.readInt();
+ }
+
+ public void writeExternal(ObjectOutput out) throws IOException {
+ out.writeInt(value);
+ }
public int getValue() {
return this.value;
}
Modified: labs/jbossrules/branches/temporal_rete/drools-compiler/src/test/java/org/drools/integrationtests/waltz/Waltz.java
===================================================================
--- labs/jbossrules/branches/temporal_rete/drools-compiler/src/test/java/org/drools/integrationtests/waltz/Waltz.java 2008-03-20 18:57:07 UTC (rev 19163)
+++ labs/jbossrules/branches/temporal_rete/drools-compiler/src/test/java/org/drools/integrationtests/waltz/Waltz.java 2008-03-20 19:32:10 UTC (rev 19164)
@@ -16,15 +16,7 @@
* limitations under the License.
*/
-import java.io.BufferedReader;
-import java.io.IOException;
-import java.io.InputStreamReader;
-import java.io.Reader;
-import java.util.regex.Matcher;
-import java.util.regex.Pattern;
-
import junit.framework.TestCase;
-
import org.drools.PackageIntegrationException;
import org.drools.RuleBase;
import org.drools.RuleIntegrationException;
@@ -32,10 +24,18 @@
import org.drools.compiler.DrlParser;
import org.drools.compiler.DroolsParserException;
import org.drools.compiler.PackageBuilder;
+import org.drools.integrationtests.SerializationHelper;
import org.drools.lang.descr.PackageDescr;
import org.drools.rule.InvalidPatternException;
import org.drools.rule.Package;
+import java.io.BufferedReader;
+import java.io.IOException;
+import java.io.InputStreamReader;
+import java.io.Reader;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
/**
* This is a sample file to launch a rule package from a rule source file.
*/
@@ -100,7 +100,7 @@
//add the package to a rulebase
final RuleBase ruleBase = getRuleBase();
ruleBase.addPackage( pkg );
- return ruleBase;
+ return SerializationHelper.serializeObject(ruleBase);
}
private void loadLines(final WorkingMemory wm,
Modified: labs/jbossrules/branches/temporal_rete/drools-compiler/src/test/java/org/drools/lang/MVELDumperTest.java
===================================================================
--- labs/jbossrules/branches/temporal_rete/drools-compiler/src/test/java/org/drools/lang/MVELDumperTest.java 2008-03-20 18:57:07 UTC (rev 19163)
+++ labs/jbossrules/branches/temporal_rete/drools-compiler/src/test/java/org/drools/lang/MVELDumperTest.java 2008-03-20 19:32:10 UTC (rev 19164)
@@ -7,15 +7,22 @@
import org.antlr.runtime.CommonTokenStream;
import org.antlr.runtime.Lexer;
import org.antlr.runtime.TokenStream;
+import org.drools.base.evaluators.MatchesEvaluatorsDefinition;
+import org.drools.base.evaluators.SetEvaluatorsDefinition;
import org.drools.lang.descr.FieldConstraintDescr;
import org.drools.lang.descr.PatternDescr;
public class MVELDumperTest extends TestCase {
private MVELDumper dumper;
-
+
protected void setUp() throws Exception {
super.setUp();
+
+ // configure operators
+ new SetEvaluatorsDefinition();
+ new MatchesEvaluatorsDefinition();
+
dumper = new MVELDumper();
}
@@ -23,7 +30,7 @@
super.tearDown();
}
- public void xxxtestDump() throws Exception {
+ public void testDump() throws Exception {
String input = "Cheese( price > 10 && < 20 || == $val || == 30 )";
String expected = "( ( price > 10 && price < 20 ) || price == $val || price == 30 )" ;
DRLParser parser = parse( input );
@@ -59,7 +66,30 @@
assertEquals( expected, result );
}
-
+ public void testDumpMatches3() throws Exception {
+ String input = "Map( this[\"content\"] matches \"hello ;=\" )";
+ String expected = "this[\"content\"] ~= \"hello ;=\"" ;
+ DRLParser parser = parse( input );
+ PatternDescr pattern = (PatternDescr) parser.fact( null );
+
+ FieldConstraintDescr fieldDescr = (FieldConstraintDescr) pattern.getConstraint().getDescrs().get( 0 );
+ String result = dumper.dump( fieldDescr );
+
+ assertEquals( expected, result );
+ }
+
+ public void testDumpWithDateAttr() throws Exception {
+ String input = "Person( son.birthDate == \"01-jan-2000\" )";
+ String expected = "son.birthDate == org.drools.util.DateUtils.parseDate( \"01-jan-2000\" )" ;
+ DRLParser parser = parse( input );
+ PatternDescr pattern = (PatternDescr) parser.fact( null );
+
+ FieldConstraintDescr fieldDescr = (FieldConstraintDescr) pattern.getConstraint().getDescrs().get( 0 );
+ String result = dumper.dump( fieldDescr, true );
+
+ assertEquals( expected, result );
+ }
+
private DRLParser parse(final String text) throws Exception {
return newParser( newTokenStream( newLexer( newCharStream( text ) ) ) );
}
Modified: labs/jbossrules/branches/temporal_rete/drools-compiler/src/test/java/org/drools/rule/builder/dialect/java/JavaAccumulateBuilderTest.java
===================================================================
--- labs/jbossrules/branches/temporal_rete/drools-compiler/src/test/java/org/drools/rule/builder/dialect/java/JavaAccumulateBuilderTest.java 2008-03-20 18:57:07 UTC (rev 19163)
+++ labs/jbossrules/branches/temporal_rete/drools-compiler/src/test/java/org/drools/rule/builder/dialect/java/JavaAccumulateBuilderTest.java 2008-03-20 19:32:10 UTC (rev 19164)
@@ -5,7 +5,6 @@
import junit.framework.TestCase;
import org.drools.compiler.Dialect;
-import org.drools.compiler.DialectRegistry;
import org.drools.compiler.PackageBuilder;
import org.drools.compiler.PackageBuilderConfiguration;
import org.drools.lang.descr.AccumulateDescr;
Modified: labs/jbossrules/branches/temporal_rete/drools-compiler/src/test/java/org/drools/rule/builder/dialect/java/JavaActionBuilderTest.java
===================================================================
--- labs/jbossrules/branches/temporal_rete/drools-compiler/src/test/java/org/drools/rule/builder/dialect/java/JavaActionBuilderTest.java 2008-03-20 18:57:07 UTC (rev 19163)
+++ labs/jbossrules/branches/temporal_rete/drools-compiler/src/test/java/org/drools/rule/builder/dialect/java/JavaActionBuilderTest.java 2008-03-20 19:32:10 UTC (rev 19164)
@@ -1,54 +1,23 @@
package org.drools.rule.builder.dialect.java;
-import java.io.InputStreamReader;
-import java.io.Serializable;
import java.io.StringReader;
import java.util.ArrayList;
-import java.util.HashMap;
import java.util.List;
-import java.util.Map;
-import java.util.Properties;
-import junit.framework.Assert;
import junit.framework.TestCase;
-import org.drools.Cheese;
import org.drools.RuleBase;
import org.drools.RuleBaseFactory;
import org.drools.WorkingMemory;
-import org.drools.base.ClassObjectType;
-import org.drools.base.DefaultKnowledgeHelper;
-import org.drools.base.mvel.MVELConsequence;
-import org.drools.base.mvel.MVELDebugHandler;
-import org.drools.common.AgendaItem;
-import org.drools.common.InternalFactHandle;
-import org.drools.common.PropagationContextImpl;
-import org.drools.compiler.Dialect;
-import org.drools.compiler.DialectConfiguration;
-import org.drools.compiler.DrlParser;
-import org.drools.compiler.DroolsParserException;
import org.drools.compiler.PackageBuilder;
import org.drools.compiler.PackageBuilderConfiguration;
import org.drools.lang.descr.ActionDescr;
-import org.drools.lang.descr.PackageDescr;
import org.drools.lang.descr.ProcessDescr;
-import org.drools.lang.descr.RuleDescr;
-import org.drools.reteoo.ReteTuple;
-import org.drools.rule.Declaration;
import org.drools.rule.Package;
-import org.drools.rule.Pattern;
-import org.drools.rule.Rule;
-import org.drools.rule.builder.PackageBuildContext;
import org.drools.rule.builder.ProcessBuildContext;
-import org.drools.rule.builder.RuleBuildContext;
-import org.drools.rule.builder.RuleBuilder;
import org.drools.spi.Action;
-import org.drools.spi.ObjectType;
-import org.drools.spi.PatternExtractor;
import org.drools.workflow.core.impl.WorkflowProcessImpl;
import org.drools.workflow.core.node.ActionNode;
-import org.mvel.compiler.ExpressionCompiler;
-import org.mvel.ParserContext;
public class JavaActionBuilderTest extends TestCase {
Modified: labs/jbossrules/branches/temporal_rete/drools-compiler/src/test/java/org/drools/rule/builder/dialect/java/JavaConsequenceBuilderTest.java
===================================================================
--- labs/jbossrules/branches/temporal_rete/drools-compiler/src/test/java/org/drools/rule/builder/dialect/java/JavaConsequenceBuilderTest.java 2008-03-20 18:57:07 UTC (rev 19163)
+++ labs/jbossrules/branches/temporal_rete/drools-compiler/src/test/java/org/drools/rule/builder/dialect/java/JavaConsequenceBuilderTest.java 2008-03-20 19:32:10 UTC (rev 19164)
@@ -2,23 +2,20 @@
import java.util.Set;
+import junit.framework.TestCase;
+
import org.antlr.runtime.RecognitionException;
import org.drools.Cheese;
import org.drools.base.ClassObjectType;
-import org.drools.compiler.Dialect;
-import org.drools.compiler.DialectRegistry;
import org.drools.compiler.PackageBuilder;
import org.drools.compiler.PackageBuilderConfiguration;
import org.drools.lang.descr.RuleDescr;
-import org.drools.rule.builder.PackageBuildContext;
-import org.drools.rule.builder.RuleBuildContext;
import org.drools.rule.ImportDeclaration;
import org.drools.rule.Package;
import org.drools.rule.Pattern;
import org.drools.rule.Rule;
+import org.drools.rule.builder.RuleBuildContext;
-import junit.framework.TestCase;
-
public class JavaConsequenceBuilderTest extends TestCase {
private JavaConsequenceBuilder builder;
Modified: labs/jbossrules/branches/temporal_rete/drools-compiler/src/test/java/org/drools/rule/builder/dialect/java/JavaExprAnalyzerTest.java
===================================================================
--- labs/jbossrules/branches/temporal_rete/drools-compiler/src/test/java/org/drools/rule/builder/dialect/java/JavaExprAnalyzerTest.java 2008-03-20 18:57:07 UTC (rev 19163)
+++ labs/jbossrules/branches/temporal_rete/drools-compiler/src/test/java/org/drools/rule/builder/dialect/java/JavaExprAnalyzerTest.java 2008-03-20 19:32:10 UTC (rev 19164)
@@ -17,7 +17,6 @@
*/
package org.drools.rule.builder.dialect.java;
-import java.util.Iterator;
import java.util.List;
import java.util.Set;
Modified: labs/jbossrules/branches/temporal_rete/drools-compiler/src/test/java/org/drools/rule/builder/dialect/java/RuleBuilderTest.java
===================================================================
--- labs/jbossrules/branches/temporal_rete/drools-compiler/src/test/java/org/drools/rule/builder/dialect/java/RuleBuilderTest.java 2008-03-20 18:57:07 UTC (rev 19163)
+++ labs/jbossrules/branches/temporal_rete/drools-compiler/src/test/java/org/drools/rule/builder/dialect/java/RuleBuilderTest.java 2008-03-20 19:32:10 UTC (rev 19164)
@@ -29,7 +29,6 @@
import org.drools.base.ClassTypeResolver;
import org.drools.base.TypeResolver;
import org.drools.compiler.Dialect;
-import org.drools.compiler.DialectRegistry;
import org.drools.compiler.DrlParser;
import org.drools.compiler.PackageBuilder;
import org.drools.compiler.PackageBuilderConfiguration;
Modified: labs/jbossrules/branches/temporal_rete/drools-compiler/src/test/java/org/drools/rule/builder/dialect/mvel/MVELActionBuilderTest.java
===================================================================
--- labs/jbossrules/branches/temporal_rete/drools-compiler/src/test/java/org/drools/rule/builder/dialect/mvel/MVELActionBuilderTest.java 2008-03-20 18:57:07 UTC (rev 19163)
+++ labs/jbossrules/branches/temporal_rete/drools-compiler/src/test/java/org/drools/rule/builder/dialect/mvel/MVELActionBuilderTest.java 2008-03-20 19:32:10 UTC (rev 19164)
@@ -1,51 +1,21 @@
package org.drools.rule.builder.dialect.mvel;
-import java.io.InputStreamReader;
-import java.io.Serializable;
import java.io.StringReader;
import java.util.ArrayList;
-import java.util.HashMap;
import java.util.List;
-import java.util.Map;
-import java.util.Properties;
-import junit.framework.Assert;
import junit.framework.TestCase;
-import org.drools.Cheese;
import org.drools.RuleBase;
import org.drools.RuleBaseFactory;
import org.drools.WorkingMemory;
-import org.drools.base.ClassObjectType;
-import org.drools.base.DefaultKnowledgeHelper;
-import org.drools.base.mvel.MVELConsequence;
-import org.drools.base.mvel.MVELDebugHandler;
-import org.drools.common.AgendaItem;
-import org.drools.common.InternalFactHandle;
-import org.drools.common.PropagationContextImpl;
-import org.drools.compiler.Dialect;
-import org.drools.compiler.DialectConfiguration;
-import org.drools.compiler.DrlParser;
-import org.drools.compiler.DroolsParserException;
import org.drools.compiler.PackageBuilder;
import org.drools.compiler.PackageBuilderConfiguration;
import org.drools.lang.descr.ActionDescr;
-import org.drools.lang.descr.PackageDescr;
-import org.drools.lang.descr.RuleDescr;
-import org.drools.reteoo.ReteTuple;
-import org.drools.rule.Declaration;
import org.drools.rule.Package;
-import org.drools.rule.Pattern;
-import org.drools.rule.Rule;
import org.drools.rule.builder.PackageBuildContext;
-import org.drools.rule.builder.RuleBuildContext;
-import org.drools.rule.builder.RuleBuilder;
import org.drools.spi.Action;
-import org.drools.spi.ObjectType;
-import org.drools.spi.PatternExtractor;
import org.drools.workflow.core.node.ActionNode;
-import org.mvel.compiler.ExpressionCompiler;
-import org.mvel.ParserContext;
public class MVELActionBuilderTest extends TestCase {
Modified: labs/jbossrules/branches/temporal_rete/drools-compiler/src/test/java/org/drools/rule/builder/dialect/mvel/MVELConsequenceBuilderTest.java
===================================================================
--- labs/jbossrules/branches/temporal_rete/drools-compiler/src/test/java/org/drools/rule/builder/dialect/mvel/MVELConsequenceBuilderTest.java 2008-03-20 18:57:07 UTC (rev 19163)
+++ labs/jbossrules/branches/temporal_rete/drools-compiler/src/test/java/org/drools/rule/builder/dialect/mvel/MVELConsequenceBuilderTest.java 2008-03-20 19:32:10 UTC (rev 19164)
@@ -21,12 +21,10 @@
import org.drools.common.InternalFactHandle;
import org.drools.common.PropagationContextImpl;
import org.drools.compiler.Dialect;
-import org.drools.compiler.DialectConfiguration;
import org.drools.compiler.DrlParser;
import org.drools.compiler.DroolsParserException;
import org.drools.compiler.PackageBuilder;
import org.drools.compiler.PackageBuilderConfiguration;
-import org.drools.lang.descr.ActionDescr;
import org.drools.lang.descr.PackageDescr;
import org.drools.lang.descr.RuleDescr;
import org.drools.reteoo.ReteTuple;
@@ -38,8 +36,8 @@
import org.drools.rule.builder.RuleBuilder;
import org.drools.spi.ObjectType;
import org.drools.spi.PatternExtractor;
-import org.mvel.compiler.ExpressionCompiler;
import org.mvel.ParserContext;
+import org.mvel.compiler.ExpressionCompiler;
public class MVELConsequenceBuilderTest extends TestCase {
Modified: labs/jbossrules/branches/temporal_rete/drools-compiler/src/test/java/org/drools/rule/builder/dialect/mvel/MVELDecisionBuilderTest.java
===================================================================
--- labs/jbossrules/branches/temporal_rete/drools-compiler/src/test/java/org/drools/rule/builder/dialect/mvel/MVELDecisionBuilderTest.java 2008-03-20 18:57:07 UTC (rev 19163)
+++ labs/jbossrules/branches/temporal_rete/drools-compiler/src/test/java/org/drools/rule/builder/dialect/mvel/MVELDecisionBuilderTest.java 2008-03-20 19:32:10 UTC (rev 19164)
@@ -1,51 +1,21 @@
package org.drools.rule.builder.dialect.mvel;
-import java.io.InputStreamReader;
-import java.io.Serializable;
import java.io.StringReader;
import java.util.ArrayList;
-import java.util.HashMap;
import java.util.List;
-import java.util.Map;
-import java.util.Properties;
-import junit.framework.Assert;
import junit.framework.TestCase;
-import org.drools.Cheese;
import org.drools.RuleBase;
import org.drools.RuleBaseFactory;
import org.drools.WorkingMemory;
-import org.drools.base.ClassObjectType;
-import org.drools.base.DefaultKnowledgeHelper;
-import org.drools.base.mvel.MVELConsequence;
-import org.drools.base.mvel.MVELDebugHandler;
-import org.drools.common.AgendaItem;
-import org.drools.common.InternalFactHandle;
-import org.drools.common.PropagationContextImpl;
-import org.drools.compiler.Dialect;
-import org.drools.compiler.DialectConfiguration;
-import org.drools.compiler.DrlParser;
-import org.drools.compiler.DroolsParserException;
import org.drools.compiler.PackageBuilder;
import org.drools.compiler.PackageBuilderConfiguration;
import org.drools.lang.descr.ActionDescr;
-import org.drools.lang.descr.PackageDescr;
-import org.drools.lang.descr.RuleDescr;
-import org.drools.reteoo.ReteTuple;
-import org.drools.rule.Declaration;
import org.drools.rule.Package;
-import org.drools.rule.Pattern;
-import org.drools.rule.Rule;
import org.drools.rule.builder.PackageBuildContext;
-import org.drools.rule.builder.RuleBuildContext;
-import org.drools.rule.builder.RuleBuilder;
import org.drools.spi.Action;
-import org.drools.spi.ObjectType;
-import org.drools.spi.PatternExtractor;
import org.drools.workflow.core.node.ActionNode;
-import org.mvel.compiler.ExpressionCompiler;
-import org.mvel.ParserContext;
public class MVELDecisionBuilderTest extends TestCase {
Modified: labs/jbossrules/branches/temporal_rete/drools-compiler/src/test/java/org/drools/rule/builder/dialect/mvel/MVELEvalBuilderTest.java
===================================================================
--- labs/jbossrules/branches/temporal_rete/drools-compiler/src/test/java/org/drools/rule/builder/dialect/mvel/MVELEvalBuilderTest.java 2008-03-20 18:57:07 UTC (rev 19163)
+++ labs/jbossrules/branches/temporal_rete/drools-compiler/src/test/java/org/drools/rule/builder/dialect/mvel/MVELEvalBuilderTest.java 2008-03-20 19:32:10 UTC (rev 19164)
@@ -12,7 +12,6 @@
import org.drools.base.ClassFieldExtractorCache;
import org.drools.base.ClassObjectType;
import org.drools.common.InternalFactHandle;
-import org.drools.compiler.DialectConfiguration;
import org.drools.compiler.PackageBuilder;
import org.drools.compiler.PackageBuilderConfiguration;
import org.drools.lang.descr.EvalDescr;
Modified: labs/jbossrules/branches/temporal_rete/drools-compiler/src/test/java/org/drools/rule/builder/dialect/mvel/MVELSalienceBuilderTest.java
===================================================================
--- labs/jbossrules/branches/temporal_rete/drools-compiler/src/test/java/org/drools/rule/builder/dialect/mvel/MVELSalienceBuilderTest.java 2008-03-20 18:57:07 UTC (rev 19163)
+++ labs/jbossrules/branches/temporal_rete/drools-compiler/src/test/java/org/drools/rule/builder/dialect/mvel/MVELSalienceBuilderTest.java 2008-03-20 19:32:10 UTC (rev 19164)
@@ -11,8 +11,6 @@
import org.drools.WorkingMemory;
import org.drools.base.ClassObjectType;
import org.drools.common.InternalFactHandle;
-import org.drools.compiler.DialectConfiguration;
-import org.drools.compiler.DialectRegistry;
import org.drools.compiler.PackageBuilder;
import org.drools.compiler.PackageBuilderConfiguration;
import org.drools.lang.descr.RuleDescr;
Modified: labs/jbossrules/branches/temporal_rete/drools-compiler/src/test/java/org/drools/testframework/FactPopulatorTest.java
===================================================================
--- labs/jbossrules/branches/temporal_rete/drools-compiler/src/test/java/org/drools/testframework/FactPopulatorTest.java 2008-03-20 18:57:07 UTC (rev 19163)
+++ labs/jbossrules/branches/temporal_rete/drools-compiler/src/test/java/org/drools/testframework/FactPopulatorTest.java 2008-03-20 19:32:10 UTC (rev 19164)
@@ -1,17 +1,12 @@
package org.drools.testframework;
-import java.io.Serializable;
-import java.util.ArrayList;
import java.util.HashMap;
-import java.util.List;
import java.util.Map;
-import org.mvel.compiler.ExpressionCompiler;
-import org.mvel.MVEL;
-import org.mvel.ParserContext;
-
import junit.framework.TestCase;
+import org.mvel.MVEL;
+
public class FactPopulatorTest extends TestCase {
public void testMVELPopulate() throws Exception {
Modified: labs/jbossrules/branches/temporal_rete/drools-compiler/src/test/java/org/drools/testframework/MockFactHandle.java
===================================================================
--- labs/jbossrules/branches/temporal_rete/drools-compiler/src/test/java/org/drools/testframework/MockFactHandle.java 2008-03-20 18:57:07 UTC (rev 19163)
+++ labs/jbossrules/branches/temporal_rete/drools-compiler/src/test/java/org/drools/testframework/MockFactHandle.java 2008-03-20 19:32:10 UTC (rev 19164)
@@ -2,22 +2,25 @@
import org.drools.FactHandle;
+import java.io.IOException;
+import java.io.ObjectInput;
+import java.io.ObjectOutput;
/*
- * Copyright 2005 JBoss Inc
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
+* Copyright 2005 JBoss Inc
+*
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
public class MockFactHandle
implements
@@ -28,10 +31,23 @@
private static final long serialVersionUID = 400L;
private int id;
+ public MockFactHandle() {
+
+ }
+
public MockFactHandle(final int id) {
this.id = id;
}
+ public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
+ id = in.readInt();
+ }
+
+ public void writeExternal(ObjectOutput out) throws IOException {
+ out.writeInt(id);
+ }
+
+
public String toExternalForm() {
return "[fact:" + this.id + "]";
}
Modified: labs/jbossrules/branches/temporal_rete/drools-compiler/src/test/java/org/drools/testframework/MockRuleBase.java
===================================================================
--- labs/jbossrules/branches/temporal_rete/drools-compiler/src/test/java/org/drools/testframework/MockRuleBase.java 2008-03-20 18:57:07 UTC (rev 19163)
+++ labs/jbossrules/branches/temporal_rete/drools-compiler/src/test/java/org/drools/testframework/MockRuleBase.java 2008-03-20 19:32:10 UTC (rev 19164)
@@ -2,6 +2,8 @@
import java.io.IOException;
import java.io.InputStream;
+import java.io.ObjectOutput;
+import java.io.ObjectInput;
import java.util.List;
import org.drools.ClockType;
@@ -124,7 +126,14 @@
public void addPackage(Package pkg) {
// TODO Auto-generated method stub
-
+
}
+ public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
+
+ }
+
+ public void writeExternal(ObjectOutput out) throws IOException {
+
+ }
}
Modified: labs/jbossrules/branches/temporal_rete/drools-compiler/src/test/java/org/drools/testframework/MockWorkingMemory.java
===================================================================
--- labs/jbossrules/branches/temporal_rete/drools-compiler/src/test/java/org/drools/testframework/MockWorkingMemory.java 2008-03-20 18:57:07 UTC (rev 19163)
+++ labs/jbossrules/branches/temporal_rete/drools-compiler/src/test/java/org/drools/testframework/MockWorkingMemory.java 2008-03-20 19:32:10 UTC (rev 19164)
@@ -7,6 +7,9 @@
import java.util.List;
import java.util.Map;
import java.util.concurrent.locks.Lock;
+import java.io.IOException;
+import java.io.ObjectInput;
+import java.io.ObjectOutput;
import org.drools.Agenda;
import org.drools.WorkingMemoryEntryPoint;
@@ -53,7 +56,21 @@
TimeMachine timeMachine = new TimeMachine();
Map<String, Object> globals = new HashMap<String, Object>();
- public void addLIANodePropagation(LIANodePropagation liaNodePropagation) {
+ public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
+ facts = (List<Object>)in.readObject();
+ agendaEventListener = (AgendaEventListener)in.readObject();
+ timeMachine = (TimeMachine)in.readObject();
+ globals = (Map<String, Object>)in.readObject();
+ }
+
+ public void writeExternal(ObjectOutput out) throws IOException {
+ out.writeObject(facts);
+ out.writeObject(agendaEventListener);
+ out.writeObject(timeMachine);
+ out.writeObject(globals);
+ }
+
+ public void addLIANodePropagation(LIANodePropagation liaNodePropagation) {
// TODO Auto-generated method stub
}
@@ -248,7 +265,7 @@
this.facts .add(object);
return new MockFactHandle(object.hashCode());
}
-
+
public FactHandle insert(Object object, long duration)
throws FactException {
// TODO Auto-generated method stub
@@ -260,7 +277,7 @@
// TODO Auto-generated method stub
return null;
}
-
+
public FactHandle insert(Object object, long duration, boolean dynamic)
throws FactException {
// TODO Auto-generated method stub
@@ -409,17 +426,17 @@
public void setId(long id) {
// TODO Auto-generated method stub
-
+
}
public void setRuleBase(InternalRuleBase ruleBase) {
// TODO Auto-generated method stub
-
+
}
public void removeProcessInstance(ProcessInstance processInstance) {
// TODO Auto-generated method stub
-
+
}
public ProcessInstance getProcessInstance(long id) {
@@ -471,7 +488,7 @@
public void registerProcessInstanceFactory(String type,
ProcessInstanceFactory nodeInstanceFactory) {
// TODO Auto-generated method stub
-
+
}
public ObjectStore getObjectStore() {
@@ -486,7 +503,7 @@
public void setExecutorService(ExecutorService executor) {
// TODO Auto-generated method stub
-
+
}
}
Modified: labs/jbossrules/branches/temporal_rete/drools-compiler/src/test/java/org/drools/testframework/ScenarioTest.java
===================================================================
--- labs/jbossrules/branches/temporal_rete/drools-compiler/src/test/java/org/drools/testframework/ScenarioTest.java 2008-03-20 18:57:07 UTC (rev 19163)
+++ labs/jbossrules/branches/temporal_rete/drools-compiler/src/test/java/org/drools/testframework/ScenarioTest.java 2008-03-20 19:32:10 UTC (rev 19164)
@@ -4,17 +4,16 @@
import java.util.List;
import java.util.Map;
+import junit.framework.TestCase;
+
import org.drools.brms.client.modeldriven.testing.ExecutionTrace;
import org.drools.brms.client.modeldriven.testing.FactData;
-import org.drools.brms.client.modeldriven.testing.FieldData;
import org.drools.brms.client.modeldriven.testing.RetractFact;
import org.drools.brms.client.modeldriven.testing.Scenario;
import org.drools.brms.client.modeldriven.testing.VerifyFact;
import org.drools.brms.client.modeldriven.testing.VerifyField;
import org.drools.brms.client.modeldriven.testing.VerifyRuleFired;
-import junit.framework.TestCase;
-
public class ScenarioTest extends TestCase {
public void testInsertAfter() {
Modified: labs/jbossrules/branches/temporal_rete/drools-compiler/src/test/java/org/drools/testframework/TestingEventListenerTest.java
===================================================================
--- labs/jbossrules/branches/temporal_rete/drools-compiler/src/test/java/org/drools/testframework/TestingEventListenerTest.java 2008-03-20 18:57:07 UTC (rev 19163)
+++ labs/jbossrules/branches/temporal_rete/drools-compiler/src/test/java/org/drools/testframework/TestingEventListenerTest.java 2008-03-20 19:32:10 UTC (rev 19164)
@@ -1,17 +1,11 @@
package org.drools.testframework;
-import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
import org.drools.Cheese;
-import org.drools.RuleBase;
-import org.drools.RuleBaseFactory;
import org.drools.StatefulSession;
-import org.drools.compiler.PackageBuilder;
-import org.drools.spi.Activation;
-import org.drools.spi.AgendaFilter;
public class TestingEventListenerTest extends RuleUnit {
Modified: labs/jbossrules/branches/temporal_rete/drools-compiler/src/test/java/org/drools/xml/processes/ActionNodeTest.java
===================================================================
--- labs/jbossrules/branches/temporal_rete/drools-compiler/src/test/java/org/drools/xml/processes/ActionNodeTest.java 2008-03-20 18:57:07 UTC (rev 19163)
+++ labs/jbossrules/branches/temporal_rete/drools-compiler/src/test/java/org/drools/xml/processes/ActionNodeTest.java 2008-03-20 19:32:10 UTC (rev 19164)
@@ -10,8 +10,6 @@
import org.drools.RuleBaseFactory;
import org.drools.StatefulSession;
import org.drools.compiler.PackageBuilder;
-import org.drools.process.core.Process;
-import org.drools.xml.XmlProcessReader;
public class ActionNodeTest extends TestCase {
public void testSingleActionNode() throws Exception {
Modified: labs/jbossrules/branches/temporal_rete/drools-compiler/src/test/java/org/drools/xml/rules/DumperTestHelper.java
===================================================================
--- labs/jbossrules/branches/temporal_rete/drools-compiler/src/test/java/org/drools/xml/rules/DumperTestHelper.java 2008-03-20 18:57:07 UTC (rev 19163)
+++ labs/jbossrules/branches/temporal_rete/drools-compiler/src/test/java/org/drools/xml/rules/DumperTestHelper.java 2008-03-20 19:32:10 UTC (rev 19164)
@@ -5,7 +5,6 @@
import java.io.IOException;
import java.io.InputStreamReader;
-import java.io.StringReader;
import junit.framework.Assert;
@@ -13,7 +12,6 @@
import org.drools.compiler.PackageBuilderConfiguration;
import org.drools.lang.DrlDumper;
import org.drools.lang.descr.PackageDescr;
-import org.drools.xml.SemanticModules;
import org.drools.xml.XmlDumper;
import org.drools.xml.XmlPackageReader;
Modified: labs/jbossrules/branches/temporal_rete/drools-compiler/src/test/java/org/drools/xml/rules/XmlPackageReaderTest.java
===================================================================
--- labs/jbossrules/branches/temporal_rete/drools-compiler/src/test/java/org/drools/xml/rules/XmlPackageReaderTest.java 2008-03-20 18:57:07 UTC (rev 19163)
+++ labs/jbossrules/branches/temporal_rete/drools-compiler/src/test/java/org/drools/xml/rules/XmlPackageReaderTest.java 2008-03-20 19:32:10 UTC (rev 19164)
@@ -13,7 +13,6 @@
import org.drools.lang.descr.AccumulateDescr;
import org.drools.lang.descr.AndDescr;
import org.drools.lang.descr.AttributeDescr;
-import org.drools.lang.descr.BaseDescr;
import org.drools.lang.descr.CollectDescr;
import org.drools.lang.descr.EvalDescr;
import org.drools.lang.descr.ExistsDescr;
@@ -35,7 +34,6 @@
import org.drools.lang.descr.ReturnValueRestrictionDescr;
import org.drools.lang.descr.RuleDescr;
import org.drools.lang.descr.VariableRestrictionDescr;
-import org.drools.xml.SemanticModules;
import org.drools.xml.XmlPackageReader;
public class XmlPackageReaderTest extends TestCase {
Copied: labs/jbossrules/branches/temporal_rete/drools-compiler/src/test/resources/billasurf.jar (from rev 19160, labs/jbossrules/dev_tags/before_righttuple_merge_20080320/drools-compiler/src/test/resources/billasurf.jar)
===================================================================
(Binary files differ)
Copied: labs/jbossrules/branches/temporal_rete/drools-compiler/src/test/resources/org/drools/integrationtests/big_decimal_and_literal.drl (from rev 19160, labs/jbossrules/dev_tags/before_righttuple_merge_20080320/drools-compiler/src/test/resources/org/drools/integrationtests/big_decimal_and_literal.drl)
===================================================================
--- labs/jbossrules/branches/temporal_rete/drools-compiler/src/test/resources/org/drools/integrationtests/big_decimal_and_literal.drl (rev 0)
+++ labs/jbossrules/branches/temporal_rete/drools-compiler/src/test/resources/org/drools/integrationtests/big_decimal_and_literal.drl 2008-03-20 19:32:10 UTC (rev 19164)
@@ -0,0 +1,59 @@
+package org.drools.test
+
+import org.drools.Person;
+import java.math.BigDecimal;
+
+global java.util.List list;
+
+rule "BigDec"
+
+ when
+ p: Person(bigDecimal < 100.01)
+ then
+ System.err.println("rule1");
+ list.add( p );
+end
+
+rule "BigInt"
+ when
+ p: Person(bigInteger < 100.1)
+ then
+ System.err.println("rule2");
+ list.add( p );
+end
+
+rule "BigDec2"
+
+ when
+ p: Person(bigDecimal == 42)
+ then
+ System.err.println("rule3");
+ list.add( p );
+end
+
+rule "BigInt2"
+ when
+ p: Person(bigInteger == 42)
+ then
+ System.err.println("rule4");
+ list.add( p );
+end
+
+rule "BigDec3"
+
+ when
+ p: Person(bigDecimal != 100)
+ then
+ System.err.println("rule5");
+ list.add( p );
+end
+
+rule "BigInt3"
+ when
+ p: Person(bigInteger != 100)
+ then
+ System.err.println("rule6");
+ list.add( p );
+end
+
+
Copied: labs/jbossrules/branches/temporal_rete/drools-compiler/src/test/resources/org/drools/integrationtests/test_Dynamic1_0.drl (from rev 19160, labs/jbossrules/dev_tags/before_righttuple_merge_20080320/drools-compiler/src/test/resources/org/drools/integrationtests/test_Dynamic1_0.drl)
===================================================================
--- labs/jbossrules/branches/temporal_rete/drools-compiler/src/test/resources/org/drools/integrationtests/test_Dynamic1_0.drl (rev 0)
+++ labs/jbossrules/branches/temporal_rete/drools-compiler/src/test/resources/org/drools/integrationtests/test_Dynamic1_0.drl 2008-03-20 19:32:10 UTC (rev 19164)
@@ -0,0 +1,13 @@
+package org.drools.test;
+
+import org.drools.Cheese;
+
+global java.util.List results
+
+rule "like stilton"
+ salience 50
+ when
+ $cheese :Cheese( type:type == "stilton" )
+ then
+ results.add( $cheese );
+end
Copied: labs/jbossrules/branches/temporal_rete/drools-compiler/src/test/resources/org/drools/integrationtests/test_Dynamic1_1.drl (from rev 19160, labs/jbossrules/dev_tags/before_righttuple_merge_20080320/drools-compiler/src/test/resources/org/drools/integrationtests/test_Dynamic1_1.drl)
===================================================================
--- labs/jbossrules/branches/temporal_rete/drools-compiler/src/test/resources/org/drools/integrationtests/test_Dynamic1_1.drl (rev 0)
+++ labs/jbossrules/branches/temporal_rete/drools-compiler/src/test/resources/org/drools/integrationtests/test_Dynamic1_1.drl 2008-03-20 19:32:10 UTC (rev 19164)
@@ -0,0 +1,13 @@
+package org.drools.test;
+
+import org.drools.Cheese;
+
+global java.util.List results;
+
+rule "like brie"
+ salience 20
+ when
+ $cheese : Cheese( type:type == "brie" )
+ then
+ results.add( $cheese );
+end
\ No newline at end of file
Copied: labs/jbossrules/branches/temporal_rete/drools-compiler/src/test/resources/org/drools/integrationtests/test_Dynamic1_2.drl (from rev 19160, labs/jbossrules/dev_tags/before_righttuple_merge_20080320/drools-compiler/src/test/resources/org/drools/integrationtests/test_Dynamic1_2.drl)
===================================================================
--- labs/jbossrules/branches/temporal_rete/drools-compiler/src/test/resources/org/drools/integrationtests/test_Dynamic1_2.drl (rev 0)
+++ labs/jbossrules/branches/temporal_rete/drools-compiler/src/test/resources/org/drools/integrationtests/test_Dynamic1_2.drl 2008-03-20 19:32:10 UTC (rev 19164)
@@ -0,0 +1,13 @@
+package org.drools.test;
+
+import org.drools.Address;
+
+global java.util.List results;
+
+rule "match SerializeAddress"
+ salience 10
+ when
+ $address : Address()
+ then
+ results.add( $address );
+end
Copied: labs/jbossrules/branches/temporal_rete/drools-compiler/src/test/resources/org/drools/integrationtests/test_Dynamic3_0.drl (from rev 19160, labs/jbossrules/dev_tags/before_righttuple_merge_20080320/drools-compiler/src/test/resources/org/drools/integrationtests/test_Dynamic3_0.drl)
===================================================================
--- labs/jbossrules/branches/temporal_rete/drools-compiler/src/test/resources/org/drools/integrationtests/test_Dynamic3_0.drl (rev 0)
+++ labs/jbossrules/branches/temporal_rete/drools-compiler/src/test/resources/org/drools/integrationtests/test_Dynamic3_0.drl 2008-03-20 19:32:10 UTC (rev 19164)
@@ -0,0 +1,13 @@
+package org.drools.newtest;
+
+import org.drools.Person;
+
+global java.util.List results
+
+rule "match Person"
+ salience 30
+ when
+ $person : Person()
+ then
+ results.add( $person );
+end
\ No newline at end of file
Copied: labs/jbossrules/branches/temporal_rete/drools-compiler/src/test/resources/org/drools/integrationtests/test_FromArrayIteration.drl (from rev 19160, labs/jbossrules/dev_tags/before_righttuple_merge_20080320/drools-compiler/src/test/resources/org/drools/integrationtests/test_FromArrayIteration.drl)
===================================================================
--- labs/jbossrules/branches/temporal_rete/drools-compiler/src/test/resources/org/drools/integrationtests/test_FromArrayIteration.drl (rev 0)
+++ labs/jbossrules/branches/temporal_rete/drools-compiler/src/test/resources/org/drools/integrationtests/test_FromArrayIteration.drl 2008-03-20 19:32:10 UTC (rev 19164)
@@ -0,0 +1,14 @@
+package org.drools.test;
+
+import org.drools.DomainObject
+import org.drools.DomainObjectHolder;
+
+global java.util.List list
+
+rule "Test Rule"
+when
+ $holder : DomainObjectHolder()
+ $object : DomainObject( $message : message) from $holder.objects;
+then
+ list.add( $message );
+end
\ No newline at end of file
Copied: labs/jbossrules/branches/temporal_rete/drools-compiler/src/test/resources/org/drools/integrationtests/test_MatchesMVEL.drl (from rev 19160, labs/jbossrules/dev_tags/before_righttuple_merge_20080320/drools-compiler/src/test/resources/org/drools/integrationtests/test_MatchesMVEL.drl)
===================================================================
--- labs/jbossrules/branches/temporal_rete/drools-compiler/src/test/resources/org/drools/integrationtests/test_MatchesMVEL.drl (rev 0)
+++ labs/jbossrules/branches/temporal_rete/drools-compiler/src/test/resources/org/drools/integrationtests/test_MatchesMVEL.drl 2008-03-20 19:32:10 UTC (rev 19164)
@@ -0,0 +1,12 @@
+package org.drools;
+
+import java.util.Map;
+
+global java.util.List results;
+
+rule "Matches mvel"
+when
+ Map( this["content"] matches "hello ;=" )
+then
+ results.add( "OK" );
+end
\ No newline at end of file
Copied: labs/jbossrules/branches/temporal_rete/drools-compiler/src/test/resources/org/drools/integrationtests/test_MergePackageWithSameRuleNames1.drl (from rev 19160, labs/jbossrules/dev_tags/before_righttuple_merge_20080320/drools-compiler/src/test/resources/org/drools/integrationtests/test_MergePackageWithSameRuleNames1.drl)
===================================================================
--- labs/jbossrules/branches/temporal_rete/drools-compiler/src/test/resources/org/drools/integrationtests/test_MergePackageWithSameRuleNames1.drl (rev 0)
+++ labs/jbossrules/branches/temporal_rete/drools-compiler/src/test/resources/org/drools/integrationtests/test_MergePackageWithSameRuleNames1.drl 2008-03-20 19:32:10 UTC (rev 19164)
@@ -0,0 +1,10 @@
+package org.drools.test
+
+global java.util.List results;
+
+rule "rule1"
+ when
+
+ then
+ results.add("rule1 for the package1");
+end
\ No newline at end of file
Copied: labs/jbossrules/branches/temporal_rete/drools-compiler/src/test/resources/org/drools/integrationtests/test_MergePackageWithSameRuleNames2.drl (from rev 19160, labs/jbossrules/dev_tags/before_righttuple_merge_20080320/drools-compiler/src/test/resources/org/drools/integrationtests/test_MergePackageWithSameRuleNames2.drl)
===================================================================
--- labs/jbossrules/branches/temporal_rete/drools-compiler/src/test/resources/org/drools/integrationtests/test_MergePackageWithSameRuleNames2.drl (rev 0)
+++ labs/jbossrules/branches/temporal_rete/drools-compiler/src/test/resources/org/drools/integrationtests/test_MergePackageWithSameRuleNames2.drl 2008-03-20 19:32:10 UTC (rev 19164)
@@ -0,0 +1,10 @@
+package org.drools.test
+
+global java.util.List results;
+
+rule "rule1"
+ when
+
+ then
+ results.add("rule1 for the package2");
+end
\ No newline at end of file
Copied: labs/jbossrules/branches/temporal_rete/drools-compiler/src/test/resources/org/drools/integrationtests/test_ModifyBlock.drl (from rev 19160, labs/jbossrules/dev_tags/before_righttuple_merge_20080320/drools-compiler/src/test/resources/org/drools/integrationtests/test_ModifyBlock.drl)
===================================================================
--- labs/jbossrules/branches/temporal_rete/drools-compiler/src/test/resources/org/drools/integrationtests/test_ModifyBlock.drl (rev 0)
+++ labs/jbossrules/branches/temporal_rete/drools-compiler/src/test/resources/org/drools/integrationtests/test_ModifyBlock.drl 2008-03-20 19:32:10 UTC (rev 19164)
@@ -0,0 +1,12 @@
+package org.drools;
+
+global java.util.List results;
+
+rule "test modify block"
+when
+ $p: Person( status == "hungry" )
+ $c: Cheese( )
+then
+ modify( $c ) {setPrice (10) }
+ modify( $p ) {setStatus("fine") }
+end
\ No newline at end of file
Modified: labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/FactHandle.java
===================================================================
--- labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/FactHandle.java 2008-03-20 18:57:07 UTC (rev 19163)
+++ labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/FactHandle.java 2008-03-20 19:32:10 UTC (rev 19164)
@@ -2,13 +2,13 @@
/*
* Copyright 2005 JBoss Inc
- *
+ *
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -24,15 +24,15 @@
* @author <a href="mailto:bob at werken.com">bob mcwhirter </a>
*/
-import java.io.Serializable;
+import java.io.Externalizable;
public interface FactHandle
extends
- Serializable {
+ Externalizable {
/**
* Convert this handle to an external representation.
- *
+ *
* @return The external string form.
*/
String toExternalForm();
Modified: labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/InitialFact.java
===================================================================
--- labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/InitialFact.java 2008-03-20 18:57:07 UTC (rev 19163)
+++ labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/InitialFact.java 2008-03-20 19:32:10 UTC (rev 19164)
@@ -1,16 +1,17 @@
package org.drools;
import java.io.Serializable;
+import java.io.Externalizable;
/*
* Copyright 2005 JBoss Inc
- *
+ *
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
Modified: labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/RuleBase.java
===================================================================
--- labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/RuleBase.java 2008-03-20 18:57:07 UTC (rev 19163)
+++ labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/RuleBase.java 2008-03-20 19:32:10 UTC (rev 19164)
@@ -2,13 +2,13 @@
/*
* Copyright 2005 JBoss Inc
- *
+ *
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -18,24 +18,24 @@
import java.io.IOException;
import java.io.InputStream;
-import java.io.Serializable;
+import java.io.Externalizable;
import org.drools.rule.Package;
/**
* Active collection of <code>Rule</code>s.
- *
+ *
* <p>
* From a <code>RuleBase</code> many <code>WorkingMemory</code> rule
* sessions may be instantiated. Additionally, it may be inspected to determine
* which <code>Package</code> s it contains.
* </p>
- *
+ *
* @see WorkingMemory
*/
public interface RuleBase
extends
- Serializable,
+ Externalizable,
RuleBaseEventManager {
public static final int RETEOO = 1;
@@ -46,15 +46,15 @@
* Create a new <code>WorkingMemory</code> session for this
* <code>RuleBase</code>. By default the RuleBase retains a
* weak reference to returned WorkingMemory.
- *
+ *
* <p>
* The created <code>WorkingMemory</code> uses the default conflict
* resolution strategy.
* </p>
- *
+ *
* @see WorkingMemory
* @see org.drools.conflict.DefaultConflictResolver
- *
+ *
* @return A newly initialized <code>WorkingMemory</code>.
*/
StatefulSession newStatefulSession();
@@ -63,15 +63,15 @@
* Create a new <code>WorkingMemory</code> session for this
* <code>RuleBase</code>. Optionally the RuleBase retains a
* weak reference to returned WorkingMemory.
- *
+ *
* <p>
* The created <code>WorkingMemory</code> uses the default conflict
* resolution strategy.
* </p>
- *
+ *
* @see WorkingMemory
* @see org.drools.conflict.DefaultConflictResolver
- *
+ *
* @return A newly initialized <code>WorkingMemory</code>.
*/
StatefulSession newStatefulSession(boolean keepReference);
@@ -81,23 +81,23 @@
* pass as an InputStream. If the reference is a byte[] then
* wrap with new ByteArrayInputStream. By default the RuleBase retains a
* weak reference to returned WorkingMemory.
- *
+ *
* <p>
* The created <code>WorkingMemory</code> uses the default conflict
* resolution strategy.
* </p>
- *
+ *
* @see WorkingMemory
* @see org.drools.conflict.DefaultConflictResolver
- *
+ *
* @return A serialised initialized <code>WorkingMemory</code>.
*/
StatefulSession newStatefulSession(InputStream stream) throws IOException,
ClassNotFoundException;
-
+
/**
* Creates a new temporal session using the defined clock type.
- *
+ *
* @param clockType
* @return
*/
@@ -105,7 +105,7 @@
/**
* Creates a new temporal session using the defined clock type.
- *
+ *
* @param keepReference maintains a reference in the rulebase to the created session
* @param clockType
* @return
@@ -117,15 +117,15 @@
* pass as an InputStream. If the reference is a byte[] then
* wrap with new ByteArrayInputStream. Optionally the RuleBase retains a
* weak reference to returned WorkingMemory.
- *
+ *
* <p>
* The created <code>WorkingMemory</code> uses the default conflict
* resolution strategy.
* </p>
- *
+ *
* @see WorkingMemory
* @see org.drools.conflict.DefaultConflictResolver
- *
+ *
* @return A serialised initialized <code>WorkingMemory</code>.
*/
StatefulSession newStatefulSession(InputStream stream,
@@ -137,15 +137,15 @@
Package getPackage(String name);
void addPackage(Package pkg);
-
+
/**
- * This locks the current RuleBase and all there referenced StatefulSessions. This should be
+ * This locks the current RuleBase and all there referenced StatefulSessions. This should be
* used when there is a number of dynamic RuleBase changes you wish to make, but cannot have any normal
* WorkingMemory operations occuring inbetween.
*
*/
void lock();
-
+
/**
* Unlocks the RuleBase and all of the referenced StatefulSessions.
*
@@ -153,13 +153,13 @@
void unlock();
/**
- * Returns the number of additive operations applied since the last lock() was obtained
+ * Returns the number of additive operations applied since the last lock() was obtained
* @return
*/
int getAdditionsSinceLock();
/**
- * Returns the number of removal operations applied since the last lock() was obtained
+ * Returns the number of removal operations applied since the last lock() was obtained
* @return
*/
int getRemovalsSinceLock();
Modified: labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/RuleBaseConfiguration.java
===================================================================
--- labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/RuleBaseConfiguration.java 2008-03-20 18:57:07 UTC (rev 19163)
+++ labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/RuleBaseConfiguration.java 2008-03-20 19:32:10 UTC (rev 19164)
@@ -1,12 +1,12 @@
/*
* Copyright 2005 JBoss Inc
- *
+ *
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -16,7 +16,10 @@
package org.drools;
-import java.io.Serializable;
+import java.io.Externalizable;
+import java.io.IOException;
+import java.io.ObjectInput;
+import java.io.ObjectOutput;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
@@ -40,16 +43,16 @@
/**
* RuleBaseConfiguration
- *
+ *
* A class to store RuleBase related configuration. It must be used at rule base instantiation time
* or not used at all.
* This class will automatically load default values from system properties, so if you want to set
- * a default configuration value for all your new rule bases, you can simply set the property as
+ * a default configuration value for all your new rule bases, you can simply set the property as
* a System property.
- *
- * After RuleBase is created, it makes the configuration immutable and there is no way to make it
+ *
+ * After RuleBase is created, it makes the configuration immutable and there is no way to make it
* mutable again. This is to avoid inconsistent behavior inside rulebase.
- *
+ *
* NOTE: This API is under review and may change in the future.
*/
@@ -74,53 +77,109 @@
* drools.consequenceExceptionHandler = <qualified class name>
* drools.ruleBaseUpdateHandler = <qualified class name>
* drools.sessionClock = <qualified class name>
+ * drools.useStaticObjenesis = <false|true>
*
*/
public class RuleBaseConfiguration
implements
- Serializable {
- private static final long serialVersionUID = 400L;
+ Externalizable {
+ private static final long serialVersionUID = 400L;
- private ChainedProperties chainedProperties;
+ private ChainedProperties chainedProperties;
- private boolean immutable;
+ private boolean immutable;
- private boolean sequential;
- private SequentialAgenda sequentialAgenda;
+ private boolean sequential;
+ private SequentialAgenda sequentialAgenda;
- private boolean maintainTms;
- private boolean removeIdentities;
- private boolean shareAlphaNodes;
- private boolean shareBetaNodes;
- private boolean alphaMemory;
- private int alphaNodeHashingThreshold;
- private int compositeKeyDepth;
- private boolean indexLeftBetaMemory;
- private boolean indexRightBetaMemory;
- private AssertBehaviour assertBehaviour;
- private LogicalOverride logicalOverride;
- private String executorService;
- private ConsequenceExceptionHandler consequenceExceptionHandler;
- private String ruleBaseUpdateHandler;
- private Class< ? extends SessionClock> sessionClockClass;
+ private boolean maintainTms;
+ private boolean removeIdentities;
+ private boolean shareAlphaNodes;
+ private boolean shareBetaNodes;
+ private boolean alphaMemory;
+ private int alphaNodeHashingThreshold;
+ private int compositeKeyDepth;
+ private boolean indexLeftBetaMemory;
+ private boolean indexRightBetaMemory;
+ private AssertBehaviour assertBehaviour;
+ private LogicalOverride logicalOverride;
+ private String executorService;
+ private ConsequenceExceptionHandler consequenceExceptionHandler;
+ private String ruleBaseUpdateHandler;
+ private Class< ? extends SessionClock> sessionClockClass;
- private ConflictResolver conflictResolver;
+ private ConflictResolver conflictResolver;
- private boolean shadowProxy;
- private Map shadowProxyExcludes;
- private static final String STAR = "*";
+ private boolean shadowProxy;
+ private Map shadowProxyExcludes;
+ private boolean useStaticObjenesis;
- private NodeInstanceFactoryRegistry processNodeInstanceFactoryRegistry;
+ private static final String STAR = "*";
- private transient ClassLoader classLoader;
+ private NodeInstanceFactoryRegistry processNodeInstanceFactoryRegistry;
+ private transient ClassLoader classLoader;
+
+ public void writeExternal(ObjectOutput out) throws IOException {
+ out.writeObject( chainedProperties );
+ out.writeBoolean( immutable );
+ out.writeBoolean( sequential );
+ out.writeObject( sequentialAgenda );
+ out.writeBoolean( maintainTms );
+ out.writeBoolean( removeIdentities );
+ out.writeBoolean( shareAlphaNodes );
+ out.writeBoolean( shareBetaNodes );
+ out.writeBoolean( alphaMemory );
+ out.writeInt( alphaNodeHashingThreshold );
+ out.writeInt( compositeKeyDepth );
+ out.writeBoolean( indexLeftBetaMemory );
+ out.writeBoolean( indexRightBetaMemory );
+ out.writeObject( assertBehaviour );
+ out.writeObject( logicalOverride );
+ out.writeObject( executorService );
+ out.writeObject( consequenceExceptionHandler );
+ out.writeObject( ruleBaseUpdateHandler );
+ out.writeObject( sessionClockClass );
+ out.writeObject( conflictResolver );
+ out.writeBoolean( shadowProxy );
+ out.writeObject( shadowProxyExcludes );
+ out.writeObject( processNodeInstanceFactoryRegistry );
+ }
+
+ public void readExternal(ObjectInput in) throws IOException,
+ ClassNotFoundException {
+ chainedProperties = (ChainedProperties) in.readObject();
+ immutable = in.readBoolean();
+ sequential = in.readBoolean();
+ sequentialAgenda = (SequentialAgenda) in.readObject();
+ maintainTms = in.readBoolean();
+ removeIdentities = in.readBoolean();
+ shareAlphaNodes = in.readBoolean();
+ shareBetaNodes = in.readBoolean();
+ alphaMemory = in.readBoolean();
+ alphaNodeHashingThreshold = in.readInt();
+ compositeKeyDepth = in.readInt();
+ indexLeftBetaMemory = in.readBoolean();
+ indexRightBetaMemory = in.readBoolean();
+ assertBehaviour = (AssertBehaviour) in.readObject();
+ logicalOverride = (LogicalOverride) in.readObject();
+ executorService = (String) in.readObject();
+ consequenceExceptionHandler = (ConsequenceExceptionHandler) in.readObject();
+ ruleBaseUpdateHandler = (String) in.readObject();
+ sessionClockClass = (Class< ? extends SessionClock>) in.readObject();
+ conflictResolver = (ConflictResolver) in.readObject();
+ shadowProxy = in.readBoolean();
+ shadowProxyExcludes = (Map) in.readObject();
+ processNodeInstanceFactoryRegistry = (NodeInstanceFactoryRegistry) in.readObject();
+ }
+
/**
* Creates a new rulebase configuration using the provided properties
* as configuration options. Also, if a Thread.currentThread().getContextClassLoader()
* returns a non-null class loader, it will be used as the parent classloader
* for this rulebase class loaders, otherwise, the RuleBaseConfiguration.class.getClassLoader()
* class loader will be used.
- *
+ *
* @param properties
*/
public RuleBaseConfiguration(Properties properties) {
@@ -131,11 +190,11 @@
/**
* Creates a new rulebase with a default parent class loader set according
* to the following algorithm:
- *
- * If a Thread.currentThread().getContextClassLoader() returns a non-null class loader,
- * it will be used as the parent class loader for this rulebase class loaders, otherwise,
+ *
+ * If a Thread.currentThread().getContextClassLoader() returns a non-null class loader,
+ * it will be used as the parent class loader for this rulebase class loaders, otherwise,
* the RuleBaseConfiguration.class.getClassLoader() class loader will be used.
- *
+ *
* @param properties
*/
public RuleBaseConfiguration() {
@@ -146,7 +205,7 @@
/**
* A constructor that sets the parent classloader to be used
* while dealing with this rule base
- *
+ *
* @param classLoader
*/
public RuleBaseConfiguration(ClassLoader classLoader) {
@@ -158,7 +217,7 @@
* A constructor that sets the classloader to be used as the parent classloader
* of this rule base classloaders, and the properties to be used
* as base configuration options
- *
+ *
* @param classLoder
* @param properties
*/
@@ -245,11 +304,13 @@
setSessionClockClass( this.chainedProperties.getProperty( "drools.sessionClock",
SessionPseudoClock.class.getName() ) );
+ setUseStaticObjenesis( Boolean.valueOf( this.chainedProperties.getProperty( "drools.useStaticObjenesis",
+ "false" ) ).booleanValue() );
}
/**
- * Makes the configuration object immutable. Once it becomes immutable,
- * there is no way to make it mutable again.
+ * Makes the configuration object immutable. Once it becomes immutable,
+ * there is no way to make it mutable again.
* This is done to keep consistency.
*/
public void makeImmutable() {
@@ -328,7 +389,7 @@
}
public void setAlphaNodeHashingThreshold(final int alphaNodeHashingThreshold) {
- checkCanChange(); // throws an exception if a change isn't possible;
+ checkCanChange(); // throws an exception if a change isn't possible;
this.alphaNodeHashingThreshold = alphaNodeHashingThreshold;
}
@@ -388,7 +449,7 @@
}
public void setExecutorService(String executorService) {
- checkCanChange(); // throws an exception if a change isn't possible;
+ checkCanChange(); // throws an exception if a change isn't possible;
this.executorService = executorService;
}
@@ -397,7 +458,7 @@
}
public void setConsequenceExceptionHandler(ConsequenceExceptionHandler consequenceExceptionHandler) {
- checkCanChange(); // throws an exception if a change isn't possible;
+ checkCanChange(); // throws an exception if a change isn't possible;
this.consequenceExceptionHandler = consequenceExceptionHandler;
}
@@ -406,14 +467,14 @@
}
public void setRuleBaseUpdateHandler(String ruleBaseUpdateHandler) {
- checkCanChange(); // throws an exception if a change isn't possible;
+ checkCanChange(); // throws an exception if a change isn't possible;
this.ruleBaseUpdateHandler = ruleBaseUpdateHandler;
}
/**
* Returns the actual class that is set to be used as the session clock
* for sessions of this rulebase
- *
+ *
* @return
*/
public Class< ? extends SessionClock> getSessionClockClass() {
@@ -421,20 +482,20 @@
}
/**
- * Sets the class whose instance is to be used as the session clock
+ * Sets the class whose instance is to be used as the session clock
* for sessions of this rulebase
- *
+ *
* @param sessionClockClass
*/
public void setSessionClockClass(Class< ? extends SessionClock> sessionClockClass) {
- checkCanChange(); // throws an exception if a change isn't possible;
+ checkCanChange(); // throws an exception if a change isn't possible;
this.sessionClockClass = sessionClockClass;
}
/**
* Sets the class name whose instance is to be used as the session clock
* for sessions of this rulebase
- *
+ *
* @param className
*/
public void setSessionClockClass(String className) {
@@ -513,9 +574,9 @@
String content = ConfFileUtils.URLContentsToString( ConfFileUtils.getURL( factoryLocation,
null,
RuleBaseConfiguration.class ) );
-
+
Map<Class< ? extends Node>, NodeInstanceFactory> map = (Map<Class< ? extends Node>, NodeInstanceFactory>) MVEL.eval( content,
- new HashMap() );
+ new HashMap() );
if ( map != null ) {
for ( Entry<Class< ? extends Node>, NodeInstanceFactory> entry : map.entrySet() ) {
@@ -583,6 +644,15 @@
return this.shadowProxy;
}
+ public boolean isUseStaticObjenesis() {
+ return useStaticObjenesis;
+ }
+
+ public void setUseStaticObjenesis(boolean useStaticObjenesis) {
+ checkCanChange(); // throws an exception if a change isn't possible;
+ this.useStaticObjenesis = useStaticObjenesis;
+ }
+
public ClassLoader getClassLoader() {
return classLoader;
}
@@ -684,7 +754,7 @@
public static class AssertBehaviour
implements
- Serializable {
+ Externalizable {
private static final long serialVersionUID = 400L;
public static final AssertBehaviour IDENTITY = new AssertBehaviour( 0 );
@@ -692,10 +762,33 @@
private int value;
+ public void readExternal(ObjectInput in) throws IOException,
+ ClassNotFoundException {
+ value = in.readInt();
+ }
+
+ public void writeExternal(ObjectOutput out) throws IOException {
+ out.writeInt( value );
+ }
+
+ public AssertBehaviour() {
+
+ }
+
private AssertBehaviour(final int value) {
this.value = value;
}
+ public boolean equals(Object obj) {
+ if ( obj == this ) return true;
+ else if ( obj instanceof AssertBehaviour ) {
+ AssertBehaviour that = (AssertBehaviour) obj;
+
+ return value == that.value;
+ }
+ return false;
+ }
+
public static AssertBehaviour determineAssertBehaviour(final String value) {
if ( "IDENTITY".equalsIgnoreCase( value ) ) {
return IDENTITY;
@@ -724,7 +817,7 @@
public static class LogicalOverride
implements
- Serializable {
+ Externalizable {
private static final long serialVersionUID = 400L;
public static final LogicalOverride PRESERVE = new LogicalOverride( 0 );
@@ -732,6 +825,19 @@
private int value;
+ public void readExternal(ObjectInput in) throws IOException,
+ ClassNotFoundException {
+ value = in.readInt();
+ }
+
+ public void writeExternal(ObjectOutput out) throws IOException {
+ out.writeInt( value );
+ }
+
+ public LogicalOverride() {
+
+ }
+
private LogicalOverride(final int value) {
this.value = value;
}
@@ -757,6 +863,15 @@
}
}
+ public boolean equals(Object obj) {
+ if ( obj == this ) {
+ return true;
+ } else if ( obj instanceof LogicalOverride ) {
+ return value == ((LogicalOverride) obj).value;
+ }
+ return false;
+ }
+
public String toString() {
return "LogicalOverride : " + ((this.value == 0) ? "preserve" : "discard");
}
@@ -764,7 +879,7 @@
public static class SequentialAgenda
implements
- Serializable {
+ Externalizable {
private static final long serialVersionUID = 400L;
public static final SequentialAgenda SEQUENTIAL = new SequentialAgenda( 0 );
@@ -772,6 +887,19 @@
private int value;
+ public void readExternal(ObjectInput in) throws IOException,
+ ClassNotFoundException {
+ value = in.readInt();
+ }
+
+ public void writeExternal(ObjectOutput out) throws IOException {
+ out.writeInt( value );
+ }
+
+ public SequentialAgenda() {
+
+ }
+
private SequentialAgenda(final int value) {
this.value = value;
}
Modified: labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/RuleBaseEventManager.java
===================================================================
--- labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/RuleBaseEventManager.java 2008-03-20 18:57:07 UTC (rev 19163)
+++ labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/RuleBaseEventManager.java 2008-03-20 19:32:10 UTC (rev 19164)
@@ -16,7 +16,7 @@
* limitations under the License.
*/
-import java.io.Serializable;
+import java.io.Externalizable;
import java.util.List;
import org.drools.event.RuleBaseEventListener;
@@ -27,7 +27,7 @@
*/
public interface RuleBaseEventManager
extends
- Serializable {
+ Externalizable {
/**
* Add an event listener.
*
Modified: labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/WorkingMemory.java
===================================================================
--- labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/WorkingMemory.java 2008-03-20 18:57:07 UTC (rev 19163)
+++ labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/WorkingMemory.java 2008-03-20 19:32:10 UTC (rev 19164)
@@ -2,13 +2,13 @@
/*
* Copyright 2005 JBoss Inc
- *
+ *
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -16,6 +16,7 @@
* limitations under the License.
*/
+import java.io.Externalizable;
import java.util.Collection;
import java.util.Iterator;
import java.util.Map;
@@ -29,16 +30,16 @@
/**
* A knowledge session for a <code>RuleBase</code>.
- *
+ *
* While this object can be serialised out, it cannot be serialised in. This is because
* the RuleBase reference is transient. Please see the RuleBase interface for serializing
* in WorkingMemories from an InputStream.
- *
+ *
*/
-public interface WorkingMemory extends WorkingMemoryEventManager, WorkingMemoryEntryPoint {
+public interface WorkingMemory extends WorkingMemoryEventManager, WorkingMemoryEntryPoint, Externalizable {
/**
- * Returns the Agenda for this WorkingMemory. While the WorkingMemory interface is considered public, the Agenda interface
+ * Returns the Agenda for this WorkingMemory. While the WorkingMemory interface is considered public, the Agenda interface
* is more subject to change.
* @return
* the Agenda
@@ -48,7 +49,7 @@
/**
* Set a specific instance as a global in this working memory. Null values will return doing nothing.
* The global identifier and its type must be declared in the drl.
- *
+ *
* @param identifier
* the identifier under which to populate the data
* @param value
@@ -59,38 +60,38 @@
/**
* Retrieve a specific instance of global data by identifier
- *
+ *
* @return application data or null if nothing is set under this identifier
*/
Object getGlobal(String identifier);
-
+
/**
* Sets the GlobalResolver instance to be used when resolving globals, replaces the current GlobalResolver.
* Typcicaly a delegating GlobalResolver is created that first gets a reference to the current GlobalResolver,
* for delegating
- *
+ *
* @param globalResolver
*/
void setGlobalResolver(GlobalResolver globalResolver);
-
+
/**
* Returns the current GlobalResolver
- *
+ *
* @return
*/
GlobalResolver getGlobalResolver();
/**
* Retrieve the <code>RuleBase</code> for this working memory.
- *
+ *
* @return The <code>RuleBase</code>.
*/
RuleBase getRuleBase();
/**
* Fire all items on the agenda until empty.
- *
+ *
* @throws FactException
* If a RuntimeException error occurs.
*/
@@ -98,15 +99,15 @@
/**
* Fire all items on the agenda until empty, using the given AgendaFiler
- *
+ *
* @throws FactException
* If a RuntimeException error occurs.
*/
void fireAllRules(AgendaFilter agendaFilter) throws FactException;
-
+
/**
* Fire all items on the agenda until empty or at most 'fireLimit' rules have fired
- *
+ *
* @throws FactException
* If a RuntimeException error occurs.
*/
@@ -115,7 +116,7 @@
/**
* Fire all items on the agenda using the given AgendaFiler
* until empty or at most 'fireLimit' rules have fired
- *
+ *
* @throws FactException
* If a RuntimeException error occurs.
*/
@@ -123,45 +124,45 @@
/**
* Retrieve the object associated with a <code>FactHandle</code>.
- *
- *
+ *
+ *
* @param handle
* The fact handle.
- *
+ *
* @return The associated object.
*/
Object getObject(FactHandle handle);
/**
* Retrieve the <code>FactHandle</code> associated with an Object.
- *
+ *
* @param object
* The object.
- *
+ *
* @return The associated fact handle.
*/
FactHandle getFactHandle(Object object);
FactHandle getFactHandleByIdentity(final Object object);
-
+
/**
- * Returns an Iterator for the Objects in the Working Memory. This Iterator is not thread safe.
+ * Returns an Iterator for the Objects in the Working Memory. This Iterator is not thread safe.
* This means that any working memory actions during iteration may invalidate the iterator.
* @return
* the Iterator
*/
Iterator iterateObjects();
-
+
/**
* Returns an Iterator for the Objects in the Working Memory. This Iterator will filter out
* any objects that the ObjectFilter does not accept. This Iterator is not thread safe.
* This means that any working memory actions during iteration may invalidate the iterator.
- *
+ *
* @param filter
- *
+ *
* @return
* the Iterator
- */
+ */
Iterator iterateObjects(ObjectFilter filter);
/**
@@ -169,21 +170,21 @@
* This means that any working memory actions during iteration may invalidate the iterator.
* @return
* the Iterator
- */
+ */
Iterator iterateFactHandles();
-
+
/**
* Returns an Iterator for the Objects in the Working Memory. This Iterator will filter out
* any objects that the ObjectFilter does not accept. This Iterator is not thread safe.
* This means that any working memory actions during iteration may invalidate the iterator.
- *
+ *
* @param filter
- *
+ *
* @return
* the Iterator
- */
- Iterator iterateFactHandles(ObjectFilter filter);
-
+ */
+ Iterator iterateFactHandles(ObjectFilter filter);
+
/**
* Returns the AgendaGroup which has the current WorkingMemory focus. The AgendaGroup interface is subject to change.
* @return
@@ -200,10 +201,10 @@
/**
* Set the focus to the specified AgendaGroup
* @param focus
- */
+ */
void setFocus(AgendaGroup focus);
-
+
/**
* Retrieve the QueryResults of the specified query.
*
@@ -212,33 +213,33 @@
*
* @return The QueryResults of the specified query.
* If no results match the query it is empty.
- *
- * @throws IllegalArgumentException
- * if no query named "query" is found in the rulebase
+ *
+ * @throws IllegalArgumentException
+ * if no query named "query" is found in the rulebase
*/
public QueryResults getQueryResults(String query);
-
+
/**
* Retrieve the QueryResults of the specified query and arguments
*
* @param query
* The name of the query.
- *
+ *
* @param arguments
* The arguments used for the query
*
* @return The QueryResults of the specified query.
* If no results match the query it is empty.
- *
- * @throws IllegalArgumentException
- * if no query named "query" is found in the rulebase
- */
+ *
+ * @throws IllegalArgumentException
+ * if no query named "query" is found in the rulebase
+ */
public QueryResults getQueryResults(String query, Object[] arguments);
/**
* Sets the AsyncExceptionHandler to handle exceptions thrown by the Agenda
* Scheduler used for duration rules.
- *
+ *
* @param handler
*/
void setAsyncExceptionHandler(AsyncExceptionHandler handler);
@@ -258,20 +259,20 @@
* @param group
*/
public void clearActivationGroup(String group);
-
+
/**
* Clears the RuleFlow group, cancelling all its Activations
* @param group
*/
public void clearRuleFlowGroup(String group);
-
+
/**
- * Starts a new process instance for the process with the given id.
+ * Starts a new process instance for the process with the given id.
*/
ProcessInstance startProcess(String processId);
/**
- * Starts a new process instance for the process with the given id.
+ * Starts a new process instance for the process with the given id.
*/
ProcessInstance startProcess(String processId, Map<String, Object> parameters);
@@ -281,28 +282,28 @@
* @return the list of process instances
*/
public Collection getProcessInstances();
-
+
/**
* Returns the process instance with the given id.
* @return the process instance with the given id
*/
public ProcessInstance getProcessInstance(long id);
-
+
public WorkItemManager getWorkItemManager();
-
+
/**
* Stops rule firing after the currect rule finishes executing
*
*/
public void halt();
-
+
/**
* Returns the interface instance for a given entry point, so
* that the application can manage entry-point-scoped facts.
- *
+ *
* @param id the id of the entry point, as defined in the rules file
* @return
*/
public WorkingMemoryEntryPoint getWorkingMemoryEntryPoint( String id );
-
+
}
\ No newline at end of file
Modified: labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/WorkingMemoryEventManager.java
===================================================================
--- labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/WorkingMemoryEventManager.java 2008-03-20 18:57:07 UTC (rev 19163)
+++ labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/WorkingMemoryEventManager.java 2008-03-20 19:32:10 UTC (rev 19164)
@@ -16,7 +16,7 @@
* limitations under the License.
*/
-import java.io.Serializable;
+import java.io.Externalizable;
import java.util.List;
import org.drools.event.AgendaEventListener;
@@ -30,7 +30,7 @@
public interface WorkingMemoryEventManager
extends
RuleBaseEventManager,
- Serializable {
+ Externalizable {
/**
* Add an event listener.
*
Modified: labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/agent/FileScanner.java
===================================================================
--- labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/agent/FileScanner.java 2008-03-20 18:57:07 UTC (rev 19163)
+++ labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/agent/FileScanner.java 2008-03-20 19:32:10 UTC (rev 19164)
@@ -5,6 +5,7 @@
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.ObjectInputStream;
+import java.io.ObjectInput;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
@@ -64,9 +65,6 @@
/**
* Calculate a change set, based on last updated times.
* (keep a map of files).
- * @throws ClassNotFoundException
- * @throws IOException
- * @throws FileNotFoundException
*/
private Package[] getChangeSet() {
if ( this.files == null ) return new Package[0];
@@ -106,7 +104,7 @@
} else {
Package p1_ = null;
- ObjectInputStream in;
+ ObjectInput in;
try {
in = new DroolsObjectInputStream( new FileInputStream( pkgFile ) );
p1_ = (Package) in.readObject();
Modified: labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/agent/HttpClientImpl.java
===================================================================
--- labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/agent/HttpClientImpl.java 2008-03-20 18:57:07 UTC (rev 19163)
+++ labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/agent/HttpClientImpl.java 2008-03-20 19:32:10 UTC (rev 19164)
@@ -11,36 +11,42 @@
public class HttpClientImpl implements IHttpClient {
-
-
-
-
-
-
+
+
+
+
+
+
public LastUpdatedPing checkLastUpdated(URL url) throws IOException {
URLConnection con = url.openConnection();
HttpURLConnection httpCon = (HttpURLConnection) con;
try {
httpCon.setRequestMethod( "HEAD" );
-
+
+
String lm = httpCon.getHeaderField( "lastModified" );
LastUpdatedPing ping = new LastUpdatedPing();
-
+
ping.responseMessage = httpCon.getHeaderFields().toString();
-
+
if (lm != null) {
ping.lastUpdated = Long.parseLong( lm );
+ } else {
+ long httpLM = httpCon.getLastModified();
+ if (httpLM > 0) {
+ ping.lastUpdated = httpLM;
+ }
}
-
+
return ping;
- } finally {
+ } finally {
httpCon.disconnect();
}
-
+
}
public Package fetchPackage(URL url) throws IOException, ClassNotFoundException {
@@ -49,28 +55,28 @@
try {
httpCon.setRequestMethod( "GET" );
InputStream in = httpCon.getInputStream();
-
+
DroolsObjectInputStream oin = new DroolsObjectInputStream(in);
return (Package) oin.readObject();
-
+
} finally {
httpCon.disconnect();
}
}
-
+
public static void main(String[] args) throws Exception {
HttpClientImpl cl = new HttpClientImpl();
URL url = new URL("http://localhost:8888/org.drools.brms.JBRMS/package/com.billasurf.manufacturing.plant/SNAP");
-
-
+
+
LastUpdatedPing ping = cl.checkLastUpdated( url );
-
-
+
+
Package p = cl.fetchPackage( url );
-
-
+
+
System.err.println(ping);
System.err.println( ping.isError() );
}
-
+
}
Modified: labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/agent/URLScanner.java
===================================================================
--- labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/agent/URLScanner.java 2008-03-20 18:57:07 UTC (rev 19163)
+++ labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/agent/URLScanner.java 2008-03-20 19:32:10 UTC (rev 19164)
@@ -5,6 +5,7 @@
import java.io.IOException;
import java.io.ObjectOutputStream;
import java.io.UnsupportedEncodingException;
+import java.io.ObjectOutput;
import java.net.MalformedURLException;
import java.net.URL;
import java.net.URLEncoder;
@@ -15,6 +16,7 @@
import java.util.Properties;
import org.drools.RuntimeDroolsException;
+import org.drools.common.DroolsObjectOutputStream;
import org.drools.rule.Package;
public class URLScanner extends PackageProvider {
@@ -122,7 +124,7 @@
if (local.exists()) local.delete();
try {
- ObjectOutputStream out = new ObjectOutputStream(new FileOutputStream(local));
+ ObjectOutput out = new DroolsObjectOutputStream(new FileOutputStream(local));
out.writeObject( p );
out.flush();
out.close();
Modified: labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/audit/WorkingMemoryConsoleLogger.java
===================================================================
--- labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/audit/WorkingMemoryConsoleLogger.java 2008-03-20 18:57:07 UTC (rev 19163)
+++ labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/audit/WorkingMemoryConsoleLogger.java 2008-03-20 19:32:10 UTC (rev 19164)
@@ -3,14 +3,26 @@
import org.drools.WorkingMemory;
import org.drools.audit.event.LogEvent;
+import java.io.ObjectOutput;
+import java.io.IOException;
+import java.io.ObjectInput;
+
public class WorkingMemoryConsoleLogger extends WorkingMemoryLogger {
- public WorkingMemoryConsoleLogger(WorkingMemory workingMemory) {
- super(workingMemory);
- }
-
- public void logEventCreated(LogEvent logEvent) {
- System.out.println(logEvent);
- }
+ public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
+ super.readExternal(in);
+ }
+ public void writeExternal(ObjectOutput out) throws IOException {
+ super.writeExternal(out);
+ }
+
+ public WorkingMemoryConsoleLogger(WorkingMemory workingMemory) {
+ super(workingMemory);
+ }
+
+ public void logEventCreated(LogEvent logEvent) {
+ System.out.println(logEvent);
+ }
+
}
Modified: labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/audit/WorkingMemoryFileLogger.java
===================================================================
--- labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/audit/WorkingMemoryFileLogger.java 2008-03-20 18:57:07 UTC (rev 19163)
+++ labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/audit/WorkingMemoryFileLogger.java 2008-03-20 19:32:10 UTC (rev 19164)
@@ -16,16 +16,18 @@
* limitations under the License.
*/
+import com.thoughtworks.xstream.XStream;
+import org.drools.WorkingMemoryEventManager;
+import org.drools.audit.event.LogEvent;
+
import java.io.FileNotFoundException;
import java.io.FileWriter;
+import java.io.IOException;
+import java.io.ObjectInput;
+import java.io.ObjectOutput;
import java.util.ArrayList;
import java.util.List;
-import org.drools.WorkingMemoryEventManager;
-import org.drools.audit.event.LogEvent;
-
-import com.thoughtworks.xstream.XStream;
-
/**
* A logger of events generated by a working memory.
* It stores its information in a file that can be specified.
@@ -44,21 +46,44 @@
*/
public class WorkingMemoryFileLogger extends WorkingMemoryLogger {
- private final List<LogEvent> events = new ArrayList<LogEvent>();
+ private List<LogEvent> events = new ArrayList<LogEvent>();
private String fileName = "event";
private int maxEventsInMemory = 1000;
private int nbOfFile = 0;
private boolean split = true;
private boolean initialized = false;
+ public WorkingMemoryFileLogger() {
+ }
+
/**
* Creates a new WorkingMemoryFileLogger for the given working memory.
- * @param workingMemory
+ * @param workingMemoryEventManager
*/
public WorkingMemoryFileLogger(final WorkingMemoryEventManager workingMemoryEventManager) {
super( workingMemoryEventManager );
}
+ public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
+ super.readExternal(in);
+ events = (List<LogEvent>)in.readObject();
+ fileName = (String)in.readObject();
+ maxEventsInMemory = in.readInt();
+ nbOfFile = in.readInt();
+ split = in.readBoolean();
+ initialized = in.readBoolean();
+ }
+
+ public void writeExternal(ObjectOutput out) throws IOException {
+ super.writeExternal(out);
+ out.writeObject(events);
+ out.writeObject(fileName);
+ out.writeInt(maxEventsInMemory);
+ out.writeInt(nbOfFile);
+ out.writeBoolean(split);
+ out.writeBoolean(initialized);
+ }
+
/**
* Sets the name of the file the events are logged in.
* No extensions should be given since .log is automatically appended
Modified: labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/audit/WorkingMemoryInMemoryLogger.java
===================================================================
--- labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/audit/WorkingMemoryInMemoryLogger.java 2008-03-20 18:57:07 UTC (rev 19163)
+++ labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/audit/WorkingMemoryInMemoryLogger.java 2008-03-20 19:32:10 UTC (rev 19164)
@@ -16,16 +16,18 @@
* limitations under the License.
*/
+import com.thoughtworks.xstream.XStream;
+import org.drools.WorkingMemory;
+import org.drools.audit.event.LogEvent;
+
+import java.io.IOException;
+import java.io.ObjectInput;
+import java.io.ObjectOutput;
import java.io.ObjectOutputStream;
import java.io.StringWriter;
import java.util.ArrayList;
import java.util.List;
-import org.drools.WorkingMemory;
-import org.drools.audit.event.LogEvent;
-
-import com.thoughtworks.xstream.XStream;
-
/**
* A logger of events generated by a working memory.
* It stores its information in memory, so it can be retrieved later.
@@ -34,8 +36,11 @@
*/
public class WorkingMemoryInMemoryLogger extends WorkingMemoryLogger {
- private final List events = new ArrayList();
+ private List events = new ArrayList();
+ public WorkingMemoryInMemoryLogger() {
+ }
+
/**
* Creates a new WorkingMemoryInMemoryLogger for the given working memory.
* @param workingMemory
@@ -44,6 +49,16 @@
super( workingMemory );
}
+ public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
+ super.readExternal(in);
+ events = (List)in.readObject();
+ }
+
+ public void writeExternal(ObjectOutput out) throws IOException {
+ super.writeExternal(out);
+ out.writeObject(events);
+ }
+
public String getEvents() {
final XStream xstream = new XStream();
StringWriter writer = new StringWriter();
Modified: labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/audit/WorkingMemoryLogger.java
===================================================================
--- labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/audit/WorkingMemoryLogger.java 2008-03-20 18:57:07 UTC (rev 19163)
+++ labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/audit/WorkingMemoryLogger.java 2008-03-20 19:32:10 UTC (rev 19164)
@@ -20,6 +20,9 @@
import java.util.Iterator;
import java.util.List;
import java.util.Map;
+import java.io.ObjectOutput;
+import java.io.IOException;
+import java.io.ObjectInput;
import org.drools.WorkingMemoryEventManager;
import org.drools.FactHandle;
@@ -91,8 +94,11 @@
RuleFlowEventListener,
RuleBaseEventListener {
- private final List filters = new ArrayList();
+ private List filters = new ArrayList();
+ public WorkingMemoryLogger() {
+ }
+
/**
* Creates a new working memory logger for the given working memory.
*
@@ -105,6 +111,14 @@
workingMemoryEventManager.addEventListener( (RuleBaseEventListener) this );
}
+ public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
+ filters = (List)in.readObject();
+ }
+
+ public void writeExternal(ObjectOutput out) throws IOException {
+ out.writeObject(filters);
+ }
+
/**
* This method is invoked every time a new log event is created.
* Subclasses should implement this method and store the event,
@@ -264,7 +278,7 @@
// This handle is now invalid, probably due to an fact retraction
continue;
}
- final Object value = declaration.getValue( (InternalWorkingMemory) workingMemory, workingMemory.getObject( handle ) );
+ final Object value = declaration.getValue( (InternalWorkingMemory) workingMemory, handleImpl.getObject() );
result.append( declaration.getIdentifier() );
result.append( "=" );
Modified: labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/audit/event/ActivationLogEvent.java
===================================================================
--- labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/audit/event/ActivationLogEvent.java 2008-03-20 18:57:07 UTC (rev 19163)
+++ labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/audit/event/ActivationLogEvent.java 2008-03-20 19:32:10 UTC (rev 19164)
@@ -1,5 +1,9 @@
package org.drools.audit.event;
+import java.io.ObjectInput;
+import java.io.IOException;
+import java.io.ObjectOutput;
+
/*
* Copyright 2005 JBoss Inc
*
@@ -41,6 +45,9 @@
private String declarations;
private String ruleFlowGroup;
+ public ActivationLogEvent() {
+ }
+
/**
* Create a new activation log event.
*
@@ -63,6 +70,22 @@
this.ruleFlowGroup = ruleFlowGroup;
}
+ public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
+ super.readExternal(in);
+ activationId = (String)in.readObject();
+ rule = (String)in.readObject();
+ declarations = (String)in.readObject();
+ ruleFlowGroup = (String)in.readObject();
+ }
+
+ public void writeExternal(ObjectOutput out) throws IOException {
+ super.writeExternal(out);
+ out.writeObject(activationId);
+ out.writeObject(rule);
+ out.writeObject(declarations);
+ out.writeObject(ruleFlowGroup);
+ }
+
/**
* Returns a unique id for the activation.
*
Modified: labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/audit/event/LogEvent.java
===================================================================
--- labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/audit/event/LogEvent.java 2008-03-20 18:57:07 UTC (rev 19163)
+++ labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/audit/event/LogEvent.java 2008-03-20 19:32:10 UTC (rev 19164)
@@ -1,5 +1,10 @@
package org.drools.audit.event;
+import java.io.Externalizable;
+import java.io.ObjectInput;
+import java.io.IOException;
+import java.io.ObjectOutput;
+
/*
* Copyright 2005 JBoss Inc
*
@@ -22,7 +27,7 @@
*
* @author <a href="mailto:kris_verlaenen at hotmail.com">Kris Verlaenen </a>
*/
-public class LogEvent {
+public class LogEvent implements Externalizable {
public static final int INSERTED = 1;
public static final int UPDATED = 2;
@@ -63,6 +68,9 @@
private int type;
+ public LogEvent() {
+ }
+
/**
* Creates a new log event.
*
@@ -72,6 +80,13 @@
this.type = type;
}
+ public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
+ type = in.readInt();
+ }
+
+ public void writeExternal(ObjectOutput out) throws IOException {
+ out.writeInt(type);
+ }
/**
* Returns the type of the log event as defined in this class.
*
Modified: labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/base/BaseClassFieldExtractor.java
===================================================================
--- labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/base/BaseClassFieldExtractor.java 2008-03-20 18:57:07 UTC (rev 19163)
+++ labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/base/BaseClassFieldExtractor.java 2008-03-20 19:32:10 UTC (rev 19164)
@@ -2,13 +2,13 @@
/*
* Copyright 2005 JBoss Inc
- *
+ *
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -21,6 +21,10 @@
import org.drools.util.ClassUtils;
import org.drools.util.asm.ClassFieldInspector;
+import java.io.IOException;
+import java.io.ObjectInput;
+import java.io.ObjectOutput;
+
/**
* This is the supertype for the ASM generated classes for accessing a field.
* @author Alexander Bagerman
@@ -28,15 +32,19 @@
abstract public class BaseClassFieldExtractor
implements
FieldExtractor {
- private final int index;
+ private int index;
- private final Class fieldType;
+ private Class fieldType;
- private final ValueType valueType;
+ private ValueType valueType;
+ public BaseClassFieldExtractor() {
+
+ }
+
/**
* This constructor is not supposed to be used from outside the class hirarchy
- *
+ *
* @param index
* @param fieldType
* @param valueType
@@ -51,7 +59,7 @@
/**
* This is the constructor to be used
- *
+ *
* @param clazz
* @param fieldName
*/
@@ -67,6 +75,20 @@
}
}
+ public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
+ index = in.readInt();
+ fieldType = (Class)in.readObject();
+ valueType = (ValueType)in.readObject();
+ if (valueType != null)
+ valueType = ValueType.determineValueType(valueType.getClassType());
+ }
+
+ public void writeExternal(ObjectOutput out) throws IOException {
+ out.writeInt(index);
+ out.writeObject(fieldType);
+ out.writeObject(valueType);
+ }
+
public int getIndex() {
return this.index;
}
@@ -82,11 +104,11 @@
public ValueType getValueType() {
return this.valueType;
}
-
+
public boolean isGlobal() {
return false;
}
-
+
public int hashCode() {
final int PRIME = 31;
int result = 1;
Modified: labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/base/BaseEvaluator.java
===================================================================
--- labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/base/BaseEvaluator.java 2008-03-20 18:57:07 UTC (rev 19163)
+++ labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/base/BaseEvaluator.java 2008-03-20 19:32:10 UTC (rev 19164)
@@ -2,13 +2,13 @@
/*
* Copyright 2005 JBoss Inc
- *
+ *
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -20,26 +20,46 @@
import org.drools.common.InternalFactHandle;
import org.drools.spi.Evaluator;
+import java.io.Externalizable;
+import java.io.ObjectInput;
+import java.io.IOException;
+import java.io.ObjectOutput;
+
/**
* BaseEvaluator is an Object Comparator that is operator aware
- *
+ *
* @author mproctor
- *
+ *
*/
public abstract class BaseEvaluator
implements
- Evaluator {
+ Evaluator, Externalizable {
- private final Operator operator;
+ private Operator operator;
- private final ValueType type;
+ private ValueType type;
+ public BaseEvaluator() {
+ }
+
public BaseEvaluator(final ValueType type,
final Operator operator) {
this.type = type;
this.operator = operator;
}
+ public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
+ operator = (Operator)in.readObject();
+ type = (ValueType)in.readObject();
+ if (type != null)
+ type = ValueType.determineValueType(type.getClassType());
+ }
+
+ public void writeExternal(ObjectOutput out) throws IOException {
+ out.writeObject(operator);
+ out.writeObject(type);
+ }
+
public Operator getOperator() {
return this.operator;
}
@@ -55,7 +75,7 @@
public Object prepareObject(InternalFactHandle handle) {
return handle.getObject();
}
-
+
public boolean equals(final Object object) {
if ( this == object ) {
return true;
Modified: labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/base/ClassFieldExtractor.java
===================================================================
--- labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/base/ClassFieldExtractor.java 2008-03-20 18:57:07 UTC (rev 19163)
+++ labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/base/ClassFieldExtractor.java 2008-03-20 19:32:10 UTC (rev 19164)
@@ -2,13 +2,13 @@
/*
* Copyright 2005 JBoss Inc
- *
+ *
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -19,34 +19,42 @@
import java.io.IOException;
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;
+import java.io.ObjectInput;
+import java.io.ObjectOutput;
+import java.io.Externalizable;
import java.lang.reflect.Method;
import org.drools.RuntimeDroolsException;
import org.drools.common.DroolsObjectInputStream;
import org.drools.common.InternalWorkingMemory;
+import org.drools.common.DroolsObjectInput;
import org.drools.spi.FieldExtractor;
import org.drools.util.ClassUtils;
/**
* This provides access to fields, and what their numerical index/object type is.
- * This is basically a wrapper class around dynamically generated subclasses of
+ * This is basically a wrapper class around dynamically generated subclasses of
* BaseClassFieldExtractor,
- * which allows serialization by regenerating the accessor classes
+ * which allows serialization by regenerating the accessor classes
* when needed.
- *
+ *
* @author Michael Neale
*/
public class ClassFieldExtractor
implements
FieldExtractor {
/**
- *
+ *
*/
private static final long serialVersionUID = 400L;
private String fieldName;
private Class clazz;
private transient FieldExtractor extractor;
+ public ClassFieldExtractor() {
+
+ }
+
public ClassFieldExtractor(final Class clazz,
final String fieldName) {
this( clazz,
@@ -73,27 +81,25 @@
factory );
}
- private void writeObject(ObjectOutputStream s) throws IOException {
+ public void writeExternal(ObjectOutput out) throws IOException {
// Call even if there is no default serializable fields.
- s.defaultWriteObject();
+ out.writeObject(clazz);
+ out.writeObject(fieldName);
}
- private void readObject(final ObjectInputStream is) throws ClassNotFoundException,
- IOException,
- Exception {
- //always perform the default de-serialization first
- is.defaultReadObject();
- if ( is instanceof DroolsObjectInputStream ) {
- DroolsObjectInputStream dois = (DroolsObjectInputStream) is;
- this.extractor = dois.getExtractorFactory().getExtractor( this.clazz,
- this.fieldName,
- dois.getClassLoader() );
- } else {
- this.extractor = ClassFieldExtractorCache.getInstance().getExtractor( this.clazz,
- this.fieldName,
- this.clazz.getClassLoader() );
-
+ public void readExternal(final ObjectInput is) throws ClassNotFoundException,
+ IOException {
+ clazz = (Class)is.readObject();
+ fieldName = (String)is.readObject();
+ if (is instanceof DroolsObjectInput) {
+ DroolsObjectInput droolsInput = (DroolsObjectInput)is;
+ extractor = droolsInput.getExtractorFactory().getExtractor( clazz,
+ fieldName,
+ droolsInput.getClassLoader() );
}
+ else
+ extractor = ClassFieldExtractorCache.getInstance().getExtractor( clazz, fieldName,
+ getClass().getClassLoader());
}
// private Object readResolve() {
Modified: labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/base/ClassFieldExtractorCache.java
===================================================================
--- labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/base/ClassFieldExtractorCache.java 2008-03-20 18:57:07 UTC (rev 19163)
+++ labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/base/ClassFieldExtractorCache.java 2008-03-20 19:32:10 UTC (rev 19164)
@@ -1,6 +1,9 @@
package org.drools.base;
-import java.io.Serializable;
+import java.io.Externalizable;
+import java.io.ObjectInput;
+import java.io.IOException;
+import java.io.ObjectOutput;
import java.util.HashMap;
import java.util.Map;
@@ -53,13 +56,16 @@
private static class ExtractorKey
implements
- Serializable {
+ Externalizable {
private static final long serialVersionUID = 400;
- private final Class clazz;
- private final String fieldName;
- private final int hashCode;
+ private Class clazz;
+ private String fieldName;
+ private int hashCode;
+ public ExtractorKey() {
+ }
+
public ExtractorKey(Class clazz,
String fieldName) {
super();
@@ -73,6 +79,18 @@
this.hashCode = result;
}
+ public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
+ clazz = (Class)in.readObject();
+ fieldName = (String)in.readObject();
+ hashCode = in.readInt();
+ }
+
+ public void writeExternal(ObjectOutput out) throws IOException {
+ out.writeObject(clazz);
+ out.writeObject(fieldName);
+ out.writeInt(hashCode);
+ }
+
public Class getClazz() {
return clazz;
}
Modified: labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/base/ClassObjectType.java
===================================================================
--- labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/base/ClassObjectType.java 2008-03-20 18:57:07 UTC (rev 19163)
+++ labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/base/ClassObjectType.java 2008-03-20 19:32:10 UTC (rev 19164)
@@ -2,13 +2,13 @@
/*
* Copyright 2005 JBoss Inc
- *
+ *
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -18,19 +18,24 @@
import org.drools.spi.ObjectType;
+import java.io.ObjectInput;
+import java.io.IOException;
+import java.io.ObjectOutput;
+import java.io.Externalizable;
+
/**
* Java class semantics <code>ObjectType</code>.
- *
+ *
* @author <a href="mailto:bob at werken.com">bob at werken.com </a>
- *
+ *
* @version $Id: ClassObjectType.java,v 1.5 2005/02/04 02:13:36 mproctor Exp $
*/
public class ClassObjectType
implements
- ObjectType {
+ ObjectType, Externalizable {
/**
- *
+ *
*/
private static final long serialVersionUID = 400L;
@@ -45,9 +50,12 @@
// Constructors
// ------------------------------------------------------------
+ public ClassObjectType() {
+ this(null);
+ }
/**
* Creates a new class object type with shadow disabled.
- *
+ *
* @param objectTypeClass
* Java object class.
*/
@@ -57,23 +65,38 @@
/**
* Creates a new class object type
- *
+ *
* @param objectTypeClass the class represented by this class object type
* @param isEvent true if it is an event class, false otherwise
*/
public ClassObjectType(final Class objectTypeClass, final boolean isEvent) {
this.objectTypeClass = objectTypeClass;
this.isEvent = isEvent;
- this.valueType = ValueType.determineValueType( objectTypeClass );
+ if (objectTypeClass != null)
+ this.valueType = ValueType.determineValueType( objectTypeClass );
}
+ public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
+ objectTypeClass = (Class)in.readObject();
+ valueType = (ValueType)in.readObject();
+ if (valueType != null)
+ valueType = ValueType.determineValueType(valueType.getClassType());
+ isEvent = in.readBoolean();
+ }
+
+ public void writeExternal(ObjectOutput out) throws IOException {
+ out.writeObject(objectTypeClass);
+ out.writeObject(valueType);
+ out.writeBoolean(isEvent);
+ }
+
// ------------------------------------------------------------
// Instance methods
// ------------------------------------------------------------
/**
* Return the Java object class.
- *
+ *
* @return The Java object class.
*/
public Class getClassType() {
@@ -87,10 +110,10 @@
/**
* Determine if the passed <code>Class</code> matches to the object type
* defined by this <code>objectType</code> instance.
- *
+ *
* @param clazz
* The <code>Class</code> to test.
- *
+ *
* @return <code>true</code> if the <code>Class</code> matches this
* object type, else <code>false</code>.
*/
@@ -101,10 +124,10 @@
/**
* Determine if the passed <code>Object</code> belongs to the object type
* defined by this <code>objectType</code> instance.
- *
+ *
* @param object
* The <code>Object</code> to test.
- *
+ *
* @return <code>true</code> if the <code>Object</code> matches this
* object type, else <code>false</code>.
*/
@@ -142,10 +165,10 @@
/**
* Determine if another object is equal to this.
- *
+ *
* @param object
* The object to test.
- *
+ *
* @return <code>true</code> if <code>object</code> is equal to this,
* otherwise <code>false</code>.
*/
@@ -157,7 +180,7 @@
if ( object == null || object.getClass() != ClassObjectType.class ) {
return false;
}
-
+
return this.objectTypeClass == ((ClassObjectType) object).objectTypeClass;
}
Modified: labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/base/CopyIdentifiersGlobalExporter.java
===================================================================
--- labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/base/CopyIdentifiersGlobalExporter.java 2008-03-20 18:57:07 UTC (rev 19163)
+++ labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/base/CopyIdentifiersGlobalExporter.java 2008-03-20 19:32:10 UTC (rev 19164)
@@ -1,10 +1,13 @@
/**
- *
+ *
*/
package org.drools.base;
import java.util.HashMap;
import java.util.Map;
+import java.io.ObjectInput;
+import java.io.IOException;
+import java.io.ObjectOutput;
import org.drools.WorkingMemory;
import org.drools.common.InternalRuleBase;
@@ -19,7 +22,7 @@
*/
public class CopyIdentifiersGlobalExporter implements GlobalExporter {
private String[] identifiers;
-
+
/**
* All identifiers will be copied
*
@@ -27,7 +30,7 @@
public CopyIdentifiersGlobalExporter() {
this.identifiers = null;
}
-
+
/**
* Specified identifiers will be copied
* @param identifiers
@@ -35,7 +38,15 @@
public CopyIdentifiersGlobalExporter(String[] identifiers) {
this.identifiers = identifiers;
}
-
+
+ public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
+ identifiers = (String[])in.readObject();
+ }
+
+ public void writeExternal(ObjectOutput out) throws IOException {
+ out.writeObject(identifiers);
+ }
+
public GlobalResolver export(WorkingMemory workingMemory) {
if ( this.identifiers == null || this.identifiers.length == 0 ) {
// no identifiers, to get all the identifiers from that defined in
@@ -44,7 +55,7 @@
this.identifiers = new String[ map.size() ];
this.identifiers = (String[]) map.keySet().toArray( this.identifiers );
}
-
+
Map map = new HashMap(identifiers.length);
for ( int i = 0, length = identifiers.length; i < length; i++ ) {
map.put( identifiers[i], workingMemory.getGlobal( identifiers[i] ) );
Modified: labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/base/DefaultConsequenceExceptionHandler.java
===================================================================
--- labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/base/DefaultConsequenceExceptionHandler.java 2008-03-20 18:57:07 UTC (rev 19163)
+++ labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/base/DefaultConsequenceExceptionHandler.java 2008-03-20 19:32:10 UTC (rev 19164)
@@ -5,12 +5,22 @@
import org.drools.spi.ConsequenceException;
import org.drools.spi.ConsequenceExceptionHandler;
-public class DefaultConsequenceExceptionHandler implements ConsequenceExceptionHandler {
+import java.io.Externalizable;
+import java.io.ObjectOutput;
+import java.io.IOException;
+import java.io.ObjectInput;
+public class DefaultConsequenceExceptionHandler implements ConsequenceExceptionHandler, Externalizable {
+
+ public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
+ }
+
+ public void writeExternal(ObjectOutput out) throws IOException {
+ }
+
public void handleException(Activation activation,
WorkingMemory workingMemory,
Exception exception) {
- exception.printStackTrace();
throw new ConsequenceException( exception,
activation.getRule() );
}
Modified: labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/base/DefaultKnowledgeHelper.java
===================================================================
--- labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/base/DefaultKnowledgeHelper.java 2008-03-20 18:57:07 UTC (rev 19163)
+++ labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/base/DefaultKnowledgeHelper.java 2008-03-20 19:32:10 UTC (rev 19164)
@@ -2,13 +2,13 @@
/*
* Copyright 2005 JBoss Inc
- *
+ *
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -27,9 +27,14 @@
import org.drools.spi.KnowledgeHelper;
import org.drools.spi.Tuple;
+import java.io.Externalizable;
+import java.io.IOException;
+import java.io.ObjectOutput;
+import java.io.ObjectInput;
+
public class DefaultKnowledgeHelper
implements
- KnowledgeHelper {
+ KnowledgeHelper, Externalizable {
private static final long serialVersionUID = 400L;
@@ -37,19 +42,38 @@
private GroupElement subrule;
private Activation activation;
private Tuple tuple;
- private final InternalWorkingMemoryActions workingMemory;
+ private InternalWorkingMemoryActions workingMemory;
+ public DefaultKnowledgeHelper() {
+
+ }
public DefaultKnowledgeHelper(final WorkingMemory workingMemory) {
this.workingMemory = (InternalWorkingMemoryActions) workingMemory;
}
+ public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
+ rule = (Rule)in.readObject();
+ subrule = (GroupElement)in.readObject();
+ activation = (Activation)in.readObject();
+ tuple = (Tuple)in.readObject();
+ workingMemory = (InternalWorkingMemoryActions)in.readObject();
+ }
+
+ public void writeExternal(ObjectOutput out) throws IOException {
+ out.writeObject(rule);
+ out.writeObject(subrule);
+ out.writeObject(activation);
+ out.writeObject(tuple);
+ out.writeObject(workingMemory);
+ }
+
public void setActivation(final Activation agendaItem) {
this.rule = agendaItem.getRule();
this.subrule = agendaItem.getSubRule();
this.activation = agendaItem;
this.tuple = agendaItem.getTuple();
}
-
+
public void reset() {
this.rule = null;
this.subrule = null;
@@ -70,7 +94,7 @@
this.rule,
this.activation );
}
-
+
public void insertLogical(final Object object) throws FactException {
insertLogical( object,
false );
@@ -84,7 +108,7 @@
this.rule,
this.activation );
}
-
+
public void update(final FactHandle handle,
final Object newObject) throws FactException {
// only update if this fact exists in the wm
@@ -142,7 +166,7 @@
public void modifyInsert(final FactHandle factHandle,
final Object object) {
- this.workingMemory.modifyInsert( factHandle, object, rule, activation );
+ this.workingMemory.modifyInsert( factHandle, object, rule, activation );
}
public Rule getRule() {
@@ -193,15 +217,15 @@
// public void setFocus(final AgendaGroup focus) {
// this.workingMemory.setFocus( focus );
// }
-
+
public Object get(final Declaration declaration) {
return declaration.getValue( workingMemory, this.tuple.get( declaration ).getObject() );
- }
+ }
public Declaration getDeclaration(final String identifier) {
return (Declaration) this.subrule.getOuterDeclarations().get( identifier );
}
-
+
public void halt() {
this.workingMemory.halt();
}
Modified: labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/base/FieldFactory.java
===================================================================
--- labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/base/FieldFactory.java 2008-03-20 18:57:07 UTC (rev 19163)
+++ labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/base/FieldFactory.java 2008-03-20 19:32:10 UTC (rev 19164)
@@ -18,22 +18,26 @@
import java.math.BigDecimal;
import java.math.BigInteger;
+import java.util.Date;
import org.drools.base.field.BooleanFieldImpl;
import org.drools.base.field.DoubleFieldImpl;
import org.drools.base.field.LongFieldImpl;
import org.drools.base.field.ObjectFieldImpl;
import org.drools.spi.FieldValue;
+import org.drools.util.DateUtils;
public class FieldFactory {
private static final FieldFactory INSTANCE = new FieldFactory();
+ private static final String DEFAULT_FORMAT_MASK = "dd-MMM-yyyy";
+ private static final String DATE_FORMAT_MASK = getDateFormatMask();
+
public static FieldFactory getInstance() {
return FieldFactory.INSTANCE;
}
private FieldFactory() {
-
}
public static FieldValue getFieldValue(final String value,
@@ -80,8 +84,8 @@
} else if ( valueType == ValueType.STRING_TYPE ) {
field = new ObjectFieldImpl( value.intern() );
} else if ( valueType == ValueType.DATE_TYPE ) {
- //MN: I think its fine like this, seems to work !
- field = new ObjectFieldImpl( value );
+ Date date = DateUtils.parseDate( value );
+ field = new ObjectFieldImpl( date );
} else if ( valueType == ValueType.ARRAY_TYPE ) {
//MN: I think its fine like this.
field = new ObjectFieldImpl( value );
@@ -110,49 +114,49 @@
field = new LongFieldImpl( ((String) value).charAt(0) );
} else {
field = new LongFieldImpl( ((Character) value).charValue() );
- }
+ }
} else if ( valueType == ValueType.PBYTE_TYPE ) {
if( value instanceof String ) {
field = new LongFieldImpl( Byte.parseByte( (String) value) );
} else {
field = new LongFieldImpl( ((Number) value).byteValue() );
- }
+ }
} else if ( valueType == ValueType.PSHORT_TYPE ) {
if( value instanceof String ) {
field = new LongFieldImpl( Short.parseShort( (String) value) );
} else {
field = new LongFieldImpl( ((Number) value).shortValue() );
- }
+ }
} else if ( valueType == ValueType.PINTEGER_TYPE ) {
if( value instanceof String ) {
field = new LongFieldImpl( Integer.parseInt( stripNumericType( (String) value ) ) );
} else {
field = new LongFieldImpl( ((Number) value).intValue() );
- }
+ }
} else if ( valueType == ValueType.PLONG_TYPE ) {
if( value instanceof String ) {
field = new LongFieldImpl( Long.parseLong( stripNumericType( (String) value ) ) );
} else {
field = new LongFieldImpl( ((Number) value).longValue() );
- }
+ }
} else if ( valueType == ValueType.PFLOAT_TYPE ) {
if( value instanceof String ) {
field = new DoubleFieldImpl( Float.parseFloat( stripNumericType( (String) value ) ) );
} else {
field = new DoubleFieldImpl( ((Number) value).floatValue() );
- }
+ }
} else if ( valueType == ValueType.PDOUBLE_TYPE ) {
if( value instanceof String ) {
field = new DoubleFieldImpl( Double.parseDouble( stripNumericType( (String) value ) ) );
} else {
field = new DoubleFieldImpl( ((Number) value).doubleValue() );
- }
+ }
} else if ( valueType == ValueType.PBOOLEAN_TYPE ) {
if( value instanceof String ) {
field = new BooleanFieldImpl( Boolean.valueOf( (String) value).booleanValue() );
} else {
field = new BooleanFieldImpl( ((Boolean) value).booleanValue() );
- }
+ }
} else if ( valueType == ValueType.CHAR_TYPE ) {
field = new ObjectFieldImpl( value );
} else if ( valueType == ValueType.BYTE_TYPE ) {
@@ -173,7 +177,12 @@
field = new ObjectFieldImpl( value );
} else if ( valueType == ValueType.DATE_TYPE ) {
//MN: I think its fine like this, seems to work !
- field = new ObjectFieldImpl( value );
+ if( value instanceof String ) {
+ Date date = DateUtils.parseDate( (String) value );
+ field = new ObjectFieldImpl( date );
+ } else {
+ field = new ObjectFieldImpl( value );
+ }
} else if ( valueType == ValueType.ARRAY_TYPE ) {
//MN: I think its fine like this.
field = new ObjectFieldImpl( value );
@@ -234,4 +243,12 @@
return value;
}
+ /** Check for the system property override, if it exists */
+ private static String getDateFormatMask() {
+ String fmt = System.getProperty( "drools.dateformat" );
+ if ( fmt == null ) {
+ fmt = FieldFactory.DEFAULT_FORMAT_MASK;
+ }
+ return fmt;
+ }
}
\ No newline at end of file
Modified: labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/base/FireAllRulesRuleBaseUpdateListener.java
===================================================================
--- labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/base/FireAllRulesRuleBaseUpdateListener.java 2008-03-20 18:57:07 UTC (rev 19163)
+++ labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/base/FireAllRulesRuleBaseUpdateListener.java 2008-03-20 19:32:10 UTC (rev 19164)
@@ -3,7 +3,10 @@
*/
package org.drools.base;
-import java.io.Serializable;
+import java.io.Externalizable;
+import java.io.ObjectInput;
+import java.io.ObjectOutput;
+import java.io.IOException;
import org.drools.StatefulSession;
import org.drools.event.BeforeRuleBaseUnlockedEvent;
@@ -13,13 +16,22 @@
public class FireAllRulesRuleBaseUpdateListener extends DefaultRuleBaseEventListener
implements
RuleBaseUpdateListener,
- Serializable {
+ Externalizable {
private StatefulSession session;
public FireAllRulesRuleBaseUpdateListener() {
+ }
+ public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
+ super.readExternal(in);
+ session = (StatefulSession)in.readObject();
}
+ public void writeExternal(ObjectOutput out) throws IOException {
+ super.writeExternal(out);
+ out.writeObject(session);
+ }
+
public void setSession(StatefulSession session) {
this.session = session;
}
Modified: labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/base/MapGlobalResolver.java
===================================================================
--- labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/base/MapGlobalResolver.java 2008-03-20 18:57:07 UTC (rev 19163)
+++ labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/base/MapGlobalResolver.java 2008-03-20 19:32:10 UTC (rev 19164)
@@ -3,34 +3,45 @@
import java.util.HashMap;
import java.util.Map;
import java.util.Map.Entry;
+import java.io.ObjectInput;
+import java.io.IOException;
+import java.io.ObjectOutput;
import org.drools.spi.GlobalResolver;
public class MapGlobalResolver
implements
GlobalResolver {
-
+
private static final long serialVersionUID = 400L;
-
- private final Map map;
-
+
+ private Map map;
+
public MapGlobalResolver() {
this.map = new HashMap();
}
-
+
public MapGlobalResolver(Map map) {
this.map = map;
- }
+ }
+ public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
+ map = (Map)in.readObject();
+ }
+
+ public void writeExternal(ObjectOutput out) throws IOException {
+ out.writeObject(map);
+ }
+
public Object resolveGlobal(String identifier) {
return this.map.get( identifier );
}
-
+
public void setGlobal(String identifier, Object value) {
this.map.put( identifier,
value );
}
-
+
public Entry[] getGlobals() {
return (Entry[]) this.map.entrySet().toArray(new Entry[this.map.size()]);
}
Modified: labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/base/ModifyInterceptor.java
===================================================================
--- labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/base/ModifyInterceptor.java 2008-03-20 18:57:07 UTC (rev 19163)
+++ labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/base/ModifyInterceptor.java 2008-03-20 19:32:10 UTC (rev 19164)
@@ -1,6 +1,10 @@
package org.drools.base;
import java.io.Serializable;
+import java.io.Externalizable;
+import java.io.ObjectOutput;
+import java.io.IOException;
+import java.io.ObjectInput;
import org.drools.base.mvel.DroolsMVELKnowledgeHelper;
import org.drools.spi.KnowledgeHelper;
@@ -12,9 +16,15 @@
public class ModifyInterceptor
implements
Interceptor,
- Serializable {
+ Externalizable {
private static final long serialVersionUID = 400L;
+ public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
+ }
+
+ public void writeExternal(ObjectOutput out) throws IOException {
+ }
+
public int doBefore(ASTNode node,
VariableResolverFactory factory) {
Object object = ((WithNode) node).getNestedStatement().getValue( null,
Modified: labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/base/ReferenceOriginalGlobalExporter.java
===================================================================
--- labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/base/ReferenceOriginalGlobalExporter.java 2008-03-20 18:57:07 UTC (rev 19163)
+++ labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/base/ReferenceOriginalGlobalExporter.java 2008-03-20 19:32:10 UTC (rev 19164)
@@ -1,5 +1,5 @@
/**
- *
+ *
*/
package org.drools.base;
@@ -7,14 +7,25 @@
import org.drools.spi.GlobalExporter;
import org.drools.spi.GlobalResolver;
+import java.io.ObjectInput;
+import java.io.IOException;
+import java.io.ObjectOutput;
+
/**
* This implementation does nothing other than pass by reference the original GlobalResolver as used in the StatelessSession.
* Care should be taken if you use this strategy, as later executes may change those globals. The GlobalResolver of the StatelessSession
* may also not be serialisable friendly.
*
*/
-public class ReferenceOriginalGlobalExporter implements GlobalExporter {
+public class ReferenceOriginalGlobalExporter implements GlobalExporter {
public GlobalResolver export(WorkingMemory workingMemory) {
return workingMemory.getGlobalResolver();
}
+
+ public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
+ }
+
+ public void writeExternal(ObjectOutput out) throws IOException {
+ }
+
}
\ No newline at end of file
Modified: labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/base/SalienceInteger.java
===================================================================
--- labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/base/SalienceInteger.java 2008-03-20 18:57:07 UTC (rev 19163)
+++ labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/base/SalienceInteger.java 2008-03-20 19:32:10 UTC (rev 19164)
@@ -4,28 +4,43 @@
import org.drools.spi.Salience;
import org.drools.spi.Tuple;
+import java.io.Externalizable;
+import java.io.ObjectInput;
+import java.io.IOException;
+import java.io.ObjectOutput;
+
public class SalienceInteger
implements
- Salience {
-
+ Salience, Externalizable {
+
/**
- *
+ *
*/
private static final long serialVersionUID = 400L;
public static final Salience DEFAULT_SALIENCE = new SalienceInteger( 0 );
-
- private final int value;
+ private int value;
+
+ public SalienceInteger() {
+ }
+
public SalienceInteger(int value) {
this.value = value;
}
+ public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
+ value = in.readInt();
+ }
+
+ public void writeExternal(ObjectOutput out) throws IOException {
+ out.writeInt(value);
+ }
public int getValue(final Tuple tuple,
final WorkingMemory workingMemory) {
return this.value;
}
-
+
public String toString() {
return String.valueOf( this.value );
}
Modified: labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/base/ValueType.java
===================================================================
--- labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/base/ValueType.java 2008-03-20 18:57:07 UTC (rev 19163)
+++ labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/base/ValueType.java 2008-03-20 19:32:10 UTC (rev 19164)
@@ -1,6 +1,9 @@
package org.drools.base;
-import java.io.Serializable;
+import java.io.Externalizable;
+import java.io.ObjectInput;
+import java.io.ObjectOutput;
+import java.io.IOException;
import java.math.BigDecimal;
import java.math.BigInteger;
import java.util.Date;
@@ -10,7 +13,7 @@
public class ValueType
implements
- Serializable {
+ Externalizable {
private static final long serialVersionUID = 400L;
@@ -90,10 +93,14 @@
BigInteger.class,
SimpleValueType.OBJECT );
- private final String name;
- private final Class classType;
- private final int simpleType;
+ private String name;
+ private Class classType;
+ private int simpleType;
+ public ValueType() {
+ this(null, null, 0);
+ }
+
private ValueType(final String name,
final Class classType,
final int simpleType) {
@@ -102,6 +109,17 @@
this.simpleType = simpleType;
}
+ public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
+ name = (String)in.readObject();
+ classType = (Class)in.readObject();
+ simpleType = in.readInt();
+ }
+
+ public void writeExternal(ObjectOutput out) throws IOException {
+ out.writeObject(name);
+ out.writeObject(classType);
+ out.writeInt(simpleType);
+ }
private Object readResolve() throws java.io.ObjectStreamException {
return determineValueType( this.classType );
}
@@ -185,8 +203,12 @@
public boolean equals(final Object object) {
if ( object == this ) {
return true;
+ } else if (object instanceof ValueType) {
+ ValueType that = (ValueType)object;
+ return classType == that.classType &&
+ simpleType == that.simpleType &&
+ (name == that.name || name != null && name.equals(that.name));
}
-
return false;
}
@@ -195,7 +217,9 @@
}
public boolean isNumber() {
- return (this.simpleType == SimpleValueType.INTEGER || this.simpleType == SimpleValueType.DECIMAL || this.simpleType == SimpleValueType.CHAR);
+ return (this.simpleType == SimpleValueType.INTEGER ||
+ this.simpleType == SimpleValueType.DECIMAL ||
+ this.simpleType == SimpleValueType.CHAR);
}
public boolean isIntegerNumber() {
Modified: labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/base/accumulators/AccumulateFunction.java
===================================================================
--- labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/base/accumulators/AccumulateFunction.java 2008-03-20 18:57:07 UTC (rev 19163)
+++ labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/base/accumulators/AccumulateFunction.java 2008-03-20 19:32:10 UTC (rev 19164)
@@ -1,12 +1,12 @@
/*
* Copyright 2007 JBoss Inc
- *
+ *
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -17,15 +17,15 @@
*/
package org.drools.base.accumulators;
-import java.io.Serializable;
+import java.io.Externalizable;
/**
* An interface for accumulate external function implementations
- *
+ *
* @author etirelli
*
*/
-public interface AccumulateFunction extends Serializable {
+public interface AccumulateFunction extends Externalizable {
/**
* Creates and returns a new context object
@@ -59,7 +59,7 @@
/**
* Returns the current value in this accumulation session
- *
+ *
* @param context
* @return
* @throws Exception
@@ -68,7 +68,7 @@
/**
* True if the function supports reverse. False otherwise.
- *
+ *
* @return
*/
public boolean supportsReverse();
Modified: labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/base/accumulators/AverageAccumulateFunction.java
===================================================================
--- labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/base/accumulators/AverageAccumulateFunction.java 2008-03-20 18:57:07 UTC (rev 19163)
+++ labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/base/accumulators/AverageAccumulateFunction.java 2008-03-20 19:32:10 UTC (rev 19164)
@@ -1,12 +1,12 @@
/*
* Copyright 2007 JBoss Inc
- *
+ *
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -17,18 +17,41 @@
*/
package org.drools.base.accumulators;
+import java.io.ObjectOutput;
+import java.io.ObjectInput;
+import java.io.IOException;
+import java.io.Externalizable;
/**
* An implementation of an accumulator capable of calculating average values
- *
+ *
* @author etirelli
*
*/
public class AverageAccumulateFunction implements AccumulateFunction {
- protected static class AverageData {
+ public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
+
+ }
+
+ public void writeExternal(ObjectOutput out) throws IOException {
+
+ }
+
+ public static class AverageData implements Externalizable {
public int count = 0;
public double total = 0;
+
+ public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
+ count = in.readInt();
+ total = in.readDouble();
+ }
+
+ public void writeExternal(ObjectOutput out) throws IOException {
+ out.writeInt(count);
+ out.writeDouble(total);
+ }
+
}
/* (non-Javadoc)
Modified: labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/base/accumulators/CountAccumulateFunction.java
===================================================================
--- labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/base/accumulators/CountAccumulateFunction.java 2008-03-20 18:57:07 UTC (rev 19163)
+++ labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/base/accumulators/CountAccumulateFunction.java 2008-03-20 19:32:10 UTC (rev 19164)
@@ -1,12 +1,12 @@
/*
* Copyright 2007 JBoss Inc
- *
+ *
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -17,17 +17,38 @@
*/
package org.drools.base.accumulators;
+import java.io.ObjectOutput;
+import java.io.ObjectInput;
+import java.io.IOException;
+import java.io.Externalizable;
/**
* An implementation of an accumulator capable of counting occurences
- *
+ *
* @author etirelli
*
*/
public class CountAccumulateFunction implements AccumulateFunction {
- protected static class CountData {
+ public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
+
+ }
+
+ public void writeExternal(ObjectOutput out) throws IOException {
+
+ }
+
+ protected static class CountData implements Externalizable {
public long count = 0;
+
+ public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
+ count = in.readLong();
+ }
+
+ public void writeExternal(ObjectOutput out) throws IOException {
+ out.writeLong(count);
+ }
+
}
/* (non-Javadoc)
Modified: labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/base/accumulators/JavaAccumulatorFunctionExecutor.java
===================================================================
--- labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/base/accumulators/JavaAccumulatorFunctionExecutor.java 2008-03-20 18:57:07 UTC (rev 19163)
+++ labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/base/accumulators/JavaAccumulatorFunctionExecutor.java 2008-03-20 19:32:10 UTC (rev 19164)
@@ -1,12 +1,12 @@
/*
* Copyright 2007 JBoss Inc
- *
+ *
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -24,9 +24,13 @@
import org.drools.spi.ReturnValueExpression;
import org.drools.spi.Tuple;
+import java.io.ObjectOutput;
+import java.io.IOException;
+import java.io.ObjectInput;
+
/**
* An MVEL accumulator function executor implementation
- *
+ *
* @author etirelli
*/
public class JavaAccumulatorFunctionExecutor
@@ -36,13 +40,27 @@
private static final long serialVersionUID = 400L;
private ReturnValueExpression expression;
- private final AccumulateFunction function;
+ private AccumulateFunction function;
+ public JavaAccumulatorFunctionExecutor() {
+
+ }
+
public JavaAccumulatorFunctionExecutor(final AccumulateFunction function) {
super();
this.function = function;
}
+ public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
+ expression = (ReturnValueExpression)in.readObject();
+ function = (AccumulateFunction)in.readObject();
+ }
+
+ public void writeExternal(ObjectOutput out) throws IOException {
+ out.writeObject(expression);
+ out.writeObject(function);
+ }
+
/* (non-Javadoc)
* @see org.drools.spi.Accumulator#createContext()
*/
@@ -122,7 +140,7 @@
}
public Object createWorkingMemoryContext() {
- // no working memory context needed
+ // no working memory context needed
return null;
}
}
Modified: labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/base/accumulators/MVELAccumulatorFunctionExecutor.java
===================================================================
--- labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/base/accumulators/MVELAccumulatorFunctionExecutor.java 2008-03-20 18:57:07 UTC (rev 19163)
+++ labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/base/accumulators/MVELAccumulatorFunctionExecutor.java 2008-03-20 19:32:10 UTC (rev 19164)
@@ -1,12 +1,12 @@
/*
* Copyright 2007 JBoss Inc
- *
+ *
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -18,6 +18,9 @@
package org.drools.base.accumulators;
import java.io.Serializable;
+import java.io.ObjectInput;
+import java.io.ObjectOutput;
+import java.io.IOException;
import java.util.Map;
import org.drools.WorkingMemory;
@@ -30,7 +33,7 @@
/**
* An MVEL accumulator function executor implementation
- *
+ *
* @author etirelli
*/
public class MVELAccumulatorFunctionExecutor
@@ -40,10 +43,14 @@
private static final long serialVersionUID = 400L;
private final Object dummy = new Object();
- private final DroolsMVELFactory model;
- private final Serializable expression;
- private final AccumulateFunction function;
+ private DroolsMVELFactory model;
+ private Serializable expression;
+ private AccumulateFunction function;
+ public MVELAccumulatorFunctionExecutor() {
+
+ }
+
public MVELAccumulatorFunctionExecutor(final DroolsMVELFactory factory,
final Serializable expression,
final AccumulateFunction function) {
@@ -53,6 +60,18 @@
this.function = function;
}
+ public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
+ model = (DroolsMVELFactory)in.readObject();
+ expression = (Serializable)in.readObject();
+ function = (AccumulateFunction)in.readObject();
+ }
+
+ public void writeExternal(ObjectOutput out) throws IOException {
+ out.writeObject(model);
+ out.writeObject(expression);
+ out.writeObject(function);
+ }
+
/* (non-Javadoc)
* @see org.drools.spi.Accumulator#createContext()
*/
Modified: labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/base/accumulators/MaxAccumulateFunction.java
===================================================================
--- labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/base/accumulators/MaxAccumulateFunction.java 2008-03-20 18:57:07 UTC (rev 19163)
+++ labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/base/accumulators/MaxAccumulateFunction.java 2008-03-20 19:32:10 UTC (rev 19164)
@@ -1,12 +1,12 @@
/*
* Copyright 2007 JBoss Inc
- *
+ *
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -17,10 +17,13 @@
*/
package org.drools.base.accumulators;
+import java.io.IOException;
+import java.io.ObjectInput;
+import java.io.ObjectOutput;
/**
* An implementation of an accumulator capable of calculating maximum values
- *
+ *
* @author etirelli
*
*/
@@ -30,6 +33,13 @@
public double max = Double.MIN_VALUE;
}
+ public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
+
+ }
+
+ public void writeExternal(ObjectOutput out) throws IOException {
+
+ }
/* (non-Javadoc)
* @see org.drools.base.accumulators.AccumulateFunction#createContext()
*/
Modified: labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/base/accumulators/MinAccumulateFunction.java
===================================================================
--- labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/base/accumulators/MinAccumulateFunction.java 2008-03-20 18:57:07 UTC (rev 19163)
+++ labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/base/accumulators/MinAccumulateFunction.java 2008-03-20 19:32:10 UTC (rev 19164)
@@ -1,12 +1,12 @@
/*
* Copyright 2007 JBoss Inc
- *
+ *
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -17,15 +17,26 @@
*/
package org.drools.base.accumulators;
+import java.io.ObjectOutput;
+import java.io.ObjectInput;
+import java.io.IOException;
/**
* An implementation of an accumulator capable of calculating minimun values
- *
+ *
* @author etirelli
*
*/
public class MinAccumulateFunction implements AccumulateFunction {
+ public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
+
+ }
+
+ public void writeExternal(ObjectOutput out) throws IOException {
+
+ }
+
protected static class MaxData {
public double min = Double.MAX_VALUE;
}
Modified: labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/base/accumulators/SumAccumulateFunction.java
===================================================================
--- labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/base/accumulators/SumAccumulateFunction.java 2008-03-20 18:57:07 UTC (rev 19163)
+++ labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/base/accumulators/SumAccumulateFunction.java 2008-03-20 19:32:10 UTC (rev 19164)
@@ -1,12 +1,12 @@
/*
* Copyright 2007 JBoss Inc
- *
+ *
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -17,17 +17,38 @@
*/
package org.drools.base.accumulators;
+import java.io.ObjectOutput;
+import java.io.IOException;
+import java.io.ObjectInput;
+import java.io.Externalizable;
/**
* An implementation of an accumulator capable of calculating sum of values
- *
+ *
* @author etirelli
*
*/
public class SumAccumulateFunction implements AccumulateFunction {
- protected static class SumData {
+ public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
+
+ }
+
+ public void writeExternal(ObjectOutput out) throws IOException {
+
+ }
+
+ protected static class SumData implements Externalizable {
public double total = 0;
+
+ public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
+ total = in.readDouble();
+ }
+
+ public void writeExternal(ObjectOutput out) throws IOException {
+ out.writeDouble(total);
+ }
+
}
/* (non-Javadoc)
Modified: labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/base/dataproviders/MVELDataProvider.java
===================================================================
--- labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/base/dataproviders/MVELDataProvider.java 2008-03-20 18:57:07 UTC (rev 19163)
+++ labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/base/dataproviders/MVELDataProvider.java 2008-03-20 19:32:10 UTC (rev 19164)
@@ -1,6 +1,10 @@
package org.drools.base.dataproviders;
import java.io.Serializable;
+import java.io.Externalizable;
+import java.io.ObjectOutput;
+import java.io.IOException;
+import java.io.ObjectInput;
import java.util.Collection;
import java.util.Collections;
import java.util.Iterator;
@@ -11,29 +15,44 @@
import org.drools.spi.DataProvider;
import org.drools.spi.PropagationContext;
import org.drools.spi.Tuple;
+import org.drools.util.ArrayIterator;
import org.mvel.MVEL;
public class MVELDataProvider
implements
DataProvider,
- Serializable {
+ Externalizable {
private static final long serialVersionUID = 1901006343031798173L;
-
- private final Serializable expression;
- private final DroolsMVELFactory prototype;
+ private Serializable expression;
+ private DroolsMVELFactory prototype;
+
+ public MVELDataProvider() {
+
+ }
+
public MVELDataProvider(final Serializable expression,
final DroolsMVELFactory factory) {
this.expression = expression;
this.prototype = factory;
}
+ public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
+ expression = (Serializable)in.readObject();
+ prototype = (DroolsMVELFactory)in.readObject();
+ }
+
+ public void writeExternal(ObjectOutput out) throws IOException {
+ out.writeObject(expression);
+ out.writeObject(prototype);
+ }
+
public Declaration[] getRequiredDeclarations() {
return new Declaration[]{};
//return factory.getRequiredDeclarations();
}
-
+
public Object createContext() {
return this.prototype.clone();
}
@@ -43,7 +62,7 @@
final PropagationContext ctx,
final Object executionContext ) {
DroolsMVELFactory factory = (DroolsMVELFactory) executionContext;
-
+
factory.setContext( tuple,
null,
null,
@@ -52,15 +71,18 @@
//this.expression.
final Object result = MVEL.executeExpression( this.expression,
- factory );
- if ( result instanceof Collection ) {
+ factory );
+
+ if ( result == null ) {
+ return Collections.EMPTY_LIST.iterator();
+ } else if ( result instanceof Collection ) {
return ((Collection) result).iterator();
} else if ( result instanceof Iterator ) {
return (Iterator) result;
- } else if ( result != null ){
+ } else if ( result.getClass().isArray() ) {
+ return new ArrayIterator( result );
+ } else {
return Collections.singletonList( result ).iterator();
- } else {
- return Collections.EMPTY_LIST.iterator();
}
}
}
Modified: labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/base/evaluators/AfterEvaluatorDefinition.java
===================================================================
--- labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/base/evaluators/AfterEvaluatorDefinition.java 2008-03-20 18:57:07 UTC (rev 19163)
+++ labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/base/evaluators/AfterEvaluatorDefinition.java 2008-03-20 19:32:10 UTC (rev 19164)
@@ -1,12 +1,12 @@
/*
* Copyright 2007 JBoss Inc
- *
+ *
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -20,6 +20,9 @@
import java.util.Collections;
import java.util.HashMap;
import java.util.Map;
+import java.io.ObjectInput;
+import java.io.IOException;
+import java.io.ObjectOutput;
import org.drools.RuntimeDroolsException;
import org.drools.base.BaseEvaluator;
@@ -35,7 +38,7 @@
/**
* The implementation of the 'after' evaluator definition
- *
+ *
* @author etirelli
*/
public class AfterEvaluatorDefinition
@@ -51,6 +54,14 @@
private Map<String, Evaluator> cache = Collections.emptyMap();
+ public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
+ cache = (Map<String, Evaluator>)in.readObject();
+ }
+
+ public void writeExternal(ObjectOutput out) throws IOException {
+ out.writeObject(cache);
+ }
+
/**
* @inheridDoc
*/
@@ -135,6 +146,9 @@
private long initRange;
private long finalRange;
+ public AfterEvaluator() {
+ }
+
public AfterEvaluator(final ValueType type,
final boolean isNegated,
final String parameters) {
@@ -143,6 +157,18 @@
this.parseParameters( parameters );
}
+ public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
+ super.readExternal(in);
+ initRange = in.readLong();
+ finalRange = in.readLong();
+ }
+
+ public void writeExternal(ObjectOutput out) throws IOException {
+ super.writeExternal(out);
+ out.writeLong(initRange);
+ out.writeLong(finalRange);
+ }
+
@Override
public Object prepareObject(InternalFactHandle handle) {
return handle;
@@ -162,7 +188,7 @@
return false;
}
long dist = ((EventFactHandle) ((ObjectVariableContextEntry) context).right).getStartTimestamp() - ((EventFactHandle) left).getEndTimestamp();
- return this.getOperator().isNegated() ^ ( dist >= this.initRange && dist <= this.finalRange );
+ return this.getOperator().isNegated() ^ ( dist >= this.initRange && dist <= this.finalRange );
}
public boolean evaluateCachedLeft(InternalWorkingMemory workingMemory,
@@ -219,9 +245,9 @@
}
/**
- * This methods tries to parse the string of parameters to customize
+ * This methods tries to parse the string of parameters to customize
* the evaluator.
- *
+ *
* @param parameters
*/
private void parseParameters(String parameters) {
Modified: labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/base/evaluators/BeforeEvaluatorDefinition.java
===================================================================
--- labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/base/evaluators/BeforeEvaluatorDefinition.java 2008-03-20 18:57:07 UTC (rev 19163)
+++ labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/base/evaluators/BeforeEvaluatorDefinition.java 2008-03-20 19:32:10 UTC (rev 19164)
@@ -1,12 +1,12 @@
/*
* Copyright 2007 JBoss Inc
- *
+ *
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -20,6 +20,9 @@
import java.util.Collections;
import java.util.HashMap;
import java.util.Map;
+import java.io.ObjectInput;
+import java.io.IOException;
+import java.io.ObjectOutput;
import org.drools.RuntimeDroolsException;
import org.drools.base.BaseEvaluator;
@@ -35,7 +38,7 @@
/**
* The implementation of the 'before' evaluator definition
- *
+ *
* @author mgroch
*/
public class BeforeEvaluatorDefinition
@@ -46,11 +49,19 @@
false );
public static final Operator NOT_BEFORE = Operator.addOperatorToRegistry( "before",
true );
-
+
private static final String[] SUPPORTED_IDS = { BEFORE.getOperatorString() };
-
+
private Map<String, BeforeEvaluator> cache = Collections.emptyMap();
+ public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
+ cache = (Map<String, BeforeEvaluator>)in.readObject();
+ }
+
+ public void writeExternal(ObjectOutput out) throws IOException {
+ out.writeObject(cache);
+ }
+
/**
* @inheridDoc
*/
@@ -131,10 +142,13 @@
*/
public static class BeforeEvaluator extends BaseEvaluator {
private static final long serialVersionUID = -4778826341073034320L;
-
+
private long initRange;
private long finalRange;
+ public BeforeEvaluator() {
+ }
+
public BeforeEvaluator(final ValueType type,
final boolean isNegated,
final String parameters) {
@@ -142,12 +156,24 @@
isNegated ? NOT_BEFORE : BEFORE );
this.parseParameters( parameters );
}
-
+
+ public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
+ super.readExternal(in);
+ initRange = in.readLong();
+ finalRange = in.readLong();
+ }
+
+ public void writeExternal(ObjectOutput out) throws IOException {
+ super.writeExternal(out);
+ out.writeLong(initRange);
+ out.writeLong(finalRange);
+ }
+
@Override
public Object prepareObject(InternalFactHandle handle) {
return handle;
}
-
+
public boolean evaluate(InternalWorkingMemory workingMemory,
final Extractor extractor,
final Object object1,
@@ -161,7 +187,7 @@
if ( context.rightNull ) {
return false;
}
- long dist = ((EventFactHandle) left ).getStartTimestamp() -
+ long dist = ((EventFactHandle) left ).getStartTimestamp() -
((EventFactHandle)((ObjectVariableContextEntry) context).right).getEndTimestamp();
return this.getOperator().isNegated() ^ (dist >= this.initRange && dist <= this.finalRange);
}
@@ -173,7 +199,7 @@
right ) ) {
return false;
}
- long dist = ((EventFactHandle) ((ObjectVariableContextEntry) context).left).getStartTimestamp() -
+ long dist = ((EventFactHandle) ((ObjectVariableContextEntry) context).left).getStartTimestamp() -
((EventFactHandle) right ).getEndTimestamp();
return this.getOperator().isNegated() ^ ( dist >= this.initRange && dist <= this.finalRange );
@@ -221,9 +247,9 @@
}
/**
- * This methods tries to parse the string of parameters to customize
+ * This methods tries to parse the string of parameters to customize
* the evaluator.
- *
+ *
* @param parameters
*/
private void parseParameters(String parameters) {
Modified: labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/base/evaluators/CoincidesEvaluatorDefinition.java
===================================================================
--- labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/base/evaluators/CoincidesEvaluatorDefinition.java 2008-03-20 18:57:07 UTC (rev 19163)
+++ labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/base/evaluators/CoincidesEvaluatorDefinition.java 2008-03-20 19:32:10 UTC (rev 19164)
@@ -1,12 +1,12 @@
/*
* Copyright 2007 JBoss Inc
- *
+ *
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -20,6 +20,9 @@
import java.util.Collections;
import java.util.HashMap;
import java.util.Map;
+import java.io.ObjectInput;
+import java.io.IOException;
+import java.io.ObjectOutput;
import org.drools.RuntimeDroolsException;
import org.drools.base.BaseEvaluator;
@@ -35,7 +38,7 @@
/**
* The implementation of the 'coincides' evaluator definition
- *
+ *
* @author mgroch
*/
public class CoincidesEvaluatorDefinition
@@ -46,11 +49,19 @@
false );
public static final Operator COINCIDES_NOT = Operator.addOperatorToRegistry( "coincides",
true );
-
+
private static final String[] SUPPORTED_IDS = { COINCIDES.getOperatorString() };
-
+
private Map<String, CoincidesEvaluator> cache = Collections.emptyMap();
+ public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
+ cache = (Map<String, CoincidesEvaluator>)in.readObject();
+ }
+
+ public void writeExternal(ObjectOutput out) throws IOException {
+ out.writeObject(cache);
+ }
+
/**
* @inheridDoc
*/
@@ -129,12 +140,15 @@
/**
* Implements the 'coincides' evaluator itself
*/
- public static class CoincidesEvaluator extends BaseEvaluator {
+ public static class CoincidesEvaluator extends BaseEvaluator {
private static final long serialVersionUID = 6031520837249122183L;
-
+
private long startDev;
private long endDev;
+ public CoincidesEvaluator() {
+ }
+
public CoincidesEvaluator(final ValueType type,
final boolean isNegated,
final String parameters) {
@@ -142,12 +156,24 @@
isNegated ? COINCIDES_NOT : COINCIDES );
this.parseParameters( parameters );
}
-
+
+ public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
+ super.readExternal(in);
+ startDev = in.readLong();
+ endDev = in.readLong();
+ }
+
+ public void writeExternal(ObjectOutput out) throws IOException {
+ super.writeExternal(out);
+ out.writeLong(startDev);
+ out.writeLong(endDev);
+ }
+
@Override
public Object prepareObject(InternalFactHandle handle) {
return handle;
}
-
+
public boolean evaluate(InternalWorkingMemory workingMemory,
final Extractor extractor,
final Object object1,
@@ -161,9 +187,9 @@
if ( context.rightNull ) {
return false;
}
- long distStart = Math.abs(((EventFactHandle)((ObjectVariableContextEntry) context).right).getStartTimestamp() -
+ long distStart = Math.abs(((EventFactHandle)((ObjectVariableContextEntry) context).right).getStartTimestamp() -
((EventFactHandle) left ).getStartTimestamp());
- long distEnd = Math.abs(((EventFactHandle)((ObjectVariableContextEntry) context).right).getEndTimestamp() -
+ long distEnd = Math.abs(((EventFactHandle)((ObjectVariableContextEntry) context).right).getEndTimestamp() -
((EventFactHandle) left ).getEndTimestamp());
return this.getOperator().isNegated() ^ ( distStart <= this.startDev && distEnd <= this.endDev);
}
@@ -175,9 +201,9 @@
right ) ) {
return false;
}
- long distStart = Math.abs(((EventFactHandle) right ).getStartTimestamp() -
+ long distStart = Math.abs(((EventFactHandle) right ).getStartTimestamp() -
((EventFactHandle) ((ObjectVariableContextEntry) context).left).getStartTimestamp());
- long distEnd = Math.abs(((EventFactHandle) right ).getEndTimestamp() -
+ long distEnd = Math.abs(((EventFactHandle) right ).getEndTimestamp() -
((EventFactHandle) ((ObjectVariableContextEntry) context).left).getEndTimestamp());
return this.getOperator().isNegated() ^ ( distStart <= this.startDev && distEnd <= this.endDev );
}
@@ -225,9 +251,9 @@
}
/**
- * This methods tries to parse the string of parameters to customize
+ * This methods tries to parse the string of parameters to customize
* the evaluator.
- *
+ *
* @param parameters
*/
private void parseParameters(String parameters) {
Modified: labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/base/evaluators/ComparableEvaluatorsDefinition.java
===================================================================
--- labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/base/evaluators/ComparableEvaluatorsDefinition.java 2008-03-20 18:57:07 UTC (rev 19163)
+++ labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/base/evaluators/ComparableEvaluatorsDefinition.java 2008-03-20 19:32:10 UTC (rev 19164)
@@ -1,12 +1,12 @@
/*
* Copyright 2007 JBoss Inc
- *
+ *
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -17,13 +17,15 @@
*/
package org.drools.base.evaluators;
+import java.io.IOException;
+import java.io.ObjectInput;
+import java.io.ObjectOutput;
import java.math.BigDecimal;
import java.math.BigInteger;
import java.util.Comparator;
import java.util.Date;
import org.drools.base.BaseEvaluator;
-import org.drools.base.ShadowProxy;
import org.drools.base.ValueType;
import org.drools.common.InternalWorkingMemory;
import org.drools.rule.VariableRestriction.CharVariableContextEntry;
@@ -37,13 +39,13 @@
import org.drools.util.DateUtils;
/**
- * This class defines all the comparable built in
+ * This class defines all the comparable built in
* evaluators like >, >=, etc.
- *
+ *
* @author etirelli
*/
public class ComparableEvaluatorsDefinition implements EvaluatorDefinition {
-
+
private static final String[] SUPPORTED_IDS = { Operator.LESS.getOperatorString(), Operator.LESS_OR_EQUAL.getOperatorString(),
Operator.GREATER.getOperatorString(), Operator.GREATER_OR_EQUAL.getOperatorString() };
private EvaluatorCache evaluators = new EvaluatorCache() {
@@ -123,7 +125,15 @@
addEvaluator( ValueType.PSHORT_TYPE, Operator.GREATER_OR_EQUAL, ShortGreaterOrEqualEvaluator.INSTANCE );
}
};
-
+
+ public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
+ evaluators = (EvaluatorCache)in.readObject();
+ }
+
+ public void writeExternal(ObjectOutput out) throws IOException {
+ out.writeObject(evaluators);
+ }
+
/**
* @inheridDoc
*/
@@ -147,8 +157,8 @@
final String operatorId,
final boolean isNegated,
final String parameterText) {
- return this.evaluators.getEvaluator( type,
- Operator.determineOperator( operatorId,
+ return this.evaluators.getEvaluator( type,
+ Operator.determineOperator( operatorId,
isNegated ) );
}
@@ -167,19 +177,19 @@
public boolean supportsType(ValueType type) {
return this.evaluators.supportsType( type );
}
-
+
/* *********************************************************
* Evaluator Implementations
* *********************************************************
*/
- static class BigDecimalLessEvaluator extends BaseEvaluator {
+ public static class BigDecimalLessEvaluator extends BaseEvaluator {
/**
- *
+ *
*/
private static final long serialVersionUID = 400L;
public final static Evaluator INSTANCE = new BigDecimalLessEvaluator();
- private BigDecimalLessEvaluator() {
+ public BigDecimalLessEvaluator() {
super( ValueType.BIG_DECIMAL_TYPE,
Operator.LESS );
}
@@ -191,7 +201,7 @@
return false;
}
final BigDecimal comp = (BigDecimal) extractor.getValue( workingMemory, object1 );
- return comp.compareTo( (BigDecimal) object2.getValue() ) < 0;
+ return comp.compareTo( object2.getBigDecimalValue() ) < 0;
}
public boolean evaluateCachedRight(InternalWorkingMemory workingMemory,
@@ -228,14 +238,14 @@
}
}
- static class BigDecimalLessOrEqualEvaluator extends BaseEvaluator {
+ public static class BigDecimalLessOrEqualEvaluator extends BaseEvaluator {
/**
- *
+ *
*/
private static final long serialVersionUID = 400L;
public final static Evaluator INSTANCE = new BigDecimalLessOrEqualEvaluator();
- private BigDecimalLessOrEqualEvaluator() {
+ public BigDecimalLessOrEqualEvaluator() {
super( ValueType.BIG_DECIMAL_TYPE,
Operator.LESS_OR_EQUAL );
}
@@ -247,7 +257,7 @@
return false;
}
final BigDecimal comp = (BigDecimal) extractor.getValue( workingMemory, object1 );
- return comp.compareTo( (BigDecimal) object2.getValue() ) <= 0;
+ return comp.compareTo( object2.getBigDecimalValue() ) <= 0;
}
public boolean evaluateCachedRight(InternalWorkingMemory workingMemory,
@@ -284,14 +294,14 @@
}
}
- static class BigDecimalGreaterEvaluator extends BaseEvaluator {
+ public static class BigDecimalGreaterEvaluator extends BaseEvaluator {
/**
- *
+ *
*/
private static final long serialVersionUID = 400L;
public final static Evaluator INSTANCE = new BigDecimalGreaterEvaluator();
- private BigDecimalGreaterEvaluator() {
+ public BigDecimalGreaterEvaluator() {
super( ValueType.BIG_DECIMAL_TYPE,
Operator.GREATER );
}
@@ -303,7 +313,7 @@
return false;
}
final BigDecimal comp = (BigDecimal) extractor.getValue( workingMemory, object1 );
- return comp.compareTo( (BigDecimal) object2.getValue() ) > 0;
+ return comp.compareTo( object2.getBigDecimalValue() ) > 0;
}
public boolean evaluateCachedRight(InternalWorkingMemory workingMemory,
@@ -340,14 +350,14 @@
}
}
- static class BigDecimalGreaterOrEqualEvaluator extends BaseEvaluator {
+ public static class BigDecimalGreaterOrEqualEvaluator extends BaseEvaluator {
/**
- *
+ *
*/
private static final long serialVersionUID = 400L;
private final static Evaluator INSTANCE = new BigDecimalGreaterOrEqualEvaluator();
- private BigDecimalGreaterOrEqualEvaluator() {
+ public BigDecimalGreaterOrEqualEvaluator() {
super( ValueType.BIG_DECIMAL_TYPE,
Operator.GREATER_OR_EQUAL );
}
@@ -359,7 +369,7 @@
return false;
}
final BigDecimal comp = (BigDecimal) extractor.getValue( workingMemory, object1 );
- return comp.compareTo( (BigDecimal) object2.getValue() ) >= 0;
+ return comp.compareTo( object2.getBigDecimalValue() ) >= 0;
}
public boolean evaluateCachedRight(InternalWorkingMemory workingMemory,
@@ -396,14 +406,14 @@
}
}
- static class BigIntegerLessEvaluator extends BaseEvaluator {
+ public static class BigIntegerLessEvaluator extends BaseEvaluator {
/**
- *
+ *
*/
private static final long serialVersionUID = 400L;
public final static Evaluator INSTANCE = new BigIntegerLessEvaluator();
- private BigIntegerLessEvaluator() {
+ public BigIntegerLessEvaluator() {
super( ValueType.BIG_INTEGER_TYPE,
Operator.LESS );
}
@@ -415,7 +425,7 @@
return false;
}
final BigInteger comp = (BigInteger) extractor.getValue( workingMemory, object1 );
- return comp.compareTo( (BigInteger) object2.getValue() ) < 0;
+ return comp.compareTo( object2.getBigIntegerValue() ) < 0;
}
public boolean evaluateCachedRight(InternalWorkingMemory workingMemory,
@@ -452,9 +462,9 @@
}
}
- static class BigIntegerLessOrEqualEvaluator extends BaseEvaluator {
+ public static class BigIntegerLessOrEqualEvaluator extends BaseEvaluator {
/**
- *
+ *
*/
private static final long serialVersionUID = 400L;
public final static Evaluator INSTANCE = new BigIntegerLessOrEqualEvaluator();
@@ -471,7 +481,7 @@
return false;
}
final BigInteger comp = (BigInteger) extractor.getValue( workingMemory, object1 );
- return comp.compareTo( (BigInteger) object2.getValue() ) <= 0;
+ return comp.compareTo( object2.getBigIntegerValue() ) <= 0;
}
public boolean evaluateCachedRight(InternalWorkingMemory workingMemory,
@@ -508,14 +518,14 @@
}
}
- static class BigIntegerGreaterEvaluator extends BaseEvaluator {
+ public static class BigIntegerGreaterEvaluator extends BaseEvaluator {
/**
- *
+ *
*/
private static final long serialVersionUID = 400L;
public final static Evaluator INSTANCE = new BigIntegerGreaterEvaluator();
- private BigIntegerGreaterEvaluator() {
+ public BigIntegerGreaterEvaluator() {
super( ValueType.BIG_INTEGER_TYPE,
Operator.GREATER );
}
@@ -527,7 +537,7 @@
return false;
}
final BigInteger comp = (BigInteger) extractor.getValue( workingMemory, object1 );
- return comp.compareTo( (BigInteger) object2.getValue() ) > 0;
+ return comp.compareTo( object2.getBigIntegerValue() ) > 0;
}
public boolean evaluateCachedRight(InternalWorkingMemory workingMemory,
@@ -564,14 +574,14 @@
}
}
- static class BigIntegerGreaterOrEqualEvaluator extends BaseEvaluator {
+ public static class BigIntegerGreaterOrEqualEvaluator extends BaseEvaluator {
/**
- *
+ *
*/
private static final long serialVersionUID = 400L;
private final static Evaluator INSTANCE = new BigIntegerGreaterOrEqualEvaluator();
- private BigIntegerGreaterOrEqualEvaluator() {
+ public BigIntegerGreaterOrEqualEvaluator() {
super( ValueType.BIG_INTEGER_TYPE,
Operator.GREATER_OR_EQUAL );
}
@@ -583,7 +593,7 @@
return false;
}
final BigInteger comp = (BigInteger) extractor.getValue( workingMemory, object1 );
- return comp.compareTo( (BigInteger) object2.getValue() ) >= 0;
+ return comp.compareTo( object2.getBigIntegerValue() ) >= 0;
}
public boolean evaluateCachedRight(InternalWorkingMemory workingMemory,
@@ -619,15 +629,15 @@
return "BigInteger >=";
}
}
-
- static class ByteLessEvaluator extends BaseEvaluator {
+
+ public static class ByteLessEvaluator extends BaseEvaluator {
/**
- *
+ *
*/
private static final long serialVersionUID = 400L;
public final static Evaluator INSTANCE = new ByteLessEvaluator();
- private ByteLessEvaluator() {
+ public ByteLessEvaluator() {
super( ValueType.PBYTE_TYPE,
Operator.LESS );
}
@@ -672,14 +682,14 @@
}
}
- static class ByteLessOrEqualEvaluator extends BaseEvaluator {
+ public static class ByteLessOrEqualEvaluator extends BaseEvaluator {
/**
- *
+ *
*/
private static final long serialVersionUID = 400L;
public final static Evaluator INSTANCE = new ByteLessOrEqualEvaluator();
- private ByteLessOrEqualEvaluator() {
+ public ByteLessOrEqualEvaluator() {
super( ValueType.PBYTE_TYPE,
Operator.LESS_OR_EQUAL );
}
@@ -724,14 +734,14 @@
}
}
- static class ByteGreaterEvaluator extends BaseEvaluator {
+ public static class ByteGreaterEvaluator extends BaseEvaluator {
/**
- *
+ *
*/
private static final long serialVersionUID = 400L;
public final static Evaluator INSTANCE = new ByteGreaterEvaluator();
- private ByteGreaterEvaluator() {
+ public ByteGreaterEvaluator() {
super( ValueType.PBYTE_TYPE,
Operator.GREATER );
}
@@ -776,14 +786,14 @@
}
}
- static class ByteGreaterOrEqualEvaluator extends BaseEvaluator {
+ public static class ByteGreaterOrEqualEvaluator extends BaseEvaluator {
/**
- *
+ *
*/
private static final long serialVersionUID = 400L;
private final static Evaluator INSTANCE = new ByteGreaterOrEqualEvaluator();
- private ByteGreaterOrEqualEvaluator() {
+ public ByteGreaterOrEqualEvaluator() {
super( ValueType.PBYTE_TYPE,
Operator.GREATER_OR_EQUAL );
}
@@ -828,14 +838,14 @@
}
}
- static class CharacterLessEvaluator extends BaseEvaluator {
+ public static class CharacterLessEvaluator extends BaseEvaluator {
/**
- *
+ *
*/
private static final long serialVersionUID = 400L;
public final static Evaluator INSTANCE = new CharacterLessEvaluator();
- private CharacterLessEvaluator() {
+ public CharacterLessEvaluator() {
super( ValueType.PCHAR_TYPE,
Operator.LESS );
}
@@ -880,14 +890,14 @@
}
}
- static class CharacterLessOrEqualEvaluator extends BaseEvaluator {
+ public static class CharacterLessOrEqualEvaluator extends BaseEvaluator {
/**
- *
+ *
*/
private static final long serialVersionUID = 400L;
public final static Evaluator INSTANCE = new CharacterLessOrEqualEvaluator();
- private CharacterLessOrEqualEvaluator() {
+ public CharacterLessOrEqualEvaluator() {
super( ValueType.PCHAR_TYPE,
Operator.LESS_OR_EQUAL );
}
@@ -932,14 +942,14 @@
}
}
- static class CharacterGreaterEvaluator extends BaseEvaluator {
+ public static class CharacterGreaterEvaluator extends BaseEvaluator {
/**
- *
+ *
*/
private static final long serialVersionUID = 400L;
public final static Evaluator INSTANCE = new CharacterGreaterEvaluator();
- private CharacterGreaterEvaluator() {
+ public CharacterGreaterEvaluator() {
super( ValueType.PCHAR_TYPE,
Operator.GREATER );
}
@@ -984,14 +994,14 @@
}
}
- static class CharacterGreaterOrEqualEvaluator extends BaseEvaluator {
+ public static class CharacterGreaterOrEqualEvaluator extends BaseEvaluator {
/**
- *
+ *
*/
private static final long serialVersionUID = 400L;
private final static Evaluator INSTANCE = new CharacterGreaterOrEqualEvaluator();
- private CharacterGreaterOrEqualEvaluator() {
+ public CharacterGreaterOrEqualEvaluator() {
super( ValueType.PCHAR_TYPE,
Operator.GREATER_OR_EQUAL );
}
@@ -1036,14 +1046,14 @@
}
}
- static class DateLessEvaluator extends BaseEvaluator {
+ public static class DateLessEvaluator extends BaseEvaluator {
/**
- *
+ *
*/
private static final long serialVersionUID = 400L;
public final static Evaluator INSTANCE = new DateLessEvaluator();
- private DateLessEvaluator() {
+ public DateLessEvaluator() {
super( ValueType.DATE_TYPE,
Operator.LESS );
}
@@ -1088,6 +1098,7 @@
}
final Date value1 = (Date) extractor1.getValue( workingMemory, object1 );
final Date value2 = (Date) extractor2.getValue( workingMemory, object2 );
+ if (null == value2) throw new NullPointerException(extractor2.toString());
return value1.compareTo( value2 ) < 0;
}
@@ -1096,14 +1107,14 @@
}
}
- static class DateLessOrEqualEvaluator extends BaseEvaluator {
+ public static class DateLessOrEqualEvaluator extends BaseEvaluator {
/**
- *
+ *
*/
private static final long serialVersionUID = 400L;
public final static Evaluator INSTANCE = new DateLessOrEqualEvaluator();
- private DateLessOrEqualEvaluator() {
+ public DateLessOrEqualEvaluator() {
super( ValueType.DATE_TYPE,
Operator.LESS_OR_EQUAL );
}
@@ -1148,6 +1159,7 @@
}
final Date value1 = (Date) extractor1.getValue( workingMemory, object1 );
final Date value2 = (Date) extractor2.getValue( workingMemory, object2 );
+ if (null == value2) throw new NullPointerException(extractor2.toString());
return value1.compareTo( value2 ) <= 0;
}
@@ -1156,14 +1168,14 @@
}
}
- static class DateGreaterEvaluator extends BaseEvaluator {
+ public static class DateGreaterEvaluator extends BaseEvaluator {
/**
- *
+ *
*/
private static final long serialVersionUID = 400L;
public final static Evaluator INSTANCE = new DateGreaterEvaluator();
- private DateGreaterEvaluator() {
+ public DateGreaterEvaluator() {
super( ValueType.DATE_TYPE,
Operator.GREATER );
}
@@ -1208,6 +1220,7 @@
}
final Date value1 = (Date) extractor1.getValue( workingMemory, object1 );
final Date value2 = (Date) extractor2.getValue( workingMemory, object2 );
+ if (null == value2) throw new NullPointerException(extractor2.toString());
return value1.compareTo( value2 ) > 0;
}
@@ -1216,14 +1229,14 @@
}
}
- static class DateGreaterOrEqualEvaluator extends BaseEvaluator {
+ public static class DateGreaterOrEqualEvaluator extends BaseEvaluator {
/**
- *
+ *
*/
private static final long serialVersionUID = 400L;
private final static Evaluator INSTANCE = new DateGreaterOrEqualEvaluator();
- private DateGreaterOrEqualEvaluator() {
+ public DateGreaterOrEqualEvaluator() {
super( ValueType.DATE_TYPE,
Operator.GREATER_OR_EQUAL );
}
@@ -1268,6 +1281,7 @@
}
final Date value1 = (Date) extractor1.getValue( workingMemory, object1 );
final Date value2 = (Date) extractor2.getValue( workingMemory, object2 );
+ if (null == value2) throw new NullPointerException(extractor2.toString());
return value1.compareTo( value2 ) >= 0;
}
@@ -1276,14 +1290,14 @@
}
}
- static class DoubleLessEvaluator extends BaseEvaluator {
+ public static class DoubleLessEvaluator extends BaseEvaluator {
/**
- *
+ *
*/
private static final long serialVersionUID = 400L;
public final static Evaluator INSTANCE = new DoubleLessEvaluator();
- private DoubleLessEvaluator() {
+ public DoubleLessEvaluator() {
super( ValueType.PDOUBLE_TYPE,
Operator.LESS );
}
@@ -1332,14 +1346,14 @@
}
}
- static class DoubleLessOrEqualEvaluator extends BaseEvaluator {
+ public static class DoubleLessOrEqualEvaluator extends BaseEvaluator {
/**
- *
+ *
*/
private static final long serialVersionUID = 400L;
public final static Evaluator INSTANCE = new DoubleLessOrEqualEvaluator();
- private DoubleLessOrEqualEvaluator() {
+ public DoubleLessOrEqualEvaluator() {
super( ValueType.PDOUBLE_TYPE,
Operator.LESS_OR_EQUAL );
}
@@ -1388,14 +1402,14 @@
}
}
- static class DoubleGreaterEvaluator extends BaseEvaluator {
+ public static class DoubleGreaterEvaluator extends BaseEvaluator {
/**
- *
+ *
*/
private static final long serialVersionUID = 400L;
public final static Evaluator INSTANCE = new DoubleGreaterEvaluator();
- private DoubleGreaterEvaluator() {
+ public DoubleGreaterEvaluator() {
super( ValueType.PDOUBLE_TYPE,
Operator.GREATER );
}
@@ -1444,14 +1458,14 @@
}
}
- static class DoubleGreaterOrEqualEvaluator extends BaseEvaluator {
+ public static class DoubleGreaterOrEqualEvaluator extends BaseEvaluator {
/**
- *
+ *
*/
private static final long serialVersionUID = 400L;
private final static Evaluator INSTANCE = new DoubleGreaterOrEqualEvaluator();
- private DoubleGreaterOrEqualEvaluator() {
+ public DoubleGreaterOrEqualEvaluator() {
super( ValueType.PDOUBLE_TYPE,
Operator.GREATER_OR_EQUAL );
}
@@ -1499,15 +1513,15 @@
return "Double >=";
}
}
-
- static class FloatLessEvaluator extends BaseEvaluator {
+
+ public static class FloatLessEvaluator extends BaseEvaluator {
/**
- *
+ *
*/
private static final long serialVersionUID = 400L;
public final static Evaluator INSTANCE = new FloatLessEvaluator();
- private FloatLessEvaluator() {
+ public FloatLessEvaluator() {
super( ValueType.PFLOAT_TYPE,
Operator.LESS );
}
@@ -1556,14 +1570,14 @@
}
}
- static class FloatLessOrEqualEvaluator extends BaseEvaluator {
+ public static class FloatLessOrEqualEvaluator extends BaseEvaluator {
/**
- *
+ *
*/
private static final long serialVersionUID = 400L;
public final static Evaluator INSTANCE = new FloatLessOrEqualEvaluator();
- private FloatLessOrEqualEvaluator() {
+ public FloatLessOrEqualEvaluator() {
super( ValueType.PFLOAT_TYPE,
Operator.LESS_OR_EQUAL );
}
@@ -1612,14 +1626,14 @@
}
}
- static class FloatGreaterEvaluator extends BaseEvaluator {
+ public static class FloatGreaterEvaluator extends BaseEvaluator {
/**
- *
+ *
*/
private static final long serialVersionUID = 400L;
public final static Evaluator INSTANCE = new FloatGreaterEvaluator();
- private FloatGreaterEvaluator() {
+ public FloatGreaterEvaluator() {
super( ValueType.PFLOAT_TYPE,
Operator.GREATER );
}
@@ -1668,14 +1682,14 @@
}
}
- static class FloatGreaterOrEqualEvaluator extends BaseEvaluator {
+ public static class FloatGreaterOrEqualEvaluator extends BaseEvaluator {
/**
- *
+ *
*/
private static final long serialVersionUID = 400L;
private final static Evaluator INSTANCE = new FloatGreaterOrEqualEvaluator();
- private FloatGreaterOrEqualEvaluator() {
+ public FloatGreaterOrEqualEvaluator() {
super( ValueType.PFLOAT_TYPE,
Operator.GREATER_OR_EQUAL );
}
@@ -1723,15 +1737,15 @@
return "Float >=";
}
}
-
- static class IntegerLessEvaluator extends BaseEvaluator {
+
+ public static class IntegerLessEvaluator extends BaseEvaluator {
/**
- *
+ *
*/
private static final long serialVersionUID = 400L;
public final static Evaluator INSTANCE = new IntegerLessEvaluator();
- private IntegerLessEvaluator() {
+ public IntegerLessEvaluator() {
super( ValueType.PINTEGER_TYPE,
Operator.LESS );
}
@@ -1776,14 +1790,14 @@
}
}
- static class IntegerLessOrEqualEvaluator extends BaseEvaluator {
+ public static class IntegerLessOrEqualEvaluator extends BaseEvaluator {
/**
- *
+ *
*/
private static final long serialVersionUID = 400L;
public final static Evaluator INSTANCE = new IntegerLessOrEqualEvaluator();
- private IntegerLessOrEqualEvaluator() {
+ public IntegerLessOrEqualEvaluator() {
super( ValueType.PINTEGER_TYPE,
Operator.LESS_OR_EQUAL );
}
@@ -1828,14 +1842,14 @@
}
}
- static class IntegerGreaterEvaluator extends BaseEvaluator {
+ static public class IntegerGreaterEvaluator extends BaseEvaluator {
/**
- *
+ *
*/
private static final long serialVersionUID = 400L;
public final static Evaluator INSTANCE = new IntegerGreaterEvaluator();
- private IntegerGreaterEvaluator() {
+ public IntegerGreaterEvaluator() {
super( ValueType.PINTEGER_TYPE,
Operator.GREATER );
}
@@ -1880,14 +1894,14 @@
}
}
- static class IntegerGreaterOrEqualEvaluator extends BaseEvaluator {
+ public static class IntegerGreaterOrEqualEvaluator extends BaseEvaluator {
/**
- *
+ *
*/
private static final long serialVersionUID = 400L;
private final static Evaluator INSTANCE = new IntegerGreaterOrEqualEvaluator();
- private IntegerGreaterOrEqualEvaluator() {
+ public IntegerGreaterOrEqualEvaluator() {
super( ValueType.PINTEGER_TYPE,
Operator.GREATER_OR_EQUAL );
}
@@ -1931,15 +1945,15 @@
return "Integer >=";
}
}
-
- static class LongLessEvaluator extends BaseEvaluator {
+
+ public static class LongLessEvaluator extends BaseEvaluator {
/**
- *
+ *
*/
private static final long serialVersionUID = 400L;
public final static Evaluator INSTANCE = new LongLessEvaluator();
- private LongLessEvaluator() {
+ public LongLessEvaluator() {
super( ValueType.PLONG_TYPE,
Operator.LESS );
}
@@ -1984,14 +1998,14 @@
}
}
- static class LongLessOrEqualEvaluator extends BaseEvaluator {
+ public static class LongLessOrEqualEvaluator extends BaseEvaluator {
/**
- *
+ *
*/
private static final long serialVersionUID = 400L;
public final static Evaluator INSTANCE = new LongLessOrEqualEvaluator();
- private LongLessOrEqualEvaluator() {
+ public LongLessOrEqualEvaluator() {
super( ValueType.PLONG_TYPE,
Operator.LESS_OR_EQUAL );
}
@@ -2036,14 +2050,14 @@
}
}
- static class LongGreaterEvaluator extends BaseEvaluator {
+ public static class LongGreaterEvaluator extends BaseEvaluator {
/**
- *
+ *
*/
private static final long serialVersionUID = 400L;
public final static Evaluator INSTANCE = new LongGreaterEvaluator();
- private LongGreaterEvaluator() {
+ public LongGreaterEvaluator() {
super( ValueType.PLONG_TYPE,
Operator.GREATER );
}
@@ -2088,14 +2102,14 @@
}
}
- static class LongGreaterOrEqualEvaluator extends BaseEvaluator {
+ public static class LongGreaterOrEqualEvaluator extends BaseEvaluator {
/**
- *
+ *
*/
private static final long serialVersionUID = 400L;
private final static Evaluator INSTANCE = new LongGreaterOrEqualEvaluator();
- private LongGreaterOrEqualEvaluator() {
+ public LongGreaterOrEqualEvaluator() {
super( ValueType.PLONG_TYPE,
Operator.GREATER_OR_EQUAL );
}
@@ -2139,14 +2153,14 @@
return "Long >=";
}
}
-
- static class ObjectLessEvaluator extends BaseEvaluator {
+
+ public static class ObjectLessEvaluator extends BaseEvaluator {
private static final long serialVersionUID = 400L;
public final static Evaluator INSTANCE = new ObjectLessEvaluator();
private static final ObjectComparator comparator = new ObjectComparator();
-
- private ObjectLessEvaluator() {
+
+ public ObjectLessEvaluator() {
super( ValueType.OBJECT_TYPE,
Operator.LESS );
}
@@ -2195,15 +2209,15 @@
}
}
- static class ObjectLessOrEqualEvaluator extends BaseEvaluator {
+ public static class ObjectLessOrEqualEvaluator extends BaseEvaluator {
/**
- *
+ *
*/
private static final long serialVersionUID = 400L;
public final static Evaluator INSTANCE = new ObjectLessOrEqualEvaluator();
private static final ObjectComparator comparator = new ObjectComparator();
- private ObjectLessOrEqualEvaluator() {
+ public ObjectLessOrEqualEvaluator() {
super( ValueType.OBJECT_TYPE,
Operator.LESS_OR_EQUAL );
}
@@ -2252,15 +2266,15 @@
}
}
- static class ObjectGreaterEvaluator extends BaseEvaluator {
+ public static class ObjectGreaterEvaluator extends BaseEvaluator {
/**
- *
+ *
*/
private static final long serialVersionUID = 400L;
public final static Evaluator INSTANCE = new ObjectGreaterEvaluator();
private static final ObjectComparator comparator = new ObjectComparator();
- private ObjectGreaterEvaluator() {
+ public ObjectGreaterEvaluator() {
super( ValueType.OBJECT_TYPE,
Operator.GREATER );
}
@@ -2309,15 +2323,15 @@
}
}
- static class ObjectGreaterOrEqualEvaluator extends BaseEvaluator {
+ public static class ObjectGreaterOrEqualEvaluator extends BaseEvaluator {
/**
- *
+ *
*/
private static final long serialVersionUID = 400L;
public final static Evaluator INSTANCE = new ObjectGreaterOrEqualEvaluator();
private static final ObjectComparator comparator = new ObjectComparator();
- private ObjectGreaterOrEqualEvaluator() {
+ public ObjectGreaterOrEqualEvaluator() {
super( ValueType.OBJECT_TYPE,
Operator.GREATER_OR_EQUAL );
}
@@ -2366,14 +2380,14 @@
}
}
- static class ShortLessEvaluator extends BaseEvaluator {
+ public static class ShortLessEvaluator extends BaseEvaluator {
/**
- *
+ *
*/
private static final long serialVersionUID = 400L;
private static final Evaluator INSTANCE = new ShortLessEvaluator();
- private ShortLessEvaluator() {
+ public ShortLessEvaluator() {
super( ValueType.PSHORT_TYPE,
Operator.LESS );
}
@@ -2418,14 +2432,14 @@
}
}
- static class ShortLessOrEqualEvaluator extends BaseEvaluator {
+ public static class ShortLessOrEqualEvaluator extends BaseEvaluator {
/**
- *
+ *
*/
private static final long serialVersionUID = 400L;
private static final Evaluator INSTANCE = new ShortLessOrEqualEvaluator();
- private ShortLessOrEqualEvaluator() {
+ public ShortLessOrEqualEvaluator() {
super( ValueType.PSHORT_TYPE,
Operator.LESS_OR_EQUAL );
}
@@ -2470,14 +2484,14 @@
}
}
- static class ShortGreaterEvaluator extends BaseEvaluator {
+ public static class ShortGreaterEvaluator extends BaseEvaluator {
/**
- *
+ *
*/
private static final long serialVersionUID = 400L;
private static final Evaluator INSTANCE = new ShortGreaterEvaluator();
- private ShortGreaterEvaluator() {
+ public ShortGreaterEvaluator() {
super( ValueType.PSHORT_TYPE,
Operator.GREATER );
}
@@ -2522,14 +2536,14 @@
}
}
- static class ShortGreaterOrEqualEvaluator extends BaseEvaluator {
+ public static class ShortGreaterOrEqualEvaluator extends BaseEvaluator {
/**
- *
+ *
*/
private static final long serialVersionUID = 400L;
private static final Evaluator INSTANCE = new ShortGreaterOrEqualEvaluator();
- private ShortGreaterOrEqualEvaluator() {
+ public ShortGreaterOrEqualEvaluator() {
super( ValueType.PSHORT_TYPE,
Operator.GREATER_OR_EQUAL );
}
@@ -2574,10 +2588,10 @@
}
}
-
+
protected static class ObjectComparator implements Comparator {
// this is a stateless object, and so, can be shared among threads
- // PLEASE: do not add state to it, unless you remove all concurrent
+ // PLEASE: do not add state to it, unless you remove all concurrent
// calls to this class instances
public int compare(Object arg0,
@@ -2599,7 +2613,7 @@
if( arg1 instanceof Number ) {
val1 = ((Number) arg1).longValue();
} else if( arg1 instanceof String ) {
- val1 = Long.parseLong( ( String ) arg1 );
+ val1 = Long.parseLong( ( String ) arg1 );
} else {
throw new ClassCastException( "Not possible to convert "+arg1.getClass()+" into a long value to compare it to "+arg0.getClass() );
}
@@ -2619,7 +2633,7 @@
} catch( NumberFormatException nfe ) {
return ( (String) arg0).compareTo( arg1.toString() );
}
-
+
}
try {
return ((Comparable)arg0).compareTo( arg1 );
@@ -2628,5 +2642,5 @@
}
}
}
-
+
}
Modified: labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/base/evaluators/DuringEvaluatorDefinition.java
===================================================================
--- labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/base/evaluators/DuringEvaluatorDefinition.java 2008-03-20 18:57:07 UTC (rev 19163)
+++ labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/base/evaluators/DuringEvaluatorDefinition.java 2008-03-20 19:32:10 UTC (rev 19164)
@@ -1,12 +1,12 @@
/*
* Copyright 2007 JBoss Inc
- *
+ *
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -20,6 +20,9 @@
import java.util.Collections;
import java.util.HashMap;
import java.util.Map;
+import java.io.ObjectInput;
+import java.io.IOException;
+import java.io.ObjectOutput;
import org.drools.RuntimeDroolsException;
import org.drools.base.BaseEvaluator;
@@ -35,7 +38,7 @@
/**
* The implementation of the 'during' evaluator definition
- *
+ *
* @author mgroch
*/
public class DuringEvaluatorDefinition
@@ -46,11 +49,19 @@
false );
public static final Operator NOT_DURING = Operator.addOperatorToRegistry( "during",
true );
-
+
private static final String[] SUPPORTED_IDS = { DURING.getOperatorString() };
-
+
private Map<String, DuringEvaluator> cache = Collections.emptyMap();
+ public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
+ cache = (Map<String, DuringEvaluator>)in.readObject();
+ }
+
+ public void writeExternal(ObjectOutput out) throws IOException {
+ out.writeObject(cache);
+ }
+
/**
* @inheridDoc
*/
@@ -131,10 +142,13 @@
*/
public static class DuringEvaluator extends BaseEvaluator {
private static final long serialVersionUID = -5856043346192967722L;
-
+
private long startMinDev, startMaxDev;
private long endMinDev, endMaxDev;
+ public DuringEvaluator() {
+ }
+
public DuringEvaluator(final ValueType type,
final boolean isNegated,
final String parameters) {
@@ -142,12 +156,28 @@
isNegated ? NOT_DURING : DURING );
this.parseParameters( parameters );
}
-
+
+ public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
+ super.readExternal(in);
+ startMinDev = in.readLong();
+ startMaxDev = in.readLong();
+ endMinDev = in.readLong();
+ endMaxDev = in.readLong();
+ }
+
+ public void writeExternal(ObjectOutput out) throws IOException {
+ super.writeExternal(out);
+ out.writeLong(startMinDev);
+ out.writeLong(startMaxDev);
+ out.writeLong(endMinDev);
+ out.writeLong(endMaxDev);
+ }
+
@Override
public Object prepareObject(InternalFactHandle handle) {
return handle;
}
-
+
public boolean evaluate(InternalWorkingMemory workingMemory,
final Extractor extractor,
final Object object1,
@@ -158,16 +188,16 @@
public boolean evaluateCachedRight(InternalWorkingMemory workingMemory,
final VariableContextEntry context,
final Object left) {
-
+
if ( context.rightNull ) {
return false;
}
long distStart = ((EventFactHandle)((ObjectVariableContextEntry) context).right).getStartTimestamp() - ((EventFactHandle) left ).getStartTimestamp();
long distEnd = ((EventFactHandle) left ).getEndTimestamp() - ((EventFactHandle)((ObjectVariableContextEntry) context).right).getEndTimestamp();
- return this.getOperator().isNegated() ^ ( distStart >= this.startMinDev && distStart <= this.startMaxDev
+ return this.getOperator().isNegated() ^ ( distStart >= this.startMinDev && distStart <= this.startMaxDev
&& distEnd >= this.endMinDev && distEnd <= this.endMaxDev );
}
-
+
public boolean evaluateCachedLeft(InternalWorkingMemory workingMemory,
final VariableContextEntry context,
final Object right) {
@@ -177,10 +207,10 @@
}
long distStart = ((EventFactHandle) right ).getStartTimestamp() - ((EventFactHandle) ((ObjectVariableContextEntry) context).left).getStartTimestamp();
long distEnd = ((EventFactHandle) ((ObjectVariableContextEntry) context).left).getEndTimestamp() - ((EventFactHandle) right ).getEndTimestamp();
- return this.getOperator().isNegated() ^ ( distStart >= this.startMinDev && distStart <= this.startMaxDev
+ return this.getOperator().isNegated() ^ ( distStart >= this.startMinDev && distStart <= this.startMaxDev
&& distEnd >= this.endMinDev && distEnd <= this.endMaxDev );
}
-
+
public boolean evaluate(InternalWorkingMemory workingMemory,
final Extractor extractor1,
final Object object1,
@@ -192,7 +222,7 @@
}
long distStart = ((EventFactHandle) object1 ).getStartTimestamp() - ((EventFactHandle) object2 ).getStartTimestamp();
long distEnd = ((EventFactHandle) object2 ).getEndTimestamp() - ((EventFactHandle) object1 ).getEndTimestamp();
- return this.getOperator().isNegated() ^ ( distStart >= this.startMinDev && distStart <= this.startMaxDev
+ return this.getOperator().isNegated() ^ ( distStart >= this.startMinDev && distStart <= this.startMaxDev
&& distEnd >= this.endMinDev && distEnd <= this.endMaxDev );
}
@@ -228,9 +258,9 @@
}
/**
- * This methods tries to parse the string of parameters to customize
+ * This methods tries to parse the string of parameters to customize
* the evaluator.
- *
+ *
* @param parameters
*/
private void parseParameters(String parameters) {
@@ -246,19 +276,19 @@
try {
String[] ranges = parameters.split( "," );
if ( ranges.length == 1 ) {
- // deterministic point in time for deviation of the starts of the intervals
+ // deterministic point in time for deviation of the starts of the intervals
this.startMinDev = Long.parseLong( ranges[0] );
this.startMaxDev = this.startMinDev;
this.endMinDev = this.startMinDev;
this.endMaxDev = this.startMinDev;
} else if ( ranges.length == 2 ) {
- // deterministic points in time for deviations of the starts and the ends of the intervals
+ // deterministic points in time for deviations of the starts and the ends of the intervals
this.startMinDev = Long.parseLong( ranges[0] );
this.startMaxDev = this.startMinDev;
this.endMinDev = Long.parseLong( ranges[1] );
this.endMaxDev = this.endMinDev;
} else if ( ranges.length == 4 ) {
- // ranges for deviations of the starts and the ends of the intervals
+ // ranges for deviations of the starts and the ends of the intervals
this.startMinDev = Long.parseLong( ranges[0] );
this.startMaxDev = Long.parseLong( ranges[1] );
this.endMinDev = Long.parseLong( ranges[2] );
Modified: labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/base/evaluators/EqualityEvaluatorsDefinition.java
===================================================================
--- labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/base/evaluators/EqualityEvaluatorsDefinition.java 2008-03-20 18:57:07 UTC (rev 19163)
+++ labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/base/evaluators/EqualityEvaluatorsDefinition.java 2008-03-20 19:32:10 UTC (rev 19164)
@@ -1,12 +1,12 @@
/*
* Copyright 2007 JBoss Inc
- *
+ *
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -17,6 +17,9 @@
*/
package org.drools.base.evaluators;
+import java.io.IOException;
+import java.io.ObjectInput;
+import java.io.ObjectOutput;
import java.util.Date;
import org.drools.base.BaseEvaluator;
@@ -37,11 +40,11 @@
/**
* This class defines the default built in equality
* evaluators == and !=
- *
+ *
* @author etirelli
*/
public class EqualityEvaluatorsDefinition implements EvaluatorDefinition {
-
+
private static final String[] SUPPORTED_IDS = { Operator.EQUAL.getOperatorString(), Operator.NOT_EQUAL.getOperatorString() };
private EvaluatorCache evaluators = new EvaluatorCache() {
private static final long serialVersionUID = 4782368623L;
@@ -94,7 +97,15 @@
addEvaluator( ValueType.STRING_TYPE, Operator.NOT_EQUAL, StringNotEqualEvaluator.INSTANCE );
}
};
-
+
+ public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
+ evaluators = (EvaluatorCache)in.readObject();
+ }
+
+ public void writeExternal(ObjectOutput out) throws IOException {
+ out.writeObject(evaluators);
+ }
+
/**
* @inheridDoc
*/
@@ -137,18 +148,17 @@
public boolean supportsType(ValueType type) {
return this.evaluators.supportsType( type );
}
-
+
/* *********************************************************
* Evaluator Implementations
* *********************************************************
*/
-
- static class ArrayEqualEvaluator extends BaseEvaluator {
+ public static class ArrayEqualEvaluator extends BaseEvaluator {
private static final long serialVersionUID = 400L;
public final static Evaluator INSTANCE = new ArrayEqualEvaluator();
- private ArrayEqualEvaluator() {
+ public ArrayEqualEvaluator() {
super( ValueType.ARRAY_TYPE,
Operator.EQUAL );
}
@@ -209,14 +219,14 @@
}
- static class ArrayNotEqualEvaluator extends BaseEvaluator {
+ public static class ArrayNotEqualEvaluator extends BaseEvaluator {
/**
- *
+ *
*/
private static final long serialVersionUID = 400L;
public final static Evaluator INSTANCE = new ArrayNotEqualEvaluator();
- private ArrayNotEqualEvaluator() {
+ public ArrayNotEqualEvaluator() {
super( ValueType.ARRAY_TYPE,
Operator.NOT_EQUAL );
}
@@ -276,14 +286,14 @@
}
}
- static class BigDecimalEqualEvaluator extends BaseEvaluator {
+ public static class BigDecimalEqualEvaluator extends BaseEvaluator {
/**
- *
+ *
*/
private static final long serialVersionUID = 400L;
public final static Evaluator INSTANCE = new BigDecimalEqualEvaluator();
- private BigDecimalEqualEvaluator() {
+ public BigDecimalEqualEvaluator() {
super( ValueType.BIG_DECIMAL_TYPE,
Operator.EQUAL );
}
@@ -292,7 +302,7 @@
final Extractor extractor,
final Object object1, final FieldValue object2) {
final Object value1 = extractor.getValue( workingMemory, object1 );
- final Object value2 = object2.getValue();
+ final Object value2 = object2.getBigDecimalValue();
if ( value1 == null ) {
return value2 == null;
}
@@ -335,14 +345,14 @@
}
- static class BigDecimalNotEqualEvaluator extends BaseEvaluator {
+ public static class BigDecimalNotEqualEvaluator extends BaseEvaluator {
/**
- *
+ *
*/
private static final long serialVersionUID = 400L;
public final static Evaluator INSTANCE = new BigDecimalNotEqualEvaluator();
- private BigDecimalNotEqualEvaluator() {
+ public BigDecimalNotEqualEvaluator() {
super( ValueType.BIG_DECIMAL_TYPE,
Operator.NOT_EQUAL );
}
@@ -351,7 +361,7 @@
final Extractor extractor,
final Object object1, final FieldValue object2) {
final Object value1 = extractor.getValue( workingMemory, object1 );
- final Object value2 = object2.getValue();
+ final Object value2 = object2.getBigDecimalValue();
if ( value1 == null ) {
return value2 != null;
}
@@ -393,14 +403,14 @@
}
}
- static class BigIntegerEqualEvaluator extends BaseEvaluator {
+ public static class BigIntegerEqualEvaluator extends BaseEvaluator {
/**
- *
+ *
*/
private static final long serialVersionUID = 400L;
public final static Evaluator INSTANCE = new BigIntegerEqualEvaluator();
- private BigIntegerEqualEvaluator() {
+ public BigIntegerEqualEvaluator() {
super( ValueType.BIG_INTEGER_TYPE,
Operator.EQUAL );
}
@@ -409,7 +419,7 @@
final Extractor extractor,
final Object object1, final FieldValue object2) {
final Object value1 = extractor.getValue( workingMemory, object1 );
- final Object value2 = object2.getValue();
+ final Object value2 = object2.getBigIntegerValue();
if ( value1 == null ) {
return value2 == null;
}
@@ -451,14 +461,14 @@
}
}
- static class BigIntegerNotEqualEvaluator extends BaseEvaluator {
+ public static class BigIntegerNotEqualEvaluator extends BaseEvaluator {
/**
- *
+ *
*/
private static final long serialVersionUID = 400L;
public final static Evaluator INSTANCE = new BigIntegerNotEqualEvaluator();
- private BigIntegerNotEqualEvaluator() {
+ public BigIntegerNotEqualEvaluator() {
super( ValueType.BIG_INTEGER_TYPE,
Operator.NOT_EQUAL );
}
@@ -467,7 +477,7 @@
final Extractor extractor,
final Object object1, final FieldValue object2) {
final Object value1 = extractor.getValue( workingMemory, object1 );
- final Object value2 = object2.getValue();
+ final Object value2 = object2.getBigDecimalValue();
if ( value1 == null ) {
return value2 != null;
}
@@ -509,12 +519,12 @@
}
}
- static class BooleanEqualEvaluator extends BaseEvaluator {
+ public static class BooleanEqualEvaluator extends BaseEvaluator {
private static final long serialVersionUID = 400L;
private final static Evaluator INSTANCE = new BooleanEqualEvaluator();
- private BooleanEqualEvaluator() {
+ public BooleanEqualEvaluator() {
super( ValueType.PBOOLEAN_TYPE,
Operator.EQUAL );
}
@@ -527,7 +537,7 @@
} else if ( object2.isNull() ) {
return false;
}
-
+
return extractor.getBooleanValue( workingMemory, object1 ) == object2.getBooleanValue();
}
@@ -538,7 +548,7 @@
} else if ( context.isRightNull() ) {
return false;
}
-
+
return context.declaration.getExtractor().getBooleanValue( workingMemory, left ) == ((BooleanVariableContextEntry) context).right;
}
@@ -549,7 +559,7 @@
} else if ( context.isLeftNull() ) {
return false;
}
-
+
return context.extractor.getBooleanValue( workingMemory, object2 ) == ((BooleanVariableContextEntry) context).left;
}
@@ -562,7 +572,7 @@
} else if (extractor2.isNullValue( workingMemory, object2 )) {
return false;
}
-
+
return extractor1.getBooleanValue( workingMemory, object1 ) == extractor2.getBooleanValue( workingMemory, object2 );
}
@@ -572,14 +582,14 @@
}
- static class BooleanNotEqualEvaluator extends BaseEvaluator {
+ public static class BooleanNotEqualEvaluator extends BaseEvaluator {
/**
- *
+ *
*/
private static final long serialVersionUID = 400L;
public final static Evaluator INSTANCE = new BooleanNotEqualEvaluator();
- private BooleanNotEqualEvaluator() {
+ public BooleanNotEqualEvaluator() {
super( ValueType.PBOOLEAN_TYPE,
Operator.NOT_EQUAL );
}
@@ -592,7 +602,7 @@
} else if ( object2.isNull() ) {
return true;
}
-
+
return extractor.getBooleanValue( workingMemory, object1 ) != object2.getBooleanValue();
}
@@ -613,7 +623,7 @@
} else if ( context.isLeftNull() ) {
return true;
}
-
+
return context.extractor.getBooleanValue( workingMemory, object2 ) != ((BooleanVariableContextEntry) context).left;
}
@@ -626,7 +636,7 @@
} else if (extractor2.isNullValue( workingMemory, object2 )) {
return true;
}
-
+
return extractor1.getBooleanValue( workingMemory, object1 ) != extractor1.getBooleanValue( workingMemory, object2 );
}
@@ -635,14 +645,14 @@
}
}
- static class ByteEqualEvaluator extends BaseEvaluator {
+ public static class ByteEqualEvaluator extends BaseEvaluator {
/**
- *
+ *
*/
private static final long serialVersionUID = 400L;
public final static Evaluator INSTANCE = new ByteEqualEvaluator();
- private ByteEqualEvaluator() {
+ public ByteEqualEvaluator() {
super( ValueType.PBYTE_TYPE,
Operator.EQUAL );
}
@@ -655,7 +665,7 @@
} else if ( object2.isNull() ) {
return false;
}
-
+
return extractor.getByteValue( workingMemory, object1 ) == object2.getByteValue();
}
@@ -666,7 +676,7 @@
} else if ( context.isRightNull() ) {
return false;
}
-
+
return context.declaration.getExtractor().getByteValue( workingMemory, left ) == ((LongVariableContextEntry) context).right;
}
@@ -677,7 +687,7 @@
} else if ( context.isLeftNull() ) {
return false;
}
-
+
return ((LongVariableContextEntry) context).left == context.extractor.getByteValue( workingMemory, right );
}
@@ -690,7 +700,7 @@
} else if (extractor2.isNullValue( workingMemory, object2 )) {
return false;
}
-
+
return extractor1.getByteValue( workingMemory, object1 ) == extractor2.getByteValue( workingMemory, object2 );
}
@@ -700,14 +710,14 @@
}
- static class ByteNotEqualEvaluator extends BaseEvaluator {
+ public static class ByteNotEqualEvaluator extends BaseEvaluator {
/**
- *
+ *
*/
private static final long serialVersionUID = 400L;
public final static Evaluator INSTANCE = new ByteNotEqualEvaluator();
- private ByteNotEqualEvaluator() {
+ public ByteNotEqualEvaluator() {
super( ValueType.PBYTE_TYPE,
Operator.NOT_EQUAL );
}
@@ -720,7 +730,7 @@
} else if ( object2.isNull() ) {
return true;
}
-
+
return extractor.getByteValue( workingMemory, object1 ) != object2.getByteValue();
}
@@ -731,7 +741,7 @@
} else if ( context.isRightNull() ) {
return true;
}
-
+
return context.declaration.getExtractor().getByteValue( workingMemory, left ) != ((LongVariableContextEntry) context).right;
}
@@ -742,7 +752,7 @@
} else if ( context.isLeftNull() ) {
return true;
}
-
+
return ((LongVariableContextEntry) context).left != context.extractor.getByteValue( workingMemory, object2 );
}
@@ -755,7 +765,7 @@
} else if (extractor2.isNullValue( workingMemory, object2 )) {
return true;
}
-
+
return extractor1.getByteValue( workingMemory, object1 ) != extractor2.getByteValue( workingMemory, object2 );
}
@@ -764,14 +774,14 @@
}
}
- static class CharacterEqualEvaluator extends BaseEvaluator {
+ public static class CharacterEqualEvaluator extends BaseEvaluator {
/**
- *
+ *
*/
private static final long serialVersionUID = 400L;
public final static Evaluator INSTANCE = new CharacterEqualEvaluator();
- private CharacterEqualEvaluator() {
+ public CharacterEqualEvaluator() {
super( ValueType.PCHAR_TYPE,
Operator.EQUAL );
}
@@ -784,7 +794,7 @@
} else if ( object2.isNull() ) {
return false;
}
-
+
return extractor.getCharValue( workingMemory, object1 ) == object2.getCharValue();
}
@@ -795,7 +805,7 @@
} else if ( context.isRightNull() ) {
return false;
}
-
+
return context.declaration.getExtractor().getCharValue( workingMemory, left ) == ((CharVariableContextEntry) context).right;
}
@@ -806,7 +816,7 @@
} else if ( context.isLeftNull() ) {
return false;
}
-
+
return ((CharVariableContextEntry) context).left == context.extractor.getCharValue( workingMemory, right );
}
@@ -819,7 +829,7 @@
} else if (extractor2.isNullValue( workingMemory, object2 )) {
return false;
}
-
+
return extractor1.getCharValue( workingMemory, object1 ) == extractor2.getCharValue( workingMemory, object2 );
}
@@ -828,14 +838,14 @@
}
}
- static class CharacterNotEqualEvaluator extends BaseEvaluator {
+ public static class CharacterNotEqualEvaluator extends BaseEvaluator {
/**
- *
+ *
*/
private static final long serialVersionUID = 400L;
public final static Evaluator INSTANCE = new CharacterNotEqualEvaluator();
- private CharacterNotEqualEvaluator() {
+ public CharacterNotEqualEvaluator() {
super( ValueType.PCHAR_TYPE,
Operator.NOT_EQUAL );
}
@@ -848,7 +858,7 @@
} else if ( object2.isNull() ) {
return true;
}
-
+
return extractor.getCharValue( workingMemory, object1 ) != object2.getCharValue();
}
@@ -859,7 +869,7 @@
} else if ( context.isRightNull() ) {
return true;
}
-
+
return context.declaration.getExtractor().getCharValue( workingMemory, left ) != ((CharVariableContextEntry) context).right;
}
@@ -870,7 +880,7 @@
} else if ( context.isLeftNull() ) {
return true;
}
-
+
return ((CharVariableContextEntry) context).left != context.extractor.getCharValue( workingMemory, right );
}
@@ -883,7 +893,7 @@
} else if (extractor2.isNullValue( workingMemory, object2 )) {
return true;
}
-
+
return extractor1.getCharValue( workingMemory, object1 ) != extractor2.getCharValue( workingMemory, object2 );
}
@@ -892,14 +902,14 @@
}
}
- static class DateEqualEvaluator extends BaseEvaluator {
+ public static class DateEqualEvaluator extends BaseEvaluator {
/**
- *
+ *
*/
private static final long serialVersionUID = 400L;
public final static Evaluator INSTANCE = new DateEqualEvaluator();
- private DateEqualEvaluator() {
+ public DateEqualEvaluator() {
super( ValueType.DATE_TYPE,
Operator.EQUAL );
}
@@ -965,14 +975,14 @@
}
- static class DateNotEqualEvaluator extends BaseEvaluator {
+ public static class DateNotEqualEvaluator extends BaseEvaluator {
/**
- *
+ *
*/
private static final long serialVersionUID = 400L;
public final static Evaluator INSTANCE = new DateNotEqualEvaluator();
- private DateNotEqualEvaluator() {
+ public DateNotEqualEvaluator() {
super( ValueType.DATE_TYPE,
Operator.NOT_EQUAL );
}
@@ -1037,14 +1047,14 @@
}
}
- static class DoubleEqualEvaluator extends BaseEvaluator {
+ public static class DoubleEqualEvaluator extends BaseEvaluator {
/**
- *
+ *
*/
private static final long serialVersionUID = 400L;
public final static Evaluator INSTANCE = new DoubleEqualEvaluator();
- private DoubleEqualEvaluator() {
+ public DoubleEqualEvaluator() {
super( ValueType.PDOUBLE_TYPE,
Operator.EQUAL );
}
@@ -1079,7 +1089,7 @@
} else if ( context.isLeftNull() ) {
return false;
}
-
+
// TODO: we are not handling delta right now... maybe we should
return ((DoubleVariableContextEntry) context).left == context.extractor.getDoubleValue( workingMemory, right );
}
@@ -1093,7 +1103,7 @@
} else if (extractor2.isNullValue( workingMemory, object2 )) {
return false;
}
-
+
// TODO: we are not handling delta right now... maybe we should
return extractor1.getDoubleValue( workingMemory, object1 ) == extractor2.getDoubleValue( workingMemory, object2 );
}
@@ -1103,14 +1113,14 @@
}
}
- static class DoubleNotEqualEvaluator extends BaseEvaluator {
+ public static class DoubleNotEqualEvaluator extends BaseEvaluator {
/**
- *
+ *
*/
private static final long serialVersionUID = 400L;
public final static Evaluator INSTANCE = new DoubleNotEqualEvaluator();
- private DoubleNotEqualEvaluator() {
+ public DoubleNotEqualEvaluator() {
super( ValueType.PDOUBLE_TYPE,
Operator.NOT_EQUAL );
}
@@ -1123,7 +1133,7 @@
} else if ( object2.isNull() ) {
return true;
}
-
+
// TODO: we are not handling delta right now... maybe we should
return extractor.getDoubleValue( workingMemory, object1 ) != object2.getDoubleValue();
}
@@ -1135,7 +1145,7 @@
} else if ( context.isRightNull() ) {
return true;
}
-
+
// TODO: we are not handling delta right now... maybe we should
return context.declaration.getExtractor().getDoubleValue( workingMemory, left ) != ((DoubleVariableContextEntry) context).right;
}
@@ -1147,7 +1157,7 @@
} else if ( context.isLeftNull() ) {
return true;
}
-
+
// TODO: we are not handling delta right now... maybe we should
return ((DoubleVariableContextEntry) context).left != context.extractor.getDoubleValue( workingMemory, right );
}
@@ -1161,7 +1171,7 @@
} else if (extractor2.isNullValue( workingMemory, object2 )) {
return true;
}
-
+
// TODO: we are not handling delta right now... maybe we should
return extractor1.getDoubleValue( workingMemory, object1 ) != extractor2.getDoubleValue( workingMemory, object2 );
}
@@ -1171,14 +1181,14 @@
}
}
- static class FactTemplateEqualEvaluator extends BaseEvaluator {
+ public static class FactTemplateEqualEvaluator extends BaseEvaluator {
/**
- *
+ *
*/
private static final long serialVersionUID = 400L;
public final static Evaluator INSTANCE = new FactTemplateEqualEvaluator();
- private FactTemplateEqualEvaluator() {
+ public FactTemplateEqualEvaluator() {
super( ValueType.FACTTEMPLATE_TYPE,
Operator.EQUAL );
}
@@ -1230,14 +1240,14 @@
}
- static class FactTemplateNotEqualEvaluator extends BaseEvaluator {
+ public static class FactTemplateNotEqualEvaluator extends BaseEvaluator {
/**
- *
+ *
*/
private static final long serialVersionUID = 400L;
public final static Evaluator INSTANCE = new FactTemplateNotEqualEvaluator();
- private FactTemplateNotEqualEvaluator() {
+ public FactTemplateNotEqualEvaluator() {
super( ValueType.FACTTEMPLATE_TYPE,
Operator.NOT_EQUAL );
}
@@ -1287,13 +1297,13 @@
return "FactTemplate !=";
}
}
-
- static class FloatEqualEvaluator extends BaseEvaluator {
+ public static class FloatEqualEvaluator extends BaseEvaluator {
+
private static final long serialVersionUID = 400L;
public final static Evaluator INSTANCE = new FloatEqualEvaluator();
- private FloatEqualEvaluator() {
+ public FloatEqualEvaluator() {
super( ValueType.PFLOAT_TYPE,
Operator.EQUAL );
}
@@ -1306,7 +1316,7 @@
} else if ( object2.isNull() ) {
return false;
}
-
+
// TODO: we are not handling delta right now... maybe we should
return extractor.getFloatValue( workingMemory, object1 ) == object2.getFloatValue();
}
@@ -1318,7 +1328,7 @@
} else if ( context.isRightNull() ) {
return false;
}
-
+
// TODO: we are not handling delta right now... maybe we should
return context.declaration.getExtractor().getFloatValue( workingMemory, left ) == ((DoubleVariableContextEntry) context).right;
}
@@ -1330,7 +1340,7 @@
} else if ( context.isLeftNull() ) {
return false;
}
-
+
// TODO: we are not handling delta right now... maybe we should
return ((DoubleVariableContextEntry) context).left == context.extractor.getFloatValue( workingMemory, right );
}
@@ -1344,7 +1354,7 @@
} else if (extractor2.isNullValue( workingMemory, object2 )) {
return false;
}
-
+
// TODO: we are not handling delta right now... maybe we should
return extractor1.getFloatValue( workingMemory, object1 ) == extractor2.getFloatValue( workingMemory, object2 );
}
@@ -1354,14 +1364,14 @@
}
}
- static class FloatNotEqualEvaluator extends BaseEvaluator {
+ public static class FloatNotEqualEvaluator extends BaseEvaluator {
/**
- *
+ *
*/
private static final long serialVersionUID = 400L;
public final static Evaluator INSTANCE = new FloatNotEqualEvaluator();
- private FloatNotEqualEvaluator() {
+ public FloatNotEqualEvaluator() {
super( ValueType.PFLOAT_TYPE,
Operator.NOT_EQUAL );
}
@@ -1374,7 +1384,7 @@
} else if ( object2.isNull() ) {
return true;
}
-
+
// TODO: we are not handling delta right now... maybe we should
return extractor.getFloatValue( workingMemory, object1 ) != object2.getFloatValue();
}
@@ -1386,7 +1396,7 @@
} else if ( context.isRightNull() ) {
return true;
}
-
+
// TODO: we are not handling delta right now... maybe we should
return context.declaration.getExtractor().getFloatValue( workingMemory, left ) != ((DoubleVariableContextEntry) context).right;
}
@@ -1398,7 +1408,7 @@
} else if ( context.isLeftNull() ) {
return true;
}
-
+
// TODO: we are not handling delta right now... maybe we should
return ((DoubleVariableContextEntry) context).left != context.extractor.getFloatValue( workingMemory, right );
}
@@ -1412,7 +1422,7 @@
} else if (extractor2.isNullValue( workingMemory, object2 )) {
return true;
}
-
+
// TODO: we are not handling delta right now... maybe we should
return extractor1.getFloatValue( workingMemory, object1 ) != extractor2.getFloatValue( workingMemory, object2 );
}
@@ -1422,14 +1432,14 @@
}
}
- static class IntegerEqualEvaluator extends BaseEvaluator {
+ static public class IntegerEqualEvaluator extends BaseEvaluator {
/**
- *
+ *
*/
private static final long serialVersionUID = 400L;
public final static Evaluator INSTANCE = new IntegerEqualEvaluator();
- private IntegerEqualEvaluator() {
+ public IntegerEqualEvaluator() {
super( ValueType.PINTEGER_TYPE,
Operator.EQUAL );
}
@@ -1442,7 +1452,7 @@
} else if ( object2.isNull() ) {
return false;
}
-
+
return extractor.getIntValue( workingMemory, object1 ) == object2.getIntValue();
}
@@ -1453,8 +1463,8 @@
} else if ( context.isRightNull() ) {
return false;
}
-
- return context.declaration.getExtractor().getIntValue( workingMemory, left ) == ((LongVariableContextEntry) context).right;
+
+ return context.declaration.getExtractor().getIntValue( workingMemory, left ) == ((LongVariableContextEntry) context).right;
}
public boolean evaluateCachedLeft(InternalWorkingMemory workingMemory,
@@ -1464,20 +1474,20 @@
} else if ( context.isLeftNull() ) {
return false;
}
-
+
return context.extractor.getIntValue( workingMemory, object2 ) == ((LongVariableContextEntry) context).left;
}
public boolean evaluate(InternalWorkingMemory workingMemory,
final Extractor extractor1,
final Object object1,
- final Extractor extractor2, final Object object2) {
+ final Extractor extractor2, final Object object2) {
if (extractor1.isNullValue( workingMemory, object1 )) {
return extractor2.isNullValue( workingMemory, object2 );
} else if (extractor2.isNullValue( workingMemory, object2 )) {
return false;
}
-
+
return extractor1.getIntValue( workingMemory, object1 ) == extractor2.getIntValue( workingMemory, object2 );
}
@@ -1487,27 +1497,27 @@
}
- static class IntegerNotEqualEvaluator extends BaseEvaluator {
+ public static class IntegerNotEqualEvaluator extends BaseEvaluator {
/**
- *
+ *
*/
private static final long serialVersionUID = 400L;
public final static Evaluator INSTANCE = new IntegerNotEqualEvaluator();
- private IntegerNotEqualEvaluator() {
+ public IntegerNotEqualEvaluator() {
super( ValueType.PINTEGER_TYPE,
Operator.NOT_EQUAL );
}
public boolean evaluate(InternalWorkingMemory workingMemory,
final Extractor extractor,
- final Object object1, final FieldValue object2) {
+ final Object object1, final FieldValue object2) {
if ( extractor.isNullValue( workingMemory, object1 ) ) {
return !object2.isNull();
} else if ( object2.isNull() ) {
return true;
}
-
+
return extractor.getIntValue( workingMemory, object1 ) != object2.getIntValue();
}
@@ -1518,7 +1528,7 @@
} else if ( context.isRightNull() ) {
return true;
}
-
+
return context.declaration.getExtractor().getIntValue( workingMemory, left ) != ((LongVariableContextEntry) context).right;
}
@@ -1529,7 +1539,7 @@
} else if ( context.isLeftNull() ) {
return true;
}
-
+
return context.extractor.getIntValue( workingMemory, object2 ) != ((LongVariableContextEntry) context).left;
}
@@ -1542,7 +1552,7 @@
} else if (extractor2.isNullValue( workingMemory, object2 )) {
return true;
}
-
+
return extractor1.getIntValue( workingMemory, object1 ) != extractor2.getIntValue( workingMemory, object2 );
}
@@ -1551,14 +1561,14 @@
}
}
- static class LongEqualEvaluator extends BaseEvaluator {
+ public static class LongEqualEvaluator extends BaseEvaluator {
/**
- *
+ *
*/
private static final long serialVersionUID = 400L;
public final static Evaluator INSTANCE = new LongEqualEvaluator();
- private LongEqualEvaluator() {
+ public LongEqualEvaluator() {
super( ValueType.PLONG_TYPE,
Operator.EQUAL );
}
@@ -1571,7 +1581,7 @@
} else if ( object2.isNull() ) {
return false;
}
-
+
return extractor.getLongValue( workingMemory, object1 ) == object2.getLongValue();
}
@@ -1582,7 +1592,7 @@
} else if ( context.isRightNull() ) {
return false;
}
-
+
return context.declaration.getExtractor().getLongValue( workingMemory, left ) == ((LongVariableContextEntry) context).right;
}
@@ -1593,7 +1603,7 @@
} else if ( context.isLeftNull() ) {
return false;
}
-
+
return ((LongVariableContextEntry) context).left == context.extractor.getLongValue( workingMemory, right );
}
@@ -1606,7 +1616,7 @@
} else if (extractor2.isNullValue( workingMemory, object2 )) {
return false;
}
-
+
return extractor1.getLongValue( workingMemory, object1 ) == extractor2.getLongValue( workingMemory, object2 );
}
@@ -1615,14 +1625,14 @@
}
}
- static class LongNotEqualEvaluator extends BaseEvaluator {
+ public static class LongNotEqualEvaluator extends BaseEvaluator {
/**
- *
+ *
*/
private static final long serialVersionUID = 400L;
public final static Evaluator INSTANCE = new LongNotEqualEvaluator();
- private LongNotEqualEvaluator() {
+ public LongNotEqualEvaluator() {
super( ValueType.PLONG_TYPE,
Operator.NOT_EQUAL );
}
@@ -1635,7 +1645,7 @@
} else if ( object2.isNull() ) {
return true;
}
-
+
return extractor.getLongValue( workingMemory, object1 ) != object2.getLongValue();
}
@@ -1646,7 +1656,7 @@
} else if ( context.isRightNull() ) {
return true;
}
-
+
return context.declaration.getExtractor().getLongValue( workingMemory, left ) != ((LongVariableContextEntry) context).right;
}
@@ -1657,7 +1667,7 @@
} else if ( context.isLeftNull() ) {
return true;
}
-
+
return ((LongVariableContextEntry) context).left != context.extractor.getLongValue( workingMemory, right );
}
@@ -1670,7 +1680,7 @@
} else if (extractor2.isNullValue( workingMemory, object2 )) {
return true;
}
-
+
return extractor1.getLongValue( workingMemory, object1 ) != extractor2.getLongValue( workingMemory, object2 );
}
@@ -1679,15 +1689,15 @@
}
}
- static class ObjectEqualEvaluator extends BaseEvaluator {
+ public static class ObjectEqualEvaluator extends BaseEvaluator {
/**
- *
+ *
*/
private static final long serialVersionUID = 400L;
public final static Evaluator INSTANCE = new ObjectEqualEvaluator();
- private static final ObjectEqualsComparator comparator = new ObjectEqualsComparator();
-
- private ObjectEqualEvaluator() {
+ private static final ObjectEqualsComparator comparator = new ObjectEqualsComparator();
+
+ public ObjectEqualEvaluator() {
super( ValueType.OBJECT_TYPE,
Operator.EQUAL );
}
@@ -1751,15 +1761,15 @@
}
- static class ObjectNotEqualEvaluator extends BaseEvaluator {
+ public static class ObjectNotEqualEvaluator extends BaseEvaluator {
/**
- *
+ *
*/
private static final long serialVersionUID = 400L;
public final static Evaluator INSTANCE = new ObjectNotEqualEvaluator();
- private static final ObjectEqualsComparator comparator = new ObjectEqualsComparator();
+ private static final ObjectEqualsComparator comparator = new ObjectEqualsComparator();
- private ObjectNotEqualEvaluator() {
+ public ObjectNotEqualEvaluator() {
super( ValueType.OBJECT_TYPE,
Operator.NOT_EQUAL );
}
@@ -1822,14 +1832,14 @@
}
}
- static class ShortEqualEvaluator extends BaseEvaluator {
+ public static class ShortEqualEvaluator extends BaseEvaluator {
/**
- *
+ *
*/
private static final long serialVersionUID = 400L;
private static final Evaluator INSTANCE = new ShortEqualEvaluator();
- private ShortEqualEvaluator() {
+ public ShortEqualEvaluator() {
super( ValueType.PSHORT_TYPE,
Operator.EQUAL );
}
@@ -1842,7 +1852,7 @@
} else if ( object2.isNull() ) {
return false;
}
-
+
return extractor.getShortValue( workingMemory, object1 ) == object2.getShortValue();
}
@@ -1853,7 +1863,7 @@
} else if ( context.isRightNull() ) {
return false;
}
-
+
return context.declaration.getExtractor().getShortValue( workingMemory, left ) == ((LongVariableContextEntry) context).right;
}
@@ -1864,7 +1874,7 @@
} else if ( context.isLeftNull() ) {
return false;
}
-
+
return ((LongVariableContextEntry) context).left == context.extractor.getShortValue( workingMemory, right );
}
@@ -1877,7 +1887,7 @@
} else if (extractor2.isNullValue( workingMemory, object2 )) {
return false;
}
-
+
return extractor1.getShortValue( workingMemory, object1 ) == extractor2.getShortValue( workingMemory, object2 );
}
@@ -1886,14 +1896,14 @@
}
}
- static class ShortNotEqualEvaluator extends BaseEvaluator {
+ public static class ShortNotEqualEvaluator extends BaseEvaluator {
/**
- *
+ *
*/
private static final long serialVersionUID = 400L;
private static final Evaluator INSTANCE = new ShortNotEqualEvaluator();
- private ShortNotEqualEvaluator() {
+ public ShortNotEqualEvaluator() {
super( ValueType.PSHORT_TYPE,
Operator.NOT_EQUAL );
}
@@ -1906,7 +1916,7 @@
} else if ( object2.isNull() ) {
return true;
}
-
+
return extractor.getShortValue( workingMemory, object1 ) != object2.getShortValue();
}
@@ -1917,7 +1927,7 @@
} else if ( context.isRightNull() ) {
return true;
}
-
+
return context.declaration.getExtractor().getShortValue( workingMemory, left ) != ((LongVariableContextEntry) context).right;
}
@@ -1928,7 +1938,7 @@
} else if ( context.isLeftNull() ) {
return true;
}
-
+
return ((LongVariableContextEntry) context).left != context.extractor.getShortValue( workingMemory, right );
}
@@ -1941,7 +1951,7 @@
} else if (extractor2.isNullValue( workingMemory, object2 )) {
return true;
}
-
+
return extractor1.getShortValue( workingMemory, object1 ) != extractor2.getShortValue( workingMemory, object2 );
}
@@ -1950,14 +1960,14 @@
}
}
- static class StringEqualEvaluator extends BaseEvaluator {
+ static public class StringEqualEvaluator extends BaseEvaluator {
/**
*
*/
private static final long serialVersionUID = 400L;
public final static Evaluator INSTANCE = new StringEqualEvaluator();
- private StringEqualEvaluator() {
+ public StringEqualEvaluator() {
super( ValueType.STRING_TYPE,
Operator.EQUAL );
}
@@ -2009,14 +2019,14 @@
}
- static class StringNotEqualEvaluator extends BaseEvaluator {
+ public static class StringNotEqualEvaluator extends BaseEvaluator {
/**
*
*/
private static final long serialVersionUID = 400L;
public final static Evaluator INSTANCE = new StringNotEqualEvaluator();
- private StringNotEqualEvaluator() {
+ public StringNotEqualEvaluator() {
super( ValueType.STRING_TYPE,
Operator.NOT_EQUAL );
}
@@ -2087,8 +2097,8 @@
} else {
throw new ClassCastException( "Not possible to convert "+arg1.getClass()+" into a double value to compare it to "+arg0.getClass() );
}
- return val0 == val1; // in the future we may need to handle rounding errors
- }
+ return val0 == val1; // in the future we may need to handle rounding errors
+ }
if( arg0 instanceof String ) {
return arg0.equals( arg1.toString() );
}
@@ -2105,6 +2115,6 @@
return arg0.equals( arg1 );
}
}
-
+
}
Modified: labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/base/evaluators/EvaluatorCache.java
===================================================================
--- labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/base/evaluators/EvaluatorCache.java 2008-03-20 18:57:07 UTC (rev 19163)
+++ labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/base/evaluators/EvaluatorCache.java 2008-03-20 19:32:10 UTC (rev 19164)
@@ -1,12 +1,12 @@
/*
* Copyright 2007 JBoss Inc
- *
+ *
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -17,28 +17,43 @@
*/
package org.drools.base.evaluators;
-import java.io.Serializable;
+import org.drools.base.ValueType;
+import org.drools.spi.Evaluator;
+
+import java.io.Externalizable;
+import java.io.IOException;
+import java.io.ObjectInput;
+import java.io.ObjectOutput;
import java.util.HashMap;
import java.util.Map;
-import org.drools.base.ValueType;
-import org.drools.spi.Evaluator;
-
/**
- * A simple helper class to store Evaluators for a given set of
+ * A simple helper class to store Evaluators for a given set of
* value types and operators
- *
+ *
* @author etirelli
*/
-public class EvaluatorCache implements Serializable {
-
+public class EvaluatorCache implements Externalizable {
private static final long serialVersionUID = 5643974484372543392L;
private Map<ValueType, Map<Operator, Evaluator>> evaluators = new HashMap<ValueType, Map<Operator, Evaluator>>();
-
+
public EvaluatorCache() {
}
-
+
+ public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
+ Map<ValueType, Map<Operator, Evaluator>> temp = (Map<ValueType, Map<Operator, Evaluator>>)in.readObject();
+
+ for (Map.Entry<ValueType, Map<Operator, Evaluator>> entry : temp.entrySet()) {
+ evaluators.put(ValueType.determineValueType(entry.getKey().getClassType()),
+ entry.getValue());
+ }
+ }
+
+ public void writeExternal(ObjectOutput out) throws IOException {
+ out.writeObject(evaluators);
+ }
+
public void addEvaluator( final ValueType type, final Operator operator, final Evaluator evaluator ) {
Map<Operator, Evaluator> opEvalMap = this.evaluators.get( type );
if( opEvalMap == null ) {
@@ -47,7 +62,7 @@
}
opEvalMap.put( operator, evaluator );
}
-
+
public Evaluator getEvaluator( final ValueType type, final Operator operator ) {
Map<Operator, Evaluator> opEvalMap = this.evaluators.get( type );
return opEvalMap != null ? opEvalMap.get( operator ) : null;
Modified: labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/base/evaluators/EvaluatorDefinition.java
===================================================================
--- labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/base/evaluators/EvaluatorDefinition.java 2008-03-20 18:57:07 UTC (rev 19163)
+++ labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/base/evaluators/EvaluatorDefinition.java 2008-03-20 19:32:10 UTC (rev 19164)
@@ -1,12 +1,12 @@
/*
* Copyright 2007 JBoss Inc
- *
+ *
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -20,21 +20,23 @@
import org.drools.base.ValueType;
import org.drools.spi.Evaluator;
+import java.io.Externalizable;
+
/**
* An evaluator definition interface that allows for pluggable
* evaluator implementation.
- *
+ *
* This interface is the registry entry point for all available
* evaluators and describes all evaluator capabilities
- *
+ *
* @author etirelli
*/
-public interface EvaluatorDefinition {
+public interface EvaluatorDefinition extends Externalizable {
/**
* Returns the list of identifies this
* evaluator implementation supports
- *
+ *
* @return
*/
public String[] getEvaluatorIds();
@@ -42,11 +44,11 @@
/**
* My appologies to english speakers if the word "negatable" does not
* exists. :)
- *
+ *
* This method returns true if this evaluator supports negation. Example:
- *
+ *
* the "matches" operator supports "not matches" and so is "negatable" (!?)
- *
+ *
* @return
*/
public boolean isNegatable();
@@ -54,25 +56,25 @@
/**
* Returns the evaluator instance for the given type and the
* defined parameterText
- *
- * @param type the type of the attributes this evaluator will
+ *
+ * @param type the type of the attributes this evaluator will
* operate on. This is important because the evaluator
- * may do optimizations and type coercion based on the
- * types it is evaluating. It is also possible that
+ * may do optimizations and type coercion based on the
+ * types it is evaluating. It is also possible that
* this evaluator does not support a given type.
- *
- * @param operatorId the string identifier of the evaluator
- *
+ *
+ * @param operatorId the string identifier of the evaluator
+ *
* @param isNegated true if the evaluator instance to be returned is
* the negated version of the evaluator.
- *
- * @param parameterText some evaluators support parameters and these
- * parameters are defined as a String that is
+ *
+ * @param parameterText some evaluators support parameters and these
+ * parameters are defined as a String that is
* parsed by the evaluator itself.
- *
+ *
* @return an Evaluator instance capable of evaluating expressions
* between values of the given type, or null in case the type
- * is not supported.
+ * is not supported.
*/
public Evaluator getEvaluator(ValueType type,
String operatorId,
@@ -82,22 +84,22 @@
/**
* Returns the evaluator instance for the given type and the
* defined parameterText
- *
- * @param type the type of the attributes this evaluator will
+ *
+ * @param type the type of the attributes this evaluator will
* operate on. This is important because the evaluator
- * may do optimizations and type coercion based on the
- * types it is evaluating. It is also possible that
+ * may do optimizations and type coercion based on the
+ * types it is evaluating. It is also possible that
* this evaluator does not support a given type.
- *
- * @param operator the operator implemented by the evaluator
- *
- * @param parameterText some evaluators support parameters and these
- * parameters are defined as a String that is
+ *
+ * @param operator the operator implemented by the evaluator
+ *
+ * @param parameterText some evaluators support parameters and these
+ * parameters are defined as a String that is
* parsed by the evaluator itself.
- *
+ *
* @return an Evaluator instance capable of evaluating expressions
* between values of the given type, or null in case the type
- * is not supported.
+ * is not supported.
*/
public Evaluator getEvaluator(ValueType type,
Operator operator,
@@ -106,35 +108,35 @@
/**
* Returns the evaluator instance for the given type and the
* defined parameterText
- *
- * @param type the type of the attributes this evaluator will
+ *
+ * @param type the type of the attributes this evaluator will
* operate on. This is important because the evaluator
- * may do optimizations and type coercion based on the
- * types it is evaluating. It is also possible that
+ * may do optimizations and type coercion based on the
+ * types it is evaluating. It is also possible that
* this evaluator does not support a given type.
- *
- * @param operator the operator implemented by the evaluator
- *
+ *
+ * @param operator the operator implemented by the evaluator
+ *
* @return an Evaluator instance capable of evaluating expressions
* between values of the given type, or null in case the type
- * is not supported.
+ * is not supported.
*/
public Evaluator getEvaluator(ValueType type,
Operator operator);
/**
- * Returns true in case this evaluator supports operations over values
+ * Returns true in case this evaluator supports operations over values
* of that specific type.
- *
+ *
* @param type
* @return
*/
public boolean supportsType(ValueType type);
/**
- * There are evaluators that operate on *fact handle* attributes and
+ * There are evaluators that operate on *fact handle* attributes and
* evaluators that operate on *fact* attributes.
- *
+ *
* @return true if this evaluator operates on fact handle attributes
* and false if it operates on fact attributes
*/
Modified: labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/base/evaluators/EvaluatorRegistry.java
===================================================================
--- labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/base/evaluators/EvaluatorRegistry.java 2008-03-20 18:57:07 UTC (rev 19163)
+++ labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/base/evaluators/EvaluatorRegistry.java 2008-03-20 19:32:10 UTC (rev 19164)
@@ -1,12 +1,12 @@
/*
* Copyright 2007 JBoss Inc
- *
+ *
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -17,22 +17,26 @@
*/
package org.drools.base.evaluators;
-import java.io.Serializable;
+import java.io.Externalizable;
+import java.io.ObjectInput;
+import java.io.IOException;
+import java.io.ObjectOutput;
import java.util.HashMap;
import java.util.Map;
import org.drools.RuntimeDroolsException;
+import org.drools.common.DroolsObjectInput;
import org.drools.base.ValueType;
import org.drools.spi.Evaluator;
/**
* A registry class for all available evaluators
- *
+ *
* @author etirelli
*/
public class EvaluatorRegistry
implements
- Serializable {
+ Externalizable {
private static final long serialVersionUID = -3047718531857258033L;
@@ -41,7 +45,7 @@
/**
* Default constructor. The registry will use the context classloader (if available)
- * to load the evaluator definition classes or this class classloader if it is
+ * to load the evaluator definition classes or this class classloader if it is
* not available.
*/
public EvaluatorRegistry() {
@@ -50,22 +54,22 @@
/**
* Creates a new EvaluatorRegistry using the given classloader to load
- * the evaluator definition classes.
- *
+ * the evaluator definition classes.
+ *
* @param classloader the classloader to use to load evaluator definition
* classes. If it is null, try to obtain the context
* classloader. If it is also null, uses the same classloader
* that loaded this class.
- *
+ *
*/
public EvaluatorRegistry(ClassLoader classloader) {
this.evaluators = new HashMap<String, EvaluatorDefinition>();
if ( classloader != null ) {
this.classloader = classloader;
} else {
- this.classloader = Thread.currentThread().getContextClassLoader() != null ? Thread.currentThread().getContextClassLoader() : this.getClass().getClassLoader();
+ this.classloader = getDefaultClassLoader();
}
-
+
// loading default built in evaluators
this.addEvaluatorDefinition( new EqualityEvaluatorsDefinition() );
this.addEvaluatorDefinition( new ComparableEvaluatorsDefinition() );
@@ -74,16 +78,35 @@
this.addEvaluatorDefinition( new SoundslikeEvaluatorsDefinition() );
}
+ public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
+ evaluators = (Map<String, EvaluatorDefinition>)in.readObject();
+ if (in instanceof DroolsObjectInput) {
+ classloader = ((DroolsObjectInput)in).getClassLoader();
+ } else {
+ classloader = getDefaultClassLoader();
+ }
+ }
+
+ public void writeExternal(ObjectOutput out) throws IOException {
+ out.writeObject(evaluators);
+ }
+
+ private static ClassLoader getDefaultClassLoader() {
+ if (Thread.currentThread().getContextClassLoader() != null)
+ return Thread.currentThread().getContextClassLoader();
+ return EvaluatorRegistry.class.getClassLoader();
+ }
+
/**
* Adds an evaluator definition class to the registry using the
* evaluator class name. The class will be loaded and the corresponting
* evaluator ID will be added to the registry. In case there exists
* an implementation for that ID already, the new implementation will
* replace the previous one.
- *
+ *
* @param className the name of the class for the implementation definition.
* The class must implement the EvaluatorDefinition interface.
- *
+ *
* @return true if the new class implementation is replacing an old
* implementation for the same evaluator ID. False otherwise.
*/
@@ -108,7 +131,7 @@
* Adds an evaluator definition class to the registry. In case there exists
* an implementation for that evaluator ID already, the new implementation will
* replace the previous one.
- *
+ *
* @param def the evaluator definition to be added.
*/
public void addEvaluatorDefinition(EvaluatorDefinition def) {
@@ -121,7 +144,7 @@
/**
* Returns the evaluator definition for the given evaluator ID
* or null if no one was found
- *
+ *
* @param evaluatorId
* @return
*/
@@ -132,7 +155,7 @@
/**
* Returns the evaluator definition for the given operator
* or null if no one was found
- *
+ *
* @param operator the operator implemented by the evaluator definition
* @return
*/
@@ -143,25 +166,25 @@
/**
* Returns the evaluator instance for the given type and the
* defined parameterText
- *
- * @param type the type of the attributes this evaluator will
+ *
+ * @param type the type of the attributes this evaluator will
* operate on. This is important because the evaluator
- * may do optimizations and type coercion based on the
- * types it is evaluating. It is also possible that
+ * may do optimizations and type coercion based on the
+ * types it is evaluating. It is also possible that
* this evaluator does not support a given type.
- *
- * @param operatorId the string identifier of the evaluator
- *
+ *
+ * @param operatorId the string identifier of the evaluator
+ *
* @param isNegated true if the evaluator instance to be returned is
* the negated version of the evaluator.
- *
- * @param parameterText some evaluators support parameters and these
- * parameters are defined as a String that is
+ *
+ * @param parameterText some evaluators support parameters and these
+ * parameters are defined as a String that is
* parsed by the evaluator itself.
- *
+ *
* @return an Evaluator instance capable of evaluating expressions
* between values of the given type, or null in case the type
- * is not supported.
+ * is not supported.
*/
public Evaluator getEvaluator(ValueType type,
String operatorId,
@@ -176,22 +199,22 @@
/**
* Returns the evaluator instance for the given type and the
* defined parameterText
- *
- * @param type the type of the attributes this evaluator will
+ *
+ * @param type the type of the attributes this evaluator will
* operate on. This is important because the evaluator
- * may do optimizations and type coercion based on the
- * types it is evaluating. It is also possible that
+ * may do optimizations and type coercion based on the
+ * types it is evaluating. It is also possible that
* this evaluator does not support a given type.
- *
- * @param operator the operator that evaluator implements
- *
- * @param parameterText some evaluators support parameters and these
- * parameters are defined as a String that is
+ *
+ * @param operator the operator that evaluator implements
+ *
+ * @param parameterText some evaluators support parameters and these
+ * parameters are defined as a String that is
* parsed by the evaluator itself.
- *
+ *
* @return an Evaluator instance capable of evaluating expressions
* between values of the given type, or null in case the type
- * is not supported.
+ * is not supported.
*/
public Evaluator getEvaluator(ValueType type,
Operator operator,
@@ -204,18 +227,18 @@
/**
* Returns the evaluator instance for the given type and the
* defined parameterText
- *
- * @param type the type of the attributes this evaluator will
+ *
+ * @param type the type of the attributes this evaluator will
* operate on. This is important because the evaluator
- * may do optimizations and type coercion based on the
- * types it is evaluating. It is also possible that
+ * may do optimizations and type coercion based on the
+ * types it is evaluating. It is also possible that
* this evaluator does not support a given type.
- *
- * @param operator the operator that evaluator implements
- *
+ *
+ * @param operator the operator that evaluator implements
+ *
* @return an Evaluator instance capable of evaluating expressions
* between values of the given type, or null in case the type
- * is not supported.
+ * is not supported.
*/
public Evaluator getEvaluator(ValueType type,
Operator operator) {
Modified: labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/base/evaluators/FinishedByEvaluatorDefinition.java
===================================================================
--- labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/base/evaluators/FinishedByEvaluatorDefinition.java 2008-03-20 18:57:07 UTC (rev 19163)
+++ labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/base/evaluators/FinishedByEvaluatorDefinition.java 2008-03-20 19:32:10 UTC (rev 19164)
@@ -1,12 +1,12 @@
/*
* Copyright 2007 JBoss Inc
- *
+ *
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -20,6 +20,9 @@
import java.util.Collections;
import java.util.HashMap;
import java.util.Map;
+import java.io.ObjectInput;
+import java.io.IOException;
+import java.io.ObjectOutput;
import org.drools.RuntimeDroolsException;
import org.drools.base.BaseEvaluator;
@@ -35,7 +38,7 @@
/**
* The implementation of the 'finishedby' evaluator definition
- *
+ *
* @author mgroch
*/
public class FinishedByEvaluatorDefinition
@@ -46,11 +49,19 @@
false );
public static final Operator NOT_FINISHED_BY = Operator.addOperatorToRegistry( "finishedby",
true );
-
+
private static final String[] SUPPORTED_IDS = { FINISHED_BY.getOperatorString() };
-
+
private Map<String, FinishedByEvaluator> cache = Collections.emptyMap();
+ public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
+ cache = (Map<String, FinishedByEvaluator>)in.readObject();
+ }
+
+ public void writeExternal(ObjectOutput out) throws IOException {
+ out.writeObject(cache);
+ }
+
/**
* @inheridDoc
*/
@@ -131,10 +142,13 @@
*/
public static class FinishedByEvaluator extends BaseEvaluator {
private static final long serialVersionUID = -5156972073099070733L;
-
+
private long startMinDev, startMaxDev;
private long endDev;
+ public FinishedByEvaluator() {
+ }
+
public FinishedByEvaluator(final ValueType type,
final boolean isNegated,
final String parameters) {
@@ -142,12 +156,26 @@
isNegated ? NOT_FINISHED_BY : FINISHED_BY );
this.parseParameters( parameters );
}
-
+
+ public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
+ super.readExternal(in);
+ startMinDev = in.readLong();
+ startMaxDev = in.readLong();
+ endDev = in.readLong();
+ }
+
+ public void writeExternal(ObjectOutput out) throws IOException {
+ super.writeExternal(out);
+ out.writeLong(startMinDev);
+ out.writeLong(startMaxDev);
+ out.writeLong(endDev);
+ }
+
@Override
public Object prepareObject(InternalFactHandle handle) {
return handle;
}
-
+
public boolean evaluate(InternalWorkingMemory workingMemory,
final Extractor extractor,
final Object object1,
@@ -158,16 +186,16 @@
public boolean evaluateCachedRight(InternalWorkingMemory workingMemory,
final VariableContextEntry context,
final Object left) {
-
+
if ( context.rightNull ) {
return false;
}
long distStart = ((EventFactHandle) left ).getStartTimestamp() - ((EventFactHandle)((ObjectVariableContextEntry) context).right).getStartTimestamp();
long distEnd = Math.abs(((EventFactHandle) left ).getEndTimestamp() - ((EventFactHandle)((ObjectVariableContextEntry) context).right).getEndTimestamp());
- return this.getOperator().isNegated() ^ ( distStart >= this.startMinDev && distStart <= this.startMaxDev
+ return this.getOperator().isNegated() ^ ( distStart >= this.startMinDev && distStart <= this.startMaxDev
&& distEnd <= this.endDev );
}
-
+
public boolean evaluateCachedLeft(InternalWorkingMemory workingMemory,
final VariableContextEntry context,
final Object right) {
@@ -177,10 +205,10 @@
}
long distStart = ((EventFactHandle) ((ObjectVariableContextEntry) context).left).getStartTimestamp() - ((EventFactHandle) right ).getStartTimestamp();
long distEnd = Math.abs(((EventFactHandle) ((ObjectVariableContextEntry) context).left).getEndTimestamp() - ((EventFactHandle) right ).getEndTimestamp());
- return this.getOperator().isNegated() ^ ( distStart >= this.startMinDev && distStart <= this.startMaxDev
+ return this.getOperator().isNegated() ^ ( distStart >= this.startMinDev && distStart <= this.startMaxDev
&& distEnd <= this.endDev );
}
-
+
public boolean evaluate(InternalWorkingMemory workingMemory,
final Extractor extractor1,
final Object object1,
@@ -192,7 +220,7 @@
}
long distStart = ((EventFactHandle) object2 ).getStartTimestamp() - ((EventFactHandle) object1 ).getStartTimestamp();
long distEnd = Math.abs(((EventFactHandle) object2 ).getEndTimestamp() - ((EventFactHandle) object1 ).getEndTimestamp());
- return this.getOperator().isNegated() ^ ( distStart >= this.startMinDev && distStart <= this.startMaxDev
+ return this.getOperator().isNegated() ^ ( distStart >= this.startMinDev && distStart <= this.startMaxDev
&& distEnd <= this.endDev );
}
@@ -226,9 +254,9 @@
}
/**
- * This methods tries to parse the string of parameters to customize
+ * This methods tries to parse the string of parameters to customize
* the evaluator.
- *
+ *
* @param parameters
*/
private void parseParameters(String parameters) {
@@ -250,13 +278,13 @@
this.endDev = 0;
} else if ( ranges.length == 2 ) {
// exact matching at the end of the intervals
- // range for deviations of the starts of the intervals
+ // range for deviations of the starts of the intervals
this.startMinDev = Long.parseLong( ranges[0] );
this.startMaxDev = Long.parseLong( ranges[1] );
this.endDev = 0;
} else if ( ranges.length == 3 ) {
// max. deviation at the ends of the intervals
- // range for deviations of the starts of the intervals
+ // range for deviations of the starts of the intervals
this.startMinDev = Long.parseLong( ranges[0] );
this.startMaxDev = Long.parseLong( ranges[1] );
this.endDev = Long.parseLong( ranges[2] );
Modified: labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/base/evaluators/FinishesEvaluatorDefinition.java
===================================================================
--- labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/base/evaluators/FinishesEvaluatorDefinition.java 2008-03-20 18:57:07 UTC (rev 19163)
+++ labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/base/evaluators/FinishesEvaluatorDefinition.java 2008-03-20 19:32:10 UTC (rev 19164)
@@ -1,12 +1,12 @@
/*
* Copyright 2007 JBoss Inc
- *
+ *
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -20,6 +20,9 @@
import java.util.Collections;
import java.util.HashMap;
import java.util.Map;
+import java.io.ObjectInput;
+import java.io.IOException;
+import java.io.ObjectOutput;
import org.drools.RuntimeDroolsException;
import org.drools.base.BaseEvaluator;
@@ -35,7 +38,7 @@
/**
* The implementation of the 'finishes' evaluator definition
- *
+ *
* @author mgroch
*/
public class FinishesEvaluatorDefinition
@@ -46,11 +49,19 @@
false );
public static final Operator FINISHES_NOT = Operator.addOperatorToRegistry( "finishes",
true );
-
+
private static final String[] SUPPORTED_IDS = { FINISHES.getOperatorString() };
-
+
private Map<String, FinishesEvaluator> cache = Collections.emptyMap();
+ public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
+ cache = (Map<String, FinishesEvaluator>)in.readObject();
+ }
+
+ public void writeExternal(ObjectOutput out) throws IOException {
+ out.writeObject(cache);
+ }
+
/**
* @inheridDoc
*/
@@ -131,10 +142,13 @@
*/
public static class FinishesEvaluator extends BaseEvaluator {
private static final long serialVersionUID = 6232789044144077522L;
-
+
private long startMinDev, startMaxDev;
private long endDev;
+ public FinishesEvaluator() {
+ }
+
public FinishesEvaluator(final ValueType type,
final boolean isNegated,
final String parameters) {
@@ -142,12 +156,28 @@
isNegated ? FINISHES_NOT : FINISHES );
this.parseParameters( parameters );
}
-
+
+ public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
+ super.readExternal(in);
+ startMinDev = in.readLong();
+ startMaxDev = in.readLong();
+ endDev = in.readLong();
+ }
+
+ public void writeExternal(ObjectOutput out) throws IOException {
+ super.writeExternal(out);
+ out.writeLong(startMinDev);
+ out.writeLong(startMaxDev);
+ out.writeLong(endDev);
+ }
+
+
+
@Override
public Object prepareObject(InternalFactHandle handle) {
return handle;
}
-
+
public boolean evaluate(InternalWorkingMemory workingMemory,
final Extractor extractor,
final Object object1,
@@ -158,16 +188,16 @@
public boolean evaluateCachedRight(InternalWorkingMemory workingMemory,
final VariableContextEntry context,
final Object left) {
-
+
if ( context.rightNull ) {
return false;
}
long distStart = ((EventFactHandle)((ObjectVariableContextEntry) context).right).getStartTimestamp() - ((EventFactHandle) left ).getStartTimestamp();
long distEnd = Math.abs(((EventFactHandle) left ).getEndTimestamp() - ((EventFactHandle)((ObjectVariableContextEntry) context).right).getEndTimestamp());
- return this.getOperator().isNegated() ^ ( distStart >= this.startMinDev && distStart <= this.startMaxDev
+ return this.getOperator().isNegated() ^ ( distStart >= this.startMinDev && distStart <= this.startMaxDev
&& distEnd <= this.endDev );
}
-
+
public boolean evaluateCachedLeft(InternalWorkingMemory workingMemory,
final VariableContextEntry context,
final Object right) {
@@ -177,10 +207,10 @@
}
long distStart = ((EventFactHandle) right ).getStartTimestamp() - ((EventFactHandle) ((ObjectVariableContextEntry) context).left).getStartTimestamp();
long distEnd = Math.abs(((EventFactHandle) ((ObjectVariableContextEntry) context).left).getEndTimestamp() - ((EventFactHandle) right ).getEndTimestamp());
- return this.getOperator().isNegated() ^ ( distStart >= this.startMinDev && distStart <= this.startMaxDev
+ return this.getOperator().isNegated() ^ ( distStart >= this.startMinDev && distStart <= this.startMaxDev
&& distEnd <= this.endDev );
}
-
+
public boolean evaluate(InternalWorkingMemory workingMemory,
final Extractor extractor1,
final Object object1,
@@ -192,7 +222,7 @@
}
long distStart = ((EventFactHandle) object1 ).getStartTimestamp() - ((EventFactHandle) object2 ).getStartTimestamp();
long distEnd = Math.abs(((EventFactHandle) object2 ).getEndTimestamp() - ((EventFactHandle) object1 ).getEndTimestamp());
- return this.getOperator().isNegated() ^ ( distStart >= this.startMinDev && distStart <= this.startMaxDev
+ return this.getOperator().isNegated() ^ ( distStart >= this.startMinDev && distStart <= this.startMaxDev
&& distEnd <= this.endDev );
}
@@ -226,9 +256,9 @@
}
/**
- * This methods tries to parse the string of parameters to customize
+ * This methods tries to parse the string of parameters to customize
* the evaluator.
- *
+ *
* @param parameters
*/
private void parseParameters(String parameters) {
@@ -250,13 +280,13 @@
this.endDev = 0;
} else if ( ranges.length == 2 ) {
// exact matching at the end of the intervals
- // range for deviations of the starts of the intervals
+ // range for deviations of the starts of the intervals
this.startMinDev = Long.parseLong( ranges[0] );
this.startMaxDev = Long.parseLong( ranges[1] );
this.endDev = 0;
} else if ( ranges.length == 3 ) {
// max. deviation at the ends of the intervals
- // range for deviations of the starts of the intervals
+ // range for deviations of the starts of the intervals
this.startMinDev = Long.parseLong( ranges[0] );
this.startMaxDev = Long.parseLong( ranges[1] );
this.endDev = Long.parseLong( ranges[2] );
Modified: labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/base/evaluators/IncludesEvaluatorDefinition.java
===================================================================
--- labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/base/evaluators/IncludesEvaluatorDefinition.java 2008-03-20 18:57:07 UTC (rev 19163)
+++ labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/base/evaluators/IncludesEvaluatorDefinition.java 2008-03-20 19:32:10 UTC (rev 19164)
@@ -1,12 +1,12 @@
/*
* Copyright 2007 JBoss Inc
- *
+ *
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -20,6 +20,9 @@
import java.util.Collections;
import java.util.HashMap;
import java.util.Map;
+import java.io.ObjectInput;
+import java.io.IOException;
+import java.io.ObjectOutput;
import org.drools.RuntimeDroolsException;
import org.drools.base.BaseEvaluator;
@@ -35,7 +38,7 @@
/**
* The implementation of the 'includes' evaluator definition
- *
+ *
* @author mgroch
*/
public class IncludesEvaluatorDefinition
@@ -46,11 +49,19 @@
false );
public static final Operator INCLUDES_NOT = Operator.addOperatorToRegistry( "includes",
true );
-
+
private static final String[] SUPPORTED_IDS = { INCLUDES.getOperatorString() };
-
+
private Map<String, IncludesEvaluator> cache = Collections.emptyMap();
+ public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
+ cache = (Map<String, IncludesEvaluator>)in.readObject();
+ }
+
+ public void writeExternal(ObjectOutput out) throws IOException {
+ out.writeObject(cache);
+ }
+
/**
* @inheridDoc
*/
@@ -131,10 +142,13 @@
*/
public static class IncludesEvaluator extends BaseEvaluator {
private static final long serialVersionUID = -5947397607962049251L;
-
+
private long startMinDev, startMaxDev;
private long endMinDev, endMaxDev;
+ public IncludesEvaluator() {
+ }
+
public IncludesEvaluator(final ValueType type,
final boolean isNegated,
final String parameters) {
@@ -142,12 +156,28 @@
isNegated ? INCLUDES_NOT : INCLUDES );
this.parseParameters( parameters );
}
-
+
+ public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
+ super.readExternal(in);
+ startMinDev = in.readLong();
+ startMaxDev = in.readLong();
+ endMinDev = in.readLong();
+ endMaxDev = in.readLong();
+ }
+
+ public void writeExternal(ObjectOutput out) throws IOException {
+ super.writeExternal(out);
+ out.writeLong(startMinDev);
+ out.writeLong(startMaxDev);
+ out.writeLong(endMinDev);
+ out.writeLong(endMaxDev);
+ }
+
@Override
public Object prepareObject(InternalFactHandle handle) {
return handle;
}
-
+
public boolean evaluate(InternalWorkingMemory workingMemory,
final Extractor extractor,
final Object object1,
@@ -158,16 +188,16 @@
public boolean evaluateCachedRight(InternalWorkingMemory workingMemory,
final VariableContextEntry context,
final Object left) {
-
+
if ( context.rightNull ) {
return false;
}
long distStart = ((EventFactHandle) left ).getStartTimestamp() - ((EventFactHandle)((ObjectVariableContextEntry) context).right).getStartTimestamp();
long distEnd = ((EventFactHandle)((ObjectVariableContextEntry) context).right).getEndTimestamp() - ((EventFactHandle) left ).getEndTimestamp();
- return this.getOperator().isNegated() ^ ( distStart >= this.startMinDev && distStart <= this.startMaxDev
+ return this.getOperator().isNegated() ^ ( distStart >= this.startMinDev && distStart <= this.startMaxDev
&& distEnd >= this.endMinDev && distEnd <= this.endMaxDev );
}
-
+
public boolean evaluateCachedLeft(InternalWorkingMemory workingMemory,
final VariableContextEntry context,
final Object right) {
@@ -177,10 +207,10 @@
}
long distStart = ((EventFactHandle) ((ObjectVariableContextEntry) context).left).getStartTimestamp() - ((EventFactHandle) right ).getStartTimestamp();
long distEnd = ((EventFactHandle) right ).getEndTimestamp() - ((EventFactHandle) ((ObjectVariableContextEntry) context).left).getEndTimestamp();
- return this.getOperator().isNegated() ^ ( distStart >= this.startMinDev && distStart <= this.startMaxDev
+ return this.getOperator().isNegated() ^ ( distStart >= this.startMinDev && distStart <= this.startMaxDev
&& distEnd >= this.endMinDev && distEnd <= this.endMaxDev );
}
-
+
public boolean evaluate(InternalWorkingMemory workingMemory,
final Extractor extractor1,
final Object object1,
@@ -192,7 +222,7 @@
}
long distStart = ((EventFactHandle) object2 ).getStartTimestamp() - ((EventFactHandle) object1 ).getStartTimestamp();
long distEnd = ((EventFactHandle) object1 ).getEndTimestamp() - ((EventFactHandle) object2 ).getEndTimestamp();
- return this.getOperator().isNegated() ^ ( distStart >= this.startMinDev && distStart <= this.startMaxDev
+ return this.getOperator().isNegated() ^ ( distStart >= this.startMinDev && distStart <= this.startMaxDev
&& distEnd >= this.endMinDev && distEnd <= this.endMaxDev );
}
@@ -228,9 +258,9 @@
}
/**
- * This methods tries to parse the string of parameters to customize
+ * This methods tries to parse the string of parameters to customize
* the evaluator.
- *
+ *
* @param parameters
*/
private void parseParameters(String parameters) {
@@ -246,19 +276,19 @@
try {
String[] ranges = parameters.split( "," );
if ( ranges.length == 1 ) {
- // deterministic point in time for deviation of the starts of the intervals
+ // deterministic point in time for deviation of the starts of the intervals
this.startMinDev = Long.parseLong( ranges[0] );
this.startMaxDev = this.startMinDev;
this.endMinDev = this.startMinDev;
this.endMaxDev = this.startMinDev;
} else if ( ranges.length == 2 ) {
- // deterministic points in time for deviations of the starts and the ends of the intervals
+ // deterministic points in time for deviations of the starts and the ends of the intervals
this.startMinDev = Long.parseLong( ranges[0] );
this.startMaxDev = this.startMinDev;
this.endMinDev = Long.parseLong( ranges[1] );
this.endMaxDev = this.endMinDev;
} else if ( ranges.length == 4 ) {
- // ranges for deviations of the starts and the ends of the intervals
+ // ranges for deviations of the starts and the ends of the intervals
this.startMinDev = Long.parseLong( ranges[0] );
this.startMaxDev = Long.parseLong( ranges[1] );
this.endMinDev = Long.parseLong( ranges[2] );
Modified: labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/base/evaluators/MatchesEvaluatorsDefinition.java
===================================================================
--- labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/base/evaluators/MatchesEvaluatorsDefinition.java 2008-03-20 18:57:07 UTC (rev 19163)
+++ labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/base/evaluators/MatchesEvaluatorsDefinition.java 2008-03-20 19:32:10 UTC (rev 19164)
@@ -1,12 +1,12 @@
/*
* Copyright 2007 JBoss Inc
- *
+ *
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -26,18 +26,23 @@
import org.drools.spi.Extractor;
import org.drools.spi.FieldValue;
+import java.io.ObjectInput;
+import java.io.IOException;
+import java.io.ObjectOutput;
+import java.util.Map;
+
/**
* This class defines the matches evaluator
- *
+ *
* @author etirelli
*/
public class MatchesEvaluatorsDefinition implements EvaluatorDefinition {
-
+
public static final Operator MATCHES = Operator.addOperatorToRegistry( "matches",
false );
public static final Operator NOT_MATCHES = Operator.addOperatorToRegistry( "matches",
true );
-
+
private static final String[] SUPPORTED_IDS = { MATCHES.getOperatorString() };
private EvaluatorCache evaluators = new EvaluatorCache() {
private static final long serialVersionUID = 4782368623L;
@@ -46,7 +51,15 @@
addEvaluator( ValueType.STRING_TYPE, NOT_MATCHES, StringNotMatchesEvaluator.INSTANCE );
}
};
-
+
+ public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
+ evaluators = (EvaluatorCache)in.readObject();
+ }
+
+ public void writeExternal(ObjectOutput out) throws IOException {
+ out.writeObject(evaluators);
+ }
+
/**
* @inheridDoc
*/
@@ -94,14 +107,15 @@
* Evaluator Implementations
* *********************************************************
*/
- static class StringMatchesEvaluator extends BaseEvaluator {
+ public static class StringMatchesEvaluator extends BaseEvaluator {
/**
*
*/
private static final long serialVersionUID = 400L;
public final static Evaluator INSTANCE = new StringMatchesEvaluator();
- private StringMatchesEvaluator() {
+
+ public StringMatchesEvaluator() {
super( ValueType.STRING_TYPE,
MATCHES );
}
@@ -152,14 +166,14 @@
}
}
- static class StringNotMatchesEvaluator extends BaseEvaluator {
+ public static class StringNotMatchesEvaluator extends BaseEvaluator {
/**
*
*/
private static final long serialVersionUID = 400L;
public final static Evaluator INSTANCE = new StringNotMatchesEvaluator();
- private StringNotMatchesEvaluator() {
+ public StringNotMatchesEvaluator() {
super( ValueType.STRING_TYPE,
NOT_MATCHES );
}
Modified: labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/base/evaluators/MeetsEvaluatorDefinition.java
===================================================================
--- labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/base/evaluators/MeetsEvaluatorDefinition.java 2008-03-20 18:57:07 UTC (rev 19163)
+++ labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/base/evaluators/MeetsEvaluatorDefinition.java 2008-03-20 19:32:10 UTC (rev 19164)
@@ -1,12 +1,12 @@
/*
* Copyright 2007 JBoss Inc
- *
+ *
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -20,6 +20,9 @@
import java.util.Collections;
import java.util.HashMap;
import java.util.Map;
+import java.io.ObjectInput;
+import java.io.IOException;
+import java.io.ObjectOutput;
import org.drools.RuntimeDroolsException;
import org.drools.base.BaseEvaluator;
@@ -35,7 +38,7 @@
/**
* The implementation of the 'meets' evaluator definition
- *
+ *
* @author mgroch
*/
public class MeetsEvaluatorDefinition
@@ -46,11 +49,19 @@
false );
public static final Operator MEETS_NOT = Operator.addOperatorToRegistry( "meets",
true );
-
+
private static final String[] SUPPORTED_IDS = { MEETS.getOperatorString() };
-
+
private Map<String, MeetsEvaluator> cache = Collections.emptyMap();
+ public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
+ cache = (Map<String, MeetsEvaluator>)in.readObject();
+ }
+
+ public void writeExternal(ObjectOutput out) throws IOException {
+ out.writeObject(cache);
+ }
+
/**
* @inheridDoc
*/
@@ -131,9 +142,12 @@
*/
public static class MeetsEvaluator extends BaseEvaluator {
private static final long serialVersionUID = 9091548399308812447L;
-
+
private long finalRange;
+ public MeetsEvaluator(){
+ }
+
public MeetsEvaluator(final ValueType type,
final boolean isNegated,
final String parameters) {
@@ -141,12 +155,22 @@
isNegated ? MEETS_NOT : MEETS );
this.parseParameters( parameters );
}
-
+
+ public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
+ super.readExternal(in);
+ finalRange = in.readLong();
+ }
+
+ public void writeExternal(ObjectOutput out) throws IOException {
+ super.writeExternal(out);
+ out.writeLong(finalRange);
+ }
+
@Override
public Object prepareObject(InternalFactHandle handle) {
return handle;
}
-
+
public boolean evaluate(InternalWorkingMemory workingMemory,
final Extractor extractor,
final Object object1,
@@ -161,12 +185,12 @@
return false;
}
long leftStartTS = ((EventFactHandle) left ).getStartTimestamp();
- long dist = Math.abs(leftStartTS -
+ long dist = Math.abs(leftStartTS -
((EventFactHandle)((ObjectVariableContextEntry) context).right).getEndTimestamp());
- return this.getOperator().isNegated() ^ ( ((EventFactHandle)((ObjectVariableContextEntry) context).right).getStartTimestamp() <= leftStartTS
+ return this.getOperator().isNegated() ^ ( ((EventFactHandle)((ObjectVariableContextEntry) context).right).getStartTimestamp() <= leftStartTS
&& dist <= this.finalRange );
}
-
+
public boolean evaluateCachedLeft(InternalWorkingMemory workingMemory,
final VariableContextEntry context,
final Object right) {
@@ -178,7 +202,7 @@
long dist = Math.abs(leftStartTS - ((EventFactHandle) right ).getEndTimestamp());
return this.getOperator().isNegated() ^ ( ((EventFactHandle) right ).getStartTimestamp() <= leftStartTS && dist <= this.finalRange);
}
-
+
public boolean evaluate(InternalWorkingMemory workingMemory,
final Extractor extractor1,
final Object object1,
@@ -221,9 +245,9 @@
}
/**
- * This methods tries to parse the string of parameters to customize
+ * This methods tries to parse the string of parameters to customize
* the evaluator.
- *
+ *
* @param parameters
*/
private void parseParameters(String parameters) {
Modified: labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/base/evaluators/MetByEvaluatorDefinition.java
===================================================================
--- labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/base/evaluators/MetByEvaluatorDefinition.java 2008-03-20 18:57:07 UTC (rev 19163)
+++ labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/base/evaluators/MetByEvaluatorDefinition.java 2008-03-20 19:32:10 UTC (rev 19164)
@@ -1,12 +1,12 @@
/*
* Copyright 2007 JBoss Inc
- *
+ *
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -20,6 +20,9 @@
import java.util.Collections;
import java.util.HashMap;
import java.util.Map;
+import java.io.ObjectInput;
+import java.io.IOException;
+import java.io.ObjectOutput;
import org.drools.RuntimeDroolsException;
import org.drools.base.BaseEvaluator;
@@ -35,7 +38,7 @@
/**
* The implementation of the 'metby' evaluator definition
- *
+ *
* @author mgroch
*/
public class MetByEvaluatorDefinition
@@ -46,11 +49,19 @@
false );
public static final Operator NOT_MET_BY = Operator.addOperatorToRegistry( "metby",
true );
-
+
private static final String[] SUPPORTED_IDS = { MET_BY.getOperatorString() };
-
+
private Map<String, MetByEvaluator> cache = Collections.emptyMap();
+ public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
+ cache = (Map<String, MetByEvaluator>)in.readObject();
+ }
+
+ public void writeExternal(ObjectOutput out) throws IOException {
+ out.writeObject(cache);
+ }
+
/**
* @inheridDoc
*/
@@ -131,9 +142,12 @@
*/
public static class MetByEvaluator extends BaseEvaluator {
private static final long serialVersionUID = 7907908401657594347L;
-
+
private long finalRange;
+ public MetByEvaluator() {
+ }
+
public MetByEvaluator(final ValueType type,
final boolean isNegated,
final String parameters) {
@@ -141,12 +155,22 @@
isNegated ? NOT_MET_BY : MET_BY );
this.parseParameters( parameters );
}
-
+
+ public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
+ super.readExternal(in);
+ finalRange = in.readLong();
+ }
+
+ public void writeExternal(ObjectOutput out) throws IOException {
+ super.writeExternal(out);
+ out.writeLong(finalRange);
+ }
+
@Override
public Object prepareObject(InternalFactHandle handle) {
return handle;
}
-
+
public boolean evaluate(InternalWorkingMemory workingMemory,
final Extractor extractor,
final Object object1,
@@ -175,7 +199,7 @@
long rightStartTS = ((EventFactHandle) right ).getStartTimestamp();
long dist = Math.abs(rightStartTS - ((EventFactHandle) ((ObjectVariableContextEntry) context).left).getEndTimestamp());
- return this.getOperator().isNegated() ^ ( ((EventFactHandle) ((ObjectVariableContextEntry) context).left).getStartTimestamp() <= rightStartTS &&
+ return this.getOperator().isNegated() ^ ( ((EventFactHandle) ((ObjectVariableContextEntry) context).left).getStartTimestamp() <= rightStartTS &&
dist <= this.finalRange );
}
@@ -221,9 +245,9 @@
}
/**
- * This methods tries to parse the string of parameters to customize
+ * This methods tries to parse the string of parameters to customize
* the evaluator.
- *
+ *
* @param parameters
*/
private void parseParameters(String parameters) {
Modified: labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/base/evaluators/Operator.java
===================================================================
--- labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/base/evaluators/Operator.java 2008-03-20 18:57:07 UTC (rev 19163)
+++ labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/base/evaluators/Operator.java 2008-03-20 19:32:10 UTC (rev 19164)
@@ -1,6 +1,9 @@
package org.drools.base.evaluators;
-import java.io.Serializable;
+import java.io.Externalizable;
+import java.io.IOException;
+import java.io.ObjectInput;
+import java.io.ObjectOutput;
import java.util.Collections;
import java.util.HashMap;
import java.util.Map;
@@ -9,7 +12,7 @@
public class Operator
implements
- Serializable {
+ Externalizable {
private static final long serialVersionUID = 400L;
@@ -34,12 +37,12 @@
false );
/**
- * Creates a new Operator instance for the given parameters,
+ * Creates a new Operator instance for the given parameters,
* adds it to the registry and return it
- *
+ *
* @param operatorId the identification symbol of the operator
* @param isNegated true if it is negated
- *
+ *
* @return the newly created operator
*/
public static Operator addOperatorToRegistry(final String operatorId,
@@ -54,10 +57,10 @@
/**
* Returns the operator instance for the given parameters
- *
+ *
* @param operatorId the identification symbol of the operator
* @param isNegated true if it is negated
- *
+ *
* @return the operator in case it exists
*/
public static Operator determineOperator(final String operatorId,
@@ -79,6 +82,20 @@
private String operator;
private boolean isNegated;
+ public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
+ operator = (String)in.readObject();
+ isNegated = in.readBoolean();
+ }
+
+ public void writeExternal(ObjectOutput out) throws IOException {
+ out.writeObject(operator);
+ out.writeBoolean(isNegated);
+ }
+
+ public Operator() {
+
+ }
+
private Operator(final String operator,
final boolean isNegated) {
this.operator = operator;
@@ -97,7 +114,7 @@
public String getOperatorString() {
return this.operator;
}
-
+
public boolean isNegated() {
return this.isNegated;
}
Modified: labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/base/evaluators/OverlappedByEvaluatorDefinition.java
===================================================================
--- labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/base/evaluators/OverlappedByEvaluatorDefinition.java 2008-03-20 18:57:07 UTC (rev 19163)
+++ labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/base/evaluators/OverlappedByEvaluatorDefinition.java 2008-03-20 19:32:10 UTC (rev 19164)
@@ -1,12 +1,12 @@
/*
* Copyright 2007 JBoss Inc
- *
+ *
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -20,6 +20,9 @@
import java.util.Collections;
import java.util.HashMap;
import java.util.Map;
+import java.io.ObjectInput;
+import java.io.IOException;
+import java.io.ObjectOutput;
import org.drools.RuntimeDroolsException;
import org.drools.base.BaseEvaluator;
@@ -35,7 +38,7 @@
/**
* The implementation of the 'overlappedby' evaluator definition
- *
+ *
* @author mgroch
*/
public class OverlappedByEvaluatorDefinition
@@ -46,11 +49,19 @@
false );
public static final Operator NOT_OVERLAPPED_BY = Operator.addOperatorToRegistry( "overlappedby",
true );
-
+
private static final String[] SUPPORTED_IDS = { OVERLAPPED_BY.getOperatorString() };
-
+
private Map<String, OverlappedByEvaluator> cache = Collections.emptyMap();
+ public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
+ cache = (Map<String, OverlappedByEvaluator>)in.readObject();
+ }
+
+ public void writeExternal(ObjectOutput out) throws IOException {
+ out.writeObject(cache);
+ }
+
/**
* @inheridDoc
*/
@@ -131,10 +142,13 @@
*/
public static class OverlappedByEvaluator extends BaseEvaluator {
private static final long serialVersionUID = -2768899194494247889L;
-
+
private long startMinDev, startMaxDev;
private long endMinDev, endMaxDev;
+ public OverlappedByEvaluator() {
+ }
+
public OverlappedByEvaluator(final ValueType type,
final boolean isNegated,
final String parameters) {
@@ -142,12 +156,28 @@
isNegated ? NOT_OVERLAPPED_BY : OVERLAPPED_BY );
this.parseParameters( parameters );
}
-
+
+ public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
+ super.readExternal(in);
+ startMinDev = in.readLong();
+ startMaxDev = in.readLong();
+ endMinDev = in.readLong();
+ endMaxDev = in.readLong();
+ }
+
+ public void writeExternal(ObjectOutput out) throws IOException {
+ super.writeExternal(out);
+ out.writeLong(startMinDev);
+ out.writeLong(startMaxDev);
+ out.writeLong(endMinDev);
+ out.writeLong(endMaxDev);
+ }
+
@Override
public Object prepareObject(InternalFactHandle handle) {
return handle;
}
-
+
public boolean evaluate(InternalWorkingMemory workingMemory,
final Extractor extractor,
final Object object1,
@@ -165,7 +195,7 @@
long leftEndTS = ((EventFactHandle) left ).getEndTimestamp();
long distStart = rightStartTS - ((EventFactHandle) left ).getStartTimestamp();
long distEnd = ((EventFactHandle)((ObjectVariableContextEntry) context).right).getEndTimestamp() - leftEndTS;
- return this.getOperator().isNegated() ^ ( distStart >= this.startMinDev && distStart <= this.startMaxDev
+ return this.getOperator().isNegated() ^ ( distStart >= this.startMinDev && distStart <= this.startMaxDev
&& distEnd >= this.endMinDev && distEnd <= this.endMaxDev && rightStartTS < leftEndTS );
}
@@ -180,7 +210,7 @@
long rightStartTS = ((EventFactHandle) right ).getStartTimestamp();
long distStart = rightStartTS - ((EventFactHandle) ((ObjectVariableContextEntry) context).left).getStartTimestamp();
long distEnd = ((EventFactHandle) right ).getEndTimestamp() - leftEndTS;
- return this.getOperator().isNegated() ^ ( distStart >= this.startMinDev && distStart <= this.startMaxDev
+ return this.getOperator().isNegated() ^ ( distStart >= this.startMinDev && distStart <= this.startMaxDev
&& distEnd >= this.endMinDev && distEnd <= this.endMaxDev && rightStartTS < leftEndTS );
}
@@ -197,7 +227,7 @@
long o2endTS = ((EventFactHandle) object2 ).getEndTimestamp();
long distStart = o1startTS - ((EventFactHandle) object2 ).getStartTimestamp();
long distEnd = ((EventFactHandle) object1 ).getEndTimestamp() - o2endTS;
- return this.getOperator().isNegated() ^ ( distStart >= this.startMinDev && distStart <= this.startMaxDev
+ return this.getOperator().isNegated() ^ ( distStart >= this.startMinDev && distStart <= this.startMaxDev
&& distEnd >= this.endMinDev && distEnd <= this.endMaxDev && o1startTS < o2endTS );
}
@@ -233,9 +263,9 @@
}
/**
- * This methods tries to parse the string of parameters to customize
+ * This methods tries to parse the string of parameters to customize
* the evaluator.
- *
+ *
* @param parameters
*/
private void parseParameters(String parameters) {
@@ -251,19 +281,19 @@
try {
String[] ranges = parameters.split( "," );
if ( ranges.length == 1 ) {
- // deterministic point in time for deviation of the starts of the intervals
+ // deterministic point in time for deviation of the starts of the intervals
this.startMinDev = Long.parseLong( ranges[0] );
this.startMaxDev = this.startMinDev;
this.endMinDev = this.startMinDev;
this.endMaxDev = this.startMinDev;
} else if ( ranges.length == 2 ) {
- // deterministic points in time for deviations of the starts and the ends of the intervals
+ // deterministic points in time for deviations of the starts and the ends of the intervals
this.startMinDev = Long.parseLong( ranges[0] );
this.startMaxDev = this.startMinDev;
this.endMinDev = Long.parseLong( ranges[1] );
this.endMaxDev = this.endMinDev;
} else if ( ranges.length == 4 ) {
- // ranges for deviations of the starts and the ends of the intervals
+ // ranges for deviations of the starts and the ends of the intervals
this.startMinDev = Long.parseLong( ranges[0] );
this.startMaxDev = Long.parseLong( ranges[1] );
this.endMinDev = Long.parseLong( ranges[2] );
Modified: labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/base/evaluators/OverlapsEvaluatorDefinition.java
===================================================================
--- labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/base/evaluators/OverlapsEvaluatorDefinition.java 2008-03-20 18:57:07 UTC (rev 19163)
+++ labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/base/evaluators/OverlapsEvaluatorDefinition.java 2008-03-20 19:32:10 UTC (rev 19164)
@@ -1,12 +1,12 @@
/*
* Copyright 2007 JBoss Inc
- *
+ *
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -20,6 +20,9 @@
import java.util.Collections;
import java.util.HashMap;
import java.util.Map;
+import java.io.ObjectInput;
+import java.io.IOException;
+import java.io.ObjectOutput;
import org.drools.RuntimeDroolsException;
import org.drools.base.BaseEvaluator;
@@ -35,7 +38,7 @@
/**
* The implementation of the 'overlaps' evaluator definition
- *
+ *
* @author mgroch
*/
public class OverlapsEvaluatorDefinition
@@ -46,11 +49,19 @@
false );
public static final Operator OVERLAPS_NOT = Operator.addOperatorToRegistry( "overlaps",
true );
-
+
private static final String[] SUPPORTED_IDS = { OVERLAPS.getOperatorString() };
-
+
private Map<String, OverlapsEvaluator> cache = Collections.emptyMap();
+ public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
+ cache = (Map<String, OverlapsEvaluator>)in.readObject();
+ }
+
+ public void writeExternal(ObjectOutput out) throws IOException {
+ out.writeObject(cache);
+ }
+
/**
* @inheridDoc
*/
@@ -131,10 +142,13 @@
*/
public static class OverlapsEvaluator extends BaseEvaluator {
private static final long serialVersionUID = -5108524288774833244L;
-
+
private long startMinDev, startMaxDev;
private long endMinDev, endMaxDev;
+ public OverlapsEvaluator() {
+ }
+
public OverlapsEvaluator(final ValueType type,
final boolean isNegated,
final String parameters) {
@@ -142,12 +156,28 @@
isNegated ? OVERLAPS_NOT : OVERLAPS );
this.parseParameters( parameters );
}
-
+
+ public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
+ super.readExternal(in);
+ startMinDev = in.readLong();
+ startMaxDev = in.readLong();
+ endMinDev = in.readLong();
+ endMaxDev = in.readLong();
+ }
+
+ public void writeExternal(ObjectOutput out) throws IOException {
+ super.writeExternal(out);
+ out.writeLong(startMinDev);
+ out.writeLong(startMaxDev);
+ out.writeLong(endMinDev);
+ out.writeLong(endMaxDev);
+ }
+
@Override
public Object prepareObject(InternalFactHandle handle) {
return handle;
}
-
+
public boolean evaluate(InternalWorkingMemory workingMemory,
final Extractor extractor,
final Object object1,
@@ -158,7 +188,7 @@
public boolean evaluateCachedRight(InternalWorkingMemory workingMemory,
final VariableContextEntry context,
final Object left) {
-
+
if ( context.rightNull ) {
return false;
}
@@ -166,10 +196,10 @@
long rightEndTS = ((EventFactHandle)((ObjectVariableContextEntry) context).right).getEndTimestamp();
long distStart = leftStartTS - ((EventFactHandle)((ObjectVariableContextEntry) context).right).getStartTimestamp();
long distEnd = ((EventFactHandle) left ).getEndTimestamp()- rightEndTS;
- return this.getOperator().isNegated() ^ ( distStart >= this.startMinDev && distStart <= this.startMaxDev
+ return this.getOperator().isNegated() ^ ( distStart >= this.startMinDev && distStart <= this.startMaxDev
&& distEnd >= this.endMinDev && distEnd <= this.endMaxDev && leftStartTS < rightEndTS );
}
-
+
public boolean evaluateCachedLeft(InternalWorkingMemory workingMemory,
final VariableContextEntry context,
final Object right) {
@@ -181,10 +211,10 @@
long rightEndTS = ((EventFactHandle) right ).getEndTimestamp();
long distStart = leftStartTS - ((EventFactHandle) right ).getStartTimestamp();
long distEnd = ((EventFactHandle) ((ObjectVariableContextEntry) context).left).getEndTimestamp() - rightEndTS;
- return this.getOperator().isNegated() ^ ( distStart >= this.startMinDev && distStart <= this.startMaxDev
+ return this.getOperator().isNegated() ^ ( distStart >= this.startMinDev && distStart <= this.startMaxDev
&& distEnd >= this.endMinDev && distEnd <= this.endMaxDev && leftStartTS < rightEndTS );
}
-
+
public boolean evaluate(InternalWorkingMemory workingMemory,
final Extractor extractor1,
final Object object1,
@@ -198,7 +228,7 @@
long o1endTS = ((EventFactHandle) object1 ).getEndTimestamp();
long distStart = o2startTS - ((EventFactHandle) object1 ).getStartTimestamp();
long distEnd = ((EventFactHandle) object2 ).getEndTimestamp() - o1endTS;
- return this.getOperator().isNegated() ^ ( distStart >= this.startMinDev && distStart <= this.startMaxDev
+ return this.getOperator().isNegated() ^ ( distStart >= this.startMinDev && distStart <= this.startMaxDev
&& distEnd >= this.endMinDev && distEnd <= this.endMaxDev && o2startTS < o1endTS );
}
@@ -234,9 +264,9 @@
}
/**
- * This methods tries to parse the string of parameters to customize
+ * This methods tries to parse the string of parameters to customize
* the evaluator.
- *
+ *
* @param parameters
*/
private void parseParameters(String parameters) {
@@ -252,19 +282,19 @@
try {
String[] ranges = parameters.split( "," );
if ( ranges.length == 1 ) {
- // deterministic point in time for deviation of the starts of the intervals
+ // deterministic point in time for deviation of the starts of the intervals
this.startMinDev = Long.parseLong( ranges[0] );
this.startMaxDev = this.startMinDev;
this.endMinDev = this.startMinDev;
this.endMaxDev = this.startMinDev;
} else if ( ranges.length == 2 ) {
- // deterministic points in time for deviations of the starts and the ends of the intervals
+ // deterministic points in time for deviations of the starts and the ends of the intervals
this.startMinDev = Long.parseLong( ranges[0] );
this.startMaxDev = this.startMinDev;
this.endMinDev = Long.parseLong( ranges[1] );
this.endMaxDev = this.endMinDev;
} else if ( ranges.length == 4 ) {
- // ranges for deviations of the starts and the ends of the intervals
+ // ranges for deviations of the starts and the ends of the intervals
this.startMinDev = Long.parseLong( ranges[0] );
this.startMaxDev = Long.parseLong( ranges[1] );
this.endMinDev = Long.parseLong( ranges[2] );
Modified: labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/base/evaluators/SetEvaluatorsDefinition.java
===================================================================
--- labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/base/evaluators/SetEvaluatorsDefinition.java 2008-03-20 18:57:07 UTC (rev 19163)
+++ labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/base/evaluators/SetEvaluatorsDefinition.java 2008-03-20 19:32:10 UTC (rev 19164)
@@ -1,12 +1,12 @@
/*
* Copyright 2007 JBoss Inc
- *
+ *
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -18,6 +18,10 @@
package org.drools.base.evaluators;
import java.util.Collection;
+import java.util.Map;
+import java.io.ObjectInput;
+import java.io.IOException;
+import java.io.ObjectOutput;
import org.drools.base.BaseEvaluator;
import org.drools.base.ValueType;
@@ -30,9 +34,9 @@
import org.drools.util.ShadowProxyUtils;
/**
- * This class defines all the set built in
+ * This class defines all the set built in
* evaluators like contains, memberOf, etc.
- *
+ *
* @author etirelli
*/
public class SetEvaluatorsDefinition
@@ -111,6 +115,14 @@
}
};
+ public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
+ evaluators = (EvaluatorCache)in.readObject();
+ }
+
+ public void writeExternal(ObjectOutput out) throws IOException {
+ out.writeObject(evaluators);
+ }
+
/**
* @inheridDoc
*/
@@ -157,14 +169,14 @@
/* *********************************************************
* Evaluator Implementations
- * *********************************************************
+ * *********************************************************
*/
- static class ArrayContainsEvaluator extends BaseEvaluator {
+ public static class ArrayContainsEvaluator extends BaseEvaluator {
private static final long serialVersionUID = 400L;
public final static Evaluator INSTANCE = new ArrayContainsEvaluator();
- private ArrayContainsEvaluator() {
+ public ArrayContainsEvaluator() {
super( ValueType.ARRAY_TYPE,
CONTAINS );
}
@@ -223,14 +235,14 @@
}
}
- static class ArrayExcludesEvaluator extends BaseEvaluator {
+ public static class ArrayExcludesEvaluator extends BaseEvaluator {
/**
- *
+ *
*/
private static final long serialVersionUID = 400L;
public final static Evaluator INSTANCE = new ArrayExcludesEvaluator();
- private ArrayExcludesEvaluator() {
+ public ArrayExcludesEvaluator() {
super( ValueType.ARRAY_TYPE,
EXCLUDES );
}
@@ -289,14 +301,14 @@
}
}
- static class ArrayMemberOfEvaluator extends BaseEvaluator {
+ public static class ArrayMemberOfEvaluator extends BaseEvaluator {
/**
- *
+ *
*/
private static final long serialVersionUID = 400L;
public final static Evaluator INSTANCE = new ArrayMemberOfEvaluator();
- private ArrayMemberOfEvaluator() {
+ public ArrayMemberOfEvaluator() {
super( ValueType.ARRAY_TYPE,
MEMBEROF );
}
@@ -355,14 +367,14 @@
}
}
- static class ArrayNotMemberOfEvaluator extends BaseEvaluator {
+ public static class ArrayNotMemberOfEvaluator extends BaseEvaluator {
/**
- *
+ *
*/
private static final long serialVersionUID = 400L;
public final static Evaluator INSTANCE = new ArrayNotMemberOfEvaluator();
- private ArrayNotMemberOfEvaluator() {
+ public ArrayNotMemberOfEvaluator() {
super( ValueType.ARRAY_TYPE,
NOT_MEMBEROF );
}
@@ -421,10 +433,14 @@
}
}
- static abstract class BaseMemberOfEvaluator extends BaseEvaluator {
+ public static abstract class BaseMemberOfEvaluator extends BaseEvaluator {
private static final long serialVersionUID = 2017803222427893249L;
+ public BaseMemberOfEvaluator() {
+ super(null, null);
+ }
+
public BaseMemberOfEvaluator(ValueType type,
Operator operator) {
super( type,
@@ -507,7 +523,7 @@
}
- static abstract class BaseNotMemberOfEvaluator extends BaseEvaluator {
+ public static abstract class BaseNotMemberOfEvaluator extends BaseEvaluator {
private static final long serialVersionUID = -8730331781980886901L;
@@ -592,12 +608,12 @@
public abstract String toString();
}
- static class BigDecimalMemberOfEvaluator extends BaseMemberOfEvaluator {
+ public static class BigDecimalMemberOfEvaluator extends BaseMemberOfEvaluator {
private static final long serialVersionUID = 400L;
public final static Evaluator INSTANCE = new BigDecimalMemberOfEvaluator();
- private BigDecimalMemberOfEvaluator() {
+ public BigDecimalMemberOfEvaluator() {
super( ValueType.BIG_DECIMAL_TYPE,
MEMBEROF );
}
@@ -607,12 +623,12 @@
}
}
- static class BigDecimalNotMemberOfEvaluator extends BaseNotMemberOfEvaluator {
+ public static class BigDecimalNotMemberOfEvaluator extends BaseNotMemberOfEvaluator {
private static final long serialVersionUID = 400L;
public final static Evaluator INSTANCE = new BigDecimalNotMemberOfEvaluator();
- private BigDecimalNotMemberOfEvaluator() {
+ public BigDecimalNotMemberOfEvaluator() {
super( ValueType.BIG_DECIMAL_TYPE,
NOT_MEMBEROF );
}
@@ -622,12 +638,12 @@
}
}
- static class BigIntegerMemberOfEvaluator extends BaseMemberOfEvaluator {
+ public static class BigIntegerMemberOfEvaluator extends BaseMemberOfEvaluator {
private static final long serialVersionUID = 400L;
public final static Evaluator INSTANCE = new BigIntegerMemberOfEvaluator();
- private BigIntegerMemberOfEvaluator() {
+ public BigIntegerMemberOfEvaluator() {
super( ValueType.BIG_INTEGER_TYPE,
MEMBEROF );
}
@@ -637,14 +653,14 @@
}
}
- static class BigIntegerNotMemberOfEvaluator extends BaseNotMemberOfEvaluator {
+ public static class BigIntegerNotMemberOfEvaluator extends BaseNotMemberOfEvaluator {
/**
- *
+ *
*/
private static final long serialVersionUID = 400L;
public final static Evaluator INSTANCE = new BigIntegerNotMemberOfEvaluator();
- private BigIntegerNotMemberOfEvaluator() {
+ public BigIntegerNotMemberOfEvaluator() {
super( ValueType.BIG_INTEGER_TYPE,
NOT_MEMBEROF );
}
@@ -654,12 +670,12 @@
}
}
- static class BooleanMemberOfEvaluator extends BaseMemberOfEvaluator {
+ public static class BooleanMemberOfEvaluator extends BaseMemberOfEvaluator {
private static final long serialVersionUID = 400L;
public final static Evaluator INSTANCE = new BooleanMemberOfEvaluator();
- private BooleanMemberOfEvaluator() {
+ public BooleanMemberOfEvaluator() {
super( ValueType.PBOOLEAN_TYPE,
MEMBEROF );
}
@@ -669,12 +685,12 @@
}
}
- static class BooleanNotMemberOfEvaluator extends BaseNotMemberOfEvaluator {
+ public static class BooleanNotMemberOfEvaluator extends BaseNotMemberOfEvaluator {
private static final long serialVersionUID = 400L;
public final static Evaluator INSTANCE = new BooleanNotMemberOfEvaluator();
- private BooleanNotMemberOfEvaluator() {
+ public BooleanNotMemberOfEvaluator() {
super( ValueType.PBOOLEAN_TYPE,
NOT_MEMBEROF );
}
@@ -684,12 +700,12 @@
}
}
- static class ByteMemberOfEvaluator extends BaseMemberOfEvaluator {
+ public static class ByteMemberOfEvaluator extends BaseMemberOfEvaluator {
private static final long serialVersionUID = 400L;
public final static Evaluator INSTANCE = new ByteMemberOfEvaluator();
- private ByteMemberOfEvaluator() {
+ public ByteMemberOfEvaluator() {
super( ValueType.PBYTE_TYPE,
MEMBEROF );
}
@@ -699,12 +715,12 @@
}
}
- static class ByteNotMemberOfEvaluator extends BaseNotMemberOfEvaluator {
+ public static class ByteNotMemberOfEvaluator extends BaseNotMemberOfEvaluator {
private static final long serialVersionUID = 400L;
public final static Evaluator INSTANCE = new ByteNotMemberOfEvaluator();
- private ByteNotMemberOfEvaluator() {
+ public ByteNotMemberOfEvaluator() {
super( ValueType.PBYTE_TYPE,
NOT_MEMBEROF );
}
@@ -714,12 +730,12 @@
}
}
- static class CharacterMemberOfEvaluator extends BaseMemberOfEvaluator {
+ public static class CharacterMemberOfEvaluator extends BaseMemberOfEvaluator {
private static final long serialVersionUID = 400L;
public final static Evaluator INSTANCE = new CharacterMemberOfEvaluator();
- private CharacterMemberOfEvaluator() {
+ public CharacterMemberOfEvaluator() {
super( ValueType.PCHAR_TYPE,
MEMBEROF );
}
@@ -729,12 +745,12 @@
}
}
- static class CharacterNotMemberOfEvaluator extends BaseNotMemberOfEvaluator {
+ public static class CharacterNotMemberOfEvaluator extends BaseNotMemberOfEvaluator {
private static final long serialVersionUID = 400L;
public final static Evaluator INSTANCE = new CharacterNotMemberOfEvaluator();
- private CharacterNotMemberOfEvaluator() {
+ public CharacterNotMemberOfEvaluator() {
super( ValueType.PCHAR_TYPE,
NOT_MEMBEROF );
}
@@ -744,12 +760,12 @@
}
}
- static class DateMemberOfEvaluator extends BaseMemberOfEvaluator {
+ public static class DateMemberOfEvaluator extends BaseMemberOfEvaluator {
private static final long serialVersionUID = 400L;
public final static Evaluator INSTANCE = new DateMemberOfEvaluator();
- private DateMemberOfEvaluator() {
+ public DateMemberOfEvaluator() {
super( ValueType.DATE_TYPE,
MEMBEROF );
}
@@ -759,12 +775,12 @@
}
}
- static class DateNotMemberOfEvaluator extends BaseNotMemberOfEvaluator {
+ public static class DateNotMemberOfEvaluator extends BaseNotMemberOfEvaluator {
private static final long serialVersionUID = 400L;
public final static Evaluator INSTANCE = new DateNotMemberOfEvaluator();
- private DateNotMemberOfEvaluator() {
+ public DateNotMemberOfEvaluator() {
super( ValueType.DATE_TYPE,
NOT_MEMBEROF );
}
@@ -774,12 +790,12 @@
}
}
- static class DoubleMemberOfEvaluator extends BaseMemberOfEvaluator {
+ public static class DoubleMemberOfEvaluator extends BaseMemberOfEvaluator {
private static final long serialVersionUID = 400L;
public final static Evaluator INSTANCE = new DoubleMemberOfEvaluator();
- private DoubleMemberOfEvaluator() {
+ public DoubleMemberOfEvaluator() {
super( ValueType.PDOUBLE_TYPE,
MEMBEROF );
}
@@ -789,12 +805,12 @@
}
}
- static class DoubleNotMemberOfEvaluator extends BaseNotMemberOfEvaluator {
+ public static class DoubleNotMemberOfEvaluator extends BaseNotMemberOfEvaluator {
private static final long serialVersionUID = 400L;
public final static Evaluator INSTANCE = new DoubleNotMemberOfEvaluator();
- private DoubleNotMemberOfEvaluator() {
+ public DoubleNotMemberOfEvaluator() {
super( ValueType.PDOUBLE_TYPE,
NOT_MEMBEROF );
}
@@ -804,12 +820,12 @@
}
}
- static class FloatMemberOfEvaluator extends BaseMemberOfEvaluator {
+ public static class FloatMemberOfEvaluator extends BaseMemberOfEvaluator {
private static final long serialVersionUID = 400L;
public final static Evaluator INSTANCE = new FloatMemberOfEvaluator();
- private FloatMemberOfEvaluator() {
+ public FloatMemberOfEvaluator() {
super( ValueType.PFLOAT_TYPE,
MEMBEROF );
}
@@ -819,12 +835,12 @@
}
}
- static class FloatNotMemberOfEvaluator extends BaseNotMemberOfEvaluator {
+ public static class FloatNotMemberOfEvaluator extends BaseNotMemberOfEvaluator {
private static final long serialVersionUID = 400L;
public final static Evaluator INSTANCE = new FloatNotMemberOfEvaluator();
- private FloatNotMemberOfEvaluator() {
+ public FloatNotMemberOfEvaluator() {
super( ValueType.PFLOAT_TYPE,
NOT_MEMBEROF );
}
@@ -834,12 +850,12 @@
}
}
- static class IntegerMemberOfEvaluator extends BaseMemberOfEvaluator {
+ public static class IntegerMemberOfEvaluator extends BaseMemberOfEvaluator {
private static final long serialVersionUID = 400L;
public final static Evaluator INSTANCE = new IntegerMemberOfEvaluator();
- private IntegerMemberOfEvaluator() {
+ public IntegerMemberOfEvaluator() {
super( ValueType.PINTEGER_TYPE,
MEMBEROF );
}
@@ -849,12 +865,12 @@
}
}
- static class IntegerNotMemberOfEvaluator extends BaseNotMemberOfEvaluator {
+ public static class IntegerNotMemberOfEvaluator extends BaseNotMemberOfEvaluator {
private static final long serialVersionUID = 400L;
public final static Evaluator INSTANCE = new IntegerNotMemberOfEvaluator();
- private IntegerNotMemberOfEvaluator() {
+ public IntegerNotMemberOfEvaluator() {
super( ValueType.PINTEGER_TYPE,
NOT_MEMBEROF );
}
@@ -864,12 +880,12 @@
}
}
- static class LongMemberOfEvaluator extends BaseMemberOfEvaluator {
+ public static class LongMemberOfEvaluator extends BaseMemberOfEvaluator {
private static final long serialVersionUID = 400L;
public final static Evaluator INSTANCE = new LongMemberOfEvaluator();
- private LongMemberOfEvaluator() {
+ public LongMemberOfEvaluator() {
super( ValueType.PLONG_TYPE,
MEMBEROF );
}
@@ -879,12 +895,12 @@
}
}
- static class LongNotMemberOfEvaluator extends BaseNotMemberOfEvaluator {
+ public static class LongNotMemberOfEvaluator extends BaseNotMemberOfEvaluator {
private static final long serialVersionUID = 400L;
public final static Evaluator INSTANCE = new LongNotMemberOfEvaluator();
- private LongNotMemberOfEvaluator() {
+ public LongNotMemberOfEvaluator() {
super( ValueType.PLONG_TYPE,
NOT_MEMBEROF );
}
@@ -894,14 +910,14 @@
}
}
- static class ObjectContainsEvaluator extends BaseEvaluator {
+ public static class ObjectContainsEvaluator extends BaseEvaluator {
/**
- *
+ *
*/
private static final long serialVersionUID = 400L;
public final static Evaluator INSTANCE = new ObjectContainsEvaluator();
- private ObjectContainsEvaluator() {
+ public ObjectContainsEvaluator() {
super( ValueType.OBJECT_TYPE,
CONTAINS );
}
@@ -955,14 +971,14 @@
}
}
- static class ObjectExcludesEvaluator extends BaseEvaluator {
+ public static class ObjectExcludesEvaluator extends BaseEvaluator {
/**
- *
+ *
*/
private static final long serialVersionUID = 400L;
public final static Evaluator INSTANCE = new ObjectExcludesEvaluator();
- private ObjectExcludesEvaluator() {
+ public ObjectExcludesEvaluator() {
super( ValueType.OBJECT_TYPE,
EXCLUDES );
}
@@ -1016,12 +1032,12 @@
}
}
- static class ObjectMemberOfEvaluator extends BaseMemberOfEvaluator {
+ public static class ObjectMemberOfEvaluator extends BaseMemberOfEvaluator {
private static final long serialVersionUID = 400L;
public final static Evaluator INSTANCE = new ObjectMemberOfEvaluator();
- private ObjectMemberOfEvaluator() {
+ public ObjectMemberOfEvaluator() {
super( ValueType.OBJECT_TYPE,
MEMBEROF );
}
@@ -1031,12 +1047,12 @@
}
}
- static class ObjectNotMemberOfEvaluator extends BaseNotMemberOfEvaluator {
+ public static class ObjectNotMemberOfEvaluator extends BaseNotMemberOfEvaluator {
private static final long serialVersionUID = 400L;
public final static Evaluator INSTANCE = new ObjectNotMemberOfEvaluator();
- private ObjectNotMemberOfEvaluator() {
+ public ObjectNotMemberOfEvaluator() {
super( ValueType.OBJECT_TYPE,
NOT_MEMBEROF );
}
@@ -1046,12 +1062,12 @@
}
}
- static class ShortMemberOfEvaluator extends BaseMemberOfEvaluator {
+ public static class ShortMemberOfEvaluator extends BaseMemberOfEvaluator {
private static final long serialVersionUID = 400L;
public final static Evaluator INSTANCE = new ShortMemberOfEvaluator();
- private ShortMemberOfEvaluator() {
+ public ShortMemberOfEvaluator() {
super( ValueType.PSHORT_TYPE,
MEMBEROF );
}
@@ -1061,12 +1077,12 @@
}
}
- static class ShortNotMemberOfEvaluator extends BaseNotMemberOfEvaluator {
+ public static class ShortNotMemberOfEvaluator extends BaseNotMemberOfEvaluator {
private static final long serialVersionUID = 400L;
public final static Evaluator INSTANCE = new ShortNotMemberOfEvaluator();
- private ShortNotMemberOfEvaluator() {
+ public ShortNotMemberOfEvaluator() {
super( ValueType.PSHORT_TYPE,
NOT_MEMBEROF );
}
@@ -1076,12 +1092,12 @@
}
}
- static class StringMemberOfEvaluator extends BaseMemberOfEvaluator {
+ public static class StringMemberOfEvaluator extends BaseMemberOfEvaluator {
private static final long serialVersionUID = 400L;
public final static Evaluator INSTANCE = new StringMemberOfEvaluator();
- private StringMemberOfEvaluator() {
+ public StringMemberOfEvaluator() {
super( ValueType.STRING_TYPE,
MEMBEROF );
}
@@ -1091,12 +1107,12 @@
}
}
- static class StringNotMemberOfEvaluator extends BaseNotMemberOfEvaluator {
+ public static class StringNotMemberOfEvaluator extends BaseNotMemberOfEvaluator {
private static final long serialVersionUID = 400L;
public final static Evaluator INSTANCE = new StringNotMemberOfEvaluator();
- private StringNotMemberOfEvaluator() {
+ public StringNotMemberOfEvaluator() {
super( ValueType.STRING_TYPE,
NOT_MEMBEROF );
}
Modified: labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/base/evaluators/SoundslikeEvaluatorsDefinition.java
===================================================================
--- labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/base/evaluators/SoundslikeEvaluatorsDefinition.java 2008-03-20 18:57:07 UTC (rev 19163)
+++ labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/base/evaluators/SoundslikeEvaluatorsDefinition.java 2008-03-20 19:32:10 UTC (rev 19164)
@@ -1,12 +1,12 @@
/*
* Copyright 2007 JBoss Inc
- *
+ *
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -27,18 +27,22 @@
import org.drools.spi.FieldValue;
import org.mvel.Soundex;
+import java.io.ObjectInput;
+import java.io.IOException;
+import java.io.ObjectOutput;
+
/**
* This class defines the soundslike evaluator
- *
+ *
* @author etirelli
*/
public class SoundslikeEvaluatorsDefinition implements EvaluatorDefinition {
-
+
public static final Operator SOUNDSLIKE = Operator.addOperatorToRegistry( "soundslike",
false );
public static final Operator NOT_SOUNDSLIKE = Operator.addOperatorToRegistry( "soundslike",
true );
-
+
private static final String[] SUPPORTED_IDS = { SOUNDSLIKE.getOperatorString() };
private EvaluatorCache evaluators = new EvaluatorCache() {
private static final long serialVersionUID = 4782368623L;
@@ -47,7 +51,15 @@
addEvaluator( ValueType.STRING_TYPE, NOT_SOUNDSLIKE, StringNotSoundsLikeEvaluator.INSTANCE );
}
};
-
+
+ public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
+ evaluators = (EvaluatorCache)in.readObject();
+ }
+
+ public void writeExternal(ObjectOutput out) throws IOException {
+ out.writeObject(evaluators);
+ }
+
/**
* @inheridDoc
*/
@@ -71,8 +83,8 @@
final String operatorId,
final boolean isNegated,
final String parameterText) {
- return this.evaluators.getEvaluator( type,
- Operator.determineOperator( operatorId,
+ return this.evaluators.getEvaluator( type,
+ Operator.determineOperator( operatorId,
isNegated ) );
}
@@ -91,17 +103,17 @@
public boolean supportsType(ValueType type) {
return this.evaluators.supportsType( type );
}
-
+
/* *********************************************************
* Evaluator Implementations
* *********************************************************
*/
- static class StringSoundsLikeEvaluator extends BaseEvaluator {
+ public static class StringSoundsLikeEvaluator extends BaseEvaluator {
private static final long serialVersionUID = 400L;
public final static Evaluator INSTANCE = new StringSoundsLikeEvaluator();
- private StringSoundsLikeEvaluator() {
+ public StringSoundsLikeEvaluator() {
super( ValueType.STRING_TYPE,
SOUNDSLIKE );
}
@@ -152,13 +164,13 @@
return "Strings sound alike";
}
}
-
- static class StringNotSoundsLikeEvaluator extends BaseEvaluator {
+ public static class StringNotSoundsLikeEvaluator extends BaseEvaluator {
+
private static final long serialVersionUID = 400L;
public final static Evaluator INSTANCE = new StringNotSoundsLikeEvaluator();
- private StringNotSoundsLikeEvaluator() {
+ public StringNotSoundsLikeEvaluator() {
super( ValueType.STRING_TYPE,
NOT_SOUNDSLIKE );
}
@@ -209,6 +221,6 @@
return "Strings not sound alike";
}
}
-
+
}
Modified: labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/base/evaluators/StartedByEvaluatorDefinition.java
===================================================================
--- labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/base/evaluators/StartedByEvaluatorDefinition.java 2008-03-20 18:57:07 UTC (rev 19163)
+++ labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/base/evaluators/StartedByEvaluatorDefinition.java 2008-03-20 19:32:10 UTC (rev 19164)
@@ -1,12 +1,12 @@
/*
* Copyright 2007 JBoss Inc
- *
+ *
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -20,6 +20,9 @@
import java.util.Collections;
import java.util.HashMap;
import java.util.Map;
+import java.io.ObjectInput;
+import java.io.IOException;
+import java.io.ObjectOutput;
import org.drools.RuntimeDroolsException;
import org.drools.base.BaseEvaluator;
@@ -35,7 +38,7 @@
/**
* The implementation of the 'startedby' evaluator definition
- *
+ *
* @author mgroch
*/
public class StartedByEvaluatorDefinition
@@ -46,11 +49,19 @@
false );
public static final Operator NOT_STARTED_BY = Operator.addOperatorToRegistry( "startedby",
true );
-
+
private static final String[] SUPPORTED_IDS = { STARTED_BY.getOperatorString() };
-
+
private Map<String, StartedByEvaluator> cache = Collections.emptyMap();
+ public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
+ cache = (Map<String, StartedByEvaluator>)in.readObject();
+ }
+
+ public void writeExternal(ObjectOutput out) throws IOException {
+ out.writeObject(cache);
+ }
+
/**
* @inheridDoc
*/
@@ -131,10 +142,13 @@
*/
public static class StartedByEvaluator extends BaseEvaluator {
private static final long serialVersionUID = -2655549435451501420L;
-
+
private long startDev;
private long endMinDev, endMaxDev;
+ public StartedByEvaluator() {
+ }
+
public StartedByEvaluator(final ValueType type,
final boolean isNegated,
final String parameters) {
@@ -142,12 +156,26 @@
isNegated ? NOT_STARTED_BY : STARTED_BY );
this.parseParameters( parameters );
}
-
+
+ public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
+ super.readExternal(in);
+ startDev = in.readLong();
+ endMinDev = in.readLong();
+ endMaxDev = in.readLong();
+ }
+
+ public void writeExternal(ObjectOutput out) throws IOException {
+ super.writeExternal(out);
+ out.writeLong(startDev);
+ out.writeLong(endMinDev);
+ out.writeLong(endMaxDev);
+ }
+
@Override
public Object prepareObject(InternalFactHandle handle) {
return handle;
}
-
+
public boolean evaluate(InternalWorkingMemory workingMemory,
final Extractor extractor,
final Object object1,
@@ -158,16 +186,16 @@
public boolean evaluateCachedRight(InternalWorkingMemory workingMemory,
final VariableContextEntry context,
final Object left) {
-
+
if ( context.rightNull ) {
return false;
}
long distStart = Math.abs(((EventFactHandle)((ObjectVariableContextEntry) context).right).getStartTimestamp() - ((EventFactHandle) left ).getStartTimestamp());
long distEnd = ((EventFactHandle)((ObjectVariableContextEntry) context).right).getEndTimestamp() - ((EventFactHandle) left ).getEndTimestamp();
- return this.getOperator().isNegated() ^ ( distStart <= this.startDev
+ return this.getOperator().isNegated() ^ ( distStart <= this.startDev
&& distEnd >= this.endMinDev && distEnd <= this.endMaxDev );
}
-
+
public boolean evaluateCachedLeft(InternalWorkingMemory workingMemory,
final VariableContextEntry context,
final Object right) {
@@ -177,10 +205,10 @@
}
long distStart = Math.abs(((EventFactHandle) right ).getStartTimestamp() - ((EventFactHandle) ((ObjectVariableContextEntry) context).left).getStartTimestamp());
long distEnd = ((EventFactHandle) right ).getEndTimestamp() - ((EventFactHandle) ((ObjectVariableContextEntry) context).left).getEndTimestamp();
- return this.getOperator().isNegated() ^ ( distStart <= this.startDev
+ return this.getOperator().isNegated() ^ ( distStart <= this.startDev
&& distEnd >= this.endMinDev && distEnd <= this.endMaxDev );
}
-
+
public boolean evaluate(InternalWorkingMemory workingMemory,
final Extractor extractor1,
final Object object1,
@@ -192,7 +220,7 @@
}
long distStart = Math.abs(((EventFactHandle) object1 ).getStartTimestamp() - ((EventFactHandle) object2 ).getStartTimestamp());
long distEnd = ((EventFactHandle) object1 ).getEndTimestamp() - ((EventFactHandle) object2 ).getEndTimestamp();
- return this.getOperator().isNegated() ^ ( distStart <= this.startDev
+ return this.getOperator().isNegated() ^ ( distStart <= this.startDev
&& distEnd >= this.endMinDev && distEnd <= this.endMaxDev );
}
@@ -226,9 +254,9 @@
}
/**
- * This methods tries to parse the string of parameters to customize
+ * This methods tries to parse the string of parameters to customize
* the evaluator.
- *
+ *
* @param parameters
*/
private void parseParameters(String parameters) {
@@ -250,13 +278,13 @@
this.endMaxDev = this.endMinDev;
} else if ( ranges.length == 2 ) {
// exact matching at the beginning of the intervals
- // range for deviations of the ends of the intervals
+ // range for deviations of the ends of the intervals
this.startDev = 0;
this.endMinDev = Long.parseLong( ranges[0] );
this.endMaxDev = Long.parseLong( ranges[1] );
} else if ( ranges.length == 3 ) {
// max. deviation at the starts of the intervals
- // range for deviations of the ends of the intervals
+ // range for deviations of the ends of the intervals
this.startDev = Long.parseLong( ranges[0] );;
this.endMinDev = Long.parseLong( ranges[1] );
this.endMaxDev = Long.parseLong( ranges[2] );
Modified: labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/base/evaluators/StartsEvaluatorDefinition.java
===================================================================
--- labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/base/evaluators/StartsEvaluatorDefinition.java 2008-03-20 18:57:07 UTC (rev 19163)
+++ labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/base/evaluators/StartsEvaluatorDefinition.java 2008-03-20 19:32:10 UTC (rev 19164)
@@ -1,12 +1,12 @@
/*
* Copyright 2007 JBoss Inc
- *
+ *
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -20,6 +20,9 @@
import java.util.Collections;
import java.util.HashMap;
import java.util.Map;
+import java.io.ObjectInput;
+import java.io.IOException;
+import java.io.ObjectOutput;
import org.drools.RuntimeDroolsException;
import org.drools.base.BaseEvaluator;
@@ -35,7 +38,7 @@
/**
* The implementation of the 'starts' evaluator definition
- *
+ *
* @author mgroch
*/
public class StartsEvaluatorDefinition
@@ -46,11 +49,19 @@
false );
public static final Operator STARTS_NOT = Operator.addOperatorToRegistry( "starts",
true );
-
+
private static final String[] SUPPORTED_IDS = { STARTS.getOperatorString() };
-
+
private Map<String, StartsEvaluator> cache = Collections.emptyMap();
+ public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
+ cache = (Map<String, StartsEvaluator>)in.readObject();
+ }
+
+ public void writeExternal(ObjectOutput out) throws IOException {
+ out.writeObject(cache);
+ }
+
/**
* @inheridDoc
*/
@@ -131,7 +142,7 @@
*/
public static class StartsEvaluator extends BaseEvaluator {
private static final long serialVersionUID = 5622952247746290865L;
-
+
private long startDev;
private long endMinDev, endMaxDev;
@@ -142,12 +153,29 @@
isNegated ? STARTS_NOT : STARTS );
this.parseParameters( parameters );
}
-
+
+ public StartsEvaluator() {
+ }
+
+ public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
+ super.readExternal(in);
+ startDev = in.readLong();
+ endMinDev = in.readLong();
+ endMaxDev = in.readLong();
+ }
+
+ public void writeExternal(ObjectOutput out) throws IOException {
+ super.writeExternal(out);
+ out.writeLong(startDev);
+ out.writeLong(endMinDev);
+ out.writeLong(endMaxDev);
+ }
+
@Override
public Object prepareObject(InternalFactHandle handle) {
return handle;
}
-
+
public boolean evaluate(InternalWorkingMemory workingMemory,
final Extractor extractor,
final Object object1,
@@ -158,16 +186,16 @@
public boolean evaluateCachedRight(InternalWorkingMemory workingMemory,
final VariableContextEntry context,
final Object left) {
-
+
if ( context.rightNull ) {
return false;
}
long distStart = Math.abs(((EventFactHandle)((ObjectVariableContextEntry) context).right).getStartTimestamp() - ((EventFactHandle) left ).getStartTimestamp());
long distEnd = ((EventFactHandle) left ).getEndTimestamp() - ((EventFactHandle)((ObjectVariableContextEntry) context).right).getEndTimestamp();
- return this.getOperator().isNegated() ^ ( distStart <= this.startDev
+ return this.getOperator().isNegated() ^ ( distStart <= this.startDev
&& distEnd >= this.endMinDev && distEnd <= this.endMaxDev );
}
-
+
public boolean evaluateCachedLeft(InternalWorkingMemory workingMemory,
final VariableContextEntry context,
final Object right) {
@@ -177,10 +205,10 @@
}
long distStart = Math.abs(((EventFactHandle) right ).getStartTimestamp() - ((EventFactHandle) ((ObjectVariableContextEntry) context).left).getStartTimestamp());
long distEnd = ((EventFactHandle) ((ObjectVariableContextEntry) context).left).getEndTimestamp() - ((EventFactHandle) right ).getEndTimestamp();
- return this.getOperator().isNegated() ^ ( distStart <= this.startDev
+ return this.getOperator().isNegated() ^ ( distStart <= this.startDev
&& distEnd >= this.endMinDev && distEnd <= this.endMaxDev );
}
-
+
public boolean evaluate(InternalWorkingMemory workingMemory,
final Extractor extractor1,
final Object object1,
@@ -192,7 +220,7 @@
}
long distStart = Math.abs(((EventFactHandle) object1 ).getStartTimestamp() - ((EventFactHandle) object2 ).getStartTimestamp());
long distEnd = ((EventFactHandle) object2 ).getEndTimestamp() - ((EventFactHandle) object1 ).getEndTimestamp();
- return this.getOperator().isNegated() ^ ( distStart <= this.startDev
+ return this.getOperator().isNegated() ^ ( distStart <= this.startDev
&& distEnd >= this.endMinDev && distEnd <= this.endMaxDev );
}
@@ -226,9 +254,9 @@
}
/**
- * This methods tries to parse the string of parameters to customize
+ * This methods tries to parse the string of parameters to customize
* the evaluator.
- *
+ *
* @param parameters
*/
private void parseParameters(String parameters) {
@@ -250,13 +278,13 @@
this.endMaxDev = this.endMinDev;
} else if ( ranges.length == 2 ) {
// exact matching at the beginning of the intervals
- // range for deviations of the ends of the intervals
+ // range for deviations of the ends of the intervals
this.startDev = 0;
this.endMinDev = Long.parseLong( ranges[0] );
this.endMaxDev = Long.parseLong( ranges[1] );
} else if ( ranges.length == 3 ) {
// max. deviation at the starts of the intervals
- // range for deviations of the ends of the intervals
+ // range for deviations of the ends of the intervals
this.startDev = Long.parseLong( ranges[0] );;
this.endMinDev = Long.parseLong( ranges[1] );
this.endMaxDev = Long.parseLong( ranges[2] );
Modified: labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/base/extractors/ArrayExtractor.java
===================================================================
--- labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/base/extractors/ArrayExtractor.java 2008-03-20 18:57:07 UTC (rev 19163)
+++ labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/base/extractors/ArrayExtractor.java 2008-03-20 19:32:10 UTC (rev 19164)
@@ -1,6 +1,9 @@
package org.drools.base.extractors;
import java.lang.reflect.Method;
+import java.io.IOException;
+import java.io.ObjectOutput;
+import java.io.ObjectInput;
import org.drools.base.ValueType;
import org.drools.common.InternalWorkingMemory;
@@ -8,24 +11,40 @@
import org.drools.util.ClassUtils;
public class ArrayExtractor implements Extractor {
- private final Extractor arrayExtractor;
- private final int index;
- private final Class type;
-
+ private Extractor arrayExtractor;
+ private int index;
+ private Class type;
+
+ public ArrayExtractor() {
+
+ }
+
public ArrayExtractor(Extractor arrayExtractor, int index, Class type) {
this.arrayExtractor = arrayExtractor;
this.index = index;
this.type = type;
}
-
+
public Class getExtractToClass() {
- return type;
+ return type;
}
-
+
+ public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
+ arrayExtractor = (Extractor)in.readObject();
+ index = in.readInt();
+ type = (Class)in.readObject();
+ }
+
+ public void writeExternal(ObjectOutput out) throws IOException {
+ out.writeObject(arrayExtractor);
+ out.writeInt(index);
+ out.writeObject(type);
+ }
+
public String getExtractToClassName() {
- return ClassUtils.canonicalName( type );
+ return ClassUtils.canonicalName( type );
}
-
+
public boolean getBooleanValue(InternalWorkingMemory workingMemory, Object object) {
Object[] array = ( Object[] ) this.arrayExtractor.getValue( workingMemory, object );
return ( (Boolean)array[ this.index ]).booleanValue();
@@ -74,11 +93,11 @@
Object[] array = ( Object[] ) this.arrayExtractor.getValue( workingMemory, object );
return array[ this.index ] == null;
}
-
+
public int getHashCode(InternalWorkingMemory workingMemory, Object object) {
Object[] array = ( Object[] ) this.arrayExtractor.getValue( workingMemory, object );
return array[ this.index ].hashCode();
- }
+ }
public int hashCode() {
final int PRIME = 31;
Modified: labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/base/extractors/BaseObjectClassFieldExtractor.java
===================================================================
--- labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/base/extractors/BaseObjectClassFieldExtractor.java 2008-03-20 18:57:07 UTC (rev 19163)
+++ labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/base/extractors/BaseObjectClassFieldExtractor.java 2008-03-20 19:32:10 UTC (rev 19164)
@@ -11,6 +11,10 @@
private static final long serialVersionUID = 400L;
+ public BaseObjectClassFieldExtractor() {
+
+ }
+
protected BaseObjectClassFieldExtractor(final int index,
final Class fieldType,
final ValueType valueType) {
@@ -28,10 +32,10 @@
public abstract Object getValue(InternalWorkingMemory workingMemory, Object object);
public boolean getBooleanValue(InternalWorkingMemory workingMemory, final Object object) {
- // this can be improved by generating specific
+ // this can be improved by generating specific
// bytecode generation in the subclass, avoiding the if instanceof
final Object value = getValue( workingMemory, object );
-
+
if ( value instanceof Boolean ) {
return ((Boolean) value).booleanValue();
}
@@ -39,10 +43,10 @@
}
public byte getByteValue(InternalWorkingMemory workingMemory, final Object object) {
- // this can be improved by generating specific
+ // this can be improved by generating specific
// bytecode generation in the subclass, avoiding the if instanceof
final Object value = getValue( workingMemory, object );
-
+
if ( value instanceof Number ) {
return ((Number) value).byteValue();
}
@@ -50,10 +54,10 @@
}
public char getCharValue(InternalWorkingMemory workingMemory, final Object object) {
- // this can be improved by generating specific
+ // this can be improved by generating specific
// bytecode generation in the subclass, avoiding the if instanceof
final Object value = getValue( workingMemory, object );
-
+
if ( value instanceof Character ) {
return ((Character) value).charValue();
} else if( value instanceof String && ((String)value).length() == 1 ) {
@@ -63,10 +67,10 @@
}
public double getDoubleValue(InternalWorkingMemory workingMemory, final Object object) {
- // this can be improved by generating specific
+ // this can be improved by generating specific
// bytecode generation in the subclass, avoiding the if instanceof
final Object value = getValue( workingMemory, object );
-
+
if ( value instanceof Number ) {
return ((Number) value).doubleValue();
}
@@ -74,10 +78,10 @@
}
public float getFloatValue(InternalWorkingMemory workingMemory, final Object object) {
- // this can be improved by generating specific
+ // this can be improved by generating specific
// bytecode generation in the subclass, avoiding the if instanceof
final Object value = getValue( workingMemory, object );
-
+
if ( value instanceof Number ) {
return ((Number) value).floatValue();
}
@@ -85,10 +89,10 @@
}
public int getIntValue(InternalWorkingMemory workingMemory, final Object object) {
- // this can be improved by generating specific
+ // this can be improved by generating specific
// bytecode generation in the subclass, avoiding the if instanceof
final Object value = getValue( workingMemory, object );
-
+
if ( value instanceof Number ) {
return ((Number) value).intValue();
}
@@ -96,10 +100,10 @@
}
public long getLongValue(InternalWorkingMemory workingMemory, final Object object) {
- // this can be improved by generating specific
+ // this can be improved by generating specific
// bytecode generation in the subclass, avoiding the if instanceof
final Object value = getValue( workingMemory, object );
-
+
if ( value instanceof Number ) {
return ((Number) value).longValue();
}
@@ -107,7 +111,7 @@
}
public short getShortValue(InternalWorkingMemory workingMemory, final Object object) {
- // this can be improved by generating specific
+ // this can be improved by generating specific
// bytecode generation in the subclass, avoiding the if instanceof
final Object value = getValue( workingMemory, object );
@@ -116,7 +120,7 @@
}
throw new RuntimeDroolsException( "Conversion to short not supported from " + value.getClass().getName() );
}
-
+
public boolean isNullValue(InternalWorkingMemory workingMemory, final Object object) {
if (object == null) {
return true;
Modified: labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/base/extractors/MVELClassFieldExtractor.java
===================================================================
--- labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/base/extractors/MVELClassFieldExtractor.java 2008-03-20 18:57:07 UTC (rev 19163)
+++ labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/base/extractors/MVELClassFieldExtractor.java 2008-03-20 19:32:10 UTC (rev 19164)
@@ -1,12 +1,12 @@
/*
* Copyright 2006 JBoss Inc
- *
+ *
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -21,6 +21,9 @@
import java.util.Iterator;
import java.util.Map;
import java.util.Set;
+import java.io.ObjectInput;
+import java.io.IOException;
+import java.io.ObjectOutput;
import org.drools.base.ClassFieldExtractorCache;
import org.drools.base.ValueType;
@@ -34,16 +37,18 @@
/**
* A class field extractor that uses MVEL engine to extract the actual value for a given
* expression. We use MVEL to resolve nested accessor expressions.
- *
+ *
* @author etirelli
*/
public class MVELClassFieldExtractor extends BaseObjectClassFieldExtractor {
-
+
private static final long serialVersionUID = 400L;
private CompiledExpression mvelExpression = null;
private Map extractors = null;
+ public MVELClassFieldExtractor() {
+ }
public MVELClassFieldExtractor(Class clazz,
String fieldName,
ClassLoader classLoader) {
@@ -54,16 +59,28 @@
ExpressionCompiler compiler = new ExpressionCompiler( fieldName );
this.mvelExpression = compiler.compile();
-
+
Set inputs = compiler.getParserContextState().getInputs().keySet();
for( Iterator it = inputs.iterator(); it.hasNext(); ) {
String basefield = (String) it.next();
-
+
Extractor extr = ClassFieldExtractorCache.getInstance().getExtractor( clazz, basefield, classLoader );
this.extractors.put( basefield, extr );
}
}
+ public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
+ super.readExternal(in);
+ mvelExpression = (CompiledExpression)in.readObject();
+ extractors = (Map)in.readObject();
+ }
+
+ public void writeExternal(ObjectOutput out) throws IOException {
+ super.writeExternal(out);
+ out.writeObject(mvelExpression);
+ out.writeObject(extractors);
+ }
+
/* (non-Javadoc)
* @see org.drools.base.extractors.BaseObjectClassFieldExtractor#getValue(java.lang.Object)
*/
@@ -73,7 +90,7 @@
Map.Entry entry = (Map.Entry) it.next();
String var = (String) entry.getKey();
FieldExtractor extr = (FieldExtractor) entry.getValue();
-
+
variables.put( var, extr.getValue( workingMemory, object ));
}
return MVEL.executeExpression( mvelExpression, variables );
Modified: labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/base/field/BooleanFieldImpl.java
===================================================================
--- labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/base/field/BooleanFieldImpl.java 2008-03-20 18:57:07 UTC (rev 19163)
+++ labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/base/field/BooleanFieldImpl.java 2008-03-20 19:32:10 UTC (rev 19164)
@@ -1,12 +1,12 @@
/*
* Copyright 2005 JBoss Inc
- *
+ *
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -16,24 +16,44 @@
package org.drools.base.field;
+import java.math.BigDecimal;
+import java.math.BigInteger;
+
import org.drools.RuntimeDroolsException;
import org.drools.spi.FieldValue;
+import java.io.Externalizable;
+import java.io.ObjectInput;
+import java.io.IOException;
+import java.io.ObjectOutput;
+
/**
* @author etirelli
*
*/
public class BooleanFieldImpl
implements
- FieldValue {
+ FieldValue, Externalizable {
private static final long serialVersionUID = 400L;
- private final boolean value;
+ private boolean value;
+ public BooleanFieldImpl() {
+
+ }
+
public BooleanFieldImpl(final boolean value) {
this.value = value;
}
+ public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
+ value = in.readBoolean();
+ }
+
+ public void writeExternal(ObjectOutput out) throws IOException {
+ out.writeBoolean(value);
+ }
+
public Object getValue() {
return this.value ? Boolean.TRUE : Boolean.FALSE;
}
@@ -89,7 +109,7 @@
public int hashCode() {
return this.value ? 1 : 0;
}
-
+
public boolean isNull() {
return false;
}
@@ -113,9 +133,18 @@
public boolean isCollectionField() {
return false;
}
-
+
public boolean isStringField() {
return false;
}
+ public BigDecimal getBigDecimalValue() {
+ throw new RuntimeDroolsException( "Conversion to BigDecimal not supported for type boolean" );
+ }
+
+ public BigInteger getBigIntegerValue() {
+ throw new RuntimeDroolsException( "Conversion to BigInteger not supported for type boolean" );
+ }
+
+
}
Modified: labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/base/field/DoubleFieldImpl.java
===================================================================
--- labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/base/field/DoubleFieldImpl.java 2008-03-20 18:57:07 UTC (rev 19163)
+++ labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/base/field/DoubleFieldImpl.java 2008-03-20 19:32:10 UTC (rev 19164)
@@ -1,19 +1,38 @@
package org.drools.base.field;
+import java.math.BigDecimal;
+import java.math.BigInteger;
+
import org.drools.RuntimeDroolsException;
import org.drools.spi.FieldValue;
+import java.io.Externalizable;
+import java.io.ObjectInput;
+import java.io.IOException;
+import java.io.ObjectOutput;
+
public class DoubleFieldImpl
implements
- FieldValue {
+ FieldValue, Externalizable {
private static final long serialVersionUID = 400L;
- private final double value;
+ private double value;
+ public DoubleFieldImpl() {
+ }
+
public DoubleFieldImpl(final double value) {
this.value = value;
}
+ public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
+ value = in.readDouble();
+ }
+
+ public void writeExternal(ObjectOutput out) throws IOException {
+ out.writeDouble(value);
+ }
+
public Object getValue() {
return new Double( this.value );
}
@@ -69,7 +88,7 @@
public int hashCode() {
return (int) this.value;
}
-
+
public boolean isNull() {
return false;
}
@@ -89,7 +108,7 @@
public boolean isObjectField() {
return false;
}
-
+
public boolean isCollectionField() {
return false;
}
@@ -98,4 +117,12 @@
return false;
}
+ public BigDecimal getBigDecimalValue() {
+ return new BigDecimal(this.value);
+ }
+
+ public BigInteger getBigIntegerValue() {
+ throw new RuntimeDroolsException( "Conversion to BigInteger not supported for type double" );
+ }
+
}
Modified: labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/base/field/LongFieldImpl.java
===================================================================
--- labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/base/field/LongFieldImpl.java 2008-03-20 18:57:07 UTC (rev 19163)
+++ labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/base/field/LongFieldImpl.java 2008-03-20 19:32:10 UTC (rev 19164)
@@ -1,19 +1,39 @@
package org.drools.base.field;
+import java.math.BigDecimal;
+import java.math.BigInteger;
+
import org.drools.RuntimeDroolsException;
import org.drools.spi.FieldValue;
+import java.io.Externalizable;
+import java.io.ObjectInput;
+import java.io.IOException;
+import java.io.ObjectOutput;
+
public class LongFieldImpl
implements
- FieldValue {
+ FieldValue, Externalizable {
private static final long serialVersionUID = 400L;
- private final long value;
+ private long value;
+ public LongFieldImpl() {
+
+ }
+
public LongFieldImpl(final long value) {
this.value = value;
}
+ public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
+ value = in.readLong();
+ }
+
+ public void writeExternal(ObjectOutput out) throws IOException {
+ out.writeLong(value);
+ }
+
public Object getValue() {
return new Long( this.value );
}
@@ -69,7 +89,7 @@
public int hashCode() {
return (int) this.value;
}
-
+
public boolean isNull() {
return false;
}
@@ -98,4 +118,12 @@
return false;
}
+ public BigDecimal getBigDecimalValue() {
+ return new BigDecimal(this.value);
+ }
+
+ public BigInteger getBigIntegerValue() {
+ return BigInteger.valueOf(this.value);
+ }
+
}
Modified: labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/base/field/ObjectFieldImpl.java
===================================================================
--- labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/base/field/ObjectFieldImpl.java 2008-03-20 18:57:07 UTC (rev 19163)
+++ labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/base/field/ObjectFieldImpl.java 2008-03-20 19:32:10 UTC (rev 19164)
@@ -2,13 +2,13 @@
/*
* Copyright 2005 JBoss Inc
- *
+ *
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -16,6 +16,12 @@
* limitations under the License.
*/
+import java.io.Externalizable;
+import java.io.IOException;
+import java.io.ObjectInput;
+import java.io.ObjectOutput;
+import java.math.BigDecimal;
+import java.math.BigInteger;
import java.util.Collection;
import org.drools.RuntimeDroolsException;
@@ -23,19 +29,70 @@
public class ObjectFieldImpl
implements
- FieldValue {
+ FieldValue,
+ Externalizable {
private static final long serialVersionUID = 400L;
- private final Object value;
-
- private final boolean isCollection;
- private final boolean isNumber;
- private final boolean isBoolean;
- private final boolean isCharacter;
- private final boolean isString;
+ private Object value;
+
+ // the isEnum attribute is used to support jdk 1.4 type safe enums, and so
+ // has a different behavior of the other booleans in this class
+ private boolean isEnum;
+ private String enumName;
+ private String fieldName;
+
+ private transient boolean isCollection;
+ private transient boolean isNumber;
+ private transient boolean isBoolean;
+ private transient boolean isCharacter;
+ private transient boolean isString;
+
+ public ObjectFieldImpl() {
+ this( null );
+ }
+
public ObjectFieldImpl(final Object value) {
this.value = value;
+ this.isEnum = value instanceof Enum;
+ setBooleans();
+ }
+
+ public void readExternal(ObjectInput in) throws IOException,
+ ClassNotFoundException {
+ isEnum = in.readBoolean();
+ enumName = (String) in.readObject();
+ fieldName = (String) in.readObject();
+ if ( !isEnum || enumName == null || fieldName == null ) {
+ value = in.readObject();
+ } else {
+ resolveEnumValue();
+ }
+ setBooleans();
+ }
+
+ public void writeExternal(ObjectOutput out) throws IOException {
+ out.writeBoolean( isEnum );
+ out.writeObject( enumName );
+ out.writeObject( fieldName );
+ if ( !isEnum || enumName == null || fieldName == null ) {
+ out.writeObject( value );
+ }
+ }
+
+ private void resolveEnumValue() {
+ try {
+ final Class<?> staticClass = Class.forName( enumName );
+ value = staticClass.getField( fieldName ).get( null );
+ } catch ( final Exception e ) {
+ throw new RuntimeDroolsException("Error deserializing enum value "+enumName+"."+fieldName+" : "+e.getMessage());
+ }
+ }
+
+ /**
+ * @param value
+ */
+ private void setBooleans() {
this.isCollection = value instanceof Collection;
this.isNumber = value instanceof Number;
this.isBoolean = value instanceof Boolean;
@@ -54,7 +111,7 @@
public boolean getBooleanValue() {
if ( isBoolean ) {
return ((Boolean) this.value).booleanValue();
- } else if( isString ) {
+ } else if ( isString ) {
return Boolean.valueOf( (String) this.value ).booleanValue();
}
throw new RuntimeDroolsException( "Conversion to boolean not supported for type: " + this.value.getClass() );
@@ -63,17 +120,17 @@
public byte getByteValue() {
if ( isNumber ) {
return ((Number) this.value).byteValue();
- } else if( isString ) {
+ } else if ( isString ) {
return Byte.valueOf( (String) this.value ).byteValue();
- }
+ }
throw new RuntimeDroolsException( "Conversion to byte not supported for type: " + this.value.getClass() );
}
public char getCharValue() {
if ( isCharacter ) {
return ((Character) this.value).charValue();
- } else if( isString && ((String) this.value).length() == 1 ) {
- return ( (String) this.value ).charAt( 0 );
+ } else if ( isString && ((String) this.value).length() == 1 ) {
+ return ((String) this.value).charAt( 0 );
}
throw new RuntimeDroolsException( "Conversion to char not supported for type: " + this.value.getClass() );
}
@@ -81,7 +138,7 @@
public double getDoubleValue() {
if ( isNumber ) {
return ((Number) this.value).doubleValue();
- } else if( isString ) {
+ } else if ( isString ) {
return Double.valueOf( (String) this.value ).doubleValue();
}
throw new RuntimeDroolsException( "Conversion to double not supported for type: " + this.value.getClass() );
@@ -90,7 +147,7 @@
public float getFloatValue() {
if ( isNumber ) {
return ((Number) this.value).floatValue();
- } else if( isString ) {
+ } else if ( isString ) {
return Float.valueOf( (String) this.value ).floatValue();
}
throw new RuntimeDroolsException( "Conversion to float not supported for type: " + this.value.getClass() );
@@ -99,7 +156,7 @@
public int getIntValue() {
if ( isNumber ) {
return ((Number) this.value).intValue();
- } else if( isString ) {
+ } else if ( isString ) {
return Integer.valueOf( (String) this.value ).intValue();
}
throw new RuntimeDroolsException( "Conversion to int not supported for type: " + this.value.getClass() );
@@ -108,7 +165,7 @@
public long getLongValue() {
if ( isNumber ) {
return ((Number) this.value).longValue();
- } else if( isString ) {
+ } else if ( isString ) {
return Long.valueOf( (String) this.value ).longValue();
}
throw new RuntimeDroolsException( "Conversion to long not supported for type: " + this.value.getClass() );
@@ -117,7 +174,7 @@
public short getShortValue() {
if ( isNumber ) {
return ((Number) this.value).shortValue();
- } else if( isString ) {
+ } else if ( isString ) {
return Short.valueOf( (String) this.value ).shortValue();
}
throw new RuntimeDroolsException( "Conversion to short not supported for type: " + this.value.getClass() );
@@ -142,7 +199,7 @@
return 0;
}
}
-
+
public boolean isNull() {
return value == null;
}
@@ -162,12 +219,59 @@
public boolean isObjectField() {
return true;
}
-
+
public boolean isCollectionField() {
return this.isCollection;
}
-
+
public boolean isStringField() {
return this.isString;
}
+
+ public BigDecimal getBigDecimalValue() {
+ if (this.value instanceof BigDecimal) return (BigDecimal) this.value;
+ if (this.isNumber) {
+ return new BigDecimal(((Number) value).doubleValue());
+ } else if (this.isString) {
+ return new BigDecimal((String) value);
+ }
+ if (this.value == null) return null;
+ throw new RuntimeDroolsException( "Conversion to BigDecimal not supported for type: " + this.value.getClass() );
+ }
+
+ public BigInteger getBigIntegerValue() {
+ if (this.value instanceof BigInteger) return (BigInteger) this.value;
+ if (this.isNumber) {
+ return BigInteger.valueOf(((Number) value).longValue());
+ } else if (this.isString) {
+ return new BigInteger((String) value);
+ }
+ if (this.value == null) return null;
+ throw new RuntimeDroolsException( "Conversion to BigInteger not supported for type: " + this.value.getClass() );
+ }
+
+ public boolean isEnum() {
+ return isEnum;
+ }
+
+ public void setEnum(boolean isEnum) {
+ this.isEnum = isEnum;
+ }
+
+ public String getEnumName() {
+ return enumName;
+ }
+
+ public void setEnumName(String enumName) {
+ this.enumName = enumName;
+ }
+
+ public String getFieldName() {
+ return fieldName;
+ }
+
+ public void setFieldName(String fieldName) {
+ this.fieldName = fieldName;
+ }
+
}
\ No newline at end of file
Modified: labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/base/mvel/DroolsMVELFactory.java
===================================================================
--- labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/base/mvel/DroolsMVELFactory.java 2008-03-20 18:57:07 UTC (rev 19163)
+++ labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/base/mvel/DroolsMVELFactory.java 2008-03-20 19:32:10 UTC (rev 19164)
@@ -1,6 +1,9 @@
package org.drools.base.mvel;
-import java.io.Serializable;
+import java.io.Externalizable;
+import java.io.IOException;
+import java.io.ObjectInput;
+import java.io.ObjectOutput;
import java.lang.reflect.Method;
import java.util.Calendar;
import java.util.Date;
@@ -23,7 +26,7 @@
public class DroolsMVELFactory extends BaseVariableResolverFactory
implements
LocalVariableResolverFactory,
- Serializable,
+ Externalizable,
Cloneable {
private static final long serialVersionUID = 400L;
@@ -55,6 +58,10 @@
new MVELCalendarCoercion() );
}
+ public DroolsMVELFactory() {
+
+ }
+
public DroolsMVELFactory(final Map previousDeclarations,
final Map localDeclarations,
final Map globals) {
@@ -82,36 +89,28 @@
}
}
- // public void writeExternal(final ObjectOutput stream) throws IOException {
- // setNextFactory( null );
- // stream.writeObject( this.previousDeclarations );
- // stream.writeObject( this.localDeclarations );
- // stream.writeObject( this.globals );
- // stream.writeObject( this.variableResolvers );
- // }
- //
- // public void readExternal(final ObjectInput stream) throws IOException,
- // ClassNotFoundException {
- // DroolsObjectInputStream droolsInputStream = (DroolsObjectInputStream) stream;
- //
- // this.previousDeclarations = (Map) droolsInputStream.readObject();
- // this.localDeclarations = (Map) droolsInputStream.readObject();
- // this.globals = (Map) droolsInputStream.readObject();
- // this.variableResolvers = (Map) droolsInputStream.readObject();
- //
- // StaticMethodImportResolverFactory factory = new StaticMethodImportResolverFactory();
- // setNextFactory( factory );
- //
- // Package pkg = droolsInputStream.getPackage();
- // ClassLoader classLoader = pkg.getPackageCompilationData().getClassLoader();
- // for ( Iterator it = pkg.getStaticImports().iterator(); it.hasNext(); ) {
- // String staticImportEntry = (String) it.next();
- // addStaticImport( factory,
- // staticImportEntry,
- // classLoader );
- // }
- // }
+ public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
+ tupleObjects = (Object[])in.readObject();
+ knowledgeHelper = (KnowledgeHelper)in.readObject();
+ object = in.readObject();
+ localDeclarations = (Map)in.readObject();
+ previousDeclarations = (Map)in.readObject();
+ globals = (Map)in.readObject();
+ workingMemory = (WorkingMemory)in.readObject();
+ localVariables = (Map)in.readObject();
+ }
+ public void writeExternal(ObjectOutput out) throws IOException {
+ out.writeObject(tupleObjects);
+ out.writeObject(knowledgeHelper);
+ out.writeObject(object);
+ out.writeObject(localDeclarations);
+ out.writeObject(previousDeclarations);
+ out.writeObject(globals);
+ out.writeObject(workingMemory);
+ out.writeObject(localVariables);
+ }
+
public static void addStaticImport(StaticMethodImportResolverFactory factory,
String staticImportEntry,
ClassLoader classLoader) {
Modified: labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/base/mvel/DroolsMVELGlobalVariable.java
===================================================================
--- labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/base/mvel/DroolsMVELGlobalVariable.java 2008-03-20 18:57:07 UTC (rev 19163)
+++ labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/base/mvel/DroolsMVELGlobalVariable.java 2008-03-20 19:32:10 UTC (rev 19164)
@@ -1,13 +1,17 @@
package org.drools.base.mvel;
import java.io.Serializable;
+import java.io.Externalizable;
+import java.io.ObjectOutput;
+import java.io.IOException;
+import java.io.ObjectInput;
import org.mvel.integration.VariableResolver;
public class DroolsMVELGlobalVariable
implements
VariableResolver,
- Serializable {
+ Externalizable {
private static final long serialVersionUID = -2480015657934353449L;
@@ -15,6 +19,9 @@
private Class knownType;
private DroolsMVELFactory factory;
+ public DroolsMVELGlobalVariable() {
+ }
+
public DroolsMVELGlobalVariable(final String identifier,
final Class knownType,
final DroolsMVELFactory factory) {
@@ -23,6 +30,18 @@
this.knownType = knownType;
}
+ public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
+ name = (String)in.readObject();
+ knownType = (Class)in.readObject();
+ factory = (DroolsMVELFactory)in.readObject();
+ }
+
+ public void writeExternal(ObjectOutput out) throws IOException {
+ out.writeObject(name);
+ out.writeObject(knownType);
+ out.writeObject(factory);
+ }
+
public String getName() {
return this.name;
}
Modified: labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/base/mvel/DroolsMVELKnowledgeHelper.java
===================================================================
--- labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/base/mvel/DroolsMVELKnowledgeHelper.java 2008-03-20 18:57:07 UTC (rev 19163)
+++ labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/base/mvel/DroolsMVELKnowledgeHelper.java 2008-03-20 19:32:10 UTC (rev 19164)
@@ -1,6 +1,10 @@
package org.drools.base.mvel;
import java.io.Serializable;
+import java.io.Externalizable;
+import java.io.ObjectOutput;
+import java.io.IOException;
+import java.io.ObjectInput;
import org.drools.spi.KnowledgeHelper;
import org.mvel.integration.VariableResolver;
@@ -8,17 +12,28 @@
public class DroolsMVELKnowledgeHelper
implements
VariableResolver,
- Serializable {
+ Externalizable {
private static final long serialVersionUID = 9175428283083361478L;
private DroolsMVELFactory factory;
public static final String DROOLS = "drools";
+ public DroolsMVELKnowledgeHelper() {
+ }
+
public DroolsMVELKnowledgeHelper(final DroolsMVELFactory factory) {
this.factory = factory;
}
+ public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
+ factory = (DroolsMVELFactory)in.readObject();
+ }
+
+ public void writeExternal(ObjectOutput out) throws IOException {
+ out.writeObject(factory);
+ }
+
public String getName() {
return DROOLS;
}
Modified: labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/base/mvel/DroolsMVELLocalDeclarationVariable.java
===================================================================
--- labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/base/mvel/DroolsMVELLocalDeclarationVariable.java 2008-03-20 18:57:07 UTC (rev 19163)
+++ labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/base/mvel/DroolsMVELLocalDeclarationVariable.java 2008-03-20 19:32:10 UTC (rev 19164)
@@ -1,6 +1,9 @@
package org.drools.base.mvel;
-import java.io.Serializable;
+import java.io.Externalizable;
+import java.io.IOException;
+import java.io.ObjectInput;
+import java.io.ObjectOutput;
import org.drools.common.InternalWorkingMemory;
import org.drools.rule.Declaration;
@@ -9,19 +12,32 @@
public class DroolsMVELLocalDeclarationVariable
implements
VariableResolver,
- Serializable {
+ Externalizable {
private static final long serialVersionUID = -8081447010148362496L;
private Declaration declaration;
private DroolsMVELFactory factory;
+ public DroolsMVELLocalDeclarationVariable() {
+ }
+
public DroolsMVELLocalDeclarationVariable(final Declaration declaration,
final DroolsMVELFactory factory) {
this.declaration = declaration;
this.factory = factory;
}
+ public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
+ declaration = (Declaration)in.readObject();
+ factory = (DroolsMVELFactory)in.readObject();
+ }
+
+ public void writeExternal(ObjectOutput out) throws IOException {
+ out.writeObject(declaration);
+ out.writeObject(factory);
+ }
+
public String getName() {
return this.declaration.getIdentifier();
}
Modified: labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/base/mvel/DroolsMVELPreviousDeclarationVariable.java
===================================================================
--- labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/base/mvel/DroolsMVELPreviousDeclarationVariable.java 2008-03-20 18:57:07 UTC (rev 19163)
+++ labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/base/mvel/DroolsMVELPreviousDeclarationVariable.java 2008-03-20 19:32:10 UTC (rev 19164)
@@ -1,6 +1,9 @@
package org.drools.base.mvel;
-import java.io.Serializable;
+import java.io.Externalizable;
+import java.io.ObjectOutput;
+import java.io.ObjectInput;
+import java.io.IOException;
import org.drools.common.InternalWorkingMemory;
import org.drools.rule.Declaration;
@@ -9,17 +12,30 @@
public class DroolsMVELPreviousDeclarationVariable
implements
VariableResolver,
- Serializable {
+ Externalizable {
private Declaration declaration;
private DroolsMVELFactory factory;
+ public DroolsMVELPreviousDeclarationVariable() {
+ }
+
public DroolsMVELPreviousDeclarationVariable(final Declaration declaration,
final DroolsMVELFactory factory) {
this.declaration = declaration;
this.factory = factory;
}
+ public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
+ declaration = (Declaration)in.readObject();
+ factory = (DroolsMVELFactory)in.readObject();
+ }
+
+ public void writeExternal(ObjectOutput out) throws IOException {
+ out.writeObject(declaration);
+ out.writeObject(factory);
+ }
+
public String getName() {
return this.declaration.getIdentifier();
}
Modified: labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/base/mvel/MVELAccumulator.java
===================================================================
--- labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/base/mvel/MVELAccumulator.java 2008-03-20 18:57:07 UTC (rev 19163)
+++ labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/base/mvel/MVELAccumulator.java 2008-03-20 19:32:10 UTC (rev 19164)
@@ -1,12 +1,12 @@
/*
* Copyright 2007 JBoss Inc
- *
+ *
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -18,6 +18,9 @@
package org.drools.base.mvel;
import java.io.Serializable;
+import java.io.IOException;
+import java.io.ObjectOutput;
+import java.io.ObjectInput;
import java.util.HashMap;
import java.util.Map;
@@ -32,7 +35,7 @@
/**
* An MVEL accumulator implementation
- *
+ *
* @author etirelli
*/
public class MVELAccumulator
@@ -41,12 +44,15 @@
private static final long serialVersionUID = 400L;
- private final DroolsMVELFactory prototype;
- private final Serializable init;
- private final Serializable action;
- private final Serializable reverse;
- private final Serializable result;
+ private DroolsMVELFactory prototype;
+ private Serializable init;
+ private Serializable action;
+ private Serializable reverse;
+ private Serializable result;
+ public MVELAccumulator() {
+ }
+
public MVELAccumulator(final DroolsMVELFactory factory,
final Serializable init,
final Serializable action,
@@ -60,6 +66,22 @@
this.result = result;
}
+ public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
+ prototype = (DroolsMVELFactory)in.readObject();
+ init = (Serializable)in.readObject();
+ action = (Serializable)in.readObject();
+ reverse = (Serializable)in.readObject();
+ result = (Serializable)in.readObject();
+ }
+
+ public void writeExternal(ObjectOutput out) throws IOException {
+ out.writeObject(prototype);
+ out.writeObject(init);
+ out.writeObject(action);
+ out.writeObject(reverse);
+ out.writeObject(result);
+ }
+
/* (non-Javadoc)
* @see org.drools.spi.Accumulator#createContext()
*/
@@ -102,13 +124,13 @@
handle.getObject(),
workingMemory,
(Map) context );
-
+
Package pkg = workingMemory.getRuleBase().getPackage( "MAIN" );
if ( pkg != null ) {
MVELDialectData data = ( MVELDialectData ) pkg.getDialectDatas().getDialectData( "mvel" );
factory.setNextFactory( data.getFunctionFactory() );
}
-
+
MVEL.executeExpression( this.action,
null,
factory );
@@ -127,13 +149,13 @@
handle.getObject(),
workingMemory,
(Map) context );
-
+
Package pkg = workingMemory.getRuleBase().getPackage( "MAIN" );
if ( pkg != null ) {
MVELDialectData data = ( MVELDialectData ) pkg.getDialectDatas().getDialectData( "mvel" );
factory.setNextFactory( data.getFunctionFactory() );
- }
-
+ }
+
MVEL.executeExpression( this.reverse,
null,
factory );
@@ -153,13 +175,13 @@
null,
workingMemory,
(Map) context );
-
+
Package pkg = workingMemory.getRuleBase().getPackage( "MAIN" );
if ( pkg != null ) {
MVELDialectData data = ( MVELDialectData ) pkg.getDialectDatas().getDialectData( "mvel" );
factory.setNextFactory( data.getFunctionFactory() );
- }
-
+ }
+
final Object result = MVEL.executeExpression( this.result,
null,
factory );
Modified: labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/base/mvel/MVELAction.java
===================================================================
--- labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/base/mvel/MVELAction.java 2008-03-20 18:57:07 UTC (rev 19163)
+++ labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/base/mvel/MVELAction.java 2008-03-20 19:32:10 UTC (rev 19164)
@@ -1,30 +1,47 @@
package org.drools.base.mvel;
-import java.io.Serializable;
-
import org.drools.WorkingMemory;
import org.drools.rule.MVELDialectData;
import org.drools.rule.Package;
import org.drools.spi.Action;
+import org.mvel.MVEL;
import org.mvel.compiler.CompiledExpression;
-import org.mvel.MVEL;
import org.mvel.debug.DebugTools;
+import java.io.Externalizable;
+import java.io.IOException;
+import java.io.ObjectInput;
+import java.io.ObjectOutput;
+import java.io.Serializable;
+
public class MVELAction
implements
Action,
- Serializable {
+ Externalizable {
private static final long serialVersionUID = 400L;
- private final Serializable expr;
- private final DroolsMVELFactory prototype;
+ private Serializable expr;
+ private DroolsMVELFactory prototype;
+ public MVELAction() {
+ }
+
public MVELAction(final Serializable expr,
final DroolsMVELFactory factory) {
this.expr = expr;
this.prototype = factory;
}
+ public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
+ expr = (Serializable)in.readObject();
+ prototype = (DroolsMVELFactory)in.readObject();
+ }
+
+ public void writeExternal(ObjectOutput out) throws IOException {
+ out.writeObject(expr);
+ out.writeObject(prototype);
+ }
+
public String getDialect() {
return "mvel";
}
Modified: labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/base/mvel/MVELConsequence.java
===================================================================
--- labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/base/mvel/MVELConsequence.java 2008-03-20 18:57:07 UTC (rev 19163)
+++ labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/base/mvel/MVELConsequence.java 2008-03-20 19:32:10 UTC (rev 19164)
@@ -1,48 +1,64 @@
package org.drools.base.mvel;
-import java.io.Serializable;
-
import org.drools.WorkingMemory;
-import org.drools.common.InternalRuleBase;
import org.drools.rule.MVELDialectData;
import org.drools.rule.Package;
import org.drools.spi.Consequence;
import org.drools.spi.KnowledgeHelper;
+import org.mvel.MVEL;
import org.mvel.compiler.CompiledExpression;
-import org.mvel.MVEL;
import org.mvel.debug.DebugTools;
+import java.io.Externalizable;
+import java.io.IOException;
+import java.io.ObjectInput;
+import java.io.ObjectOutput;
+import java.io.Serializable;
+
public class MVELConsequence
implements
Consequence,
- Serializable {
+ Externalizable {
private static final long serialVersionUID = 400L;
- private final Serializable expr;
- private final DroolsMVELFactory prototype;
+ private Serializable expr;
+ private DroolsMVELFactory prototype;
+ public MVELConsequence() {
+ }
+
public MVELConsequence(final Serializable expr,
final DroolsMVELFactory factory) {
this.expr = expr;
this.prototype = factory;
}
+ public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
+ expr = (Serializable)in.readObject();
+ prototype = (DroolsMVELFactory)in.readObject();
+ }
+
+ public void writeExternal(ObjectOutput out) throws IOException {
+ out.writeObject(expr);
+ out.writeObject(prototype);
+ }
+
public void evaluate(final KnowledgeHelper knowledgeHelper,
final WorkingMemory workingMemory) throws Exception {
DroolsMVELFactory factory = (DroolsMVELFactory) this.prototype.clone();
-
+
factory.setContext( knowledgeHelper.getTuple(),
knowledgeHelper,
null,
workingMemory,
null );
-
+
Package pkg = workingMemory.getRuleBase().getPackage( "MAIN" );
if ( pkg != null ) {
MVELDialectData data = ( MVELDialectData ) pkg.getDialectDatas().getDialectData( "mvel" );
factory.setNextFactory( data.getFunctionFactory() );
}
-
+
CompiledExpression compexpr = (CompiledExpression) this.expr;
//Receive breakpoints from debugger
Modified: labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/base/mvel/MVELEvalExpression.java
===================================================================
--- labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/base/mvel/MVELEvalExpression.java 2008-03-20 18:57:07 UTC (rev 19163)
+++ labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/base/mvel/MVELEvalExpression.java 2008-03-20 19:32:10 UTC (rev 19164)
@@ -1,6 +1,10 @@
package org.drools.base.mvel;
import java.io.Serializable;
+import java.io.Externalizable;
+import java.io.ObjectOutput;
+import java.io.IOException;
+import java.io.ObjectInput;
import org.drools.WorkingMemory;
import org.drools.rule.Declaration;
@@ -13,20 +17,33 @@
public class MVELEvalExpression
implements
EvalExpression,
- Serializable {
-
+ Externalizable {
+
private static final long serialVersionUID = 400L;
- private final Serializable expr;
- private final DroolsMVELFactory prototype;
+ private Serializable expr;
+ private DroolsMVELFactory prototype;
+ public MVELEvalExpression() {
+ }
+
public MVELEvalExpression(final Serializable expr,
final DroolsMVELFactory factory) {
this.expr = expr;
this.prototype = factory;
}
-
+
+ public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
+ expr = (Serializable)in.readObject();
+ prototype = (DroolsMVELFactory)in.readObject();
+ }
+
+ public void writeExternal(ObjectOutput out) throws IOException {
+ out.writeObject(expr);
+ out.writeObject(prototype);
+ }
+
public Object createContext() {
return this.prototype.clone();
}
@@ -41,13 +58,13 @@
null,
workingMemory,
null );
-
+
Package pkg = workingMemory.getRuleBase().getPackage( "MAIN" );
if ( pkg != null ) {
MVELDialectData data = ( MVELDialectData ) pkg.getDialectDatas().getDialectData( "mvel" );
factory.setNextFactory( data.getFunctionFactory() );
- }
-
+ }
+
final Boolean result = (Boolean) MVEL.executeExpression( this.expr,
new Object(),
factory );
Modified: labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/base/mvel/MVELPredicateExpression.java
===================================================================
--- labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/base/mvel/MVELPredicateExpression.java 2008-03-20 18:57:07 UTC (rev 19163)
+++ labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/base/mvel/MVELPredicateExpression.java 2008-03-20 19:32:10 UTC (rev 19164)
@@ -1,7 +1,5 @@
package org.drools.base.mvel;
-import java.io.Serializable;
-
import org.drools.WorkingMemory;
import org.drools.rule.Declaration;
import org.drools.rule.MVELDialectData;
@@ -10,21 +8,38 @@
import org.drools.spi.Tuple;
import org.mvel.MVEL;
+import java.io.IOException;
+import java.io.ObjectInput;
+import java.io.ObjectOutput;
+import java.io.Serializable;
+
public class MVELPredicateExpression
implements
- PredicateExpression,
- Serializable {
+ PredicateExpression {
private static final long serialVersionUID = 400L;
- private final Serializable expr;
- private final DroolsMVELFactory prototype;
+ private Serializable expr;
+ private DroolsMVELFactory prototype;
+ public MVELPredicateExpression() {
+ }
+
public MVELPredicateExpression(final Serializable expr,
final DroolsMVELFactory factory) {
this.expr = expr;
this.prototype = factory;
}
-
+
+ public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
+ expr = (Serializable)in.readObject();
+ prototype = (DroolsMVELFactory)in.readObject();
+ }
+
+ public void writeExternal(ObjectOutput out) throws IOException {
+ out.writeObject(expr);
+ out.writeObject(prototype);
+ }
+
public Object createContext() {
return this.prototype.clone();
}
@@ -41,13 +56,13 @@
object,
workingMemory,
null );
-
+
Package pkg = workingMemory.getRuleBase().getPackage( "MAIN" );
if ( pkg != null ) {
MVELDialectData data = ( MVELDialectData ) pkg.getDialectDatas().getDialectData( "mvel" );
factory.setNextFactory( data.getFunctionFactory() );
}
-
+
final Boolean result = (Boolean) MVEL.executeExpression( this.expr,
object,
factory );
Modified: labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/base/mvel/MVELReturnValueEvaluator.java
===================================================================
--- labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/base/mvel/MVELReturnValueEvaluator.java 2008-03-20 18:57:07 UTC (rev 19163)
+++ labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/base/mvel/MVELReturnValueEvaluator.java 2008-03-20 19:32:10 UTC (rev 19164)
@@ -1,30 +1,47 @@
package org.drools.base.mvel;
-import java.io.Serializable;
-
import org.drools.WorkingMemory;
import org.drools.rule.MVELDialectData;
import org.drools.rule.Package;
import org.drools.spi.ReturnValueEvaluator;
+import org.mvel.MVEL;
import org.mvel.compiler.CompiledExpression;
-import org.mvel.MVEL;
import org.mvel.debug.DebugTools;
+import java.io.Externalizable;
+import java.io.IOException;
+import java.io.ObjectInput;
+import java.io.ObjectOutput;
+import java.io.Serializable;
+
public class MVELReturnValueEvaluator
implements
ReturnValueEvaluator,
- Serializable {
+ Externalizable {
private static final long serialVersionUID = 400L;
- private final Serializable expr;
- private final DroolsMVELFactory prototype;
+ private Serializable expr;
+ private DroolsMVELFactory prototype;
+ public MVELReturnValueEvaluator() {
+ }
+
public MVELReturnValueEvaluator(final Serializable expr,
final DroolsMVELFactory factory) {
this.expr = expr;
this.prototype = factory;
}
+ public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
+ expr = (Serializable)in.readObject();
+ prototype = (DroolsMVELFactory)in.readObject();
+ }
+
+ public void writeExternal(ObjectOutput out) throws IOException {
+ out.writeObject(expr);
+ out.writeObject(prototype);
+ }
+
public String getDialect() {
return "mvel";
}
Modified: labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/base/mvel/MVELReturnValueExpression.java
===================================================================
--- labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/base/mvel/MVELReturnValueExpression.java 2008-03-20 18:57:07 UTC (rev 19163)
+++ labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/base/mvel/MVELReturnValueExpression.java 2008-03-20 19:32:10 UTC (rev 19164)
@@ -1,7 +1,5 @@
package org.drools.base.mvel;
-import java.io.Serializable;
-
import org.drools.WorkingMemory;
import org.drools.rule.Declaration;
import org.drools.rule.MVELDialectData;
@@ -11,15 +9,24 @@
import org.drools.spi.Tuple;
import org.mvel.MVEL;
+import java.io.Externalizable;
+import java.io.IOException;
+import java.io.ObjectInput;
+import java.io.ObjectOutput;
+import java.io.Serializable;
+
public class MVELReturnValueExpression
implements
ReturnValueExpression,
- Serializable {
+ Externalizable {
private static final long serialVersionUID = 400L;
- private final Serializable expr;
- private final DroolsMVELFactory prototype;
+ private Serializable expr;
+ private DroolsMVELFactory prototype;
+ public MVELReturnValueExpression() {
+ }
+
public MVELReturnValueExpression(final Serializable expr,
final DroolsMVELFactory factory) {
this.expr = expr;
@@ -38,18 +45,27 @@
object,
workingMemory,
null );
-
+
Package pkg = workingMemory.getRuleBase().getPackage( "MAIN" );
if ( pkg != null ) {
MVELDialectData data = ( MVELDialectData ) pkg.getDialectDatas().getDialectData( "mvel" );
factory.setNextFactory( data.getFunctionFactory() );
- }
+ }
return org.drools.base.FieldFactory.getFieldValue( MVEL.executeExpression( this.expr,
null,
factory ) );
}
+ public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
+ expr = (Serializable)in.readObject();
+ prototype = (DroolsMVELFactory)in.readObject();
+ }
+
+ public void writeExternal(ObjectOutput out) throws IOException {
+ out.writeObject(expr);
+ out.writeObject(prototype);
+ }
public Object createContext() {
return this.prototype.clone();
}
Modified: labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/base/mvel/MVELSalienceExpression.java
===================================================================
--- labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/base/mvel/MVELSalienceExpression.java 2008-03-20 18:57:07 UTC (rev 19163)
+++ labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/base/mvel/MVELSalienceExpression.java 2008-03-20 19:32:10 UTC (rev 19164)
@@ -1,6 +1,10 @@
package org.drools.base.mvel;
import java.io.Serializable;
+import java.io.Externalizable;
+import java.io.IOException;
+import java.io.ObjectOutput;
+import java.io.ObjectInput;
import org.drools.WorkingMemory;
import org.drools.spi.Salience;
@@ -10,19 +14,32 @@
public class MVELSalienceExpression
implements
Salience,
- Serializable {
+ Externalizable {
private static final long serialVersionUID = 400L;
- private final Serializable expr;
- private final DroolsMVELFactory factory;
+ private Serializable expr;
+ private DroolsMVELFactory factory;
+ public MVELSalienceExpression() {
+ }
+
public MVELSalienceExpression(final Serializable expr,
final DroolsMVELFactory factory) {
this.expr = expr;
this.factory = factory;
}
+ public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
+ expr = (Serializable)in.readObject();
+ factory = (DroolsMVELFactory)in.readObject();
+ }
+
+ public void writeExternal(ObjectOutput out) throws IOException {
+ out.writeObject(expr);
+ out.writeObject(factory);
+ }
+
public int getValue(final Tuple tuple,
final WorkingMemory workingMemory) {
this.factory.setContext( tuple,
Modified: labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/common/AbstractFactHandleFactory.java
===================================================================
--- labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/common/AbstractFactHandleFactory.java 2008-03-20 18:57:07 UTC (rev 19163)
+++ labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/common/AbstractFactHandleFactory.java 2008-03-20 19:32:10 UTC (rev 19164)
@@ -2,13 +2,13 @@
/*
* Copyright 2005 JBoss Inc
- *
+ *
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -23,12 +23,17 @@
import org.drools.spi.FactHandleFactory;
import org.drools.util.PrimitiveLongStack;
+import java.io.Externalizable;
+import java.io.ObjectInput;
+import java.io.IOException;
+import java.io.ObjectOutput;
+
public abstract class AbstractFactHandleFactory
implements
- FactHandleFactory {
+ FactHandleFactory, Externalizable {
/**
- *
+ *
*/
private static final long serialVersionUID = 400L;
@@ -45,9 +50,20 @@
this.counter = new AtomicLong(-1);
}
+
+ public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
+ id = (AtomicInteger) in.readObject();
+ counter = (AtomicLong) in.readObject();
+ }
+
+ public void writeExternal(ObjectOutput out) throws IOException {
+ out.writeObject(id);
+ out.writeObject(counter);
+ }
+
/* (non-Javadoc)
- * @see org.drools.reteoo.FactHandleFactory#newFactHandle()
- */
+ * @see org.drools.reteoo.FactHandleFactory#newFactHandle()
+ */
public final InternalFactHandle newFactHandle(final Object object,
final boolean isEvent,
final WorkingMemory workingMemory) {
@@ -59,7 +75,6 @@
// 0,
// workingMemory );
// }
-
return newFactHandle( this.id.incrementAndGet(),
object,
isEvent,
Modified: labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/common/AbstractRuleBase.java
===================================================================
--- labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/common/AbstractRuleBase.java 2008-03-20 18:57:07 UTC (rev 19163)
+++ labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/common/AbstractRuleBase.java 2008-03-20 19:32:10 UTC (rev 19164)
@@ -23,8 +23,6 @@
import java.io.InputStream;
import java.io.ObjectInput;
import java.io.ObjectOutput;
-import java.io.ObjectOutputStream;
-import java.io.Serializable;
import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
@@ -44,11 +42,9 @@
import org.drools.event.RuleBaseEventListener;
import org.drools.event.RuleBaseEventSupport;
import org.drools.objenesis.Objenesis;
-import org.drools.objenesis.ObjenesisStd;
import org.drools.process.core.Process;
import org.drools.rule.CompositePackageClassLoader;
import org.drools.rule.DialectDatas;
-import org.drools.rule.EntryPoint;
import org.drools.rule.ImportDeclaration;
import org.drools.rule.InvalidPatternException;
import org.drools.rule.MapBackedClassLoader;
@@ -58,6 +54,7 @@
import org.drools.spi.ExecutorServiceFactory;
import org.drools.spi.FactHandleFactory;
import org.drools.util.ObjectHashSet;
+import org.drools.util.ObjenesisFactory;
/**
* Implementation of <code>RuleBase</code>.
@@ -90,10 +87,10 @@
protected transient MapBackedClassLoader classLoader;
- private transient Objenesis objenesis;
-
+ private transient Objenesis objenesis;
+
/** The fact handle factory. */
- protected FactHandleFactory factHandleFactory;
+ protected FactHandleFactory factHandleFactory;
protected Map globals;
@@ -114,10 +111,10 @@
int lastAquiredLock;
// lock for entire rulebase, used for dynamic updates
- protected final ReentrantLock lock = new ReentrantLock();
+ protected ReentrantLock lock = new ReentrantLock();
- private int additionsSinceLock;
- private int removalsSinceLock;
+ private int additionsSinceLock;
+ private int removalsSinceLock;
private transient Map<Class< ? >, TypeDeclaration> classTypeDeclaration;
@@ -136,7 +133,7 @@
/**
* Construct.
*
- * @param rete
+ * @param id
* The rete network.
*/
public AbstractRuleBase(final String id,
@@ -176,31 +173,44 @@
* The Package uses PackageCompilationData to hold a reference to the generated bytecode. The generated bytecode must be restored before any Rules.
*
*/
- public void doWriteExternal(final ObjectOutput stream,
- final Object[] objects) throws IOException {
- stream.writeObject( this.pkgs );
- stream.writeObject( this.classLoader.getStore() );
+ public void writeExternal(final ObjectOutput out) throws IOException {
+ ObjectOutput droolsStream;
+ boolean isDrools = out instanceof DroolsObjectOutputStream;
+ ByteArrayOutputStream bytes;
+ if ( isDrools ) {
+ droolsStream = out;
+ bytes = null;
+ } else {
+ bytes = new ByteArrayOutputStream();
+ droolsStream = new DroolsObjectOutputStream( bytes );
+ }
+
+ droolsStream.writeObject( this.pkgs );
+ droolsStream.writeObject( this.config );
+ droolsStream.writeObject( this.classLoader.getStore() );
+
// Rules must be restored by an ObjectInputStream that can resolve using a given ClassLoader to handle seaprately by storing as
// a byte[]
- final ByteArrayOutputStream bos = new ByteArrayOutputStream();
- final ObjectOutput out = new ObjectOutputStream( bos );
- out.writeObject( this.id );
- out.writeObject( this.processes );
- out.writeObject( this.agendaGroupRuleTotals );
- out.writeObject( this.factHandleFactory );
- out.writeObject( this.globals );
- out.writeObject( this.config );
-
+ droolsStream.writeObject( this.id );
+ droolsStream.writeInt( workingMemoryCounter );
+ droolsStream.writeObject( this.processes );
+ droolsStream.writeObject( this.agendaGroupRuleTotals );
+ droolsStream.writeObject( this.factHandleFactory );
+ droolsStream.writeObject( this.globals );
+ droolsStream.writeObject( reloadPackageCompilationData );
+
this.eventSupport.removeEventListener( RuleBaseEventListener.class );
- out.writeObject( this.eventSupport );
-
- for ( int i = 0, length = objects.length; i < length; i++ ) {
- out.writeObject( objects[i] );
- }
-
- out.close();
- stream.writeObject( bos.toByteArray() );
+ droolsStream.writeObject( this.eventSupport );
+ droolsStream.writeObject( wms );
+ droolsStream.writeInt( lastAquiredLock );
+ droolsStream.writeObject( lock );
+ droolsStream.writeInt( additionsSinceLock );
+ droolsStream.writeInt( removalsSinceLock );
+ if ( !isDrools ) {
+ bytes.close();
+ out.writeObject( bytes.toByteArray() );
+ }
}
/**
@@ -209,73 +219,80 @@
* A custom ObjectInputStream, able to resolve classes against the bytecode in the PackageCompilationData, is used to restore the Rules.
*
*/
- public void doReadExternal(final ObjectInput stream,
- final Object[] objects) throws IOException,
- ClassNotFoundException {
- // PackageCompilationData must be restored before Rules as it has the ClassLoader needed to resolve the generated code references in Rules
- this.pkgs = (Map) stream.readObject();
- Map store = (Map) stream.readObject();
-
- if ( stream instanceof DroolsObjectInputStream ) {
- final DroolsObjectInputStream parentStream = (DroolsObjectInputStream) stream;
- parentStream.setRuleBase( this );
- this.packageClassLoader = new CompositePackageClassLoader( parentStream.getClassLoader() );
- this.classLoader = new MapBackedClassLoader( parentStream.getClassLoader(), store );
+ public void readExternal(final ObjectInput in) throws IOException,
+ ClassNotFoundException {
+ // PackageCompilationData must be restored before Rules as it has the ClassLoader needed to resolve the generated code references in Rules
+ DroolsObjectInput droolsStream = null;
+ boolean isDrools = in instanceof DroolsObjectInputStream;
+
+ if ( isDrools ) {
+ droolsStream = (DroolsObjectInput) in;
} else {
- this.packageClassLoader = new CompositePackageClassLoader( Thread.currentThread().getContextClassLoader() );
- this.classLoader = new MapBackedClassLoader( Thread.currentThread().getContextClassLoader(), store );
+ byte[] bytes = (byte[]) in.readObject();
+
+ droolsStream = new DroolsObjectInputStream( new ByteArrayInputStream( bytes ) );
}
+ this.pkgs = (Map) droolsStream.readObject();
+ this.config = (RuleBaseConfiguration) droolsStream.readObject();
+ Map store = (Map) droolsStream.readObject();
+ this.packageClassLoader = new CompositePackageClassLoader( droolsStream.getClassLoader() );
+ droolsStream.setClassLoader( packageClassLoader );
+ this.classLoader = new MapBackedClassLoader( this.packageClassLoader,
+ store );
this.packageClassLoader.addClassLoader( this.classLoader );
this.objenesis = createObjenesis();
- for ( final Iterator it = this.pkgs.values().iterator(); it.hasNext(); ) {
- this.packageClassLoader.addClassLoader( ((Package) it.next()).getDialectDatas().getClassLoader() );
+ for ( final Object object : this.pkgs.values() ) {
+ this.packageClassLoader.addClassLoader( ((Package) object).getDialectDatas().getClassLoader() );
}
+ // PackageCompilationData must be restored before Rules as it has the ClassLoader needed to resolve the generated code references in Rules
+ this.id = (String) droolsStream.readObject();
+ this.workingMemoryCounter = droolsStream.readInt();
- // Return the rules stored as a byte[]
- final byte[] bytes = (byte[]) stream.readObject();
+ this.config.setClassLoader( droolsStream.getClassLoader() );
- // Use a custom ObjectInputStream that can resolve against a given classLoader
- final DroolsObjectInputStream childStream = new DroolsObjectInputStream( new ByteArrayInputStream( bytes ),
- this.packageClassLoader );
- childStream.setRuleBase( this );
+ this.processes = (Map) droolsStream.readObject();
+ this.agendaGroupRuleTotals = (Map) droolsStream.readObject();
+ this.factHandleFactory = (FactHandleFactory) droolsStream.readObject();
+ this.globals = (Map) droolsStream.readObject();
+ this.reloadPackageCompilationData = (ReloadPackageCompilationData) droolsStream.readObject();
- this.id = (String) childStream.readObject();
- this.processes = (Map) childStream.readObject();
- this.agendaGroupRuleTotals = (Map) childStream.readObject();
- this.factHandleFactory = (FactHandleFactory) childStream.readObject();
- this.globals = (Map) childStream.readObject();
-
- this.config = (RuleBaseConfiguration) childStream.readObject();
- this.config.setClassLoader( childStream.getClassLoader() );
-
- this.eventSupport = (RuleBaseEventSupport) childStream.readObject();
+ this.eventSupport = (RuleBaseEventSupport) droolsStream.readObject();
this.eventSupport.setRuleBase( this );
-
this.statefulSessions = new ObjectHashSet();
- for ( int i = 0, length = objects.length; i < length; i++ ) {
- objects[i] = childStream.readObject();
+ wms = (InternalWorkingMemory[]) droolsStream.readObject();
+ lastAquiredLock = droolsStream.readInt();
+ lock = (ReentrantLock) droolsStream.readObject();
+ additionsSinceLock = droolsStream.readInt();
+ removalsSinceLock = droolsStream.readInt();
+
+ if ( !isDrools ) {
+ droolsStream.close();
}
- childStream.close();
-
+
this.populateTypeDeclarationMaps();
}
- /**
- * Creates Objenesis instance for the RuleBase.
- * @return a standart Objenesis instanse with caching turned on.
- */
- protected Objenesis createObjenesis() {
- return new ObjenesisStd( true );
- }
+ /**
+ * Creates Objenesis instance for the RuleBase.
+ * @return a standart Objenesis instanse with caching turned on.
+ */
+ protected Objenesis createObjenesis() {
+ if( this.config.isUseStaticObjenesis() ) {
+ return ObjenesisFactory.getStaticObjenesis();
+ } else {
+ return ObjenesisFactory.getDefaultObjenesis();
+ }
+ }
private void populateTypeDeclarationMaps() {
- this.classTypeDeclaration = new HashMap<Class<?>, TypeDeclaration>();
- for( Package pkg : this.pkgs.values() ) {
- for( TypeDeclaration type : pkg.getTypeDeclarations().values() ) {
- this.classTypeDeclaration.put( type.getTypeClass(), type );
+ this.classTypeDeclaration = new HashMap<Class< ? >, TypeDeclaration>();
+ for ( Package pkg : this.pkgs.values() ) {
+ for ( TypeDeclaration type : pkg.getTypeDeclarations().values() ) {
+ this.classTypeDeclaration.put( type.getTypeClass(),
+ type );
}
}
}
@@ -390,7 +407,7 @@
* network. Before update network each referenced <code>WorkingMemory</code>
* is locked.
*
- * @param pkg
+ * @param newPkg
* The package to add.
*/
public synchronized void addPackage(final Package newPkg) {
@@ -441,7 +458,7 @@
type );
}
}
-
+
final Rule[] rules = newPkg.getRules();
for ( int i = 0; i < rules.length; ++i ) {
@@ -507,15 +524,20 @@
pkg.addTypeDeclaration( type );
}
}
-
+
//Add rules into the RuleBase package
//as this is needed for individual rule removal later on
final Rule[] newRules = newPkg.getRules();
for ( int i = 0; i < newRules.length; i++ ) {
final Rule newRule = newRules[i];
- if ( pkg.getRule( newRule.getName() ) == null ) {
- pkg.addRule( newRule );
+
+ // remove the rule if it already exists
+ if ( pkg.getRule( newRule.getName() ) != null ) {
+ removeRule( pkg,
+ pkg.getRule( newRule.getName() ) );
}
+
+ pkg.addRule( newRule );
}
//and now the rule flows
@@ -534,7 +556,7 @@
}
this.reloadPackageCompilationData.addDialectDatas( pkg.getDialectDatas() );
}
-
+
public TypeDeclaration getTypeDeclaration(Class< ? > clazz) {
return this.classTypeDeclaration.get( clazz );
}
@@ -831,6 +853,15 @@
private static final long serialVersionUID = 1L;
private Set set;
+ public void readExternal(ObjectInput in) throws IOException,
+ ClassNotFoundException {
+ set = (Set) in.readObject();
+ }
+
+ public void writeExternal(ObjectOutput out) throws IOException {
+ out.writeObject( set );
+ }
+
public void addDialectDatas(final DialectDatas dialectDatas) {
if ( this.set == null ) {
this.set = new HashSet();
@@ -849,7 +880,7 @@
public static interface RuleBaseAction
extends
- Serializable {
+ Externalizable {
public void execute(InternalRuleBase ruleBase);
}
}
Modified: labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/common/AbstractWorkingMemory.java
===================================================================
--- labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/common/AbstractWorkingMemory.java 2008-03-20 18:57:07 UTC (rev 19163)
+++ labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/common/AbstractWorkingMemory.java 2008-03-20 19:32:10 UTC (rev 19164)
@@ -18,7 +18,10 @@
import java.beans.PropertyChangeEvent;
import java.beans.PropertyChangeListener;
+import java.io.Externalizable;
import java.io.IOException;
+import java.io.ObjectInput;
+import java.io.ObjectOutput;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.util.ArrayList;
@@ -82,7 +85,7 @@
/**
* Implementation of <code>WorkingMemory</code>.
- *
+ *
* @author <a href="mailto:bob at werken.com">bob mcwhirter </a>
* @author <a href="mailto:mark.proctor at jboss.com">Mark Proctor</a>
* @author <a href="mailto:simon at redhillconsulting.com.au">Simon Harris </a>
@@ -91,7 +94,7 @@
implements
InternalWorkingMemoryActions,
EventSupport,
- PropertyChangeListener {
+ PropertyChangeListener, Externalizable {
// ------------------------------------------------------------
// Constants
// ------------------------------------------------------------
@@ -104,12 +107,12 @@
protected long id;
/** The arguments used when adding/removing a property change listener. */
- protected final Object[] addRemovePropertyChangeListenerArgs = new Object[]{this};
+ protected Object[] addRemovePropertyChangeListenerArgs = new Object[]{this};
/** The actual memory for the <code>JoinNode</code>s. */
- protected final NodeMemories nodeMemories;
+ protected NodeMemories nodeMemories;
- protected final ObjectStore objectStore;
+ protected ObjectStore objectStore;
protected Map queryResults = Collections.EMPTY_MAP;
@@ -128,30 +131,29 @@
/** The <code>RuleBase</code> with which this memory is associated. */
protected transient InternalRuleBase ruleBase;
- protected final FactHandleFactory handleFactory;
+ protected FactHandleFactory handleFactory;
- protected final TruthMaintenanceSystem tms;
+ protected TruthMaintenanceSystem tms;
/** Rule-firing agenda. */
protected DefaultAgenda agenda;
- protected final Queue<WorkingMemoryAction> actionQueue = new LinkedList<WorkingMemoryAction>();
+ protected Queue<WorkingMemoryAction> actionQueue = new LinkedList<WorkingMemoryAction>();
- protected boolean evaluatingActionQueue;
+ protected boolean evaluatingActionQueue;
- protected final ReentrantLock lock = new ReentrantLock();
+ protected ReentrantLock lock = new ReentrantLock();
- protected final boolean discardOnLogicalOverride;
+ protected boolean discardOnLogicalOverride;
/**
* This must be thread safe as it is incremented and read via different EntryPoints
*/
protected AtomicLong propagationIdCounter;
- private final boolean maintainTms;
+ private boolean maintainTms;
+ private boolean sequential;
- private final boolean sequential;
-
private List liaPropagations = Collections.EMPTY_LIST;
/** Flag to determine if a rule is currently being fired. */
@@ -179,10 +181,12 @@
// ------------------------------------------------------------
// Constructors
// ------------------------------------------------------------
+ public AbstractWorkingMemory() {
+ }
/**
* Construct.
- *
+ *
* @param ruleBase
* The backing rule-base.
*/
@@ -212,7 +216,7 @@
this.lock );
// Only takes effect if are using idententity behaviour for assert
- if ( conf.getLogicalOverride() == LogicalOverride.DISCARD ) {
+ if ( LogicalOverride.DISCARD.equals(conf.getLogicalOverride()) ) {
this.discardOnLogicalOverride = true;
} else {
this.discardOnLogicalOverride = false;
@@ -224,11 +228,86 @@
this.entryPoints = new ConcurrentHashMap();
this.entryPoints.put( "DEFAULT",
this );
-
+
this.entryPoint = EntryPoint.DEFAULT;
initTransient();
}
+ public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
+ id = in.readLong();
+ evaluatingActionQueue = in.readBoolean();
+ discardOnLogicalOverride = in.readBoolean();
+ propagationIdCounter = (AtomicLong) in.readObject();
+ maintainTms = in.readBoolean();
+ sequential = in.readBoolean();
+ firing = in.readBoolean();
+ halt = in.readBoolean();
+ processCounter = in.readInt();
+ addRemovePropertyChangeListenerArgs = (Object[])in.readObject();
+ nodeMemories = (NodeMemories)in.readObject();
+ objectStore = (ObjectStore)in.readObject();
+ queryResults = (Map)in.readObject();
+ globalResolver = (GlobalResolver)in.readObject();
+ workingMemoryEventSupport = (WorkingMemoryEventSupport)in.readObject();
+ agendaEventSupport = (AgendaEventSupport)in.readObject();
+ workflowEventSupport = (RuleFlowEventSupport)in.readObject();
+ __ruleBaseEventListeners = (List)in.readObject();
+ ruleBase = (InternalRuleBase)in.readObject();
+ handleFactory = (FactHandleFactory)in.readObject();
+ tms = (TruthMaintenanceSystem)in.readObject();
+ agenda = (DefaultAgenda)in.readObject();
+ lock = (ReentrantLock)in.readObject();
+ actionQueue = (Queue<WorkingMemoryAction>)in.readObject();
+ liaPropagations = (List)in.readObject();
+ processInstances = (Map)in.readObject();
+ workItemManager = (WorkItemManager)in.readObject();
+ processInstanceFactories = (Map<String, ProcessInstanceFactory>)in.readObject();
+ timeMachine = (TimeMachine)in.readObject();
+ entryPoint = (EntryPoint)in.readObject();
+ entryPointNode = (EntryPointNode)in.readObject();
+ entryPoints = (Map<String, WorkingMemoryEntryPoint>)in.readObject();
+ initTransient();
+ }
+
+ public void writeExternal(ObjectOutput out) throws IOException {
+ out.writeLong(id);
+ out.writeBoolean(evaluatingActionQueue);
+ out.writeBoolean(discardOnLogicalOverride);
+ out.writeObject(propagationIdCounter);
+ out.writeBoolean(maintainTms);
+ out.writeBoolean(sequential);
+ out.writeBoolean(firing);
+ out.writeBoolean(halt);
+ out.writeInt(processCounter);
+ out.writeObject(addRemovePropertyChangeListenerArgs);
+ out.writeObject(nodeMemories);
+ out.writeObject(objectStore);
+ out.writeObject(queryResults);
+ out.writeObject(globalResolver);
+ out.writeObject(workingMemoryEventSupport);
+ out.writeObject(agendaEventSupport);
+ out.writeObject(workflowEventSupport);
+ out.writeObject(__ruleBaseEventListeners);
+ out.writeObject(ruleBase);
+ out.writeObject(handleFactory);
+ out.writeObject(tms);
+ out.writeObject(agenda);
+ out.writeObject(lock);
+ out.writeObject(actionQueue);
+ out.writeObject(liaPropagations);
+ out.writeObject(processInstances);
+ out.writeObject(workItemManager);
+ out.writeObject(processInstanceFactories);
+ out.writeObject(timeMachine);
+ out.writeObject(entryPoint);
+ out.writeObject(entryPointNode);
+ out.writeObject(entryPoints);
+ }
+
+ // ------------------------------------------------------------
+ // Instance methods
+ // ------------------------------------------------------------
+
public void setRuleBase(final InternalRuleBase ruleBase) {
this.ruleBase = ruleBase;
this.nodeMemories.setRuleBaseReference( this.ruleBase );
@@ -518,13 +597,13 @@
* Returns the fact Object for the given <code>FactHandle</code>. It
* actually attemps to return the value from the handle, before retrieving
* it from objects map.
- *
+ *
* @see WorkingMemory
- *
+ *
* @param handle
* The <code>FactHandle</code> reference for the
* <code>Object</code> lookup
- *
+ *
*/
public Object getObject(final FactHandle handle) {
return this.objectStore.getObjectForHandle( (InternalFactHandle) handle );
@@ -613,7 +692,7 @@
* @see WorkingMemory
*/
public FactHandle insertLogical(final Object object) throws FactException {
- return insert( object, //Not-Dynamic
+ return insert( object, //Not-Dynamic
false,
true,
null,
@@ -759,7 +838,7 @@
key.setStatus( EqualityKey.STATED );
handle = key.getFactHandle();
- if ( this.ruleBase.getConfiguration().getAssertBehaviour() == AssertBehaviour.IDENTITY ) {
+ if ( AssertBehaviour.IDENTITY.equals(this.ruleBase.getConfiguration().getAssertBehaviour()) ) {
// as assertMap may be using an "identity"
// equality comparator,
// we need to remove the handle from the map,
@@ -1158,6 +1237,12 @@
null );
}
+ /**
+ * modify is implemented as half way retract / assert due to the truth
+ * maintenance issues.
+ *
+ * @see WorkingMemory
+ */
public void update(final FactHandle factHandle,
final Object object,
final Rule rule,
@@ -1203,7 +1288,7 @@
typeConf,
this );
- if ( (originalObject != object) || (this.ruleBase.getConfiguration().getAssertBehaviour() != AssertBehaviour.IDENTITY) ) {
+ if ( originalObject != object || !AssertBehaviour.IDENTITY.equals(this.ruleBase.getConfiguration().getAssertBehaviour()) ) {
this.objectStore.removeHandle( handle );
// set anyway, so that it updates the hashCodes
@@ -1264,7 +1349,7 @@
evaluatingActionQueue = true;
WorkingMemoryAction action = null;
- while ( (action = actionQueue.poll()) != null ) {
+ while ( ( action = actionQueue.poll() ) != null ) {
action.execute( this );
}
evaluatingActionQueue = false;
@@ -1288,10 +1373,10 @@
/**
* Retrieve the <code>JoinMemory</code> for a particular
* <code>JoinNode</code>.
- *
+ *
* @param node
* The <code>JoinNode</code> key.
- *
+ *
* @return The node's memory.
*/
public Object getNodeMemory(final NodeMemory node) {
@@ -1317,7 +1402,7 @@
/**
* Sets the AsyncExceptionHandler to handle exceptions thrown by the Agenda
* Scheduler used for duration rules.
- *
+ *
* @param handler
*/
public void setAsyncExceptionHandler(final AsyncExceptionHandler handler) {
@@ -1465,7 +1550,7 @@
/**
* The time machine defaults to returning the current time when asked.
* However, you can use tell it to go back in time.
- *
+ *
* @param timeMachine
*/
public void setTimeMachine(TimeMachine timeMachine) {
Modified: labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/common/AgendaItem.java
===================================================================
--- labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/common/AgendaItem.java 2008-03-20 18:57:07 UTC (rev 19163)
+++ labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/common/AgendaItem.java 2008-03-20 19:32:10 UTC (rev 19164)
@@ -2,13 +2,13 @@
/*
* Copyright 2005 JBoss Inc
- *
+ *
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -16,7 +16,10 @@
* limitations under the License.
*/
-import java.io.Serializable;
+import java.io.Externalizable;
+import java.io.ObjectOutput;
+import java.io.IOException;
+import java.io.ObjectInput;
import org.drools.rule.GroupElement;
import org.drools.rule.Rule;
@@ -30,7 +33,7 @@
/**
* Item entry in the <code>Agenda</code>.
- *
+ *
* @author <a href="mailto:mark.proctor at jboss.com">Mark Proctor</a>
* @author <a href="mailto:bob at werken.com">Bob McWhirter</a>
*/
@@ -38,36 +41,36 @@
implements
Activation,
Queueable,
- Serializable {
+ Externalizable {
// ------------------------------------------------------------
// Instance members
// ------------------------------------------------------------
/**
- *
+ *
*/
private static final long serialVersionUID = 400L;
/** The tuple. */
- private final Tuple tuple;
+ private Tuple tuple;
/** The rule. */
- private final Rule rule;
+ private Rule rule;
/** The salience */
- private final int salience;
+ private int salience;
/** Used for sequential mode */
private int sequenence;
/** The subrule */
- private final GroupElement subrule;
+ private GroupElement subrule;
/** The propagation context */
- private final PropagationContext context;
+ private PropagationContext context;
/** The activation number */
- private final long activationNumber;
+ private long activationNumber;
/** A reference to the PriorityQeue the item is on */
private Queue queue;
@@ -87,10 +90,13 @@
// ------------------------------------------------------------
// Constructors
// ------------------------------------------------------------
+ public AgendaItem() {
+ }
+
/**
* Construct.
- *
+ *
* @param tuple
* The tuple.
* @param rule
@@ -113,13 +119,47 @@
// ------------------------------------------------------------
// Instance methods
// ------------------------------------------------------------
+ public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
+ tuple = (Tuple)in.readObject();
+ rule = (Rule)in.readObject();
+ salience = in.readInt();
+ sequenence = in.readInt();
+ subrule = (GroupElement)in.readObject();
+ context = (PropagationContext)in.readObject();
+ activationNumber = in.readLong();
+ queue = (Queue)in.readObject();
+ index = in.readInt();
+ justified = (LinkedList)in.readObject();
+ activated = in.readBoolean();
+ agendaGroup = (InternalAgendaGroup)in.readObject();
+ activationGroupNode = (ActivationGroupNode)in.readObject();
+ ruleFlowGroupNode = (RuleFlowGroupNode)in.readObject();
+ }
+
+ public void writeExternal(ObjectOutput out) throws IOException {
+ out.writeObject(tuple);
+ out.writeObject(rule);
+ out.writeInt(salience);
+ out.writeInt(sequenence);
+ out.writeObject(subrule);
+ out.writeObject(context);
+ out.writeLong(activationNumber);
+ out.writeObject(queue);
+ out.writeInt(index);
+ out.writeObject(justified);
+ out.writeBoolean(activated);
+ out.writeObject(agendaGroup);
+ out.writeObject(activationGroupNode);
+ out.writeObject(ruleFlowGroupNode);
+ }
+
public PropagationContext getPropagationContext() {
return this.context;
}
/**
* Retrieve the rule.
- *
+ *
* @return The rule.
*/
public Rule getRule() {
@@ -128,7 +168,7 @@
/**
* Retrieve the tuple.
- *
+ *
* @return The tuple.
*/
public Tuple getTuple() {
@@ -149,7 +189,7 @@
/*
* (non-Javadoc)
- *
+ *
* @see org.drools.spi.Activation#getActivationNumber()
*/
public long getActivationNumber() {
@@ -186,7 +226,7 @@
/*
* (non-Javadoc)
- *
+ *
* @see java.lang.Object#equals(java.lang.Object)
*/
public boolean equals(final Object object) {
Modified: labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/common/ArrayAgendaGroup.java
===================================================================
--- labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/common/ArrayAgendaGroup.java 2008-03-20 18:57:07 UTC (rev 19163)
+++ labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/common/ArrayAgendaGroup.java 2008-03-20 19:32:10 UTC (rev 19164)
@@ -2,13 +2,13 @@
/*
* Copyright 2005 JBoss Inc
- *
+ *
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -28,14 +28,18 @@
import org.drools.util.Queueable;
import org.drools.util.LinkedList.LinkedListIterator;
+import java.io.IOException;
+import java.io.ObjectOutput;
+import java.io.ObjectInput;
+
/**
* <code>AgendaGroup</code> implementation that uses a <code>PriorityQueue</code> to prioritise the evaluation of added
- * <code>ActivationQueue</code>s. The <code>AgendaGroup</code> also maintains a <code>Map</code> of <code>ActivationQueues</code>
+ * <code>ActivationQueue</code>s. The <code>AgendaGroup</code> also maintains a <code>Map</code> of <code>ActivationQueues</code>
* for requested salience values.
- *
+ *
* @see PriorityQueue
* @see ActivationQueue
- *
+ *
* @author <a href="mailto:mark.proctor at jboss.com">Mark Proctor</a>
* @author <a href="mailto:bob at werken.com">Bob McWhirter</a>
*
@@ -46,7 +50,7 @@
private static final long serialVersionUID = 400L;
- private final String name;
+ private String name;
/** Items in the agenda. */
private LinkedList[] array;
@@ -59,9 +63,12 @@
private int lastIndex;
+ public ArrayAgendaGroup() {
+
+ }
/**
* Construct an <code>AgendaGroup</code> with the given name.
- *
+ *
* @param name
* The <AgendaGroup> name.
*/
@@ -70,17 +77,35 @@
final InternalRuleBase ruleBase) {
this.name = name;
Integer integer = (Integer) ruleBase.getAgendaGroupRuleTotals().get( name );
-
+
if ( integer == null ) {
this.array = new LinkedList[0];
} else {
- this.array = new LinkedList[integer.intValue()];
+ this.array = new LinkedList[integer.intValue()];
}
- this.index = this.array.length-1;
- this.lastIndex = 0;
+ this.index = this.array.length-1;
+ this.lastIndex = 0;
}
+ public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
+ name = (String)in.readObject();
+ array = (LinkedList[])in.readObject();
+ active = in.readBoolean();
+ size = in.readInt();
+ index = in.readInt();
+ lastIndex = in.readInt();
+ }
+
+ public void writeExternal(ObjectOutput out) throws IOException {
+ out.writeObject(name);
+ out.writeObject(array);
+ out.writeBoolean(active);
+ out.writeInt(size);
+ out.writeInt(index);
+ out.writeInt(lastIndex);
+ }
+
/* (non-Javadoc)
* @see org.drools.spi.AgendaGroup#getName()
*/
@@ -103,28 +128,28 @@
AgendaItem item = (AgendaItem) activation;
this.size++;
int seq = item.getSequenence();
-
+
if ( seq < this.index ) {
this.index = seq;
}
-
+
if ( seq > this.lastIndex ) {
this.lastIndex = seq;
}
-
+
LinkedList list = this.array[seq];
if ( list == null ) {
list = new LinkedList();
this.array[item.getSequenence()] = list;
}
-
+
list.add( new LinkedListEntry( activation ) );
}
public Activation getNext() {
Activation activation = null;
while ( this.index <= lastIndex ) {
- LinkedList list = this.array[this.index];
+ LinkedList list = this.array[this.index];
if ( list != null ) {
activation = (Activation) ((LinkedListEntry)list.removeFirst()).getObject();
if ( list.isEmpty()) {
@@ -149,7 +174,7 @@
/**
* Iterates a PriorityQueue removing empty entries until it finds a populated entry and return true,
* otherwise it returns false;
- *
+ *
* @param priorityQueue
* @return
*/
@@ -170,7 +195,7 @@
activation = ( Activation ) it.next();
}
}
-
+
}
return activations;
}
Modified: labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/common/BaseNode.java
===================================================================
--- labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/common/BaseNode.java 2008-03-20 18:57:07 UTC (rev 19163)
+++ labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/common/BaseNode.java 2008-03-20 19:32:10 UTC (rev 19164)
@@ -1,12 +1,12 @@
/*
* Copyright 2005 JBoss Inc
- *
+ *
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -19,9 +19,14 @@
import org.drools.reteoo.ReteooBuilder;
import org.drools.reteoo.RuleRemovalContext;
+import java.io.Externalizable;
+import java.io.ObjectInput;
+import java.io.IOException;
+import java.io.ObjectOutput;
+
/**
* The base class for all Rete nodes.
- *
+ *
* @author <a href="mailto:mark.proctor at jboss.com">Mark Proctor</a>
* @author <a href="mailto:bob at werken.com">Bob McWhirter</a>
*
@@ -29,11 +34,15 @@
public abstract class BaseNode
implements
NetworkNode {
- protected final int id;
+ protected int id;
+ public BaseNode() {
+
+ }
+
/**
* All nodes have a unique id, set in the constructor.
- *
+ *
* @param id
* The unique id
*/
@@ -42,6 +51,14 @@
this.id = id;
}
+ public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
+ id = in.readInt();
+ }
+
+ public void writeExternal(ObjectOutput out) throws IOException {
+ out.writeInt(id);
+ }
+
/* (non-Javadoc)
* @see org.drools.spi.ReteooNode#getId()
*/
@@ -55,7 +72,14 @@
public abstract void attach();
public abstract void attach(InternalWorkingMemory[] workingMemories);
-
+
+ /**
+ * A method that is called for all nodes whose network bellow them
+ * changed, after the change is complete, providing them with an oportunity
+ * for state update
+ */
+ public abstract void networkUpdated();
+
public void remove(RuleRemovalContext context,
ReteooBuilder builder,
BaseNode node,
@@ -85,14 +109,14 @@
*/
public abstract boolean isInUse();
- /**
- * The hashCode return is simply the unique id of the node. It is expected that base classes will also implement equals(Object object).
+ /**
+ * The hashCode return is simply the unique id of the node. It is expected that base classes will also implement equals(Object object).
*/
public int hashCode() {
return this.id;
}
public String toString() {
- return "[" + this.getClass().getName() + "(" + this.id + ")]";
+ return "[" + this.getClass().getSimpleName() + "(" + this.id + ")]";
}
}
Modified: labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/common/BetaConstraints.java
===================================================================
--- labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/common/BetaConstraints.java 2008-03-20 18:57:07 UTC (rev 19163)
+++ labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/common/BetaConstraints.java 2008-03-20 19:32:10 UTC (rev 19164)
@@ -1,16 +1,16 @@
package org.drools.common;
-import java.io.Serializable;
-
import org.drools.RuleBaseConfiguration;
import org.drools.reteoo.BetaMemory;
import org.drools.reteoo.ReteTuple;
import org.drools.rule.ContextEntry;
import org.drools.util.LinkedList;
+import java.io.Externalizable;
+
public interface BetaConstraints
extends
- Serializable {
+ Externalizable {
public ContextEntry[] createContext();
Modified: labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/common/BinaryHeapQueueAgendaGroup.java
===================================================================
--- labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/common/BinaryHeapQueueAgendaGroup.java 2008-03-20 18:57:07 UTC (rev 19163)
+++ labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/common/BinaryHeapQueueAgendaGroup.java 2008-03-20 19:32:10 UTC (rev 19164)
@@ -2,13 +2,13 @@
/*
* Copyright 2005 JBoss Inc
- *
+ *
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -23,14 +23,18 @@
import org.drools.util.BinaryHeapQueue;
import org.drools.util.Queueable;
+import java.io.IOException;
+import java.io.ObjectInput;
+import java.io.ObjectOutput;
+
/**
* <code>AgendaGroup</code> implementation that uses a <code>PriorityQueue</code> to prioritise the evaluation of added
- * <code>ActivationQueue</code>s. The <code>AgendaGroup</code> also maintains a <code>Map</code> of <code>ActivationQueues</code>
+ * <code>ActivationQueue</code>s. The <code>AgendaGroup</code> also maintains a <code>Map</code> of <code>ActivationQueues</code>
* for requested salience values.
- *
+ *
* @see PriorityQueue
* @see ActivationQueue
- *
+ *
* @author <a href="mailto:mark.proctor at jboss.com">Mark Proctor</a>
* @author <a href="mailto:bob at werken.com">Bob McWhirter</a>
*
@@ -41,26 +45,41 @@
private static final long serialVersionUID = 400L;
- private final String name;
+ private String name;
/** Items in the agenda. */
- private final BinaryHeapQueue queue;
+ private BinaryHeapQueue queue;
private boolean active;
/**
* Construct an <code>AgendaGroup</code> with the given name.
- *
+ *
* @param name
* The <AgendaGroup> name.
*/
-
-
+ public BinaryHeapQueueAgendaGroup() {
+
+ }
+
+
public BinaryHeapQueueAgendaGroup(final String name, final InternalRuleBase ruleBase) {
this.name = name;
this.queue = new BinaryHeapQueue( ruleBase.getConfiguration().getConflictResolver() );
- }
+ }
+ public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
+ name = (String)in.readObject();
+ queue = (BinaryHeapQueue)in.readObject();
+ active = in.readBoolean();
+ }
+
+ public void writeExternal(ObjectOutput out) throws IOException {
+ out.writeObject(name);
+ out.writeObject(queue);
+ out.writeBoolean(active);
+ }
+
/* (non-Javadoc)
* @see org.drools.spi.AgendaGroup#getName()
*/
@@ -98,7 +117,7 @@
/**
* Iterates a PriorityQueue removing empty entries until it finds a populated entry and return true,
* otherwise it returns false;
- *
+ *
* @param priorityQueue
* @return
*/
Modified: labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/common/ConcurrentNodeMemories.java
===================================================================
--- labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/common/ConcurrentNodeMemories.java 2008-03-20 18:57:07 UTC (rev 19163)
+++ labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/common/ConcurrentNodeMemories.java 2008-03-20 19:32:10 UTC (rev 19164)
@@ -1,12 +1,12 @@
/*
* Copyright 2008 JBoss Inc
- *
+ *
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -21,10 +21,13 @@
import java.util.concurrent.atomic.AtomicReferenceArray;
import java.util.concurrent.locks.Lock;
import java.util.concurrent.locks.ReentrantLock;
+import java.io.IOException;
+import java.io.ObjectInput;
+import java.io.ObjectOutput;
/**
* A concurrent implementation for the node memories interface
- *
+ *
* @author etirelli
*/
public class ConcurrentNodeMemories
@@ -32,17 +35,32 @@
NodeMemories {
private static final long serialVersionUID = -2032997426288974117L;
-
+
private AtomicReferenceArray<Object> memories;
private Lock lock;
- private transient InternalRuleBase rulebase;
+ private InternalRuleBase rulebase;
+ public ConcurrentNodeMemories() {
+
+ }
+
public ConcurrentNodeMemories(InternalRuleBase rulebase) {
this.rulebase = rulebase;
this.memories = new AtomicReferenceArray<Object>( this.rulebase.getNodeCount() );
this.lock = new ReentrantLock();
}
+ public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
+ lock = (Lock)in.readObject();
+ rulebase = (InternalRuleBase)in.readObject();
+ memories = (AtomicReferenceArray<Object>)in.readObject();
+ }
+
+ public void writeExternal(ObjectOutput out) throws IOException {
+ out.writeObject(lock);
+ out.writeObject(rulebase);
+ out.writeObject(memories);
+ }
/**
* @inheritDoc
*
Modified: labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/common/DefaultAgenda.java
===================================================================
--- labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/common/DefaultAgenda.java 2008-03-20 18:57:07 UTC (rev 19163)
+++ labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/common/DefaultAgenda.java 2008-03-20 19:32:10 UTC (rev 19164)
@@ -2,13 +2,13 @@
/*
* Copyright 2005 JBoss Inc
- *
+ *
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -17,6 +17,10 @@
*/
import java.io.Serializable;
+import java.io.Externalizable;
+import java.io.ObjectInput;
+import java.io.IOException;
+import java.io.ObjectOutput;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
@@ -39,56 +43,55 @@
import org.drools.spi.KnowledgeHelper;
import org.drools.spi.RuleFlowGroup;
import org.drools.util.LinkedListNode;
-import org.drools.util.Queueable;
/**
* Rule-firing Agenda.
- *
+ *
* <p>
* Since many rules may be matched by a single assertObject(...) all scheduled
* actions are placed into the <code>Agenda</code>.
* </p>
- *
+ *
* <p>
* While processing a scheduled action, it may update or retract objects in
* other scheduled actions, which must then be removed from the agenda.
* Non-invalidated actions are left on the agenda, and are executed in turn.
* </p>
- *
+ *
* @author <a href="mailto:bob at eng.werken.com">bob mcwhirter </a>
* @author <a href="mailto:simon at redhillconsulting.com.au">Simon Harris </a>
*/
public class DefaultAgenda
implements
- Serializable,
+ Externalizable,
InternalAgenda {
// ------------------------------------------------------------
// Instance members
// ------------------------------------------------------------
/**
- *
+ *
*/
private static final long serialVersionUID = 400L;
/** Working memory of this Agenda. */
- private final InternalWorkingMemory workingMemory;
+ private InternalWorkingMemory workingMemory;
private org.drools.util.LinkedList scheduledActivations;
/** Items time-delayed. */
- private final Map agendaGroups;
+ private Map agendaGroups;
- private final Map activationGroups;
+ private Map activationGroups;
- private final Map ruleFlowGroups;
+ private Map ruleFlowGroups;
- private final LinkedList focusStack;
+ private LinkedList focusStack;
private AgendaGroup currentModule;
- private final AgendaGroup main;
+ private AgendaGroup main;
private AgendaGroupFactory agendaGroupFactory;
@@ -97,16 +100,18 @@
public int activeActivations;
public int dormantActivations;
-
+
private ConsequenceExceptionHandler consequenceExceptionHandler;
// ------------------------------------------------------------
// Constructors
// ------------------------------------------------------------
+ public DefaultAgenda() {
+ }
/**
* Construct.
- *
+ *
* @param workingMemory
* The <code>WorkingMemory</code> of this agenda.
* @param conflictResolver
@@ -134,11 +139,42 @@
this.main );
this.focusStack.add( this.main );
-
+
this.consequenceExceptionHandler = ((InternalRuleBase) workingMemory.getRuleBase()).getConfiguration().getConsequenceExceptionHandler();
}
+ public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
+ workingMemory = (InternalWorkingMemory)in.readObject();
+ scheduledActivations = (org.drools.util.LinkedList)in.readObject();
+ agendaGroups = (Map)in.readObject();
+ activationGroups = (Map)in.readObject();
+ ruleFlowGroups = (Map)in.readObject();
+ focusStack = (LinkedList)in.readObject();
+ currentModule = (AgendaGroup)in.readObject();
+ main = (AgendaGroup)in.readObject();
+ agendaGroupFactory = (AgendaGroupFactory)in.readObject();
+ knowledgeHelper = (KnowledgeHelper)in.readObject();
+ activeActivations = in.readInt();
+ dormantActivations = in.readInt();
+ consequenceExceptionHandler = (ConsequenceExceptionHandler)in.readObject();
+ }
+
+ public void writeExternal(ObjectOutput out) throws IOException {
+ out.writeObject(workingMemory);
+ out.writeObject(scheduledActivations);
+ out.writeObject(agendaGroups);
+ out.writeObject(activationGroups);
+ out.writeObject(ruleFlowGroups);
+ out.writeObject(focusStack);
+ out.writeObject(currentModule);
+ out.writeObject(main);
+ out.writeObject(agendaGroupFactory);
+ out.writeObject(knowledgeHelper);
+ out.writeInt(activeActivations);
+ out.writeInt(dormantActivations);
+ out.writeObject(consequenceExceptionHandler);
+ }
/* (non-Javadoc)
* @see org.drools.common.AgendaI#getWorkingMemory()
*/
@@ -148,7 +184,7 @@
/**
* Schedule an agenda item for delayed firing.
- *
+ *
* @param item
* The item to schedule.
*/
@@ -215,7 +251,7 @@
final boolean empty = agendaGroup.isEmpty();
- // No populated queus found so pop the focusStack and repeat
+ // No populated queus found so pop the focusStack and repeat
if ( empty && (this.focusStack.size() > 1) ) {
agendaGroup.setActive( false );
this.focusStack.removeLast();
@@ -368,7 +404,7 @@
final EventSupport eventsupport = (EventSupport) this.workingMemory;
if ( this.scheduledActivations != null && !this.scheduledActivations.isEmpty() ) {
for ( ScheduledAgendaItem item = (ScheduledAgendaItem) this.scheduledActivations.removeFirst(); item != null; item = (ScheduledAgendaItem) this.scheduledActivations.removeFirst() ) {
- item.cancel();
+ item.cancel();
eventsupport.getAgendaEventSupport().fireActivationCancelled( item,
this.workingMemory );
}
@@ -452,48 +488,48 @@
}
activationGroup.clear();
}
-
+
public void clearRuleFlowGroup(final String name) {
final RuleFlowGroup ruleFlowGrlup = (RuleFlowGroup) this.ruleFlowGroups.get( name );
if ( ruleFlowGrlup != null ) {
clearRuleFlowGroup( ruleFlowGrlup );
}
- }
-
+ }
+
public void clearRuleFlowGroup(final RuleFlowGroup ruleFlowGroup) {
final EventSupport eventsupport = (EventSupport) this.workingMemory;
-
+
for ( Iterator it = ruleFlowGroup.iterator(); it.hasNext(); ) {
RuleFlowGroupNode node = ( RuleFlowGroupNode ) it.next();
- AgendaItem item = ( AgendaItem ) node.getActivation();
+ AgendaItem item = ( AgendaItem ) node.getActivation();
if ( item != null ) {
item.setActivated( false );
item.remove();
-
+
if ( item.getActivationGroupNode() != null ) {
item.getActivationGroupNode().getActivationGroup().removeActivation( item );
- }
+ }
}
-
-
-
+
+
+
eventsupport.getAgendaEventSupport().fireActivationCancelled( item,
- this.workingMemory );
+ this.workingMemory );
}
-
- ((InternalRuleFlowGroup) ruleFlowGroup).clear();
-
+
+ ((InternalRuleFlowGroup) ruleFlowGroup).clear();
+
if ( ruleFlowGroup.isActive() && ruleFlowGroup.isAutoDeactivate() ) {
// deactivate callback
WorkingMemoryAction action = new DeactivateCallback( (InternalRuleFlowGroup) ruleFlowGroup );
this.workingMemory.queueWorkingMemoryAction( action );
- }
- }
+ }
+ }
/**
* Fire the next scheduled <code>Agenda</code> item.
- *
+ *
* @throws ConsequenceException
* If an error occurs while firing an agenda item.
*/
@@ -519,10 +555,10 @@
/**
* Fire this item.
- *
+ *
* @param workingMemory
* The working memory context.
- *
+ *
* @throws ConsequenceException
* If an error occurs while attempting to fire the consequence.
*/
Modified: labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/common/DefaultBetaConstraints.java
===================================================================
--- labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/common/DefaultBetaConstraints.java 2008-03-20 18:57:07 UTC (rev 19163)
+++ labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/common/DefaultBetaConstraints.java 2008-03-20 19:32:10 UTC (rev 19164)
@@ -2,13 +2,13 @@
/*
* Copyright 2005 JBoss Inc
- *
+ *
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -16,10 +16,6 @@
* limitations under the License.
*/
-import java.io.Serializable;
-import java.util.ArrayList;
-import java.util.List;
-
import org.drools.RuleBaseConfiguration;
import org.drools.base.evaluators.Operator;
import org.drools.reteoo.BetaMemory;
@@ -30,6 +26,7 @@
import org.drools.rule.VariableConstraint;
import org.drools.spi.BetaNodeFieldConstraint;
import org.drools.spi.Constraint;
+import org.drools.util.AbstractHashTable.FieldIndex;
import org.drools.util.FactHandleIndexHashTable;
import org.drools.util.FactHashTable;
import org.drools.util.FactList;
@@ -37,22 +34,29 @@
import org.drools.util.LinkedListEntry;
import org.drools.util.TupleHashTable;
import org.drools.util.TupleIndexHashTable;
-import org.drools.util.AbstractHashTable.FieldIndex;
+import java.io.IOException;
+import java.io.ObjectInput;
+import java.io.ObjectOutput;
+import java.util.ArrayList;
+import java.util.List;
+
public class DefaultBetaConstraints
implements
- Serializable,
BetaConstraints {
/**
- *
+ *
*/
private static final long serialVersionUID = 400L;
- private final LinkedList constraints;
+ private LinkedList constraints;
private int indexed;
+ public DefaultBetaConstraints() {
+
+ }
public DefaultBetaConstraints(final BetaNodeFieldConstraint[] constraints,
final RuleBaseConfiguration conf) {
this( constraints,
@@ -90,6 +94,16 @@
}
+ public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
+ constraints = (LinkedList)in.readObject();
+ indexed = in.readInt();
+ }
+
+ public void writeExternal(ObjectOutput out) throws IOException {
+ out.writeObject(constraints);
+ out.writeInt(indexed);
+ }
+
public ContextEntry[] createContext() {
// Now create the ContextEntries in the same order the constraints
ContextEntry[] contexts = new ContextEntry[this.constraints.size()];
@@ -262,10 +276,10 @@
/**
* Determine if another object is equal to this.
- *
+ *
* @param object
* The object to test.
- *
+ *
* @return <code>true</code> if <code>object</code> is equal to this,
* otherwise <code>false</code>.
*/
Modified: labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/common/DefaultFactHandle.java
===================================================================
--- labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/common/DefaultFactHandle.java 2008-03-20 18:57:07 UTC (rev 19163)
+++ labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/common/DefaultFactHandle.java 2008-03-20 19:32:10 UTC (rev 19164)
@@ -2,13 +2,13 @@
/*
* Copyright 2005 JBoss Inc
- *
+ *
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -18,6 +18,10 @@
import org.drools.FactHandle;
+import java.io.ObjectOutput;
+import java.io.IOException;
+import java.io.ObjectInput;
+
/**
* Implementation of <code>FactHandle</code>.
* @author <a href="mailto:mark.proctor at jboss.com">Mark Proctor</a>
@@ -31,7 +35,7 @@
// ----------------------------------------------------------------------
/**
- *
+ *
*/
private static final long serialVersionUID = 400L;
/** Handle id. */
@@ -42,12 +46,28 @@
private int objectHashCode;
private boolean shadowFact;
+ public void writeExternal(ObjectOutput out) throws IOException {
+ out.writeInt(id);
+ out.writeLong(recency);
+ out.writeObject(object);
+ out.writeObject(key);
+ out.writeInt(objectHashCode);
+ out.writeBoolean(shadowFact);
+ }
+
+ public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
+ id = in.readInt();
+ recency = in.readLong();
+ object = in.readObject();
+ key = (EqualityKey)in.readObject();
+ objectHashCode = in.readInt();
+ shadowFact = in.readBoolean();
+ }
// ----------------------------------------------------------------------
// Constructors
// ----------------------------------------------------------------------
public DefaultFactHandle() {
-
}
public DefaultFactHandle(final int id,
@@ -59,7 +79,7 @@
/**
* Construct.
- *
+ *
* @param id
* Handle id.
*/
Modified: labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/common/DoubleBetaConstraints.java
===================================================================
--- labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/common/DoubleBetaConstraints.java 2008-03-20 18:57:07 UTC (rev 19163)
+++ labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/common/DoubleBetaConstraints.java 2008-03-20 19:32:10 UTC (rev 19164)
@@ -2,13 +2,13 @@
/*
* Copyright 2005 JBoss Inc
- *
+ *
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -16,10 +16,6 @@
* limitations under the License.
*/
-import java.io.Serializable;
-import java.util.ArrayList;
-import java.util.List;
-
import org.drools.RuleBaseConfiguration;
import org.drools.base.evaluators.Operator;
import org.drools.reteoo.BetaMemory;
@@ -29,6 +25,7 @@
import org.drools.rule.ContextEntry;
import org.drools.rule.VariableConstraint;
import org.drools.spi.BetaNodeFieldConstraint;
+import org.drools.util.AbstractHashTable.FieldIndex;
import org.drools.util.FactHandleIndexHashTable;
import org.drools.util.FactHashTable;
import org.drools.util.FactList;
@@ -36,24 +33,31 @@
import org.drools.util.LinkedListEntry;
import org.drools.util.TupleHashTable;
import org.drools.util.TupleIndexHashTable;
-import org.drools.util.AbstractHashTable.FieldIndex;
+import java.io.IOException;
+import java.io.ObjectInput;
+import java.io.ObjectOutput;
+import java.util.ArrayList;
+import java.util.List;
+
public class DoubleBetaConstraints
implements
- Serializable,
BetaConstraints {
/**
- *
+ *
*/
private static final long serialVersionUID = 400L;
- private final BetaNodeFieldConstraint constraint0;
- private final BetaNodeFieldConstraint constraint1;
+ private BetaNodeFieldConstraint constraint0;
+ private BetaNodeFieldConstraint constraint1;
private boolean indexed0;
private boolean indexed1;
+ public DoubleBetaConstraints() {
+
+ }
public DoubleBetaConstraints(final BetaNodeFieldConstraint[] constraints,
final RuleBaseConfiguration conf) {
this( constraints,
@@ -70,7 +74,7 @@
} else {
final int depth = conf.getCompositeKeyDepth();
- // Determine if this constraints are indexable
+ // Determine if this constraints are indexable
final boolean i0 = isIndexable( constraints[0] );
final boolean i1 = isIndexable( constraints[1] );
@@ -94,6 +98,21 @@
this.constraint1 = constraints[1];
}
+ public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
+ constraint0 = (BetaNodeFieldConstraint)in.readObject();
+ constraint1 = (BetaNodeFieldConstraint)in.readObject();
+ indexed0 = in.readBoolean();
+ indexed1 = in.readBoolean();
+
+ }
+
+ public void writeExternal(ObjectOutput out) throws IOException {
+ out.writeObject(constraint0);
+ out.writeObject(constraint1);
+ out.writeBoolean(indexed0);
+ out.writeBoolean(indexed1);
+
+ }
private void swap(final BetaNodeFieldConstraint[] constraints,
final int p1,
final int p2) {
@@ -249,10 +268,10 @@
/**
* Determine if another object is equal to this.
- *
+ *
* @param object
* The object to test.
- *
+ *
* @return <code>true</code> if <code>object</code> is equal to this,
* otherwise <code>false</code>.
*/
Copied: labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/common/DroolsObjectInput.java (from rev 19160, labs/jbossrules/dev_tags/before_righttuple_merge_20080320/drools-core/src/main/java/org/drools/common/DroolsObjectInput.java)
===================================================================
--- labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/common/DroolsObjectInput.java (rev 0)
+++ labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/common/DroolsObjectInput.java 2008-03-20 19:32:10 UTC (rev 19164)
@@ -0,0 +1,26 @@
+package org.drools.common;
+
+import org.drools.rule.*;
+import org.drools.rule.Package;
+import org.drools.base.ClassFieldExtractorCache;
+
+import java.io.ObjectInput;
+
+/**
+ * Created by IntelliJ IDEA. User: SG0521861 Date: Mar 4, 2008 Time: 7:24:07 AM To change this template use File |
+ * Settings | File Templates.
+ */
+public interface DroolsObjectInput extends ObjectInput {
+ ClassLoader getClassLoader();
+ void setClassLoader(ClassLoader classLoader);
+ InternalRuleBase getRuleBase();
+ void setRuleBase(InternalRuleBase ruleBase);
+ void setWorkingMemory(InternalWorkingMemory workingMemory);
+ InternalWorkingMemory getWorkingMemory();
+ Package getPackage();
+ void setPackage(Package pkg);
+ DialectDatas getDialectDatas();
+ void setDialectDatas(DialectDatas dialectDatas);
+ ClassFieldExtractorCache getExtractorFactory();
+ void setExtractorFactory(ClassFieldExtractorCache extractorFactory);
+}
Modified: labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/common/DroolsObjectInputStream.java
===================================================================
--- labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/common/DroolsObjectInputStream.java 2008-03-20 18:57:07 UTC (rev 19163)
+++ labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/common/DroolsObjectInputStream.java 2008-03-20 19:32:10 UTC (rev 19164)
@@ -1,29 +1,38 @@
/**
- *
+ *
*/
package org.drools.common;
+import java.io.Externalizable;
import java.io.IOException;
import java.io.InputStream;
+import java.io.InvalidClassException;
+import java.io.ObjectInput;
import java.io.ObjectInputStream;
import java.io.ObjectStreamClass;
+import java.io.StreamCorruptedException;
+import java.lang.reflect.Array;
+import java.lang.reflect.Constructor;
+import java.lang.reflect.InvocationTargetException;
+import java.util.Collection;
+import java.util.Collections;
import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+import java.util.concurrent.atomic.AtomicReferenceArray;
import org.drools.base.ClassFieldExtractorCache;
import org.drools.rule.DialectDatas;
import org.drools.rule.Package;
-public class DroolsObjectInputStream extends ObjectInputStream {
- private final ClassLoader classLoader;
- private InternalRuleBase ruleBase;
- private InternalWorkingMemory workingMemory;
- private Package pkg;
- private DialectDatas dialectDatas;
- private ClassFieldExtractorCache extractorFactory;
+public class DroolsObjectInputStream
+ implements DroolsObjectInput, DroolsObjectStreamConstants {
- /** table mapping primitive type names to corresponding class objects */
- private static final HashMap primClasses = new HashMap( 8,
- 1.0F );
+ private final Map<Integer, Object> objectsByHandle = new HashMap<Integer, Object>();
+ private DroolsObjectInput dataInput;
+
+ private static final Map<String, Class> primClasses = new HashMap<String, Class>( 8, 1.0F );
static {
primClasses.put( "boolean",
boolean.class );
@@ -45,78 +54,128 @@
void.class );
}
- public DroolsObjectInputStream(final InputStream in) throws IOException {
- this( in,
- null );
- }
+ private ClassLoader classLoader;
+ private InternalRuleBase ruleBase;
+ private InternalWorkingMemory workingMemory;
+ private Package pkg;
+ private DialectDatas dialectDatas;
+ private ClassFieldExtractorCache extractorFactory;
- public DroolsObjectInputStream(final InputStream in,
- ClassLoader classLoader) throws IOException {
- super( in );
- if ( classLoader == null ) {
- classLoader = Thread.currentThread().getContextClassLoader();
- if ( classLoader == null ) {
- classLoader = this.getClass().getClassLoader();
- }
+ /**
+ * Created this inner class to handle un-Externalizable objects just in case.
+ */
+ private class DroolsInternalInputStream
+ extends ObjectInputStream
+ implements DroolsObjectInput {
+
+ private DroolsInternalInputStream(InputStream in, ClassLoader classLoader) throws IOException {
+ super(in);
+ setClassLoader(classLoader);
}
- this.classLoader = classLoader;
- this.extractorFactory = ClassFieldExtractorCache.getInstance();
- enableResolveObject( true );
- }
+ public ClassLoader getClassLoader() {
+ return DroolsObjectInputStream.this.getClassLoader();
+ }
- public ClassLoader getClassLoader() {
- return this.classLoader;
- }
+ public void setClassLoader(ClassLoader classLoader) {
+ DroolsObjectInputStream.this.setClassLoader(classLoader);
+ }
- protected Class resolveClass(final ObjectStreamClass desc) throws IOException,
- ClassNotFoundException {
- if ( this.classLoader == null ) {
- return super.resolveClass( desc );
- } else {
- final String name = desc.getName();
- Class clazz = (Class) primClasses.get( name );
- if ( clazz == null ) {
+ public InternalRuleBase getRuleBase() {
+ return DroolsObjectInputStream.this.getRuleBase();
+ }
+ public void setRuleBase(InternalRuleBase ruleBase) {
+ DroolsObjectInputStream.this.setRuleBase(ruleBase);
+ }
+
+ public InternalWorkingMemory getWorkingMemory() {
+ return DroolsObjectInputStream.this.getWorkingMemory();
+ }
+ public void setWorkingMemory(InternalWorkingMemory workingMemory) {
+ DroolsObjectInputStream.this.setWorkingMemory(workingMemory);
+ }
+
+ public Package getPackage() {
+ return DroolsObjectInputStream.this.getPackage();
+ }
+ public void setPackage(Package pkg) {
+ DroolsObjectInputStream.this.setPackage(pkg);
+ }
+
+ public DialectDatas getDialectDatas() {
+ return DroolsObjectInputStream.this.getDialectDatas();
+ }
+ public void setDialectDatas(DialectDatas dialectDatas) {
+ DroolsObjectInputStream.this.setDialectDatas(dialectDatas);
+ }
+
+ public ClassFieldExtractorCache getExtractorFactory() {
+ return DroolsObjectInputStream.this.getExtractorFactory();
+ }
+
+ public void setExtractorFactory(ClassFieldExtractorCache extractorFactory) {
+ DroolsObjectInputStream.this.setExtractorFactory(extractorFactory);
+ }
+
+ protected Class resolveClass(ObjectStreamClass desc) throws IOException,
+ ClassNotFoundException {
+ if ( getClassLoader() == null ) {
+ return super.resolveClass( desc );
+ } else {
try {
- clazz = this.classLoader.loadClass( name );
- } catch ( final ClassNotFoundException cnf ) {
- clazz = super.resolveClass( desc );
+ return DroolsObjectInputStream.this.resolveClass(desc.getName());
}
+ catch (ClassNotFoundException cnf) {
+ return super.resolveClass( desc );
+ }
}
- return clazz;
}
}
+ public DroolsObjectInputStream(InputStream inputStream) throws IOException {
+ this(inputStream, null);
+ }
+
+ public DroolsObjectInputStream(InputStream inputStream, ClassLoader classLoader) throws IOException {
+ dataInput = new DroolsInternalInputStream(inputStream, classLoader);
+ extractorFactory = ClassFieldExtractorCache.getInstance();
+ readStreamHeader();
+ }
+
+ public DroolsObjectInputStream(ObjectInput inputStream) throws IOException {
+ this(inputStream, null);
+ }
+
+ public DroolsObjectInputStream(ObjectInput inputStream, ClassLoader classLoader) throws IOException {
+ this((InputStream)inputStream, classLoader);
+ }
+
public InternalRuleBase getRuleBase() {
return ruleBase;
}
-
public void setRuleBase(InternalRuleBase ruleBase) {
- this.ruleBase = ruleBase;
+ this.ruleBase = ruleBase;
}
- public void setWorkingMemory(InternalWorkingMemory workingMemory) {
- this.workingMemory = workingMemory;
- }
-
public InternalWorkingMemory getWorkingMemory() {
return workingMemory;
}
+ public void setWorkingMemory(InternalWorkingMemory workingMemory) {
+ this.workingMemory = workingMemory;
+ }
public Package getPackage() {
return pkg;
}
-
public void setPackage(Package pkg) {
- this.pkg = pkg;
- }
+ this.pkg = pkg;
+ }
public DialectDatas getDialectDatas() {
- return this.dialectDatas;
+ return dialectDatas;
}
-
public void setDialectDatas(DialectDatas dialectDatas) {
- this.dialectDatas = dialectDatas;
+ this.dialectDatas = dialectDatas;
}
public ClassFieldExtractorCache getExtractorFactory() {
@@ -124,7 +183,835 @@
}
public void setExtractorFactory(ClassFieldExtractorCache extractorFactory) {
- this.extractorFactory = extractorFactory;
+ this.extractorFactory = extractorFactory;
}
+ public ClassLoader getClassLoader() {
+ return classLoader;
+ }
+
+ public void setClassLoader(ClassLoader classLoader) {
+ if (classLoader == null) {
+ classLoader = Thread.currentThread().getContextClassLoader();
+ if ( classLoader == null ) {
+ classLoader = getClass().getClassLoader();
+ }
+ }
+ this.classLoader = classLoader;
+ }
+
+ protected void readStreamHeader() throws IOException {
+ int magic = readInt();
+ short version = readShort();
+ if (magic != STREAM_MAGIC || version != STREAM_VERSION) {
+ throw new StreamCorruptedException("Invalid stream header: "+magic+'|'+version);
+ }
+ }
+
+ public Object readObject() throws ClassNotFoundException, IOException {
+ byte type = readRecordType();
+
+ switch (type) {
+ case RT_NULL:
+ return readNull();
+ case RT_EMPTY_SET:
+ return readEmptySet();
+ case RT_EMPTY_LIST:
+ return readEmptyList();
+ case RT_EMPTY_MAP:
+ return readEmptyMap();
+ default:
+ return readObject(type);
+ }
+ }
+
+ private Object readObject(byte type) throws IOException, ClassNotFoundException {
+ int handle = readHandle();
+
+ switch (type) {
+ case RT_EXTERNALIZABLE:
+ return readExternalizable(handle);
+ case RT_STRING:
+ return readString(handle);
+ case RT_MAP:
+ return readMap(handle);
+ case RT_COLLECTION:
+ return readCollection(handle);
+ case RT_ARRAY:
+ return readArray(handle);
+ case RT_CLASS:
+ return readClass(handle);
+ case RT_REFERENCE:
+ return readReference(handle);
+ case RT_ATOMICREFERENCEARRAY:
+ return readAtomicReferenceArray(handle);
+ case RT_SERIALIZABLE:
+ return readSerializable(handle);
+ default:
+ throw new StreamCorruptedException("Unsupported object type: " + type);
+ }
+ }
+
+ private Object readArray(int handle) throws IOException, ClassNotFoundException {
+ Class clazz = (Class) readObject();
+ int length = dataInput.readInt();
+ Class componentType = clazz.getComponentType();
+ Object array = Array.newInstance(componentType, length);
+ registerObject(handle, array);
+ if (componentType.isPrimitive()) {
+ readPrimitiveArray(array, length, componentType);
+ } else {
+ readObjectArray((Object[]) array, length);
+ }
+ return array;
+ }
+
+ private void readPrimitiveArray(Object array, int length, Class clazz) throws IOException {
+ if (clazz == Integer.TYPE) {
+ readIntArray((int[]) array, length);
+ } else if (clazz == Byte.TYPE) {
+ readByteArray((byte[]) array, length);
+ } else if (clazz == Long.TYPE) {
+ readLongArray((long[]) array, length);
+ } else if (clazz == Float.TYPE) {
+ readFloatArray((float[]) array, length);
+ } else if (clazz == Double.TYPE) {
+ readDoubleArray((double[]) array, length);
+ } else if (clazz == Short.TYPE) {
+ readShortArray((short[]) array, length);
+ } else if (clazz == Character.TYPE) {
+ readCharArray((char[]) array, length);
+ } else if (clazz == Boolean.TYPE) {
+ readBooleanArray((boolean[]) array, length);
+ } else {
+ throw new StreamCorruptedException("Unsupported array type: " + clazz);
+ }
+ }
+
+ private void readIntArray(int[] ints, int length) throws IOException {
+ for (int i = 0; i < length; ++i) {
+ ints[i] = dataInput.readInt();
+ }
+ }
+
+ private void readByteArray(byte[] bytes, int length) throws IOException {
+ dataInput.readFully(bytes, 0, length);
+ }
+
+ private void readLongArray(long[] longs, int length) throws IOException {
+ for (int i = 0; i < length; ++i) {
+ longs[i] = dataInput.readLong();
+ }
+ }
+
+ private void readFloatArray(float[] floats, int length) throws IOException {
+ for (int i = 0; i < length; ++i) {
+ floats[i] = dataInput.readFloat();
+ }
+ }
+
+ private void readDoubleArray(double[] doubles, int length) throws IOException {
+ for (int i = 0; i < length; ++i) {
+ doubles[i] = dataInput.readDouble();
+ }
+ }
+
+ private void readShortArray(short[] shorts, int length) throws IOException {
+ for (int i = 0; i < length; ++i) {
+ shorts[i] = dataInput.readShort();
+ }
+ }
+
+ private void readCharArray(char[] chars, int length) throws IOException {
+ for (int i = 0; i < length; ++i) {
+ chars[i] = dataInput.readChar();
+ }
+ }
+
+ private void readBooleanArray(boolean[] booleans, int length) throws IOException {
+ for (int i = 0; i < length; ++i) {
+ booleans[i] = dataInput.readBoolean();
+ }
+ }
+
+ private void readObjectArray(Object[] objects, int length) throws IOException, ClassNotFoundException {
+ for (int i = 0; i < length; ++i) {
+ objects[i] = readObject();
+ }
+ }
+
+ private static Object readNull() {
+ return null;
+ }
+
+ private static Set readEmptySet() {
+ return Collections.EMPTY_SET;
+ }
+
+ private static List readEmptyList() {
+ return Collections.EMPTY_LIST;
+ }
+
+ private static Map readEmptyMap() {
+ return Collections.EMPTY_MAP;
+ }
+
+ private Object readSerializable(int handle) throws ClassNotFoundException, IOException {
+ Object object = dataInput.readObject();
+ registerObject(handle, object);
+ return object;
+ }
+
+ private Object readExternalizable(int handle) throws ClassNotFoundException, IOException {
+ Class clazz = (Class) readObject();
+ Externalizable externalizable;
+ try {
+ externalizable = (Externalizable) clazz.newInstance();
+ } catch (InstantiationException e) {
+ throw newInvalidClassException(clazz, e);
+ } catch (IllegalAccessException e) {
+ throw newInvalidClassException(clazz, e);
+ }
+ registerObject(handle, externalizable);
+ externalizable.readExternal(this);
+ return externalizable;
+ }
+
+ private String readString(int handle) throws IOException {
+ String string = dataInput.readUTF();
+ registerObject(handle, string);
+ return string;
+ }
+
+ private AtomicReferenceArray<Object> readAtomicReferenceArray(int handle)
+ throws IOException, ClassNotFoundException {
+ int length = dataInput.readInt();
+ AtomicReferenceArray<Object> array = new AtomicReferenceArray<Object>(length);
+ registerObject(handle, array);
+ for (int i = 0; i < length; ++i) {
+ array.set(i, readObject());
+ }
+ return array;
+ }
+
+ private Map readMap(int handle) throws IOException, ClassNotFoundException {
+ Class clazz = (Class) readObject();
+ int size = dataInput.readInt();
+ Map<Object, Object> map = (Map<Object, Object>) newCollection(handle, clazz, size);
+ for (int i = 0; i < size; ++i) {
+ Object key = readObject();
+ Object value = readObject();
+ map.put(key, value);
+ }
+ return map;
+ }
+
+ private Collection readCollection(int handle) throws IOException, ClassNotFoundException {
+ Class clazz = (Class) readObject();
+ int size = dataInput.readInt();
+ Collection<Object> collection = (Collection<Object>) newCollection(handle, clazz, size);
+ for (int i = 0; i < size; ++i) {
+ collection.add(readObject());
+ }
+ return collection;
+ }
+
+ private Object newCollection(int handle, Class clazz, int size) throws IOException {
+ Object collection;
+ try {
+ Constructor constructor = clazz.getConstructor(Integer.TYPE);
+ collection = constructor.newInstance(size);
+ } catch (InstantiationException e) {
+ throw newInvalidClassException(clazz, e);
+ } catch (IllegalAccessException e) {
+ throw newInvalidClassException(clazz, e);
+ } catch (InvocationTargetException e) {
+ throw newInvalidClassException(clazz, e);
+ } catch (NoSuchMethodException e) {
+ try {
+ Constructor constructor = clazz.getConstructor();
+ collection = constructor.newInstance();
+ } catch (Exception e2) {
+ throw newInvalidClassException(clazz, e2);
+ }
+ }
+ registerObject(handle, collection);
+ return collection;
+ }
+
+ private int readHandle() throws IOException {
+ return dataInput.readInt();
+ }
+
+ private Class readClass(int handle) throws IOException, ClassNotFoundException {
+ String className = (String) readObject();
+ Class clazz = resolveClass(className);
+ registerObject(handle, clazz);
+ return clazz;
+ }
+
+ private byte readRecordType() throws IOException {
+ return dataInput.readByte();
+ }
+
+ private Object readReference(int handle) {
+ return objectsByHandle.get(handle);
+ }
+
+ private void registerObject(int handle, Object object) {
+ objectsByHandle.put(handle, object);
+ }
+
+ private static InvalidClassException newInvalidClassException(Class clazz, Throwable cause) {
+ InvalidClassException exception = new InvalidClassException(clazz.getName());
+ exception.initCause(cause);
+ return exception;
+ }
+
+ /**
+ * Using the ClassLoader from the top of the stack to load the class specified by the given class name.
+ * @param className
+ * @return
+ * @throws ClassNotFoundException
+ */
+ protected Class resolveClass(String className) throws ClassNotFoundException{
+ try {
+ Class clazz = primClasses.get( className );
+ if ( clazz == null ) {
+ clazz = getClassLoader().loadClass( className );
+ if (clazz == null) {
+ clazz = getClass().getClassLoader().loadClass(className);
+ }
+ }
+ return clazz;
+ }
+ catch (ClassNotFoundException e) {
+ return getClass().getClassLoader().loadClass(className);
+ }
+ }
+
+ /*=================================================================================
+ ObjectInput implementations
+ =================================================================================*/
+ /**
+ * Reads a byte of data. This method will block if no input is
+ * available.
+ * @return the byte read, or -1 if the end of the
+ * stream is reached.
+ * @exception IOException If an I/O error has occurred.
+ */
+ public int read() throws IOException {
+ return dataInput.read();
+ }
+
+ /**
+ * Reads into an array of bytes. This method will
+ * block until some input is available.
+ * @param b the buffer into which the data is read
+ * @return the actual number of bytes read, -1 is
+ * returned when the end of the stream is reached.
+ * @exception IOException If an I/O error has occurred.
+ */
+ public int read(byte b[]) throws IOException {
+ return dataInput.read(b);
+ }
+
+ /**
+ * Reads into an array of bytes. This method will
+ * block until some input is available.
+ * @param b the buffer into which the data is read
+ * @param off the start offset of the data
+ * @param len the maximum number of bytes read
+ * @return the actual number of bytes read, -1 is
+ * returned when the end of the stream is reached.
+ * @exception IOException If an I/O error has occurred.
+ */
+ public int read(byte b[], int off, int len) throws IOException {
+ return dataInput.read(b, off, len);
+ }
+
+ /**
+ * Skips n bytes of input.
+ * @param n the number of bytes to be skipped
+ * @return the actual number of bytes skipped.
+ * @exception IOException If an I/O error has occurred.
+ */
+ public long skip(long n) throws IOException {
+ return dataInput.skip(n);
+ }
+
+ /**
+ * Returns the number of bytes that can be read
+ * without blocking.
+ * @return the number of available bytes.
+ * @exception IOException If an I/O error has occurred.
+ */
+ public int available() throws IOException {
+ return dataInput.available();
+ }
+
+ /**
+ * Closes the input stream. Must be called
+ * to release any resources associated with
+ * the stream.
+ * @exception IOException If an I/O error has occurred.
+ */
+ public void close() throws IOException {
+ dataInput.close();
+ }
+
+ /**
+ * Reads some bytes from an input
+ * stream and stores them into the buffer
+ * array <code>b</code>. The number of bytes
+ * read is equal
+ * to the length of <code>b</code>.
+ * <p>
+ * This method blocks until one of the
+ * following conditions occurs:<p>
+ * <ul>
+ * <li><code>b.length</code>
+ * bytes of input data are available, in which
+ * case a normal return is made.
+ *
+ * <li>End of
+ * file is detected, in which case an <code>EOFException</code>
+ * is thrown.
+ *
+ * <li>An I/O error occurs, in
+ * which case an <code>IOException</code> other
+ * than <code>EOFException</code> is thrown.
+ * </ul>
+ * <p>
+ * If <code>b</code> is <code>null</code>,
+ * a <code>NullPointerException</code> is thrown.
+ * If <code>b.length</code> is zero, then
+ * no bytes are read. Otherwise, the first
+ * byte read is stored into element <code>b[0]</code>,
+ * the next one into <code>b[1]</code>, and
+ * so on.
+ * If an exception is thrown from
+ * this method, then it may be that some but
+ * not all bytes of <code>b</code> have been
+ * updated with data from the input stream.
+ *
+ * @param b the buffer into which the data is read.
+ * @exception IOException if an I/O error occurs.
+ */
+ public void readFully(byte b[]) throws IOException {
+ dataInput.readFully(b);
+ }
+
+ /**
+ *
+ * Reads <code>len</code>
+ * bytes from
+ * an input stream.
+ * <p>
+ * This method
+ * blocks until one of the following conditions
+ * occurs:<p>
+ * <ul>
+ * <li><code>len</code> bytes
+ * of input data are available, in which case
+ * a normal return is made.
+ *
+ * <li>End of file
+ * is detected, in which case an <code>EOFException</code>
+ * is thrown.
+ *
+ * <li>An I/O error occurs, in
+ * which case an <code>IOException</code> other
+ * than <code>EOFException</code> is thrown.
+ * </ul>
+ * <p>
+ * If <code>b</code> is <code>null</code>,
+ * a <code>NullPointerException</code> is thrown.
+ * If <code>off</code> is negative, or <code>len</code>
+ * is negative, or <code>off+len</code> is
+ * greater than the length of the array <code>b</code>,
+ * then an <code>IndexOutOfBoundsException</code>
+ * is thrown.
+ * If <code>len</code> is zero,
+ * then no bytes are read. Otherwise, the first
+ * byte read is stored into element <code>b[off]</code>,
+ * the next one into <code>b[off+1]</code>,
+ * and so on. The number of bytes read is,
+ * at most, equal to <code>len</code>.
+ *
+ * @param b the buffer into which the data is read.
+ * @param off an int specifying the offset into the data.
+ * @param len an int specifying the number of bytes to read.
+ * @exception IOException if an I/O error occurs.
+ */
+ public void readFully(byte b[], int off, int len) throws IOException {
+ dataInput.readFully(b, off, len);
+ }
+
+ /**
+ * Makes an attempt to skip over
+ * <code>n</code> bytes
+ * of data from the input
+ * stream, discarding the skipped bytes. However,
+ * it may skip
+ * over some smaller number of
+ * bytes, possibly zero. This may result from
+ * any of a
+ * number of conditions; reaching
+ * end of file before <code>n</code> bytes
+ * have been skipped is
+ * only one possibility.
+ * This method never throws an <code>EOFException</code>.
+ * The actual
+ * number of bytes skipped is returned.
+ *
+ * @param n the number of bytes to be skipped.
+ * @return the number of bytes actually skipped.
+ * @exception IOException if an I/O error occurs.
+ */
+ public int skipBytes(int n) throws IOException {
+ return dataInput.skipBytes(n);
+ }
+
+ /**
+ * Reads one input byte and returns
+ * <code>true</code> if that byte is nonzero,
+ * <code>false</code> if that byte is zero.
+ * This method is suitable for reading
+ * the byte written by the <code>writeBoolean</code>
+ * method of interface <code>DataOutput</code>.
+ *
+ * @return the <code>boolean</code> value read.
+ * @exception IOException if an I/O error occurs.
+ */
+ public boolean readBoolean() throws IOException {
+ return dataInput.readBoolean();
+ }
+
+ /**
+ * Reads and returns one input byte.
+ * The byte is treated as a signed value in
+ * the range <code>-128</code> through <code>127</code>,
+ * inclusive.
+ * This method is suitable for
+ * reading the byte written by the <code>writeByte</code>
+ * method of interface <code>DataOutput</code>.
+ *
+ * @return the 8-bit value read.
+ * @exception IOException if an I/O error occurs.
+ */
+ public byte readByte() throws IOException {
+ return dataInput.readByte();
+ }
+
+ /**
+ * Reads one input byte, zero-extends
+ * it to type <code>int</code>, and returns
+ * the result, which is therefore in the range
+ * <code>0</code>
+ * through <code>255</code>.
+ * This method is suitable for reading
+ * the byte written by the <code>writeByte</code>
+ * method of interface <code>DataOutput</code>
+ * if the argument to <code>writeByte</code>
+ * was intended to be a value in the range
+ * <code>0</code> through <code>255</code>.
+ *
+ * @return the unsigned 8-bit value read.
+ * @exception IOException if an I/O error occurs.
+ */
+ public int readUnsignedByte() throws IOException {
+ return dataInput.readUnsignedByte();
+ }
+
+ /**
+ * Reads two input bytes and returns
+ * a <code>short</code> value. Let <code>a</code>
+ * be the first byte read and <code>b</code>
+ * be the second byte. The value
+ * returned
+ * is:
+ * <p><pre><code>(short)((a << 8) | (b & 0xff))
+ * </code></pre>
+ * This method
+ * is suitable for reading the bytes written
+ * by the <code>writeShort</code> method of
+ * interface <code>DataOutput</code>.
+ *
+ * @return the 16-bit value read.
+ * @exception IOException if an I/O error occurs.
+ */
+ public short readShort() throws IOException {
+ return dataInput.readShort();
+ }
+
+ /**
+ * Reads two input bytes and returns
+ * an <code>int</code> value in the range <code>0</code>
+ * through <code>65535</code>. Let <code>a</code>
+ * be the first byte read and
+ * <code>b</code>
+ * be the second byte. The value returned is:
+ * <p><pre><code>(((a & 0xff) << 8) | (b & 0xff))
+ * </code></pre>
+ * This method is suitable for reading the bytes
+ * written by the <code>writeShort</code> method
+ * of interface <code>DataOutput</code> if
+ * the argument to <code>writeShort</code>
+ * was intended to be a value in the range
+ * <code>0</code> through <code>65535</code>.
+ *
+ * @return the unsigned 16-bit value read.
+ * @exception IOException if an I/O error occurs.
+ */
+ public int readUnsignedShort() throws IOException {
+ return dataInput.readUnsignedShort();
+ }
+
+ /**
+ * Reads an input <code>char</code> and returns the <code>char</code> value.
+ * A Unicode <code>char</code> is made up of two bytes.
+ * Let <code>a</code>
+ * be the first byte read and <code>b</code>
+ * be the second byte. The value
+ * returned is:
+ * <p><pre><code>(char)((a << 8) | (b & 0xff))
+ * </code></pre>
+ * This method
+ * is suitable for reading bytes written by
+ * the <code>writeChar</code> method of interface
+ * <code>DataOutput</code>.
+ *
+ * @return the Unicode <code>char</code> read.
+ * @exception IOException if an I/O error occurs.
+ */
+ public char readChar() throws IOException {
+ return dataInput.readChar();
+ }
+
+ /**
+ * Reads four input bytes and returns an
+ * <code>int</code> value. Let <code>a</code>
+ * be the first byte read, <code>b</code> be
+ * the second byte, <code>c</code> be the third
+ * byte,
+ * and <code>d</code> be the fourth
+ * byte. The value returned is:
+ * <p><pre>
+ * <code>
+ * (((a & 0xff) << 24) | ((b & 0xff) << 16) |
+ *  ((c & 0xff) << 8) | (d & 0xff))
+ * </code></pre>
+ * This method is suitable
+ * for reading bytes written by the <code>writeInt</code>
+ * method of interface <code>DataOutput</code>.
+ *
+ * @return the <code>int</code> value read.
+ * @exception IOException if an I/O error occurs.
+ */
+ public int readInt() throws IOException {
+ return dataInput.readInt();
+ }
+
+ /**
+ * Reads eight input bytes and returns
+ * a <code>long</code> value. Let <code>a</code>
+ * be the first byte read, <code>b</code> be
+ * the second byte, <code>c</code> be the third
+ * byte, <code>d</code>
+ * be the fourth byte,
+ * <code>e</code> be the fifth byte, <code>f</code>
+ * be the sixth byte, <code>g</code> be the
+ * seventh byte,
+ * and <code>h</code> be the
+ * eighth byte. The value returned is:
+ * <p><pre> <code>
+ * (((long)(a & 0xff) << 56) |
+ * ((long)(b & 0xff) << 48) |
+ * ((long)(c & 0xff) << 40) |
+ * ((long)(d & 0xff) << 32) |
+ * ((long)(e & 0xff) << 24) |
+ * ((long)(f & 0xff) << 16) |
+ * ((long)(g & 0xff) << 8) |
+ * ((long)(h & 0xff)))
+ * </code></pre>
+ * <p>
+ * This method is suitable
+ * for reading bytes written by the <code>writeLong</code>
+ * method of interface <code>DataOutput</code>.
+ *
+ * @return the <code>long</code> value read.
+ * @exception IOException if an I/O error occurs.
+ */
+ public long readLong() throws IOException {
+ return dataInput.readLong();
+ }
+
+ /**
+ * Reads four input bytes and returns
+ * a <code>float</code> value. It does this
+ * by first constructing an <code>int</code>
+ * value in exactly the manner
+ * of the <code>readInt</code>
+ * method, then converting this <code>int</code>
+ * value to a <code>float</code> in
+ * exactly the manner of the method <code>Float.intBitsToFloat</code>.
+ * This method is suitable for reading
+ * bytes written by the <code>writeFloat</code>
+ * method of interface <code>DataOutput</code>.
+ *
+ * @return the <code>float</code> value read.
+ * @exception IOException if an I/O error occurs.
+ */
+ public float readFloat() throws IOException {
+ return dataInput.readFloat();
+ }
+
+ /**
+ * Reads eight input bytes and returns
+ * a <code>double</code> value. It does this
+ * by first constructing a <code>long</code>
+ * value in exactly the manner
+ * of the <code>readlong</code>
+ * method, then converting this <code>long</code>
+ * value to a <code>double</code> in exactly
+ * the manner of the method <code>Double.longBitsToDouble</code>.
+ * This method is suitable for reading
+ * bytes written by the <code>writeDouble</code>
+ * method of interface <code>DataOutput</code>.
+ *
+ * @return the <code>double</code> value read.
+ * @exception IOException if an I/O error occurs.
+ */
+ public double readDouble() throws IOException {
+ return dataInput.readDouble();
+ }
+
+ /**
+ * Reads the next line of text from the input stream.
+ * It reads successive bytes, converting
+ * each byte separately into a character,
+ * until it encounters a line terminator or
+ * end of
+ * file; the characters read are then
+ * returned as a <code>String</code>. Note
+ * that because this
+ * method processes bytes,
+ * it does not support input of the full Unicode
+ * character set.
+ * <p>
+ * If end of file is encountered
+ * before even one byte can be read, then <code>null</code>
+ * is returned. Otherwise, each byte that is
+ * read is converted to type <code>char</code>
+ * by zero-extension. If the character <code>'\n'</code>
+ * is encountered, it is discarded and reading
+ * ceases. If the character <code>'\r'</code>
+ * is encountered, it is discarded and, if
+ * the following byte converts  to the
+ * character <code>'\n'</code>, then that is
+ * discarded also; reading then ceases. If
+ * end of file is encountered before either
+ * of the characters <code>'\n'</code> and
+ * <code>'\r'</code> is encountered, reading
+ * ceases. Once reading has ceased, a <code>String</code>
+ * is returned that contains all the characters
+ * read and not discarded, taken in order.
+ * Note that every character in this string
+ * will have a value less than <code>\u0100</code>,
+ * that is, <code>(char)256</code>.
+ *
+ * @return the next line of text from the input stream,
+ * or <CODE>null</CODE> if the end of file is
+ * encountered before a byte can be read.
+ * @exception IOException if an I/O error occurs.
+ */
+ public String readLine() throws IOException {
+ return dataInput.readLine();
+ }
+
+ /**
+ * Reads in a string that has been encoded using a
+ * <a href="#modified-utf-8">modified UTF-8</a>
+ * format.
+ * The general contract of <code>readUTF</code>
+ * is that it reads a representation of a Unicode
+ * character string encoded in modified
+ * UTF-8 format; this string of characters
+ * is then returned as a <code>String</code>.
+ * <p>
+ * First, two bytes are read and used to
+ * construct an unsigned 16-bit integer in
+ * exactly the manner of the <code>readUnsignedShort</code>
+ * method . This integer value is called the
+ * <i>UTF length</i> and specifies the number
+ * of additional bytes to be read. These bytes
+ * are then converted to characters by considering
+ * them in groups. The length of each group
+ * is computed from the value of the first
+ * byte of the group. The byte following a
+ * group, if any, is the first byte of the
+ * next group.
+ * <p>
+ * If the first byte of a group
+ * matches the bit pattern <code>0xxxxxxx</code>
+ * (where <code>x</code> means "may be <code>0</code>
+ * or <code>1</code>"), then the group consists
+ * of just that byte. The byte is zero-extended
+ * to form a character.
+ * <p>
+ * If the first byte
+ * of a group matches the bit pattern <code>110xxxxx</code>,
+ * then the group consists of that byte <code>a</code>
+ * and a second byte <code>b</code>. If there
+ * is no byte <code>b</code> (because byte
+ * <code>a</code> was the last of the bytes
+ * to be read), or if byte <code>b</code> does
+ * not match the bit pattern <code>10xxxxxx</code>,
+ * then a <code>UTFDataFormatException</code>
+ * is thrown. Otherwise, the group is converted
+ * to the character:<p>
+ * <pre><code>(char)(((a& 0x1F) << 6) | (b & 0x3F))
+ * </code></pre>
+ * If the first byte of a group
+ * matches the bit pattern <code>1110xxxx</code>,
+ * then the group consists of that byte <code>a</code>
+ * and two more bytes <code>b</code> and <code>c</code>.
+ * If there is no byte <code>c</code> (because
+ * byte <code>a</code> was one of the last
+ * two of the bytes to be read), or either
+ * byte <code>b</code> or byte <code>c</code>
+ * does not match the bit pattern <code>10xxxxxx</code>,
+ * then a <code>UTFDataFormatException</code>
+ * is thrown. Otherwise, the group is converted
+ * to the character:<p>
+ * <pre><code>
+ * (char)(((a & 0x0F) << 12) | ((b & 0x3F) << 6) | (c & 0x3F))
+ * </code></pre>
+ * If the first byte of a group matches the
+ * pattern <code>1111xxxx</code> or the pattern
+ * <code>10xxxxxx</code>, then a <code>UTFDataFormatException</code>
+ * is thrown.
+ * <p>
+ * If end of file is encountered
+ * at any time during this entire process,
+ * then an <code>EOFException</code> is thrown.
+ * <p>
+ * After every group has been converted to
+ * a character by this process, the characters
+ * are gathered, in the same order in which
+ * their corresponding groups were read from
+ * the input stream, to form a <code>String</code>,
+ * which is returned.
+ * <p>
+ * The <code>writeUTF</code>
+ * method of interface <code>DataOutput</code>
+ * may be used to write data that is suitable
+ * for reading by this method.
+ * @return a Unicode string.
+ * @exception IOException if an I/O error occurs.
+ */
+ public String readUTF() throws IOException {
+ return dataInput.readUTF();
+ }
}
\ No newline at end of file
Copied: labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/common/DroolsObjectOutputStream.java (from rev 19160, labs/jbossrules/dev_tags/before_righttuple_merge_20080320/drools-core/src/main/java/org/drools/common/DroolsObjectOutputStream.java)
===================================================================
--- labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/common/DroolsObjectOutputStream.java (rev 0)
+++ labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/common/DroolsObjectOutputStream.java 2008-03-20 19:32:10 UTC (rev 19164)
@@ -0,0 +1,636 @@
+package org.drools.common;
+
+import java.io.Externalizable;
+import java.io.IOException;
+import java.io.NotSerializableException;
+import java.io.ObjectOutput;
+import java.io.OutputStream;
+import java.io.ObjectOutputStream;
+import java.io.Serializable;
+import java.io.ByteArrayOutputStream;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.IdentityHashMap;
+import java.util.Map;
+import java.util.concurrent.atomic.AtomicReferenceArray;
+
+/**
+ *
+ */
+public class DroolsObjectOutputStream implements ObjectOutput, DroolsObjectStreamConstants {
+ private static final Class EMPTY_SET_CLASS = Collections.EMPTY_SET.getClass();
+ private static final Class EMPTY_MAP_CLASS = Collections.EMPTY_MAP.getClass();
+ private static final Class EMPTY_LIST_CLASS = Collections.EMPTY_LIST.getClass();
+
+ private final Map<Object, Integer> handlesByObject = new IdentityHashMap<Object, Integer>();
+ private final ObjectOutput dataOutput;
+
+ public DroolsObjectOutputStream(OutputStream outputStream) throws IOException {
+ this((ObjectOutput)new ObjectOutputStream(outputStream));
+ }
+ public DroolsObjectOutputStream(ObjectOutput dataOutput) throws IOException {
+ this.dataOutput = dataOutput;
+ writeStreamHeader();
+ }
+
+ private void writeNull() throws IOException {
+ writeRecordType(RT_NULL);
+ }
+
+ private void writeObjectOrReference(Object object, Class clazz) throws IOException {
+ int handle = registerObject(object);
+ if (handle < 0) {
+ writeObject(object, clazz, -handle);
+ } else {
+ writeReference(handle);
+ }
+ }
+
+ private void writeObject(Object object, Class clazz, int handle) throws IOException {
+ if (Externalizable.class.isAssignableFrom(clazz)) {
+ writeExternalizable((Externalizable) object, clazz, handle);
+ } else if (String.class.isAssignableFrom(clazz)) {
+ writeString((String) object, handle);
+ } else if (Map.class.isAssignableFrom(clazz)) {
+ writeMap((Map) object, clazz, handle);
+ } else if (Collection.class.isAssignableFrom(clazz)) {
+ writeCollection((Collection) object, clazz, handle);
+ } else if (clazz == Class.class) {
+ writeClass((Class) object, handle);
+ } else if (clazz.isArray()) {
+ writeArray(object, clazz, handle);
+ } else if (AtomicReferenceArray.class.isAssignableFrom(clazz)) {
+ writeAtomicReferenceArray((AtomicReferenceArray)object, handle);
+ } else if (Serializable.class.isAssignableFrom(clazz)) {
+ writeSerializable((Serializable) object, handle);
+ } else {
+ throw new NotSerializableException("Unsupported class: " + clazz);
+ }
+ }
+
+ private void writeArray(Object array, Class clazz, int handle) throws IOException {
+ writeRecordType(RT_ARRAY);
+ writeHandle(handle);
+ writeObject(clazz);
+ Class componentType = clazz.getComponentType();
+ if (componentType.isPrimitive()) {
+ writePrimitiveArray(array, componentType);
+ } else {
+ writeObjectArray((Object[]) array);
+ }
+ }
+
+ private void writePrimitiveArray(Object array, Class clazz) throws IOException {
+ if (clazz == Integer.TYPE) {
+ writeIntArray(array);
+ } else if (clazz == Byte.TYPE) {
+ writeByteArray(array);
+ } else if (clazz == Long.TYPE) {
+ writeLongArray(array);
+ } else if (clazz == Float.TYPE) {
+ writeFloatArray(array);
+ } else if (clazz == Double.TYPE) {
+ writeDoubleArray(array);
+ } else if (clazz == Short.TYPE) {
+ writeShortArray(array);
+ } else if (clazz == Character.TYPE) {
+ writeCharArray(array);
+ } else if (clazz == Boolean.TYPE) {
+ writeBooleanArray(array);
+ } else {
+ throw new NotSerializableException("Unsupported array type: " + clazz);
+ }
+ }
+
+ private void writeIntArray(Object array) throws IOException {
+ int[] ints = (int[]) array;
+ int length = ints.length;
+ writeInt(length);
+ for (int i = 0; i < length; ++i) {
+ writeInt(ints[i]);
+ }
+ }
+
+ private void writeByteArray(Object array) throws IOException {
+ byte[] bytes = (byte[]) array;
+ int length = bytes.length;
+ writeInt(length);
+ write(bytes, 0, length);
+ }
+
+ private void writeLongArray(Object array) throws IOException {
+ long[] longs = (long[]) array;
+ int length = longs.length;
+ writeInt(length);
+ for (int i = 0; i < length; ++i) {
+ writeLong(longs[i]);
+ }
+ }
+
+ private void writeFloatArray(Object array) throws IOException {
+ float[] floats = (float[]) array;
+ int length = floats.length;
+ writeFloat(length);
+ for (int i = 0; i < length; ++i) {
+ writeFloat(floats[i]);
+ }
+ }
+
+ private void writeDoubleArray(Object array) throws IOException {
+ double[] doubles = (double[]) array;
+ int length = doubles.length;
+ writeInt(length);
+ for (int i = 0; i < length; ++i) {
+ writeDouble(doubles[i]);
+ }
+ }
+
+ private void writeShortArray(Object array) throws IOException {
+ short[] shorts = (short[]) array;
+ int length = shorts.length;
+ writeInt(length);
+ for (int i = 0; i < length; ++i) {
+ writeShort(shorts[i]);
+ }
+ }
+
+ private void writeCharArray(Object array) throws IOException {
+ char[] chars = (char[]) array;
+ int length = chars.length;
+ writeInt(length);
+ for (int i = 0; i < length; ++i) {
+ writeChar(chars[i]);
+ }
+ }
+
+ private void writeBooleanArray(Object array) throws IOException {
+ boolean[] booleans = (boolean[]) array;
+ int length = booleans.length;
+ writeInt(length);
+ for (int i = 0; i < length; ++i) {
+ writeBoolean(booleans[i]);
+ }
+ }
+
+ private void writeObjectArray(Object[] objects) throws IOException {
+ int length = objects.length;
+ writeInt(length);
+ for (int i = 0; i < length; ++i) {
+ writeObject(objects[i]);
+ }
+ }
+
+ private void writeClass(Class clazz, int handle) throws IOException {
+ writeRecordType(RT_CLASS);
+ writeHandle(handle);
+ writeObjectOrReference(clazz.getName(), String.class);
+ }
+
+ private void writeString(String string, int handle) throws IOException {
+ writeRecordType(RT_STRING);
+ writeHandle(handle);
+ writeUTF(string);
+ }
+
+ private void writeReference(int handle) throws IOException {
+ writeRecordType(RT_REFERENCE);
+ writeHandle(handle);
+ }
+
+ private void writeExternalizable(Externalizable externalizable, Class clazz, int handle) throws IOException {
+ writeRecordType(RT_EXTERNALIZABLE);
+ writeHandle(handle);
+ writeObject(clazz);
+ externalizable.writeExternal(this);
+ }
+
+ private void writeSerializable(Serializable serializable, int handle) throws IOException {
+ writeRecordType(RT_SERIALIZABLE);
+ writeHandle(handle);
+ dataOutput.writeObject(serializable);
+ }
+
+ private void writeAtomicReferenceArray(AtomicReferenceArray array, int handle) throws IOException {
+ writeRecordType(RT_ATOMICREFERENCEARRAY);
+ writeHandle(handle);
+ writeInt(array.length());
+ for (int i = 0; i < array.length(); i++)
+ writeObject(array.get(i));
+ }
+
+ private void writeMap(Map map, Class clazz, int handle) throws IOException {
+ writeRecordType(RT_MAP);
+ writeHandle(handle);
+ writeObject(clazz);
+ writeInt(map.size());
+ for (Object object : map.entrySet()) {
+ Map.Entry entry = (Map.Entry) object;
+ writeObject(entry.getKey());
+ writeObject(entry.getValue());
+ }
+ }
+
+ private void writeCollection(Collection collection, Class clazz, int handle) throws IOException {
+ writeRecordType(RT_COLLECTION);
+ writeHandle(handle);
+ writeObject(clazz);
+ writeInt(collection.size());
+ for (Object object : collection) {
+ writeObject(object);
+ }
+ }
+
+ private void writeEmptySet() throws IOException {
+ writeRecordType(RT_EMPTY_SET);
+ }
+
+ private void writeEmptyList() throws IOException {
+ writeRecordType(RT_EMPTY_LIST);
+ }
+
+ private void writeEmptyMap() throws IOException {
+ writeRecordType(RT_EMPTY_MAP);
+ }
+
+ private void writeRecordType(byte type) throws IOException {
+ writeByte(type);
+ }
+
+ private void writeHandle(int handle) throws IOException {
+ writeInt(handle);
+ }
+
+ private void writeStreamHeader() throws IOException {
+ writeInt(STREAM_MAGIC);
+ writeShort(STREAM_VERSION);
+ }
+
+ private int registerObject(Object object) {
+ Integer handle = handlesByObject.get(object);
+ if (handle == null) {
+ handle = handlesByObject.size() + 1;
+ handlesByObject.put(object, handle);
+ handle = -handle;
+ }
+ return handle;
+ }
+
+ /*==========================================================================
+ Implementations of ObjectOutput
+ ==========================================================================*/
+ /**
+ * Write an object to the underlying storage or stream. The object was written
+ * in Drools specific format.
+ *
+ * @param object the object to be written
+ * @exception IOException Any of the usual Input/Output related exceptions.
+ */
+ public void writeObject(Object object) throws IOException {
+ if (object == null) {
+ writeNull();
+ } else {
+ Class clazz = object.getClass();
+
+ if (clazz == EMPTY_SET_CLASS) {
+ writeEmptySet();
+ } else if (clazz == EMPTY_LIST_CLASS) {
+ writeEmptyList();
+ } else if (clazz == EMPTY_MAP_CLASS) {
+ writeEmptyMap();
+ } else if (clazz == String.class) {
+ writeObjectOrReference(((String) object).intern(), clazz);
+ } else {
+ writeObjectOrReference(object, clazz);
+ }
+ }
+ flush();
+ }
+
+ /**
+ * Writes a byte. This method will block until the byte is actually
+ * written.
+ * @param b the byte
+ * @exception IOException If an I/O error has occurred.
+ */
+ public void write(int b) throws IOException {
+ dataOutput.write(b);
+ }
+
+ /**
+ * Writes an array of bytes. This method will block until the bytes
+ * are actually written.
+ * @param b the data to be written
+ * @exception IOException If an I/O error has occurred.
+ */
+ public void write(byte b[]) throws IOException {
+ dataOutput.write(b);
+ }
+
+ /**
+ * Writes a sub array of bytes.
+ * @param b the data to be written
+ * @param off the start offset in the data
+ * @param len the number of bytes that are written
+ * @exception IOException If an I/O error has occurred.
+ */
+ public void write(byte b[], int off, int len) throws IOException {
+ dataOutput.write(b, off, len);
+ }
+
+ /**
+ * Flushes the stream. This will write any buffered
+ * output bytes.
+ * @exception IOException If an I/O error has occurred.
+ */
+ public void flush() throws IOException {
+ dataOutput.flush();
+ }
+
+ /**
+ * Closes the stream. This method must be called
+ * to release any resources associated with the
+ * stream.
+ * @exception IOException If an I/O error has occurred.
+ */
+ public void close() throws IOException {
+ dataOutput.close();
+ }
+
+ /**
+ * Writes a <code>boolean</code> value to this output stream.
+ * If the argument <code>v</code>
+ * is <code>true</code>, the value <code>(byte)1</code>
+ * is written; if <code>v</code> is <code>false</code>,
+ * the value <code>(byte)0</code> is written.
+ * The byte written by this method may
+ * be read by the <code>readBoolean</code>
+ * method of interface <code>DataInput</code>,
+ * which will then return a <code>boolean</code>
+ * equal to <code>v</code>.
+ *
+ * @param v the boolean to be written.
+ * @exception IOException if an I/O error occurs.
+ */
+ public void writeBoolean(boolean v) throws IOException {
+ dataOutput.writeBoolean(v);
+ }
+
+ /**
+ * Writes to the output stream the eight low-
+ * order bits of the argument <code>v</code>.
+ * The 24 high-order bits of <code>v</code>
+ * are ignored. (This means that <code>writeByte</code>
+ * does exactly the same thing as <code>write</code>
+ * for an integer argument.) The byte written
+ * by this method may be read by the <code>readByte</code>
+ * method of interface <code>DataInput</code>,
+ * which will then return a <code>byte</code>
+ * equal to <code>(byte)v</code>.
+ *
+ * @param v the byte value to be written.
+ * @exception IOException if an I/O error occurs.
+ */
+ public void writeByte(int v) throws IOException {
+ dataOutput.writeByte(v);
+ }
+
+ /**
+ * Writes two bytes to the output
+ * stream to represent the value of the argument.
+ * The byte values to be written, in the order
+ * shown, are: <p>
+ * <pre><code>
+ * (byte)(0xff & (v >> 8))
+ * (byte)(0xff & v)
+ * </code> </pre> <p>
+ * The bytes written by this method may be
+ * read by the <code>readShort</code> method
+ * of interface <code>DataInput</code> , which
+ * will then return a <code>short</code> equal
+ * to <code>(short)v</code>.
+ *
+ * @param v the <code>short</code> value to be written.
+ * @exception IOException if an I/O error occurs.
+ */
+ public void writeShort(int v) throws IOException {
+ dataOutput.writeShort(v);
+ }
+
+ /**
+ * Writes a <code>char</code> value, which
+ * is comprised of two bytes, to the
+ * output stream.
+ * The byte values to be written, in the order
+ * shown, are:
+ * <p><pre><code>
+ * (byte)(0xff & (v >> 8))
+ * (byte)(0xff & v)
+ * </code></pre><p>
+ * The bytes written by this method may be
+ * read by the <code>readChar</code> method
+ * of interface <code>DataInput</code> , which
+ * will then return a <code>char</code> equal
+ * to <code>(char)v</code>.
+ *
+ * @param v the <code>char</code> value to be written.
+ * @exception IOException if an I/O error occurs.
+ */
+ public void writeChar(int v) throws IOException {
+ dataOutput.writeChar(v);
+ }
+
+ /**
+ * Writes an <code>int</code> value, which is
+ * comprised of four bytes, to the output stream.
+ * The byte values to be written, in the order
+ * shown, are:
+ * <p><pre><code>
+ * (byte)(0xff & (v >> 24))
+ * (byte)(0xff & (v >> 16))
+ * (byte)(0xff & (v >>    8))
+ * (byte)(0xff & v)
+ * </code></pre><p>
+ * The bytes written by this method may be read
+ * by the <code>readInt</code> method of interface
+ * <code>DataInput</code> , which will then
+ * return an <code>int</code> equal to <code>v</code>.
+ *
+ * @param v the <code>int</code> value to be written.
+ * @exception IOException if an I/O error occurs.
+ */
+ public void writeInt(int v) throws IOException {
+ dataOutput.writeInt(v);
+ }
+
+ /**
+ * Writes a <code>long</code> value, which is
+ * comprised of eight bytes, to the output stream.
+ * The byte values to be written, in the order
+ * shown, are:
+ * <p><pre><code>
+ * (byte)(0xff & (v >> 56))
+ * (byte)(0xff & (v >> 48))
+ * (byte)(0xff & (v >> 40))
+ * (byte)(0xff & (v >> 32))
+ * (byte)(0xff & (v >> 24))
+ * (byte)(0xff & (v >> 16))
+ * (byte)(0xff & (v >> 8))
+ * (byte)(0xff & v)
+ * </code></pre><p>
+ * The bytes written by this method may be
+ * read by the <code>readLong</code> method
+ * of interface <code>DataInput</code> , which
+ * will then return a <code>long</code> equal
+ * to <code>v</code>.
+ *
+ * @param v the <code>long</code> value to be written.
+ * @exception IOException if an I/O error occurs.
+ */
+ public void writeLong(long v) throws IOException {
+ dataOutput.writeLong(v);
+ }
+
+ /**
+ * Writes a <code>float</code> value,
+ * which is comprised of four bytes, to the output stream.
+ * It does this as if it first converts this
+ * <code>float</code> value to an <code>int</code>
+ * in exactly the manner of the <code>Float.floatToIntBits</code>
+ * method and then writes the <code>int</code>
+ * value in exactly the manner of the <code>writeInt</code>
+ * method. The bytes written by this method
+ * may be read by the <code>readFloat</code>
+ * method of interface <code>DataInput</code>,
+ * which will then return a <code>float</code>
+ * equal to <code>v</code>.
+ *
+ * @param v the <code>float</code> value to be written.
+ * @exception IOException if an I/O error occurs.
+ */
+ public void writeFloat(float v) throws IOException {
+ dataOutput.writeFloat(v);
+ }
+
+ /**
+ * Writes a <code>double</code> value,
+ * which is comprised of eight bytes, to the output stream.
+ * It does this as if it first converts this
+ * <code>double</code> value to a <code>long</code>
+ * in exactly the manner of the <code>Double.doubleToLongBits</code>
+ * method and then writes the <code>long</code>
+ * value in exactly the manner of the <code>writeLong</code>
+ * method. The bytes written by this method
+ * may be read by the <code>readDouble</code>
+ * method of interface <code>DataInput</code>,
+ * which will then return a <code>double</code>
+ * equal to <code>v</code>.
+ *
+ * @param v the <code>double</code> value to be written.
+ * @exception IOException if an I/O error occurs.
+ */
+ public void writeDouble(double v) throws IOException {
+ dataOutput.writeDouble(v);
+ }
+
+ /**
+ * Writes a string to the output stream.
+ * For every character in the string
+ * <code>s</code>, taken in order, one byte
+ * is written to the output stream. If
+ * <code>s</code> is <code>null</code>, a <code>NullPointerException</code>
+ * is thrown.<p> If <code>s.length</code>
+ * is zero, then no bytes are written. Otherwise,
+ * the character <code>s[0]</code> is written
+ * first, then <code>s[1]</code>, and so on;
+ * the last character written is <code>s[s.length-1]</code>.
+ * For each character, one byte is written,
+ * the low-order byte, in exactly the manner
+ * of the <code>writeByte</code> method . The
+ * high-order eight bits of each character
+ * in the string are ignored.
+ *
+ * @param s the string of bytes to be written.
+ * @exception IOException if an I/O error occurs.
+ */
+ public void writeBytes(String s) throws IOException {
+ dataOutput.writeBytes(s);
+ }
+
+ /**
+ * Writes every character in the string <code>s</code>,
+ * to the output stream, in order,
+ * two bytes per character. If <code>s</code>
+ * is <code>null</code>, a <code>NullPointerException</code>
+ * is thrown. If <code>s.length</code>
+ * is zero, then no characters are written.
+ * Otherwise, the character <code>s[0]</code>
+ * is written first, then <code>s[1]</code>,
+ * and so on; the last character written is
+ * <code>s[s.length-1]</code>. For each character,
+ * two bytes are actually written, high-order
+ * byte first, in exactly the manner of the
+ * <code>writeChar</code> method.
+ *
+ * @param s the string value to be written.
+ * @exception IOException if an I/O error occurs.
+ */
+ public void writeChars(String s) throws IOException {
+ dataOutput.writeChars(s);
+ }
+
+ /**
+ * Writes two bytes of length information
+ * to the output stream, followed
+ * by the
+ * <a href="DataInput.html#modified-utf-8">modified UTF-8</a>
+ * representation
+ * of every character in the string <code>s</code>.
+ * If <code>s</code> is <code>null</code>,
+ * a <code>NullPointerException</code> is thrown.
+ * Each character in the string <code>s</code>
+ * is converted to a group of one, two, or
+ * three bytes, depending on the value of the
+ * character.<p>
+ * If a character <code>c</code>
+ * is in the range <code>\u0001</code> through
+ * <code>\u007f</code>, it is represented
+ * by one byte:<p>
+ * <pre>(byte)c </pre> <p>
+ * If a character <code>c</code> is <code>\u0000</code>
+ * or is in the range <code>\u0080</code>
+ * through <code>\u07ff</code>, then it is
+ * represented by two bytes, to be written
+ * in the order shown:<p> <pre><code>
+ * (byte)(0xc0 | (0x1f & (c >> 6)))
+ * (byte)(0x80 | (0x3f & c))
+ * </code></pre> <p> If a character
+ * <code>c</code> is in the range <code>\u0800</code>
+ * through <code>uffff</code>, then it is
+ * represented by three bytes, to be written
+ * in the order shown:<p> <pre><code>
+ * (byte)(0xe0 | (0x0f & (c >> 12)))
+ * (byte)(0x80 | (0x3f & (c >> 6)))
+ * (byte)(0x80 | (0x3f & c))
+ * </code></pre> <p> First,
+ * the total number of bytes needed to represent
+ * all the characters of <code>s</code> is
+ * calculated. If this number is larger than
+ * <code>65535</code>, then a <code>UTFDataFormatException</code>
+ * is thrown. Otherwise, this length is written
+ * to the output stream in exactly the manner
+ * of the <code>writeShort</code> method;
+ * after this, the one-, two-, or three-byte
+ * representation of each character in the
+ * string <code>s</code> is written.<p> The
+ * bytes written by this method may be read
+ * by the <code>readUTF</code> method of interface
+ * <code>DataInput</code> , which will then
+ * return a <code>String</code> equal to <code>s</code>.
+ *
+ * @param str the string value to be written.
+ * @exception IOException if an I/O error occurs.
+ */
+ public void writeUTF(String str) throws IOException {
+ dataOutput.writeUTF(str);
+ }
+}
Copied: labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/common/DroolsObjectStreamConstants.java (from rev 19160, labs/jbossrules/dev_tags/before_righttuple_merge_20080320/drools-core/src/main/java/org/drools/common/DroolsObjectStreamConstants.java)
===================================================================
--- labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/common/DroolsObjectStreamConstants.java (rev 0)
+++ labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/common/DroolsObjectStreamConstants.java 2008-03-20 19:32:10 UTC (rev 19164)
@@ -0,0 +1,20 @@
+package org.drools.common;
+
+public interface DroolsObjectStreamConstants {
+ int STREAM_MAGIC = 0x001500d2;
+ short STREAM_VERSION = 400;
+
+ byte RT_CLASS = 11;
+ byte RT_SERIALIZABLE = 12;
+ byte RT_REFERENCE = 13;
+ byte RT_EMPTY_SET = 14;
+ byte RT_EMPTY_LIST = 15;
+ byte RT_EMPTY_MAP = 16;
+ byte RT_MAP = 17;
+ byte RT_ARRAY = 18;
+ byte RT_STRING = 19;
+ byte RT_NULL = 20;
+ byte RT_COLLECTION = 21;
+ byte RT_EXTERNALIZABLE = 22;
+ byte RT_ATOMICREFERENCEARRAY = 30;
+}
Modified: labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/common/EmptyBetaConstraints.java
===================================================================
--- labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/common/EmptyBetaConstraints.java 2008-03-20 18:57:07 UTC (rev 19163)
+++ labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/common/EmptyBetaConstraints.java 2008-03-20 19:32:10 UTC (rev 19164)
@@ -2,13 +2,13 @@
/*
* Copyright 2005 JBoss Inc
- *
+ *
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -16,8 +16,6 @@
* limitations under the License.
*/
-import java.io.Serializable;
-
import org.drools.RuleBaseConfiguration;
import org.drools.reteoo.BetaMemory;
import org.drools.reteoo.FactHandleMemory;
@@ -28,9 +26,12 @@
import org.drools.util.LinkedList;
import org.drools.util.TupleHashTable;
+import java.io.IOException;
+import java.io.ObjectInput;
+import java.io.ObjectOutput;
+
public class EmptyBetaConstraints
implements
- Serializable,
BetaConstraints {
private static final BetaConstraints INSTANCE = new EmptyBetaConstraints();
@@ -41,13 +42,18 @@
}
/**
- *
+ *
*/
private static final long serialVersionUID = 400L;
- private EmptyBetaConstraints() {
+ public EmptyBetaConstraints() {
}
+ public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
+ }
+
+ public void writeExternal(ObjectOutput out) throws IOException {
+ }
/* (non-Javadoc)
* @see org.drools.common.BetaNodeConstraints#updateFromTuple(org.drools.reteoo.ReteTuple)
*/
@@ -120,10 +126,10 @@
/**
* Determine if another object is equal to this.
- *
+ *
* @param object
* The object to test.
- *
+ *
* @return <code>true</code> if <code>object</code> is equal to this,
* otherwise <code>false</code>.
*/
Modified: labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/common/EqualityAssertMapComparator.java
===================================================================
--- labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/common/EqualityAssertMapComparator.java 2008-03-20 18:57:07 UTC (rev 19163)
+++ labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/common/EqualityAssertMapComparator.java 2008-03-20 19:32:10 UTC (rev 19164)
@@ -2,13 +2,13 @@
/*
* Copyright 2005 JBoss Inc
- *
+ *
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -20,17 +20,27 @@
import org.drools.base.ShadowProxy;
import org.drools.util.AbstractHashTable.ObjectComparator;
+import java.io.IOException;
+import java.io.ObjectOutput;
+import java.io.ObjectInput;
+
public class EqualityAssertMapComparator
implements
ObjectComparator {
/**
- *
+ *
*/
private static final long serialVersionUID = 400L;
public EqualityAssertMapComparator() {
}
+ public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
+ }
+
+ public void writeExternal(ObjectOutput out) throws IOException {
+ }
+
public int hashCodeOf(final Object obj) {
if ( obj instanceof FactHandle ) {
return rehash( ((InternalFactHandle) obj).getObjectHashCode() );
Modified: labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/common/EqualityKey.java
===================================================================
--- labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/common/EqualityKey.java 2008-03-20 18:57:07 UTC (rev 19163)
+++ labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/common/EqualityKey.java 2008-03-20 19:32:10 UTC (rev 19164)
@@ -2,13 +2,13 @@
/*
* Copyright 2005 JBoss Inc
- *
+ *
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -16,7 +16,10 @@
* limitations under the License.
*/
-import java.io.Serializable;
+import java.io.Externalizable;
+import java.io.ObjectOutput;
+import java.io.IOException;
+import java.io.ObjectInput;
import java.util.ArrayList;
import java.util.List;
@@ -24,16 +27,16 @@
/**
* Upon instantiation the EqualityKey caches the first Object's hashCode
- * this can never change. The EqualityKey has an internal datastructure
+ * this can never change. The EqualityKey has an internal datastructure
* which references all the handles which are equal. It also records
* Whether the referenced facts are JUSTIFIED or STATED
- *
+ *
* @author <a href="mailto:mark.proctor at jboss.com">Mark Proctor</a>
*
*/
public class EqualityKey
implements
- Serializable {
+ Externalizable {
public final static int STATED = 1;
public final static int JUSTIFIED = 2;
@@ -44,11 +47,15 @@
private List instances;
/** This is cached in the constructor from the first added Object */
- private final int hashCode;
+ private int hashCode;
/** Tracks whether this Fact is Stated or Justified */
private int status;
+ public EqualityKey() {
+
+ }
+
public EqualityKey(final InternalFactHandle handle) {
this.handle = handle;
this.hashCode = handle.getObjectHashCode();
@@ -61,6 +68,20 @@
this.status = status;
}
+ public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
+ handle = (InternalFactHandle)in.readObject();
+ instances = (List)in.readObject();
+ hashCode = in.readInt();
+ status = in.readInt();
+ }
+
+ public void writeExternal(ObjectOutput out) throws IOException {
+ out.writeObject(handle);
+ out.writeObject(instances);
+ out.writeInt(hashCode);
+ out.writeInt(status);
+ }
+
public InternalFactHandle getFactHandle() {
return this.handle;
}
@@ -84,7 +105,7 @@
this.handle = (InternalFactHandle) this.instances.remove( 0 );
if ( this.instances.isEmpty() ) {
this.instances = null;
- }
+ }
}
} else {
this.instances.remove( handle );
@@ -142,10 +163,10 @@
}
/**
- * Equality for the EqualityKey means two things. It returns
+ * Equality for the EqualityKey means two things. It returns
* true if the object is also an EqualityKey the of the same
* the same identity as this. It also returns true if the object
- * is equal to the head FactHandle's referenced Object.
+ * is equal to the head FactHandle's referenced Object.
*/
public boolean equals(final Object object) {
if ( object == null ) {
@@ -155,7 +176,7 @@
if ( object instanceof EqualityKey ) {
return this == object;
}
-
+
return (this.handle.getObject().equals( object ));
}
Modified: labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/common/EqualityKeyComparator.java
===================================================================
--- labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/common/EqualityKeyComparator.java 2008-03-20 18:57:07 UTC (rev 19163)
+++ labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/common/EqualityKeyComparator.java 2008-03-20 19:32:10 UTC (rev 19164)
@@ -2,13 +2,13 @@
/*
* Copyright 2005 JBoss Inc
- *
+ *
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -18,11 +18,15 @@
import org.drools.util.AbstractHashTable.ObjectComparator;
+import java.io.ObjectOutput;
+import java.io.IOException;
+import java.io.ObjectInput;
+
public class EqualityKeyComparator
implements
ObjectComparator {
/**
- *
+ *
*/
private static final long serialVersionUID = 400L;
@@ -36,6 +40,12 @@
return EqualityKeyComparator.instance;
}
+ public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
+ }
+
+ public void writeExternal(ObjectOutput out) throws IOException {
+ }
+
public int hashCodeOf(final Object key) {
return rehash( key.hashCode() );
}
Modified: labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/common/EventFactHandle.java
===================================================================
--- labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/common/EventFactHandle.java 2008-03-20 18:57:07 UTC (rev 19163)
+++ labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/common/EventFactHandle.java 2008-03-20 19:32:10 UTC (rev 19164)
@@ -2,13 +2,17 @@
import org.drools.FactHandle;
+import java.io.ObjectOutput;
+import java.io.ObjectInput;
+import java.io.IOException;
+
public class EventFactHandle extends DefaultFactHandle {
private static final long serialVersionUID = 5997141759543399455L;
-
- private final long startTimestamp;
- private final long duration;
+ private long startTimestamp;
+ private long duration;
+
// ----------------------------------------------------------------------
// Constructors
// ----------------------------------------------------------------------
@@ -29,7 +33,7 @@
/**
* Construct.
- *
+ *
* @param id
* Handle id.
*/
@@ -42,10 +46,10 @@
this.startTimestamp = 0;
this.duration = 0;
}
-
+
/**
* Creates a new event fact handle.
- *
+ *
* @param id this event fact handle ID
* @param object the event object encapsulated in this event fact handle
* @param recency the recency of this event fact handle
@@ -58,12 +62,26 @@
final long timestamp,
final long duration ) {
super( id,
- object,
+ object,
recency );
this.startTimestamp = timestamp;
this.duration = duration;
}
-
+
+ public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
+ super.readExternal(in);
+ startTimestamp = in.readLong();
+ duration = in.readLong();
+
+ }
+
+ public void writeExternal(ObjectOutput out) throws IOException {
+ super.writeExternal(out);
+ out.writeLong(startTimestamp);
+ out.writeLong(duration);
+ }
+
+
/**
* @see FactHandle
*/
@@ -95,9 +113,9 @@
}
/**
- * Returns the duration of this event. In case this is a primitive event,
+ * Returns the duration of this event. In case this is a primitive event,
* returns 0 (zero).
- *
+ *
* @return
*/
public long getDuration() {
@@ -106,9 +124,9 @@
/**
* Returns the end timestamp for this event. This is the same as:
- *
+ *
* startTimestamp + duration
- *
+ *
* @return
*/
public long getEndTimestamp() {
Modified: labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/common/IdentityAssertMapComparator.java
===================================================================
--- labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/common/IdentityAssertMapComparator.java 2008-03-20 18:57:07 UTC (rev 19163)
+++ labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/common/IdentityAssertMapComparator.java 2008-03-20 19:32:10 UTC (rev 19164)
@@ -2,13 +2,13 @@
/*
* Copyright 2005 JBoss Inc
- *
+ *
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -20,17 +20,27 @@
import org.drools.base.ShadowProxy;
import org.drools.util.AbstractHashTable.ObjectComparator;
+import java.io.IOException;
+import java.io.ObjectOutput;
+import java.io.ObjectInput;
+
public class IdentityAssertMapComparator
implements
ObjectComparator {
/**
- *
+ *
*/
private static final long serialVersionUID = 400L;
public IdentityAssertMapComparator() {
}
+ public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
+ }
+
+ public void writeExternal(ObjectOutput out) throws IOException {
+ }
+
public int hashCodeOf(final Object obj) {
Object realObject = obj;
if ( realObject instanceof FactHandle ) {
Modified: labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/common/InstanceEqualsConstraint.java
===================================================================
--- labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/common/InstanceEqualsConstraint.java 2008-03-20 18:57:07 UTC (rev 19163)
+++ labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/common/InstanceEqualsConstraint.java 2008-03-20 19:32:10 UTC (rev 19164)
@@ -1,12 +1,12 @@
/*
* Copyright 2005 JBoss Inc
- *
+ *
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -22,11 +22,15 @@
import org.drools.rule.Declaration;
import org.drools.spi.BetaNodeFieldConstraint;
+import java.io.ObjectInput;
+import java.io.IOException;
+import java.io.ObjectOutput;
+
/**
* InstanceEqualsConstraint
*
* Created: 21/06/2006
- * @author <a href="mailto:tirelli at post.com">Edson Tirelli</a>
+ * @author <a href="mailto:tirelli at post.com">Edson Tirelli</a>
*
* @version $Id$
*/
@@ -37,14 +41,27 @@
private static final long serialVersionUID = 400L;
- private final Declaration[] declarations = new Declaration[0];
+ private Declaration[] declarations = new Declaration[0];
private Pattern otherPattern;
+ public InstanceEqualsConstraint() {
+ }
+
public InstanceEqualsConstraint(final Pattern otherPattern) {
this.otherPattern = otherPattern;
}
+ public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
+ declarations = (Declaration[])in.readObject();
+ otherPattern = (Pattern)in.readObject();
+ }
+
+ public void writeExternal(ObjectOutput out) throws IOException {
+ out.writeObject(declarations);
+ out.writeObject(otherPattern);
+ }
+
public Declaration[] getRequiredDeclarations() {
return this.declarations;
}
@@ -109,10 +126,27 @@
private Pattern pattern;
private ContextEntry entry;
+ public InstanceEqualsConstraintContextEntry() {
+ }
+
public InstanceEqualsConstraintContextEntry(final Pattern pattern) {
this.pattern = pattern;
}
+ public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
+ left = in.readObject();
+ right = in.readObject();
+ pattern = (Pattern)in.readObject();
+ entry = (ContextEntry)in.readObject();
+ }
+
+ public void writeExternal(ObjectOutput out) throws IOException {
+ out.writeObject(left);
+ out.writeObject(right);
+ out.writeObject(pattern);
+ out.writeObject(entry);
+ }
+
public ContextEntry getNext() {
return this.entry;
}
@@ -130,14 +164,14 @@
final InternalFactHandle handle) {
this.right = handle.getObject();
}
-
+
public void resetTuple() {
this.left = null;
}
-
+
public void resetFactHandle() {
this.right = null;
- }
+ }
}
public ConstraintType getType() {
Modified: labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/common/InstanceNotEqualsConstraint.java
===================================================================
--- labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/common/InstanceNotEqualsConstraint.java 2008-03-20 18:57:07 UTC (rev 19163)
+++ labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/common/InstanceNotEqualsConstraint.java 2008-03-20 19:32:10 UTC (rev 19164)
@@ -2,13 +2,13 @@
/*
* Copyright 2005 JBoss Inc
- *
+ *
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -22,24 +22,43 @@
import org.drools.rule.Pattern;
import org.drools.spi.BetaNodeFieldConstraint;
+import java.io.ObjectOutput;
+import java.io.IOException;
+import java.io.ObjectInput;
+
public class InstanceNotEqualsConstraint
implements
BetaNodeFieldConstraint {
private static final long serialVersionUID = 400L;
- private static final Declaration[] declarations = new Declaration[0];
+ private static Declaration[] declarations = new Declaration[0];
private Pattern otherPattern;
+ public InstanceNotEqualsConstraint() {
+
+ }
+
public InstanceNotEqualsConstraint(final Pattern otherPattern) {
this.otherPattern = otherPattern;
+
}
+ public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
+ declarations = (Declaration[])in.readObject();
+ otherPattern = (Pattern)in.readObject();
+ }
+
+ public void writeExternal(ObjectOutput out) throws IOException {
+ out.writeObject(declarations);
+ out.writeObject(otherPattern);
+ }
+
public Declaration[] getRequiredDeclarations() {
return InstanceNotEqualsConstraint.declarations;
}
-
+
public void replaceDeclaration(Declaration oldDecl,
Declaration newDecl) {
}
@@ -87,7 +106,7 @@
final InstanceNotEqualsConstraint other = (InstanceNotEqualsConstraint) object;
return this.otherPattern.equals( other.otherPattern );
}
-
+
public Object clone() {
return new InstanceNotEqualsConstraint( this.otherPattern );
}
@@ -107,10 +126,27 @@
private Pattern pattern;
private ContextEntry entry;
+ public InstanceNotEqualsConstraintContextEntry() {
+ }
+
public InstanceNotEqualsConstraintContextEntry(final Pattern pattern) {
this.pattern = pattern;
}
+ public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
+ left = in.readObject();
+ right = in.readObject();
+ pattern = (Pattern)in.readObject();
+ entry = (ContextEntry)in.readObject();
+ }
+
+ public void writeExternal(ObjectOutput out) throws IOException {
+ out.writeObject(left);
+ out.writeObject(right);
+ out.writeObject(pattern);
+ out.writeObject(entry);
+ }
+
public ContextEntry getNext() {
return this.entry;
}
@@ -128,14 +164,14 @@
final InternalFactHandle handle) {
this.right = handle.getObject();
}
-
+
public void resetTuple() {
this.left = null;
}
-
+
public void resetFactHandle() {
this.right = null;
- }
+ }
}
}
\ No newline at end of file
Modified: labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/common/InternalWorkingMemory.java
===================================================================
--- labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/common/InternalWorkingMemory.java 2008-03-20 18:57:07 UTC (rev 19163)
+++ labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/common/InternalWorkingMemory.java 2008-03-20 19:32:10 UTC (rev 19164)
@@ -1,6 +1,5 @@
package org.drools.common;
-import java.util.Map;
import java.util.concurrent.locks.Lock;
import org.drools.FactException;
@@ -12,10 +11,7 @@
import org.drools.event.WorkingMemoryEventSupport;
import org.drools.process.instance.ProcessInstance;
import org.drools.process.instance.ProcessInstanceFactory;
-import org.drools.reteoo.EntryPointNode;
import org.drools.reteoo.LIANodePropagation;
-import org.drools.reteoo.ObjectTypeConf;
-import org.drools.rule.EntryPoint;
import org.drools.rule.Rule;
import org.drools.rule.TimeMachine;
import org.drools.spi.Activation;
Modified: labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/common/InternalWorkingMemoryActions.java
===================================================================
--- labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/common/InternalWorkingMemoryActions.java 2008-03-20 18:57:07 UTC (rev 19163)
+++ labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/common/InternalWorkingMemoryActions.java 2008-03-20 19:32:10 UTC (rev 19164)
@@ -2,13 +2,13 @@
/*
* Copyright 2005 JBoss Inc
- *
+ *
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -41,10 +41,10 @@
boolean logical,
Rule rule,
Activation activation) throws FactException;
-
+
public FactHandle insertLogical(Object object,
boolean dynamic) throws FactException;
-
+
public void modifyRetract(final FactHandle factHandle,
final Rule rule,
final Activation activation);
@@ -53,5 +53,5 @@
final Object object,
final Rule rule,
final Activation activation);
-
+
}
\ No newline at end of file
Modified: labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/common/NetworkNode.java
===================================================================
--- labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/common/NetworkNode.java 2008-03-20 18:57:07 UTC (rev 19163)
+++ labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/common/NetworkNode.java 2008-03-20 19:32:10 UTC (rev 19164)
@@ -2,13 +2,13 @@
/*
* Copyright 2005 JBoss Inc
- *
+ *
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -16,19 +16,19 @@
* limitations under the License.
*/
-import java.io.Serializable;
+import java.io.Externalizable;
/**
* Interface used to expose generic information on Rete nodes outside of he package. It is used
* for exposing information events.
- *
+ *
* @author <a href="mailto:mark.proctor at jboss.com">Mark Proctor</a>
* @author <a href="mailto:bob at werken.com">Bob McWhirter</a>
*
*/
public interface NetworkNode
extends
- Serializable {
+ Externalizable {
/**
* Returns the unique id that represents the node in the Rete network
Modified: labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/common/NodeMemories.java
===================================================================
--- labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/common/NodeMemories.java 2008-03-20 18:57:07 UTC (rev 19163)
+++ labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/common/NodeMemories.java 2008-03-20 19:32:10 UTC (rev 19164)
@@ -1,12 +1,12 @@
/*
* Copyright 2008 JBoss Inc
- *
+ *
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -18,17 +18,17 @@
package org.drools.common;
-import java.io.Serializable;
+import java.io.Externalizable;
/**
* An interface for node memories implementation
- *
+ *
* @author etirelli
*/
-public interface NodeMemories extends Serializable {
-
+public interface NodeMemories extends Externalizable {
+
public Object getNodeMemory( NodeMemory node );
-
+
public void clearNodeMemory( NodeMemory node );
public void setRuleBaseReference(InternalRuleBase ruleBase);
Modified: labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/common/PriorityQueueAgendaGroupFactory.java
===================================================================
--- labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/common/PriorityQueueAgendaGroupFactory.java 2008-03-20 18:57:07 UTC (rev 19163)
+++ labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/common/PriorityQueueAgendaGroupFactory.java 2008-03-20 19:32:10 UTC (rev 19164)
@@ -1,18 +1,27 @@
package org.drools.common;
-import java.io.Serializable;
+import java.io.Externalizable;
+import java.io.ObjectOutput;
+import java.io.IOException;
+import java.io.ObjectInput;
import org.drools.spi.AgendaGroup;
-public class PriorityQueueAgendaGroupFactory implements AgendaGroupFactory, Serializable {
+public class PriorityQueueAgendaGroupFactory implements AgendaGroupFactory, Externalizable {
private static final AgendaGroupFactory INSTANCE = new PriorityQueueAgendaGroupFactory();
-
+
+ public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
+ }
+
+ public void writeExternal(ObjectOutput out) throws IOException {
+ }
+
public static AgendaGroupFactory getInstance() {
return INSTANCE;
}
-
+
public AgendaGroup createAgendaGroup(String name, InternalRuleBase ruleBase) {
return new BinaryHeapQueueAgendaGroup( name,
- ruleBase );
+ ruleBase );
}
}
Modified: labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/common/PropagationContextImpl.java
===================================================================
--- labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/common/PropagationContextImpl.java 2008-03-20 18:57:07 UTC (rev 19163)
+++ labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/common/PropagationContextImpl.java 2008-03-20 19:32:10 UTC (rev 19164)
@@ -2,13 +2,13 @@
/*
* Copyright 2005 JBoss Inc
- *
+ *
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -23,28 +23,36 @@
import org.drools.spi.PropagationContext;
import org.drools.util.ObjectHashMap;
+import java.io.ObjectInput;
+import java.io.ObjectOutput;
+import java.io.IOException;
+
public class PropagationContextImpl
implements
PropagationContext {
private static final long serialVersionUID = 8400185220119865618L;
- private final int type;
+ private int type;
private Rule rule;
private Activation activation;
- private final long propagationNumber;
+ private long propagationNumber;
- public final int activeActivations;
+ public int activeActivations;
- public final int dormantActivations;
+ public int dormantActivations;
public ObjectHashMap retracted;
private EntryPoint entryPoint;
+ public PropagationContextImpl() {
+
+ }
+
public PropagationContextImpl(final long number,
final int type,
final Rule rule,
@@ -74,13 +82,35 @@
this.entryPoint = entryPoint;
}
+ public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
+ type = in.readInt();
+ activeActivations = in.readInt();
+ dormantActivations = in.readInt();
+ propagationNumber = in.readLong();
+ rule = (Rule)in.readObject();
+ activation = (Activation)in.readObject();
+ retracted = (ObjectHashMap)in.readObject();
+ entryPoint = (EntryPoint)in.readObject();
+ }
+
+ public void writeExternal(ObjectOutput out) throws IOException {
+ out.writeInt(type);
+ out.writeInt(activeActivations);
+ out.writeInt(dormantActivations);
+ out.writeLong(propagationNumber);
+ out.writeObject(rule);
+ out.writeObject(activation);
+ out.writeObject(retracted);
+ out.writeObject(entryPoint);
+ }
+
public long getPropagationNumber() {
return this.propagationNumber;
}
/*
* (non-Javadoc)
- *
+ *
* @see org.drools.reteoo.PropagationContext#getRuleOrigin()
*/
public Rule getRuleOrigin() {
@@ -89,7 +119,7 @@
/*
* (non-Javadoc)
- *
+ *
* @see org.drools.reteoo.PropagationContext#getActivationOrigin()
*/
public Activation getActivationOrigin() {
@@ -98,7 +128,7 @@
/*
* (non-Javadoc)
- *
+ *
* @see org.drools.reteoo.PropagationContext#getType()
*/
public int getType() {
Modified: labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/common/QuadroupleBetaConstraints.java
===================================================================
--- labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/common/QuadroupleBetaConstraints.java 2008-03-20 18:57:07 UTC (rev 19163)
+++ labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/common/QuadroupleBetaConstraints.java 2008-03-20 19:32:10 UTC (rev 19164)
@@ -2,13 +2,13 @@
/*
* Copyright 2005 JBoss Inc
- *
+ *
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -16,10 +16,6 @@
* limitations under the License.
*/
-import java.io.Serializable;
-import java.util.ArrayList;
-import java.util.List;
-
import org.drools.RuleBaseConfiguration;
import org.drools.base.evaluators.Operator;
import org.drools.reteoo.BetaMemory;
@@ -29,6 +25,7 @@
import org.drools.rule.ContextEntry;
import org.drools.rule.VariableConstraint;
import org.drools.spi.BetaNodeFieldConstraint;
+import org.drools.util.AbstractHashTable.FieldIndex;
import org.drools.util.FactHandleIndexHashTable;
import org.drools.util.FactHashTable;
import org.drools.util.FactList;
@@ -36,28 +33,35 @@
import org.drools.util.LinkedListEntry;
import org.drools.util.TupleHashTable;
import org.drools.util.TupleIndexHashTable;
-import org.drools.util.AbstractHashTable.FieldIndex;
+import java.io.IOException;
+import java.io.ObjectInput;
+import java.io.ObjectOutput;
+import java.util.ArrayList;
+import java.util.List;
+
public class QuadroupleBetaConstraints
implements
- Serializable,
BetaConstraints {
/**
- *
+ *
*/
private static final long serialVersionUID = 400L;
- private final BetaNodeFieldConstraint constraint0;
- private final BetaNodeFieldConstraint constraint1;
- private final BetaNodeFieldConstraint constraint2;
- private final BetaNodeFieldConstraint constraint3;
+ private BetaNodeFieldConstraint constraint0;
+ private BetaNodeFieldConstraint constraint1;
+ private BetaNodeFieldConstraint constraint2;
+ private BetaNodeFieldConstraint constraint3;
private boolean indexed0;
private boolean indexed1;
private boolean indexed2;
private boolean indexed3;
+ public QuadroupleBetaConstraints() {
+ }
+
public QuadroupleBetaConstraints(final BetaNodeFieldConstraint[] constraints,
final RuleBaseConfiguration conf) {
this( constraints,
@@ -76,7 +80,7 @@
} else {
final int depth = conf.getCompositeKeyDepth();
- // Determine if this constraints are indexable
+ // Determine if this constraints are indexable
final boolean i0 = isIndexable( constraints[0] );
final boolean i1 = isIndexable( constraints[1] );
final boolean i2 = isIndexable( constraints[2] );
@@ -141,6 +145,30 @@
this.constraint3 = constraints[3];
}
+ public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
+ constraint0 = (BetaNodeFieldConstraint)in.readObject();
+ constraint1 = (BetaNodeFieldConstraint)in.readObject();
+ constraint2 = (BetaNodeFieldConstraint)in.readObject();
+ constraint3 = (BetaNodeFieldConstraint)in.readObject();
+
+ indexed0 = in.readBoolean();
+ indexed1 = in.readBoolean();
+ indexed2 = in.readBoolean();
+ indexed3 = in.readBoolean();
+ }
+
+ public void writeExternal(ObjectOutput out) throws IOException {
+ out.writeObject(constraint0);
+ out.writeObject(constraint1);
+ out.writeObject(constraint2);
+ out.writeObject(constraint3);
+
+ out.writeBoolean(indexed0);
+ out.writeBoolean(indexed1);
+ out.writeBoolean(indexed2);
+ out.writeBoolean(indexed3);
+ }
+
private void swap(final BetaNodeFieldConstraint[] constraints,
final int p1,
final int p2) {
@@ -343,10 +371,10 @@
/**
* Determine if another object is equal to this.
- *
+ *
* @param object
* The object to test.
- *
+ *
* @return <code>true</code> if <code>object</code> is equal to this,
* otherwise <code>false</code>.
*/
Modified: labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/common/RuleFlowGroupImpl.java
===================================================================
--- labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/common/RuleFlowGroupImpl.java 2008-03-20 18:57:07 UTC (rev 19163)
+++ labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/common/RuleFlowGroupImpl.java 2008-03-20 19:32:10 UTC (rev 19164)
@@ -2,13 +2,13 @@
/*
* Copyright 2005 JBoss Inc
- *
+ *
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -18,6 +18,9 @@
import java.util.ArrayList;
import java.util.List;
+import java.io.IOException;
+import java.io.ObjectInput;
+import java.io.ObjectOutput;
import org.drools.spi.Activation;
import org.drools.util.Iterator;
@@ -31,8 +34,8 @@
* Deactivating the group removes all its activations from the agenda and
* collects them until it is activated again.
* By default, <code>RuleFlowGroups</code> are automatically deactivated when there are no more
- * activations in the <code>RuleFlowGroup</code>. However, this can be configured.
- *
+ * activations in the <code>RuleFlowGroup</code>. However, this can be configured.
+ *
* @author <a href="mailto:mark.proctor at jboss.com">Mark Proctor</a>
* @author <a href="mailto:kris_verlaenen at hotmail.com">Kris Verlaenen</a>
*
@@ -42,15 +45,18 @@
private static final long serialVersionUID = 400L;
private InternalWorkingMemory workingMemory;
- private final String name;
+ private String name;
private boolean active = false;
- private final LinkedList list;
+ private LinkedList list;
private boolean autoDeactivate = true;
private List<RuleFlowGroupListener> listeners;
+ public RuleFlowGroupImpl() {
+
+ }
/**
* Construct a <code>RuleFlowGroupImpl</code> with the given name.
- *
+ *
* @param name
* The RuleFlowGroup name.
*/
@@ -59,6 +65,24 @@
this.list = new LinkedList();
}
+ public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
+ workingMemory = (InternalWorkingMemory)in.readObject();
+ name = (String)in.readObject();
+ active = in.readBoolean();
+ list = (LinkedList)in.readObject();
+ autoDeactivate = in.readBoolean();
+ listeners = (List<RuleFlowGroupListener>)in.readObject();
+ }
+
+ public void writeExternal(ObjectOutput out) throws IOException {
+ out.writeObject(workingMemory);
+ out.writeObject(name);
+ out.writeBoolean(active);
+ out.writeObject(list);
+ out.writeBoolean(autoDeactivate);
+ out.writeObject(listeners);
+ }
+
public String getName() {
return this.name;
}
@@ -163,7 +187,7 @@
}
}
}
-
+
public void addRuleFlowGroupListener(RuleFlowGroupListener listener) {
if (listeners == null) {
listeners = new ArrayList<RuleFlowGroupListener>();
@@ -176,7 +200,7 @@
listeners.remove(listener);
}
}
-
+
public void notifyRuleFlowGroupListeners() {
if (listeners != null) {
for (java.util.Iterator<RuleFlowGroupListener> iterator = listeners.iterator(); iterator.hasNext(); ) {
@@ -215,12 +239,22 @@
public static class DeactivateCallback implements WorkingMemoryAction {
private static final long serialVersionUID = 400L;
- private final InternalRuleFlowGroup ruleFlowGroup;
+ private InternalRuleFlowGroup ruleFlowGroup;
+ public DeactivateCallback() {
+ }
public DeactivateCallback(InternalRuleFlowGroup ruleFlowGroup) {
this.ruleFlowGroup = ruleFlowGroup;
}
+ public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
+ ruleFlowGroup = (InternalRuleFlowGroup)in.readObject();
+ }
+
+ public void writeExternal(ObjectOutput out) throws IOException {
+ out.writeObject(ruleFlowGroup);
+ }
+
public void execute(InternalWorkingMemory workingMemory) {
// check whether ruleflow group is still empty first
if (this.ruleFlowGroup.isEmpty()) {
Modified: labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/common/ScheduledAgendaItem.java
===================================================================
--- labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/common/ScheduledAgendaItem.java 2008-03-20 18:57:07 UTC (rev 19163)
+++ labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/common/ScheduledAgendaItem.java 2008-03-20 19:32:10 UTC (rev 19164)
@@ -2,13 +2,13 @@
/*
* Copyright 2005 JBoss Inc
- *
+ *
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -16,7 +16,10 @@
* limitations under the License.
*/
-import java.io.Serializable;
+import java.io.Externalizable;
+import java.io.ObjectOutput;
+import java.io.IOException;
+import java.io.ObjectInput;
import java.util.TimerTask;
import org.drools.rule.GroupElement;
@@ -30,20 +33,20 @@
/**
* Item entry in the <code>Agenda</code>.
- *
+ *
* @author <a href="mailto:bob at eng.werken.com">bob mcwhirter </a>
*/
public class ScheduledAgendaItem extends TimerTask
implements
Activation,
- Serializable,
+ Externalizable,
LinkedListNode {
// ------------------------------------------------------------
// Instance members
// ------------------------------------------------------------
/**
- *
+ *
*/
private static final long serialVersionUID = 400L;
@@ -52,19 +55,19 @@
private LinkedListNode next;
/** The tuple. */
- private final Tuple tuple;
+ private Tuple tuple;
/** The rule. */
- private final Rule rule;
+ private Rule rule;
/** The subrule */
- private final GroupElement subrule;
+ private GroupElement subrule;
- private final InternalAgenda agenda;
+ private InternalAgenda agenda;
- private final PropagationContext context;
+ private PropagationContext context;
- private final long activationNumber;
+ private long activationNumber;
private LinkedList justified;
@@ -75,10 +78,13 @@
// ------------------------------------------------------------
// Constructors
// ------------------------------------------------------------
+ public ScheduledAgendaItem() {
+ }
+
/**
* Construct.
- *
+ *
* @param tuple
* The tuple.
* @param rule
@@ -101,17 +107,45 @@
// ------------------------------------------------------------
// Instance methods
// ------------------------------------------------------------
+ public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
+ previous = (LinkedListNode)in.readObject();
+ next = (LinkedListNode)in.readObject();
+ tuple = (Tuple)in.readObject();
+ rule = (Rule)in.readObject();
+ subrule = (GroupElement)in.readObject();
+ agenda = (InternalAgenda)in.readObject();
+ context = (PropagationContext)in.readObject();
+ activationNumber = in.readLong();
+ justified = (LinkedList)in.readObject();
+ activated = in.readBoolean();
+ activationGroupNode = (ActivationGroupNode)in.readObject();
+ }
+
+ public void writeExternal(ObjectOutput out) throws IOException {
+ out.writeObject(previous);
+ out.writeObject(next);
+ out.writeObject(tuple);
+ out.writeObject(rule);
+ out.writeObject(subrule);
+ out.writeObject(agenda);
+ out.writeObject(context);
+ out.writeLong(activationNumber);
+ out.writeObject(justified);
+ out.writeBoolean(activated);
+ out.writeObject(activationGroupNode);
+ }
+
public PropagationContext getPropagationContext() {
return this.context;
}
-
+
public int getSalience() {
throw new UnsupportedOperationException( "salience is now application to scheduled activations" );
}
/**
* Retrieve the rule.
- *
+ *
* @return The rule.
*/
public Rule getRule() {
@@ -120,7 +154,7 @@
/**
* Retrieve the tuple.
- *
+ *
* @return The tuple.
*/
public Tuple getTuple() {
@@ -205,7 +239,7 @@
/*
* (non-Javadoc)
- *
+ *
* @see java.lang.Object#equals(java.lang.Object)
*/
public boolean equals(final Object object) {
Modified: labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/common/SequentialAgendaGroupImpl.java
===================================================================
--- labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/common/SequentialAgendaGroupImpl.java 2008-03-20 18:57:07 UTC (rev 19163)
+++ labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/common/SequentialAgendaGroupImpl.java 2008-03-20 19:32:10 UTC (rev 19164)
@@ -2,13 +2,13 @@
/*
* Copyright 2005 JBoss Inc
- *
+ *
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -24,14 +24,18 @@
import org.drools.util.PrimitiveLongMap;
import org.drools.util.Queueable;
+import java.io.IOException;
+import java.io.ObjectInput;
+import java.io.ObjectOutput;
+
/**
* <code>AgendaGroup</code> implementation that uses a <code>PriorityQueue</code> to prioritise the evaluation of added
- * <code>ActivationQueue</code>s. The <code>AgendaGroup</code> also maintains a <code>Map</code> of <code>ActivationQueues</code>
+ * <code>ActivationQueue</code>s. The <code>AgendaGroup</code> also maintains a <code>Map</code> of <code>ActivationQueues</code>
* for requested salience values.
- *
+ *
* @see PriorityQueue
* @see ActivationQueue
- *
+ *
* @author <a href="mailto:mark.proctor at jboss.com">Mark Proctor</a>
* @author <a href="mailto:bob at werken.com">Bob McWhirter</a>
*
@@ -42,29 +46,46 @@
private static final long serialVersionUID = 400L;
- private final String name;
+ private String name;
/** Items in the agenda. */
//private final BinaryHeapQueue queue;
private PrimitiveLongMap queue;
private boolean active;
-
+
private long index;
+ public SequentialAgendaGroupImpl() {
+
+ }
+
/**
* Construct an <code>AgendaGroup</code> with the given name.
- *
+ *
* @param name
* The <AgendaGroup> name.
*/
-
-
+
+
public SequentialAgendaGroupImpl(final String name, final ConflictResolver conflictResolver) {
this.name = name;
this.queue = new PrimitiveLongMap();//new BinaryHeapQueue( conflictResolver );
- }
+ }
+ public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
+ name = (String)in.readObject();
+ queue = (PrimitiveLongMap)in.readObject();
+ active = in.readBoolean();
+ index = in.readLong();
+ }
+
+ public void writeExternal(ObjectOutput out) throws IOException {
+ out.writeObject(name);
+ out.writeObject(queue);
+ out.writeBoolean(active);
+ out.writeLong(index);
+ }
/* (non-Javadoc)
* @see org.drools.spi.AgendaGroup#getName()
*/
@@ -94,7 +115,7 @@
return null;
}
return ( Activation ) this.queue.get( index );
-//
+//
// if ( index > this.queue.size() ) {
// return null;
// } else {
@@ -113,7 +134,7 @@
/**
* Iterates a PriorityQueue removing empty entries until it finds a populated entry and return true,
* otherwise it returns false;
- *
+ *
* @param priorityQueue
* @return
*/
Modified: labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/common/SingleBetaConstraints.java
===================================================================
--- labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/common/SingleBetaConstraints.java 2008-03-20 18:57:07 UTC (rev 19163)
+++ labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/common/SingleBetaConstraints.java 2008-03-20 19:32:10 UTC (rev 19164)
@@ -2,22 +2,24 @@
/*
* Copyright 2005 JBoss Inc
- *
+ *
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
+import java.io.Externalizable;
+import java.io.ObjectInput;
+import java.io.IOException;
+import java.io.ObjectOutput;
-import java.io.Serializable;
-
import org.drools.RuleBaseConfiguration;
import org.drools.base.evaluators.Operator;
import org.drools.reteoo.BetaMemory;
@@ -38,20 +40,23 @@
public class SingleBetaConstraints
implements
- Serializable,
BetaConstraints {
/**
- *
+ *
*/
private static final long serialVersionUID = 400L;
- private final BetaNodeFieldConstraint constraint;
+ private BetaNodeFieldConstraint constraint;
private boolean indexed;
private RuleBaseConfiguration conf;
+ public SingleBetaConstraints() {
+
+ }
+
public SingleBetaConstraints(final BetaNodeFieldConstraint[] constraint,
final RuleBaseConfiguration conf) {
this( constraint[0],
@@ -81,6 +86,19 @@
this.constraint = constraint;
}
+ public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
+ constraint = (BetaNodeFieldConstraint)in.readObject();
+ indexed = in.readBoolean();
+ conf = (RuleBaseConfiguration)in.readObject();
+
+ }
+
+ public void writeExternal(ObjectOutput out) throws IOException {
+ out.writeObject(constraint);
+ out.writeBoolean(indexed);
+ out.writeObject(conf);
+ }
+
private boolean isIndexable(final BetaNodeFieldConstraint constraint) {
if ( constraint instanceof VariableConstraint ) {
final VariableConstraint variableConstraint = (VariableConstraint) constraint;
@@ -191,10 +209,10 @@
/**
* Determine if another object is equal to this.
- *
+ *
* @param object
* The object to test.
- *
+ *
* @return <code>true</code> if <code>object</code> is equal to this,
* otherwise <code>false</code>.
*/
Modified: labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/common/SingleThreadedObjectStore.java
===================================================================
--- labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/common/SingleThreadedObjectStore.java 2008-03-20 18:57:07 UTC (rev 19163)
+++ labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/common/SingleThreadedObjectStore.java 2008-03-20 19:32:10 UTC (rev 19164)
@@ -1,9 +1,12 @@
/**
- *
+ *
*/
package org.drools.common;
-import java.io.Serializable;
+import java.io.Externalizable;
+import java.io.ObjectOutput;
+import java.io.IOException;
+import java.io.ObjectInput;
import java.util.Iterator;
import java.util.concurrent.locks.Lock;
@@ -15,43 +18,61 @@
import org.drools.util.ObjectHashMap;
import org.drools.util.AbstractHashTable.HashTableIterator;
-public class SingleThreadedObjectStore implements Serializable, ObjectStore {
+public class SingleThreadedObjectStore implements Externalizable, ObjectStore {
/** Object-to-handle mapping. */
private ObjectHashMap assertMap;
private ObjectHashMap identityMap;
private AssertBehaviour behaviour;
private Lock lock;
-
+
+ public SingleThreadedObjectStore() {
+
+ }
+
public SingleThreadedObjectStore(RuleBaseConfiguration conf, Lock lock) {
this.behaviour = conf.getAssertBehaviour();
this.lock = lock;
-
- this.assertMap = new ObjectHashMap();
- if ( this.behaviour == AssertBehaviour.IDENTITY ) {
+ this.assertMap = new ObjectHashMap();
+
+ if ( AssertBehaviour.IDENTITY.equals(this.behaviour) ) {
this.assertMap.setComparator( new IdentityAssertMapComparator() );
this.identityMap = assertMap;
} else {
this.assertMap.setComparator( new EqualityAssertMapComparator() );
this.identityMap = new ObjectHashMap();
this.identityMap.setComparator( new IdentityAssertMapComparator() );
- }
+ }
}
-
+
+ public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
+ assertMap = (ObjectHashMap)in.readObject();
+ identityMap = (ObjectHashMap)in.readObject();
+ behaviour = (AssertBehaviour)in.readObject();
+ lock = (Lock)in.readObject();
+ }
+
+ public void writeExternal(ObjectOutput out) throws IOException {
+ out.writeObject(assertMap);
+ out.writeObject(identityMap);
+ out.writeObject(behaviour);
+ out.writeObject(lock);
+ }
+
/* (non-Javadoc)
* @see org.drools.common.ObjectStore#size()
*/
public int size() {
return this.assertMap.size();
}
-
+
/* (non-Javadoc)
* @see org.drools.common.ObjectStore#isEmpty()
*/
public boolean isEmpty() {
return this.assertMap != null;
}
-
+
/* (non-Javadoc)
* @see org.drools.common.ObjectStore#getObjectForHandle(org.drools.common.InternalFactHandle)
*/
@@ -74,23 +95,23 @@
return object;
} finally {
this.lock.unlock();
- }
+ }
}
-
+
/* (non-Javadoc)
* @see org.drools.common.ObjectStore#getHandleForObject(java.lang.Object)
*/
public InternalFactHandle getHandleForObject(Object object){
return (InternalFactHandle) this.assertMap.get( object );
}
-
+
/* (non-Javadoc)
* @see org.drools.common.ObjectStore#getHandleForObject(java.lang.Object)
*/
public InternalFactHandle getHandleForObjectIdentity(Object object) {
return (InternalFactHandle) this.identityMap.get( object );
}
-
+
/* (non-Javadoc)
* @see org.drools.common.ObjectStore#updateHandle(org.drools.common.InternalFactHandle, java.lang.Object)
*/
@@ -106,7 +127,7 @@
handle,
false );
}
-
+
/* (non-Javadoc)
* @see org.drools.common.ObjectStore#addHandle(org.drools.common.InternalFactHandle, java.lang.Object)
*/
@@ -114,7 +135,7 @@
this.assertMap.put( handle,
handle,
false );
- if ( this.behaviour == AssertBehaviour.EQUALITY ) {
+ if ( AssertBehaviour.EQUALITY.equals(this.behaviour) ) {
this.identityMap.put( handle,
handle,
false );
@@ -126,11 +147,11 @@
*/
public void removeHandle(final InternalFactHandle handle) {
this.assertMap.remove( handle );
- if ( this.behaviour == AssertBehaviour.EQUALITY ) {
+ if ( AssertBehaviour.EQUALITY.equals(this.behaviour) ) {
this.identityMap.remove( handle );
}
- }
-
+ }
+
/* (non-Javadoc)
* @see org.drools.common.ObjectStore#iterateObjects()
*/
@@ -171,6 +192,6 @@
return new JavaIteratorAdapter( iterator,
JavaIteratorAdapter.FACT_HANDLE,
filter );
- }
-
+ }
+
}
\ No newline at end of file
Modified: labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/common/TripleBetaConstraints.java
===================================================================
--- labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/common/TripleBetaConstraints.java 2008-03-20 18:57:07 UTC (rev 19163)
+++ labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/common/TripleBetaConstraints.java 2008-03-20 19:32:10 UTC (rev 19164)
@@ -2,13 +2,13 @@
/*
* Copyright 2005 JBoss Inc
- *
+ *
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -16,7 +16,9 @@
* limitations under the License.
*/
-import java.io.Serializable;
+import java.io.IOException;
+import java.io.ObjectInput;
+import java.io.ObjectOutput;
import java.util.ArrayList;
import java.util.List;
@@ -40,22 +42,24 @@
public class TripleBetaConstraints
implements
- Serializable,
BetaConstraints {
/**
- *
+ *
*/
private static final long serialVersionUID = 400L;
- private final BetaNodeFieldConstraint constraint0;
- private final BetaNodeFieldConstraint constraint1;
- private final BetaNodeFieldConstraint constraint2;
+ private BetaNodeFieldConstraint constraint0;
+ private BetaNodeFieldConstraint constraint1;
+ private BetaNodeFieldConstraint constraint2;
private boolean indexed0;
private boolean indexed1;
private boolean indexed2;
+ public TripleBetaConstraints() {
+ }
+
public TripleBetaConstraints(final BetaNodeFieldConstraint[] constraints,
final RuleBaseConfiguration conf) {
this( constraints,
@@ -73,7 +77,7 @@
} else {
final int depth = conf.getCompositeKeyDepth();
- // Determine if this constraints are indexable
+ // Determine if this constraints are indexable
final boolean i0 = isIndexable( constraints[0] );
final boolean i1 = isIndexable( constraints[1] );
final boolean i2 = isIndexable( constraints[2] );
@@ -114,6 +118,24 @@
this.constraint2 = constraints[2];
}
+ public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
+ constraint0 = (BetaNodeFieldConstraint)in.readObject();
+ constraint1 = (BetaNodeFieldConstraint)in.readObject();
+ constraint2 = (BetaNodeFieldConstraint)in.readObject();
+ indexed0 = in.readBoolean();
+ indexed1 = in.readBoolean();
+ indexed2 = in.readBoolean();
+ }
+
+ public void writeExternal(ObjectOutput out) throws IOException {
+ out.writeObject(constraint0);
+ out.writeObject(constraint1);
+ out.writeObject(constraint2);
+ out.writeBoolean(indexed0);
+ out.writeBoolean(indexed1);
+ out.writeBoolean(indexed2);
+ }
+
private void swap(final BetaNodeFieldConstraint[] constraints,
final int p1,
final int p2) {
@@ -294,10 +316,10 @@
/**
* Determine if another object is equal to this.
- *
+ *
* @param object
* The object to test.
- *
+ *
* @return <code>true</code> if <code>object</code> is equal to this,
* otherwise <code>false</code>.
*/
Modified: labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/common/TruthMaintenanceSystem.java
===================================================================
--- labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/common/TruthMaintenanceSystem.java 2008-03-20 18:57:07 UTC (rev 19163)
+++ labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/common/TruthMaintenanceSystem.java 2008-03-20 19:32:10 UTC (rev 19164)
@@ -2,13 +2,13 @@
/*
* Copyright 2005 JBoss Inc
- *
+ *
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -16,7 +16,10 @@
* limitations under the License.
*/
-import java.io.Serializable;
+import java.io.ObjectOutput;
+import java.io.IOException;
+import java.io.ObjectInput;
+import java.io.Externalizable;
import java.util.HashSet;
import java.util.Iterator;
import java.util.Set;
@@ -31,26 +34,29 @@
/**
* The Truth Maintenance System is responsible for tracking two things. Firstly
- * It maintains a Map to track the classes with the same Equality, using the
+ * It maintains a Map to track the classes with the same Equality, using the
* EqualityKey. The EqualityKey has an internal datastructure which references
* all the handles which are equal. Secondly It maintains another map tracking
* the justificiations for logically asserted facts.
- *
+ *
* @author <a href="mailto:mark.proctor at jboss.com">Mark Proctor</a>
*
*/
public class TruthMaintenanceSystem
implements
- Serializable {
+ Externalizable {
private static final long serialVersionUID = 400L;
- private final AbstractWorkingMemory workingMemory;
+ private AbstractWorkingMemory workingMemory;
- private final PrimitiveLongMap justifiedMap;
+ private PrimitiveLongMap justifiedMap;
- private final ObjectHashMap assertMap;
+ private ObjectHashMap assertMap;
+ public TruthMaintenanceSystem() {
+ }
+
public TruthMaintenanceSystem(final AbstractWorkingMemory workingMemory) {
this.workingMemory = workingMemory;
@@ -60,6 +66,18 @@
this.assertMap.setComparator( EqualityKeyComparator.getInstance() );
}
+ public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
+ workingMemory = (AbstractWorkingMemory)in.readObject();
+ justifiedMap = (PrimitiveLongMap)in.readObject();
+ assertMap = (ObjectHashMap)in.readObject();
+ }
+
+ public void writeExternal(ObjectOutput out) throws IOException {
+ out.writeObject(workingMemory);
+ out.writeObject(justifiedMap);
+ out.writeObject(assertMap);
+ }
+
public PrimitiveLongMap getJustifiedMap() {
return this.justifiedMap;
}
@@ -90,9 +108,9 @@
* An Activation is no longer true so it no longer justifies any of the logical facts
* it logically asserted. It iterates over the Activation's LinkedList of DependencyNodes
* it retrieves the justitication set for each DependencyNode's FactHandle and removes
- * itself. If the Set is empty it retracts the FactHandle from the WorkingMemory.
- *
- * @param activation
+ * itself. If the Set is empty it retracts the FactHandle from the WorkingMemory.
+ *
+ * @param activation
* @param context
* @param rule
* @throws FactException
@@ -122,12 +140,15 @@
public static class LogicalRetractCallback
implements
WorkingMemoryAction {
- private final TruthMaintenanceSystem tms;
- private final LogicalDependency node;
- private final Set set;
- private final InternalFactHandle handle;
- private final PropagationContext context;
+ private TruthMaintenanceSystem tms;
+ private LogicalDependency node;
+ private Set set;
+ private InternalFactHandle handle;
+ private PropagationContext context;
+ public LogicalRetractCallback() {
+
+ }
public LogicalRetractCallback(TruthMaintenanceSystem tms,
LogicalDependency node,
Set set,
@@ -140,6 +161,22 @@
this.context = context;
}
+ public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
+ tms = (TruthMaintenanceSystem)in.readObject();
+ node = (LogicalDependency)in.readObject();
+ set = (Set)in.readObject();
+ handle = (InternalFactHandle)in.readObject();
+ context = (PropagationContext)in.readObject();
+ }
+
+ public void writeExternal(ObjectOutput out) throws IOException {
+ out.writeObject(tms);
+ out.writeObject(node);
+ out.writeObject(set);
+ out.writeObject(handle);
+ out.writeObject(context);
+ }
+
public void execute(InternalWorkingMemory workingMemory) {
if ( set.isEmpty() ) {
@@ -159,13 +196,13 @@
/**
* The FactHandle is being removed from the system so remove any logical dependencies
- * between the justified FactHandle and its justifiers. Removes the FactHandle key
- * from the justifiedMap. It then iterates over all the LogicalDependency nodes, if any,
- * in the returned Set and removes the LogicalDependency node from the LinkedList maintained
+ * between the justified FactHandle and its justifiers. Removes the FactHandle key
+ * from the justifiedMap. It then iterates over all the LogicalDependency nodes, if any,
+ * in the returned Set and removes the LogicalDependency node from the LinkedList maintained
* by the Activation.
- *
+ *
* @see LogicalDependency
- *
+ *
* @param handle - The FactHandle to be removed
* @throws FactException
*/
@@ -181,7 +218,7 @@
/**
* Adds a justification for the FactHandle to the justifiedMap.
- *
+ *
* @param handle
* @param activation
* @param context
Modified: labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/common/TupleStartEqualsConstraint.java
===================================================================
--- labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/common/TupleStartEqualsConstraint.java 2008-03-20 18:57:07 UTC (rev 19163)
+++ labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/common/TupleStartEqualsConstraint.java 2008-03-20 19:32:10 UTC (rev 19164)
@@ -1,12 +1,12 @@
/*
* Copyright 2006 JBoss Inc
- *
+ *
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -21,23 +21,27 @@
import org.drools.rule.Declaration;
import org.drools.spi.BetaNodeFieldConstraint;
+import java.io.IOException;
+import java.io.ObjectInput;
+import java.io.ObjectOutput;
+
/**
* Checks if one tuple is the start subtuple of other tuple.
* For instance, if we have two tuples:
- *
+ *
* T1 = [ a, b, c ]
* T2 = [ a, b, c, d, e]
- *
+ *
* This constraint will evaluate to true as T1 is the starting subtuple
* of T2. On the other hand, if we have:
- *
+ *
* T1 = [ a, c, b ]
* T2 = [ a, b, c, d, e ]
- *
+ *
* This constraint will evaluate to false, as T1 is not the starting subtuple
* of T2. Besides having the same elements, the order is different.
- *
- * This constraint is used when joining subnetworks back into the main
+ *
+ * This constraint is used when joining subnetworks back into the main
* network.
*
* @author etirelli
@@ -49,14 +53,22 @@
private static final long serialVersionUID = 400L;
- private final Declaration[] declarations = new Declaration[0];
+ private Declaration[] declarations = new Declaration[0];
private static final TupleStartEqualsConstraint INSTANCE = new TupleStartEqualsConstraint();
// this is a stateless constraint, so we can make it a singleton
- private TupleStartEqualsConstraint() {
+ public TupleStartEqualsConstraint() {
}
+ public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
+ declarations = (Declaration[])in.readObject();
+ }
+
+ public void writeExternal(ObjectOutput out) throws IOException {
+ out.writeObject(declarations);
+ }
+
public static TupleStartEqualsConstraint getInstance() {
return INSTANCE;
}
@@ -64,7 +76,7 @@
public Declaration[] getRequiredDeclarations() {
return this.declarations;
}
-
+
public void replaceDeclaration(Declaration oldDecl,
Declaration newDecl) {
}
@@ -99,9 +111,9 @@
}
return false;
}
-
+
public Object clone() {
- return INSTANCE;
+ return INSTANCE;
}
public static class TupleStartEqualsConstraintContextEntry
@@ -121,6 +133,20 @@
public TupleStartEqualsConstraintContextEntry() {
}
+ public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
+ left = (ReteTuple)in.readObject();
+ right = (ReteTuple)in.readObject();
+ compareSize = in.readInt();
+ entry = (ContextEntry)in.readObject();
+ }
+
+ public void writeExternal(ObjectOutput out) throws IOException {
+ out.writeObject(left);
+ out.writeObject(right);
+ out.writeInt(compareSize);
+ out.writeObject(entry);
+ }
+
public ContextEntry getNext() {
return this.entry;
}
@@ -141,14 +167,14 @@
// it MUST be a rete tuple
this.right = (ReteTuple) handle.getObject();
}
-
+
public void resetTuple() {
this.left = null;
}
-
+
public void resetFactHandle() {
this.right = null;
- }
+ }
}
public ConstraintType getType() {
Modified: labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/common/WorkingMemoryAction.java
===================================================================
--- labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/common/WorkingMemoryAction.java 2008-03-20 18:57:07 UTC (rev 19163)
+++ labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/common/WorkingMemoryAction.java 2008-03-20 19:32:10 UTC (rev 19164)
@@ -1,10 +1,10 @@
/**
- *
+ *
*/
package org.drools.common;
-import java.io.Serializable;
+import java.io.Externalizable;
-public interface WorkingMemoryAction extends Serializable {
+public interface WorkingMemoryAction extends Externalizable {
public void execute(InternalWorkingMemory workingMemory);
}
\ No newline at end of file
Modified: labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/concurrent/AssertObject.java
===================================================================
--- labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/concurrent/AssertObject.java 2008-03-20 18:57:07 UTC (rev 19163)
+++ labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/concurrent/AssertObject.java 2008-03-20 19:32:10 UTC (rev 19164)
@@ -5,6 +5,10 @@
import org.drools.WorkingMemory;
+import java.io.ObjectOutput;
+import java.io.IOException;
+import java.io.ObjectInput;
+
public class AssertObject
implements
Command,
@@ -13,10 +17,25 @@
private volatile Object result;
private Exception e;
+ public AssertObject() {
+ }
+
public AssertObject(final Object object) {
this.object = object;
}
+ public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
+ object = in.readObject();
+ result = in.readObject();
+ e = (Exception)in.readObject();
+ }
+
+ public void writeExternal(ObjectOutput out) throws IOException {
+ out.writeObject(object);
+ out.writeObject(result);
+ out.writeObject(e);
+ }
+
public void execute(final WorkingMemory workingMemory) {
try {
this.result = workingMemory.insert( this.object );
@@ -27,16 +46,16 @@
public Object getObject() {
return this.result;
- }
+ }
public boolean isDone() {
return this.result != null;
}
-
+
public boolean exceptionThrown() {
return e != null;
}
-
+
public Exception getException() {
return this.e;
}
Modified: labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/concurrent/AssertObjects.java
===================================================================
--- labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/concurrent/AssertObjects.java 2008-03-20 18:57:07 UTC (rev 19163)
+++ labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/concurrent/AssertObjects.java 2008-03-20 19:32:10 UTC (rev 19164)
@@ -3,12 +3,15 @@
*/
package org.drools.concurrent;
+import org.drools.WorkingMemory;
+
+import java.io.IOException;
+import java.io.ObjectInput;
+import java.io.ObjectOutput;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
-import org.drools.WorkingMemory;
-
public class AssertObjects
implements
Command,
@@ -17,10 +20,25 @@
private volatile List results;
private Exception e;
+ public AssertObjects() {
+ }
+
public AssertObjects(final Object object) {
this.object = object;
}
+ public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
+ object = in.readObject();
+ results = (List)in.readObject();
+ e = (Exception)in.readObject();
+ }
+
+ public void writeExternal(ObjectOutput out) throws IOException {
+ out.writeObject(object);
+ out.writeObject(results);
+ out.writeObject(e);
+ }
+
public void execute(final WorkingMemory workingMemory) {
try {
if ( this.object instanceof Object[] ) {
Modified: labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/concurrent/Command.java
===================================================================
--- labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/concurrent/Command.java 2008-03-20 18:57:07 UTC (rev 19163)
+++ labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/concurrent/Command.java 2008-03-20 19:32:10 UTC (rev 19164)
@@ -3,10 +3,10 @@
*/
package org.drools.concurrent;
-import java.io.Serializable;
-
import org.drools.WorkingMemory;
-public interface Command extends Serializable {
+import java.io.Externalizable;
+
+public interface Command extends Externalizable {
void execute(WorkingMemory workingMemory);
}
\ No newline at end of file
Modified: labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/concurrent/CommandExecutor.java
===================================================================
--- labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/concurrent/CommandExecutor.java 2008-03-20 18:57:07 UTC (rev 19163)
+++ labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/concurrent/CommandExecutor.java 2008-03-20 19:32:10 UTC (rev 19164)
@@ -3,19 +3,22 @@
*/
package org.drools.concurrent;
-import java.io.Serializable;
+import org.drools.WorkingMemory;
+
+import java.io.Externalizable;
+import java.io.IOException;
+import java.io.ObjectInput;
+import java.io.ObjectOutput;
import java.util.concurrent.BlockingQueue;
import java.util.concurrent.LinkedBlockingQueue;
-import org.drools.WorkingMemory;
-
/**
* The CommandExecutor is a Producer/Consumer style classes that provides a queue of Commands
* in a LinkedBlockingQueue. This the run() method loops for continously until shutdown() is
* called.
*
*/
-public class CommandExecutor implements Runnable, Serializable {
+public class CommandExecutor implements Runnable, Externalizable {
private static final long serialVersionUID = 5924295088331461167L;
@@ -24,12 +27,27 @@
private volatile boolean run;
-
+
+ public CommandExecutor() {
+ }
+
public CommandExecutor(WorkingMemory workingMemory) {
this.workingMemory = workingMemory;
this.queue = new LinkedBlockingQueue();
}
+ public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
+ workingMemory = (WorkingMemory)in.readObject();
+ queue = (BlockingQueue)in.readObject();
+ run = in.readBoolean();
+ }
+
+ public void writeExternal(ObjectOutput out) throws IOException {
+ out.writeObject(workingMemory);
+ out.writeObject(queue);
+ out.writeBoolean(run);
+ }
+
/**
* Allows the looping run() method to execute.
*
Modified: labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/concurrent/DefaultExecutorService.java
===================================================================
--- labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/concurrent/DefaultExecutorService.java 2008-03-20 18:57:07 UTC (rev 19163)
+++ labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/concurrent/DefaultExecutorService.java 2008-03-20 19:32:10 UTC (rev 19164)
@@ -3,34 +3,48 @@
*/
package org.drools.concurrent;
+import java.io.ObjectOutput;
+import java.io.IOException;
+import java.io.ObjectInput;
-public class DefaultExecutorService implements ExecutorService {
+public class DefaultExecutorService implements ExecutorService {
private static final long serialVersionUID = 7860812696865293690L;
private Thread thread;
private CommandExecutor executor;
private boolean running;
-
+
public DefaultExecutorService() {
-
}
-
+
+ public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
+ thread = (Thread)in.readObject();
+ executor = (CommandExecutor)in.readObject();
+ running = in.readBoolean();
+ }
+
+ public void writeExternal(ObjectOutput out) throws IOException {
+ out.writeObject(thread);
+ out.writeObject(executor);
+ out.writeBoolean(running);
+ }
+
public void setCommandExecutor(CommandExecutor executor) {
this.executor = executor;
}
-
+
public void startUp() {
this.thread = new Thread( executor );
this.thread.start();
this.running = true;
}
-
+
public void shutDown() {
this.executor.shutdown();
this.running = false;
this.thread = null;
- }
-
+ }
+
public Future submit(Command command) {
if (!this.running) {
startUp();
Modified: labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/concurrent/ExecutorService.java
===================================================================
--- labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/concurrent/ExecutorService.java 2008-03-20 18:57:07 UTC (rev 19163)
+++ labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/concurrent/ExecutorService.java 2008-03-20 19:32:10 UTC (rev 19164)
@@ -3,36 +3,35 @@
*/
package org.drools.concurrent;
-import java.io.Serializable;
+import java.io.Externalizable;
-
/**
* This class instance is configed by the RuleBaseConfiguration and is responsible for thread management
* of the async services.
*
*/
-public interface ExecutorService extends Serializable {
-
+public interface ExecutorService extends Externalizable {
+
/**
* The CommandExecutor is a producer/consumer style class that handles the queue and execution
* of the async actions
* @param executor
*/
public void setCommandExecutor(CommandExecutor executor);
-
+
/**
* Submit a command for execution, adds it ot the commandExecutor's queue
* @param command
* @return
*/
Future submit(Command command);
-
+
/**
* Shutdown this ExecutorService
*
*/
void shutDown();
-
+
/**
* Startup this ExecutorService, typically called on first submit for lazy startup.
*
Modified: labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/concurrent/FireAllRules.java
===================================================================
--- labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/concurrent/FireAllRules.java 2008-03-20 18:57:07 UTC (rev 19163)
+++ labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/concurrent/FireAllRules.java 2008-03-20 19:32:10 UTC (rev 19164)
@@ -6,6 +6,10 @@
import org.drools.WorkingMemory;
import org.drools.spi.AgendaFilter;
+import java.io.IOException;
+import java.io.ObjectInput;
+import java.io.ObjectOutput;
+
public class FireAllRules
implements
Command,
@@ -14,10 +18,25 @@
private volatile boolean done;
private Exception e;
+ public FireAllRules() {
+ }
+
public FireAllRules(final AgendaFilter agendaFilter) {
this.agendaFilter = agendaFilter;
}
+ public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
+ agendaFilter = (AgendaFilter)in.readObject();
+ done = in.readBoolean();
+ e = (Exception)in.readObject();
+ }
+
+ public void writeExternal(ObjectOutput out) throws IOException {
+ out.writeObject(agendaFilter);
+ out.writeBoolean(done);
+ out.writeObject(e);
+ }
+
public void execute(final WorkingMemory workingMemory) {
try {
workingMemory.fireAllRules( this.agendaFilter );
@@ -34,12 +53,12 @@
public boolean isDone() {
return this.done;
}
-
+
public boolean exceptionThrown() {
return e != null;
}
-
+
public Exception getException() {
return this.e;
- }
+ }
}
\ No newline at end of file
Modified: labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/concurrent/Future.java
===================================================================
--- labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/concurrent/Future.java 2008-03-20 18:57:07 UTC (rev 19163)
+++ labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/concurrent/Future.java 2008-03-20 19:32:10 UTC (rev 19164)
@@ -1,12 +1,12 @@
package org.drools.concurrent;
-import java.io.Serializable;
+import java.io.Externalizable;
-public interface Future extends Serializable {
+public interface Future extends Externalizable {
boolean isDone();
-
+
Object getObject();
-
+
boolean exceptionThrown();
Exception getException();
}
Modified: labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/concurrent/RetractObject.java
===================================================================
--- labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/concurrent/RetractObject.java 2008-03-20 18:57:07 UTC (rev 19163)
+++ labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/concurrent/RetractObject.java 2008-03-20 19:32:10 UTC (rev 19164)
@@ -6,6 +6,10 @@
import org.drools.FactHandle;
import org.drools.WorkingMemory;
+import java.io.IOException;
+import java.io.ObjectInput;
+import java.io.ObjectOutput;
+
public class RetractObject
implements
Command,
@@ -14,6 +18,9 @@
private volatile boolean done;
private Exception e;
+ public RetractObject() {
+ }
+
public RetractObject(final FactHandle factHandle) {
this.factHandle = factHandle;
}
@@ -24,6 +31,18 @@
}
+ public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
+ factHandle = (FactHandle)in.readObject();
+ done = in.readBoolean();
+ e = (Exception)in.readObject();
+ }
+
+ public void writeExternal(ObjectOutput out) throws IOException {
+ out.writeObject(factHandle);
+ out.writeBoolean(done);
+ out.writeObject(e);
+ }
+
public Object getObject() {
return null;
}
@@ -31,12 +50,12 @@
public boolean isDone() {
return this.done;
}
-
+
public boolean exceptionThrown() {
return e != null;
}
-
+
public Exception getException() {
return this.e;
- }
+ }
}
\ No newline at end of file
Modified: labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/concurrent/UpdateObject.java
===================================================================
--- labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/concurrent/UpdateObject.java 2008-03-20 18:57:07 UTC (rev 19163)
+++ labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/concurrent/UpdateObject.java 2008-03-20 19:32:10 UTC (rev 19164)
@@ -6,6 +6,10 @@
import org.drools.FactHandle;
import org.drools.WorkingMemory;
+import java.io.ObjectOutput;
+import java.io.IOException;
+import java.io.ObjectInput;
+
public class UpdateObject
implements
Command,
@@ -15,15 +19,32 @@
private volatile boolean done;
private Exception e;
+ public UpdateObject() {
+ }
+
public UpdateObject(final FactHandle factHandle,
final Object object) {
this.factHandle = factHandle;
this.object = object;
}
+ public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
+ factHandle = (FactHandle)in.readObject();
+ object = in.readObject();
+ done = in.readBoolean();
+ e = (Exception)in.readObject();
+ }
+
+ public void writeExternal(ObjectOutput out) throws IOException {
+ out.writeObject(factHandle);
+ out.writeObject(object);
+ out.writeBoolean(done);
+ out.writeObject(e);
+ }
+
public void execute(final WorkingMemory workingMemory) {
workingMemory.update( this.factHandle,
- this.object );
+ this.object );
this.done = true;
}
@@ -34,12 +55,12 @@
public boolean isDone() {
return this.done == true;
}
-
+
public boolean exceptionThrown() {
return e != null;
}
-
+
public Exception getException() {
return this.e;
- }
+ }
}
\ No newline at end of file
Modified: labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/conflict/DepthConflictResolver.java
===================================================================
--- labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/conflict/DepthConflictResolver.java 2008-03-20 18:57:07 UTC (rev 19163)
+++ labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/conflict/DepthConflictResolver.java 2008-03-20 19:32:10 UTC (rev 19164)
@@ -3,15 +3,26 @@
import org.drools.spi.Activation;
import org.drools.spi.ConflictResolver;
+import java.io.Externalizable;
+import java.io.IOException;
+import java.io.ObjectOutput;
+import java.io.ObjectInput;
+
public class DepthConflictResolver
implements
- ConflictResolver {
+ ConflictResolver, Externalizable {
/**
- *
+ *
*/
private static final long serialVersionUID = 400L;
public static final DepthConflictResolver INSTANCE = new DepthConflictResolver();
+ public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
+ }
+
+ public void writeExternal(ObjectOutput out) throws IOException {
+ }
+
public static ConflictResolver getInstance() {
return DepthConflictResolver.INSTANCE;
}
@@ -30,7 +41,7 @@
final int s1 = lhs.getSalience();
final int s2 = rhs.getSalience();
- if ( s1 > s2 ) {
+ if ( s1 > s2 ) {
return -1;
} else if ( s1 < s2 ) {
return 1;
Modified: labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/event/AgendaEventSupport.java
===================================================================
--- labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/event/AgendaEventSupport.java 2008-03-20 18:57:07 UTC (rev 19163)
+++ labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/event/AgendaEventSupport.java 2008-03-20 19:32:10 UTC (rev 19164)
@@ -2,13 +2,13 @@
/*
* Copyright 2005 JBoss Inc
- *
+ *
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -16,7 +16,10 @@
* limitations under the License.
*/
-import java.io.Serializable;
+import java.io.Externalizable;
+import java.io.ObjectOutput;
+import java.io.IOException;
+import java.io.ObjectInput;
import java.util.Collections;
import java.util.List;
import java.util.concurrent.CopyOnWriteArrayList;
@@ -31,16 +34,24 @@
*/
public class AgendaEventSupport
implements
- Serializable {
+ Externalizable {
/**
- *
+ *
*/
private static final long serialVersionUID = 400L;
- private final List<AgendaEventListener> listeners = new CopyOnWriteArrayList<AgendaEventListener>();
+ private List<AgendaEventListener> listeners = new CopyOnWriteArrayList<AgendaEventListener>();
public AgendaEventSupport() {
}
+ public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
+ listeners = (List<AgendaEventListener>)in.readObject();
+ }
+
+ public void writeExternal(ObjectOutput out) throws IOException {
+ out.writeObject(listeners);
+ }
+
public void addEventListener(final AgendaEventListener listener) {
if ( !this.listeners.contains( listener ) ) {
this.listeners.add( listener );
Modified: labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/event/DefaultRuleBaseEventListener.java
===================================================================
--- labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/event/DefaultRuleBaseEventListener.java 2008-03-20 18:57:07 UTC (rev 19163)
+++ labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/event/DefaultRuleBaseEventListener.java 2008-03-20 19:32:10 UTC (rev 19164)
@@ -1,4 +1,8 @@
package org.drools.event;
+
+import java.io.ObjectOutput;
+import java.io.IOException;
+import java.io.ObjectInput;
/*
* Copyright 2005 JBoss Inc
*
@@ -20,6 +24,12 @@
implements
RuleBaseEventListener {
+ public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
+ }
+
+ public void writeExternal(ObjectOutput out) throws IOException {
+ }
+
public void afterFunctionRemoved(AfterFunctionRemovedEvent event) {
// intentionally left blank
}
Modified: labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/event/RuleBaseEventListener.java
===================================================================
--- labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/event/RuleBaseEventListener.java 2008-03-20 18:57:07 UTC (rev 19163)
+++ labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/event/RuleBaseEventListener.java 2008-03-20 19:32:10 UTC (rev 19164)
@@ -1,10 +1,11 @@
package org.drools.event;
import java.util.EventListener;
+import java.io.Externalizable;
public interface RuleBaseEventListener
extends
- EventListener {
+ EventListener, Externalizable {
/**
* Method called before a new package is added to the rule base
Modified: labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/event/RuleBaseEventSupport.java
===================================================================
--- labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/event/RuleBaseEventSupport.java 2008-03-20 18:57:07 UTC (rev 19163)
+++ labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/event/RuleBaseEventSupport.java 2008-03-20 19:32:10 UTC (rev 19164)
@@ -2,50 +2,61 @@
/*
* Copyright 2007 JBoss Inc
- *
+ *
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-import java.io.Serializable;
-import java.util.ArrayList;
+import java.io.Externalizable;
+import java.io.IOException;
+import java.io.ObjectOutput;
+import java.io.ObjectInput;
import java.util.Collections;
-import java.util.EventListener;
import java.util.List;
+import java.util.concurrent.CopyOnWriteArrayList;
+
import org.drools.RuleBase;
import org.drools.rule.Rule;
import org.drools.rule.Package;
-import java.util.Iterator;
-import java.util.concurrent.CopyOnWriteArrayList;
-
/**
- *
+ *
* @author etirelli
*/
public class RuleBaseEventSupport
implements
- Serializable {
+ Externalizable {
/**
- *
+ *
*/
private static final long serialVersionUID = 400L;
- private final List<RuleBaseEventListener> listeners = new CopyOnWriteArrayList<RuleBaseEventListener>();
+ private List<RuleBaseEventListener> listeners = new CopyOnWriteArrayList<RuleBaseEventListener>();
private transient RuleBase ruleBase;
+ public RuleBaseEventSupport() {
+
+ }
public RuleBaseEventSupport(final RuleBase ruleBase) {
this.ruleBase = ruleBase;
}
+ public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
+ listeners = (List<RuleBaseEventListener>)in.readObject();
+ }
+
+ public void writeExternal(ObjectOutput out) throws IOException {
+ out.writeObject(listeners);
+ }
+
public void addEventListener(final RuleBaseEventListener listener) {
if ( !this.listeners.contains( listener ) ) {
this.listeners.add( listener );
Modified: labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/event/RuleFlowEventSupport.java
===================================================================
--- labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/event/RuleFlowEventSupport.java 2008-03-20 18:57:07 UTC (rev 19163)
+++ labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/event/RuleFlowEventSupport.java 2008-03-20 19:32:10 UTC (rev 19164)
@@ -2,13 +2,13 @@
/*
* Copyright 2005 JBoss Inc
- *
+ *
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -16,8 +16,10 @@
* limitations under the License.
*/
-import java.io.Serializable;
-import java.util.ArrayList;
+import java.io.Externalizable;
+import java.io.ObjectOutput;
+import java.io.IOException;
+import java.io.ObjectInput;
import java.util.Collections;
import java.util.List;
import java.util.concurrent.CopyOnWriteArrayList;
@@ -31,16 +33,24 @@
/**
* @author <a href="mailto:kris_verlaenen at hotmail.com">Kris Verlaenen</a>
*/
-public class RuleFlowEventSupport implements Serializable {
-
+public class RuleFlowEventSupport implements Externalizable {
+
// TODO separate out process level stuff
private static final long serialVersionUID = 400L;
- private final List<RuleFlowEventListener> listeners = new CopyOnWriteArrayList<RuleFlowEventListener>();
+ private List<RuleFlowEventListener> listeners = new CopyOnWriteArrayList<RuleFlowEventListener>();
public RuleFlowEventSupport() {
}
+ public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
+ listeners = (List<RuleFlowEventListener>)in.readObject();
+ }
+
+ public void writeExternal(ObjectOutput out) throws IOException {
+ out.writeObject(listeners);
+ }
+
public void addEventListener(final RuleFlowEventListener listener) {
if ( !this.listeners.contains( listener ) ) {
this.listeners.add( listener );
Modified: labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/event/WorkingMemoryEventSupport.java
===================================================================
--- labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/event/WorkingMemoryEventSupport.java 2008-03-20 18:57:07 UTC (rev 19163)
+++ labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/event/WorkingMemoryEventSupport.java 2008-03-20 19:32:10 UTC (rev 19164)
@@ -2,13 +2,13 @@
/*
* Copyright 2005 JBoss Inc
- *
+ *
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -16,8 +16,10 @@
* limitations under the License.
*/
-import java.io.Serializable;
-import java.util.ArrayList;
+import java.io.Externalizable;
+import java.io.ObjectOutput;
+import java.io.ObjectInput;
+import java.io.IOException;
import java.util.Collections;
import java.util.List;
import java.util.concurrent.CopyOnWriteArrayList;
@@ -31,16 +33,24 @@
*/
public class WorkingMemoryEventSupport
implements
- Serializable {
+ Externalizable {
/**
- *
+ *
*/
private static final long serialVersionUID = 400L;
- private final List<WorkingMemoryEventListener> listeners = new CopyOnWriteArrayList<WorkingMemoryEventListener>();
+ private List<WorkingMemoryEventListener> listeners = new CopyOnWriteArrayList<WorkingMemoryEventListener>();
public WorkingMemoryEventSupport() {
}
+ public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
+ listeners = (List<WorkingMemoryEventListener>)in.readObject();
+ }
+
+ public void writeExternal(ObjectOutput out) throws IOException {
+ out.writeObject(listeners);
+ }
+
public void addEventListener(final WorkingMemoryEventListener listener) {
if ( !this.listeners.contains( listener ) ) {
this.listeners.add( listener );
Modified: labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/facttemplates/FactImpl.java
===================================================================
--- labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/facttemplates/FactImpl.java 2008-03-20 18:57:07 UTC (rev 19163)
+++ labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/facttemplates/FactImpl.java 2008-03-20 19:32:10 UTC (rev 19164)
@@ -17,6 +17,10 @@
package org.drools.facttemplates;
import java.io.Serializable;
+import java.io.Externalizable;
+import java.io.ObjectOutput;
+import java.io.IOException;
+import java.io.ObjectInput;
import java.util.Arrays;
//import woolfel.engine.rule.Rule;
@@ -30,7 +34,7 @@
public class FactImpl
implements
Fact,
- Serializable {
+ Externalizable {
private static int hashCode(final Object[] array) {
final int PRIME = 31;
@@ -53,6 +57,9 @@
*/
private long id;
+ public FactImpl() {
+ }
+
/**
* this is the default constructor
* @param instance
@@ -73,6 +80,20 @@
this.id = id;
}
+ public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
+ factTemplate = (FactTemplate)in.readObject();
+ values = (Object[])in.readObject();
+ hashCode = in.readInt();
+ id = in.readLong();
+ }
+
+ public void writeExternal(ObjectOutput out) throws IOException {
+ out.writeObject(factTemplate);
+ out.writeObject(values);
+ out.writeInt(hashCode);
+ out.writeLong(id);
+ }
+
/**
* Method returns the value of the given slot at the
* id.
Modified: labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/facttemplates/FactTemplate.java
===================================================================
--- labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/facttemplates/FactTemplate.java 2008-03-20 18:57:07 UTC (rev 19163)
+++ labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/facttemplates/FactTemplate.java 2008-03-20 19:32:10 UTC (rev 19164)
@@ -12,11 +12,11 @@
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
- *
+ *
*/
package org.drools.facttemplates;
-import java.io.Serializable;
+import java.io.Externalizable;
import org.drools.rule.Package;
@@ -29,7 +29,7 @@
*/
public interface FactTemplate
extends
- Serializable {
+ Externalizable {
Package getPackage();
Modified: labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/facttemplates/FactTemplateFieldExtractor.java
===================================================================
--- labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/facttemplates/FactTemplateFieldExtractor.java 2008-03-20 18:57:07 UTC (rev 19163)
+++ labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/facttemplates/FactTemplateFieldExtractor.java 2008-03-20 19:32:10 UTC (rev 19164)
@@ -1,6 +1,9 @@
package org.drools.facttemplates;
import java.lang.reflect.Method;
+import java.io.ObjectOutput;
+import java.io.ObjectInput;
+import java.io.IOException;
import org.drools.RuntimeDroolsException;
import org.drools.base.ValueType;
@@ -16,12 +19,26 @@
private FactTemplate factTemplate;
private int fieldIndex;
+ public FactTemplateFieldExtractor() {
+
+ }
+
public FactTemplateFieldExtractor(final FactTemplate factTemplate,
final int fieldIndex) {
this.factTemplate = factTemplate;
this.fieldIndex = fieldIndex;
}
+ public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
+ factTemplate = (FactTemplate)in.readObject();
+ fieldIndex = in.readInt();
+ }
+
+ public void writeExternal(ObjectOutput out) throws IOException {
+ out.writeObject(factTemplate);
+ out.writeInt(fieldIndex);
+ }
+
public ValueType getValueType() {
return this.factTemplate.getFieldTemplate( this.fieldIndex ).getValueType();
}
Modified: labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/facttemplates/FactTemplateImpl.java
===================================================================
--- labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/facttemplates/FactTemplateImpl.java 2008-03-20 18:57:07 UTC (rev 19163)
+++ labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/facttemplates/FactTemplateImpl.java 2008-03-20 19:32:10 UTC (rev 19164)
@@ -12,18 +12,21 @@
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
- *
+ *
*/
package org.drools.facttemplates;
import java.util.Arrays;
+import java.io.ObjectOutput;
+import java.io.ObjectInput;
+import java.io.IOException;
import org.drools.rule.Package;
/**
* @author Peter Lin
* Deftemplate is equivalent to CLIPS deftemplate<br/>
- *
+ *
* Some general design notes about the current implementation. In the
* case where a class is declared to create the deftemplate, the order
* of the slots are based on java Introspection. In the case where an
@@ -56,6 +59,10 @@
private Package pkg;
private String name;
+ public FactTemplateImpl() {
+
+ }
+
public FactTemplateImpl(final Package pkg,
final String name,
final FieldTemplate[] fields) {
@@ -65,6 +72,18 @@
this.pkg.addFactTemplate( this );
}
+ public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
+ pkg = (Package)in.readObject();
+ name = (String)in.readObject();
+ fields = (FieldTemplate[])in.readObject();
+ }
+
+ public void writeExternal(ObjectOutput out) throws IOException {
+ out.writeObject(pkg);
+ out.writeObject(name);
+ out.writeObject(fields);
+ }
+
public Package getPackage() {
return this.pkg;
}
@@ -150,7 +169,7 @@
final StringBuffer buf = new StringBuffer();
buf.append( "(" + this.name + " " );
// for (int idx=0; idx < this.slots.length; idx++){
- // buf.append("(" + this.slots[idx].getName() +
+ // buf.append("(" + this.slots[idx].getName() +
// " (type " + ConversionUtils.getTypeName(
// this.slots[idx].getValueType()) +
// ") ) ");
Modified: labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/facttemplates/FactTemplateObjectType.java
===================================================================
--- labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/facttemplates/FactTemplateObjectType.java 2008-03-20 18:57:07 UTC (rev 19163)
+++ labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/facttemplates/FactTemplateObjectType.java 2008-03-20 19:32:10 UTC (rev 19164)
@@ -2,13 +2,13 @@
/*
* Copyright 2005 JBoss Inc
- *
+ *
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -19,11 +19,15 @@
import org.drools.base.ValueType;
import org.drools.spi.ObjectType;
+import java.io.ObjectOutput;
+import java.io.IOException;
+import java.io.ObjectInput;
+
/**
* Java class semantics <code>ObjectType</code>.
- *
+ *
* @author <a href="mailto:bob at werken.com">bob at werken.com </a>
- *
+ *
* @version $Id: ClassObjectType.java,v 1.5 2005/02/04 02:13:36 mproctor Exp $
*/
public class FactTemplateObjectType
@@ -34,7 +38,7 @@
// ------------------------------------------------------------
/**
- *
+ *
*/
private static final long serialVersionUID = 400L;
@@ -46,10 +50,13 @@
// ------------------------------------------------------------
// Constructors
// ------------------------------------------------------------
+ public FactTemplateObjectType() {
+ }
+
/**
* Construct.
- *
+ *
* @param objectTypeClass
* Java object class.
*/
@@ -57,13 +64,23 @@
this.factTemplate = factTemplate;
}
+ public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
+ factTemplate = (FactTemplate)in.readObject();
+ isEvent = in.readBoolean();
+ }
+
+ public void writeExternal(ObjectOutput out) throws IOException {
+ out.writeObject(factTemplate);
+ out.writeBoolean(isEvent);
+
+ }
// ------------------------------------------------------------
// Instance methods
// ------------------------------------------------------------
/**
* Return the Fact Template.
- *
+ *
* @return The Fact Template
*/
public FactTemplate getFactTemplate() {
@@ -77,10 +94,10 @@
/**
* Determine if the passed <code>Object</code> belongs to the object type
* defined by this <code>objectType</code> instance.
- *
+ *
* @param object
* The <code>Object</code> to test.
- *
+ *
* @return <code>true</code> if the <code>Object</code> matches this
* object type, else <code>false</code>.
*/
@@ -122,10 +139,10 @@
/**
* Determine if another object is equal to this.
- *
+ *
* @param object
* The object to test.
- *
+ *
* @return <code>true</code> if <code>object</code> is equal to this,
* otherwise <code>false</code>.
*/
Modified: labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/facttemplates/FieldTemplateImpl.java
===================================================================
--- labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/facttemplates/FieldTemplateImpl.java 2008-03-20 18:57:07 UTC (rev 19163)
+++ labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/facttemplates/FieldTemplateImpl.java 2008-03-20 19:32:10 UTC (rev 19164)
@@ -2,16 +2,25 @@
import org.drools.base.ValueType;
+import java.io.Externalizable;
+import java.io.IOException;
+import java.io.ObjectInput;
+import java.io.ObjectOutput;
+
public class FieldTemplateImpl
implements
- FieldTemplate {
+ FieldTemplate, Externalizable {
private static final long serialVersionUID = 400L;
- private final String name;
- private final int index;
- private final ValueType valueType;
+ private String name;
+ private int index;
+ private ValueType valueType;
+ public FieldTemplateImpl() {
+
+ }
+
public FieldTemplateImpl(final String name,
final int index,
final Class clazz) {
@@ -20,6 +29,19 @@
this.valueType = ValueType.determineValueType( clazz );
}
+ public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
+ name = (String)in.readObject();
+ index = in.readInt();
+ valueType = (ValueType)in.readObject();
+ if (valueType != null)
+ valueType = ValueType.determineValueType(valueType.getClassType());
+ }
+
+ public void writeExternal(ObjectOutput out) throws IOException {
+ out.writeObject(name);
+ out.writeInt(index);
+ out.writeObject(valueType);
+ }
/* (non-Javadoc)
* @see org.drools.facttemplates.FieldTemplate#getIndex()
*/
Modified: labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/process/core/datatype/DataType.java
===================================================================
--- labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/process/core/datatype/DataType.java 2008-03-20 18:57:07 UTC (rev 19163)
+++ labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/process/core/datatype/DataType.java 2008-03-20 19:32:10 UTC (rev 19164)
@@ -16,14 +16,14 @@
* limitations under the License.
*/
-import java.io.Serializable;
+import java.io.Externalizable;
/**
* Abstract representation of a datatype.
*
* @author <a href="mailto:kris_verlaenen at hotmail.com">Kris Verlaenen</a>
*/
-public interface DataType extends Serializable {
+public interface DataType extends Externalizable {
/**
* Returns true if the given value is a valid value of this data type.
Modified: labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/process/core/datatype/impl/type/BooleanDataType.java
===================================================================
--- labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/process/core/datatype/impl/type/BooleanDataType.java 2008-03-20 18:57:07 UTC (rev 19163)
+++ labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/process/core/datatype/impl/type/BooleanDataType.java 2008-03-20 19:32:10 UTC (rev 19164)
@@ -18,6 +18,10 @@
import org.drools.process.core.datatype.DataType;
+import java.io.IOException;
+import java.io.ObjectInput;
+import java.io.ObjectOutput;
+
/**
* Representation of a boolean datatype.
*
@@ -29,6 +33,12 @@
private static final long serialVersionUID = 400L;
+ public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
+ }
+
+ public void writeExternal(ObjectOutput out) throws IOException {
+ }
+
public boolean verifyDataType(final Object value) {
if ( value instanceof Boolean ) {
return true;
Modified: labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/process/core/datatype/impl/type/FloatDataType.java
===================================================================
--- labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/process/core/datatype/impl/type/FloatDataType.java 2008-03-20 18:57:07 UTC (rev 19163)
+++ labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/process/core/datatype/impl/type/FloatDataType.java 2008-03-20 19:32:10 UTC (rev 19164)
@@ -18,6 +18,10 @@
import org.drools.process.core.datatype.DataType;
+import java.io.IOException;
+import java.io.ObjectInput;
+import java.io.ObjectOutput;
+
/**
* Representation of a float datatype.
*
@@ -29,6 +33,12 @@
private static final long serialVersionUID = 400L;
+ public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
+ }
+
+ public void writeExternal(ObjectOutput out) throws IOException {
+ }
+
public boolean verifyDataType(final Object value) {
if ( value instanceof Float ) {
return true;
Modified: labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/process/core/datatype/impl/type/IntegerDataType.java
===================================================================
--- labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/process/core/datatype/impl/type/IntegerDataType.java 2008-03-20 18:57:07 UTC (rev 19163)
+++ labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/process/core/datatype/impl/type/IntegerDataType.java 2008-03-20 19:32:10 UTC (rev 19164)
@@ -18,6 +18,10 @@
import org.drools.process.core.datatype.DataType;
+import java.io.IOException;
+import java.io.ObjectInput;
+import java.io.ObjectOutput;
+
/**
* Representation of an integer datatype.
*
@@ -29,6 +33,12 @@
private static final long serialVersionUID = 400L;
+ public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
+ }
+
+ public void writeExternal(ObjectOutput out) throws IOException {
+ }
+
public boolean verifyDataType(final Object value) {
if ( value instanceof Integer ) {
return true;
Modified: labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/process/core/datatype/impl/type/ListDataType.java
===================================================================
--- labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/process/core/datatype/impl/type/ListDataType.java 2008-03-20 18:57:07 UTC (rev 19163)
+++ labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/process/core/datatype/impl/type/ListDataType.java 2008-03-20 19:32:10 UTC (rev 19164)
@@ -16,24 +16,34 @@
* limitations under the License.
*/
-import java.io.Serializable;
+import org.drools.process.core.datatype.DataType;
+
+import java.io.IOException;
+import java.io.ObjectInput;
+import java.io.ObjectOutput;
import java.util.Iterator;
import java.util.List;
-import org.drools.process.core.datatype.DataType;
-
/**
* Representation of a list datatype.
* All elements in the list must have the same datatype.
*
* @author <a href="mailto:kris_verlaenen at hotmail.com">Kris Verlaenen</a>
*/
-public class ListDataType implements DataType, Serializable {
+public class ListDataType implements DataType {
private static final long serialVersionUID = 400L;
private DataType dataType;
+ public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
+ dataType = (DataType)in.readObject();
+ }
+
+ public void writeExternal(ObjectOutput out) throws IOException {
+ out.writeObject(dataType);
+ }
+
public void setDataType(final DataType dataType) {
this.dataType = dataType;
}
Modified: labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/process/core/datatype/impl/type/StringDataType.java
===================================================================
--- labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/process/core/datatype/impl/type/StringDataType.java 2008-03-20 18:57:07 UTC (rev 19163)
+++ labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/process/core/datatype/impl/type/StringDataType.java 2008-03-20 19:32:10 UTC (rev 19164)
@@ -18,6 +18,10 @@
import org.drools.process.core.datatype.DataType;
+import java.io.IOException;
+import java.io.ObjectInput;
+import java.io.ObjectOutput;
+
/**
* Representation of a string datatype.
*
@@ -29,6 +33,12 @@
private static final long serialVersionUID = 400L;
+ public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
+ }
+
+ public void writeExternal(ObjectOutput out) throws IOException {
+ }
+
public boolean verifyDataType(final Object value) {
if ( value instanceof String ) {
return true;
Modified: labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/process/core/datatype/impl/type/UndefinedDataType.java
===================================================================
--- labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/process/core/datatype/impl/type/UndefinedDataType.java 2008-03-20 18:57:07 UTC (rev 19163)
+++ labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/process/core/datatype/impl/type/UndefinedDataType.java 2008-03-20 19:32:10 UTC (rev 19164)
@@ -18,6 +18,10 @@
import org.drools.process.core.datatype.DataType;
+import java.io.ObjectOutput;
+import java.io.IOException;
+import java.io.ObjectInput;
+
/**
* Representation of an undefined datatype.
*
@@ -28,6 +32,12 @@
private static final long serialVersionUID = 400L;
private static UndefinedDataType instance;
+ public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
+ }
+
+ public void writeExternal(ObjectOutput out) throws IOException {
+ }
+
public static UndefinedDataType getInstance() {
if (instance == null) {
instance = new UndefinedDataType();
Modified: labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/process/instance/WorkItemManager.java
===================================================================
--- labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/process/instance/WorkItemManager.java 2008-03-20 18:57:07 UTC (rev 19163)
+++ labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/process/instance/WorkItemManager.java 2008-03-20 19:32:10 UTC (rev 19164)
@@ -1,6 +1,10 @@
package org.drools.process.instance;
import java.io.Serializable;
+import java.io.Externalizable;
+import java.io.IOException;
+import java.io.ObjectOutput;
+import java.io.ObjectInput;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Map;
@@ -10,22 +14,39 @@
import org.drools.process.instance.impl.WorkItemImpl;
/**
- *
+ *
* @author <a href="mailto:kris_verlaenen at hotmail.com">Kris Verlaenen</a>
*/
-public class WorkItemManager implements Serializable {
+public class WorkItemManager implements Externalizable {
private static final long serialVersionUID = 400L;
-
- private long workItemCounter;
+
+ private long workItemCounter;
private Map<Long, WorkItem> workItems = new HashMap<Long, WorkItem>();
private WorkingMemory workingMemory;
private Map<String, WorkItemHandler> workItemHandlers = new HashMap<String, WorkItemHandler>();
-
- public WorkItemManager(WorkingMemory workingMemory) {
+
+ public WorkItemManager() {
+
+ }
+ public WorkItemManager(WorkingMemory workingMemory) {
this.workingMemory = workingMemory;
}
-
+
+ public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
+ workItemCounter = in.readLong();
+ workItems = (Map<Long, WorkItem>)in.readObject();
+ workingMemory = (WorkingMemory)in.readObject();
+ workItemHandlers = (Map<String, WorkItemHandler>)in.readObject();
+ }
+
+ public void writeExternal(ObjectOutput out) throws IOException {
+ out.writeLong(workItemCounter);
+ out.writeObject(workItems);
+ out.writeObject(workingMemory);
+ out.writeObject(workItemHandlers);
+ }
+
public void executeWorkItem(WorkItem workItem) {
((WorkItemImpl) workItem).setId(++workItemCounter);
workItems.put(new Long(workItem.getId()), workItem);
@@ -36,12 +57,12 @@
System.err.println("Could not find work item handler for " + workItem.getName());
}
}
-
+
public Set<WorkItem> getWorkItems() {
return new HashSet<WorkItem>(workItems.values());
}
-
+
public void completeWorkItem(long id, Map<String, Object> results) {
WorkItemImpl workItem = (WorkItemImpl) workItems.get(new Long(id));
if (workItem == null) {
@@ -58,7 +79,7 @@
processInstance.workItemCompleted(workItem);
workItems.remove(new Long(id));
}
-
+
public void abortWorkItem(long id) {
WorkItemImpl workItem = (WorkItemImpl) workItems.get(new Long(id));
if (workItem == null) {
@@ -74,7 +95,7 @@
processInstance.workItemAborted(workItem);
workItems.remove(new Long(id));
}
-
+
public void registerWorkItemHandler(String workItemName, WorkItemHandler handler) {
this.workItemHandlers.put(workItemName, handler);
}
Modified: labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/reteoo/AccumulateNode.java
===================================================================
--- labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/reteoo/AccumulateNode.java 2008-03-20 18:57:07 UTC (rev 19163)
+++ labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/reteoo/AccumulateNode.java 2008-03-20 19:32:10 UTC (rev 19164)
@@ -1,12 +1,12 @@
/*
* Copyright 2005 JBoss Inc
- *
+ *
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -17,6 +17,10 @@
package org.drools.reteoo;
import java.util.Arrays;
+import java.io.IOException;
+import java.io.ObjectInput;
+import java.io.ObjectOutput;
+import java.io.Externalizable;
import org.drools.RuleBaseConfiguration;
import org.drools.RuntimeDroolsException;
@@ -39,7 +43,7 @@
* A beta node capable of doing accumulate logic.
*
* Created: 04/06/2006
- * @author <a href="mailto:tirelli at post.com">Edson Tirelli</a>
+ * @author <a href="mailto:tirelli at post.com">Edson Tirelli</a>
*
* @version $Id$
*/
@@ -47,11 +51,14 @@
private static final long serialVersionUID = 400L;
- private final boolean unwrapRightObject;
- private final Accumulate accumulate;
- private final AlphaNodeFieldConstraint[] resultConstraints;
- private final BetaConstraints resultBinder;
+ private boolean unwrapRightObject;
+ private Accumulate accumulate;
+ private AlphaNodeFieldConstraint[] resultConstraints;
+ private BetaConstraints resultBinder;
+ public AccumulateNode() {
+ }
+
public AccumulateNode(final int id,
final TupleSource leftInput,
final ObjectSource rightInput,
@@ -72,24 +79,40 @@
this.tupleMemoryEnabled = context.isTupleMemoryEnabled();
}
+ public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
+ super.readExternal(in);
+ unwrapRightObject = in.readBoolean();
+ accumulate = (Accumulate)in.readObject();
+ resultConstraints = (AlphaNodeFieldConstraint[])in.readObject();
+ resultBinder = (BetaConstraints)in.readObject();
+ }
+
+ public void writeExternal(ObjectOutput out) throws IOException {
+ super.writeExternal(out);
+ out.writeBoolean(unwrapRightObject);
+ out.writeObject(accumulate);
+ out.writeObject(resultConstraints);
+ out.writeObject(resultBinder);
+ }
+
/**
* @inheritDoc
- *
+ *
* When a new tuple is asserted into an AccumulateNode, do this:
- *
+ *
* 1. Select all matching objects from right memory
* 2. Execute the initialization code using the tuple + matching objects
* 3. Execute the accumulation code for each combination of tuple+object
* 4. Execute the return code
* 5. Create a new CalculatedObjectHandle for the resulting object and add it to the tuple
* 6. Propagate the tuple
- *
+ *
* The initialization, accumulation and return codes, in JBRules, are assembled
* into a generated method code and called once for the whole match, as you can see
* bellow:
- *
+ *
* Object result = this.accumulator.accumulate( ... );
- *
+ *
*/
public void assertTuple(final ReteTuple leftTuple,
final PropagationContext context,
@@ -125,7 +148,7 @@
handle ) ) {
if ( this.unwrapRightObject ) {
// if there is a subnetwork, handle must be unwrapped
- ReteTuple tuple = (ReteTuple) handle.getObject();
+ ReteTuple tuple = (ReteTuple) handle.getObject();
handle = tuple.getLastHandle();
this.accumulate.accumulate( memory.workingMemoryContext,
accContext,
@@ -141,14 +164,14 @@
}
}
}
-
+
this.constraints.resetTuple( memory.betaMemory.getContext() );
final Object result = this.accumulate.getResult( memory.workingMemoryContext,
accContext,
leftTuple,
workingMemory );
-
+
if( result == null ) {
throw new RuntimeDroolsException("Accumulate must not return a null value.");
}
@@ -188,10 +211,10 @@
/**
* @inheritDoc
- *
+ *
* As the accumulate node will always propagate the tuple,
* it must always also retreat it.
- *
+ *
*/
public void retractTuple(final ReteTuple leftTuple,
final PropagationContext context,
@@ -209,7 +232,7 @@
context,
workingMemory );
- // Destroying the acumulate result object
+ // Destroying the acumulate result object
workingMemory.getFactHandleFactory().destroyFactHandle( accresult.handle );
}
@@ -217,12 +240,12 @@
/**
* @inheritDoc
- *
+ *
* When a new object is asserted into an AccumulateNode, do this:
- *
+ *
* 1. Select all matching tuples from left memory
* 2. For each matching tuple, call a modify tuple
- *
+ *
*/
public void assertObject(final InternalFactHandle handle,
final PropagationContext context,
@@ -263,13 +286,13 @@
}
}
}
-
+
this.constraints.resetFactHandle( memory.betaMemory.getContext() );
}
/**
* @inheritDoc
- *
+ *
* If an object is retract, call modify tuple for each
* tuple match.
*/
@@ -306,7 +329,7 @@
}
}
}
-
+
this.constraints.resetFactHandle( memory.betaMemory.getContext() );
}
@@ -326,7 +349,7 @@
context,
workingMemory );
- // Destroying the acumulate result object
+ // Destroying the acumulate result object
workingMemory.getFactHandleFactory().destroyFactHandle( accresult.handle );
accresult.handle = null;
}
@@ -356,8 +379,8 @@
tuple,
handle,
workingMemory );
- } else if ( context.getType() == PropagationContext.MODIFICATION ||
- context.getType() == PropagationContext.RULE_ADDITION ||
+ } else if ( context.getType() == PropagationContext.MODIFICATION ||
+ context.getType() == PropagationContext.RULE_ADDITION ||
context.getType() == PropagationContext.RULE_REMOVAL ) {
// modification
if ( isAssert ) {
@@ -417,7 +440,7 @@
} else {
workingMemory.getFactHandleFactory().destroyFactHandle( createdHandle );
}
-
+
this.resultBinder.resetTuple( memory.resultsContext );
} else {
workingMemory.getFactHandleFactory().destroyFactHandle( createdHandle );
@@ -488,18 +511,44 @@
return memory;
}
- public static class AccumulateMemory {
+ public static class AccumulateMemory implements Externalizable {
private static final long serialVersionUID = 400L;
-
+
public Object workingMemoryContext;
public BetaMemory betaMemory;
public ContextEntry[] resultsContext;
public ContextEntry[] alphaContexts;
+
+ public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
+ workingMemoryContext = in.readObject();
+ betaMemory = (BetaMemory)in.readObject();
+ resultsContext = (ContextEntry[])in.readObject();
+ alphaContexts = (ContextEntry[])in.readObject();
+ }
+
+ public void writeExternal(ObjectOutput out) throws IOException {
+ out.writeObject(workingMemoryContext);
+ out.writeObject(betaMemory);
+ out.writeObject(resultsContext);
+ out.writeObject(alphaContexts);
+ }
+
}
- private static class AccumulateResult {
+ public static class AccumulateResult implements Externalizable {
// keeping attributes public just for performance
public InternalFactHandle handle;
public Object context;
- }
+
+ public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
+ handle = (InternalFactHandle)in.readObject();
+ context = in.readObject();
+ }
+
+ public void writeExternal(ObjectOutput out) throws IOException {
+ out.writeObject(handle);
+ out.writeObject(context);
+ }
+
+ }
}
Modified: labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/reteoo/AlphaNode.java
===================================================================
--- labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/reteoo/AlphaNode.java 2008-03-20 18:57:07 UTC (rev 19163)
+++ labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/reteoo/AlphaNode.java 2008-03-20 19:32:10 UTC (rev 19164)
@@ -2,20 +2,23 @@
/*
* Copyright 2005 JBoss Inc
- *
+ *
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-import java.io.Serializable;
+import java.io.ObjectInput;
+import java.io.ObjectOutput;
+import java.io.IOException;
+import java.io.Externalizable;
import org.drools.FactException;
import org.drools.RuleBaseConfiguration;
@@ -34,11 +37,11 @@
/**
* <code>AlphaNodes</code> are nodes in the <code>Rete</code> network used
- * to apply <code>FieldConstraint<.code>s on asserted fact
+ * to apply <code>FieldConstraint<.code>s on asserted fact
* objects where the <code>FieldConstraint</code>s have no dependencies on any other of the facts in the current <code>Rule</code>.
- *
+ *
* @see AlphaNodeFieldConstraint
- *
+ *
* @author <a href="mailto:mark.proctor at jboss.com">Mark Proctor</a>
* @author <a href="mailto:bob at werken.com">Bob McWhirter</a>
*
@@ -49,12 +52,12 @@
NodeMemory {
/**
- *
+ *
*/
private static final long serialVersionUID = 400L;
/** The <code>FieldConstraint</code> */
- private final AlphaNodeFieldConstraint constraint;
+ private AlphaNodeFieldConstraint constraint;
private ObjectSinkNode previousObjectSinkNode;
private ObjectSinkNode nextObjectSinkNode;
@@ -63,13 +66,17 @@
private boolean objectMemoryAllowed;
+ public AlphaNode() {
+
+ }
+
/**
* Construct an <code>AlphaNode</code> with a unique id using the provided
* <code>FieldConstraint</code> and the given <code>ObjectSource</code>.
- * Set the boolean flag to true if the node is supposed to have local
- * memory, or false otherwise. Memory is optional for <code>AlphaNode</code>s
- * and is only of benefic when adding additional <code>Rule</code>s at runtime.
- *
+ * Set the boolean flag to true if the node is supposed to have local
+ * memory, or false otherwise. Memory is optional for <code>AlphaNode</code>s
+ * and is only of benefic when adding additional <code>Rule</code>s at runtime.
+ *
* @param id Node's ID
* @param constraint Node's constraints
* @param objectSource Node's object source
@@ -91,9 +98,26 @@
}
}
+ public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
+ super.readExternal(in);
+ constraint = (AlphaNodeFieldConstraint)in.readObject();
+ previousObjectSinkNode = (ObjectSinkNode)in.readObject();
+ nextObjectSinkNode = (ObjectSinkNode)in.readObject();
+ objectMemoryEnabled = in.readBoolean();
+ objectMemoryAllowed = in.readBoolean();
+ }
+
+ public void writeExternal(ObjectOutput out) throws IOException {
+ super.writeExternal(out);
+ out.writeObject(constraint);
+ out.writeObject(previousObjectSinkNode);
+ out.writeObject(nextObjectSinkNode);
+ out.writeBoolean(objectMemoryEnabled);
+ out.writeBoolean(objectMemoryAllowed);
+ }
/**
* Retruns the <code>FieldConstraint</code>
- *
+ *
* @return <code>FieldConstraint</code>
*/
public AlphaNodeFieldConstraint getConstraint() {
@@ -102,7 +126,7 @@
/*
* (non-Javadoc)
- *
+ *
* @see org.drools.reteoo.BaseNode#attach()
*/
public void attach() {
@@ -233,7 +257,7 @@
return memory;
}
- /**
+ /**
* @inheritDoc
*/
protected void addObjectSink(final ObjectSink objectSink) {
@@ -250,7 +274,7 @@
/*
* (non-Javadoc)
- *
+ *
* @see java.lang.Object#equals(java.lang.Object)
*/
public boolean equals(final Object object) {
@@ -277,7 +301,7 @@
}
/**
- * Sets the next node
+ * Sets the next node
* @param next
* The next ObjectSinkNode
*/
@@ -295,7 +319,7 @@
}
/**
- * Sets the previous node
+ * Sets the previous node
* @param previous
* The previous ObjectSinkNode
*/
@@ -305,12 +329,21 @@
public static class AlphaMemory
implements
- Serializable {
+ Externalizable {
private static final long serialVersionUID = -5852576405010023458L;
public FactHashTable facts;
public ContextEntry context;
+ public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
+ facts = (FactHashTable)in.readObject();
+ context = (ContextEntry)in.readObject();
+ }
+
+ public void writeExternal(ObjectOutput out) throws IOException {
+ out.writeObject(facts);
+ out.writeObject(context);
+ }
}
/**
Modified: labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/reteoo/BetaMemory.java
===================================================================
--- labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/reteoo/BetaMemory.java 2008-03-20 18:57:07 UTC (rev 19163)
+++ labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/reteoo/BetaMemory.java 2008-03-20 19:32:10 UTC (rev 19164)
@@ -1,13 +1,17 @@
package org.drools.reteoo;
import java.io.Serializable;
+import java.io.Externalizable;
+import java.io.IOException;
+import java.io.ObjectInput;
+import java.io.ObjectOutput;
import org.drools.rule.ContextEntry;
import org.drools.util.ObjectHashMap;
public class BetaMemory
implements
- Serializable {
+ Externalizable {
private static final long serialVersionUID = 400L;
@@ -16,6 +20,9 @@
private ObjectHashMap createdHandles;
private ContextEntry[] context;
+ public BetaMemory() {
+ }
+
public BetaMemory(final TupleMemory tupleMemory,
final FactHandleMemory objectMemory,
final ContextEntry[] context ) {
@@ -24,6 +31,20 @@
this.context = context;
}
+ public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
+ tupleMemory = (TupleMemory)in.readObject();
+ factHandleMemory = (FactHandleMemory)in.readObject();
+ createdHandles = (ObjectHashMap)in.readObject();
+ context = (ContextEntry[])in.readObject();
+ }
+
+ public void writeExternal(ObjectOutput out) throws IOException {
+ out.writeObject(tupleMemory);
+ out.writeObject(factHandleMemory);
+ out.writeObject(createdHandles);
+ out.writeObject(context);
+ }
+
public FactHandleMemory getFactHandleMemory() {
return this.factHandleMemory;
}
Modified: labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/reteoo/BetaNode.java
===================================================================
--- labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/reteoo/BetaNode.java 2008-03-20 18:57:07 UTC (rev 19163)
+++ labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/reteoo/BetaNode.java 2008-03-20 19:32:10 UTC (rev 19164)
@@ -2,13 +2,13 @@
/*
* Copyright 2005 JBoss Inc
- *
+ *
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -18,6 +18,9 @@
import java.util.ArrayList;
import java.util.List;
+import java.io.ObjectOutput;
+import java.io.IOException;
+import java.io.ObjectInput;
import org.drools.RuleBaseConfiguration;
import org.drools.common.BaseNode;
@@ -34,11 +37,11 @@
* <code>BetaNode</code> provides the base abstract class for <code>JoinNode</code> and <code>NotNode</code>. It implements
* both TupleSink and ObjectSink and as such can receive <code>Tuple</code>s and <code>FactHandle</code>s. BetaNode uses BetaMemory
* to store the propagated instances.
- *
+ *
* @see org.drools.reteoo.TupleSource
* @see org.drools.reteoo.TupleSink
* @see org.drools.reteoo.BetaMemory
- *
+ *
* @author <a href="mailto:mark.proctor at jboss.com">Mark Proctor</a>
* @author <a href="mailto:bob at werken.com">Bob McWhirter</a>
*/
@@ -52,29 +55,32 @@
// ------------------------------------------------------------
/** The left input <code>TupleSource</code>. */
- protected final TupleSource leftInput;
+ protected TupleSource leftInput;
/** The right input <code>TupleSource</code>. */
- protected final ObjectSource rightInput;
+ protected ObjectSource rightInput;
- protected final BetaConstraints constraints;
+ protected BetaConstraints constraints;
private TupleSinkNode previousTupleSinkNode;
private TupleSinkNode nextTupleSinkNode;
private ObjectSinkNode previousObjectSinkNode;
private ObjectSinkNode nextObjectSinkNode;
-
+
protected boolean objectMemory = true; // hard coded to true
protected boolean tupleMemoryEnabled;
// ------------------------------------------------------------
// Constructors
// ------------------------------------------------------------
+ public BetaNode() {
+ }
+
/**
* Constructs a <code>BetaNode</code> using the specified <code>BetaNodeBinder</code>.
- *
+ *
* @param leftInput
* The left input <code>TupleSource</code>.
* @param rightInput
@@ -94,6 +100,32 @@
}
}
+ public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
+ super.readExternal(in);
+ leftInput = (TupleSource)in.readObject();
+ rightInput = (ObjectSource)in.readObject();
+ constraints = (BetaConstraints)in.readObject();
+ previousTupleSinkNode = (TupleSinkNode)in.readObject();
+ nextTupleSinkNode = (TupleSinkNode)in.readObject();
+ previousObjectSinkNode = (ObjectSinkNode)in.readObject();
+ nextObjectSinkNode = (ObjectSinkNode)in.readObject();
+ objectMemory = in.readBoolean();
+ tupleMemoryEnabled = in.readBoolean();
+ }
+
+ public void writeExternal(ObjectOutput out) throws IOException {
+ super.writeExternal(out);
+ out.writeObject(leftInput);
+ out.writeObject(rightInput);
+ out.writeObject(constraints);
+ out.writeObject(previousTupleSinkNode);
+ out.writeObject(nextTupleSinkNode);
+ out.writeObject(previousObjectSinkNode);
+ out.writeObject(nextObjectSinkNode);
+ out.writeBoolean(objectMemory);
+ out.writeBoolean(tupleMemoryEnabled);
+ }
+
public BetaNodeFieldConstraint[] getConstraints() {
final LinkedList constraints = this.constraints.getConstraints();
@@ -109,10 +141,15 @@
* @see org.drools.reteoo.BaseNode#attach()
*/
public void attach() {
+ this.rightInput.addObjectSink( this );
this.leftInput.addTupleSink( this );
- this.rightInput.addObjectSink( this );
}
+ public void networkUpdated() {
+ this.rightInput.networkUpdated();
+ this.leftInput.networkUpdated();
+ }
+
public List getRules() {
final List list = new ArrayList();
@@ -145,12 +182,12 @@
PropagationContext.RULE_ADDITION,
null,
null );
+ this.rightInput.updateSink( this,
+ propagationContext,
+ workingMemory );
this.leftInput.updateSink( this,
propagationContext,
workingMemory );
- this.rightInput.updateSink( this,
- propagationContext,
- workingMemory );
}
}
@@ -170,7 +207,7 @@
}
this.rightInput.remove( context,
builder,
- this,
+ this,
workingMemories );
if( !context.alreadyVisited( this.leftInput )) {
this.leftInput.remove( context,
@@ -188,14 +225,14 @@
public void setObjectMemoryEnabled(boolean objectMemory) {
this.objectMemory = objectMemory;
}
-
+
public boolean isTupleMemoryEnabled() {
return tupleMemoryEnabled;
}
public void setTupleMemoryEnabled(boolean tupleMemoryEnabled) {
this.tupleMemoryEnabled = tupleMemoryEnabled;
- }
+ }
public String toString() {
return "";
@@ -247,7 +284,7 @@
}
/**
- * Sets the next node
+ * Sets the next node
* @param next
* The next TupleSinkNode
*/
@@ -265,7 +302,7 @@
}
/**
- * Sets the previous node
+ * Sets the previous node
* @param previous
* The previous TupleSinkNode
*/
@@ -283,7 +320,7 @@
}
/**
- * Sets the next node
+ * Sets the next node
* @param next
* The next ObjectSinkNode
*/
@@ -301,7 +338,7 @@
}
/**
- * Sets the previous node
+ * Sets the previous node
* @param previous
* The previous ObjectSinkNode
*/
Modified: labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/reteoo/ClassObjectTypeConf.java
===================================================================
--- labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/reteoo/ClassObjectTypeConf.java 2008-03-20 18:57:07 UTC (rev 19163)
+++ labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/reteoo/ClassObjectTypeConf.java 2008-03-20 19:32:10 UTC (rev 19164)
@@ -1,12 +1,12 @@
/*
* Copyright 2007 JBoss Inc
- *
+ *
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -17,8 +17,10 @@
*/
package org.drools.reteoo;
+import java.io.Externalizable;
import java.io.IOException;
-import java.io.ObjectInputStream;
+import java.io.ObjectInput;
+import java.io.ObjectOutput;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.Collection;
@@ -31,7 +33,6 @@
import org.drools.base.DroolsQuery;
import org.drools.base.ShadowProxy;
import org.drools.base.ShadowProxyFactory;
-import org.drools.common.DroolsObjectInputStream;
import org.drools.common.InternalRuleBase;
import org.drools.objenesis.instantiator.ObjectInstantiator;
import org.drools.reteoo.builder.BuildContext;
@@ -43,11 +44,11 @@
public class ClassObjectTypeConf
implements
ObjectTypeConf,
- Serializable {
+ Externalizable {
private static final long serialVersionUID = 8218802585428841926L;
- private final Class<?> cls;
+ private Class<?> cls;
private transient InternalRuleBase ruleBase;
private ObjectTypeNode[] objectTypeNodes;
@@ -58,6 +59,10 @@
private ObjectTypeNode concreteObjectTypeNode;
private EntryPoint entryPoint;
+ public ClassObjectTypeConf() {
+
+ }
+
public ClassObjectTypeConf(final EntryPoint entryPoint,
final Class<?> clazz,
final InternalRuleBase ruleBase) {
@@ -96,6 +101,28 @@
defineShadowProxyData( clazz );
}
+ public void readExternal(ObjectInput stream) throws IOException,
+ ClassNotFoundException {
+ ruleBase = (InternalRuleBase)stream.readObject();
+ cls = (Class)stream.readObject();
+ objectTypeNodes = (ObjectTypeNode[])stream.readObject();
+ shadowEnabled = stream.readBoolean();
+ shadowClass = (Class)stream.readObject();
+ concreteObjectTypeNode = (ObjectTypeNode)stream.readObject();
+ entryPoint = (EntryPoint)stream.readObject();
+ defineShadowProxyData(cls);
+ }
+
+ public void writeExternal(ObjectOutput stream) throws IOException {
+ stream.writeObject(ruleBase);
+ stream.writeObject(cls);
+ stream.writeObject(objectTypeNodes);
+ stream.writeBoolean(shadowEnabled);
+ stream.writeObject(shadowClass);
+ stream.writeObject(concreteObjectTypeNode);
+ stream.writeObject(entryPoint);
+ }
+
public boolean isAssignableFrom(Object object) {
return this.cls.isAssignableFrom( (Class) object );
}
@@ -223,12 +250,6 @@
return ret;
}
- private void readObject(ObjectInputStream stream) throws IOException,
- ClassNotFoundException {
- stream.defaultReadObject();
- this.ruleBase = ((DroolsObjectInputStream) stream).getRuleBase();
- }
-
/**
*
*/
@@ -254,7 +275,7 @@
}
proxy = (ShadowProxy) this.instantiator.newInstance();
}
-
+
proxy.setShadowedObject( fact );
} catch ( final Exception e ) {
System.out.println( "shadow: " +proxy.getClass() + ":" + fact.getClass() );
Modified: labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/reteoo/CollectNode.java
===================================================================
--- labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/reteoo/CollectNode.java 2008-03-20 18:57:07 UTC (rev 19163)
+++ labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/reteoo/CollectNode.java 2008-03-20 19:32:10 UTC (rev 19164)
@@ -1,12 +1,12 @@
/*
* Copyright 2005 JBoss Inc
- *
+ *
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -18,6 +18,9 @@
import java.util.Arrays;
import java.util.Collection;
+import java.io.IOException;
+import java.io.ObjectOutput;
+import java.io.ObjectInput;
import org.drools.RuleBaseConfiguration;
import org.drools.common.BetaConstraints;
@@ -45,14 +48,17 @@
private static final long serialVersionUID = 400L;
- private final Collect collect;
- private final AlphaNodeFieldConstraint[] resultConstraints;
- private final BetaConstraints resultsBinder;
- private final boolean unwrapRightObject;
+ private Collect collect;
+ private AlphaNodeFieldConstraint[] resultConstraints;
+ private BetaConstraints resultsBinder;
+ private boolean unwrapRightObject;
+ public CollectNode() {
+ }
+
/**
* Constructor.
- *
+ *
* @param id
* The id for the node
* @param leftInput
@@ -88,18 +94,33 @@
this.tupleMemoryEnabled = context.isTupleMemoryEnabled();
}
+ public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
+ super.readExternal(in);
+ collect = (Collect)in.readObject();
+ resultConstraints = (AlphaNodeFieldConstraint[])in.readObject();
+ resultsBinder = (BetaConstraints)in.readObject();
+ unwrapRightObject = in.readBoolean();
+ }
+
+ public void writeExternal(ObjectOutput out) throws IOException {
+ super.writeExternal(out);
+ out.writeObject(collect);
+ out.writeObject(resultConstraints);
+ out.writeObject(resultsBinder);
+ out.writeBoolean(unwrapRightObject);
+ }
/**
* @inheritDoc
- *
+ *
* When a new tuple is asserted into a CollectNode, do this:
- *
+ *
* 1. Select all matching objects from right memory
* 2. Add them to the resulting collection object
* 3. Apply resultConstraints and resultsBinder to the resulting collection
* 4. In case all of them evaluates to true do the following:
* 4.1. Create a new InternalFactHandle for the resulting collection and add it to the tuple
* 4.2. Propagate the tuple
- *
+ *
*/
public void assertTuple(final ReteTuple leftTuple,
final PropagationContext context,
@@ -189,19 +210,19 @@
context,
workingMemory );
- // Destroying the acumulate result object
+ // Destroying the acumulate result object
workingMemory.getFactHandleFactory().destroyFactHandle( handle );
}
}
/**
* @inheritDoc
- *
+ *
* When a new object is asserted into a CollectNode, do this:
- *
+ *
* 1. Select all matching tuples from left memory
* 2. For each matching tuple, call a modify tuple
- *
+ *
*/
public void assertObject(final InternalFactHandle handle,
final PropagationContext context,
@@ -238,7 +259,7 @@
/**
* @inheritDoc
- *
+ *
* If an object is retract, call modify tuple for each
* tuple match.
*/
@@ -276,7 +297,7 @@
/**
* Modifies the results match for a tuple, retracting it and repropagating
* if constraints allow it
- *
+ *
* @param leftTuple
* @param handle
* @param context
Modified: labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/reteoo/CompositeObjectSinkAdapter.java
===================================================================
--- labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/reteoo/CompositeObjectSinkAdapter.java 2008-03-20 18:57:07 UTC (rev 19163)
+++ labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/reteoo/CompositeObjectSinkAdapter.java 2008-03-20 19:32:10 UTC (rev 19164)
@@ -1,8 +1,11 @@
package org.drools.reteoo;
-import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;
+import java.io.IOException;
+import java.io.ObjectInput;
+import java.io.ObjectOutput;
+import java.io.Externalizable;
import org.drools.base.ValueType;
import org.drools.base.evaluators.Operator;
@@ -40,7 +43,7 @@
ObjectHashMap hashedSinkMap;
- private final int alphaNodeHashingThreshold;
+ private int alphaNodeHashingThreshold;
public CompositeObjectSinkAdapter() {
this( 3 );
@@ -50,6 +53,22 @@
this.alphaNodeHashingThreshold = alphaNodeHashingThreshold;
}
+ public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
+ otherSinks = (ObjectSinkNodeList)in.readObject();
+ hashableSinks = (ObjectSinkNodeList)in.readObject();
+ hashedFieldIndexes = (LinkedList)in.readObject();
+ hashedSinkMap = (ObjectHashMap)in.readObject();
+ alphaNodeHashingThreshold = in.readInt();
+ }
+
+ public void writeExternal(ObjectOutput out) throws IOException {
+ out.writeObject(otherSinks);
+ out.writeObject(hashableSinks);
+ out.writeObject(hashedFieldIndexes);
+ out.writeObject(hashedSinkMap);
+ out.writeInt(alphaNodeHashingThreshold);
+ }
+
public void addObjectSink(final ObjectSink sink) {
if ( sink instanceof AlphaNode ) {
final AlphaNode alphaNode = (AlphaNode) sink;
@@ -282,7 +301,7 @@
// if the field is hashed then it builds the hashkey to return the correct sink for the current objects slot's
// value, one object may have multiple fields indexed.
if ( this.hashedFieldIndexes != null ) {
- // Iterate the FieldIndexes to see if any are hashed
+ // Iterate the FieldIndexes to see if any are hashed
for ( FieldIndex fieldIndex = (FieldIndex) this.hashedFieldIndexes.getFirst(); fieldIndex != null; fieldIndex = (FieldIndex) fieldIndex.getNext() ) {
if ( !fieldIndex.isHashed() ) {
continue;
@@ -330,7 +349,7 @@
if ( this.hashedFieldIndexes != null ) {
if ( useHash && this.hashedSinkMap != null ) {
final Object object = handle.getObject();
- // Iterate the FieldIndexes to see if any are hashed
+ // Iterate the FieldIndexes to see if any are hashed
for ( FieldIndex fieldIndex = (FieldIndex) this.hashedFieldIndexes.getFirst(); fieldIndex != null; fieldIndex = (FieldIndex) fieldIndex.getNext() ) {
// this field is hashed so set the existing hashKey and see if there is a sink for it
if ( !fieldIndex.isHashed() ) {
@@ -415,7 +434,7 @@
public static class HashKey
implements
- Serializable {
+ Externalizable {
private static final long serialVersionUID = 400L;
private static final byte OBJECT = 1;
@@ -454,6 +473,28 @@
extractor );
}
+ public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
+ index = in.readInt();
+ type = in.readByte();
+ ovalue = in.readObject();
+ lvalue = in.readLong();
+ bvalue = in.readBoolean();
+ dvalue = in.readDouble();
+ isNull = in.readBoolean();
+ hashCode = in.readInt();
+ }
+
+ public void writeExternal(ObjectOutput out) throws IOException {
+ out.writeInt(index);
+ out.writeByte(type);
+ out.writeObject(ovalue);
+ out.writeLong(lvalue);
+ out.writeBoolean(bvalue);
+ out.writeDouble(dvalue);
+ out.writeBoolean(isNull);
+ out.writeInt(hashCode);
+ }
+
public int getIndex() {
return this.index;
}
@@ -675,7 +716,7 @@
implements
LinkedListNode {
private static final long serialVersionUID = 400L;
- private final int index;
+ private int index;
private FieldExtractor fieldExtactor;
private int count;
@@ -685,12 +726,34 @@
private LinkedListNode previous;
private LinkedListNode next;
+ public FieldIndex() {
+
+ }
+
public FieldIndex(final int index,
final FieldExtractor fieldExtractor) {
this.index = index;
this.fieldExtactor = fieldExtractor;
}
+ public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
+ index = in.readInt();
+ fieldExtactor = (FieldExtractor)in.readObject();
+ count = in.readInt();
+ hashed = in.readBoolean();
+ previous = (LinkedListNode)in.readObject();
+ next = (LinkedListNode)in.readObject();
+ }
+
+ public void writeExternal(ObjectOutput out) throws IOException {
+ out.writeInt(index);
+ out.writeObject(fieldExtactor);
+ out.writeInt(count);
+ out.writeBoolean(hashed);
+ out.writeObject(previous);
+ out.writeObject(next);
+ }
+
public FieldExtractor getFieldExtractor() {
return this.fieldExtactor;
}
Modified: labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/reteoo/CompositeTupleSinkAdapter.java
===================================================================
--- labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/reteoo/CompositeTupleSinkAdapter.java 2008-03-20 18:57:07 UTC (rev 19163)
+++ labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/reteoo/CompositeTupleSinkAdapter.java 2008-03-20 19:32:10 UTC (rev 19164)
@@ -4,6 +4,10 @@
import org.drools.common.InternalWorkingMemory;
import org.drools.spi.PropagationContext;
+import java.io.IOException;
+import java.io.ObjectInput;
+import java.io.ObjectOutput;
+
public class CompositeTupleSinkAdapter
implements
TupleSinkPropagator {
@@ -13,6 +17,14 @@
this.sinks = new TupleSinkNodeList();
}
+ public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
+ sinks = (TupleSinkNodeList)in.readObject();
+ }
+
+ public void writeExternal(ObjectOutput out) throws IOException {
+ out.writeObject(sinks);
+ }
+
public void addTupleSink(final TupleSink sink) {
this.sinks.add( (TupleSinkNode) sink );
}
Modified: labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/reteoo/EmptyObjectSinkAdapter.java
===================================================================
--- labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/reteoo/EmptyObjectSinkAdapter.java 2008-03-20 18:57:07 UTC (rev 19163)
+++ labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/reteoo/EmptyObjectSinkAdapter.java 2008-03-20 19:32:10 UTC (rev 19164)
@@ -4,6 +4,10 @@
import org.drools.common.InternalWorkingMemory;
import org.drools.spi.PropagationContext;
+import java.io.ObjectOutput;
+import java.io.IOException;
+import java.io.ObjectInput;
+
public class EmptyObjectSinkAdapter
implements
ObjectSinkPropagator {
@@ -11,16 +15,22 @@
private static final long serialVersionUID = -631743913176779720L;
private static final EmptyObjectSinkAdapter instance = new EmptyObjectSinkAdapter();
-
+
private static final ObjectSink[] SINK_LIST = new ObjectSink[0];
public static EmptyObjectSinkAdapter getInstance() {
return instance;
}
- private EmptyObjectSinkAdapter() {
+ public EmptyObjectSinkAdapter() {
}
+ public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
+ }
+
+ public void writeExternal(ObjectOutput out) throws IOException {
+ }
+
public void propagateAssertObject(final InternalFactHandle handle,
final PropagationContext context,
final InternalWorkingMemory workingMemory) {
@@ -36,9 +46,13 @@
public ObjectSink[] getSinks() {
return SINK_LIST;
}
-
+
public int size() {
return 0;
}
+ public boolean equals(Object obj) {
+ return obj instanceof EmptyObjectSinkAdapter;
+ }
+
}
Modified: labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/reteoo/EmptyTupleSinkAdapter.java
===================================================================
--- labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/reteoo/EmptyTupleSinkAdapter.java 2008-03-20 18:57:07 UTC (rev 19163)
+++ labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/reteoo/EmptyTupleSinkAdapter.java 2008-03-20 19:32:10 UTC (rev 19164)
@@ -4,6 +4,10 @@
import org.drools.common.InternalWorkingMemory;
import org.drools.spi.PropagationContext;
+import java.io.ObjectOutput;
+import java.io.IOException;
+import java.io.ObjectInput;
+
public class EmptyTupleSinkAdapter
implements
TupleSinkPropagator {
@@ -14,9 +18,15 @@
return instance;
}
- private EmptyTupleSinkAdapter() {
+ public EmptyTupleSinkAdapter() {
}
+ public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
+ }
+
+ public void writeExternal(ObjectOutput out) throws IOException {
+ }
+
public void propagateAssertTuple(final ReteTuple tuple,
final InternalFactHandle handle,
final PropagationContext context,
Modified: labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/reteoo/EntryPointNode.java
===================================================================
--- labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/reteoo/EntryPointNode.java 2008-03-20 18:57:07 UTC (rev 19163)
+++ labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/reteoo/EntryPointNode.java 2008-03-20 19:32:10 UTC (rev 19164)
@@ -14,11 +14,14 @@
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
- *
+ *
* Created on January 8th, 2007
*/
-import java.io.Serializable;
+import java.io.Externalizable;
+import java.io.ObjectInput;
+import java.io.IOException;
+import java.io.ObjectOutput;
import java.util.HashMap;
import java.util.Map;
@@ -41,19 +44,19 @@
/**
* A node that is an entry point into the Rete network.
*
- * As we move the design to support network partitions and concurrent processing
+ * As we move the design to support network partitions and concurrent processing
* of parts of the network, we also need to support multiple, independent entry
- * points and this class represents that.
- *
+ * points and this class represents that.
+ *
* It replaces the function of the Rete Node class in previous designs.
- *
+ *
* @see ObjectTypeNode
*
* @author <a href="mailto:tirelli at post.com">Edson Tirelli</a>
*/
public class EntryPointNode extends ObjectSource
implements
- Serializable,
+ Externalizable,
ObjectSink {
// ------------------------------------------------------------
// Instance members
@@ -64,17 +67,20 @@
/**
* The entry point ID for this node
*/
- private final EntryPoint entryPoint;
+ private EntryPoint entryPoint;
/**
* The object type nodes under this node
*/
- private final Map<ObjectType, ObjectTypeNode> objectTypeNodes;
+ private Map<ObjectType, ObjectTypeNode> objectTypeNodes;
// ------------------------------------------------------------
// Constructors
// ------------------------------------------------------------
+ public EntryPointNode() {
+ }
+
public EntryPointNode(final int id,
final ObjectSource objectSource,
final BuildContext context) {
@@ -97,6 +103,17 @@
// Instance methods
// ------------------------------------------------------------
+ public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
+ super.readExternal(in);
+ entryPoint = (EntryPoint)in.readObject();
+ objectTypeNodes = (Map<ObjectType, ObjectTypeNode>)in.readObject();
+ }
+
+ public void writeExternal(ObjectOutput out) throws IOException {
+ super.writeExternal(out);
+ out.writeObject(entryPoint);
+ out.writeObject(objectTypeNodes);
+ }
/**
* @return the entryPoint
*/
@@ -286,7 +303,7 @@
public void setObjectMemoryEnabled(boolean objectMemoryEnabled) {
throw new UnsupportedOperationException( "Entry Point Node has no Object memory" );
}
-
+
public String toString() {
return "[EntryPointNode("+this.id+") "+this.entryPoint+" ]";
}
Modified: labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/reteoo/EvalConditionNode.java
===================================================================
--- labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/reteoo/EvalConditionNode.java 2008-03-20 18:57:07 UTC (rev 19163)
+++ labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/reteoo/EvalConditionNode.java 2008-03-20 19:32:10 UTC (rev 19164)
@@ -2,13 +2,13 @@
/*
* Copyright 2005 JBoss Inc
- *
+ *
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -16,7 +16,10 @@
* limitations under the License.
*/
-import java.io.Serializable;
+import java.io.ObjectOutput;
+import java.io.IOException;
+import java.io.ObjectInput;
+import java.io.Externalizable;
import org.drools.RuleBaseConfiguration;
import org.drools.common.BaseNode;
@@ -31,16 +34,16 @@
/**
* Node which filters <code>ReteTuple</code>s.
- *
+ *
* <p>
* Using a semantic <code>Test</code>, this node may allow or disallow
* <code>Tuples</code> to proceed further through the Rete-OO network.
* </p>
- *
+ *
* @see EvalConditionNode
* @see Eval
* @see ReteTuple
- *
+ *
* @author <a href="mailto:mark.proctor at jboss.com">Mark Proctor</a>
* @author <a href="mailto:bob at werken.com">Bob McWhirter</a>
*/
@@ -53,28 +56,31 @@
// ------------------------------------------------------------
/**
- *
+ *
*/
private static final long serialVersionUID = 400L;
/** The semantic <code>Test</code>. */
- private final EvalCondition condition;
+ private EvalCondition condition;
/** The source of incoming <code>Tuples</code>. */
- private final TupleSource tupleSource;
-
- protected boolean tupleMemoryEnabled;
+ private TupleSource tupleSource;
+ protected boolean tupleMemoryEnabled;
+
private TupleSinkNode previousTupleSinkNode;
private TupleSinkNode nextTupleSinkNode;
// ------------------------------------------------------------
// Constructors
// ------------------------------------------------------------
+ public EvalConditionNode() {
+ }
+
/**
* Construct.
- *
+ *
* @param rule
* The rule
* @param tupleSource
@@ -91,6 +97,23 @@
this.tupleMemoryEnabled = context.isTupleMemoryEnabled();
}
+ public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
+ super.readExternal(in);
+ condition = (EvalCondition)in.readObject();
+ tupleSource = (TupleSource)in.readObject();
+ tupleMemoryEnabled = in.readBoolean();
+ previousTupleSinkNode = (TupleSinkNode)in.readObject();
+ nextTupleSinkNode = (TupleSinkNode)in.readObject();
+ }
+
+ public void writeExternal(ObjectOutput out) throws IOException {
+ super.writeExternal(out);
+ out.writeObject(condition);
+ out.writeObject(tupleSource);
+ out.writeBoolean(tupleMemoryEnabled);
+ out.writeObject(previousTupleSinkNode);
+ out.writeObject(nextTupleSinkNode);
+ }
/**
* Attaches this node into the network.
*/
@@ -113,13 +136,17 @@
}
}
+ public void networkUpdated() {
+ this.tupleSource.networkUpdated();
+ }
+
// ------------------------------------------------------------
// Instance methods
// ------------------------------------------------------------
/**
* Retrieve the <code>Test</code> associated with this node.
- *
+ *
* @return The <code>Test</code>.
*/
public EvalCondition getCondition() {
@@ -132,7 +159,7 @@
/**
* Assert a new <code>Tuple</code>.
- *
+ *
* @param tuple
* The <code>Tuple</code> being asserted.
* @param workingMemory
@@ -176,7 +203,7 @@
/**
* Produce a debug string.
- *
+ *
* @return The debug string.
*/
public String toString() {
@@ -202,7 +229,7 @@
}
public Object createMemory(final RuleBaseConfiguration config) {
- return new EvalMemory( this.tupleMemoryEnabled, this.condition.createContext() );
+ return new EvalMemory( this.tupleMemoryEnabled, this.condition.createContext() );
}
/* (non-Javadoc)
@@ -242,14 +269,14 @@
workingMemories );
}
}
-
+
public boolean isTupleMemoryEnabled() {
return tupleMemoryEnabled;
}
public void setTupleMemoryEnabled(boolean tupleMemoryEnabled) {
this.tupleMemoryEnabled = tupleMemoryEnabled;
- }
+ }
/**
* Returns the next node
@@ -261,7 +288,7 @@
}
/**
- * Sets the next node
+ * Sets the next node
* @param next
* The next TupleSinkNode
*/
@@ -279,27 +306,40 @@
}
/**
- * Sets the previous node
+ * Sets the previous node
* @param previous
* The previous TupleSinkNode
*/
public void setPreviousTupleSinkNode(final TupleSinkNode previous) {
this.previousTupleSinkNode = previous;
}
-
- public static class EvalMemory implements Serializable {
+ public static class EvalMemory implements Externalizable {
+
private static final long serialVersionUID = -2754669682742843929L;
-
+
public TupleHashTable tupleMemory;
public Object context;
-
+
+ public EvalMemory() {
+
+ }
public EvalMemory( final boolean tupleMemoryEnabled, final Object context ) {
this.context = context;
if( tupleMemoryEnabled ) {
this.tupleMemory = new TupleHashTable();
}
}
+
+ public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
+ tupleMemory = (TupleHashTable)in.readObject();
+ context = in.readObject();
+ }
+
+ public void writeExternal(ObjectOutput out) throws IOException {
+ out.writeObject(tupleMemory);
+ out.writeObject(context);
+ }
}
}
Modified: labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/reteoo/ExistsNode.java
===================================================================
--- labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/reteoo/ExistsNode.java 2008-03-20 18:57:07 UTC (rev 19163)
+++ labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/reteoo/ExistsNode.java 2008-03-20 19:32:10 UTC (rev 19164)
@@ -1,12 +1,12 @@
/*
* Copyright 2006 JBoss Inc
- *
+ *
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -29,13 +29,13 @@
* the existence of a Fact plus one or more conditions. Where existence
* is found the left ReteTuple is copied and propagated. Further to this it
* maintains the "truth" by canceling any
- * <code>Activation<code>s that are no longer
- * considered true by the retraction of ReteTuple's or FactHandleImpl.
+ * <code>Activation<code>s that are no longer
+ * considered true by the retraction of ReteTuple's or FactHandleImpl.
* Tuples are considered to be asserted from the left input and facts from the right input.
- * The <code>BetaNode</code> provides the BetaMemory to store asserted ReteTuples and
- * <code>FactHandleImpl<code>s. Each fact handle is stored in the right
+ * The <code>BetaNode</code> provides the BetaMemory to store asserted ReteTuples and
+ * <code>FactHandleImpl<code>s. Each fact handle is stored in the right
* memory.
- *
+ *
* @author <a href="mailto:etirelli at redhat.com">Edson Tirelli</a>
*
*/
@@ -46,13 +46,16 @@
static int notAssertObject = 0;
static int notAssertTuple = 0;
+ public ExistsNode() {
+ }
+
// ------------------------------------------------------------
// Instance methods
// ------------------------------------------------------------
/**
* Construct.
- *
+ *
* @param id
* The unique id for this node.
* @param leftInput
@@ -71,14 +74,14 @@
leftInput,
rightInput,
joinNodeBinder );
- this.tupleMemoryEnabled = context.isTupleMemoryEnabled();
+ this.tupleMemoryEnabled = context.isTupleMemoryEnabled();
}
/**
* Assert a new <code>ReteTuple</code> from the left input. It iterates
* over the right <code>FactHandleImpl</code>'s and if any match is found,
* a copy of the <code>ReteTuple</code> is made and propagated.
- *
+ *
* @param tuple
* The <code>Tuple</code> being asserted.
* @param context
@@ -90,7 +93,7 @@
final PropagationContext context,
final InternalWorkingMemory workingMemory) {
final BetaMemory memory = (BetaMemory) workingMemory.getNodeMemory( this );
-
+
if ( this.tupleMemoryEnabled ) {
memory.getTupleMemory().add( leftTuple );
}
@@ -99,15 +102,15 @@
this.constraints.updateFromTuple( memory.getContext(),
workingMemory,
leftTuple );
- for ( FactEntry entry = (FactEntry) it.next(); entry != null; entry = (FactEntry) it.next() ) {
+ for ( FactEntry entry = (FactEntry) it.next(); entry != null; entry = (FactEntry) it.next() ) {
final InternalFactHandle handle = entry.getFactHandle();
if ( this.constraints.isAllowedCachedLeft( memory.getContext(),
handle ) ) {
leftTuple.setMatch( handle );
break;
- }
+ }
}
-
+
this.constraints.resetTuple( memory.getContext() );
if ( leftTuple.getMatch() != null ) {
@@ -119,9 +122,9 @@
/**
* Assert a new <code>FactHandleImpl</code> from the right input. If it
- * matches any left ReteTuple's that had no matches before, propagate
+ * matches any left ReteTuple's that had no matches before, propagate
* tuple as an assertion.
- *
+ *
* @param handle
* The <code>FactHandleImpl</code> being asserted.
* @param context
@@ -134,11 +137,11 @@
final InternalWorkingMemory workingMemory) {
final BetaMemory memory = (BetaMemory) workingMemory.getNodeMemory( this );
memory.getFactHandleMemory().add( handle );
-
+
if ( !this.tupleMemoryEnabled ) {
// do nothing here, as we know there are no left tuples at this stage in sequential mode.
return;
- }
+ }
final Iterator it = memory.getTupleMemory().iterator( handle );
this.constraints.updateFromFactHandle( memory.getContext(),
@@ -150,10 +153,10 @@
tuple.setMatch( handle );
this.sink.propagateAssertTuple( tuple,
context,
- workingMemory );
+ workingMemory );
}
}
-
+
this.constraints.resetFactHandle( memory.getContext() );
}
@@ -161,7 +164,7 @@
* Retract the <code>FactHandleImpl</code>. If the handle has any
* <code>ReteTuple</code> matches and those tuples now have no
* other match, retract tuple
- *
+ *
* @param handle
* the <codeFactHandleImpl</code> being retracted
* @param context
@@ -185,14 +188,14 @@
if ( this.constraints.isAllowedCachedRight( memory.getContext(),
tuple ) ) {
if ( tuple.getMatch() == handle ) {
- // reset the match
+ // reset the match
tuple.setMatch( null );
-
+
// find next match, remember it and break.
final Iterator tupleIt = memory.getFactHandleMemory().iterator( tuple );
this.constraints.updateFromTuple( memory.getContext(),
workingMemory, tuple );
-
+
for ( FactEntry entry = (FactEntry) tupleIt.next(); entry != null; entry = (FactEntry) tupleIt.next() ) {
final InternalFactHandle rightHandle = entry.getFactHandle();
if ( this.constraints.isAllowedCachedLeft( memory.getContext(),
@@ -201,17 +204,17 @@
break;
}
}
-
+
this.constraints.resetTuple( memory.getContext() );
-
+
// if there is now no new tuple match then propagate assert.
if ( tuple.getMatch() == null ) {
this.sink.propagateRetractTuple( tuple,
context,
workingMemory );
- }
+ }
}
-
+
}
}
@@ -220,8 +223,8 @@
/**
* Retract the
- * <code>ReteTuple<code>, any resulting propagated joins are also retracted.
- *
+ * <code>ReteTuple<code>, any resulting propagated joins are also retracted.
+ *
* @param leftTuple
* The tuple being retracted
* @param context
@@ -249,7 +252,7 @@
/**
* Updates the given sink propagating all previously propagated tuples to it
- *
+ *
*/
public void updateSink(final TupleSink sink,
final PropagationContext context,
Modified: labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/reteoo/FactTemplateTypeConf.java
===================================================================
--- labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/reteoo/FactTemplateTypeConf.java 2008-03-20 18:57:07 UTC (rev 19163)
+++ labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/reteoo/FactTemplateTypeConf.java 2008-03-20 19:32:10 UTC (rev 19164)
@@ -1,12 +1,12 @@
/*
* Copyright 2007 JBoss Inc
- *
+ *
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -18,6 +18,10 @@
package org.drools.reteoo;
import java.io.Serializable;
+import java.io.Externalizable;
+import java.io.IOException;
+import java.io.ObjectOutput;
+import java.io.ObjectInput;
import org.drools.RuntimeDroolsException;
import org.drools.common.InternalRuleBase;
@@ -31,7 +35,7 @@
public class FactTemplateTypeConf
implements
ObjectTypeConf,
- Serializable {
+ Externalizable {
private static final long serialVersionUID = 4493660262148247467L;
@@ -39,6 +43,9 @@
private ObjectTypeNode concreteObjectTypeNode;
private ObjectTypeNode[] cache;
+ public FactTemplateTypeConf() {
+ }
+
public FactTemplateTypeConf(final EntryPoint entryPoint,
final FactTemplate factTemplate,
final InternalRuleBase ruleBase) {
@@ -59,13 +66,25 @@
context.setObjectTypeNodeMemoryEnabled( true );
context.setTerminalNodeMemoryEnabled( true );
}
- // there must exist an ObjectTypeNode for this concrete class
+ // there must exist an ObjectTypeNode for this concrete class
this.concreteObjectTypeNode = PatternBuilder.attachObjectTypeNode( context,
objectType );
}
this.cache = new ObjectTypeNode[]{this.concreteObjectTypeNode};
}
+ public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
+ factTemplate = (FactTemplate)in.readObject();
+ concreteObjectTypeNode = (ObjectTypeNode)in.readObject();
+ cache = (ObjectTypeNode[])in.readObject();
+ }
+
+ public void writeExternal(ObjectOutput out) throws IOException {
+ out.writeObject(factTemplate);
+ out.writeObject(concreteObjectTypeNode);
+ out.writeObject(cache);
+ }
+
public ObjectTypeNode getConcreteObjectTypeNode() {
return this.concreteObjectTypeNode;
}
Modified: labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/reteoo/FromNode.java
===================================================================
--- labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/reteoo/FromNode.java 2008-03-20 18:57:07 UTC (rev 19163)
+++ labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/reteoo/FromNode.java 2008-03-20 19:32:10 UTC (rev 19164)
@@ -1,6 +1,9 @@
package org.drools.reteoo;
import java.io.Serializable;
+import java.io.IOException;
+import java.io.ObjectInput;
+import java.io.ObjectOutput;
import org.drools.RuleBaseConfiguration;
import org.drools.common.BaseNode;
@@ -24,7 +27,7 @@
TupleSinkNode,
NodeMemory {
/**
- *
+ *
*/
private static final long serialVersionUID = 400L;
@@ -38,6 +41,9 @@
protected boolean tupleMemoryEnabled;
+ public FromNode() {
+ }
+
public FromNode(final int id,
final DataProvider dataProvider,
final TupleSource tupleSource,
@@ -51,8 +57,29 @@
this.tupleMemoryEnabled = false;
}
+ public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
+ super.readExternal(in);
+ dataProvider = (DataProvider)in.readObject();
+ tupleSource = (TupleSource)in.readObject();
+ alphaConstraints = (AlphaNodeFieldConstraint[])in.readObject();
+ betaConstraints = (BetaConstraints)in.readObject();
+ previousTupleSinkNode = (TupleSinkNode)in.readObject();
+ nextTupleSinkNode = (TupleSinkNode)in.readObject();
+ tupleMemoryEnabled = in.readBoolean();
+ }
+
+ public void writeExternal(ObjectOutput out) throws IOException {
+ super.writeExternal(out);
+ out.writeObject(dataProvider);
+ out.writeObject(tupleSource);
+ out.writeObject(alphaConstraints);
+ out.writeObject(betaConstraints);
+ out.writeObject(previousTupleSinkNode);
+ out.writeObject(nextTupleSinkNode);
+ out.writeBoolean(tupleMemoryEnabled);
+ }
/**
- * @inheritDoc
+ * @inheritDoc
*/
public void assertTuple(final ReteTuple leftTuple,
final PropagationContext context,
@@ -155,6 +182,10 @@
}
}
+ public void networkUpdated() {
+ this.tupleSource.networkUpdated();
+ }
+
protected void doRemove(final RuleRemovalContext context,
final ReteooBuilder builder,
final BaseNode node,
@@ -227,7 +258,7 @@
}
/**
- * Sets the next node
+ * Sets the next node
* @param next
* The next TupleSinkNode
*/
@@ -245,7 +276,7 @@
}
/**
- * Sets the previous node
+ * Sets the previous node
* @param previous
* The previous TupleSinkNode
*/
Modified: labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/reteoo/InitialFactHandle.java
===================================================================
--- labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/reteoo/InitialFactHandle.java 2008-03-20 18:57:07 UTC (rev 19163)
+++ labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/reteoo/InitialFactHandle.java 2008-03-20 19:32:10 UTC (rev 19164)
@@ -3,15 +3,19 @@
import org.drools.common.DefaultFactHandle;
import org.drools.common.InternalFactHandle;
+import java.io.ObjectInput;
+import java.io.IOException;
+import java.io.ObjectOutput;
+
/*
* Copyright 2005 JBoss Inc
- *
+ *
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -21,14 +25,17 @@
public class InitialFactHandle extends DefaultFactHandle {
/**
- *
+ *
*/
private static final long serialVersionUID = 400L;
- private final InternalFactHandle delegate;
+ private InternalFactHandle delegate;
private Object object;
+ public InitialFactHandle() {
+
+ }
public InitialFactHandle(final InternalFactHandle delegate) {
super();
this.delegate = delegate;
@@ -38,7 +45,18 @@
// ----------------------------------------------------------------------
// Instance members
// ----------------------------------------------------------------------
+ public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
+ super.readExternal(in);
+ delegate = (InternalFactHandle)in.readObject();
+ object = in.readObject();
+ }
+ public void writeExternal(ObjectOutput out) throws IOException {
+ super.writeExternal(out);
+ out.writeObject(delegate);
+ out.writeObject(object);
+ }
+
/**
* @see Object
*/
Modified: labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/reteoo/InitialFactImpl.java
===================================================================
--- labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/reteoo/InitialFactImpl.java 2008-03-20 18:57:07 UTC (rev 19163)
+++ labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/reteoo/InitialFactImpl.java 2008-03-20 19:32:10 UTC (rev 19164)
@@ -18,6 +18,11 @@
import org.drools.InitialFact;
+import java.io.Externalizable;
+import java.io.IOException;
+import java.io.ObjectInput;
+import java.io.ObjectOutput;
+
/**
* We dont want users to be able to instantiate InitialFact so we expose it as
* an interface and make the class and its constructor package protected
@@ -26,20 +31,26 @@
* @author <a href="mailto:bob at werken.com">Bob McWhirter</a>
*
*/
-final class InitialFactImpl
+public final class InitialFactImpl
implements
- InitialFact {
+ InitialFact, Externalizable {
private static final InitialFact INSTANCE = new InitialFactImpl();
- private final int hashCode = "InitialFactImpl".hashCode();
+ private final int hashCode = "InitialFactImpl".hashCode();
public static InitialFact getInstance() {
return InitialFactImpl.INSTANCE;
}
- private InitialFactImpl() {
+ public InitialFactImpl() {
}
+ public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
+ }
+
+ public void writeExternal(ObjectOutput out) throws IOException {
+
+ }
public int hashCode() {
return this.hashCode;
}
Modified: labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/reteoo/JoinNode.java
===================================================================
--- labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/reteoo/JoinNode.java 2008-03-20 18:57:07 UTC (rev 19163)
+++ labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/reteoo/JoinNode.java 2008-03-20 19:32:10 UTC (rev 19164)
@@ -2,13 +2,13 @@
/*
* Copyright 2005 JBoss Inc
- *
+ *
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -30,21 +30,21 @@
* considered to be asserted from the left input and facts from the right input.
* The <code>BetaNode</code> provides the BetaMemory to store assserted
* ReteTuples and
- * <code>FactHandleImpl<code>s. Each fact handle is stored in the right memory as a key in a <code>HashMap</code>, the value is an <code>ObjectMatches</code>
- * instance which maintains a <code>LinkedList of <code>TuplesMatches - The tuples that are matched with the handle. the left memory is a <code>LinkedList</code>
- * of <code>ReteTuples</code> which maintains a <code>HashMa</code>, where the keys are the matching <code>FactHandleImpl</code>s and the value is
- * populated <code>TupleMatche</code>es, the keys are matched fact handles. <code>TupleMatch</code> maintains a <code>List</code> of resulting joins,
+ * <code>FactHandleImpl<code>s. Each fact handle is stored in the right memory as a key in a <code>HashMap</code>, the value is an <code>ObjectMatches</code>
+ * instance which maintains a <code>LinkedList of <code>TuplesMatches - The tuples that are matched with the handle. the left memory is a <code>LinkedList</code>
+ * of <code>ReteTuples</code> which maintains a <code>HashMa</code>, where the keys are the matching <code>FactHandleImpl</code>s and the value is
+ * populated <code>TupleMatche</code>es, the keys are matched fact handles. <code>TupleMatch</code> maintains a <code>List</code> of resulting joins,
* where there is joined <code>ReteTuple</code> per <code>TupleSink</code>.
- *
- *
+ *
+ *
* The BetaNode provides
- * the BetaMemory which stores the
- *
+ * the BetaMemory which stores the
+ *
* @see BetaNode
* @see ObjectMatches
* @see TupleMatch
* @see TupleSink
- *
+ *
* @author <a href="mailto:mark.proctor at jboss.com">Mark Proctor</a>
* @author <a href="mailto:bob at werken.com">Bob McWhirter</a>
*
@@ -53,12 +53,16 @@
// ------------------------------------------------------------
// Instance methods
// ------------------------------------------------------------
-
+
/**
- *
+ *
*/
private static final long serialVersionUID = 400L;
+ public JoinNode() {
+
+ }
+
public JoinNode(final int id,
final TupleSource leftInput,
final ObjectSource rightInput,
@@ -76,12 +80,12 @@
* <code>FactHandleInput</code>'s is iterated and joins attemped, via the
* binder, any successful bindings results in joined tuples being created
* and propaged. there is a joined tuple per TupleSink.
- *
+ *
* @see ReteTuple
* @see ObjectMatches
* @see TupleSink
* @see TupleMatch
- *
+ *
* @param tuple
* The <code>Tuple</code> being asserted.
* @param context
@@ -93,7 +97,7 @@
final PropagationContext context,
final InternalWorkingMemory workingMemory) {
final BetaMemory memory = (BetaMemory) workingMemory.getNodeMemory( this );
-
+
if ( this.tupleMemoryEnabled ) {
memory.getTupleMemory().add( leftTuple );
}
@@ -112,7 +116,7 @@
workingMemory );
}
}
-
+
this.constraints.resetTuple( memory.getContext() );
}
@@ -121,12 +125,12 @@
* <code>ReteTuple</code>s is iterated and joins attemped, via the
* binder, any successful bindings results in joined tuples being created
* and propaged. there is a joined tuple per TupleSink.
- *
+ *
* @see ReteTuple
* @see ObjectMatches
* @see TupleSink
* @see TupleMatch
- *
+ *
* @param handle
* The <code>FactHandleImpl</code> being asserted.
* @param context
@@ -164,7 +168,7 @@
/**
* Retract a FactHandleImpl. Iterates the referenced TupleMatches stored in
* the handle's ObjectMatches retracting joined tuples.
- *
+ *
* @param handle
* the <codeFactHandleImpl</code> being retracted
* @param context
@@ -193,7 +197,7 @@
workingMemory );
}
}
-
+
this.constraints.resetFactHandle( memory.getContext() );
}
@@ -201,7 +205,7 @@
* Retract a <code>ReteTuple</code>. Iterates the referenced
* <code>TupleMatche</code>'s stored in the tuples <code>Map</code>
* retracting all joined tuples.
- *
+ *
* @param key
* The tuple key.
* @param context
@@ -232,7 +236,7 @@
workingMemory );
}
}
-
+
this.constraints.resetTuple( memory.getContext() );
}
@@ -261,7 +265,7 @@
workingMemory );
}
}
-
+
this.constraints.resetTuple( memory.getContext() );
}
}
Modified: labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/reteoo/LIANodePropagation.java
===================================================================
--- labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/reteoo/LIANodePropagation.java 2008-03-20 18:57:07 UTC (rev 19163)
+++ labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/reteoo/LIANodePropagation.java 2008-03-20 19:32:10 UTC (rev 19164)
@@ -4,11 +4,16 @@
import org.drools.common.InternalWorkingMemory;
import org.drools.spi.PropagationContext;
-public class LIANodePropagation {
- private final LeftInputAdapterNode node;
- private final InternalFactHandle handle;
- private final PropagationContext context;
-
+import java.io.Externalizable;
+import java.io.IOException;
+import java.io.ObjectOutput;
+import java.io.ObjectInput;
+
+public class LIANodePropagation implements Externalizable {
+ private LeftInputAdapterNode node;
+ private InternalFactHandle handle;
+ private PropagationContext context;
+
public LIANodePropagation(final LeftInputAdapterNode node,
final InternalFactHandle handle,
final PropagationContext context ) {
@@ -17,10 +22,22 @@
this.handle = handle;
this.context = context;
}
-
+
+ public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
+ node = (LeftInputAdapterNode)in.readObject();
+ handle = (InternalFactHandle)in.readObject();
+ context = (PropagationContext)in.readObject();
+ }
+
+ public void writeExternal(ObjectOutput out) throws IOException {
+ out.writeObject(node);
+ out.writeObject(handle);
+ out.writeObject(context);
+ }
+
public void doPropagation(InternalWorkingMemory workingMemory) {
node.getSinkPropagator().createAndPropagateAssertTuple( handle, context, workingMemory );
}
-
-
+
+
}
Modified: labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/reteoo/LeftInputAdapterNode.java
===================================================================
--- labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/reteoo/LeftInputAdapterNode.java 2008-03-20 18:57:07 UTC (rev 19163)
+++ labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/reteoo/LeftInputAdapterNode.java 2008-03-20 19:32:10 UTC (rev 19164)
@@ -2,13 +2,13 @@
/*
* Copyright 2005 JBoss Inc
- *
+ *
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -28,12 +28,16 @@
import org.drools.util.FactHashTable;
import org.drools.util.Iterator;
+import java.io.ObjectOutput;
+import java.io.IOException;
+import java.io.ObjectInput;
+
/**
* All asserting Facts must propagated into the right <code>ObjectSink</code> side of a BetaNode, if this is the first Pattern
- * then there are no BetaNodes to propagate to. <code>LeftInputAdapter</code> is used to adapt an ObjectSink propagation into a
- * <code>TupleSource</code> which propagates a <code>ReteTuple</code> suitable fot the right <code>ReteTuple</code> side
+ * then there are no BetaNodes to propagate to. <code>LeftInputAdapter</code> is used to adapt an ObjectSink propagation into a
+ * <code>TupleSource</code> which propagates a <code>ReteTuple</code> suitable fot the right <code>ReteTuple</code> side
* of a <code>BetaNode</code>.
- *
+ *
* @author <a href="mailto:mark.proctor at jboss.com">Mark Proctor</a>
* @author <a href="mailto:bob at werken.com">Bob McWhirter</a>
*
@@ -44,20 +48,24 @@
NodeMemory {
/**
- *
+ *
*/
private static final long serialVersionUID = 400L;
- private final ObjectSource objectSource;
+ private ObjectSource objectSource;
private ObjectSinkNode previousObjectSinkNode;
private ObjectSinkNode nextObjectSinkNode;
-
- private boolean objectMemoryEnabled;
+ private boolean objectMemoryEnabled;
+
+ public LeftInputAdapterNode() {
+
+ }
+
/**
- * Constructus a LeftInputAdapterNode with a unique id that receives <code>FactHandle</code> from a
+ * Constructus a LeftInputAdapterNode with a unique id that receives <code>FactHandle</code> from a
* parent <code>ObjectSource</code> and adds it to a given pattern in the resulting Tuples.
- *
+ *
* @param id
* The unique id of this node in the current Rete network
* @param source
@@ -75,6 +83,21 @@
setObjectMemoryEnabled( false );
}
+ public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
+ super.readExternal(in);
+ objectSource = (ObjectSource)in.readObject();
+ previousObjectSinkNode = (ObjectSinkNode)in.readObject();
+ nextObjectSinkNode = (ObjectSinkNode)in.readObject();
+ objectMemoryEnabled = in.readBoolean();
+ }
+
+ public void writeExternal(ObjectOutput out) throws IOException {
+ super.writeExternal(out);
+ out.writeObject(objectSource);
+ out.writeObject(previousObjectSinkNode);
+ out.writeObject(nextObjectSinkNode);
+ out.writeBoolean(objectMemoryEnabled);
+ }
/* (non-Javadoc)
* @see org.drools.reteoo.BaseNode#attach()
*/
@@ -97,14 +120,18 @@
}
}
+ public void networkUpdated() {
+ this.objectSource.networkUpdated();
+ }
+
/**
* Takes the asserted <code>FactHandleImpl</code> received from the <code>ObjectSource</code> and puts it
* in a new <code>ReteTuple</code> before propagating to the <code>TupleSinks</code>
- *
+ *
* @param handle
* The asserted <code>FactHandle/code>.
* @param context
- * The <code>PropagationContext</code> of the <code>WorkingMemory<code> action.
+ * The <code>PropagationContext</code> of the <code>WorkingMemory<code> action.
* @param workingMemory
* the <code>WorkingMemory</code> session.
*/
@@ -128,13 +155,13 @@
}
/**
- * Retract an existing <code>FactHandleImpl</code> by placing it in a new <code>ReteTuple</code> before
+ * Retract an existing <code>FactHandleImpl</code> by placing it in a new <code>ReteTuple</code> before
* proagating to the <code>TupleSinks</code>
- *
+ *
* @param handle
* The <code>FactHandle/code> to retract.
* @param context
- * The <code>PropagationContext</code> of the <code>WorkingMemory<code> action.
+ * The <code>PropagationContext</code> of the <code>WorkingMemory<code> action.
* @param workingMemory
* the <code>WorkingMemory</code> session.
*/
@@ -192,15 +219,15 @@
builder,
this,
workingMemories );
- }
-
+ }
+
public boolean isObjectMemoryEnabled() {
return this.objectMemoryEnabled;
}
public void setObjectMemoryEnabled(boolean objectMemoryEnabled) {
this.objectMemoryEnabled = objectMemoryEnabled;
- }
+ }
/**
* Returns the next node
@@ -212,7 +239,7 @@
}
/**
- * Sets the next node
+ * Sets the next node
* @param next
* The next ObjectSinkNode
*/
@@ -230,7 +257,7 @@
}
/**
- * Sets the previous node
+ * Sets the previous node
* @param previous
* The previous ObjectSinkNode
*/
@@ -295,14 +322,14 @@
final InternalWorkingMemory workingMemory) {
throw new UnsupportedOperationException( "ObjectSinkAdapter onlys supports assertObject method calls" );
}
-
+
public boolean isObjectMemoryEnabled() {
throw new UnsupportedOperationException("ObjectSinkAdapters have no Object memory");
}
public void setObjectMemoryEnabled(boolean objectMemoryEnabled) {
throw new UnsupportedOperationException("ObjectSinkAdapters have no Object memory");
- }
+ }
}
}
Modified: labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/reteoo/MemoryVisitor.java
===================================================================
--- labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/reteoo/MemoryVisitor.java 2008-03-20 18:57:07 UTC (rev 19163)
+++ labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/reteoo/MemoryVisitor.java 2008-03-20 19:32:10 UTC (rev 19164)
@@ -2,6 +2,10 @@
import java.lang.reflect.Field;
import java.util.Map;
+import java.io.Externalizable;
+import java.io.ObjectOutput;
+import java.io.ObjectInput;
+import java.io.IOException;
import org.drools.common.InternalWorkingMemory;
import org.drools.reteoo.RuleTerminalNode.TerminalNodeMemory;
@@ -13,17 +17,30 @@
import org.drools.util.ReflectiveVisitor;
import org.drools.util.FactHandleIndexHashTable.FieldIndexEntry;
-public class MemoryVisitor extends ReflectiveVisitor {
+public class MemoryVisitor extends ReflectiveVisitor implements Externalizable {
private InternalWorkingMemory workingMemory;
private int indent = 0;
/**
* Constructor.
*/
+ public MemoryVisitor() {
+ }
+
public MemoryVisitor(final InternalWorkingMemory workingMemory) {
this.workingMemory = workingMemory;
}
+ public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
+ workingMemory = (InternalWorkingMemory)in.readObject();
+ indent = in.readInt();
+ }
+
+ public void writeExternal(ObjectOutput out) throws IOException {
+ out.writeObject(workingMemory);
+ out.writeInt(indent);
+ }
+
/**
* RuleBaseImpl visits its Rete.
*/
Modified: labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/reteoo/NotNode.java
===================================================================
--- labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/reteoo/NotNode.java 2008-03-20 18:57:07 UTC (rev 19163)
+++ labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/reteoo/NotNode.java 2008-03-20 19:32:10 UTC (rev 19164)
@@ -2,13 +2,13 @@
/*
* Copyright 2005 JBoss Inc
- *
+ *
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -30,14 +30,14 @@
* the non existence of a Fact plus one or more conditions. Where none existence
* is found the left ReteTuple is copied and propgated. Further to this it
* maintains the "truth" by cancelling any
- * <code>Activation<code>s that are nolonger
+ * <code>Activation<code>s that are nolonger
* considered true by the assertion of ReteTuple's or FactHandleImpl. Tuples are considered to be asserted from the left input and facts from the right input.
- * The <code>BetaNode</code> provides the BetaMemory to store assserted ReteTuples and <code>FactHandleImpl<code>s. Each fact handle is stored in the right
- * memory as a key in a <code>HashMap</code>, the value is an <code>ObjectMatches</code> instance which maintains a <code>LinkedList of <code>TuplesMatches -
- * The tuples that are matched with the handle. the left memory is a <code>LinkedList</code> of <code>ReteTuples</code> which maintains a <code>HashMa</code>,
- * where the keys are the matching <code>FactHandleImpl</code>s and the value is populated <code>TupleMatche</code>es, the keys are matched fact handles.
+ * The <code>BetaNode</code> provides the BetaMemory to store assserted ReteTuples and <code>FactHandleImpl<code>s. Each fact handle is stored in the right
+ * memory as a key in a <code>HashMap</code>, the value is an <code>ObjectMatches</code> instance which maintains a <code>LinkedList of <code>TuplesMatches -
+ * The tuples that are matched with the handle. the left memory is a <code>LinkedList</code> of <code>ReteTuples</code> which maintains a <code>HashMa</code>,
+ * where the keys are the matching <code>FactHandleImpl</code>s and the value is populated <code>TupleMatche</code>es, the keys are matched fact handles.
* <code>TupleMatch</code> maintains a <code>List</code> of resulting joins, where there is joined <code>ReteTuple</code> per <code>TupleSink</code>.
- *
+ *
* @author <a href="mailto:mark.proctor at jboss.com">Mark Proctor</a>
* @author <a href="mailto:bob at werken.com">Bob McWhirter</a>
*
@@ -51,10 +51,12 @@
// ------------------------------------------------------------
// Instance methods
// ------------------------------------------------------------
+ public NotNode() {
+ }
/**
* Construct.
- *
+ *
* @param leftInput
* The left input <code>TupleSource</code>.
* @param rightInput
@@ -69,14 +71,14 @@
leftInput,
rightInput,
joinNodeBinder );
- this.tupleMemoryEnabled = context.isTupleMemoryEnabled();
+ this.tupleMemoryEnabled = context.isTupleMemoryEnabled();
}
/**
* Assert a new <code>ReteTuple</code> from the left input. It iterates
* over the right <code>FactHandleImpl</code>'s if no matches are found
* the a copy of the <code>ReteTuple</code> is made and propagated.
- *
+ *
* @param tuple
* The <code>Tuple</code> being asserted.
* @param context
@@ -88,7 +90,7 @@
final PropagationContext context,
final InternalWorkingMemory workingMemory) {
final BetaMemory memory = (BetaMemory) workingMemory.getNodeMemory( this );
-
+
if ( this.tupleMemoryEnabled ) {
memory.getTupleMemory().add( leftTuple );
}
@@ -97,7 +99,7 @@
this.constraints.updateFromTuple( memory.getContext(),
workingMemory,
leftTuple );
-
+
for ( FactEntry entry = (FactEntry) it.next(); entry != null; entry = (FactEntry) it.next() ) {
final InternalFactHandle handle = entry.getFactHandle();
if ( this.constraints.isAllowedCachedLeft( memory.getContext(),
@@ -106,7 +108,7 @@
break;
}
}
-
+
this.constraints.resetTuple( memory.getContext() );
if ( leftTuple.getMatch() == null ) {
@@ -120,7 +122,7 @@
* Assert a new <code>FactHandleImpl</code> from the right input. If it
* matches any left ReteTuple's that already has propagations then those
* propagations are retracted.
- *
+ *
* @param handle
* The <code>FactHandleImpl</code> being asserted.
* @param context
@@ -133,11 +135,11 @@
final InternalWorkingMemory workingMemory) {
final BetaMemory memory = (BetaMemory) workingMemory.getNodeMemory( this );
memory.getFactHandleMemory().add( handle );
-
+
if ( !this.tupleMemoryEnabled ) {
// do nothing here, as we know there are no left tuples at this stage in sequential mode.
return;
- }
+ }
final Iterator it = memory.getTupleMemory().iterator( handle );
this.constraints.updateFromFactHandle( memory.getContext(),
@@ -149,10 +151,10 @@
tuple.setMatch( handle );
this.sink.propagateRetractTuple( tuple,
context,
- workingMemory );
+ workingMemory );
}
}
-
+
this.constraints.resetFactHandle( memory.getContext() );
}
@@ -160,7 +162,7 @@
* Retract the <code>FactHandleImpl</code>. If the handle has any
* <code>ReteTuple</code> matches then those matches copied are propagated
* as new joins.
- *
+ *
* @param handle
* the <codeFactHandleImpl</code> being retracted
* @param context
@@ -184,16 +186,16 @@
for ( ReteTuple tuple = (ReteTuple) it.next(); tuple != null; tuple = (ReteTuple) it.next() ) {
if ( this.constraints.isAllowedCachedRight( memory.getContext(),
tuple ) ) {
-
+
if ( tuple.getMatch() == handle ) {
- // reset the match
+ // reset the match
tuple.setMatch( null );
-
+
// find next match, remember it and break.
final Iterator tupleIt = memory.getFactHandleMemory().iterator( tuple );
this.constraints.updateFromTuple( memory.getContext(),
workingMemory, tuple );
-
+
for ( FactEntry entry = (FactEntry) tupleIt.next(); entry != null; entry = (FactEntry) tupleIt.next() ) {
final InternalFactHandle rightHandle = entry.getFactHandle();
if ( this.constraints.isAllowedCachedLeft( memory.getContext(),
@@ -202,25 +204,25 @@
break;
}
}
-
+
this.constraints.resetTuple( memory.getContext() );
// if there is now no new tuple match then propagate assert.
if ( tuple.getMatch() == null ) {
this.sink.propagateAssertTuple( tuple,
context,
workingMemory );
- }
+ }
}
}
}
-
+
this.constraints.resetFactHandle( memory.getContext() );
}
/**
* Retract the
- * <code>ReteTuple<code>, any resulting proppagated joins are also retracted.
- *
+ * <code>ReteTuple<code>, any resulting proppagated joins are also retracted.
+ *
* @param key
* The tuple key.
* @param context
Modified: labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/reteoo/ObjectSinkNodeList.java
===================================================================
--- labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/reteoo/ObjectSinkNodeList.java 2008-03-20 18:57:07 UTC (rev 19163)
+++ labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/reteoo/ObjectSinkNodeList.java 2008-03-20 19:32:10 UTC (rev 19164)
@@ -1,18 +1,21 @@
package org.drools.reteoo;
-import java.io.Serializable;
+import java.io.Externalizable;
+import java.io.ObjectInput;
+import java.io.IOException;
+import java.io.ObjectOutput;
import java.util.Iterator;
import java.util.NoSuchElementException;
/*
* Copyright 2005 JBoss Inc
- *
+ *
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -23,7 +26,7 @@
/**
* This is a simple linked linked implementation. Each node must implement </code>LinkedListNode<code> so that it references
* the node before and after it. This way a node can be removed without having to scan the list to find it. This class
- * does not provide an Iterator implementation as its designed for efficiency and not genericity. There are a number of
+ * does not provide an Iterator implementation as its designed for efficiency and not genericity. There are a number of
* ways to iterate the list.
* <p>
* Simple iterator:
@@ -31,7 +34,7 @@
* for ( LinkedListNode node = list.getFirst(); node != null; node = node.getNext() ) {
* }
* </pre>
- *
+ *
* Iterator that pops the first entry:
* <pre>
* for ( LinkedListNode node = list.removeFirst(); node != null; node = list.removeFirst() ) {
@@ -45,7 +48,7 @@
*/
public class ObjectSinkNodeList
implements
- Serializable {
+ Externalizable {
private static final long serialVersionUID = 400L;
private ObjectSinkNode firstNode;
@@ -60,10 +63,21 @@
}
+ public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
+ firstNode = (ObjectSinkNode)in.readObject();
+ lastNode = (ObjectSinkNode)in.readObject();
+ size = in.readInt();
+ }
+
+ public void writeExternal(ObjectOutput out) throws IOException {
+ out.writeObject(firstNode);
+ out.writeObject(lastNode);
+ out.writeInt(size);
+ }
/**
- * Add a <code>ObjectSinkNode</code> to the list. If the <code>LinkedList</code> is empty then the first and
+ * Add a <code>ObjectSinkNode</code> to the list. If the <code>LinkedList</code> is empty then the first and
* last nodes are set to the added node.
- *
+ *
* @param node
* The <code>ObjectSinkNode</code> to be added
*/
@@ -83,7 +97,7 @@
* Removes a <code>ObjectSinkNode</code> from the list. This works by attach the previous reference to the child reference.
* When the node to be removed is the first node it calls <code>removeFirst()</code>. When the node to be removed is the last node
* it calls <code>removeLast()</code>.
- *
+ *
* @param node
* The <code>ObjectSinkNode</code> to be removed.
*/
@@ -123,9 +137,9 @@
}
/**
- * Remove the first node from the list. The next node then becomes the first node. If this is the last
+ * Remove the first node from the list. The next node then becomes the first node. If this is the last
* node then both first and last node references are set to null.
- *
+ *
* @return
* The first <code>ObjectSinkNode</code>.
*/
@@ -146,9 +160,9 @@
}
/**
- * Remove the last node from the list. The previous node then becomes the last node. If this is the last
+ * Remove the last node from the list. The previous node then becomes the last node. If this is the last
* node then both first and last node references are set to null.
- *
+ *
* @return
* The first <code>ObjectSinkNode</code>.
*/
@@ -177,7 +191,7 @@
}
/**
- * Iterates the list removing all the nodes until there are no more nodes to remove.
+ * Iterates the list removing all the nodes until there are no more nodes to remove.
*/
public void clear() {
while ( removeFirst() != null ) {
Modified: labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/reteoo/ObjectSinkPropagator.java
===================================================================
--- labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/reteoo/ObjectSinkPropagator.java 2008-03-20 18:57:07 UTC (rev 19163)
+++ labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/reteoo/ObjectSinkPropagator.java 2008-03-20 19:32:10 UTC (rev 19164)
@@ -1,6 +1,7 @@
package org.drools.reteoo;
import java.io.Serializable;
+import java.io.Externalizable;
import org.drools.common.InternalFactHandle;
import org.drools.common.InternalWorkingMemory;
@@ -8,7 +9,7 @@
public interface ObjectSinkPropagator
extends
- Serializable {
+ Externalizable {
public void propagateAssertObject(InternalFactHandle handle,
PropagationContext context,
InternalWorkingMemory workingMemory);
@@ -19,6 +20,6 @@
boolean useHash);
public ObjectSink[] getSinks();
-
+
public int size();
}
Modified: labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/reteoo/ObjectSource.java
===================================================================
--- labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/reteoo/ObjectSource.java 2008-03-20 18:57:07 UTC (rev 19163)
+++ labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/reteoo/ObjectSource.java 2008-03-20 19:32:10 UTC (rev 19164)
@@ -2,13 +2,13 @@
/*
* Copyright 2005 JBoss Inc
- *
+ *
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -17,6 +17,10 @@
*/
import java.io.Serializable;
+import java.io.Externalizable;
+import java.io.IOException;
+import java.io.ObjectInput;
+import java.io.ObjectOutput;
import org.drools.common.BaseNode;
import org.drools.common.DefaultFactHandle;
@@ -25,20 +29,20 @@
/**
* A source of <code>FactHandle</code>s for an <code>ObjectSink</code>.
- *
+ *
* <p>
* Nodes that propagate <code>FactHandleImpl</code> extend this class.
* </p>
- *
+ *
* @see ObjectSource
* @see DefaultFactHandle
- *
+ *
* @author <a href="mailto:mark.proctor at jboss.com">Mark Proctor</a>
* @author <a href="mailto:bob at werken.com">Bob McWhirter</a>
*/
public abstract class ObjectSource extends BaseNode
implements
- Serializable {
+ Externalizable {
// ------------------------------------------------------------
// Instance members
// ------------------------------------------------------------
@@ -53,10 +57,13 @@
// ------------------------------------------------------------
// Constructors
// ------------------------------------------------------------
+ public ObjectSource() {
+ }
+
/**
* Single parameter constructor that specifies the unique id of the node.
- *
+ *
* @param id
*/
ObjectSource(final int id) {
@@ -67,7 +74,7 @@
/**
* Single parameter constructor that specifies the unique id of the node.
- *
+ *
* @param id
*/
ObjectSource(final int id,
@@ -82,18 +89,31 @@
// ------------------------------------------------------------
// Instance methods
// ------------------------------------------------------------
+ public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
+ super.readExternal(in);
+ sink = (ObjectSinkPropagator)in.readObject();
+ objectSource = (ObjectSource)in.readObject();
+ alphaNodeHashingThreshold = in.readInt();
+ }
+ public void writeExternal(ObjectOutput out) throws IOException {
+ super.writeExternal(out);
+ out.writeObject(sink);
+ out.writeObject(objectSource);
+ out.writeInt(alphaNodeHashingThreshold);
+ }
+
/**
* Adds the <code>ObjectSink</code> so that it may receive
* <code>FactHandleImpl</code> propagated from this
* <code>ObjectSource</code>.
- *
+ *
* @param objectSink
* The <code>ObjectSink</code> to receive propagated
* <code>FactHandleImpl</code>.
*/
protected void addObjectSink(final ObjectSink objectSink) {
- if ( this.sink == EmptyObjectSinkAdapter.getInstance() ) {
+ if ( this.sink instanceof EmptyObjectSinkAdapter ) {
this.sink = new SingleObjectSinkAdapter( objectSink );
} else if ( this.sink instanceof SingleObjectSinkAdapter ) {
final CompositeObjectSinkAdapter sinkAdapter = new CompositeObjectSinkAdapter( this.alphaNodeHashingThreshold );
@@ -107,12 +127,12 @@
/**
* Removes the <code>ObjectSink</code>
- *
+ *
* @param objectSink
* The <code>ObjectSink</code> to remove
*/
protected void removeObjectSink(final ObjectSink objectSink) {
- if ( this.sink == EmptyObjectSinkAdapter.getInstance() ) {
+ if ( this.sink instanceof EmptyObjectSinkAdapter ) {
throw new IllegalArgumentException( "Cannot remove a sink, when the list of sinks is null" );
}
@@ -130,11 +150,15 @@
public abstract void updateSink(ObjectSink sink,
PropagationContext context,
InternalWorkingMemory workingMemory);
+
+ public void networkUpdated() {
+ this.objectSource.networkUpdated();
+ }
public ObjectSinkPropagator getSinkPropagator() {
return this.sink;
}
-
+
public boolean isInUse() {
return this.sink.size() > 0;
}
Modified: labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/reteoo/ObjectTypeNode.java
===================================================================
--- labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/reteoo/ObjectTypeNode.java 2008-03-20 18:57:07 UTC (rev 19163)
+++ labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/reteoo/ObjectTypeNode.java 2008-03-20 19:32:10 UTC (rev 19164)
@@ -2,13 +2,13 @@
/*
* Copyright 2005 JBoss Inc
- *
+ *
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -17,6 +17,10 @@
*/
import java.io.Serializable;
+import java.io.Externalizable;
+import java.io.ObjectOutput;
+import java.io.IOException;
+import java.io.ObjectInput;
import org.drools.RuleBaseConfiguration;
import org.drools.common.BaseNode;
@@ -27,6 +31,7 @@
import org.drools.reteoo.builder.BuildContext;
import org.drools.rule.Declaration;
import org.drools.rule.EntryPoint;
+import org.drools.rule.EvalCondition;
import org.drools.spi.Constraint;
import org.drools.spi.ObjectType;
import org.drools.spi.PropagationContext;
@@ -45,18 +50,18 @@
* <p>
* Filters <code>Objects</code> coming from the <code>Rete</code> using a
* <code>ObjectType</code> semantic module.
- *
- *
+ *
+ *
* @see ObjectType
* @see Rete
- *
+ *
* @author <a href="mailto:mark.proctor at jboss.com">Mark Proctor</a>
* @author <a href="mailto:bob at werken.com">Bob McWhirter</a>
*/
public class ObjectTypeNode extends ObjectSource
implements
ObjectSink,
- Serializable,
+ Externalizable,
NodeMemory
{
@@ -65,21 +70,25 @@
// ------------------------------------------------------------
/**
- *
+ *
*/
private static final long serialVersionUID = 400L;
/** The <code>ObjectType</code> semantic module. */
- private final ObjectType objectType;
+ private ObjectType objectType;
private boolean skipOnModify = false;
private boolean objectMemoryEnabled;
+ public ObjectTypeNode() {
+
+ }
+
/**
* Construct given a semantic <code>ObjectType</code> and the provided
* unique id. All <code>ObjectTypdeNode</code> have node memory.
- *
+ *
* @param id
* The unique id for the node.
* @param objectType
@@ -96,10 +105,23 @@
setObjectMemoryEnabled( context.isObjectTypeNodeMemoryEnabled() );
}
+ public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
+ super.readExternal(in);
+ objectType = (ObjectType)in.readObject();
+ skipOnModify = in.readBoolean();
+ objectMemoryEnabled = in.readBoolean();
+ }
+
+ public void writeExternal(ObjectOutput out) throws IOException {
+ super.writeExternal(out);
+ out.writeObject(objectType);
+ out.writeBoolean(skipOnModify);
+ out.writeBoolean(objectMemoryEnabled);
+ }
/**
* Retrieve the semantic <code>ObjectType</code> differentiator.
- *
- * @return
+ *
+ * @return
* The semantic <code>ObjectType</code> differentiator.
*/
public ObjectType getObjectType() {
@@ -109,7 +131,7 @@
/**
* Tests the provided object to see if this <code>ObjectTypeNode</code> can receive the object
* for assertion and retraction propagations.
- *
+ *
* @param object
* @return
* boolean value indicating whether the <code>ObjectTypeNode</code> can receive the object.
@@ -126,7 +148,7 @@
* Propagate the <code>FactHandleimpl</code> through the <code>Rete</code> network. All
* <code>FactHandleImpl</code> should be remembered in the node memory, so that later runtime rule attachmnents
* can have the matched facts propagated to them.
- *
+ *
* @param handle
* The fact handle.
* @param object
@@ -154,9 +176,9 @@
}
/**
- * Retract the <code>FactHandleimpl</code> from the <code>Rete</code> network. Also remove the
+ * Retract the <code>FactHandleimpl</code> from the <code>Rete</code> network. Also remove the
* <code>FactHandleImpl</code> from the node memory.
- *
+ *
* @param handle
* The fact handle.
* @param object
@@ -203,8 +225,8 @@
public void attach(final InternalWorkingMemory[] workingMemories) {
attach();
- // we need to call updateSink on Rete, because someone
- // might have already added facts matching this ObjectTypeNode
+ // we need to call updateSink on Rete, because someone
+ // might have already added facts matching this ObjectTypeNode
// to working memories
for ( int i = 0, length = workingMemories.length; i < length; i++ ) {
final InternalWorkingMemory workingMemory = workingMemories[i];
@@ -219,10 +241,14 @@
}
}
+ public void networkUpdated() {
+ this.skipOnModify = canSkipOnModify( this.sink.getSinks() );
+ }
+
/**
- * OTN needs to override remove to avoid releasing the node ID, since OTN are
+ * OTN needs to override remove to avoid releasing the node ID, since OTN are
* never removed from the rulebase in the current implementation
- *
+ *
* @inheritDoc
*
* @see org.drools.common.BaseNode#remove(org.drools.reteoo.RuleRemovalContext, org.drools.reteoo.ReteooBuilder, org.drools.common.BaseNode, org.drools.common.InternalWorkingMemory[])
@@ -288,12 +314,11 @@
return this.objectType.equals( other.objectType ) && this.objectSource.equals( other.objectSource );
}
- /**
+ /**
* @inheritDoc
*/
protected void addObjectSink(final ObjectSink objectSink) {
super.addObjectSink( objectSink );
- this.skipOnModify = canSkipOnModify( this.sink.getSinks() );
}
/**
@@ -301,13 +326,12 @@
*/
protected void removeObjectSink(final ObjectSink objectSink) {
super.removeObjectSink( objectSink );
- this.skipOnModify = canSkipOnModify( this.sink.getSinks() );
}
/**
* Checks if a modify action on this object type may
* be skipped because no constraint is applied to it
- *
+ *
* @param sinks
* @return
*/
@@ -315,15 +339,17 @@
// If we have no alpha or beta node with constraints on this ObjectType, we can just skip modifies
boolean hasConstraints = false;
for ( int i = 0; i < sinks.length && !hasConstraints; i++ ) {
- if ( sinks[i] instanceof AlphaNode ) {
- hasConstraints = this.usesDeclaration( ((AlphaNode) sinks[i]).getConstraint() );
+ if ( sinks[i] instanceof AlphaNode || sinks[i] instanceof AccumulateNode || sinks[i] instanceof CollectNode || sinks[i] instanceof FromNode ) {
+ hasConstraints = true;
} else if ( sinks[i] instanceof BetaNode && ((BetaNode) sinks[i]).getConstraints().length > 0 ) {
hasConstraints = this.usesDeclaration( ((BetaNode) sinks[i]).getConstraints() );
+ } else if ( sinks[i] instanceof EvalConditionNode ) {
+ hasConstraints = this.usesDeclaration( ((EvalConditionNode)sinks[i]).getCondition() );
}
if ( !hasConstraints && sinks[i] instanceof ObjectSource ) {
- hasConstraints = this.canSkipOnModify( ((ObjectSource) sinks[i]).getSinkPropagator().getSinks() );
- } else if ( sinks[i] instanceof TupleSource ) {
- hasConstraints = this.canSkipOnModify( ((TupleSource) sinks[i]).getSinkPropagator().getSinks() );
+ hasConstraints = !this.canSkipOnModify( ((ObjectSource) sinks[i]).getSinkPropagator().getSinks() );
+ } else if ( !hasConstraints && sinks[i] instanceof TupleSource ) {
+ hasConstraints = !this.canSkipOnModify( ((TupleSource) sinks[i]).getSinkPropagator().getSinks() );
}
}
@@ -331,6 +357,7 @@
return !hasConstraints;
}
+
private boolean usesDeclaration(final Constraint[] constraints) {
boolean usesDecl = false;
for ( int i = 0; !usesDecl && i < constraints.length; i++ ) {
@@ -348,6 +375,15 @@
return usesDecl;
}
+ private boolean usesDeclaration(final EvalCondition condition) {
+ boolean usesDecl = false;
+ final Declaration[] declarations = condition.getRequiredDeclarations();
+ for ( int j = 0; !usesDecl && j < declarations.length; j++ ) {
+ usesDecl = (declarations[j].getPattern().getObjectType() == this.objectType);
+ }
+ return usesDecl;
+ }
+
/**
* @return the entryPoint
*/
Modified: labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/reteoo/PropagationQueuingNode.java
===================================================================
--- labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/reteoo/PropagationQueuingNode.java 2008-03-20 18:57:07 UTC (rev 19163)
+++ labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/reteoo/PropagationQueuingNode.java 2008-03-20 19:32:10 UTC (rev 19164)
@@ -1,12 +1,12 @@
/*
* Copyright 2008 JBoss Inc
- *
+ *
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -15,7 +15,10 @@
*/
package org.drools.reteoo;
-import java.io.Serializable;
+import java.io.ObjectOutput;
+import java.io.IOException;
+import java.io.ObjectInput;
+import java.io.Externalizable;
import java.util.concurrent.ConcurrentLinkedQueue;
import java.util.concurrent.atomic.AtomicBoolean;
@@ -33,7 +36,7 @@
* A node that will add the propagation to the working memory actions queue,
* in order to allow multiple threads to concurrently assert objects to multiple
* entry points.
- *
+ *
* @author etirelli
*
*/
@@ -43,7 +46,7 @@
NodeMemory {
private static final long serialVersionUID = -615639068150958767L;
-
+
// should we make this one configurable?
private static final int PROPAGATION_SLICE_LIMIT = 1000;
@@ -51,11 +54,14 @@
private ObjectSinkNode nextObjectSinkNode;
private PropagateAction action;
+ public PropagationQueuingNode() {
+ }
+
/**
* Construct a <code>PropagationQueuingNode</code> that will queue up
* propagations until it the engine reaches a safe propagation point,
* when all the queued facts are propagated.
- *
+ *
* @param id Node's ID
* @param constraint Node's constraints
* @param objectSource Node's object source
@@ -70,6 +76,20 @@
this.action = new PropagateAction( this );
}
+ public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
+ super.readExternal(in);
+ previousObjectSinkNode = (ObjectSinkNode)in.readObject();
+ nextObjectSinkNode = (ObjectSinkNode)in.readObject();
+ action = (PropagateAction)in.readObject();
+ }
+
+ public void writeExternal(ObjectOutput out) throws IOException {
+ super.writeExternal(out);
+ out.writeObject(previousObjectSinkNode);
+ out.writeObject(nextObjectSinkNode);
+ out.writeObject(action);
+ }
+
/**
* @see org.drools.reteoo.ObjectSource#updateSink(org.drools.reteoo.ObjectSink, org.drools.spi.PropagationContext, org.drools.common.InternalWorkingMemory)
*/
@@ -126,7 +146,7 @@
}
this.objectSource.remove( context,
builder,
- this,
+ this,
workingMemories );
}
@@ -201,11 +221,11 @@
/**
* Propagate all queued actions (asserts and retracts).
- *
- * This method implementation is based on optimistic behavior to avoid the
+ *
+ * This method implementation is based on optimistic behavior to avoid the
* use of locks. There may eventually be a minimum wasted effort, but overall
* it will be better than paying for the lock's cost.
- *
+ *
* @param workingMemory
*/
public void propagateActions(InternalWorkingMemory workingMemory) {
@@ -219,7 +239,7 @@
for( int counter = 0; next != null && counter < PROPAGATION_SLICE_LIMIT; next = memory.getNext(), counter++ ) {
next.execute( this.sink, workingMemory );
}
-
+
if( memory.hasNext() ) {
// add action to the queue again.
memory.isQueued().set( true );
@@ -240,12 +260,12 @@
/**
* Memory implementation for the node
- *
+ *
* @author etirelli
*/
- private static class PropagationQueueingNodeMemory
+ public static class PropagationQueueingNodeMemory
implements
- Serializable {
+ Externalizable {
private static final long serialVersionUID = 7372028632974484023L;
@@ -260,6 +280,16 @@
this.isQueued = new AtomicBoolean( false );
}
+ public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
+ queue = (ConcurrentLinkedQueue<Action>)in.readObject();
+ isQueued = (AtomicBoolean)in.readObject();
+ }
+
+ public void writeExternal(ObjectOutput out) throws IOException {
+ out.writeObject(queue);
+ out.writeObject(isQueued);
+ }
+
public boolean isEmpty() {
return this.queue.isEmpty();
}
@@ -283,11 +313,15 @@
private static abstract class Action
implements
- Serializable {
+ Externalizable {
- protected final InternalFactHandle handle;
- protected final PropagationContext context;
+ protected InternalFactHandle handle;
+ protected PropagationContext context;
+ public Action() {
+
+ }
+
public Action(InternalFactHandle handle,
PropagationContext context) {
super();
@@ -295,6 +329,16 @@
this.context = context;
}
+ public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
+ handle = (InternalFactHandle)in.readObject();
+ context = (PropagationContext)in.readObject();
+ }
+
+ public void writeExternal(ObjectOutput out) throws IOException {
+ out.writeObject(handle);
+ out.writeObject(context);
+ }
+
public abstract void execute(final ObjectSinkPropagator sink,
final InternalWorkingMemory workingMemory);
}
@@ -319,6 +363,9 @@
private static class RetractAction extends Action {
private static final long serialVersionUID = -84784886430845209L;
+ public RetractAction() {
+
+ }
public RetractAction(final InternalFactHandle handle,
final PropagationContext context) {
super( handle,
@@ -337,11 +384,11 @@
/**
* This is the action that is added to the working memory actions queue, so that
* this node propagation can be triggered at a safe point
- *
+ *
* @author etirelli
*
*/
- private static class PropagateAction
+ public static class PropagateAction
implements
WorkingMemoryAction {
@@ -349,10 +396,22 @@
private PropagationQueuingNode node;
+ public PropagateAction() {
+
+ }
+
public PropagateAction(PropagationQueuingNode node) {
this.node = node;
}
+ public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
+ node = (PropagationQueuingNode)in.readObject();
+ }
+
+ public void writeExternal(ObjectOutput out) throws IOException {
+ out.writeObject(node);
+ }
+
public void execute(InternalWorkingMemory workingMemory) {
this.node.propagateActions( workingMemory );
}
Modified: labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/reteoo/QueryTerminalNode.java
===================================================================
--- labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/reteoo/QueryTerminalNode.java 2008-03-20 18:57:07 UTC (rev 19163)
+++ labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/reteoo/QueryTerminalNode.java 2008-03-20 19:32:10 UTC (rev 19164)
@@ -2,13 +2,13 @@
/*
* Copyright 2005 JBoss Inc
- *
+ *
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -17,6 +17,9 @@
*/
import java.util.LinkedList;
+import java.io.ObjectOutput;
+import java.io.IOException;
+import java.io.ObjectInput;
import org.drools.RuleBaseConfiguration;
import org.drools.common.BaseNode;
@@ -30,9 +33,9 @@
/**
* Leaf Rete-OO node responsible for enacting <code>Action</code> s on a
* matched <code>Rule</code>.
- *
+ *
* @see org.drools.rule.Rule
- *
+ *
* @author <a href="mailto:bob at eng.werken.com">bob mcwhirter </a>
*/
public final class QueryTerminalNode extends BaseNode
@@ -45,25 +48,27 @@
// ------------------------------------------------------------
/**
- *
+ *
*/
private static final long serialVersionUID = 400L;
/** The rule to invoke upon match. */
- private final Rule rule;
- private final GroupElement subrule;
- private final TupleSource tupleSource;
- private boolean tupleMemoryEnabled;
-
+ private Rule rule;
+ private GroupElement subrule;
+ private TupleSource tupleSource;
+ private boolean tupleMemoryEnabled;
+
private TupleSinkNode previousTupleSinkNode;
- private TupleSinkNode nextTupleSinkNode;
+ private TupleSinkNode nextTupleSinkNode;
// ------------------------------------------------------------
// Constructors
// ------------------------------------------------------------
+ public QueryTerminalNode() {
+ }
/**
* Construct.
- *
+ *
* @param inputSource
* The parent tuple source.
* @param rule
@@ -83,10 +88,29 @@
// ------------------------------------------------------------
// Instance methods
// ------------------------------------------------------------
+ public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
+ super.readExternal(in);
+ rule = (Rule)in.readObject();
+ subrule = (GroupElement)in.readObject();
+ tupleSource = (TupleSource)in.readObject();
+ tupleMemoryEnabled = in.readBoolean();
+ previousTupleSinkNode = (TupleSinkNode)in.readObject();
+ nextTupleSinkNode = (TupleSinkNode)in.readObject();
+ }
+ public void writeExternal(ObjectOutput out) throws IOException {
+ super.writeExternal(out);
+ out.writeObject(rule);
+ out.writeObject(subrule);
+ out.writeObject(tupleSource);
+ out.writeBoolean(tupleMemoryEnabled);
+ out.writeObject(previousTupleSinkNode);
+ out.writeObject(nextTupleSinkNode);
+ }
+
/**
* Retrieve the <code>Action</code> associated with this node.
- *
+ *
* @return The <code>Action</code> associated with this node.
*/
public Rule getRule() {
@@ -99,7 +123,7 @@
/**
* Assert a new <code>Tuple</code>.
- *
+ *
* @param tuple
* The <code>Tuple</code> being asserted.
* @param workingMemory
@@ -150,6 +174,10 @@
}
}
+ public void networkUpdated() {
+ this.tupleSource.networkUpdated();
+ }
+
protected void doRemove(final RuleRemovalContext context,
final ReteooBuilder builder,
final BaseNode node,
@@ -157,7 +185,7 @@
for ( int i = 0, length = workingMemories.length; i < length; i++ ) {
workingMemories[i].clearNodeMemory( this );
}
-
+
if( ! context.alreadyVisited( this.tupleSource ) ) {
this.tupleSource.remove( context,
builder,
@@ -186,14 +214,14 @@
public void setTupleMemoryEnabled(boolean tupleMemoryEnabled) {
this.tupleMemoryEnabled = tupleMemoryEnabled;
}
-
+
/**
* @return the subrule
*/
public GroupElement getSubrule() {
return this.subrule;
}
-
+
/**
* Returns the previous node
* @return
@@ -204,14 +232,14 @@
}
/**
- * Sets the previous node
+ * Sets the previous node
* @param previous
* The previous TupleSinkNode
*/
public void setPreviousTupleSinkNode(final TupleSinkNode previous) {
this.previousTupleSinkNode = previous;
- }
-
+ }
+
/**
* Returns the next node
* @return
@@ -222,12 +250,12 @@
}
/**
- * Sets the next node
+ * Sets the next node
* @param next
* The next TupleSinkNode
*/
public void setNextTupleSinkNode(final TupleSinkNode next) {
this.nextTupleSinkNode = next;
- }
+ }
}
Modified: labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/reteoo/Rete.java
===================================================================
--- labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/reteoo/Rete.java 2008-03-20 18:57:07 UTC (rev 19163)
+++ labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/reteoo/Rete.java 2008-03-20 19:32:10 UTC (rev 19164)
@@ -16,27 +16,23 @@
* limitations under the License.
*/
+import java.io.Externalizable;
import java.io.IOException;
-import java.io.ObjectInputStream;
-import java.io.Serializable;
+import java.io.ObjectInput;
+import java.io.ObjectOutput;
import java.util.HashMap;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import org.drools.common.BaseNode;
-import org.drools.common.DroolsObjectInputStream;
import org.drools.common.InternalFactHandle;
import org.drools.common.InternalRuleBase;
import org.drools.common.InternalWorkingMemory;
import org.drools.common.InternalWorkingMemoryEntryPoint;
-import org.drools.reteoo.builder.BuildContext;
import org.drools.rule.EntryPoint;
import org.drools.spi.ObjectType;
import org.drools.spi.PropagationContext;
-import org.drools.util.FactEntry;
-import org.drools.util.FactHashTable;
-import org.drools.util.Iterator;
/**
* The Rete-OO network.
@@ -59,7 +55,7 @@
*/
public class Rete extends ObjectSource
implements
- Serializable,
+ Externalizable,
ObjectSink {
// ------------------------------------------------------------
// Instance members
@@ -70,10 +66,14 @@
*/
private static final long serialVersionUID = 400L;
- private final Map<EntryPoint, EntryPointNode> entryPoints;
+ private Map<EntryPoint, EntryPointNode> entryPoints;
private transient InternalRuleBase ruleBase;
+ public Rete() {
+ this(null);
+ }
+
// ------------------------------------------------------------
// Constructors
// ------------------------------------------------------------
@@ -84,12 +84,6 @@
this.ruleBase = ruleBase;
}
- private void readObject(ObjectInputStream stream) throws IOException,
- ClassNotFoundException {
- stream.defaultReadObject();
- this.ruleBase = ((DroolsObjectInputStream) stream).getRuleBase();
- }
-
// ------------------------------------------------------------
// Instance methods
// ------------------------------------------------------------
@@ -167,6 +161,10 @@
throw new UnsupportedOperationException( "cannot call attach() from the root Rete node" );
}
+ public void networkUpdated() {
+ // nothing to do
+ }
+
protected void doRemove(final RuleRemovalContext context,
final ReteooBuilder builder,
final BaseNode node,
@@ -174,7 +172,7 @@
final EntryPointNode entryPointNode = (EntryPointNode) node;
removeObjectSink( entryPointNode );
}
-
+
public EntryPointNode getEntryPointNode( final EntryPoint entryPoint ) {
return this.entryPoints.get( entryPoint );
}
@@ -226,4 +224,15 @@
throw new UnsupportedOperationException( "ORete has no Object memory" );
}
+ public void writeExternal(ObjectOutput out) throws IOException {
+ super.writeExternal(out);
+ out.writeObject(entryPoints);
+ out.writeObject(ruleBase);
+ }
+
+ public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
+ super.readExternal(in);
+ entryPoints = (Map<EntryPoint, EntryPointNode>) in.readObject();
+ ruleBase = (InternalRuleBase)in.readObject();
+ }
}
Modified: labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/reteoo/ReteStatelessSessionResult.java
===================================================================
--- labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/reteoo/ReteStatelessSessionResult.java 2008-03-20 18:57:07 UTC (rev 19163)
+++ labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/reteoo/ReteStatelessSessionResult.java 2008-03-20 19:32:10 UTC (rev 19164)
@@ -1,6 +1,10 @@
package org.drools.reteoo;
import java.util.Iterator;
+import java.io.Externalizable;
+import java.io.ObjectOutput;
+import java.io.ObjectInput;
+import java.io.IOException;
import org.drools.ObjectFilter;
import org.drools.QueryResults;
@@ -12,24 +16,38 @@
import org.drools.util.ObjectHashMap;
import org.drools.util.AbstractHashTable.HashTableIterator;
-public class ReteStatelessSessionResult implements StatelessSessionResult {
+public class ReteStatelessSessionResult implements StatelessSessionResult, Externalizable {
private transient InternalWorkingMemory workingMemory;
// @TODO ObjectStore is currently too heavy for serialisation, but done to fix for now
private ObjectStore objectStore;
private GlobalResolver globalResolver;
-
+
+ public ReteStatelessSessionResult() {
+ }
+
public ReteStatelessSessionResult(InternalWorkingMemory workingMemory, GlobalResolver globalResolver) {
this.workingMemory = workingMemory;
this.objectStore = workingMemory.getObjectStore();
this.globalResolver = globalResolver;
}
+ public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
+ workingMemory = (InternalWorkingMemory)in.readObject();
+ objectStore = (ObjectStore)in.readObject();
+ globalResolver = (GlobalResolver)in.readObject();
+ }
+
+ public void writeExternal(ObjectOutput out) throws IOException {
+ out.writeObject(workingMemory);
+ out.writeObject(objectStore);
+ out.writeObject(globalResolver);
+ }
public QueryResults getQueryResults(String query) {
return this.workingMemory.getQueryResults( query );
}
-
+
public QueryResults getQueryResults(final String query, final Object[] arguments) {
- return this.workingMemory.getQueryResults( query,
+ return this.workingMemory.getQueryResults( query,
arguments );
}
@@ -40,14 +58,14 @@
public Iterator iterateObjects(ObjectFilter filter) {
return this.objectStore.iterateObjects( filter );
}
-
+
public Object getGlobal(String identifier) {
if ( this.globalResolver == null ) {
return null;
}
return this.globalResolver.resolveGlobal( identifier );
}
-
+
public GlobalResolver getGlobalResolver() {
return this.globalResolver;
}
Modified: labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/reteoo/ReteTuple.java
===================================================================
--- labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/reteoo/ReteTuple.java 2008-03-20 18:57:07 UTC (rev 19163)
+++ labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/reteoo/ReteTuple.java 2008-03-20 19:32:10 UTC (rev 19164)
@@ -2,6 +2,9 @@
import java.util.ArrayList;
import java.util.List;
+import java.io.ObjectOutput;
+import java.io.IOException;
+import java.io.ObjectInput;
import org.drools.base.ShadowProxy;
import org.drools.common.InternalFactHandle;
@@ -18,7 +21,7 @@
private int index;
- private final InternalFactHandle handle;
+ private InternalFactHandle handle;
private ReteTuple parent;
@@ -27,7 +30,7 @@
private long recency;
private int hashCode;
-
+
private InternalFactHandle match;
private Entry next;
@@ -35,6 +38,9 @@
// ------------------------------------------------------------
// Constructors
// ------------------------------------------------------------
+ public ReteTuple() {
+
+ }
public ReteTuple(final InternalFactHandle handle) {
this.recency = handle.getRecency();
this.handle = handle;
@@ -63,6 +69,29 @@
this.hashCode = parentTuple.hashCode ^ (handle.hashCode() * 31);
}
+ public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
+ index = in.readInt();
+ handle = (InternalFactHandle)in.readObject();
+ parent = (ReteTuple)in.readObject();
+ activation = (Activation)in.readObject();
+ recency = in.readLong();
+ hashCode = in.readInt();
+ match = (InternalFactHandle)in.readObject();
+ next = (Entry)in.readObject();
+
+ }
+
+ public void writeExternal(ObjectOutput out) throws IOException {
+ out.writeInt(index);
+ out.writeObject(handle);
+ out.writeObject(parent);
+ out.writeObject(activation);
+ out.writeLong(recency);
+ out.writeInt(hashCode);
+ out.writeObject(match);
+ out.writeObject(next);
+ }
+
public InternalFactHandle get(final int index) {
ReteTuple entry = this;
while ( entry.index != index ) {
@@ -108,8 +137,8 @@
public long getRecency() {
return this.recency;
}
-
+
public InternalFactHandle getMatch() {
return match;
}
@@ -166,7 +195,7 @@
}
public boolean equals(final Object object) {
- // we know the object is never null and always of the type ReteTuple
+ // we know the object is never null and always of the type ReteTuple
return equals( (ReteTuple) object );
}
@@ -177,17 +206,17 @@
/**
* Returns the ReteTuple that contains the "elements"
* first elements in this tuple.
- *
+ *
* Use carefully as no cloning is made during this process.
- *
+ *
* This method is used by TupleStartEqualsConstraint when
* joining a subnetwork tuple into the main network tuple;
- *
+ *
* @param elements the number of elements to return, starting from
* the begining of the tuple
- *
+ *
* @return a ReteTuple containing the "elements" first elements
- * of this tuple or null if "elements" is greater than size;
+ * of this tuple or null if "elements" is greater than size;
*/
public ReteTuple getSubTuple(final int elements) {
ReteTuple entry = this;
@@ -200,10 +229,10 @@
}
return entry;
}
-
- public Object[] toObjectArray() {
+
+ public Object[] toObjectArray() {
Object[] objects = new Object[ this.index + 1 ];
- ReteTuple entry = this;
+ ReteTuple entry = this;
while ( entry != null ) {
Object object = entry.getLastHandle().getObject();
if ( object instanceof ShadowProxy ) {
@@ -211,7 +240,7 @@
}
objects[entry.index] = object;
entry = entry.parent;
- }
+ }
return objects;
}
}
Modified: labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/reteoo/ReteooBuilder.java
===================================================================
--- labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/reteoo/ReteooBuilder.java 2008-03-20 18:57:07 UTC (rev 19163)
+++ labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/reteoo/ReteooBuilder.java 2008-03-20 19:32:10 UTC (rev 19164)
@@ -2,13 +2,13 @@
/*
* Copyright 2005 JBoss Inc
- *
+ *
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -19,6 +19,14 @@
import java.io.IOException;
import java.io.ObjectInputStream;
import java.io.Serializable;
+import java.io.ObjectInput;
+import java.io.ObjectOutput;
+import java.io.Externalizable;
+import java.io.ByteArrayOutputStream;
+import java.io.ObjectOutputStream;
+import java.io.OutputStream;
+import java.io.ByteArrayInputStream;
+import java.io.InputStream;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
@@ -36,6 +44,7 @@
import org.drools.common.DroolsObjectInputStream;
import org.drools.common.InternalRuleBase;
import org.drools.common.InternalWorkingMemory;
+import org.drools.common.DroolsObjectOutputStream;
import org.drools.reteoo.builder.ReteooRuleBuilder;
import org.drools.rule.InvalidPatternException;
import org.drools.rule.Rule;
@@ -43,22 +52,22 @@
/**
* Builds the Rete-OO network for a <code>Package</code>.
- *
+ *
* @see org.drools.rule.Package
- *
+ *
* @author <a href="mailto:mark.proctor at jboss.com">Mark Proctor</a>
* @author <a href="mailto:bob at werken.com">Bob McWhirter</a>
- *
+ *
*/
public class ReteooBuilder
implements
- Serializable {
+ Externalizable {
// ------------------------------------------------------------
// Instance members
// ------------------------------------------------------------
/**
- *
+ *
*/
private static final long serialVersionUID = 400L;
@@ -79,6 +88,9 @@
// Constructors
// ------------------------------------------------------------
+ public ReteooBuilder() {
+
+ }
/**
* Construct a <code>Builder</code> against an existing <code>Rete</code>
* network.
@@ -92,23 +104,16 @@
this.ruleBuilder = new ReteooRuleBuilder();
}
- private void readObject(ObjectInputStream stream) throws IOException,
- ClassNotFoundException {
- stream.defaultReadObject();
- this.ruleBase = ((DroolsObjectInputStream) stream).getRuleBase();
- this.ruleBuilder = new ReteooRuleBuilder();
- }
-
// ------------------------------------------------------------
// Instance methods
// ------------------------------------------------------------
/**
* Add a <code>Rule</code> to the network.
- *
+ *
* @param rule
* The rule to add.
- *
+ *
* @throws RuleIntegrationException
* if an error prevents complete construction of the network for
* the <code>Rule</code>.
@@ -241,18 +246,32 @@
public static class IdGenerator
implements
- Serializable {
+ Externalizable {
private static final long serialVersionUID = 400L;
private Queue<Integer> recycledIds;
private int nextId;
+ public IdGenerator() {
+
+ }
+
public IdGenerator(final int firstId) {
this.nextId = firstId;
this.recycledIds = new LinkedList<Integer>();
}
+ public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
+ recycledIds = (Queue<Integer>)in.readObject();
+ nextId = in.readInt();
+ }
+
+ public void writeExternal(ObjectOutput out) throws IOException {
+ out.writeObject(recycledIds);
+ out.writeInt(nextId);
+ }
+
public int getNextId() {
Integer id = this.recycledIds.poll();
if( id == null ) {
@@ -271,4 +290,49 @@
}
+ public void writeExternal(ObjectOutput out) throws IOException {
+ boolean isDrools = out instanceof DroolsObjectOutputStream;
+ DroolsObjectOutputStream droolsStream;
+ ByteArrayOutputStream bytes;
+
+ if (isDrools) {
+ bytes = null;
+ droolsStream = (DroolsObjectOutputStream)out;
+ } else {
+ bytes = new ByteArrayOutputStream();
+ droolsStream = new DroolsObjectOutputStream(bytes);
+ }
+ droolsStream.writeObject(rules);
+ droolsStream.writeObject(idGenerator);
+ droolsStream.writeBoolean(ordered);
+ droolsStream.writeObject(ruleBase);
+ if (!isDrools) {
+ bytes.close();
+ out.writeObject(bytes.toByteArray());
+ }
+ }
+
+ public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
+ boolean isDrools = in instanceof DroolsObjectInputStream;
+ DroolsObjectInputStream droolsStream;
+ ByteArrayInputStream bytes;
+
+ if (isDrools) {
+ bytes = null;
+ droolsStream = (DroolsObjectInputStream)in;
+ } else {
+ bytes = new ByteArrayInputStream((byte[])in.readObject());
+ droolsStream = new DroolsObjectInputStream(bytes);
+ }
+ this.rules = (Map)in.readObject();
+ this.idGenerator = (IdGenerator)in.readObject();
+ this.ordered = in.readBoolean();
+ this.ruleBase = (InternalRuleBase)droolsStream.readObject();
+ if (!isDrools) {
+ bytes.close();
+ }
+
+ this.ruleBuilder = new ReteooRuleBuilder();
+ }
+
}
Modified: labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/reteoo/ReteooFactHandleFactory.java
===================================================================
--- labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/reteoo/ReteooFactHandleFactory.java 2008-03-20 18:57:07 UTC (rev 19163)
+++ labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/reteoo/ReteooFactHandleFactory.java 2008-03-20 19:32:10 UTC (rev 19164)
@@ -2,13 +2,13 @@
/*
* Copyright 2005 JBoss Inc
- *
+ *
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -16,6 +16,10 @@
* limitations under the License.
*/
+import java.io.IOException;
+import java.io.ObjectInput;
+import java.io.ObjectOutput;
+
import org.drools.TemporalSession;
import org.drools.WorkingMemory;
import org.drools.common.AbstractFactHandleFactory;
@@ -33,6 +37,14 @@
super();
}
+ public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
+ super.readExternal(in);
+ }
+
+ public void writeExternal(ObjectOutput out) throws IOException {
+ super.writeExternal(out);
+ }
+
/* (non-Javadoc)
* @see org.drools.reteoo.FactHandleFactory#newFactHandle(long)
*/
@@ -42,7 +54,7 @@
final boolean isEvent,
final WorkingMemory workingMemory ) {
if ( isEvent ) {
- SessionClock clock = ((TemporalSession) workingMemory).getSessionClock();
+ SessionClock clock = ((TemporalSession) workingMemory).getSessionClock();
return new EventFactHandle( id,
object,
recency,
@@ -54,7 +66,7 @@
recency );
}
}
-
+
/* (non-Javadoc)
* @see org.drools.reteoo.FactHandleFactory#newInstance()
*/
Modified: labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/reteoo/ReteooRuleBase.java
===================================================================
--- labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/reteoo/ReteooRuleBase.java 2008-03-20 18:57:07 UTC (rev 19163)
+++ labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/reteoo/ReteooRuleBase.java 2008-03-20 19:32:10 UTC (rev 19164)
@@ -2,13 +2,13 @@
/*
* Copyright 2005 JBoss Inc
- *
+ *
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -20,6 +20,7 @@
import java.io.ObjectInput;
import java.io.ObjectOutput;
import java.io.Serializable;
+import java.io.Externalizable;
import java.util.Iterator;
import org.drools.ClockType;
@@ -46,19 +47,20 @@
import org.drools.spi.ExecutorServiceFactory;
import org.drools.spi.FactHandleFactory;
import org.drools.spi.PropagationContext;
+import org.drools.temporal.SessionClock;
/**
* Implementation of <code>RuleBase</code>.
- *
+ *
* @author <a href="mailto:bob at werken.com">bob mcwhirter</a>
- * @author <a href="mailto:mark.proctor at jboss.com">Mark Proctor</a>
- *
+ * @author <a href="mailto:mark.proctor at jboss.com">Mark Proctor</a>
+ *
* @version $Id: RuleBaseImpl.java,v 1.5 2005/08/14 22:44:12 mproctor Exp $
*/
public class ReteooRuleBase extends AbstractRuleBase {
/**
* DO NOT CHANGE BELLOW SERIAL_VERSION_ID UNLESS YOU ARE CHANGING DROOLS VERSION
- * SERIAL_VERSION_ID=320 stands for version 3.2.0
+ * SERIAL_VERSION_ID=320 stands for version 3.2.0
*/
private static final long serialVersionUID = 400L;
@@ -72,7 +74,7 @@
// ------------------------------------------------------------
/**
- * Default constructor - for Externalizable. This should never be used by a user, as it
+ * Default constructor - for Externalizable. This should never be used by a user, as it
* will result in an invalid state for the instance.
*/
public ReteooRuleBase() {
@@ -81,8 +83,8 @@
/**
* Construct.
- *
- * @param rete
+ *
+ * @param id
* The rete network.
*/
public ReteooRuleBase(final String id) {
@@ -119,8 +121,8 @@
/**
* Construct.
- *
- * @param rete
+ *
+ * @param id
* The rete network.
*/
public ReteooRuleBase(final String id,
@@ -131,40 +133,37 @@
factHandleFactory );
this.rete = new Rete( this );
this.reteooBuilder = new ReteooBuilder( this );
-
+
// always add the default entry point
- EntryPointNode epn = new EntryPointNode( this.reteooBuilder.getIdGenerator().getNextId(),
+ EntryPointNode epn = new EntryPointNode( this.reteooBuilder.getIdGenerator().getNextId(),
this.rete,
EntryPoint.DEFAULT );
epn.attach();
-
+
}
/**
* Handles the write serialization of the Package. Patterns in Rules may reference generated data which cannot be serialized by default methods.
* The Package uses PackageCompilationData to hold a reference to the generated bytecode. The generated bytecode must be restored before any Rules.
- *
+ *
*/
public void writeExternal(final ObjectOutput stream) throws IOException {
- final Object[] objects = new Object[]{this.rete, this.reteooBuilder};
- doWriteExternal( stream,
- objects );
+ super.writeExternal( stream );
+ stream.writeObject(this.rete);
+ stream.writeObject(this.reteooBuilder);
}
/**
* Handles the read serialization of the Package. Patterns in Rules may reference generated data which cannot be serialized by default methods.
* The Package uses PackageCompilationData to hold a reference to the generated bytecode; which must be restored before any Rules.
* A custom ObjectInputStream, able to resolve classes against the bytecode in the PackageCompilationData, is used to restore the Rules.
- *
+ *
*/
public void readExternal(final ObjectInput stream) throws IOException,
ClassNotFoundException {
- final Object[] objects = new Object[2];
- doReadExternal( stream,
- objects );
-
- this.rete = (Rete) objects[0];
- this.reteooBuilder = (ReteooBuilder) objects[1];
+ super.readExternal( stream );
+ this.rete = (Rete) stream.readObject();
+ this.reteooBuilder = (ReteooBuilder) stream.readObject();
}
// ------------------------------------------------------------
@@ -173,7 +172,7 @@
/**
* Retrieve the Rete-OO network for this <code>RuleBase</code>.
- *
+ *
* @return The RETE-OO network.
*/
public Rete getRete() {
@@ -186,14 +185,14 @@
/**
* Assert a fact object.
- *
+ *
* @param handle
* The handle.
* @param object
* The fact.
* @param workingMemory
* The working-memory.
- *
+ *
* @throws FactException
* If an error occurs while performing the assertion.
*/
@@ -208,12 +207,12 @@
/**
* Retract a fact object.
- *
+ *
* @param handle
* The handle.
* @param workingMemory
* The working-memory.
- *
+ *
* @throws FactException
* If an error occurs while performing the retraction.
*/
@@ -307,7 +306,7 @@
protected synchronized void removeRule(final Rule rule) {
this.reteooBuilder.removeRule( rule );
}
-
+
public int getNodeCount() {
// may start in 0
return this.reteooBuilder.getIdGenerator().getLastId()+1;
@@ -315,8 +314,14 @@
public static class InitialFactHandleDummyObject
implements
- Serializable {
+ Externalizable {
private static final long serialVersionUID = 400L;
+
+ public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
+ }
+
+ public void writeExternal(ObjectOutput out) throws IOException {
+ }
}
}
Modified: labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/reteoo/ReteooStatefulSession.java
===================================================================
--- labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/reteoo/ReteooStatefulSession.java 2008-03-20 18:57:07 UTC (rev 19163)
+++ labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/reteoo/ReteooStatefulSession.java 2008-03-20 19:32:10 UTC (rev 19164)
@@ -29,9 +29,13 @@
private static final long serialVersionUID = -5360554247241558374L;
private transient ExecutorService executor;
-
+
private transient List ruleBaseListeners;
+ public ReteooStatefulSession() {
+
+ }
+
public ReteooStatefulSession(final int id,
final InternalRuleBase ruleBase,
final ExecutorService executorService) {
@@ -79,7 +83,7 @@
this.executor.submit( fireAllRules );
return fireAllRules;
}
-
+
public void dispose() {
this.ruleBase.disposeStatefulSession( this );
this.workingMemoryEventSupport.reset();
Modified: labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/reteoo/ReteooStatelessSession.java
===================================================================
--- labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/reteoo/ReteooStatelessSession.java 2008-03-20 18:57:07 UTC (rev 19163)
+++ labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/reteoo/ReteooStatelessSession.java 2008-03-20 19:32:10 UTC (rev 19164)
@@ -3,6 +3,10 @@
import java.util.Collection;
import java.util.Iterator;
import java.util.List;
+import java.io.Externalizable;
+import java.io.ObjectOutput;
+import java.io.ObjectInput;
+import java.io.IOException;
import org.drools.StatelessSession;
import org.drools.StatelessSessionResult;
@@ -31,13 +35,13 @@
public class ReteooStatelessSession
implements
- StatelessSession {
+ StatelessSession, Externalizable {
//private WorkingMemory workingMemory;
private InternalRuleBase ruleBase;
private AgendaFilter agendaFilter;
private GlobalResolver globalResolver = new MapGlobalResolver();
-
+
private GlobalExporter globalExporter;
/** The eventSupport */
@@ -47,10 +51,26 @@
protected RuleFlowEventSupport ruleFlowEventSupport = new RuleFlowEventSupport();
+ public ReteooStatelessSession() {
+ }
+
public ReteooStatelessSession(final InternalRuleBase ruleBase) {
this.ruleBase = ruleBase;
}
+ public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
+ ruleBase = (InternalRuleBase)in.readObject();
+ agendaFilter = (AgendaFilter)in.readObject();
+ globalResolver = (GlobalResolver)in.readObject();
+ globalExporter = (GlobalExporter)in.readObject();
+ }
+
+ public void writeExternal(ObjectOutput out) throws IOException {
+ out.writeObject(ruleBase);
+ out.writeObject(agendaFilter);
+ out.writeObject(globalResolver);
+ out.writeObject(globalExporter);
+ }
public InternalWorkingMemory newWorkingMemory() {
synchronized ( this.ruleBase.getPackagesMap() ) {
InternalWorkingMemory wm = new ReteooWorkingMemory( this.ruleBase.nextWorkingMemoryCounter(),
@@ -107,7 +127,7 @@
public List getRuleFlowEventListeners() {
return this.ruleFlowEventSupport.getEventListeners();
}
-
+
public void addEventListener(RuleBaseEventListener listener) {
this.ruleBase.addEventListener( listener );
}
@@ -133,7 +153,7 @@
public void setGlobalResolver(GlobalResolver globalResolver) {
this.globalResolver = globalResolver;
}
-
+
public void setGlobalExporter(GlobalExporter globalExporter) {
this.globalExporter = globalExporter;
}
@@ -198,7 +218,7 @@
wm.insert( object );
wm.fireAllRules( this.agendaFilter );
-
+
GlobalResolver globalResolver = null;
if ( this.globalExporter != null ) {
globalResolver = this.globalExporter.export( wm );
@@ -214,7 +234,7 @@
wm.insert( array[i] );
}
wm.fireAllRules( this.agendaFilter );
-
+
GlobalResolver globalResolver = null;
if ( this.globalExporter != null ) {
globalResolver = this.globalExporter.export( wm );
@@ -236,6 +256,6 @@
globalResolver = this.globalExporter.export( wm );
}
return new ReteStatelessSessionResult( wm,
- globalResolver );
+ globalResolver );
}
}
Modified: labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/reteoo/ReteooTemporalSession.java
===================================================================
--- labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/reteoo/ReteooTemporalSession.java 2008-03-20 18:57:07 UTC (rev 19163)
+++ labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/reteoo/ReteooTemporalSession.java 2008-03-20 19:32:10 UTC (rev 19164)
@@ -1,12 +1,12 @@
/*
* Copyright 2007 JBoss Inc
- *
+ *
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -17,16 +17,19 @@
*/
package org.drools.reteoo;
+import java.io.IOException;
+import java.io.ObjectInput;
+import java.io.ObjectOutput;
+
import org.drools.TemporalSession;
import org.drools.common.InternalRuleBase;
import org.drools.concurrent.ExecutorService;
-import org.drools.rule.EntryPoint;
import org.drools.temporal.SessionClock;
/**
* ReteooStatefulTemporalSession implements a temporal enabled session
* for Reteoo rulebases
- *
+ *
* @author etirelli
*/
public class ReteooTemporalSession<T extends SessionClock> extends ReteooStatefulSession
@@ -34,19 +37,31 @@
TemporalSession<T> {
private static final long serialVersionUID = -2129661675928809928L;
-
private T sessionClock;
- public ReteooTemporalSession(final int id,
- final InternalRuleBase ruleBase,
- final ExecutorService executorService,
- final T clock) {
+ public ReteooTemporalSession() {
+ }
+
+ public ReteooTemporalSession(int id,
+ InternalRuleBase ruleBase,
+ ExecutorService executorService,
+ T clock) {
super( id,
ruleBase,
executorService );
this.sessionClock = clock;
}
+ public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
+ super.readExternal(in);
+ sessionClock = (T)in.readObject();
+ }
+
+ public void writeExternal(ObjectOutput out) throws IOException {
+ super.writeExternal(out);
+ out.writeObject(sessionClock);
+ }
+
public T getSessionClock() {
return this.sessionClock;
}
Modified: labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/reteoo/ReteooWorkingMemory.java
===================================================================
--- labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/reteoo/ReteooWorkingMemory.java 2008-03-20 18:57:07 UTC (rev 19163)
+++ labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/reteoo/ReteooWorkingMemory.java 2008-03-20 19:32:10 UTC (rev 19164)
@@ -2,13 +2,13 @@
/*
* Copyright 2005 JBoss Inc
- *
+ *
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -19,6 +19,10 @@
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
+import java.io.Externalizable;
+import java.io.IOException;
+import java.io.ObjectInput;
+import java.io.ObjectOutput;
import org.drools.FactException;
import org.drools.FactHandle;
@@ -41,21 +45,25 @@
/**
* Implementation of <code>WorkingMemory</code>.
- *
+ *
* @author <a href="mailto:bob at werken.com">bob mcwhirter </a>
* @author <a href="mailto:mark.proctor at jboss.com">Mark Proctor</a>
* @author <a href="mailto:simon at redhillconsulting.com.au">Simon Harris</a>
*/
-public class ReteooWorkingMemory extends AbstractWorkingMemory {
+public class ReteooWorkingMemory extends AbstractWorkingMemory implements Externalizable {
/**
- *
+ *
*/
private static final long serialVersionUID = 400L;
+ public ReteooWorkingMemory() {
+
+ }
+
/**
* Construct.
- *
+ *
* @param ruleBase
* The backing rule-base.
*/
@@ -70,18 +78,18 @@
public QueryResults getQueryResults(final String query) {
return getQueryResults( query, null );
}
-
+
public QueryResults getQueryResults(final String query, final Object[] arguments) {
Object object = new DroolsQuery( query, arguments );
InternalFactHandle handle = this.handleFactory.newFactHandle( object, false, this );
-
+
insert( handle,
object,
null,
null,
this.typeConfReg.getObjectTypeConf( this.entryPoint, object ));
-
+
final QueryTerminalNode node = (QueryTerminalNode) this.queryResults.remove( query );
Query queryObj = null;
List list = null;
@@ -98,27 +106,27 @@
}
this.handleFactory.destroyFactHandle( handle );
-
+
if ( queryObj == null ) {
throw new IllegalArgumentException( "Query '" + query + "' does not exist" );
}
list = Collections.EMPTY_LIST;
} else {
list = (List) this.getNodeMemory( node );
-
+
if ( list == null ) {
list = Collections.EMPTY_LIST;
} else {
this.clearNodeMemory( node );
}
queryObj = (Query) node.getRule();
-
+
this.handleFactory.destroyFactHandle( handle );
}
-
-
-
+
+
+
return new QueryResults( list,
queryObj,
this );
@@ -146,6 +154,10 @@
private Activation activationOrigin;
+ public WorkingMemoryReteAssertAction() {
+
+ }
+
public WorkingMemoryReteAssertAction(final InternalFactHandle factHandle,
final boolean removeLogical,
final boolean updateEqualsMap,
@@ -159,6 +171,22 @@
this.activationOrigin = activationOrigin;
}
+ public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
+ factHandle = (InternalFactHandle)in.readObject();
+ removeLogical = in.readBoolean();
+ updateEqualsMap = in.readBoolean();
+ ruleOrigin = (Rule)in.readObject();
+ activationOrigin = (Activation)in.readObject();
+ }
+
+ public void writeExternal(ObjectOutput out) throws IOException {
+ out.writeObject(factHandle);
+ out.writeBoolean(removeLogical);
+ out.writeBoolean(updateEqualsMap);
+ out.writeObject(ruleOrigin);
+ out.writeObject(activationOrigin);
+ }
+
public void execute(InternalWorkingMemory workingMemory) {
final PropagationContext context = new PropagationContextImpl( workingMemory.getNextPropagationIdCounter(),
Modified: labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/reteoo/RightInputAdapterNode.java
===================================================================
--- labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/reteoo/RightInputAdapterNode.java 2008-03-20 18:57:07 UTC (rev 19163)
+++ labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/reteoo/RightInputAdapterNode.java 2008-03-20 19:32:10 UTC (rev 19164)
@@ -2,13 +2,13 @@
/*
* Copyright 2005 JBoss Inc
- *
+ *
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -28,11 +28,15 @@
import org.drools.util.ObjectHashMap;
import org.drools.util.ObjectHashMap.ObjectEntry;
+import java.io.ObjectOutput;
+import java.io.ObjectInput;
+import java.io.IOException;
+
/**
- * When joining a subnetwork into the main network again, RightInputAdapterNode adapts the
+ * When joining a subnetwork into the main network again, RightInputAdapterNode adapts the
* subnetwork's tuple into a fact in order right join it with the tuple being propagated in
* the main network.
- *
+ *
* @author <a href="mailto:mark.proctor at jboss.com">Mark Proctor</a>
* @author <a href="mailto:bob at werken.com">Bob McWhirter</a>
* @author <a href="mailto:etirelli at redhat.com">Edson Tirelli</a>
@@ -45,19 +49,22 @@
private static final long serialVersionUID = 400L;
- private final TupleSource tupleSource;
-
- protected boolean tupleMemoryEnabled;
+ private TupleSource tupleSource;
+ protected boolean tupleMemoryEnabled;
+
private TupleSinkNode previousTupleSinkNode;
private TupleSinkNode nextTupleSinkNode;
+ public RightInputAdapterNode() {
+ }
+
/**
* Constructor specifying the unique id of the node in the Rete network, the position of the propagating <code>FactHandleImpl</code> in
* <code>ReteTuple</code> and the source that propagates the receive <code>ReteTuple<code>s.
- *
+ *
* @param id
- * Unique id
+ * Unique id
* @param source
* The <code>TupleSource</code> which propagates the received <code>ReteTuple</code>
*/
@@ -69,6 +76,22 @@
this.tupleMemoryEnabled = context.isTupleMemoryEnabled();
}
+ public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
+ super.readExternal(in);
+ tupleSource = (TupleSource)in.readObject();
+ tupleMemoryEnabled = in.readBoolean();
+ previousTupleSinkNode = (TupleSinkNode)in.readObject();
+ nextTupleSinkNode = (TupleSinkNode)in.readObject();
+ }
+
+ public void writeExternal(ObjectOutput out) throws IOException {
+ super.writeExternal(out);
+ out.writeObject(tupleSource);
+ out.writeBoolean(tupleMemoryEnabled);
+ out.writeObject(previousTupleSinkNode);
+ out.writeObject(nextTupleSinkNode);
+
+ }
/**
* Creates and return the node memory
*/
@@ -77,13 +100,13 @@
}
/**
- * Takes the asserted <code>ReteTuple</code> received from the <code>TupleSource</code> and
+ * Takes the asserted <code>ReteTuple</code> received from the <code>TupleSource</code> and
* adapts it into a FactHandleImpl
- *
+ *
* @param tuple
* The asserted <code>ReteTuple</code>.
* @param context
- * The <code>PropagationContext</code> of the <code>WorkingMemory<code> action.
+ * The <code>PropagationContext</code> of the <code>WorkingMemory<code> action.
* @param workingMemory
* the <code>WorkingMemory</code> session.
*/
@@ -93,7 +116,7 @@
// creating a dummy fact handle to wrap the tuple
final InternalFactHandle handle = workingMemory.getFactHandleFactory().newFactHandle( tuple, false, workingMemory );
-
+
if ( this.tupleMemoryEnabled ) {
final ObjectHashMap memory = (ObjectHashMap) workingMemory.getNodeMemory( this );
// add it to a memory mapping
@@ -148,6 +171,10 @@
workingMemory );
}
}
+
+ public void networkUpdated() {
+ this.tupleSource.networkUpdated();
+ }
public void updateSink(final ObjectSink sink,
final PropagationContext context,
@@ -179,7 +206,7 @@
workingMemories );
}
}
-
+
public boolean isTupleMemoryEnabled() {
return tupleMemoryEnabled;
}
@@ -198,7 +225,7 @@
}
/**
- * Sets the next node
+ * Sets the next node
* @param next
* The next TupleSinkNode
*/
@@ -216,7 +243,7 @@
}
/**
- * Sets the previous node
+ * Sets the previous node
* @param previous
* The previous TupleSinkNode
*/
@@ -230,7 +257,7 @@
/*
* (non-Javadoc)
- *
+ *
* @see java.lang.Object#equals(java.lang.Object)
*/
public boolean equals(final Object object) {
Modified: labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/reteoo/RuleRemovalContext.java
===================================================================
--- labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/reteoo/RuleRemovalContext.java 2008-03-20 18:57:07 UTC (rev 19163)
+++ labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/reteoo/RuleRemovalContext.java 2008-03-20 19:32:10 UTC (rev 19164)
@@ -1,12 +1,12 @@
/*
* Copyright 2008 JBoss Inc
- *
+ *
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -19,6 +19,10 @@
package org.drools.reteoo;
import java.io.Serializable;
+import java.io.Externalizable;
+import java.io.ObjectOutput;
+import java.io.IOException;
+import java.io.ObjectInput;
import java.util.HashMap;
import java.util.Map;
@@ -27,34 +31,42 @@
/**
* This context class is used during rule removal to ensure
* network consistency.
- *
+ *
* @author etirelli
*
*/
public class RuleRemovalContext
implements
- Serializable {
-
+ Externalizable {
+
private Map visitedNodes;
-
+
public RuleRemovalContext() {
this.visitedNodes = new HashMap();
}
-
+
+ public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
+ visitedNodes = (Map)in.readObject();
+ }
+
+ public void writeExternal(ObjectOutput out) throws IOException {
+ out.writeObject(visitedNodes);
+ }
+
/**
* We need to track tuple source nodes that we visit
* to avoid multiple removal in case of subnetworks
- *
+ *
* @param node
*/
public void visitTupleSource( TupleSource node ) {
this.visitedNodes.put( new Integer(node.getId()), node );
}
-
+
/**
* We need to track tuple source nodes that we visit
* to avoid multiple removal in case of subnetworks
- *
+ *
* @param node
* @return
*/
Modified: labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/reteoo/RuleTerminalNode.java
===================================================================
--- labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/reteoo/RuleTerminalNode.java 2008-03-20 18:57:07 UTC (rev 19163)
+++ labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/reteoo/RuleTerminalNode.java 2008-03-20 19:32:10 UTC (rev 19164)
@@ -16,7 +16,10 @@
* limitations under the License.
*/
-import java.io.Serializable;
+import java.io.Externalizable;
+import java.io.IOException;
+import java.io.ObjectInput;
+import java.io.ObjectOutput;
import org.drools.common.EventSupport;
import org.drools.RuleBaseConfiguration;
@@ -57,7 +60,7 @@
implements
TupleSinkNode,
NodeMemory,
- TerminalNode {
+ TerminalNode, Externalizable {
// ------------------------------------------------------------
// Instance members
// ------------------------------------------------------------
@@ -69,13 +72,13 @@
*/
private static final long serialVersionUID = 400L;
/** The rule to invoke upon match. */
- private final Rule rule;
+ private Rule rule;
/**
* the subrule reference is needed to resolve declarations
* because declarations may have different offsets in each subrule
*/
- private final GroupElement subrule;
- private final TupleSource tupleSource;
+ private GroupElement subrule;
+ private TupleSource tupleSource;
private TupleSinkNode previousTupleSinkNode;
private TupleSinkNode nextTupleSinkNode;
@@ -85,7 +88,10 @@
// ------------------------------------------------------------
// Constructors
// ------------------------------------------------------------
+ public RuleTerminalNode() {
+ }
+
/**
* Construct.
*
@@ -109,7 +115,26 @@
// ------------------------------------------------------------
// Instance methods
// ------------------------------------------------------------
+ public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
+ super.readExternal(in);
+ sequence = in.readInt();
+ rule = (Rule)in.readObject();
+ subrule = (GroupElement)in.readObject();
+ tupleSource = (TupleSource)in.readObject();
+ previousTupleSinkNode = (TupleSinkNode)in.readObject();
+ nextTupleSinkNode = (TupleSinkNode)in.readObject();
+ }
+ public void writeExternal(ObjectOutput out) throws IOException {
+ super.writeExternal(out);
+ out.writeInt(sequence);
+ out.writeObject(rule);
+ out.writeObject(subrule);
+ out.writeObject(tupleSource);
+ out.writeObject(previousTupleSinkNode);
+ out.writeObject(nextTupleSinkNode);
+ }
+
/**
* Retrieve the <code>Action</code> associated with this node.
*
@@ -432,6 +457,10 @@
}
}
+ public void networkUpdated() {
+ this.tupleSource.networkUpdated();
+ }
+
protected void doRemove(final RuleRemovalContext context,
final ReteooBuilder builder,
final BaseNode node,
@@ -540,9 +569,9 @@
return this.rule.equals( other.rule );
}
- class TerminalNodeMemory
+ public static class TerminalNodeMemory
implements
- Serializable {
+ Externalizable {
private static final long serialVersionUID = 400L;
private InternalAgendaGroup agendaGroup;
@@ -557,6 +586,19 @@
this.tupleMemory = new TupleHashTable();
}
+ public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
+ agendaGroup = (InternalAgendaGroup)in.readObject();
+ activationGroup = (ActivationGroup)in.readObject();
+ ruleFlowGroup = (RuleFlowGroup)in.readObject();
+ tupleMemory = (TupleHashTable)in.readObject();
+ }
+
+ public void writeExternal(ObjectOutput out) throws IOException {
+ out.writeObject(agendaGroup);
+ out.writeObject(activationGroup);
+ out.writeObject(ruleFlowGroup);
+ out.writeObject(tupleMemory);
+ }
public InternalAgendaGroup getAgendaGroup() {
return this.agendaGroup;
}
Modified: labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/reteoo/SingleObjectSinkAdapter.java
===================================================================
--- labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/reteoo/SingleObjectSinkAdapter.java 2008-03-20 18:57:07 UTC (rev 19163)
+++ labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/reteoo/SingleObjectSinkAdapter.java 2008-03-20 19:32:10 UTC (rev 19164)
@@ -4,18 +4,33 @@
import org.drools.common.InternalWorkingMemory;
import org.drools.spi.PropagationContext;
+import java.io.Externalizable;
+import java.io.ObjectOutput;
+import java.io.IOException;
+import java.io.ObjectInput;
+
public class SingleObjectSinkAdapter
implements
- ObjectSinkPropagator {
+ ObjectSinkPropagator, Externalizable {
private static final long serialVersionUID = 873985743021L;
-
+
private ObjectSink sink;
+ public SingleObjectSinkAdapter() {
+
+ }
public SingleObjectSinkAdapter(final ObjectSink sink) {
this.sink = sink;
}
+ public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
+ sink = (ObjectSink)in.readObject();
+ }
+
+ public void writeExternal(ObjectOutput out) throws IOException {
+ out.writeObject(sink);
+ }
public void propagateAssertObject(final InternalFactHandle handle,
final PropagationContext context,
final InternalWorkingMemory workingMemory) {
@@ -38,7 +53,7 @@
public ObjectSink[] getSinks() {
return new ObjectSink[]{this.sink};
}
-
+
public int size() {
return 1;
}
Modified: labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/reteoo/SingleTupleSinkAdapter.java
===================================================================
--- labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/reteoo/SingleTupleSinkAdapter.java 2008-03-20 18:57:07 UTC (rev 19163)
+++ labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/reteoo/SingleTupleSinkAdapter.java 2008-03-20 19:32:10 UTC (rev 19164)
@@ -4,15 +4,31 @@
import org.drools.common.InternalWorkingMemory;
import org.drools.spi.PropagationContext;
+import java.io.ObjectInput;
+import java.io.IOException;
+import java.io.ObjectOutput;
+
public class SingleTupleSinkAdapter
implements
TupleSinkPropagator {
private TupleSink sink;
+ public SingleTupleSinkAdapter() {
+
+ }
+
public SingleTupleSinkAdapter(final TupleSink sink) {
this.sink = sink;
}
+ public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
+ sink = (TupleSink)in.readObject();
+ }
+
+ public void writeExternal(ObjectOutput out) throws IOException {
+ out.writeObject(sink);
+ }
+
public void propagateAssertTuple(final ReteTuple tuple,
final InternalFactHandle handle,
final PropagationContext context,
Modified: labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/reteoo/TerminalNode.java
===================================================================
--- labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/reteoo/TerminalNode.java 2008-03-20 18:57:07 UTC (rev 19163)
+++ labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/reteoo/TerminalNode.java 2008-03-20 19:32:10 UTC (rev 19164)
@@ -16,11 +16,13 @@
package org.drools.reteoo;
+import org.drools.common.NetworkNode;
+
/**
* A markup interface for terminal nodes
*
* @author etirelli
*/
-public interface TerminalNode {
+public interface TerminalNode extends NetworkNode {
}
Modified: labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/reteoo/TupleSink.java
===================================================================
--- labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/reteoo/TupleSink.java 2008-03-20 18:57:07 UTC (rev 19163)
+++ labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/reteoo/TupleSink.java 2008-03-20 19:32:10 UTC (rev 19164)
@@ -2,13 +2,13 @@
/*
* Copyright 2005 JBoss Inc
- *
+ *
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -17,6 +17,7 @@
*/
import java.io.Serializable;
+import java.io.Externalizable;
import org.drools.common.InternalWorkingMemory;
import org.drools.spi.PropagationContext;
@@ -24,24 +25,24 @@
/**
* Receiver of propagated <code>ReteTuple</code>s from a
* <code>TupleSource</code>.
- *
+ *
* @see TupleSource
- *
+ *
* @author <a href="mailto:mark.proctor at jboss.com">Mark Proctor</a>
* @author <a href="mailto:bob at werken.com">Bob McWhirter</a>
*/
public interface TupleSink
extends
- Serializable,
+ Externalizable,
Sink {
/**
* Assert a new <code>ReteTuple</code>.
- *
+ *
* @param tuple
* The <code>ReteTuple</code> to propagate.
* @param context
- * The <code>PropagationContext</code> of the <code>WorkingMemory<code> action
+ * The <code>PropagationContext</code> of the <code>WorkingMemory<code> action
* @param workingMemory
* the <code>WorkingMemory</code> session.
*/
@@ -52,8 +53,8 @@
void retractTuple(ReteTuple tuple,
PropagationContext context,
InternalWorkingMemory workingMemory);
-
+
public boolean isTupleMemoryEnabled();
- public void setTupleMemoryEnabled(boolean tupleMemoryEnabled);
+ public void setTupleMemoryEnabled(boolean tupleMemoryEnabled);
}
Modified: labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/reteoo/TupleSinkNodeList.java
===================================================================
--- labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/reteoo/TupleSinkNodeList.java 2008-03-20 18:57:07 UTC (rev 19163)
+++ labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/reteoo/TupleSinkNodeList.java 2008-03-20 19:32:10 UTC (rev 19164)
@@ -1,18 +1,22 @@
package org.drools.reteoo;
import java.io.Serializable;
+import java.io.Externalizable;
+import java.io.ObjectOutput;
+import java.io.ObjectInput;
+import java.io.IOException;
import java.util.Iterator;
import java.util.NoSuchElementException;
/*
* Copyright 2005 JBoss Inc
- *
+ *
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -23,7 +27,7 @@
/**
* This is a simple linked linked implementation. Each node must implement </code>LinkedListNode<code> so that it references
* the node before and after it. This way a node can be removed without having to scan the list to find it. This class
- * does not provide an Iterator implementation as its designed for efficiency and not genericity. There are a number of
+ * does not provide an Iterator implementation as its designed for efficiency and not genericity. There are a number of
* ways to iterate the list.
* <p>
* Simple iterator:
@@ -31,7 +35,7 @@
* for ( LinkedListNode node = list.getFirst(); node != null; node = node.getNext() ) {
* }
* </pre>
- *
+ *
* Iterator that pops the first entry:
* <pre>
* for ( LinkedListNode node = list.removeFirst(); node != null; node = list.removeFirst() ) {
@@ -45,7 +49,7 @@
*/
public class TupleSinkNodeList
implements
- Serializable {
+ Externalizable {
private static final long serialVersionUID = 400L;
private TupleSinkNode firstNode;
@@ -57,13 +61,23 @@
* Construct an empty <code>LinkedList</code>
*/
public TupleSinkNodeList() {
+ }
+ public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
+ firstNode = (TupleSinkNode)in.readObject();
+ lastNode = (TupleSinkNode)in.readObject();
+ size = in.readInt();
}
+ public void writeExternal(ObjectOutput out) throws IOException {
+ out.writeObject(firstNode);
+ out.writeObject(lastNode);
+ out.writeInt(size);
+ }
/**
- * Add a <code>TupleSinkNode</code> to the list. If the <code>LinkedList</code> is empty then the first and
+ * Add a <code>TupleSinkNode</code> to the list. If the <code>LinkedList</code> is empty then the first and
* last nodes are set to the added node.
- *
+ *
* @param node
* The <code>TupleSinkNode</code> to be added
*/
@@ -83,7 +97,7 @@
* Removes a <code>TupleSinkNode</code> from the list. This works by attach the previous reference to the child reference.
* When the node to be removed is the first node it calls <code>removeFirst()</code>. When the node to be removed is the last node
* it calls <code>removeLast()</code>.
- *
+ *
* @param node
* The <code>TupleSinkNode</code> to be removed.
*/
@@ -123,9 +137,9 @@
}
/**
- * Remove the first node from the list. The next node then becomes the first node. If this is the last
+ * Remove the first node from the list. The next node then becomes the first node. If this is the last
* node then both first and last node references are set to null.
- *
+ *
* @return
* The first <code>TupleSinkNode</code>.
*/
@@ -146,9 +160,9 @@
}
/**
- * Remove the last node from the list. The previous node then becomes the last node. If this is the last
+ * Remove the last node from the list. The previous node then becomes the last node. If this is the last
* node then both first and last node references are set to null.
- *
+ *
* @return
* The first <code>TupleSinkNode</code>.
*/
@@ -177,7 +191,7 @@
}
/**
- * Iterates the list removing all the nodes until there are no more nodes to remove.
+ * Iterates the list removing all the nodes until there are no more nodes to remove.
*/
public void clear() {
while ( removeFirst() != null ) {
Modified: labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/reteoo/TupleSinkPropagator.java
===================================================================
--- labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/reteoo/TupleSinkPropagator.java 2008-03-20 18:57:07 UTC (rev 19163)
+++ labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/reteoo/TupleSinkPropagator.java 2008-03-20 19:32:10 UTC (rev 19164)
@@ -1,6 +1,6 @@
package org.drools.reteoo;
-import java.io.Serializable;
+import java.io.Externalizable;
import org.drools.common.InternalFactHandle;
import org.drools.common.InternalWorkingMemory;
@@ -8,7 +8,7 @@
public interface TupleSinkPropagator
extends
- Serializable {
+ Externalizable {
public void propagateAssertTuple(ReteTuple tuple,
InternalFactHandle handle,
PropagationContext context,
Modified: labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/reteoo/TupleSource.java
===================================================================
--- labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/reteoo/TupleSource.java 2008-03-20 18:57:07 UTC (rev 19163)
+++ labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/reteoo/TupleSource.java 2008-03-20 19:32:10 UTC (rev 19164)
@@ -2,13 +2,13 @@
/*
* Copyright 2005 JBoss Inc
- *
+ *
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -17,6 +17,10 @@
*/
import java.io.Serializable;
+import java.io.Externalizable;
+import java.io.IOException;
+import java.io.ObjectOutput;
+import java.io.ObjectInput;
import org.drools.common.BaseNode;
import org.drools.common.InternalWorkingMemory;
@@ -24,20 +28,20 @@
/**
* A source of <code>ReteTuple</code> s for a <code>TupleSink</code>.
- *
+ *
* <p>
* Nodes that propagate <code>Tuples</code> extend this class.
* </p>
- *
+ *
* @see TupleSource
* @see ReteTuple
- *
+ *
* @author <a href="mailto:mark.proctor at jboss.com">Mark Proctor</a>
* @author <a href="mailto:bob at werken.com">Bob McWhirter</a>
*/
public abstract class TupleSource extends BaseNode
implements
- Serializable {
+ Externalizable {
// ------------------------------------------------------------
// Instance members
// ------------------------------------------------------------
@@ -48,10 +52,13 @@
// ------------------------------------------------------------
// Constructors
// ------------------------------------------------------------
+ public TupleSource() {
+ }
+
/**
* Single parameter constructor that specifies the unique id of the node.
- *
+ *
* @param id
*/
TupleSource(final int id) {
@@ -62,17 +69,26 @@
// ------------------------------------------------------------
// Instance methods
// ------------------------------------------------------------
+ public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
+ super.readExternal(in);
+ sink = (TupleSinkPropagator)in.readObject();
+ }
+ public void writeExternal(ObjectOutput out) throws IOException {
+ super.writeExternal(out);
+ out.writeObject(sink);
+ }
+
/**
* Adds the <code>TupleSink</code> so that it may receive
* <code>Tuples</code> propagated from this <code>TupleSource</code>.
- *
+ *
* @param tupleSink
* The <code>TupleSink</code> to receive propagated
* <code>Tuples</code>.
*/
protected void addTupleSink(final TupleSink tupleSink) {
- if ( this.sink == EmptyTupleSinkAdapter.getInstance() ) {
+ if ( this.sink instanceof EmptyTupleSinkAdapter ) {
this.sink = new SingleTupleSinkAdapter( tupleSink );
} else if ( this.sink instanceof SingleTupleSinkAdapter ) {
final CompositeTupleSinkAdapter sinkAdapter = new CompositeTupleSinkAdapter();
@@ -86,12 +102,12 @@
/**
* Removes the <code>TupleSink</code>
- *
+ *
* @param tupleSink
* The <code>TupleSink</code> to remove
*/
protected void removeTupleSink(final TupleSink tupleSink) {
- if ( this.sink == EmptyTupleSinkAdapter.getInstance() ) {
+ if ( this.sink instanceof EmptyTupleSinkAdapter ) {
throw new IllegalArgumentException( "Cannot remove a sink, when the list of sinks is null" );
}
@@ -113,7 +129,7 @@
public abstract void updateSink(TupleSink sink,
PropagationContext context,
InternalWorkingMemory workingMemory);
-
+
public boolean isInUse() {
return this.sink.size() > 0;
}
Modified: labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/reteoo/builder/ReteooRuleBuilder.java
===================================================================
--- labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/reteoo/builder/ReteooRuleBuilder.java 2008-03-20 18:57:07 UTC (rev 19163)
+++ labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/reteoo/builder/ReteooRuleBuilder.java 2008-03-20 19:32:10 UTC (rev 19164)
@@ -181,6 +181,8 @@
((BaseNode) terminal).attach( context.getWorkingMemories() );
}
+ ((BaseNode) terminal).networkUpdated();
+
return terminal;
}
Modified: labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/rule/AbstractCompositeConstraint.java
===================================================================
--- labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/rule/AbstractCompositeConstraint.java 2008-03-20 18:57:07 UTC (rev 19163)
+++ labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/rule/AbstractCompositeConstraint.java 2008-03-20 19:32:10 UTC (rev 19164)
@@ -1,12 +1,12 @@
/*
* Copyright 2006 JBoss Inc
- *
+ *
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -16,6 +16,9 @@
package org.drools.rule;
import java.util.Arrays;
+import java.io.ObjectOutput;
+import java.io.IOException;
+import java.io.ObjectInput;
import org.drools.RuntimeDroolsException;
import org.drools.common.InternalFactHandle;
@@ -28,7 +31,7 @@
/**
* A superclass for all composite constraints, like "OR" and "AND"
- *
+ *
* @author etirelli
*/
public abstract class AbstractCompositeConstraint extends MutableTypeConstraint {
@@ -42,9 +45,22 @@
this.setType( Constraint.ConstraintType.ALPHA );
}
+ public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
+ super.readExternal(in);
+ alphaConstraints = (AlphaNodeFieldConstraint[])in.readObject();
+ betaConstraints = (BetaNodeFieldConstraint[])in.readObject();
+ requiredDeclarations = (Declaration[])in.readObject();
+ }
+
+ public void writeExternal(ObjectOutput out) throws IOException {
+ super.writeExternal(out);
+ out.writeObject(alphaConstraints);
+ out.writeObject(betaConstraints);
+ out.writeObject(requiredDeclarations);
+ }
/**
* Adds an alpha constraint to the multi field OR constraint
- *
+ *
* @param constraint
*/
public void addAlphaConstraint(AlphaNodeFieldConstraint constraint) {
@@ -81,13 +97,13 @@
}
/**
- * Adds a constraint too all lists it belongs to by checking for its type
+ * Adds a constraint too all lists it belongs to by checking for its type
* @param constraint
*/
public void addConstraint(Constraint constraint) {
- if ( constraint.getType() == ConstraintType.ALPHA ) {
+ if ( ConstraintType.ALPHA.equals(constraint.getType())) {
this.addAlphaConstraint( (AlphaNodeFieldConstraint) constraint );
- } else if ( constraint.getType() == ConstraintType.BETA ) {
+ } else if ( ConstraintType.BETA.equals(constraint.getType())) {
this.addBetaConstraint( (BetaNodeFieldConstraint) constraint );
} else {
throw new RuntimeDroolsException( "Constraint type MUST be known in advance.");
@@ -96,7 +112,7 @@
/**
* Updades the cached required declaration array
- *
+ *
* @param constraint
*/
protected void updateRequiredDeclarations(Constraint constraint) {
@@ -185,10 +201,10 @@
}
public abstract Object clone();
-
+
/**
* A context entry for composite restrictions
- *
+ *
* @author etirelli
*/
protected static class MultiFieldConstraintContextEntry
@@ -197,12 +213,15 @@
private static final long serialVersionUID = 400L;
- public final ContextEntry[] alphas;
- public final ContextEntry[] betas;
+ public ContextEntry[] alphas;
+ public ContextEntry[] betas;
public ContextEntry next;
public InternalWorkingMemory workingMemory;
public InternalFactHandle handle;
+ public MultiFieldConstraintContextEntry() {
+ }
+
public MultiFieldConstraintContextEntry(final AlphaNodeFieldConstraint[] alphas,
final BetaNodeFieldConstraint[] betas) {
this.alphas = new ContextEntry[alphas.length];
@@ -215,6 +234,22 @@
}
}
+ public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
+ alphas = (ContextEntry[])in.readObject();
+ betas = (ContextEntry[])in.readObject();
+ next = (ContextEntry)in.readObject();
+ workingMemory = (InternalWorkingMemory)in.readObject();
+ handle = (InternalFactHandle)in.readObject();
+ }
+
+ public void writeExternal(ObjectOutput out) throws IOException {
+ out.writeObject(alphas);
+ out.writeObject(betas);
+ out.writeObject(next);
+ out.writeObject(workingMemory);
+ out.writeObject(handle);
+ }
+
public ContextEntry getNext() {
return this.next;
}
Modified: labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/rule/AbstractCompositeRestriction.java
===================================================================
--- labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/rule/AbstractCompositeRestriction.java 2008-03-20 18:57:07 UTC (rev 19163)
+++ labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/rule/AbstractCompositeRestriction.java 2008-03-20 19:32:10 UTC (rev 19164)
@@ -3,6 +3,9 @@
import java.util.Arrays;
import java.util.HashSet;
import java.util.Set;
+import java.io.IOException;
+import java.io.ObjectInput;
+import java.io.ObjectOutput;
import org.drools.common.InternalFactHandle;
import org.drools.common.InternalWorkingMemory;
@@ -15,12 +18,23 @@
private static final long serialVersionUID = 400L;
- protected final Restriction[] restrictions;
+ protected Restriction[] restrictions;
+ public AbstractCompositeRestriction() {
+ }
+
public AbstractCompositeRestriction(final Restriction[] restriction) {
this.restrictions = restriction;
}
+ public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
+ restrictions = (Restriction[])in.readObject();
+ }
+
+ public void writeExternal(ObjectOutput out) throws IOException {
+ out.writeObject(restrictions);
+ }
+
public Declaration[] getRequiredDeclarations() {
// Iterate all restrictions building up a unique list of declarations
// No need to cache, as this should only be called once at build time
@@ -95,6 +109,9 @@
private ContextEntry entry;
+ public CompositeContextEntry() {
+ }
+
public CompositeContextEntry(final Restriction[] restrictions) {
contextEntries = new ContextEntry[restrictions.length];
for ( int i = 0; i < restrictions.length; i++ ) {
@@ -102,6 +119,15 @@
}
}
+ public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
+ contextEntries = (ContextEntry[])in.readObject();
+ entry = (ContextEntry)in.readObject();
+ }
+
+ public void writeExternal(ObjectOutput out) throws IOException {
+ out.writeObject(contextEntries);
+ out.writeObject(entry);
+ }
public ContextEntry getNext() {
return this.entry;
}
@@ -125,18 +151,18 @@
tuple );
}
}
-
+
public void resetTuple() {
for ( int i = 0, length = this.contextEntries.length; i < length; i++ ) {
this.contextEntries[i].resetTuple();
}
}
-
+
public void resetFactHandle() {
for ( int i = 0, length = this.contextEntries.length; i < length; i++ ) {
this.contextEntries[i].resetFactHandle();
}
- }
+ }
}
Modified: labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/rule/Accumulate.java
===================================================================
--- labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/rule/Accumulate.java 2008-03-20 18:57:07 UTC (rev 19163)
+++ labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/rule/Accumulate.java 2008-03-20 19:32:10 UTC (rev 19164)
@@ -1,12 +1,12 @@
/*
* Copyright 2005 JBoss Inc
- *
+ *
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -19,6 +19,9 @@
import java.util.Collections;
import java.util.List;
import java.util.Map;
+import java.io.ObjectOutput;
+import java.io.IOException;
+import java.io.ObjectInput;
import org.drools.RuntimeDroolsException;
import org.drools.WorkingMemory;
@@ -40,6 +43,10 @@
private Declaration[] requiredDeclarations;
private Declaration[] innerDeclarations;
+ public Accumulate() {
+
+ }
+
public Accumulate(final RuleConditionElement source) {
this( source,
@@ -69,6 +76,20 @@
this.accumulator = accumulator;
}
+ public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
+ accumulator = (Accumulator)in.readObject();
+ source = (RuleConditionElement)in.readObject();
+ requiredDeclarations = (Declaration[])in.readObject();
+ innerDeclarations = (Declaration[])in.readObject();
+ }
+
+ public void writeExternal(ObjectOutput out) throws IOException {
+ out.writeObject(accumulator);
+ out.writeObject(source);
+ out.writeObject(requiredDeclarations);
+ out.writeObject(innerDeclarations);
+ }
+
public Accumulator getAccumulator() {
return this.accumulator;
}
@@ -83,7 +104,7 @@
/**
* Executes the initialization block of code
- *
+ *
* @param leftTuple tuple causing the rule fire
* @param declarations previous declarations
* @param workingMemory
@@ -106,7 +127,7 @@
/**
* Executes the accumulate (action) code for the given fact handle
- *
+ *
* @param leftTuple
* @param handle
* @param declarations
@@ -134,7 +155,7 @@
/**
* Executes the reverse (action) code for the given fact handle
- *
+ *
* @param leftTuple
* @param handle
* @param declarations
@@ -162,7 +183,7 @@
/**
* Gets the result of the accummulation
- *
+ *
* @param leftTuple
* @param declarations
* @param workingMemory
Modified: labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/rule/AndCompositeRestriction.java
===================================================================
--- labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/rule/AndCompositeRestriction.java 2008-03-20 18:57:07 UTC (rev 19163)
+++ labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/rule/AndCompositeRestriction.java 2008-03-20 19:32:10 UTC (rev 19164)
@@ -10,6 +10,9 @@
private static final long serialVersionUID = 400L;
+ public AndCompositeRestriction() {
+ }
+
public AndCompositeRestriction(final Restriction[] restriction) {
super( restriction );
}
@@ -52,7 +55,7 @@
}
return true;
}
-
+
public Object clone() {
Restriction[] clone = new Restriction[ this.restrictions.length ];
for( int i = 0; i < clone.length; i++ ) {
Modified: labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/rule/Collect.java
===================================================================
--- labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/rule/Collect.java 2008-03-20 18:57:07 UTC (rev 19163)
+++ labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/rule/Collect.java 2008-03-20 19:32:10 UTC (rev 19164)
@@ -1,12 +1,12 @@
/*
* Copyright 2005 JBoss Inc
- *
+ *
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -20,6 +20,9 @@
import java.util.Collections;
import java.util.List;
import java.util.Map;
+import java.io.ObjectOutput;
+import java.io.IOException;
+import java.io.ObjectInput;
import org.drools.RuntimeDroolsException;
import org.drools.base.ClassObjectType;
@@ -37,6 +40,9 @@
private Pattern sourcePattern;
private Pattern resultPattern;
+ public Collect() {
+ }
+
public Collect(final Pattern sourcePattern,
final Pattern resultPattern) {
@@ -44,6 +50,16 @@
this.resultPattern = resultPattern;
}
+ public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
+ sourcePattern = (Pattern)in.readObject();
+ resultPattern = (Pattern)in.readObject();
+ }
+
+ public void writeExternal(ObjectOutput out) throws IOException {
+ out.writeObject(sourcePattern);
+ out.writeObject(resultPattern);
+ }
+
public Object clone() {
return new Collect( this.sourcePattern,
this.resultPattern );
Modified: labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/rule/CompositePackageClassLoader.java
===================================================================
--- labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/rule/CompositePackageClassLoader.java 2008-03-20 18:57:07 UTC (rev 19163)
+++ labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/rule/CompositePackageClassLoader.java 2008-03-20 19:32:10 UTC (rev 19164)
@@ -1,7 +1,6 @@
package org.drools.rule;
import java.io.InputStream;
-import java.net.URL;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
@@ -58,7 +57,7 @@
if ( parent != null ) {
clazz = parent.loadClass( name );
} else {
- throw new ClassNotFoundException( name );
+ return null;
}
}
}
@@ -79,7 +78,7 @@
if ( stream != null ) {
return stream;
}
- }
+ }
return stream;
}
Modified: labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/rule/ContextEntry.java
===================================================================
--- labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/rule/ContextEntry.java 2008-03-20 18:57:07 UTC (rev 19163)
+++ labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/rule/ContextEntry.java 2008-03-20 19:32:10 UTC (rev 19164)
@@ -1,6 +1,6 @@
package org.drools.rule;
-import java.io.Serializable;
+import java.io.Externalizable;
import org.drools.common.InternalFactHandle;
import org.drools.common.InternalWorkingMemory;
@@ -8,7 +8,7 @@
public interface ContextEntry
extends
- Serializable {
+ Externalizable {
public ContextEntry getNext();
@@ -19,9 +19,9 @@
public void updateFromFactHandle(InternalWorkingMemory workingMemory,
InternalFactHandle handle);
-
+
public void resetTuple();
-
+
public void resetFactHandle();
-
+
}
Modified: labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/rule/Declaration.java
===================================================================
--- labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/rule/Declaration.java 2008-03-20 18:57:07 UTC (rev 19163)
+++ labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/rule/Declaration.java 2008-03-20 19:32:10 UTC (rev 19164)
@@ -41,6 +41,10 @@
*/
import java.io.Serializable;
+import java.io.Externalizable;
+import java.io.IOException;
+import java.io.ObjectInput;
+import java.io.ObjectOutput;
import java.lang.reflect.Method;
import java.util.Collection;
import java.util.Iterator;
@@ -53,13 +57,13 @@
/*
* Copyright 2005 JBoss Inc
- *
+ *
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -75,33 +79,36 @@
*/
public class Declaration
implements
- Serializable,
+ Externalizable,
Cloneable {
// ------------------------------------------------------------
// Instance members
// ------------------------------------------------------------
/**
- *
+ *
*/
private static final long serialVersionUID = 400L;
/** The identifier for the variable. */
- private final String identifier;
+ private String identifier;
- private final Extractor extractor;
+ private Extractor extractor;
private Pattern pattern;
- private final boolean internalFact;
+ private boolean internalFact;
// ------------------------------------------------------------
// Constructors
// ------------------------------------------------------------
+ public Declaration() {
+ this(null, null, null);
+ }
/**
* Construct.
- *
+ *
* @param identifier
* The name of the variable.
* @param objectType
@@ -120,7 +127,7 @@
/**
* Construct.
- *
+ *
* @param identifier
* The name of the variable.
* @param objectType
@@ -141,13 +148,26 @@
this.internalFact = internalFact;
}
+ public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
+ identifier = (String)in.readObject();
+ extractor = (Extractor)in.readObject();
+ pattern = (Pattern)in.readObject();
+ internalFact = in.readBoolean();
+ }
+
+ public void writeExternal(ObjectOutput out) throws IOException {
+ out.writeObject(identifier);
+ out.writeObject(extractor);
+ out.writeObject(pattern);
+ out.writeBoolean(internalFact);
+ }
// ------------------------------------------------------------
// Instance methods
// ------------------------------------------------------------
/**
* Retrieve the variable's identifier.
- *
+ *
* @return The variable's identifier.
*/
public String getIdentifier() {
@@ -156,7 +176,7 @@
/**
* Retrieve the <code>ValueType</code>.
- *
+ *
* @return The ValueType.
*/
public ValueType getValueType() {
@@ -165,7 +185,7 @@
/**
* Returns the index of the pattern
- *
+ *
* @return the pattern
*/
public Pattern getPattern() {
@@ -186,7 +206,7 @@
/**
* Returns the Extractor expression
- *
+ *
* @return
*/
public Extractor getExtractor() {
@@ -287,7 +307,7 @@
throw new RuntimeDroolsException( "This is a bug. Please report to development team: " + e.getMessage(),
e );
}
- }
+ }
return this.extractor.getNativeReadMethod();
}
@@ -323,7 +343,7 @@
protected boolean isInternalFact() {
return internalFact;
}
-
+
public Object clone() {
return new Declaration( this.identifier, this.extractor, this.pattern );
}
Modified: labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/rule/DialectDatas.java
===================================================================
--- labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/rule/DialectDatas.java 2008-03-20 18:57:07 UTC (rev 19163)
+++ labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/rule/DialectDatas.java 2008-03-20 19:32:10 UTC (rev 19164)
@@ -1,56 +1,48 @@
package org.drools.rule;
-import java.io.ByteArrayInputStream;
-import java.io.ByteArrayOutputStream;
+import org.drools.common.DroolsObjectInput;
+
import java.io.Externalizable;
import java.io.IOException;
import java.io.ObjectInput;
import java.io.ObjectOutput;
-import java.io.ObjectOutputStream;
-import java.io.Serializable;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;
import java.util.Map.Entry;
-import org.drools.RuntimeDroolsException;
-import org.drools.common.DroolsObjectInputStream;
-import org.drools.rule.JavaDialectData.PackageClassLoader;
+import org.drools.common.DroolsObjectInput;
public class DialectDatas implements Externalizable {
- private ClassLoader parentClassLoader;
+ private transient ClassLoader parentClassLoader;
private CompositePackageClassLoader classLoader;
-
+
private Map<String, DialectData> dialects;
-
+
private Map lineMappings;
-
+
/**
* Default constructor - for Externalizable. This should never be used by a user, as it
* will result in an invalid state for the instance.
- */
+ */
public DialectDatas() {
-
+ this(null);
}
-
+
public DialectDatas(ClassLoader classLoader) {
- this.parentClassLoader = classLoader;
+ setParentClassLoader(classLoader);
this.classLoader = new CompositePackageClassLoader( this.parentClassLoader );
this.dialects = new HashMap<String, DialectData>();
}
-
+
/**
* Handles the write serialization of the PackageCompilationData. Patterns in Rules may reference generated data which cannot be serialized by
* default methods. The PackageCompilationData holds a reference to the generated bytecode. The generated bytecode must be restored before any Rules.
*
*/
public void writeExternal(final ObjectOutput stream) throws IOException {
- stream.writeObject( this.lineMappings );
-
- final ByteArrayOutputStream bos = new ByteArrayOutputStream();
- final ObjectOutput out = new ObjectOutputStream( bos );
- out.writeObject( this.dialects );
- stream.writeObject( bos.toByteArray() );
+ stream.writeObject(this.dialects);
+ stream.writeObject( this.lineMappings );
}
/**
@@ -60,56 +52,49 @@
*
*/
public void readExternal(final ObjectInput stream) throws IOException,
- ClassNotFoundException {
- if ( stream instanceof DroolsObjectInputStream ) {
- DroolsObjectInputStream droolsStream = (DroolsObjectInputStream) stream;
- this.parentClassLoader = droolsStream.getClassLoader();
- } else {
- this.parentClassLoader = Thread.currentThread().getContextClassLoader();
- }
-
+ ClassNotFoundException {
+ DroolsObjectInput droolsStream = (DroolsObjectInput)stream;
+
+ setParentClassLoader(droolsStream.getClassLoader());
this.classLoader = new CompositePackageClassLoader( this.parentClassLoader );
+ droolsStream.setDialectDatas(this);
+ droolsStream.setClassLoader(this.classLoader);
- this.lineMappings = (Map) stream.readObject();
-
- final byte[] bytes = (byte[]) stream.readObject();
- final DroolsObjectInputStream streamWithLoader = new DroolsObjectInputStream( new ByteArrayInputStream( bytes ),
- this.classLoader );
- streamWithLoader.setDialectDatas( this );
- this.dialects = (Map) streamWithLoader.readObject();
- }
-
+ this.dialects = (Map<String, DialectData>)droolsStream.readObject();
+ this.lineMappings = (Map) stream.readObject();
+ }
+
public void addDialectData(String dialect, DialectData dialectData) {
this.dialects.put( dialect, dialectData );
}
-
+
public void setDialectData(String name, DialectData data) {
this.dialects.put( name, data );
}
-
+
public DialectData getDialectData(String dialect) {
return this.dialects.get( dialect );
}
-
+
public DialectData removeRule(final Package pkg, final Rule rule) {
DialectData dialect = this.dialects.get( rule.getDialect() );
dialect.removeRule( pkg, rule );
return dialect;
}
-
+
public DialectData removeFunction(final Package pkg, final Function function) {
DialectData dialect = this.dialects.get( function.getDialect() );
dialect.removeFunction( pkg, function );
- return dialect;
+ return dialect;
}
-
+
public void merge(DialectDatas newDatas) {
for(Iterator it = newDatas.dialects.entrySet().iterator(); it.hasNext(); ) {
Entry entry = ( Entry ) it.next();
DialectData data = ( DialectData ) this.dialects.get( entry.getKey() );
- data.merge( ( DialectData ) entry.getValue() );
+ data.merge( ( DialectData ) entry.getValue() );
}
-
+
if ( this.lineMappings != null ) {
// merge line mappings
this.lineMappings.putAll( newDatas.getLineMappings() );
@@ -117,59 +102,68 @@
this.lineMappings = newDatas.getLineMappings();
}
}
-
+
public boolean isDirty() {
return true;
}
-
+
public void reloadDirty() {
// detect if any dialect is dirty, if so reload() them all
boolean isDirty = false;
- for(Iterator it = this.dialects.values().iterator(); it.hasNext(); ) {
+ for(Iterator it = this.dialects.values().iterator(); it.hasNext(); ) {
DialectData data = ( DialectData ) it.next();
if ( data.isDirty() ) {
isDirty = true;
break;
}
- }
-
+ }
+
if ( isDirty ) {
this.classLoader = new CompositePackageClassLoader( this.parentClassLoader );
- for(Iterator it = this.dialects.values().iterator(); it.hasNext(); ) {
+ for(Iterator it = this.dialects.values().iterator(); it.hasNext(); ) {
DialectData data = ( DialectData ) it.next();
data.reload();
- }
+ }
}
- }
-
+ }
+
public ClassLoader getParentClassLoader() {
return this.parentClassLoader;
}
public void setParentClassLoader(ClassLoader classLoader) {
+ if (classLoader == null) {
+ classLoader = Thread.currentThread().getContextClassLoader();
+ if ( classLoader == null ) {
+ classLoader = getClass().getClassLoader();
+ }
+ }
this.parentClassLoader = classLoader;
}
-
+
public ClassLoader getClassLoader() {
return this.classLoader;
}
-
+
public void addClassLoader(ClassLoader classLoader) {
+ if (this.classLoader == null) {
+
+ }
this.classLoader.addClassLoader( classLoader );
}
public void clear() {
this.dialects.clear();
}
-
+
public LineMappings getLineMappings(final String className) {
return (LineMappings) getLineMappings().get( className );
- }
-
+ }
+
public Map getLineMappings() {
if ( this.lineMappings == null ) {
this.lineMappings = new HashMap();
}
return this.lineMappings;
- }
+ }
}
Modified: labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/rule/DroolsClassLoader.java
===================================================================
--- labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/rule/DroolsClassLoader.java 2008-03-20 18:57:07 UTC (rev 19163)
+++ labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/rule/DroolsClassLoader.java 2008-03-20 19:32:10 UTC (rev 19164)
@@ -1,10 +1,11 @@
package org.drools.rule;
import java.io.InputStream;
+import java.io.Externalizable;
public interface DroolsClassLoader {
-
+
InputStream getResourceAsStream(final String name);
-
+
public Class fastFindClass(final String name);
}
Modified: labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/rule/EntryPoint.java
===================================================================
--- labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/rule/EntryPoint.java 2008-03-20 18:57:07 UTC (rev 19163)
+++ labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/rule/EntryPoint.java 2008-03-20 19:32:10 UTC (rev 19164)
@@ -1,12 +1,12 @@
/*
* Copyright 2007 JBoss Inc
- *
+ *
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -20,6 +20,10 @@
import java.util.Collections;
import java.util.List;
import java.util.Map;
+import java.io.Externalizable;
+import java.io.ObjectInput;
+import java.io.IOException;
+import java.io.ObjectOutput;
/**
* This class defines a Rete "Entry Point".
@@ -28,33 +32,44 @@
* network is not shared among separate entry points
* and this allows them to safelly run in parallel
* and concurrent modes.
- *
+ *
* @author etirelli
*
*/
public class EntryPoint extends ConditionalElement
implements
- PatternSource {
+ PatternSource, Externalizable {
public static final EntryPoint DEFAULT = new EntryPoint("DEFAULT");
-
+
private static final long serialVersionUID = 1435985794248365232L;
-
- private final String entryPointId;
-
+
+ private String entryPointId;
+
+ public EntryPoint() {
+
+ }
/**
* Constructor.
- *
+ *
* @param entryPointId the ID for this entry point
*/
public EntryPoint( final String entryPointId ) {
this.entryPointId = entryPointId;
}
- /**
- * There is not reason to clone this object since it is stateless.
+ public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
+ entryPointId = (String)in.readObject();
+ }
+
+ public void writeExternal(ObjectOutput out) throws IOException {
+ out.writeObject(entryPointId);
+ }
+
+ /**
+ * There is not reason to clone this object since it is stateless.
* So a clone() call will return the instance itself.
- *
+ *
* @see org.drools.rule.ConditionalElement#clone()
*/
@Override
@@ -62,10 +77,10 @@
return this;
}
- /**
+ /**
* It is not possible to declare any new variables, so always
* return an Empty Map
- *
+ *
* @see org.drools.rule.RuleConditionElement#getInnerDeclarations()
*/
public Map getInnerDeclarations() {
@@ -75,7 +90,7 @@
/**
* It is not possible to nest elements inside an entry point, so
* always return an empty list.
- *
+ *
* @see org.drools.rule.RuleConditionElement#getNestedElements()
*/
public List getNestedElements() {
@@ -85,22 +100,22 @@
/**
* It is not possible to declare and export any variables,
* so always return an empty map
- *
+ *
* @see org.drools.rule.RuleConditionElement#getOuterDeclarations()
*/
public Map getOuterDeclarations() {
return Collections.EMPTY_MAP;
}
- /**
+ /**
* Not possible to resolve any declaration, so always return null.
- *
+ *
* @see org.drools.rule.RuleConditionElement#resolveDeclaration(java.lang.String)
*/
public Declaration resolveDeclaration(String identifier) {
return null;
}
-
+
/**
* Returns this entry point ID
* @return
Modified: labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/rule/EvalCondition.java
===================================================================
--- labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/rule/EvalCondition.java 2008-03-20 18:57:07 UTC (rev 19163)
+++ labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/rule/EvalCondition.java 2008-03-20 19:32:10 UTC (rev 19164)
@@ -2,13 +2,13 @@
/*
* Copyright 2005 JBoss Inc
- *
+ *
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -19,24 +19,32 @@
import java.util.Collections;
import java.util.List;
import java.util.Map;
+import java.io.ObjectOutput;
+import java.io.IOException;
+import java.io.ObjectInput;
+import java.io.Externalizable;
import org.drools.RuntimeDroolsException;
import org.drools.WorkingMemory;
import org.drools.spi.EvalExpression;
import org.drools.spi.Tuple;
-public class EvalCondition extends ConditionalElement {
+public class EvalCondition extends ConditionalElement implements Externalizable {
/**
- *
+ *
*/
private static final long serialVersionUID = 400L;
private EvalExpression expression;
- private final Declaration[] requiredDeclarations;
+ private Declaration[] requiredDeclarations;
private static final Declaration[] EMPTY_DECLARATIONS = new Declaration[0];
+ public EvalCondition() {
+ this(null);
+ }
+
public EvalCondition(final Declaration[] requiredDeclarations) {
this( null,
requiredDeclarations );
@@ -54,6 +62,16 @@
}
}
+ public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
+ expression = (EvalExpression)in.readObject();
+ requiredDeclarations = (Declaration[])in.readObject();
+ }
+
+ public void writeExternal(ObjectOutput out) throws IOException {
+ out.writeObject(expression);
+ out.writeObject(requiredDeclarations);
+ }
+
public EvalExpression getEvalExpression() {
return this.expression;
}
@@ -65,7 +83,7 @@
public Declaration[] getRequiredDeclarations() {
return this.requiredDeclarations;
}
-
+
public Object createContext() {
return this.expression.createContext();
}
@@ -79,7 +97,7 @@
workingMemory,
context );
} catch ( final Exception e ) {
- throw new RuntimeDroolsException( e );
+ throw new RuntimeDroolsException( this.getEvalExpression() + " : " + e, e );
}
}
Modified: labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/rule/Forall.java
===================================================================
--- labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/rule/Forall.java 2008-03-20 18:57:07 UTC (rev 19163)
+++ labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/rule/Forall.java 2008-03-20 19:32:10 UTC (rev 19164)
@@ -1,12 +1,12 @@
/*
* Copyright 2006 JBoss Inc
- *
+ *
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -22,10 +22,13 @@
import java.util.Iterator;
import java.util.List;
import java.util.Map;
+import java.io.IOException;
+import java.io.ObjectOutput;
+import java.io.ObjectInput;
/**
* The forall conditional element.
- *
+ *
* @author etirelli
*/
public class Forall extends ConditionalElement {
@@ -53,6 +56,15 @@
this.remainingPatterns = remainingPatterns;
}
+ public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
+ basePattern = (Pattern)in.readObject();
+ remainingPatterns = (List)in.readObject();
+ }
+
+ public void writeExternal(ObjectOutput out) throws IOException {
+ out.writeObject(basePattern);
+ out.writeObject(remainingPatterns);
+ }
/* (non-Javadoc)
* @see org.drools.rule.ConditionalElement#clone()
*/
Modified: labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/rule/From.java
===================================================================
--- labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/rule/From.java 2008-03-20 18:57:07 UTC (rev 19163)
+++ labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/rule/From.java 2008-03-20 19:32:10 UTC (rev 19164)
@@ -1,6 +1,10 @@
package org.drools.rule;
import java.io.Serializable;
+import java.io.Externalizable;
+import java.io.IOException;
+import java.io.ObjectInput;
+import java.io.ObjectOutput;
import java.util.Collections;
import java.util.List;
import java.util.Map;
@@ -9,17 +13,28 @@
public class From extends ConditionalElement
implements
- Serializable,
+ Externalizable,
PatternSource {
private static final long serialVersionUID = 400L;
private DataProvider dataProvider;
+ public From() {
+ }
+
public From(final DataProvider dataProvider) {
this.dataProvider = dataProvider;
}
+ public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
+ dataProvider = (DataProvider)in.readObject();
+ }
+
+ public void writeExternal(ObjectOutput out) throws IOException {
+ out.writeObject(dataProvider);
+ }
+
public DataProvider getDataProvider() {
return this.dataProvider;
}
@@ -43,7 +58,7 @@
public Declaration resolveDeclaration(final String identifier) {
return null;
}
-
+
public List getNestedElements() {
return Collections.EMPTY_LIST;
}
Modified: labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/rule/Function.java
===================================================================
--- labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/rule/Function.java 2008-03-20 18:57:07 UTC (rev 19163)
+++ labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/rule/Function.java 2008-03-20 19:32:10 UTC (rev 19164)
@@ -1,11 +1,18 @@
package org.drools.rule;
-import java.io.Serializable;
+import java.io.Externalizable;
+import java.io.IOException;
+import java.io.ObjectInput;
+import java.io.ObjectOutput;
-public class Function implements Dialectable, Serializable {
+public class Function implements Dialectable, Externalizable {
private String name;
private String dialect;
-
+
+ public Function() {
+
+ }
+
public Function(String name,
String dialect) {
this.name = name;
@@ -19,4 +26,14 @@
public String getDialect() {
return this.dialect;
}
+
+ public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
+ name = (String)in.readObject();
+ dialect = (String)in.readObject();
+ }
+
+ public void writeExternal(ObjectOutput out) throws IOException {
+ out.writeObject(name);
+ out.writeObject(dialect);
+ }
}
Modified: labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/rule/GroupElement.java
===================================================================
--- labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/rule/GroupElement.java 2008-03-20 18:57:07 UTC (rev 19163)
+++ labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/rule/GroupElement.java 2008-03-20 19:32:10 UTC (rev 19164)
@@ -2,13 +2,13 @@
/*
* Copyright 2005 JBoss Inc
- *
+ *
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -17,6 +17,10 @@
*/
import java.io.Serializable;
+import java.io.ObjectInput;
+import java.io.ObjectOutput;
+import java.io.IOException;
+import java.io.Externalizable;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
@@ -26,7 +30,7 @@
import org.drools.RuntimeDroolsException;
-public class GroupElement extends ConditionalElement {
+public class GroupElement extends ConditionalElement implements Externalizable {
private static final long serialVersionUID = 400L;
@@ -36,7 +40,7 @@
public static final Type NOT = new NotType();
private Type type = null;
- private final List children = new ArrayList();
+ private List children = new ArrayList();
public GroupElement() {
this( AND );
@@ -46,12 +50,29 @@
this.type = type;
}
+ public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
+ String name = (String)in.readObject();
+ if ("AND".equals(name))
+ type = AND;
+ else if ("OR".equals(name))
+ type = OR;
+ else if ("EXISTS".equals(name))
+ type = EXISTS;
+ else
+ type = NOT;
+ children = (List)in.readObject();
+ }
+
+ public void writeExternal(ObjectOutput out) throws IOException {
+ out.writeObject(type.toString());
+ out.writeObject(children);
+ }
/**
* Adds a child to the current GroupElement.
- *
+ *
* Restrictions are:
* NOT/EXISTS: can have only one child, either a single Pattern or another CE
- *
+ *
* @param child
*/
public void addChild(final RuleConditionElement child) {
@@ -62,7 +83,7 @@
}
/**
- * Adds the given child as the (index)th child of the this GroupElement
+ * Adds the given child as the (index)th child of the this GroupElement
* @param index
* @param rce
*/
@@ -101,14 +122,14 @@
* Optimize the group element subtree by removing redundancies
* like an AND inside another AND, OR inside OR, single branches
* AND/OR, etc.
- *
+ *
* LogicTransformer does further, more complicated, transformations
*/
public void pack() {
// we must clone, since we want to iterate only over the original list
final Object[] clone = this.children.toArray();
for ( int i = 0; i < clone.length; i++ ) {
- // if child is also a group element, there may be
+ // if child is also a group element, there may be
// some possible clean up / optimizations to be done
if ( clone[i] instanceof GroupElement ) {
final GroupElement childGroup = (GroupElement) clone[i];
@@ -127,7 +148,7 @@
this.children.addAll( group.getChildren() );
}
}
-
+
}
/**
@@ -159,7 +180,7 @@
if ( child instanceof GroupElement ) {
final int previousSize = parent.getChildren().size();
((GroupElement) child).pack( parent );
- // in case the child also added elements to the parent,
+ // in case the child also added elements to the parent,
// we need to compensate
index += (parent.getChildren().size() - previousSize);
}
@@ -184,7 +205,7 @@
this.pack();
}
- // also pack itself if it is a NOT
+ // also pack itself if it is a NOT
} else {
this.pack();
}
@@ -193,7 +214,7 @@
/**
* Traverses two trees and checks that they are structurally equal at all
* levels
- *
+ *
* @param e1
* @param e2
* @return
@@ -239,7 +260,7 @@
/**
* Clones all Conditional Elements but references the non ConditionalElement
* children
- *
+ *
* @param e1
* @param e2
* @return
@@ -295,7 +316,7 @@
public String toString() {
return this.type.toString() + this.children.toString();
}
-
+
public List getNestedElements() {
return this.children;
}
@@ -309,7 +330,7 @@
*/
public static interface Type
extends
- Serializable {
+ Externalizable {
/**
* Returns true if this CE type is an AND
@@ -342,12 +363,12 @@
* visible outside of an element of this type
*/
public Map getOuterDeclarations(List children);
-
+
/**
* Returns true in case this RuleConditionElement delimits
* a pattern visibility scope.
- *
- * For instance, AND CE is not a scope delimiter, while
+ *
+ * For instance, AND CE is not a scope delimiter, while
* NOT CE is a scope delimiter
* @return
*/
@@ -408,7 +429,7 @@
private static final long serialVersionUID = 400L;
- AndType() {
+ public AndType() {
}
public boolean isAnd() {
@@ -446,6 +467,13 @@
return false;
}
+ public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
+
+ }
+
+ public void writeExternal(ObjectOutput out) throws IOException {
+
+ }
}
/**
@@ -455,7 +483,7 @@
private static final long serialVersionUID = 400L;
- OrType() {
+ public OrType() {
}
public boolean isAnd() {
@@ -492,6 +520,13 @@
public boolean isPatternScopeDelimiter() {
return false;
}
+ public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
+
+ }
+
+ public void writeExternal(ObjectOutput out) throws IOException {
+
+ }
}
/**
@@ -501,7 +536,7 @@
private static final long serialVersionUID = 400L;
- NotType() {
+ public NotType() {
}
public boolean isAnd() {
@@ -545,6 +580,13 @@
public boolean isPatternScopeDelimiter() {
return true;
}
+ public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
+
+ }
+
+ public void writeExternal(ObjectOutput out) throws IOException {
+
+ }
}
/**
@@ -554,7 +596,7 @@
private static final long serialVersionUID = 400L;
- ExistsType() {
+ public ExistsType() {
}
public boolean isAnd() {
@@ -598,6 +640,13 @@
public boolean isPatternScopeDelimiter() {
return true;
}
+ public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
+
+ }
+
+ public void writeExternal(ObjectOutput out) throws IOException {
+
+ }
}
}
\ No newline at end of file
Modified: labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/rule/ImportDeclaration.java
===================================================================
--- labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/rule/ImportDeclaration.java 2008-03-20 18:57:07 UTC (rev 19163)
+++ labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/rule/ImportDeclaration.java 2008-03-20 19:32:10 UTC (rev 19164)
@@ -1,12 +1,12 @@
/*
* Copyright 2007 JBoss Inc
- *
+ *
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -17,21 +17,24 @@
*/
package org.drools.rule;
-import java.io.Serializable;
+import java.io.Externalizable;
+import java.io.ObjectInput;
+import java.io.IOException;
+import java.io.ObjectOutput;
/**
* A class to represent an import declaration.
- *
+ *
* @author etirelli
*/
-public class ImportDeclaration implements Serializable {
+public class ImportDeclaration implements Externalizable {
private static final long serialVersionUID = 6410032114027977766L;
private String target;
/**
- * Creates an empty import declaration
+ * Creates an empty import declaration
*/
public ImportDeclaration() {
this( null );
@@ -39,14 +42,21 @@
/**
* Creates an import declaration for the given target.
- *
+ *
* @param target
*/
public ImportDeclaration( String target ) {
- super();
this.target = target;
}
-
+
+ public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
+ target = (String)in.readObject();
+ }
+
+ public void writeExternal(ObjectOutput out) throws IOException {
+ out.writeObject(target);
+ }
+
public String getTarget() {
return target;
}
@@ -76,7 +86,7 @@
/**
* Returns true if this ImportDeclaration correctly matches to
* the given clazz
- *
+ *
* @param name
* @return
*/
@@ -85,16 +95,16 @@
if( this.target.equals( clazz.getName() ) ) {
return true;
}
-
+
// wild card imports
if( this.target.endsWith( ".*" ) ) {
String prefix = this.target.substring( 0, this.target.indexOf( ".*" ) );
-
+
// package import: import my.package.*
if( prefix.equals( clazz.getPackage().getName() ) ) {
return true;
}
-
+
// inner class imports with wild card?
// by looking at the ClassTypeResolver class, it seems we do not support
// the usage of wild cards when importing static inner classes like the
Modified: labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/rule/JavaDialectData.java
===================================================================
--- labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/rule/JavaDialectData.java 2008-03-20 18:57:07 UTC (rev 19163)
+++ labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/rule/JavaDialectData.java 2008-03-20 19:32:10 UTC (rev 19164)
@@ -17,14 +17,11 @@
*/
import java.io.ByteArrayInputStream;
-import java.io.ByteArrayOutputStream;
import java.io.Externalizable;
import java.io.IOException;
import java.io.InputStream;
import java.io.ObjectInput;
import java.io.ObjectOutput;
-import java.io.ObjectOutputStream;
-import java.net.URL;
import java.security.AccessController;
import java.security.PrivilegedAction;
import java.security.ProtectionDomain;
@@ -35,10 +32,11 @@
import java.util.Map;
import java.util.Map.Entry;
-import org.drools.CheckedDroolsException;
import org.drools.RuntimeDroolsException;
import org.drools.base.accumulators.JavaAccumulatorFunctionExecutor;
import org.drools.common.DroolsObjectInputStream;
+import org.drools.common.DroolsObjectOutputStream;
+import org.drools.common.DroolsObjectInput;
import org.drools.spi.Accumulator;
import org.drools.spi.Consequence;
import org.drools.spi.EvalExpression;
@@ -66,7 +64,7 @@
private Object AST;
private Map store;
-
+
private DialectDatas datas;
private transient PackageClassLoader classLoader;
@@ -86,12 +84,11 @@
* will result in an invalid state for the instance.
*/
public JavaDialectData() {
-
}
public JavaDialectData(final DialectDatas datas) {
this.datas = datas;
- this.classLoader = new PackageClassLoader( this.datas.getParentClassLoader() );
+ this.classLoader = new PackageClassLoader( this.datas.getParentClassLoader(), this );
this.datas.addClassLoader( this.classLoader );
this.invokerLookups = new HashMap();
this.store = new HashMap();
@@ -107,16 +104,11 @@
* default methods. The PackageCompilationData holds a reference to the generated bytecode. The generated bytecode must be restored before any Rules.
*
*/
- public void writeExternal(final ObjectOutput stream) throws IOException {
+ public void writeExternal(ObjectOutput stream) throws IOException {
stream.writeObject( this.store );
stream.writeObject( this.AST );
-
- // Rules must be restored by an ObjectInputStream that can resolve using a given ClassLoader to handle seaprately by storing as
- // a byte[]
- final ByteArrayOutputStream bos = new ByteArrayOutputStream();
- final ObjectOutput out = new ObjectOutputStream( bos );
- out.writeObject( this.invokerLookups );
- stream.writeObject( bos.toByteArray() );
+ stream.writeObject( this.invokerLookups );
+ stream.writeBoolean( this.dirty );
}
/**
@@ -125,23 +117,18 @@
* A custom ObjectInputStream, able to resolve classes against the bytecode, is used to restore the Rules.
*
*/
- public void readExternal(final ObjectInput stream) throws IOException,
+ public void readExternal(ObjectInput stream) throws IOException,
ClassNotFoundException {
- DroolsObjectInputStream droolsStream = (DroolsObjectInputStream) stream;
- this.datas = droolsStream.getDialectDatas();
- this.classLoader = new PackageClassLoader( this.datas.getParentClassLoader() );
+ DroolsObjectInput droolsStream = (DroolsObjectInput)stream;
+
+ this.datas = droolsStream.getDialectDatas();
+ this.classLoader = new PackageClassLoader( this.datas.getParentClassLoader(), this );
this.datas.addClassLoader( this.classLoader );
-
+
this.store = (Map) stream.readObject();
this.AST = stream.readObject();
-
- // Return the rules stored as a byte[]
- final byte[] bytes = (byte[]) stream.readObject();
-
- // Use a custom ObjectInputStream that can resolve against a given classLoader
- final DroolsObjectInputStream streamWithLoader = new DroolsObjectInputStream( new ByteArrayInputStream( bytes ),
- this.classLoader );
- this.invokerLookups = (Map) streamWithLoader.readObject();
+ this.invokerLookups = (Map) droolsStream.readObject();
+ this.dirty = droolsStream.readBoolean();
}
public ClassLoader getClassLoader() {
@@ -212,7 +199,7 @@
public byte[] read(final String resourceName) {
byte[] bytes = null;
- if ( this.store != null ) {
+ if ( this.store != null && !this.store.isEmpty()) {
bytes = (byte[]) this.store.get( resourceName );
}
return bytes;
@@ -263,11 +250,11 @@
/**
* This class drops the classLoader and reloads it. During this process it must re-wire all the invokeables.
- * @throws CheckedDroolsException
+ * @throws RuntimeDroolsException
*/
public void reload() throws RuntimeDroolsException {
// drops the classLoader and adds a new one
- this.classLoader = new PackageClassLoader( this.datas.getParentClassLoader() );
+ this.classLoader = new PackageClassLoader( this.datas.getParentClassLoader(), this );
this.datas.addClassLoader( this.classLoader );
// Wire up invokers
@@ -310,23 +297,29 @@
InstantiationException,
IllegalAccessException {
final Class clazz = this.classLoader.findClass( className );
- if ( invoker instanceof ReturnValueRestriction ) {
- ((ReturnValueRestriction) invoker).setReturnValueExpression( (ReturnValueExpression) clazz.newInstance() );
- } else if ( invoker instanceof PredicateConstraint ) {
- ((PredicateConstraint) invoker).setPredicateExpression( (PredicateExpression) clazz.newInstance() );
- } else if ( invoker instanceof EvalCondition ) {
- ((EvalCondition) invoker).setEvalExpression( (EvalExpression) clazz.newInstance() );
- } else if ( invoker instanceof Accumulate ) {
- ((Accumulate) invoker).setAccumulator( (Accumulator) clazz.newInstance() );
- } else if ( invoker instanceof Rule ) {
- ((Rule) invoker).setConsequence( (Consequence) clazz.newInstance() );
- } else if ( invoker instanceof JavaAccumulatorFunctionExecutor ) {
- ((JavaAccumulatorFunctionExecutor) invoker).setExpression( (ReturnValueExpression) clazz.newInstance() );
- } else if ( invoker instanceof ActionNode ) {
- ((ActionNode) invoker).setAction( clazz.newInstance() );
- } else if ( invoker instanceof ReturnValueConstraintEvaluator ) {
- ((ReturnValueConstraintEvaluator) invoker).setEvaluator( (ReturnValueEvaluator) clazz.newInstance() );
+
+ if (clazz != null) {
+ if ( invoker instanceof ReturnValueRestriction ) {
+ ((ReturnValueRestriction) invoker).setReturnValueExpression( (ReturnValueExpression) clazz.newInstance() );
+ } else if ( invoker instanceof PredicateConstraint ) {
+ ((PredicateConstraint) invoker).setPredicateExpression( (PredicateExpression) clazz.newInstance() );
+ } else if ( invoker instanceof EvalCondition ) {
+ ((EvalCondition) invoker).setEvalExpression( (EvalExpression) clazz.newInstance() );
+ } else if ( invoker instanceof Accumulate ) {
+ ((Accumulate) invoker).setAccumulator( (Accumulator) clazz.newInstance() );
+ } else if ( invoker instanceof Rule ) {
+ ((Rule) invoker).setConsequence( (Consequence) clazz.newInstance() );
+ } else if ( invoker instanceof JavaAccumulatorFunctionExecutor ) {
+ ((JavaAccumulatorFunctionExecutor) invoker).setExpression( (ReturnValueExpression) clazz.newInstance() );
+ } else if ( invoker instanceof ActionNode ) {
+ ((ActionNode) invoker).setAction( clazz.newInstance() );
+ } else if ( invoker instanceof ReturnValueConstraintEvaluator ) {
+ ((ReturnValueConstraintEvaluator) invoker).setEvaluator( (ReturnValueEvaluator) clazz.newInstance() );
+ }
}
+ else {
+ throw new ClassNotFoundException(className);
+ }
}
public String toString() {
@@ -366,19 +359,24 @@
* @author mproctor
*
*/
- public class PackageClassLoader extends ClassLoader
+ public static class PackageClassLoader extends ClassLoader
implements
DroolsClassLoader {
+ private JavaDialectData parent;
- public PackageClassLoader(final ClassLoader parentClassLoader) {
+ public PackageClassLoader() {
+ }
+
+ public PackageClassLoader(final ClassLoader parentClassLoader, JavaDialectData parent) {
super( parentClassLoader );
+ this.parent = parent;
}
public Class fastFindClass(final String name) {
final Class clazz = findLoadedClass( name );
- if ( clazz == null ) {
- final byte[] clazzBytes = read( convertClassToResourcePath( name ) );
+ if ( clazz == null && parent != null) {
+ final byte[] clazzBytes = parent.read( convertClassToResourcePath( name ) );
if ( clazzBytes != null ) {
return defineClass( name,
clazzBytes,
@@ -406,12 +404,10 @@
final ClassLoader parent = getParent();
if ( parent != null ) {
clazz = parent.loadClass( name );
- } else {
- throw new ClassNotFoundException( name );
}
}
- if ( resolve ) {
+ if ( resolve && clazz != null) {
resolveClass( clazz );
}
@@ -419,16 +415,11 @@
}
protected Class findClass(final String name) throws ClassNotFoundException {
- final Class clazz = fastFindClass( name );
- if ( clazz == null ) {
- throw new ClassNotFoundException( name );
- }
- return clazz;
+ return fastFindClass( name );
}
-
public InputStream getResourceAsStream(final String name) {
- final byte[] bytes = (byte[]) JavaDialectData.this.store.get( name );
+ final byte[] bytes = (byte[]) parent.store.get( name );
if ( bytes != null ) {
return new ByteArrayInputStream( bytes );
} else {
Modified: labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/rule/LineMappings.java
===================================================================
--- labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/rule/LineMappings.java 2008-03-20 18:57:07 UTC (rev 19163)
+++ labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/rule/LineMappings.java 2008-03-20 19:32:10 UTC (rev 19164)
@@ -1,16 +1,35 @@
package org.drools.rule;
import java.io.Serializable;
+import java.io.Externalizable;
+import java.io.ObjectInput;
+import java.io.IOException;
+import java.io.ObjectOutput;
-public class LineMappings implements Serializable {
+public class LineMappings implements Externalizable {
private String className;
private int startLine;
private int offset;
+ public LineMappings() {
+ }
+
public LineMappings(final String className) {
this.className = className;
}
+ public void readExternal(ObjectInput stream) throws IOException, ClassNotFoundException {
+ className = (String)stream.readObject();
+ startLine = stream.readInt();
+ offset = stream.readInt();
+ }
+
+ public void writeExternal(ObjectOutput stream) throws IOException {
+ stream.writeObject(className);
+ stream.writeInt(startLine);
+ stream.writeInt(offset);
+ }
+
public String getClassName() {
return this.className;
}
Modified: labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/rule/LiteralConstraint.java
===================================================================
--- labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/rule/LiteralConstraint.java 2008-03-20 18:57:07 UTC (rev 19163)
+++ labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/rule/LiteralConstraint.java 2008-03-20 19:32:10 UTC (rev 19164)
@@ -2,13 +2,13 @@
/*
* Copyright 2005 JBoss Inc
- *
+ *
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -24,15 +24,23 @@
import org.drools.spi.FieldExtractor;
import org.drools.spi.FieldValue;
+import java.io.Externalizable;
+import java.io.ObjectOutput;
+import java.io.ObjectInput;
+import java.io.IOException;
+
public class LiteralConstraint
implements
- AlphaNodeFieldConstraint {
+ AlphaNodeFieldConstraint, Externalizable {
private static final long serialVersionUID = 400L;
- private final FieldExtractor extractor;
+ private FieldExtractor extractor;
+ private LiteralRestriction restriction;
- private final LiteralRestriction restriction;
+ public LiteralConstraint() {
+ this(null, null);
+ }
public LiteralConstraint(final FieldExtractor extractor,
final Evaluator evaluator,
@@ -49,6 +57,16 @@
this.restriction = restriction;
}
+ public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
+ extractor = (FieldExtractor)in.readObject();
+ restriction = (LiteralRestriction)in.readObject();
+ }
+
+ public void writeExternal(ObjectOutput out) throws IOException {
+ out.writeObject(extractor);
+ out.writeObject(restriction);
+ }
+
public Evaluator getEvaluator() {
return this.restriction.getEvaluator();
}
Modified: labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/rule/LiteralRestriction.java
===================================================================
--- labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/rule/LiteralRestriction.java 2008-03-20 18:57:07 UTC (rev 19163)
+++ labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/rule/LiteralRestriction.java 2008-03-20 19:32:10 UTC (rev 19164)
@@ -2,13 +2,13 @@
/*
* Copyright 2005 JBoss Inc
- *
+ *
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -25,20 +25,29 @@
import org.drools.spi.FieldValue;
import org.drools.spi.Restriction;
+import java.io.Externalizable;
+import java.io.IOException;
+import java.io.ObjectOutput;
+import java.io.ObjectInput;
+
public class LiteralRestriction
implements
- Restriction {
+ Restriction, Externalizable {
private static final long serialVersionUID = 400L;
- private final FieldValue field;
+ private FieldValue field;
- private final Evaluator evaluator;
+ private Evaluator evaluator;
- private final FieldExtractor extractor;
+ private FieldExtractor extractor;
private static final Declaration[] requiredDeclarations = new Declaration[0];
+ public LiteralRestriction() {
+ this(null, null, null);
+ }
+
public LiteralRestriction(final FieldValue field,
final Evaluator evaluator,
final FieldExtractor fieldExtractor) {
@@ -47,6 +56,17 @@
this.extractor = fieldExtractor;
}
+ public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
+ field = (FieldValue)in.readObject();
+ evaluator = (Evaluator)in.readObject();
+ extractor = (FieldExtractor)in.readObject();
+ }
+
+ public void writeExternal(ObjectOutput out) throws IOException {
+ out.writeObject(field);
+ out.writeObject(evaluator);
+ out.writeObject(extractor);
+ }
public Evaluator getEvaluator() {
return this.evaluator;
}
@@ -137,10 +157,25 @@
public Object object;
public ContextEntry next;
+ public LiteralContextEntry() {
+ }
+
public LiteralContextEntry(final FieldExtractor extractor) {
this.extractor = extractor;
}
+ public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
+ extractor = (FieldExtractor)in.readObject();
+ object = in.readObject();
+ next = (ContextEntry)in.readObject();
+ }
+
+ public void writeExternal(ObjectOutput out) throws IOException {
+ out.writeObject(extractor);
+ out.writeObject(object);
+ out.writeObject(next);
+ }
+
public FieldExtractor getFieldExtractor() {
return this.extractor;
}
Modified: labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/rule/MVELDialectData.java
===================================================================
--- labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/rule/MVELDialectData.java 2008-03-20 18:57:07 UTC (rev 19163)
+++ labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/rule/MVELDialectData.java 2008-03-20 19:32:10 UTC (rev 19164)
@@ -12,7 +12,7 @@
import org.mvel.integration.VariableResolver;
import org.mvel.integration.impl.MapVariableResolverFactory;
-public class MVELDialectData implements DialectData, Serializable {
+public class MVELDialectData implements DialectData, Externalizable {
private MapFunctionResolverFactory functionFactory;
/**
@@ -20,7 +20,7 @@
* user, as it will result in an invalid state for the instance.
*/
public MVELDialectData() {
-
+ this(null);
}
public MVELDialectData(final DialectDatas datas) {
@@ -53,39 +53,45 @@
public void reload() {
}
- public static class MapFunctionResolverFactory extends
- MapVariableResolverFactory implements Externalizable {
+ public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
+ }
- public MapFunctionResolverFactory() {
- super(new HashMap<String, Object>());
- }
+ public void writeExternal(ObjectOutput out) throws IOException {
+ }
- public void writeExternal(ObjectOutput out) throws IOException {
- out.writeObject( this.variables );
- }
-
- public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
- this.variables = ( Map ) in.readObject();
- }
+ public static class MapFunctionResolverFactory extends
+ MapVariableResolverFactory implements Externalizable {
- public void addFunction(Function function) {
- this.variables.put(function.getName(), function);
- }
+ public MapFunctionResolverFactory() {
+ super(new HashMap<String, Object>());
+ }
- public void removeFunction(String functionName) {
- this.variables.remove(functionName);
- this.variableResolvers.remove(functionName);
- }
+ public void writeExternal(ObjectOutput out) throws IOException {
+ out.writeObject( this.variables );
+ }
- public VariableResolver createVariable(String name, Object value) {
- throw new RuntimeException(
- "variable is a read-only function pointer");
- }
+ public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
+ this.variables = ( Map ) in.readObject();
+ }
- public VariableResolver createIndexedVariable(int index, String name,
- Object value, Class<?> type) {
- throw new RuntimeException(
- "variable is a read-only function pointer");
- }
- }
+ public void addFunction(Function function) {
+ this.variables.put(function.getName(), function);
+ }
+
+ public void removeFunction(String functionName) {
+ this.variables.remove(functionName);
+ this.variableResolvers.remove(functionName);
+ }
+
+ public VariableResolver createVariable(String name, Object value) {
+ throw new RuntimeException(
+ "variable is a read-only function pointer");
+ }
+
+ public VariableResolver createIndexedVariable(int index, String name,
+ Object value, Class<?> type) {
+ throw new RuntimeException(
+ "variable is a read-only function pointer");
+ }
+ }
}
Modified: labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/rule/MapBackedClassLoader.java
===================================================================
--- labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/rule/MapBackedClassLoader.java 2008-03-20 18:57:07 UTC (rev 19163)
+++ labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/rule/MapBackedClassLoader.java 2008-03-20 19:32:10 UTC (rev 19164)
@@ -3,16 +3,20 @@
import java.io.ByteArrayInputStream;
import java.io.InputStream;
import java.io.Serializable;
+import java.io.ObjectInput;
+import java.io.IOException;
+import java.io.ObjectOutput;
+import java.io.Externalizable;
import java.security.AccessController;
import java.security.PrivilegedAction;
import java.security.ProtectionDomain;
import java.util.HashMap;
import java.util.Map;
+import java.util.List;
public class MapBackedClassLoader extends ClassLoader
implements
- DroolsClassLoader,
- Serializable {
+ DroolsClassLoader {
private static final long serialVersionUID = 400L;
@@ -53,16 +57,21 @@
public void addClass(final String className,
byte[] bytes) {
-
- this.store.put( convertResourcePathToClassName( className ),
- bytes );
+ synchronized ( this.store ) {
+ this.store.put( convertResourcePathToClassName( className ),
+ bytes );
+ }
}
public Class fastFindClass(final String name) {
final Class clazz = findLoadedClass( name );
if ( clazz == null ) {
- final byte[] clazzBytes = (byte[]) this.store.get( name );
+ byte[] clazzBytes = null;
+ synchronized ( this.store ) {
+ clazzBytes = (byte[]) this.store.get( name );
+ }
+
if ( clazzBytes != null ) {
return defineClass( name,
clazzBytes,
@@ -89,8 +98,6 @@
final ClassLoader parent = getParent();
if ( parent != null ) {
clazz = parent.loadClass( name );
- } else {
- throw new ClassNotFoundException( name );
}
}
@@ -102,15 +109,15 @@
}
protected Class findClass(final String name) throws ClassNotFoundException {
- final Class clazz = fastFindClass( name );
- if ( clazz == null ) {
- throw new ClassNotFoundException( name );
- }
- return clazz;
+ return fastFindClass( name );
}
public InputStream getResourceAsStream(final String name) {
- final byte[] bytes = (byte[]) this.store.get( name );
+ byte[] bytes = null;
+ synchronized ( this.store ) {
+ bytes = (byte[]) this.store.get( name );
+ }
+
if ( bytes != null ) {
return new ByteArrayInputStream( bytes );
} else {
Modified: labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/rule/MultiRestrictionFieldConstraint.java
===================================================================
--- labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/rule/MultiRestrictionFieldConstraint.java 2008-03-20 18:57:07 UTC (rev 19163)
+++ labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/rule/MultiRestrictionFieldConstraint.java 2008-03-20 19:32:10 UTC (rev 19164)
@@ -6,20 +6,39 @@
import org.drools.spi.FieldExtractor;
import org.drools.spi.Restriction;
+import java.io.ObjectOutput;
+import java.io.ObjectInput;
+import java.io.IOException;
+
public class MultiRestrictionFieldConstraint extends MutableTypeConstraint {
private static final long serialVersionUID = 400L;
- private final FieldExtractor extractor;
+ private FieldExtractor extractor;
- private final Restriction restrictions;
+ private Restriction restrictions;
+ public MultiRestrictionFieldConstraint() {
+
+ }
+
public MultiRestrictionFieldConstraint(final FieldExtractor extractor,
final Restriction restrictions) {
this.extractor = extractor;
this.restrictions = restrictions;
}
+ public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
+ super.readExternal(in);
+ extractor = (FieldExtractor)in.readObject();
+ restrictions = (Restriction)in.readObject();
+ }
+
+ public void writeExternal(ObjectOutput out) throws IOException {
+ super.writeExternal(out);
+ out.writeObject(extractor);
+ out.writeObject(restrictions);
+ }
public FieldExtractor getFieldExtractor() {
return this.extractor;
}
Modified: labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/rule/MutableTypeConstraint.java
===================================================================
--- labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/rule/MutableTypeConstraint.java 2008-03-20 18:57:07 UTC (rev 19163)
+++ labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/rule/MutableTypeConstraint.java 2008-03-20 19:32:10 UTC (rev 19164)
@@ -1,12 +1,12 @@
/*
* Copyright 2008 JBoss Inc
- *
+ *
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -22,25 +22,38 @@
import org.drools.spi.BetaNodeFieldConstraint;
import org.drools.spi.Constraint;
+import java.io.Externalizable;
+import java.io.ObjectOutput;
+import java.io.ObjectInput;
+import java.io.IOException;
+
/**
* A base class for constraints
- *
+ *
* @author etirelli
*/
public abstract class MutableTypeConstraint
implements
AlphaNodeFieldConstraint,
- BetaNodeFieldConstraint {
+ BetaNodeFieldConstraint,
+ Externalizable {
private Constraint.ConstraintType type = Constraint.ConstraintType.UNKNOWN;
-
+
public void setType( ConstraintType type ) {
this.type = type;
}
-
+
public ConstraintType getType() {
return this.type;
}
+ public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
+ type = (Constraint.ConstraintType)in.readObject();
+ }
+
+ public void writeExternal(ObjectOutput out) throws IOException {
+ out.writeObject(type);
+ }
public abstract Object clone();
}
Modified: labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/rule/OrCompositeRestriction.java
===================================================================
--- labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/rule/OrCompositeRestriction.java 2008-03-20 18:57:07 UTC (rev 19163)
+++ labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/rule/OrCompositeRestriction.java 2008-03-20 19:32:10 UTC (rev 19164)
@@ -10,6 +10,9 @@
private static final long serialVersionUID = 400L;
+ public OrCompositeRestriction() {
+ }
+
public OrCompositeRestriction(final Restriction[] restriction) {
super( restriction );
}
Modified: labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/rule/Package.java
===================================================================
--- labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/rule/Package.java 2008-03-20 18:57:07 UTC (rev 19163)
+++ labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/rule/Package.java 2008-03-20 19:32:10 UTC (rev 19164)
@@ -22,7 +22,6 @@
import java.io.IOException;
import java.io.ObjectInput;
import java.io.ObjectOutput;
-import java.io.ObjectOutputStream;
import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
@@ -30,7 +29,9 @@
import java.util.Map;
import java.util.Set;
+import org.drools.common.DroolsObjectInput;
import org.drools.common.DroolsObjectInputStream;
+import org.drools.common.DroolsObjectOutputStream;
import org.drools.facttemplates.FactTemplate;
import org.drools.process.core.Process;
@@ -143,56 +144,70 @@
/**
* Handles the write serialization of the Package. Patterns in Rules may reference generated data which cannot be serialized by default methods.
* The Package uses PackageCompilationData to hold a reference to the generated bytecode. The generated bytecode must be restored before any Rules.
+ * @param stream out the stream to write the object to; should be an instance of DroolsObjectOutputStream or OutputStream
*
*/
- public void writeExternal(final ObjectOutput stream) throws IOException {
- stream.writeObject( this.dialectDatas );
- stream.writeObject( this.name );
- stream.writeObject( this.imports );
- stream.writeObject( this.staticImports );
- stream.writeObject( this.typeDeclarations );
- stream.writeObject( this.functions );
- stream.writeObject( this.factTemplates );
- stream.writeObject( this.ruleFlows );
- stream.writeObject( this.globals );
- stream.writeBoolean( this.valid );
+ public void writeExternal(ObjectOutput stream) throws IOException {
+ boolean isDroolsStream = stream instanceof DroolsObjectOutputStream;
+ ByteArrayOutputStream bytes = null;
+ ObjectOutput out;
- // Rules must be restored by an ObjectInputStream that can resolve using a given ClassLoader to handle seaprately by storing as
- // a byte[]
- final ByteArrayOutputStream bos = new ByteArrayOutputStream();
- final ObjectOutput out = new ObjectOutputStream( bos );
+ if (isDroolsStream) {
+ out = stream;
+ }
+ else {
+ bytes = new ByteArrayOutputStream();
+ out = new DroolsObjectOutputStream(bytes);
+ }
+ out.writeObject( this.dialectDatas );
+ out.writeObject( this.typeDeclarations );
+ out.writeObject( this.name );
+ out.writeObject( this.imports );
+ out.writeObject( this.staticImports );
+ out.writeObject( this.functions );
+ out.writeObject( this.factTemplates );
+ out.writeObject( this.ruleFlows );
+ out.writeObject( this.globals );
+ out.writeBoolean( this.valid );
out.writeObject( this.rules );
- stream.writeObject( bos.toByteArray() );
+ // writing the whole stream as a byte array
+ if (!isDroolsStream) {
+ bytes.flush();
+ bytes.close();
+ stream.writeObject(bytes.toByteArray());
+ }
}
/**
* Handles the read serialization of the Package. Patterns in Rules may reference generated data which cannot be serialized by default methods.
* The Package uses PackageCompilationData to hold a reference to the generated bytecode; which must be restored before any Rules.
* A custom ObjectInputStream, able to resolve classes against the bytecode in the PackageCompilationData, is used to restore the Rules.
+ * @param stream, the stream to read data from in order to restore the object; should be an instance of
+ * DroolsObjectInputStream or InputStream
*
*/
- public void readExternal(final ObjectInput stream) throws IOException,
+ public void readExternal(ObjectInput stream) throws IOException,
ClassNotFoundException {
- // PackageCompilationData must be restored before Rules as it has the ClassLoader needed to resolve the generated code references in Rules
- this.dialectDatas = (DialectDatas) stream.readObject();
- this.name = (String) stream.readObject();
- this.imports = (Map<String, ImportDeclaration>) stream.readObject();
- this.staticImports = (Set) stream.readObject();
- this.typeDeclarations = (Map<String, TypeDeclaration>) stream.readObject();
- this.functions = (Map) stream.readObject();
- this.factTemplates = (Map) stream.readObject();
- this.ruleFlows = (Map) stream.readObject();
- this.globals = (Map) stream.readObject();
- this.valid = stream.readBoolean();
+ boolean isDroolsStream = stream instanceof DroolsObjectInputStream;
+ ObjectInput in = isDroolsStream
+ ? stream
+ : new DroolsObjectInputStream(new ByteArrayInputStream((byte[])stream.readObject()));
- // Return the rules stored as a byte[]
- final byte[] bytes = (byte[]) stream.readObject();
+ this.dialectDatas = (DialectDatas)in.readObject();
+ this.typeDeclarations = (Map)in.readObject();
+ this.name = (String) in.readObject();
+ this.imports = (Map<String, ImportDeclaration>) in.readObject();
+ this.staticImports = (Set) in.readObject();
+ this.functions = (Map<String, Function>) in.readObject();
+ this.factTemplates = (Map) in.readObject();
+ this.ruleFlows = (Map) in.readObject();
+ this.globals = (Map) in.readObject();
+ this.valid = in.readBoolean();
+ this.rules = (Map) in.readObject();
- // Use a custom ObjectInputStream that can resolve against a given classLoader
- final DroolsObjectInputStream streamWithLoader = new DroolsObjectInputStream( new ByteArrayInputStream( bytes ),
- this.dialectDatas.getClassLoader() );
-
- this.rules = (Map) streamWithLoader.readObject();
+ if (!isDroolsStream) {
+ in.close();
+ }
}
// ------------------------------------------------------------
@@ -360,7 +375,7 @@
this.dialectDatas.removeRule( this,
rule );
// final String consequenceName = rule.getConsequence().getClass().getName();
- //
+ //
// Object object = this.dialectData.getDialectData( rule.getDialect() );
//
// // check for compiled code and remove if present.
@@ -478,9 +493,9 @@
}
/**
- * Returns true if clazz is imported as an Event class in this package
+ * Returns true if clazz is imported as an Event class in this package
* @param clazz
- * @return
+ * @return true if clazz is imported as an Event class in this package
*/
public boolean isEvent(Class clazz) {
if ( clazz == null ) {
Modified: labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/rule/Pattern.java
===================================================================
--- labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/rule/Pattern.java 2008-03-20 18:57:07 UTC (rev 19163)
+++ labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/rule/Pattern.java 2008-03-20 19:32:10 UTC (rev 19164)
@@ -2,13 +2,13 @@
/*
* Copyright 2005 JBoss Inc
- *
+ *
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -22,6 +22,10 @@
import java.util.Iterator;
import java.util.List;
import java.util.Map;
+import java.io.Externalizable;
+import java.io.ObjectOutput;
+import java.io.ObjectInput;
+import java.io.IOException;
import org.drools.spi.Constraint;
import org.drools.spi.Extractor;
@@ -31,22 +35,26 @@
public class Pattern
implements
- RuleConditionElement {
+ RuleConditionElement, Externalizable {
/**
- *
+ *
*/
private static final long serialVersionUID = 400L;
- private final ObjectType objectType;
- private List constraints = Collections.EMPTY_LIST;
- final Declaration declaration;
+ private ObjectType objectType;
+ private List constraints = Collections.EMPTY_LIST;
+ Declaration declaration;
private Map declarations;
- private final int index;
+ private int index;
private PatternSource source;
// this is the offset of the related fact inside a tuple. i.e:
- // the position of the related fact inside the tuple;
+ // the position of the related fact inside the tuple;
private int offset;
+ public Pattern() {
+ this(0, null);
+ }
+
public Pattern(final int index,
final ObjectType objectType) {
this( index,
@@ -96,6 +104,26 @@
}
}
+ public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
+ objectType = (ObjectType)in.readObject();
+ constraints = (List)in.readObject();
+ declaration = (Declaration)in.readObject();
+ declarations = (Map)in.readObject();
+ index = in.readInt();
+ source = (PatternSource)in.readObject();
+ offset = in.readInt();
+ }
+
+ public void writeExternal(ObjectOutput out) throws IOException {
+ out.writeObject(objectType);
+ out.writeObject(constraints);
+ out.writeObject(declaration);
+ out.writeObject(declarations);
+ out.writeInt(index);
+ out.writeObject(source);
+ out.writeInt(offset);
+ }
+
public Object clone() {
final String identifier = (this.declaration != null) ? this.declaration.getIdentifier() : null;
final Pattern clone = new Pattern( this.index,
@@ -194,9 +222,9 @@
}
/**
- * The offset of the fact related to this pattern
+ * The offset of the fact related to this pattern
* inside the tuple
- *
+ *
* @return the offset
*/
public int getOffset() {
@@ -275,7 +303,7 @@
public List getNestedElements() {
return this.source != null ? Collections.singletonList( this.source ) : Collections.EMPTY_LIST;
}
-
+
public boolean isPatternScopeDelimiter() {
return true;
}
@@ -293,7 +321,7 @@
}
}
- ConstraintType type = isAlphaConstraint ? ConstraintType.ALPHA : ConstraintType.BETA;
+ ConstraintType type = isAlphaConstraint ? ConstraintType.ALPHA : ConstraintType.BETA;
constraint.setType( type );
}
}
\ No newline at end of file
Modified: labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/rule/PredicateConstraint.java
===================================================================
--- labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/rule/PredicateConstraint.java 2008-03-20 18:57:07 UTC (rev 19163)
+++ labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/rule/PredicateConstraint.java 2008-03-20 19:32:10 UTC (rev 19164)
@@ -2,13 +2,13 @@
/*
* Copyright 2005 JBoss Inc
- *
+ *
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -17,6 +17,10 @@
*/
import java.util.Arrays;
+import java.io.Externalizable;
+import java.io.ObjectInput;
+import java.io.ObjectOutput;
+import java.io.IOException;
import org.drools.RuntimeDroolsException;
import org.drools.common.InternalFactHandle;
@@ -28,33 +32,37 @@
/**
* A predicate can be written as a top level constraint or be nested
- * inside inside a field constraint (and as so, must implement the
+ * inside inside a field constraint (and as so, must implement the
* Restriction interface).
- *
+ *
* @author etirelli
*/
public class PredicateConstraint extends MutableTypeConstraint
implements
- Restriction {
+ Restriction, Externalizable {
/**
- *
+ *
*/
private static final long serialVersionUID = 400L;
private PredicateExpression expression;
- private final Declaration[] requiredDeclarations;
+ private Declaration[] requiredDeclarations;
- private final Declaration[] previousDeclarations;
+ private Declaration[] previousDeclarations;
- private final Declaration[] localDeclarations;
+ private Declaration[] localDeclarations;
- private final String[] requiredGlobals;
+ private String[] requiredGlobals;
private static final Declaration[] EMPTY_DECLARATIONS = new Declaration[0];
private static final String[] EMPTY_GLOBALS = new String[0];
+ public PredicateConstraint() {
+ this(null);
+ }
+
public PredicateConstraint(final PredicateExpression evaluator) {
this( evaluator,
null,
@@ -108,6 +116,23 @@
this.localDeclarations.length );
}
+ public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
+ super.readExternal(in);
+ expression = (PredicateExpression)in.readObject();
+ requiredDeclarations = (Declaration[])in.readObject();
+ previousDeclarations = (Declaration[])in.readObject();
+ localDeclarations = (Declaration[])in.readObject();
+ requiredGlobals = (String[])in.readObject();
+ }
+ public void writeExternal(ObjectOutput out) throws IOException {
+ super.writeExternal(out);
+ out.writeObject(expression);
+ out.writeObject(requiredDeclarations);
+ out.writeObject(previousDeclarations);
+ out.writeObject(localDeclarations);
+ out.writeObject(requiredGlobals);
+ }
+
public Declaration[] getRequiredDeclarations() {
return this.requiredDeclarations;
}
@@ -230,7 +255,7 @@
public boolean isAllowed(Extractor extractor,
InternalFactHandle handle,
- InternalWorkingMemory workingMemory,
+ InternalWorkingMemory workingMemory,
ContextEntry context ) {
throw new UnsupportedOperationException("Method not supported. Please contact development team.");
}
@@ -293,7 +318,7 @@
public ReteTuple leftTuple;
public Object rightObject;
public InternalWorkingMemory workingMemory;
-
+
public Object dialectContext;
private ContextEntry entry;
@@ -301,6 +326,22 @@
public PredicateContextEntry() {
}
+ public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
+ leftTuple = (ReteTuple)in.readObject();
+ rightObject = in.readObject();
+ workingMemory = (InternalWorkingMemory)in.readObject();
+ dialectContext = in.readObject();
+ entry = (ContextEntry)in.readObject();
+ }
+
+ public void writeExternal(ObjectOutput out) throws IOException {
+ out.writeObject(leftTuple);
+ out.writeObject(rightObject);
+ out.writeObject(workingMemory);
+ out.writeObject(dialectContext);
+ out.writeObject(entry);
+ }
+
public ContextEntry getNext() {
return this.entry;
}
@@ -320,14 +361,14 @@
this.workingMemory = workingMemory;
this.leftTuple = tuple;
}
-
+
public void resetTuple() {
this.leftTuple = null;
}
-
+
public void resetFactHandle() {
this.rightObject = null;
- }
+ }
}
}
\ No newline at end of file
Modified: labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/rule/Query.java
===================================================================
--- labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/rule/Query.java 2008-03-20 18:57:07 UTC (rev 19163)
+++ labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/rule/Query.java 2008-03-20 19:32:10 UTC (rev 19164)
@@ -2,13 +2,13 @@
/*
* Copyright 2005 JBoss Inc
- *
+ *
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -16,18 +16,22 @@
* limitations under the License.
*/
-public class Query extends Rule {
+public class Query extends Rule {
/**
- *
+ *
*/
private static final long serialVersionUID = 400L;
+ public Query() {
+
+ }
+
public Query(final String name) {
super( name );
- }
+ }
- /**
+ /**
* Override this as Queries will NEVER have a consequence, and it should
* not be taken into account when deciding if it is valid.
*/
Modified: labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/rule/ReturnValueConstraint.java
===================================================================
--- labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/rule/ReturnValueConstraint.java 2008-03-20 18:57:07 UTC (rev 19163)
+++ labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/rule/ReturnValueConstraint.java 2008-03-20 19:32:10 UTC (rev 19164)
@@ -2,13 +2,13 @@
/*
* Copyright 2005 JBoss Inc
- *
+ *
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -25,19 +25,39 @@
import org.drools.spi.FieldExtractor;
import org.drools.spi.ReturnValueExpression;
-public class ReturnValueConstraint extends MutableTypeConstraint {
+import java.io.Externalizable;
+import java.io.ObjectOutput;
+import java.io.IOException;
+import java.io.ObjectInput;
+public class ReturnValueConstraint extends MutableTypeConstraint implements Externalizable {
+
private static final long serialVersionUID = 400L;
- private final FieldExtractor fieldExtractor;
- private final ReturnValueRestriction restriction;
+ private FieldExtractor fieldExtractor;
+ private ReturnValueRestriction restriction;
+ public ReturnValueConstraint() {
+ this(null, null);
+ }
public ReturnValueConstraint(final FieldExtractor fieldExtractor,
final ReturnValueRestriction restriction) {
this.fieldExtractor = fieldExtractor;
this.restriction = restriction;
}
+ public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
+ super.readExternal(in);
+ fieldExtractor = (FieldExtractor)in.readObject();
+ restriction = (ReturnValueRestriction)in.readObject();
+ }
+
+ public void writeExternal(ObjectOutput out) throws IOException {
+ super.writeExternal(out);
+ out.writeObject(fieldExtractor);
+ out.writeObject(restriction);
+ }
+
public Declaration[] getRequiredDeclarations() {
return this.restriction.getRequiredDeclarations();
}
@@ -47,7 +67,7 @@
this.restriction.replaceDeclaration( oldDecl,
newDecl );
}
-
+
public void setReturnValueExpression(final ReturnValueExpression expression) {
this.restriction.setReturnValueExpression( expression );
}
@@ -134,7 +154,7 @@
e );
}
}
-
+
public Object clone() {
return new ReturnValueConstraint( this.fieldExtractor, (ReturnValueRestriction) this.restriction.clone() );
}
Modified: labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/rule/ReturnValueRestriction.java
===================================================================
--- labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/rule/ReturnValueRestriction.java 2008-03-20 18:57:07 UTC (rev 19163)
+++ labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/rule/ReturnValueRestriction.java 2008-03-20 19:32:10 UTC (rev 19164)
@@ -2,13 +2,13 @@
/*
* Copyright 2005 JBoss Inc
- *
+ *
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -17,6 +17,10 @@
*/
import java.util.Arrays;
+import java.io.Externalizable;
+import java.io.ObjectInput;
+import java.io.ObjectOutput;
+import java.io.IOException;
import org.drools.RuntimeDroolsException;
import org.drools.WorkingMemory;
@@ -38,22 +42,26 @@
private ReturnValueExpression expression;
- private final Declaration[] requiredDeclarations;
+ private Declaration[] requiredDeclarations;
- private final String[] requiredGlobals;
+ private String[] requiredGlobals;
- private final Declaration[] previousDeclarations;
+ private Declaration[] previousDeclarations;
- private final Declaration[] localDeclarations;
+ private Declaration[] localDeclarations;
- private final Evaluator evaluator;
+ private Evaluator evaluator;
- private final FieldExtractor extractor;
+ private FieldExtractor extractor;
private static final Declaration[] noRequiredDeclarations = new Declaration[]{};
private static final String[] noRequiredGlobals = new String[]{};
+ public ReturnValueRestriction() {
+
+ }
+
public ReturnValueRestriction(final FieldExtractor fieldExtractor,
final Declaration[] previousDeclarations,
final Declaration[] localDeclarations,
@@ -109,6 +117,24 @@
this.localDeclarations.length );
}
+ public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
+ expression = (ReturnValueExpression)in.readObject();
+ requiredDeclarations = (Declaration[])in.readObject();
+ previousDeclarations = (Declaration[])in.readObject();
+ localDeclarations = ( Declaration[])in.readObject();
+ evaluator = (Evaluator)in.readObject();
+ extractor = (FieldExtractor)in.readObject();
+ }
+
+ public void writeExternal(ObjectOutput out) throws IOException {
+ out.writeObject(expression);
+ out.writeObject(requiredDeclarations);
+ out.writeObject(previousDeclarations);
+ out.writeObject(localDeclarations);
+ out.writeObject(evaluator);
+ out.writeObject(extractor);
+ }
+
public Declaration[] getRequiredDeclarations() {
return this.requiredDeclarations;
}
@@ -300,6 +326,9 @@
public Object dialectContext;
+ public ReturnValueContextEntry() {
+ }
+
public ReturnValueContextEntry(final FieldExtractor fieldExtractor,
final Declaration[] previousDeclarations,
final Declaration[] localDeclarations) {
@@ -308,6 +337,28 @@
this.localDeclarations = localDeclarations;
}
+ public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
+ fieldExtractor = (FieldExtractor)in.readObject();
+ handle = (InternalFactHandle)in.readObject();
+ leftTuple = (ReteTuple)in.readObject();
+ workingMemory = (InternalWorkingMemory)in.readObject();
+ previousDeclarations = (Declaration[])in.readObject();
+ localDeclarations = (Declaration[])in.readObject();
+ entry = (ContextEntry)in.readObject();
+ dialectContext = in.readObject();
+ }
+
+ public void writeExternal(ObjectOutput out) throws IOException {
+ out.writeObject(fieldExtractor);
+ out.writeObject(handle);
+ out.writeObject(leftTuple);
+ out.writeObject(workingMemory);
+ out.writeObject(previousDeclarations);
+ out.writeObject(localDeclarations);
+ out.writeObject(entry);
+ out.writeObject(dialectContext);
+ }
+
public ContextEntry getNext() {
return this.entry;
}
Modified: labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/rule/Rule.java
===================================================================
--- labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/rule/Rule.java 2008-03-20 18:57:07 UTC (rev 19163)
+++ labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/rule/Rule.java 2008-03-20 19:32:10 UTC (rev 19164)
@@ -17,6 +17,10 @@
*/
import java.io.Serializable;
+import java.io.Externalizable;
+import java.io.ObjectOutput;
+import java.io.IOException;
+import java.io.ObjectInput;
import java.util.Calendar;
import java.util.Iterator;
import java.util.Map;
@@ -41,7 +45,7 @@
*/
public class Rule
implements
- Serializable,
+ Externalizable,
Dialectable {
/**
*
@@ -56,7 +60,7 @@
private String pkg;
/** Name of the rule. */
- private final String name;
+ private String name;
/** Salience value. */
private Salience salience;
@@ -104,10 +108,61 @@
private boolean enabled;
+ public void writeExternal(ObjectOutput out) throws IOException {
+ out.writeObject(pkg);
+ out.writeObject(name);
+ out.writeObject(salience);
+ out.writeBoolean(dirty);
+ out.writeObject(declarations);
+ out.writeObject(declarationArray);
+ out.writeObject(lhsRoot);
+ out.writeObject(dialect);
+ out.writeObject(agendaGroup);
+ out.writeObject(consequence);
+ out.writeObject(duration);
+ out.writeLong(loadOrder);
+ out.writeBoolean(noLoop);
+ out.writeBoolean(autoFocus);
+ out.writeObject(activationGroup);
+ out.writeObject(ruleFlowGroup);
+ out.writeBoolean(lockOnActive);
+ out.writeBoolean(hasLogicalDependency);
+ out.writeBoolean(semanticallyValid);
+ out.writeObject(dateEffective);
+ out.writeObject(dateExpires);
+ out.writeBoolean(enabled);
+ }
+ public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
+ pkg = (String)in.readObject();
+ name = (String)in.readObject();
+ salience = (Salience)in.readObject();
+ dirty = in.readBoolean();
+ declarations = (Map)in.readObject();
+ declarationArray = (Declaration[])in.readObject();
+ lhsRoot = (GroupElement)in.readObject();
+ dialect = (String)in.readObject();
+ agendaGroup = (String)in.readObject();
+ consequence = (Consequence)in.readObject();
+ duration = (Duration)in.readObject();
+ loadOrder = in.readLong();
+ noLoop = in.readBoolean();
+ autoFocus = in.readBoolean();
+ activationGroup = (String)in.readObject();
+ ruleFlowGroup = (String)in.readObject();
+ lockOnActive = in.readBoolean();
+ hasLogicalDependency = in.readBoolean();
+ semanticallyValid = in.readBoolean();
+ dateEffective = (Calendar)in.readObject();
+ dateExpires = (Calendar)in.readObject();
+ enabled = in.readBoolean();
+ }
// ------------------------------------------------------------
// Constructors
// ------------------------------------------------------------
+ public Rule() {
+ }
+
/**
* Construct a
* <code>Rule<code> with the given name for the specified pkg parent
Modified: labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/rule/TimeMachine.java
===================================================================
--- labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/rule/TimeMachine.java 2008-03-20 18:57:07 UTC (rev 19163)
+++ labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/rule/TimeMachine.java 2008-03-20 19:32:10 UTC (rev 19164)
@@ -1,6 +1,10 @@
package org.drools.rule;
import java.io.Serializable;
+import java.io.Externalizable;
+import java.io.IOException;
+import java.io.ObjectOutput;
+import java.io.ObjectInput;
import java.util.Calendar;
/**
@@ -9,10 +13,16 @@
*
* @author Michael Neale
*/
-public class TimeMachine implements Serializable {
+public class TimeMachine implements Externalizable {
private static final long serialVersionUID = 400L;
+ public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
+ }
+
+ public void writeExternal(ObjectOutput out) throws IOException {
+ }
+
public Calendar getNow() {
return Calendar.getInstance();
}
Modified: labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/rule/TypeDeclaration.java
===================================================================
--- labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/rule/TypeDeclaration.java 2008-03-20 18:57:07 UTC (rev 19163)
+++ labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/rule/TypeDeclaration.java 2008-03-20 19:32:10 UTC (rev 19164)
@@ -20,18 +20,24 @@
import org.drools.facttemplates.FactTemplate;
+import java.io.Serializable;
+import java.io.Externalizable;
+import java.io.ObjectInput;
+import java.io.IOException;
+import java.io.ObjectOutput;
+
/**
* The type declaration class stores all type's metadata
* declared in source files.
*
* @author etirelli
*/
-public class TypeDeclaration {
-
+public class TypeDeclaration implements Externalizable {
+
public static enum Role {
FACT,
EVENT;
-
+
public static Role parseRole( String role ) {
if( "event".equalsIgnoreCase( role ) ) {
return EVENT;
@@ -41,9 +47,9 @@
return null;
}
}
-
+
public static enum Format {
- POJO,
+ POJO,
TEMPLATE;
public static Format parseFormat( String format ) {
@@ -55,14 +61,14 @@
return null;
}
}
-
+
public static enum ClockStrategy {
NONE,
- PSEUDO,
- SYSTEM,
- HEARTBEAT,
+ PSEUDO,
+ SYSTEM,
+ HEARTBEAT,
ATTRIBUTE;
-
+
public static ClockStrategy parseClockStrategy( String clockStrategy ) {
if( "none".equalsIgnoreCase( clockStrategy ) ) {
return NONE;
@@ -79,7 +85,7 @@
}
}
- private final String typeName;
+ private String typeName;
private Role role;
private Format format;
private ClockStrategy clockStrategy;
@@ -87,7 +93,10 @@
private String durationAttribute;
private Class<?> typeClass;
private FactTemplate typeTemplate;
-
+
+ public TypeDeclaration() {
+ }
+
public TypeDeclaration( String typeName ) {
this.typeName = typeName;
this.role = Role.FACT;
@@ -98,7 +107,29 @@
this.typeClass = null;
this.typeTemplate = null;
}
-
+
+ public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
+ this.typeName = (String)in.readObject();
+ this.role = (Role)in.readObject();
+ this.format = (Format)in.readObject();
+ this.clockStrategy = (ClockStrategy)in.readObject();
+ this.durationAttribute = (String)in.readObject();
+ this.timestampAttribute = (String)in.readObject();
+ this.typeClass = (Class<?>)in.readObject();
+ this.typeTemplate = (FactTemplate)in.readObject();
+ }
+
+ public void writeExternal(ObjectOutput out) throws IOException {
+ out.writeObject(typeName);
+ out.writeObject(role);
+ out.writeObject(format);
+ out.writeObject(clockStrategy);
+ out.writeObject(durationAttribute);
+ out.writeObject(timestampAttribute);
+ out.writeObject(typeClass);
+ out.writeObject(typeTemplate);
+ }
+
/**
* @return the type
*/
@@ -203,7 +234,7 @@
public void setTypeTemplate(FactTemplate typeTemplate) {
this.typeTemplate = typeTemplate;
}
-
+
/**
* Returns true if the given parameter matches this type declaration
*
@@ -219,6 +250,27 @@
}
return matches;
}
-
-
+
+ public boolean equals(Object obj) {
+ if (obj == this) {
+ return true;
+ } else if (obj instanceof TypeDeclaration) {
+ TypeDeclaration that = (TypeDeclaration)obj;
+ return isObjectEqual(typeName, that.typeName) &&
+ role == that.role &&
+ format == that.format &&
+ clockStrategy == that.clockStrategy &&
+ isObjectEqual(timestampAttribute, that.timestampAttribute) &&
+ isObjectEqual(durationAttribute, that.durationAttribute) &&
+ typeClass == that.typeClass &&
+ isObjectEqual(typeTemplate, that.typeTemplate);
+ }
+ return false;
+ }
+
+
+ private static boolean isObjectEqual(Object a, Object b) {
+ return a == b || a != null && a.equals(b);
+ }
+
}
Modified: labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/rule/VariableConstraint.java
===================================================================
--- labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/rule/VariableConstraint.java 2008-03-20 18:57:07 UTC (rev 19163)
+++ labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/rule/VariableConstraint.java 2008-03-20 19:32:10 UTC (rev 19164)
@@ -2,13 +2,13 @@
/*
* Copyright 2005 JBoss Inc
- *
+ *
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -22,13 +22,21 @@
import org.drools.spi.Evaluator;
import org.drools.spi.FieldExtractor;
-public class VariableConstraint extends MutableTypeConstraint {
+import java.io.IOException;
+import java.io.ObjectInput;
+import java.io.ObjectOutput;
+import java.io.Externalizable;
+public class VariableConstraint extends MutableTypeConstraint implements Externalizable {
+
private static final long serialVersionUID = 400L;
- private final FieldExtractor fieldExtractor;
- private final VariableRestriction restriction;
+ private FieldExtractor fieldExtractor;
+ private VariableRestriction restriction;
+ public VariableConstraint() {
+ }
+
public VariableConstraint(final FieldExtractor fieldExtractor,
final Declaration declaration,
final Evaluator evaluator) {
@@ -44,6 +52,17 @@
this.restriction = restriction;
}
+ public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
+ super.readExternal(in);
+ fieldExtractor = (FieldExtractor)in.readObject();
+ restriction = (VariableRestriction)in.readObject();
+ }
+
+ public void writeExternal(ObjectOutput out) throws IOException {
+ super.writeExternal(out);
+ out.writeObject(fieldExtractor);
+ out.writeObject(restriction);
+ }
public Declaration[] getRequiredDeclarations() {
return this.restriction.getRequiredDeclarations();
}
Modified: labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/rule/VariableRestriction.java
===================================================================
--- labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/rule/VariableRestriction.java 2008-03-20 18:57:07 UTC (rev 19163)
+++ labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/rule/VariableRestriction.java 2008-03-20 19:32:10 UTC (rev 19164)
@@ -2,13 +2,13 @@
/*
* Copyright 2005 JBoss Inc
- *
+ *
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -17,6 +17,10 @@
*/
import java.util.Arrays;
+import java.io.Externalizable;
+import java.io.ObjectOutput;
+import java.io.IOException;
+import java.io.ObjectInput;
import org.drools.base.ValueType;
import org.drools.common.InternalFactHandle;
@@ -35,12 +39,15 @@
private Declaration declaration;
- private final Declaration[] requiredDeclarations;
+ private Declaration[] requiredDeclarations;
- private final Evaluator evaluator;
+ private Evaluator evaluator;
- private final FieldExtractor extractor;
+ private FieldExtractor extractor;
+ public VariableRestriction() {
+ }
+
public VariableRestriction(final FieldExtractor fieldExtractor,
final Declaration declaration,
final Evaluator evaluator) {
@@ -50,6 +57,20 @@
this.extractor = fieldExtractor;
}
+ public void writeExternal(ObjectOutput out) throws IOException {
+ out.writeObject(declaration);
+ out.writeObject(requiredDeclarations);
+ out.writeObject(evaluator);
+ out.writeObject(extractor);
+ }
+
+ public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
+ declaration = (Declaration) in.readObject();
+ requiredDeclarations = (Declaration[]) in.readObject();
+ evaluator = (Evaluator) in.readObject();
+ extractor = (FieldExtractor) in.readObject();
+ }
+
public Declaration[] getRequiredDeclarations() {
return this.requiredDeclarations;
}
@@ -173,6 +194,9 @@
public boolean rightNull;
public InternalWorkingMemory workingMemory;
+ public VariableContextEntry() {
+ }
+
public VariableContextEntry(final FieldExtractor extractor,
final Declaration declaration,
final Evaluator evaluator) {
@@ -181,6 +205,30 @@
this.evaluator = evaluator;
}
+ public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
+ workingMemory = (InternalWorkingMemory)in.readObject();
+ extractor = (FieldExtractor)in.readObject();
+ evaluator = (Evaluator)in.readObject();
+ object = in.readObject();
+ declaration = (Declaration)in.readObject();
+ reteTuple = (ReteTuple)in.readObject();
+ entry = (ContextEntry)in.readObject();
+ leftNull = in.readBoolean();
+ rightNull = in.readBoolean();
+ }
+
+ public void writeExternal(ObjectOutput out) throws IOException {
+ out.writeObject(workingMemory);
+ out.writeObject(extractor);
+ out.writeObject(evaluator);
+ out.writeObject(object);
+ out.writeObject(declaration);
+ out.writeObject(reteTuple);
+ out.writeObject(entry);
+ out.writeBoolean(leftNull);
+ out.writeBoolean(rightNull);
+ }
+
public ContextEntry getNext() {
return this.entry;
}
@@ -228,6 +276,9 @@
public Object left;
public Object right;
+ public ObjectVariableContextEntry() {
+ }
+
public ObjectVariableContextEntry(final FieldExtractor extractor,
final Declaration declaration,
final Evaluator evaluator) {
@@ -236,6 +287,18 @@
evaluator );
}
+ public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
+ super.readExternal(in);
+ left = in.readObject();
+ right = in.readObject();
+ }
+
+ public void writeExternal(ObjectOutput out) throws IOException {
+ super.writeExternal(out);
+ out.writeObject(left);
+ out.writeObject(right);
+ }
+
public void updateFromTuple(final InternalWorkingMemory workingMemory,
final ReteTuple tuple) {
this.reteTuple = tuple;
@@ -274,6 +337,9 @@
public long left;
public long right;
+ public LongVariableContextEntry() {
+ }
+
public LongVariableContextEntry(final FieldExtractor extractor,
final Declaration declaration,
final Evaluator evaluator) {
@@ -282,6 +348,18 @@
evaluator );
}
+ public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
+ super.readExternal(in);
+ left = in.readLong();
+ right = in.readLong();
+ }
+
+ public void writeExternal(ObjectOutput out) throws IOException {
+ super.writeExternal(out);
+ out.writeLong(left);
+ out.writeLong(right);
+ }
+
public void updateFromTuple(final InternalWorkingMemory workingMemory,
final ReteTuple tuple) {
this.reteTuple = tuple;
@@ -320,6 +398,9 @@
public char left;
public char right;
+ public CharVariableContextEntry() {
+ }
+
public CharVariableContextEntry(final FieldExtractor extractor,
final Declaration declaration,
final Evaluator evaluator) {
@@ -328,6 +409,18 @@
evaluator );
}
+ public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
+ super.readExternal(in);
+ left = in.readChar();
+ right = in.readChar();
+ }
+
+ public void writeExternal(ObjectOutput out) throws IOException {
+ super.writeExternal(out);
+ out.writeChar(left);
+ out.writeChar(right);
+ }
+
public void updateFromTuple(final InternalWorkingMemory workingMemory,
final ReteTuple tuple) {
this.reteTuple = tuple;
@@ -366,6 +459,9 @@
public double left;
public double right;
+ public DoubleVariableContextEntry() {
+ }
+
public DoubleVariableContextEntry(final FieldExtractor extractor,
final Declaration declaration,
final Evaluator evaluator) {
@@ -374,6 +470,18 @@
evaluator );
}
+ public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
+ super.readExternal(in);
+ left = in.readDouble();
+ right = in.readDouble();
+ }
+
+ public void writeExternal(ObjectOutput out) throws IOException {
+ super.writeExternal(out);
+ out.writeDouble(left);
+ out.writeDouble(right);
+ }
+
public void updateFromTuple(final InternalWorkingMemory workingMemory,
final ReteTuple tuple) {
this.reteTuple = tuple;
@@ -411,6 +519,9 @@
public boolean left;
public boolean right;
+ public BooleanVariableContextEntry() {
+ }
+
public BooleanVariableContextEntry(final FieldExtractor extractor,
final Declaration declaration,
final Evaluator evaluator) {
@@ -419,6 +530,18 @@
evaluator );
}
+ public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
+ super.readExternal(in);
+ left = in.readBoolean();
+ right = in.readBoolean();
+ }
+
+ public void writeExternal(ObjectOutput out) throws IOException {
+ super.writeExternal(out);
+ out.writeBoolean(left);
+ out.writeBoolean(right);
+ }
+
public void updateFromTuple(final InternalWorkingMemory workingMemory,
final ReteTuple tuple) {
this.reteTuple = tuple;
Modified: labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/ruleflow/instance/RuleFlowProcessInstanceFactory.java
===================================================================
--- labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/ruleflow/instance/RuleFlowProcessInstanceFactory.java 2008-03-20 18:57:07 UTC (rev 19163)
+++ labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/ruleflow/instance/RuleFlowProcessInstanceFactory.java 2008-03-20 19:32:10 UTC (rev 19164)
@@ -1,18 +1,26 @@
package org.drools.ruleflow.instance;
-import java.io.Serializable;
+import java.io.Externalizable;
+import java.io.ObjectOutput;
+import java.io.ObjectInput;
+import java.io.IOException;
import org.drools.process.instance.ProcessInstance;
import org.drools.process.instance.ProcessInstanceFactory;
-public class RuleFlowProcessInstanceFactory implements ProcessInstanceFactory, Serializable {
+public class RuleFlowProcessInstanceFactory implements ProcessInstanceFactory, Externalizable {
private static final long serialVersionUID = 400L;
public ProcessInstance createProcessInstance() {
return new RuleFlowProcessInstance();
}
-
-
+ public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
+ }
+
+ public void writeExternal(ObjectOutput out) throws IOException {
+ }
+
+
}
Modified: labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/spi/AgendaGroup.java
===================================================================
--- labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/spi/AgendaGroup.java 2008-03-20 18:57:07 UTC (rev 19163)
+++ labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/spi/AgendaGroup.java 2008-03-20 19:32:10 UTC (rev 19164)
@@ -1,18 +1,19 @@
package org.drools.spi;
import java.io.Serializable;
+import java.io.Externalizable;
import org.drools.common.DefaultAgenda;
/*
* Copyright 2005 JBoss Inc
- *
+ *
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -22,17 +23,17 @@
/**
* The <code>Agenda</code> can be partitioned into groups, called <code>AgendaGroup</code>s. <code>Rule</code>s can be assigned to
- * these <code>AgendaGroup</code>s. Only rules in the focus group can fire.
- *
+ * these <code>AgendaGroup</code>s. Only rules in the focus group can fire.
+ *
* @see DefaultAgenda
- *
+ *
* @author <a href="mailto:mark.proctor at jboss.com">Mark Proctor</a>
* @author <a href="mailto:bob at werken.com">Bob McWhirter</a>
*
*/
public interface AgendaGroup
extends
- Serializable {
+ Externalizable {
/**
* Static reference to determine the default <code>AgendaGroup</code> name.
@@ -56,7 +57,7 @@
* int value for the total number of activations
*/
public int size();
-
+
public boolean isEmpty();
public boolean isActive();
Modified: labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/spi/ConsequenceExceptionHandler.java
===================================================================
--- labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/spi/ConsequenceExceptionHandler.java 2008-03-20 18:57:07 UTC (rev 19163)
+++ labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/spi/ConsequenceExceptionHandler.java 2008-03-20 19:32:10 UTC (rev 19164)
@@ -1,15 +1,15 @@
package org.drools.spi;
-import java.io.Serializable;
+import java.io.Externalizable;
import org.drools.WorkingMemory;
/**
* Care should be taken when implementing this class. Swallowing of consequence can be dangerous
- * if the exception occured during a WorkingMemory action, thus leaving the integrity of the
+ * if the exception occured during a WorkingMemory action, thus leaving the integrity of the
* WorkingMemory invalid.
*
*/
-public interface ConsequenceExceptionHandler extends Serializable {
+public interface ConsequenceExceptionHandler extends Externalizable {
void handleException(Activation activation, WorkingMemory workingMemory, Exception exception);
-}
+}
Modified: labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/spi/Constraint.java
===================================================================
--- labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/spi/Constraint.java 2008-03-20 18:57:07 UTC (rev 19163)
+++ labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/spi/Constraint.java 2008-03-20 19:32:10 UTC (rev 19164)
@@ -1,18 +1,22 @@
package org.drools.spi;
import java.io.Serializable;
+import java.io.Externalizable;
+import java.io.ObjectOutput;
+import java.io.IOException;
+import java.io.ObjectInput;
import org.drools.rule.Declaration;
/*
* Copyright 2005 JBoss Inc
- *
+ *
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -26,9 +30,9 @@
Cloneable {
/**
- * Returns all the declarations required by the given
+ * Returns all the declarations required by the given
* constraint implementation.
- *
+ *
* @return
*/
Declaration[] getRequiredDeclarations();
@@ -36,7 +40,7 @@
/**
* A constraint may be required to replace an old
* declaration object by a new updated one
- *
+ *
* @param oldDecl
* @param newDecl
*/
@@ -51,30 +55,43 @@
/**
* Returns the type of the constraint, either ALPHA, BETA or UNKNOWN
- *
+ *
* @return
*/
public ConstraintType getType();
-
+
/**
* A java 1.4 type-safe enum
*/
- public static class ConstraintType implements Serializable {
-
+ public static class ConstraintType implements Externalizable {
+
private static final long serialVersionUID = 4865182371013556266L;
-
+
public static final ConstraintType UNKNOWN = new ConstraintType(0, "UNKNOWN");
public static final ConstraintType ALPHA = new ConstraintType(1, "ALPHA");
public static final ConstraintType BETA = new ConstraintType(2, "BETA");
-
- private final int type;
- private final String desc;
-
+
+ private int type;
+ private String desc;
+
+ public ConstraintType() {
+
+ }
+
private ConstraintType( int type, String desc ) {
this.type = type;
this.desc = desc;
}
+ public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
+ type = in.readInt();
+ desc = (String)in.readObject();
+ }
+
+ public void writeExternal(ObjectOutput out) throws IOException {
+ out.writeInt(type);
+ out.writeObject(desc);
+ }
/**
* @inheritDoc
*
@@ -100,7 +117,7 @@
if ( type != other.type ) return false;
return true;
}
-
+
public String toString() {
return "ConstraintType::"+this.desc;
}
Modified: labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/spi/Extractor.java
===================================================================
--- labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/spi/Extractor.java 2008-03-20 18:57:07 UTC (rev 19163)
+++ labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/spi/Extractor.java 2008-03-20 19:32:10 UTC (rev 19164)
@@ -2,13 +2,13 @@
/*
* Copyright 2005 JBoss Inc
- *
+ *
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -16,7 +16,7 @@
* limitations under the License.
*/
-import java.io.Serializable;
+import java.io.Externalizable;
import java.lang.reflect.Method;
import org.drools.base.ValueType;
@@ -24,7 +24,7 @@
public interface Extractor
extends
- Serializable {
+ Externalizable {
public Object getValue(InternalWorkingMemory workingMemory, Object object);
@@ -43,9 +43,9 @@
public double getDoubleValue(InternalWorkingMemory workingMemory, Object object);
public boolean getBooleanValue(InternalWorkingMemory workingMemory, Object object);
-
+
public boolean isNullValue(InternalWorkingMemory workingMemory, Object object);
-
+
public boolean isGlobal();
public ValueType getValueType();
Modified: labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/spi/FieldValue.java
===================================================================
--- labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/spi/FieldValue.java 2008-03-20 18:57:07 UTC (rev 19163)
+++ labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/spi/FieldValue.java 2008-03-20 19:32:10 UTC (rev 19164)
@@ -2,13 +2,13 @@
/*
* Copyright 2005 JBoss Inc
- *
+ *
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -17,6 +17,8 @@
*/
import java.io.Serializable;
+import java.math.BigDecimal;
+import java.math.BigInteger;
public interface FieldValue
extends
@@ -26,6 +28,10 @@
public char getCharValue();
+ public BigDecimal getBigDecimalValue();
+
+ public BigInteger getBigIntegerValue();
+
public int getIntValue();
public byte getByteValue();
@@ -39,7 +45,7 @@
public double getDoubleValue();
public boolean getBooleanValue();
-
+
public boolean isNull();
public boolean isBooleanField();
@@ -55,7 +61,7 @@
* @return
*/
public boolean isCollectionField();
-
+
public boolean isStringField();
}
\ No newline at end of file
Modified: labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/spi/GlobalExporter.java
===================================================================
--- labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/spi/GlobalExporter.java 2008-03-20 18:57:07 UTC (rev 19163)
+++ labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/spi/GlobalExporter.java 2008-03-20 19:32:10 UTC (rev 19164)
@@ -1,9 +1,9 @@
/**
- *
+ *
*/
package org.drools.spi;
-import java.io.Serializable;
+import java.io.Externalizable;
import org.drools.WorkingMemory;
@@ -12,8 +12,8 @@
* globals using during the execute(...) method that returned the StatelessSessionResult.
*
*/
-public interface GlobalExporter extends Serializable {
-
+public interface GlobalExporter extends Externalizable {
+
/**
* This method is called internally by the StatelessSession, which will provide the WorkingMemory.
* The returned GlobalResolver is used by the StatefulSessionResult
Modified: labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/spi/GlobalExtractor.java
===================================================================
--- labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/spi/GlobalExtractor.java 2008-03-20 18:57:07 UTC (rev 19163)
+++ labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/spi/GlobalExtractor.java 2008-03-20 19:32:10 UTC (rev 19164)
@@ -1,12 +1,12 @@
/*
* Copyright 2006 JBoss Inc
- *
+ *
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -18,6 +18,9 @@
import java.lang.reflect.Method;
import java.util.Map;
+import java.io.ObjectOutput;
+import java.io.IOException;
+import java.io.ObjectInput;
import org.drools.RuntimeDroolsException;
import org.drools.base.ClassObjectType;
@@ -27,7 +30,7 @@
/**
* This is a global variable extractor used to get a global variable value
- *
+ *
* @author etirelli
*/
public class GlobalExtractor
@@ -35,9 +38,12 @@
Extractor {
private static final long serialVersionUID = 400L;
- private final String key;
- private final ObjectType objectType;
+ private String key;
+ private ObjectType objectType;
+ public GlobalExtractor() {
+
+ }
public GlobalExtractor(final String key,
final Map map) {
this.key = key;
@@ -48,6 +54,16 @@
return workingMemory.getGlobal( key );
}
+ public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
+ key = (String)in.readObject();
+ objectType = (ObjectType)in.readObject();
+ }
+
+ public void writeExternal(ObjectOutput out) throws IOException {
+ out.writeObject(key);
+ out.writeObject(objectType);
+ }
+
public ObjectType getObjectType() {
return this.objectType;
}
Modified: labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/spi/GlobalResolver.java
===================================================================
--- labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/spi/GlobalResolver.java 2008-03-20 18:57:07 UTC (rev 19163)
+++ labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/spi/GlobalResolver.java 2008-03-20 19:32:10 UTC (rev 19164)
@@ -1,9 +1,9 @@
package org.drools.spi;
-import java.io.Serializable;
+import java.io.Externalizable;
-public interface GlobalResolver extends Serializable {
+public interface GlobalResolver extends Externalizable {
public Object resolveGlobal(String identifier);
-
+
public void setGlobal(String identifier, Object value);
}
Modified: labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/spi/ObjectType.java
===================================================================
--- labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/spi/ObjectType.java 2008-03-20 18:57:07 UTC (rev 19163)
+++ labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/spi/ObjectType.java 2008-03-20 19:32:10 UTC (rev 19164)
@@ -2,50 +2,49 @@
/*
* Copyright 2005 JBoss Inc
- *
+ *
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
+import java.io.Externalizable;
-import java.io.Serializable;
-
import org.drools.base.ValueType;
/**
* Semantic object type differentiator.
- *
+ *
* @see org.drools.rule.Declaration
- *
+ *
* @author <a href="mailto:bob at werken.com">bob mcwhirter </a>
*/
public interface ObjectType
extends
- Serializable {
+ Externalizable {
/**
* Determine if the passed <code>Object</code> belongs to the object type
* defined by this <code>objectType</code> instance.
- *
+ *
* @param object
* The <code>Object</code> to test.
- *
+ *
* @return <code>true</code> if the <code>Object</code> matches this
* object type, else <code>false</code>.
*/
boolean matches(Object object);
-
+
boolean isAssignableFrom(Object object);
-
+
boolean isAssignableFrom(ObjectType objectType);
-
+
/**
* Returns true if the object type represented by this object
* is an event object type. False otherwise.
Modified: labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/spi/PatternExtractor.java
===================================================================
--- labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/spi/PatternExtractor.java 2008-03-20 18:57:07 UTC (rev 19163)
+++ labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/spi/PatternExtractor.java 2008-03-20 19:32:10 UTC (rev 19164)
@@ -3,6 +3,10 @@
import java.lang.reflect.Method;
import java.util.Collection;
import java.util.Iterator;
+import java.io.Externalizable;
+import java.io.IOException;
+import java.io.ObjectInput;
+import java.io.ObjectOutput;
import org.drools.RuntimeDroolsException;
import org.drools.base.ClassObjectType;
@@ -14,13 +18,13 @@
/*
* Copyright 2005 JBoss Inc
- *
+ *
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -30,18 +34,29 @@
public class PatternExtractor
implements
- Extractor {
+ Extractor, Externalizable {
/**
- *
+ *
*/
private static final long serialVersionUID = 400L;
private ObjectType objectType;
+ public PatternExtractor() {
+ this(null);
+ }
public PatternExtractor(final ObjectType objectType) {
this.objectType = objectType;
}
+ public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
+ objectType = (ObjectType)in.readObject();
+ }
+
+ public void writeExternal(ObjectOutput out) throws IOException {
+ out.writeObject(objectType);
+ }
+
public Object getValue(InternalWorkingMemory workingMemory, final Object object) {
// need to use instanceof because an object may be created in nodes like accumulate and from
// where no shadow is applied
Modified: labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/spi/PredicateExpression.java
===================================================================
--- labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/spi/PredicateExpression.java 2008-03-20 18:57:07 UTC (rev 19163)
+++ labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/spi/PredicateExpression.java 2008-03-20 19:32:10 UTC (rev 19164)
@@ -2,13 +2,13 @@
/*
* Copyright 2005 JBoss Inc
- *
+ *
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -19,12 +19,14 @@
import org.drools.WorkingMemory;
import org.drools.rule.Declaration;
+import java.io.Externalizable;
+
public interface PredicateExpression
extends
- Invoker {
-
+ Invoker, Externalizable {
+
public Object createContext();
-
+
public boolean evaluate(Object object,
Tuple tuple,
Declaration[] previousDeclarations,
Modified: labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/spi/PropagationContext.java
===================================================================
--- labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/spi/PropagationContext.java 2008-03-20 18:57:07 UTC (rev 19163)
+++ labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/spi/PropagationContext.java 2008-03-20 19:32:10 UTC (rev 19164)
@@ -2,13 +2,13 @@
/*
* Copyright 2005 JBoss Inc
- *
+ *
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -16,14 +16,15 @@
* limitations under the License.
*/
-import java.io.Serializable;
+import java.io.Externalizable;
+
import org.drools.reteoo.ReteTuple;
import org.drools.rule.EntryPoint;
import org.drools.rule.Rule;
public interface PropagationContext
extends
- Serializable {
+ Externalizable {
public static final int ASSERTION = 0;
public static final int RETRACTION = 1;
@@ -50,9 +51,9 @@
ReteTuple tuple);
public void clearRetractedTuples();
-
+
public void releaseResources();
-
+
public EntryPoint getEntryPoint();
}
\ No newline at end of file
Modified: labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/spi/Restriction.java
===================================================================
--- labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/spi/Restriction.java 2008-03-20 18:57:07 UTC (rev 19163)
+++ labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/spi/Restriction.java 2008-03-20 19:32:10 UTC (rev 19164)
@@ -1,6 +1,7 @@
package org.drools.spi;
import java.io.Serializable;
+import java.io.Externalizable;
import org.drools.common.InternalFactHandle;
import org.drools.common.InternalWorkingMemory;
@@ -10,7 +11,7 @@
public interface Restriction
extends
- Serializable,
+ Externalizable,
Cloneable {
Declaration[] getRequiredDeclarations();
@@ -30,7 +31,7 @@
/**
* A restriction may be required to replace an old
* declaration object by a new updated one
- *
+ *
* @param oldDecl
* @param newDecl
*/
Modified: labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/spi/RuleComponent.java
===================================================================
--- labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/spi/RuleComponent.java 2008-03-20 18:57:07 UTC (rev 19163)
+++ labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/spi/RuleComponent.java 2008-03-20 19:32:10 UTC (rev 19164)
@@ -2,13 +2,13 @@
/*
* Copyright 2005 JBoss Inc
- *
+ *
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -16,17 +16,17 @@
* limitations under the License.
*/
-import java.io.Serializable;
+import java.io.Externalizable;
/**
* Semantic component marker.
- *
+ *
* @author <a href="mailto:bob at werken.com">bob mcwhirter </a>
- *
+ *
* @version $Id$
*/
public interface RuleComponent
extends
- Serializable {
+ Externalizable {
}
\ No newline at end of file
Modified: labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/spi/RuleFlowGroup.java
===================================================================
--- labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/spi/RuleFlowGroup.java 2008-03-20 18:57:07 UTC (rev 19163)
+++ labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/spi/RuleFlowGroup.java 2008-03-20 19:32:10 UTC (rev 19164)
@@ -2,13 +2,13 @@
/*
* Copyright 2005 JBoss Inc
- *
+ *
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -16,10 +16,10 @@
* limitations under the License.
*/
-import java.io.Serializable;
+import java.io.Externalizable;
import java.util.Iterator;
-public interface RuleFlowGroup extends Serializable {
+public interface RuleFlowGroup extends Externalizable {
String getName();
@@ -37,7 +37,7 @@
* Sets the auto-deactivate status of this RuleFlowGroup.
* If this is set to true, an active RuleFlowGroup automatically
* deactivates if it has no more activations. If it had no
- * activations when it was activated, it will be deactivated immediately.
+ * activations when it was activated, it will be deactivated immediately.
*/
void setAutoDeactivate(boolean autoDeactivate);
}
\ No newline at end of file
Modified: labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/temporal/SessionClock.java
===================================================================
--- labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/temporal/SessionClock.java 2008-03-20 18:57:07 UTC (rev 19163)
+++ labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/temporal/SessionClock.java 2008-03-20 19:32:10 UTC (rev 19164)
@@ -17,13 +17,15 @@
*/
package org.drools.temporal;
+import java.io.Externalizable;
+
/**
* A clock interface that all engine clocks must implement
*
* @author etirelli
*/
-public interface SessionClock {
-
+public interface SessionClock extends Externalizable {
+
/**
* Returns the current time. There is no semantics attached
* to the long return value, so it will depend on the actual
@@ -35,5 +37,5 @@
*
*/
public long getCurrentTime();
-
+
}
Modified: labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/temporal/SessionPseudoClock.java
===================================================================
--- labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/temporal/SessionPseudoClock.java 2008-03-20 18:57:07 UTC (rev 19163)
+++ labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/temporal/SessionPseudoClock.java 2008-03-20 19:32:10 UTC (rev 19164)
@@ -17,6 +17,10 @@
*/
package org.drools.temporal;
+import java.io.ObjectInput;
+import java.io.IOException;
+import java.io.ObjectOutput;
+
/**
* A SessionPseudoClock is a clock that allows the user to explicitly
* control current time.
@@ -27,20 +31,28 @@
public class SessionPseudoClock
implements
SessionClock {
-
+
private long timer;
public SessionPseudoClock() {
this.timer = 0;
}
-
+
+ public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
+ timer = in.readLong();
+ }
+
+ public void writeExternal(ObjectOutput out) throws IOException {
+ out.writeLong(timer);
+ }
+
/* (non-Javadoc)
- * @see org.drools.temporal.SessionClock#getCurrentTime()
- */
+ * @see org.drools.temporal.SessionClock#getCurrentTime()
+ */
public long getCurrentTime() {
return this.timer;
}
-
+
public long advanceTime( long millisecs ) {
this.timer += millisecs;
return this.timer;
Modified: labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/util/AbstractBaseLinkedListNode.java
===================================================================
--- labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/util/AbstractBaseLinkedListNode.java 2008-03-20 18:57:07 UTC (rev 19163)
+++ labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/util/AbstractBaseLinkedListNode.java 2008-03-20 19:32:10 UTC (rev 19164)
@@ -1,14 +1,18 @@
package org.drools.util;
+import java.io.IOException;
+import java.io.ObjectInput;
+import java.io.ObjectOutput;
+
/*
* Copyright 2005 JBoss Inc
- *
+ *
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -18,9 +22,9 @@
/**
* Provides a abstract base implementation that an object can extend so that it can be used in a LinkedList.
- *
+ *
* @see LinkedList
- *
+ *
* @author <a href="mailto:mark.proctor at jboss.com">Mark Proctor</a>
* @author <a href="mailto:bob at werken.com">Bob McWhirter</a>
*/
@@ -40,6 +44,16 @@
public AbstractBaseLinkedListNode() {
}
+ public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
+ previous = (LinkedListNode)in.readObject();
+ next = (LinkedListNode)in.readObject();
+ }
+
+ public void writeExternal(ObjectOutput out) throws IOException {
+ out.writeObject(previous);
+ out.writeObject(next);
+ }
+
/* (non-Javadoc)
* @see org.drools.reteoo.LinkedListNode#getNext()
*/
Modified: labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/util/AbstractHashTable.java
===================================================================
--- labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/util/AbstractHashTable.java 2008-03-20 18:57:07 UTC (rev 19163)
+++ labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/util/AbstractHashTable.java 2008-03-20 19:32:10 UTC (rev 19164)
@@ -1,9 +1,12 @@
/**
- *
+ *
*/
package org.drools.util;
-import java.io.Serializable;
+import java.io.Externalizable;
+import java.io.ObjectOutput;
+import java.io.IOException;
+import java.io.ObjectInput;
import org.drools.common.InternalFactHandle;
import org.drools.reteoo.ReteTuple;
@@ -13,7 +16,7 @@
public abstract class AbstractHashTable
implements
- Serializable {
+ Externalizable {
static final int MAX_CAPACITY = 1 << 30;
protected int size;
@@ -30,7 +33,7 @@
this( 16,
0.75f );
}
-
+
public AbstractHashTable(final int capacity,
final float loadFactor) {
this.loadFactor = loadFactor;
@@ -38,19 +41,37 @@
this.table = new Entry[capacity];
this.comparator = EqualityEquals.getInstance();
}
-
+
public AbstractHashTable(final Entry[] table) {
this( 0.75f, table);
- }
-
+ }
+
public AbstractHashTable(final float loadFactor,
final Entry[] table) {
this.loadFactor = loadFactor;
this.threshold = (int) (table.length * loadFactor);
this.table = table;
this.comparator = EqualityEquals.getInstance();
- }
+ }
+ public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
+ size = in.readInt();
+ threshold = in.readInt();
+ loadFactor = in.readFloat();
+ comparator = (ObjectComparator)in.readObject();
+ table = (Entry[])in.readObject();
+ iterator = (HashTableIterator)in.readObject();
+ }
+
+ public void writeExternal(ObjectOutput out) throws IOException {
+ out.writeInt(size);
+ out.writeInt(threshold);
+ out.writeFloat(loadFactor);
+ out.writeObject(comparator);
+ out.writeObject(table);
+ out.writeObject(iterator);
+ }
+
public Iterator iterator() {
if ( this.iterator == null ) {
this.iterator = new HashTableIterator( this );
@@ -59,12 +80,12 @@
this.iterator.reset();
return this.iterator;
}
-
+
public Iterator newIterator() {
HashTableIterator iterator = new HashTableIterator( this );
iterator.reset();
return iterator;
-
+
}
public void setComparator(final ObjectComparator comparator) {
@@ -102,8 +123,8 @@
this.table = newTable;
this.threshold = (int) (newCapacity * this.loadFactor);
- }
-
+ }
+
public Entry[] toArray() {
Entry[] result = new Entry[this.size];
int index = 0;
@@ -120,24 +141,24 @@
// public void add(Entry entry) {
// int index = indexOf( entry.hashCode(), table.length );
//
- //
+ //
// boolean exists = false;
- //
+ //
// // scan the linked entries to see if it exists
// if ( !checkExists ) {
// Entry current = this.table[index];
// int hashCode = entry.hashCode();
- // while ( current != null ) {
+ // while ( current != null ) {
// if ( hashCode == current.hashCode() && entry.equals( current ) ) {
// exists = true;
// }
- // }
+ // }
// }
- //
+ //
// if( exists == false ) {
// entry.setNext( this.table[index] );
// this.table[index] = entry;
- //
+ //
// if ( this.size++ >= this.threshold ) {
// resize( 2 * this.table.length );
// }
@@ -159,7 +180,7 @@
//
// public Entry remove(Entry entry) {
// int index = indexOf( entry.hashCode(), table.length );
- // Entry previous = this.table[index];
+ // Entry previous = this.table[index];
// Entry current = previous;
// int hashCode = entry.hashCode();
// while ( current != null ) {
@@ -214,7 +235,7 @@
public interface ObjectComparator
extends
- Serializable {
+ Externalizable {
public int hashCodeOf(Object object);
public int rehash(int hashCode);
@@ -229,7 +250,7 @@
*/
public static class HashTableIterator
implements
- Iterator {
+ Iterator, Externalizable {
private static final long serialVersionUID = 400L;
@@ -239,18 +260,37 @@
private int length;
private Entry entry;
+ public HashTableIterator() {
+ }
+
public HashTableIterator(final AbstractHashTable hashTable) {
this.hashTable = hashTable;
}
-
+
+ public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
+ hashTable = (AbstractHashTable)in.readObject();
+ table = (Entry[])in.readObject();
+ row = in.readInt();
+ length = in.readInt();
+ entry = (Entry)in.readObject();
+ }
+
+ public void writeExternal(ObjectOutput out) throws IOException {
+ out.writeObject(hashTable);
+ out.writeObject(table);
+ out.writeInt(row);
+ out.writeInt(length);
+ out.writeObject(entry);
+ }
+
/* (non-Javadoc)
* @see org.drools.util.Iterator#next()
*/
- public Object next() {
+ public Object next() {
if ( this.entry != null ) {
this.entry = this.entry.getNext();
}
-
+
// if no entry keep skipping rows until we come to the end, or find one that is populated
while ( this.entry == null ) {
this.row++;
@@ -258,11 +298,11 @@
return null;
}
this.entry = this.table[this.row];
- }
-
+ }
+
return this.entry;
- }
-
+ }
+
// /* (non-Javadoc)
// * @see org.drools.util.Iterator#next()
// */
@@ -284,7 +324,7 @@
// }
//
// return this.entry;
-// }
+// }
// /* (non-Javadoc)
// * @see org.drools.util.Iterator#next()
@@ -327,6 +367,12 @@
private static final long serialVersionUID = 400L;
public static ObjectComparator INSTANCE = new InstanceEquals();
+ public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
+ }
+
+ public void writeExternal(ObjectOutput out) throws IOException {
+ }
+
public static ObjectComparator getInstance() {
return InstanceEquals.INSTANCE;
}
@@ -360,6 +406,12 @@
private static final long serialVersionUID = 400L;
public static ObjectComparator INSTANCE = new EqualityEquals();
+ public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
+ }
+
+ public void writeExternal(ObjectOutput out) throws IOException {
+ }
+
public static ObjectComparator getInstance() {
return EqualityEquals.INSTANCE;
}
@@ -376,7 +428,7 @@
return h;
}
- private EqualityEquals() {
+ public EqualityEquals() {
}
@@ -403,7 +455,10 @@
public Entry next;
// private LinkedList list;
+ public FactEntryImpl() {
+ }
+
public FactEntryImpl(final InternalFactHandle handle) {
this.handle = handle;
this.hashCode = handle.hashCode();
@@ -417,6 +472,18 @@
// this.list = new LinkedList();
}
+ public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
+ handle = (InternalFactHandle)in.readObject();
+ hashCode = in.readInt();
+ next = (Entry)in.readObject();
+ }
+
+ public void writeExternal(ObjectOutput out) throws IOException {
+ out.writeObject(handle);
+ out.writeInt(hashCode);
+ out.writeObject(next);
+ }
+
public InternalFactHandle getFactHandle() {
return this.handle;
}
@@ -429,13 +496,13 @@
this.next = next;
}
- //
+ //
// void add(final LinkedListEntry tupleMatchEntry) {
// this.list.add( tupleMatchEntry );
// }
// void remove(final LinkedListEntry tupleMatchEntry) {
// this.list.remove( tupleMatchEntry );
- // }
+ // }
public int hashCode() {
return this.hashCode;
@@ -450,14 +517,18 @@
}
}
- public static class FieldIndex implements Serializable {
+ public static class FieldIndex implements Externalizable {
private static final long serialVersionUID = 1020010166351582645L;
-
+
FieldExtractor extractor;
Declaration declaration;
public Evaluator evaluator;
+ public FieldIndex() {
+
+ }
+
public FieldIndex(final FieldExtractor extractor,
final Declaration declaration,
final Evaluator evaluator) {
@@ -467,6 +538,17 @@
this.evaluator = evaluator;
}
+ public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
+ extractor = (FieldExtractor)in.readObject();
+ declaration = (Declaration)in.readObject();
+ evaluator = (Evaluator)in.readObject();
+ }
+
+ public void writeExternal(ObjectOutput out) throws IOException {
+ out.writeObject(extractor);
+ out.writeObject(declaration);
+ out.writeObject(evaluator);
+ }
public Declaration getDeclaration() {
return this.declaration;
}
@@ -480,9 +562,9 @@
}
}
- public static interface Index extends Serializable {
+ public static interface Index extends Externalizable {
public FieldIndex getFieldIndex(int index);
-
+
public int hashCodeOf(ReteTuple tuple);
public int hashCodeOf(Object object);
@@ -502,13 +584,17 @@
Index {
private static final long serialVersionUID = -1022777958435032326L;
-
+
private FieldExtractor extractor;
private Declaration declaration;
private Evaluator evaluator;
private int startResult;
+ public SingleIndex() {
+
+ }
+
public SingleIndex(final FieldIndex[] indexes,
final int startResult) {
this.startResult = startResult;
@@ -518,14 +604,29 @@
this.evaluator = indexes[0].evaluator;
}
+ public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
+ extractor = (FieldExtractor)in.readObject();
+ declaration = (Declaration)in.readObject();
+ evaluator = (Evaluator)in.readObject();
+ startResult = in.readInt();
+ }
+
+ public void writeExternal(ObjectOutput out) throws IOException {
+ out.writeObject(extractor);
+ out.writeObject(declaration);
+ out.writeObject(evaluator);
+ out.writeInt(startResult);
+ }
+
+
public FieldIndex getFieldIndex(int index) {
if ( index > 0 ) {
throw new IllegalArgumentException("Index position " + index + " does not exist" );
}
return new FieldIndex(extractor, declaration, evaluator);
}
-
-
+
+
public int hashCodeOf(final Object object) {
int hashCode = this.startResult;
hashCode = TupleIndexHashTable.PRIME * hashCode + this.extractor.getHashCode( null, object );
@@ -582,12 +683,15 @@
Index {
private static final long serialVersionUID = 5453765340969897686L;
-
+
private FieldIndex index0;
private FieldIndex index1;
private int startResult;
+ public DoubleCompositeIndex() {
+
+ }
public DoubleCompositeIndex(final FieldIndex[] indexes,
final int startResult) {
this.startResult = startResult;
@@ -595,7 +699,19 @@
this.index0 = indexes[0];
this.index1 = indexes[1];
}
-
+
+ public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
+ index0 = (FieldIndex)in.readObject();
+ index1 = (FieldIndex)in.readObject();
+ startResult = in.readInt();
+ }
+
+ public void writeExternal(ObjectOutput out) throws IOException {
+ out.writeObject(index0);
+ out.writeObject(index1);
+ out.writeInt(startResult);
+ }
+
public FieldIndex getFieldIndex(int index) {
switch ( index ) {
case 0:
@@ -679,15 +795,19 @@
public static class TripleCompositeIndex
implements
Index {
-
+
private static final long serialVersionUID = 7743486670399440233L;
-
+
private FieldIndex index0;
private FieldIndex index1;
private FieldIndex index2;
private int startResult;
+ public TripleCompositeIndex() {
+
+ }
+
public TripleCompositeIndex(final FieldIndex[] indexes,
final int startResult) {
this.startResult = startResult;
@@ -696,7 +816,21 @@
this.index1 = indexes[1];
this.index2 = indexes[2];
}
-
+
+ public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
+ index0 = (FieldIndex)in.readObject();
+ index1 = (FieldIndex)in.readObject();
+ index2 = (FieldIndex)in.readObject();
+ startResult = in.readInt();
+ }
+
+ public void writeExternal(ObjectOutput out) throws IOException {
+ out.writeObject(index0);
+ out.writeObject(index1);
+ out.writeObject(index2);
+ out.writeInt(startResult);
+ }
+
public FieldIndex getFieldIndex(int index) {
switch ( index ) {
case 0:
@@ -704,11 +838,11 @@
case 1:
return index1;
case 2:
- return index2;
+ return index2;
default:
throw new IllegalArgumentException("Index position " + index + " does not exist" );
}
- }
+ }
public int hashCodeOf(final Object object) {
int hashCode = this.startResult;
Copied: labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/util/ArrayIterator.java (from rev 19160, labs/jbossrules/dev_tags/before_righttuple_merge_20080320/drools-core/src/main/java/org/drools/util/ArrayIterator.java)
===================================================================
--- labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/util/ArrayIterator.java (rev 0)
+++ labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/util/ArrayIterator.java 2008-03-20 19:32:10 UTC (rev 19164)
@@ -0,0 +1,158 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.drools.util;
+
+import java.lang.reflect.Array;
+import java.util.NoSuchElementException;
+
+/**
+ * Implements an {@link java.util.Iterator Iterator} over any array.
+ * <p>
+ * The array can be either an array of object or of primitives. If you know
+ * that you have an object array, the
+ * {@link org.apache.commons.collections.iterators.ObjectArrayIterator ObjectArrayIterator}
+ * class is a better choice, as it will perform better.
+ * <p>
+ * The iterator implements a {@link #reset} method, allowing the reset of
+ * the iterator back to the start if required.
+ *
+ * @since Commons Collections 1.0
+ * @version $Revision$ $Date$
+ *
+ * @author James Strachan
+ * @author Mauricio S. Moura
+ * @author Michael A. Smith
+ * @author Neil O'Toole
+ * @author Stephen Colebourne
+ */
+public class ArrayIterator implements java.util.Iterator {
+
+ /** The array to iterate over */
+ protected Object array;
+ /** The end index to loop to */
+ protected int endIndex = 0;
+ /** The current iterator index */
+ protected int index = 0;
+
+
+ /**
+ * Constructs an ArrayIterator that will iterate over the values in the
+ * specified array.
+ *
+ * @param array the array to iterate over.
+ * @throws IllegalArgumentException if <code>array</code> is not an array.
+ * @throws NullPointerException if <code>array</code> is <code>null</code>
+ */
+ public ArrayIterator(final Object array) {
+ setArray(array);
+ }
+
+ /**
+ * Checks whether the index is valid or not.
+ *
+ * @param bound the index to check
+ * @param type the index type (for error messages)
+ * @throws IndexOutOfBoundsException if the index is invalid
+ */
+ protected void checkBound(final int bound, final String type ) {
+ if (bound > this.endIndex) {
+ throw new ArrayIndexOutOfBoundsException(
+ "Attempt to make an ArrayIterator that " + type +
+ "s beyond the end of the array. "
+ );
+ }
+ if (bound < 0) {
+ throw new ArrayIndexOutOfBoundsException(
+ "Attempt to make an ArrayIterator that " + type +
+ "s before the start of the array. "
+ );
+ }
+ }
+
+ // Iterator interface
+ //-----------------------------------------------------------------------
+ /**
+ * Returns true if there are more elements to return from the array.
+ *
+ * @return true if there is a next element to return
+ */
+ public boolean hasNext() {
+ return (index < endIndex);
+ }
+
+ /**
+ * Returns the next element in the array.
+ *
+ * @return the next element in the array
+ * @throws NoSuchElementException if all the elements in the array
+ * have already been returned
+ */
+ public Object next() {
+ if (hasNext() == false) {
+ throw new NoSuchElementException();
+ }
+ return Array.get(array, index++);
+ }
+
+ /**
+ * Throws {@link UnsupportedOperationException}.
+ *
+ * @throws UnsupportedOperationException always
+ */
+ public void remove() {
+ throw new UnsupportedOperationException("remove() method is not supported");
+ }
+
+ // Properties
+ //-----------------------------------------------------------------------
+ /**
+ * Gets the array that this iterator is iterating over.
+ *
+ * @return the array this iterator iterates over, or <code>null</code> if
+ * the no-arg constructor was used and {@link #setArray(Object)} has never
+ * been called with a valid array.
+ */
+ public Object getArray() {
+ return array;
+ }
+
+ /**
+ * Sets the array that the ArrayIterator should iterate over.
+ * <p>
+ * If an array has previously been set (using the single-arg constructor
+ * or this method) then that array is discarded in favour of this one.
+ * Iteration is restarted at the start of the new array.
+ * Although this can be used to reset iteration, the {@link #reset()} method
+ * is a more effective choice.
+ *
+ * @param array the array that the iterator should iterate over.
+ * @throws IllegalArgumentException if <code>array</code> is not an array.
+ * @throws NullPointerException if <code>array</code> is <code>null</code>
+ */
+ private void setArray(final Object array) {
+ // Array.getLength throws IllegalArgumentException if the object is not
+ // an array or NullPointerException if the object is null. This call
+ // is made before saving the array and resetting the index so that the
+ // array iterator remains in a consistent state if the argument is not
+ // an array or is null.
+ this.endIndex = Array.getLength(array);
+ this.array = array;
+ this.index = 0;
+ }
+
+}
Modified: labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/util/BinaryHeapQueue.java
===================================================================
--- labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/util/BinaryHeapQueue.java 2008-03-20 18:57:07 UTC (rev 19163)
+++ labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/util/BinaryHeapQueue.java 2008-03-20 19:32:10 UTC (rev 19164)
@@ -2,13 +2,13 @@
/*
* Copyright 2005 JBoss Inc
- *
+ *
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -16,19 +16,22 @@
* limitations under the License.
*/
-import java.io.Serializable;
+import java.io.Externalizable;
+import java.io.IOException;
+import java.io.ObjectOutput;
+import java.io.ObjectInput;
import java.util.Comparator;
import java.util.NoSuchElementException;
public class BinaryHeapQueue
implements
Queue,
- Serializable {
+ Externalizable {
/** The default capacity for a binary heap. */
private final static int DEFAULT_CAPACITY = 13;
/** The comparator used to order the elements */
- private final Comparator comparator;
+ private Comparator comparator;
/** The number of elements currently in this heap. */
private int size;
@@ -36,6 +39,9 @@
/** The elements in this heap. */
private Queueable[] elements;
+ public BinaryHeapQueue() {
+
+ }
/**
* Constructs a new <code>BinaryHeap</code> that will use the given
* comparator to order its elements.
@@ -68,7 +74,18 @@
}
//-----------------------------------------------------------------------
+ public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
+ comparator = (Comparator)in.readObject();
+ elements = (Queueable[])in.readObject();
+ size = in.readInt();
+ }
+ public void writeExternal(ObjectOutput out) throws IOException {
+ out.writeObject(comparator);
+ out.writeObject(elements);
+ out.writeInt(size);
+ }
+
/**
* Clears all elements from queue.
*/
Modified: labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/util/BinaryRuleBaseLoader.java
===================================================================
--- labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/util/BinaryRuleBaseLoader.java 2008-03-20 18:57:07 UTC (rev 19163)
+++ labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/util/BinaryRuleBaseLoader.java 2008-03-20 19:32:10 UTC (rev 19164)
@@ -14,7 +14,7 @@
* This loads up rulebases from binary packages.
* Can work with an existing or a new rulebase.
* This is useful for deployment.
- *
+ *
* @author Michael Neale
*/
public class BinaryRuleBaseLoader {
@@ -29,7 +29,7 @@
*/
public BinaryRuleBaseLoader() {
this( RuleBaseFactory.newRuleBase(), null );
- }
+ }
/**
* This will add any binary packages to the rulebase.
@@ -52,17 +52,17 @@
if ( classLoader == null ) {
classLoader = this.getClass().getClassLoader();
}
- }
+ }
this.ruleBase = rb;
this.classLoader = classLoader;
}
-
+
/**
* This will add the BINARY package to the rulebase.
* Uses the member ClassLoader as the Package's internal parent classLoader
* which is Thread.currentThread.getContextClassLoader if not user specified
* @param in An input stream to the serialized package.
- */
+ */
public void addPackage(InputStream in) {
addPackage(in, this.classLoader);
}
@@ -70,15 +70,15 @@
/**
* This will add the BINARY package to the rulebase.
* @param in An input stream to the serialized package.
- * @param optional classLoader used as the parent ClassLoader for the Package's internal ClassLaoder
- */
+ * @param classLoader used as the parent ClassLoader for the Package's internal ClassLaoder
+ */
public void addPackage(InputStream in, ClassLoader classLoader) {
if ( classLoader == null ) {
classLoader = this.classLoader;
}
-
+
try {
- ObjectInputStream oin = new DroolsObjectInputStream( in, classLoader);
+ DroolsObjectInputStream oin = new DroolsObjectInputStream( in, classLoader);
Object opkg = oin.readObject();
if ( !(opkg instanceof Package) ) {
throw new IllegalArgumentException( "Can only add instances of org.drools.rule.Package to a rulebase instance." );
Modified: labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/util/ChainedProperties.java
===================================================================
--- labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/util/ChainedProperties.java 2008-03-20 18:57:07 UTC (rev 19163)
+++ labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/util/ChainedProperties.java 2008-03-20 19:32:10 UTC (rev 19164)
@@ -1,11 +1,14 @@
/**
- *
+ *
*/
package org.drools.util;
import java.io.File;
import java.io.IOException;
import java.io.Serializable;
+import java.io.Externalizable;
+import java.io.ObjectOutput;
+import java.io.ObjectInput;
import java.net.MalformedURLException;
import java.net.URL;
import java.util.ArrayList;
@@ -17,10 +20,14 @@
public class ChainedProperties
implements
- Serializable {
- private final List props;
- private final List defaultProps;
+ Externalizable {
+ private List props;
+ private List defaultProps;
+ public ChainedProperties() {
+
+ }
+
public ChainedProperties(String confFileName) {
this( null,
confFileName );
@@ -126,6 +133,16 @@
}
}
+ public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
+ props = (List)in.readObject();
+ defaultProps = (List)in.readObject();
+ }
+
+ public void writeExternal(ObjectOutput out) throws IOException {
+ out.writeObject(props);
+ out.writeObject(defaultProps);
+ }
+
private Enumeration getResources(String name,
ClassLoader classLoader) {
Enumeration enumeration = null;
Modified: labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/util/Entry.java
===================================================================
--- labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/util/Entry.java 2008-03-20 18:57:07 UTC (rev 19163)
+++ labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/util/Entry.java 2008-03-20 19:32:10 UTC (rev 19164)
@@ -1,13 +1,13 @@
/**
- *
+ *
*/
package org.drools.util;
-import java.io.Serializable;
+import java.io.Externalizable;
public interface Entry
extends
- Serializable {
+ Externalizable {
public void setNext(Entry next);
public Entry getNext();
Modified: labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/util/FactHandleIndexHashTable.java
===================================================================
--- labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/util/FactHandleIndexHashTable.java 2008-03-20 18:57:07 UTC (rev 19163)
+++ labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/util/FactHandleIndexHashTable.java 2008-03-20 19:32:10 UTC (rev 19164)
@@ -1,5 +1,5 @@
/**
- *
+ *
*/
package org.drools.util;
@@ -8,9 +8,14 @@
import org.drools.reteoo.ReteTuple;
import org.drools.util.TupleIndexHashTable.FieldIndexEntry;
+import java.io.ObjectInput;
+import java.io.IOException;
+import java.io.ObjectOutput;
+import java.io.Externalizable;
+
public class FactHandleIndexHashTable extends AbstractHashTable
implements
- FactHandleMemory {
+ FactHandleMemory, Externalizable {
private static final long serialVersionUID = 400L;
@@ -24,6 +29,9 @@
private Index index;
+ public FactHandleIndexHashTable() {
+ }
+
public FactHandleIndexHashTable(final FieldIndex[] index) {
this( 16,
0.75f,
@@ -61,6 +69,22 @@
}
}
+ public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
+ super.readExternal(in);
+ startResult = in.readInt();
+ tupleValueIterator = (FieldIndexHashTableIterator)in.readObject();
+ factSize = in.readInt();
+ index = (Index)in.readObject();
+ }
+
+ public void writeExternal(ObjectOutput out) throws IOException {
+ super.writeExternal(out);
+ out.writeInt(startResult);
+ out.writeObject(tupleValueIterator);
+ out.writeInt(factSize);
+ out.writeObject(index);
+ }
+
public Iterator iterator() {
throw new UnsupportedOperationException( "FieldIndexHashTable does not support iterator()" );
}
@@ -77,7 +101,7 @@
public boolean isIndexed() {
return true;
}
-
+
public Index getIndex() {
return this.index;
}
@@ -96,13 +120,21 @@
*/
public static class FieldIndexHashTableIterator
implements
- Iterator {
+ Iterator, Externalizable {
private Entry entry;
public FieldIndexHashTableIterator() {
}
+ public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
+ entry = (Entry)in.readObject();
+ }
+
+ public void writeExternal(ObjectOutput out) throws IOException {
+ out.writeObject(entry);
+ }
+
/* (non-Javadoc)
* @see org.drools.util.Iterator#next()
*/
@@ -119,7 +151,7 @@
this.entry = entry;
}
}
-
+
public Entry[] toArray() {
Entry[] result = new Entry[this.factSize];
int index = 0;
@@ -130,12 +162,12 @@
while ( entry != null ) {
result[index++] = entry;
entry = entry.getNext();
- }
+ }
fieldIndexEntry = ( FieldIndexEntry ) fieldIndexEntry.getNext();
}
}
return result;
- }
+ }
public boolean add(final InternalFactHandle handle) {
final FieldIndexEntry entry = getOrCreate( handle.getObject() );
@@ -157,7 +189,7 @@
final int index = indexOf( hashCode,
this.table.length );
- // search the table for the Entry, we need to track previous and next, so if the
+ // search the table for the Entry, we need to track previous and next, so if the
// Entry is empty after its had the FactEntry removed, we must remove it from the table
FieldIndexEntry previous = (FieldIndexEntry) this.table[index];
FieldIndexEntry current = previous;
@@ -228,7 +260,7 @@
/**
* We use this method to aviod to table lookups for the same hashcode; which is what we would have to do if we did
* a get and then a create if the value is null.
- *
+ *
* @param value
* @return
*/
@@ -273,15 +305,32 @@
private static final long serialVersionUID = 400L;
private Entry next;
private FactEntryImpl first;
- private final int hashCode;
+ private int hashCode;
private Index index;
+ public FieldIndexEntry() {
+
+ }
+
public FieldIndexEntry(final Index index,
final int hashCode) {
this.index = index;
this.hashCode = hashCode;
}
+ public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
+ next = (Entry)in.readObject();
+ first = (FactEntryImpl)in.readObject();
+ hashCode = in.readInt();
+ index = (Index)in.readObject();
+ }
+
+ public void writeExternal(ObjectOutput out) throws IOException {
+ out.writeObject(next);
+ out.writeObject(first);
+ out.writeInt(hashCode);
+ out.writeObject(index);
+ }
public Entry getNext() {
return this.next;
}
Modified: labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/util/LinkedList.java
===================================================================
--- labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/util/LinkedList.java 2008-03-20 18:57:07 UTC (rev 19163)
+++ labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/util/LinkedList.java 2008-03-20 19:32:10 UTC (rev 19164)
@@ -1,17 +1,20 @@
package org.drools.util;
-import java.io.Serializable;
+import java.io.Externalizable;
+import java.io.ObjectOutput;
+import java.io.ObjectInput;
+import java.io.IOException;
import java.util.NoSuchElementException;
/*
* Copyright 2005 JBoss Inc
- *
+ *
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -22,7 +25,7 @@
/**
* This is a simple linked linked implementation. Each node must implement </code>LinkedListNode<code> so that it references
* the node before and after it. This way a node can be removed without having to scan the list to find it. This class
- * does not provide an Iterator implementation as its designed for efficiency and not genericity. There are a number of
+ * does not provide an Iterator implementation as its designed for efficiency and not genericity. There are a number of
* ways to iterate the list.
* <p>
* Simple iterator:
@@ -30,7 +33,7 @@
* for ( LinkedListNode node = list.getFirst(); node != null; node = node.getNext() ) {
* }
* </pre>
- *
+ *
* Iterator that pops the first entry:
* <pre>
* for ( LinkedListNode node = list.removeFirst(); node != null; node = list.removeFirst() ) {
@@ -44,7 +47,7 @@
*/
public class LinkedList
implements
- Serializable {
+ Externalizable {
private static final long serialVersionUID = 400L;
private LinkedListNode firstNode;
@@ -61,10 +64,23 @@
this.iterator = new LinkedListIterator();
}
+ public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
+ firstNode = (LinkedListNode)in.readObject();
+ lastNode = (LinkedListNode)in.readObject();
+ size = in.readInt();
+ iterator = (LinkedListIterator)in.readObject();
+ }
+
+ public void writeExternal(ObjectOutput out) throws IOException {
+ out.writeObject(firstNode);
+ out.writeObject(lastNode);
+ out.writeInt(size);
+ out.writeObject(iterator);
+ }
/**
- * Add a <code>LinkedListNode</code> to the list. If the <code>LinkedList</code> is empty then the first and
+ * Add a <code>LinkedListNode</code> to the list. If the <code>LinkedList</code> is empty then the first and
* last nodes are set to the added node.
- *
+ *
* @param node
* The <code>LinkedListNode</code> to be added
*/
@@ -84,7 +100,7 @@
* Removes a <code>LinkedListNode</code> from the list. This works by attach the previous reference to the child reference.
* When the node to be removed is the first node it calls <code>removeFirst()</code>. When the node to be removed is the last node
* it calls <code>removeLast()</code>.
- *
+ *
* @param node
* The <code>LinkedListNode</code> to be removed.
*/
@@ -121,9 +137,9 @@
}
/**
- * Remove the first node from the list. The next node then becomes the first node. If this is the last
+ * Remove the first node from the list. The next node then becomes the first node. If this is the last
* node then both first and last node references are set to null.
- *
+ *
* @return
* The first <code>LinkedListNode</code>.
*/
@@ -175,9 +191,9 @@
}
/**
- * Remove the last node from the list. The previous node then becomes the last node. If this is the last
+ * Remove the last node from the list. The previous node then becomes the last node. If this is the last
* node then both first and last node references are set to null.
- *
+ *
* @return
* The first <code>LinkedListNode</code>.
*/
@@ -206,7 +222,7 @@
}
/**
- * Iterates the list removing all the nodes until there are no more nodes to remove.
+ * Iterates the list removing all the nodes until there are no more nodes to remove.
*/
public void clear() {
while ( removeFirst() != null ) {
@@ -266,10 +282,10 @@
* Returns a list iterator
* @return
*/
- public class LinkedListIterator
+ public static class LinkedListIterator
implements
Iterator,
- Serializable {
+ Externalizable {
private LinkedList list;
private LinkedListNode current;
@@ -286,17 +302,32 @@
this.current = this.current.getNext();
return node;
}
+
+ public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
+ list = (LinkedList)in.readObject();
+ current = (LinkedListNode)in.readObject();
+ }
+
+ public void writeExternal(ObjectOutput out) throws IOException {
+ out.writeObject(list);
+ out.writeObject(current);
+ }
+
}
public static class JavaUtilIterator
implements
java.util.Iterator,
- Serializable {
+ Externalizable {
private LinkedList list;
private LinkedListNode currentNode;
private LinkedListNode nextNode;
private boolean immutable;
+ public JavaUtilIterator() {
+
+ }
+
public JavaUtilIterator(final LinkedList list) {
this( list,
true );
@@ -309,6 +340,20 @@
this.immutable = immutable;
}
+ public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
+ list = (LinkedList)in.readObject();
+ currentNode = (LinkedListNode)in.readObject();
+ nextNode = (LinkedListNode)in.readObject();
+ immutable = in.readBoolean();
+ }
+
+ public void writeExternal(ObjectOutput out) throws IOException {
+ out.writeObject(list);
+ out.writeObject(currentNode);
+ out.writeObject(nextNode);
+ out.writeBoolean(immutable);
+ }
+
public boolean hasNext() {
return (this.nextNode != null);
}
Modified: labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/util/LinkedListEntry.java
===================================================================
--- labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/util/LinkedListEntry.java 2008-03-20 18:57:07 UTC (rev 19163)
+++ labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/util/LinkedListEntry.java 2008-03-20 19:32:10 UTC (rev 19164)
@@ -1,14 +1,18 @@
package org.drools.util;
+import java.io.ObjectOutput;
+import java.io.ObjectInput;
+import java.io.IOException;
+
/*
* Copyright 2005 JBoss Inc
- *
+ *
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -18,7 +22,7 @@
/**
* The idea behind <code>LinkedListNodeWrapper</code> is to be able to add
- * the same <code>LinkedListNode</code> to multiple <code>LinkedList</code>s
+ * the same <code>LinkedListNode</code> to multiple <code>LinkedList</code>s
* where the node can have different previous and next nodes in each list.
*/
public class LinkedListEntry extends AbstractBaseLinkedListNode {
@@ -26,10 +30,23 @@
private static final long serialVersionUID = 400L;
private Object object;
+ public LinkedListEntry() {
+ }
+
public LinkedListEntry(final Object object) {
this.object = object;
}
+ public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
+ super.readExternal(in);
+ object = in.readObject();
+ }
+
+ public void writeExternal(ObjectOutput out) throws IOException {
+ super.writeExternal(out);
+ out.writeObject(object);
+ }
+
public Object getObject() {
return this.object;
}
Modified: labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/util/LinkedListNode.java
===================================================================
--- labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/util/LinkedListNode.java 2008-03-20 18:57:07 UTC (rev 19163)
+++ labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/util/LinkedListNode.java 2008-03-20 19:32:10 UTC (rev 19164)
@@ -2,13 +2,13 @@
/*
* Copyright 2005 JBoss Inc
- *
+ *
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -16,19 +16,19 @@
* limitations under the License.
*/
-import java.io.Serializable;
+import java.io.Externalizable;
/**
* Items placed in a <code>LinkedList<code> must implement this interface .
- *
+ *
* @see LinkedList
- *
+ *
* @author <a href="mailto:mark.proctor at jboss.com">Mark Proctor</a>
* @author <a href="mailto:bob at werken.com">Bob McWhirter</a>
*/
public interface LinkedListNode
extends
- Serializable {
+ Externalizable {
/**
* Returns the next node
@@ -38,7 +38,7 @@
public LinkedListNode getNext();
/**
- * Sets the next node
+ * Sets the next node
* @param next
* The next LinkedListNode
*/
@@ -52,7 +52,7 @@
public LinkedListNode getPrevious();
/**
- * Sets the previous node
+ * Sets the previous node
* @param previous
* The previous LinkedListNode
*/
Modified: labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/util/ObjectHashMap.java
===================================================================
--- labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/util/ObjectHashMap.java 2008-03-20 18:57:07 UTC (rev 19163)
+++ labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/util/ObjectHashMap.java 2008-03-20 19:32:10 UTC (rev 19164)
@@ -1,12 +1,17 @@
/**
- *
+ *
*/
package org.drools.util;
import org.drools.util.AbstractHashTable.EqualityEquals;
-public class ObjectHashMap extends AbstractHashTable {
+import java.io.ObjectOutput;
+import java.io.ObjectInput;
+import java.io.IOException;
+import java.io.Externalizable;
+public class ObjectHashMap extends AbstractHashTable implements Externalizable {
+
private static final long serialVersionUID = 400L;
public ObjectHashMap() {
@@ -19,15 +24,15 @@
super( capacity,
loadFactor );
}
-
+
public ObjectHashMap(final Entry[] table) {
super( 0.75f, table);
- }
-
+ }
+
public ObjectHashMap(final float loadFactor,
- final Entry[] table) {
+ final Entry[] table) {
super(loadFactor, table);
- }
+ }
public Object put(final Object key,
final Object value) {
@@ -140,6 +145,10 @@
private Entry next;
+ public ObjectEntry() {
+
+ }
+
public ObjectEntry(final Object key,
final Object value,
final int hashCode) {
@@ -148,6 +157,20 @@
this.hashCode = hashCode;
}
+ public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
+ key = in.readObject();
+ value = in.readObject();
+ hashCode = in.readInt();
+ next = (Entry)in.readObject();
+ }
+
+ public void writeExternal(ObjectOutput out) throws IOException {
+ out.writeObject(key);
+ out.writeObject(value);
+ out.writeInt(hashCode);
+ out.writeObject(next);
+ }
+
public Object getValue() {
return this.value;
}
Modified: labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/util/ObjectHashSet.java
===================================================================
--- labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/util/ObjectHashSet.java 2008-03-20 18:57:07 UTC (rev 19163)
+++ labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/util/ObjectHashSet.java 2008-03-20 19:32:10 UTC (rev 19164)
@@ -1,10 +1,14 @@
/**
- *
+ *
*/
package org.drools.util;
import org.drools.util.AbstractHashTable.EqualityEquals;
+import java.io.ObjectInput;
+import java.io.IOException;
+import java.io.ObjectOutput;
+
public class ObjectHashSet extends AbstractHashTable {
private static final long serialVersionUID = 400L;
@@ -123,7 +127,7 @@
return this.table[index];
}
-
+
public Object[] toArray(Object[] objects) {
Iterator it = iterator();
int i = 0;
@@ -145,12 +149,27 @@
private Entry next;
+ public ObjectEntry() {
+
+ }
+
public ObjectEntry(final Object value,
final int hashCode) {
this.value = value;
this.hashCode = hashCode;
}
+ public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
+ value = in.readObject();
+ hashCode = in.readInt();
+ next = (Entry)in.readObject();
+ }
+
+ public void writeExternal(ObjectOutput out) throws IOException {
+ out.writeObject(value);
+ out.writeInt(hashCode);
+ out.writeObject(next);
+ }
public Object getValue() {
return this.value;
}
Copied: labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/util/ObjenesisFactory.java (from rev 19160, labs/jbossrules/dev_tags/before_righttuple_merge_20080320/drools-core/src/main/java/org/drools/util/ObjenesisFactory.java)
===================================================================
--- labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/util/ObjenesisFactory.java (rev 0)
+++ labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/util/ObjenesisFactory.java 2008-03-20 19:32:10 UTC (rev 19164)
@@ -0,0 +1,54 @@
+/*
+ * Copyright 2008 JBoss Inc
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * Created on Mar 17, 2008
+ */
+package org.drools.util;
+
+import java.io.Serializable;
+
+import org.drools.objenesis.Objenesis;
+import org.drools.objenesis.ObjenesisStd;
+
+/**
+ * A factory interface for Objenesis instances
+ *
+ * @author etirelli
+ */
+public class ObjenesisFactory implements Serializable {
+
+ private static final long serialVersionUID = 969174504278340793L;
+ private static Objenesis OBJENESIS_INSTANCE = null;
+
+ private ObjenesisFactory() {}
+
+ /**
+ * Returns a statically cached objenesis instance
+ */
+ public static Objenesis getStaticObjenesis() {
+ if( OBJENESIS_INSTANCE == null ) {
+ OBJENESIS_INSTANCE = new ObjenesisStd(true);
+ }
+ return OBJENESIS_INSTANCE;
+ }
+
+ /**
+ * Returns a newly instantiated objenesis instance
+ */
+ public static Objenesis getDefaultObjenesis() {
+ return new ObjenesisStd(true);
+ }
+
+}
Modified: labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/util/PrimitiveLongMap.java
===================================================================
--- labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/util/PrimitiveLongMap.java 2008-03-20 18:57:07 UTC (rev 19163)
+++ labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/util/PrimitiveLongMap.java 2008-03-20 19:32:10 UTC (rev 19164)
@@ -2,13 +2,13 @@
/*
* Copyright 2005 JBoss Inc
- *
+ *
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -17,35 +17,39 @@
*/
import java.io.Serializable;
+import java.io.Externalizable;
+import java.io.ObjectOutput;
+import java.io.IOException;
+import java.io.ObjectInput;
import java.util.Arrays;
import java.util.Collection;
/**
- *
+ *
* @author Mark Proctor
*/
public class PrimitiveLongMap
implements
- Serializable {
+ Externalizable {
/**
- *
+ *
*/
private static final long serialVersionUID = 400L;
private final static Object NULL = new Serializable() {
/**
- *
+ *
*/
private static final long serialVersionUID = 400L;
};
- private final int indexIntervals;
- private final int intervalShifts;
- private final int midIntervalPoint;
- private final int tableSize;
- private final int shifts;
- private final int doubleShifts;
+ private int indexIntervals;
+ private int intervalShifts;
+ private int midIntervalPoint;
+ private int tableSize;
+ private int shifts;
+ private int doubleShifts;
private Page firstPage;
private Page lastPage;
private int lastPageId;
@@ -94,6 +98,36 @@
init();
}
+ public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
+ indexIntervals = in.readInt();
+ intervalShifts = in.readInt();
+ midIntervalPoint = in.readInt();
+ tableSize = in.readInt();
+ shifts = in.readInt();
+ doubleShifts = in.readInt();
+ firstPage = (Page)in.readObject();
+ lastPage = (Page)in.readObject();
+ lastPageId = in.readInt();
+ maxKey = in.readLong();
+ pageIndex = (Page[])in.readObject();
+ totalSize = in.readInt();
+ }
+
+ public void writeExternal(ObjectOutput out) throws IOException {
+ out.writeInt(indexIntervals);
+ out.writeInt(intervalShifts);
+ out.writeInt(midIntervalPoint);
+ out.writeInt(tableSize);
+ out.writeInt(shifts);
+ out.writeInt(doubleShifts);
+ out.writeObject(firstPage);
+ out.writeObject(lastPage);
+ out.writeInt(lastPageId);
+ out.writeLong(maxKey);
+ out.writeObject(pageIndex);
+ out.writeInt(totalSize);
+ }
+
private void init() {
// instantiate the first page
// previous sibling of first page is null
@@ -175,7 +209,7 @@
}
return value;
}
-
+
/**
* gets the next populated key, after the given key position.
* @param key
@@ -184,7 +218,7 @@
public long getNext(long key) {
final int currentPageId = (int) key >> this.doubleShifts;
final int nextPageId = (int) (key+1) >> this.doubleShifts;
-
+
if ( currentPageId != nextPageId ) {
Page page = findPage( key + 1);
while ( page.isEmpty() ) {
@@ -194,15 +228,15 @@
} else {
key += 1;
}
-
+
while ( !containsKey( key ) && key <= this.maxKey ) {
key++;
}
-
+
if ( key > this.maxKey ) {
key -= 1;
}
-
+
return key;
}
@@ -315,22 +349,26 @@
return page;
}
- private static class Page
+ public static class Page
implements
- Serializable {
+ Externalizable {
/**
- *
+ *
*/
private static final long serialVersionUID = 400L;
- private final int pageSize;
- private final int pageId;
- private final int shifts;
- private final int tableSize;
+ private int pageSize;
+ private int pageId;
+ private int shifts;
+ private int tableSize;
private Page nextSibling;
private Page previousSibling;
private Object[][] tables;
private int filledSlots;
+ public Page() {
+
+ }
+
Page(final Page previousSibling,
final int pageId,
final int tableSize) {
@@ -354,6 +392,28 @@
this.pageSize = tableSize << this.shifts;
}
+ public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
+ pageSize = in.readInt();
+ pageId = in.readInt();
+ shifts = in.readInt();
+ tableSize = in.readInt();
+ nextSibling = (Page)in.readObject();
+ previousSibling = (Page)in.readObject();
+ tables = (Object[][])in.readObject();
+ filledSlots = in.readInt();
+ }
+
+ public void writeExternal(ObjectOutput out) throws IOException {
+ out.writeInt(pageSize);
+ out.writeInt(pageId);
+ out.writeInt(shifts);
+ out.writeInt(tableSize);
+ out.writeObject(nextSibling);
+ out.writeObject(previousSibling);
+ out.writeObject(tables);
+ out.writeInt(filledSlots);
+ }
+
public int getPageId() {
return this.pageId;
}
@@ -389,7 +449,7 @@
// tables[table][slot]
return this.tables[table][(int) key - offset];
- }
+ }
public Object put(long key,
final Object newValue) {
Modified: labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/util/PrimitiveLongStack.java
===================================================================
--- labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/util/PrimitiveLongStack.java 2008-03-20 18:57:07 UTC (rev 19163)
+++ labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/util/PrimitiveLongStack.java 2008-03-20 19:32:10 UTC (rev 19164)
@@ -2,13 +2,13 @@
/*
* Copyright 2005 JBoss Inc
- *
+ *
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -17,15 +17,19 @@
*/
import java.io.Serializable;
+import java.io.Externalizable;
+import java.io.ObjectInput;
+import java.io.IOException;
+import java.io.ObjectOutput;
public class PrimitiveLongStack
implements
- Serializable {
+ Externalizable {
/**
- *
+ *
*/
private static final long serialVersionUID = 400L;
- private final int tableSize;
+ private int tableSize;
private int currentPageId;
private Page currentPage;
@@ -33,6 +37,18 @@
this( 256 );
}
+ public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
+ tableSize = in.readInt();
+ currentPageId = in.readInt();
+ currentPage = (Page)in.readObject();
+ }
+
+ public void writeExternal(ObjectOutput out) throws IOException {
+ out.writeInt(tableSize);
+ out.writeInt(currentPageId);
+ out.writeObject(currentPage);
+ }
+
public PrimitiveLongStack(final int tableSize) {
this.tableSize = tableSize;
this.currentPageId = 0;
@@ -77,19 +93,23 @@
return this.currentPageId == 0 && this.currentPage.getPosition() == -1;
}
- private static final class Page
+ public static final class Page
implements
- Serializable {
+ Externalizable {
/**
- *
+ *
*/
private static final long serialVersionUID = 400L;
- private final int pageId;
+ private int pageId;
private Page nextSibling;
private Page previousSibling;
private long[] table;
private int lastKey;
+ public Page() {
+
+ }
+
Page(final Page previousSibling,
final int nodeId,
final int tableSize) {
@@ -105,6 +125,22 @@
this.table = new long[tableSize];
}
+ public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
+ pageId = in.readInt();
+ nextSibling = (Page)in.readObject();
+ previousSibling = (Page)in.readObject();
+ table = (long[])in.readObject();
+ lastKey = in.readInt();
+ }
+
+ public void writeExternal(ObjectOutput out) throws IOException {
+ out.writeInt(pageId);
+ out.writeObject(nextSibling);
+ out.writeObject(previousSibling);
+ out.writeObject(table);
+ out.writeInt(lastKey);
+ }
+
public int getNodeId() {
return this.pageId;
}
@@ -138,5 +174,6 @@
this.previousSibling = null;
this.table = null;
}
+
}
}
\ No newline at end of file
Modified: labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/util/TupleIndexHashTable.java
===================================================================
--- labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/util/TupleIndexHashTable.java 2008-03-20 18:57:07 UTC (rev 19163)
+++ labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/util/TupleIndexHashTable.java 2008-03-20 19:32:10 UTC (rev 19164)
@@ -1,5 +1,5 @@
/**
- *
+ *
*/
package org.drools.util;
@@ -7,6 +7,11 @@
import org.drools.reteoo.ReteTuple;
import org.drools.reteoo.TupleMemory;
+import java.io.ObjectOutput;
+import java.io.ObjectInput;
+import java.io.IOException;
+import java.io.Externalizable;
+
public class TupleIndexHashTable extends AbstractHashTable
implements
TupleMemory {
@@ -24,6 +29,9 @@
private Index index;
+ public TupleIndexHashTable() {
+ }
+
public TupleIndexHashTable(final FieldIndex[] index) {
this( 16,
0.75f,
@@ -61,6 +69,24 @@
}
}
+ public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
+ super.readExternal(in);
+ startResult = in.readInt();
+ tupleValueIterator = (FieldIndexHashTableIterator)in.readObject();
+ tupleValueFullIterator = (FieldIndexHashTableFullIterator)in.readObject();
+ factSize = in.readInt();
+ index = (Index)in.readObject();
+ }
+
+ public void writeExternal(ObjectOutput out) throws IOException {
+ super.writeExternal(out);
+ out.writeInt(startResult);
+ out.writeObject(tupleValueIterator);
+ out.writeObject(tupleValueFullIterator);
+ out.writeInt(factSize);
+ out.writeObject(index);
+ }
+
public Iterator iterator() {
if ( this.tupleValueFullIterator == null ) {
this.tupleValueFullIterator = new FieldIndexHashTableFullIterator( this );
@@ -81,7 +107,7 @@
public boolean isIndexed() {
return true;
}
-
+
public Index getIndex() {
return this.index;
}
@@ -100,13 +126,21 @@
*/
public static class FieldIndexHashTableIterator
implements
- Iterator {
+ Iterator, Externalizable {
private Entry entry;
public FieldIndexHashTableIterator() {
}
+ public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
+ entry = (Entry)in.readObject();
+ }
+
+ public void writeExternal(ObjectOutput out) throws IOException {
+ out.writeObject(entry);
+ }
+
/* (non-Javadoc)
* @see org.drools.util.Iterator#next()
*/
@@ -126,17 +160,36 @@
public static class FieldIndexHashTableFullIterator
implements
- Iterator {
+ Iterator, Externalizable {
private AbstractHashTable hashTable;
private Entry[] table;
private int row;
private int length;
private Entry entry;
+ public FieldIndexHashTableFullIterator() {
+
+ }
public FieldIndexHashTableFullIterator(final AbstractHashTable hashTable) {
this.hashTable = hashTable;
}
+ public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
+ hashTable = (AbstractHashTable)in.readObject();
+ table = (Entry[])in.readObject();
+ row = in.readInt();
+ length = in.readInt();
+ entry = (Entry)in.readObject();
+ }
+
+ public void writeExternal(ObjectOutput out) throws IOException {
+ out.writeObject(hashTable);
+ out.writeObject(table);
+ out.writeInt(row);
+ out.writeInt(length);
+ out.writeObject(entry);
+ }
+
/* (non-Javadoc)
* @see org.drools.util.Iterator#next()
*/
@@ -170,7 +223,7 @@
this.entry = null;
}
}
-
+
public Entry[] toArray() {
Entry[] result = new Entry[this.factSize];
int index = 0;
@@ -181,12 +234,12 @@
while ( entry != null ) {
result[index++] = entry;
entry = entry.getNext();
- }
+ }
fieldIndexEntry = ( FieldIndexEntry ) fieldIndexEntry.getNext();
}
}
return result;
- }
+ }
public void add(final ReteTuple tuple) {
final FieldIndexEntry entry = getOrCreate( tuple );
@@ -205,7 +258,7 @@
final int index = indexOf( hashCode,
this.table.length );
- // search the table for the Entry, we need to track previous and next, so if the
+ // search the table for the Entry, we need to track previous and next, so if the
// Entry is empty after its had the FactEntry removed, we must remove it from the table
FieldIndexEntry previous = (FieldIndexEntry) this.table[index];
FieldIndexEntry current = previous;
@@ -272,7 +325,7 @@
/**
* We use this method to aviod to table lookups for the same hashcode; which is what we would have to do if we did
* a get and then a create if the value is null.
- *
+ *
* @param value
* @return
*/
@@ -317,15 +370,32 @@
private static final long serialVersionUID = 400L;
private Entry next;
private ReteTuple first;
- private final int hashCode;
+ private int hashCode;
private Index index;
+ public FieldIndexEntry() {
+
+ }
public FieldIndexEntry(final Index index,
final int hashCode) {
this.index = index;
this.hashCode = hashCode;
}
+ public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
+ next = (Entry)in.readObject();
+ first = (ReteTuple)in.readObject();
+ hashCode = in.readInt();
+ index = (Index)in.readObject();
+ }
+
+ public void writeExternal(ObjectOutput out) throws IOException {
+ out.writeObject(next);
+ out.writeObject(first);
+ out.writeInt(hashCode);
+ out.writeObject(index);
+ }
+
public Entry getNext() {
return this.next;
}
Modified: labs/jbossrules/branches/temporal_rete/drools-core/src/test/java/org/drools/CheeseEqual.java
===================================================================
--- labs/jbossrules/branches/temporal_rete/drools-core/src/test/java/org/drools/CheeseEqual.java 2008-03-20 18:57:07 UTC (rev 19163)
+++ labs/jbossrules/branches/temporal_rete/drools-core/src/test/java/org/drools/CheeseEqual.java 2008-03-20 19:32:10 UTC (rev 19164)
@@ -1,16 +1,20 @@
package org.drools;
import java.io.Serializable;
+import java.io.Externalizable;
+import java.io.ObjectOutput;
+import java.io.IOException;
+import java.io.ObjectInput;
/*
* Copyright 2005 JBoss Inc
- *
+ *
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -20,14 +24,24 @@
public class CheeseEqual
implements
- Serializable {
+ Externalizable {
/**
- *
+ *
*/
private static final long serialVersionUID = 400L;
protected String type;
protected int price;
+ public void writeExternal(ObjectOutput out) throws IOException {
+ out.writeObject(type);
+ out.writeInt(price);
+ }
+
+ public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
+ type = (String)in.readObject();
+ price = in.readInt();
+ }
+
public CheeseEqual() {
}
Modified: labs/jbossrules/branches/temporal_rete/drools-core/src/test/java/org/drools/MockFactHandle.java
===================================================================
--- labs/jbossrules/branches/temporal_rete/drools-core/src/test/java/org/drools/MockFactHandle.java 2008-03-20 18:57:07 UTC (rev 19163)
+++ labs/jbossrules/branches/temporal_rete/drools-core/src/test/java/org/drools/MockFactHandle.java 2008-03-20 19:32:10 UTC (rev 19164)
@@ -1,14 +1,18 @@
package org.drools;
+import java.io.ObjectOutput;
+import java.io.IOException;
+import java.io.ObjectInput;
+
/*
* Copyright 2005 JBoss Inc
- *
+ *
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -20,11 +24,19 @@
implements
FactHandle {
/**
- *
+ *
*/
private static final long serialVersionUID = 400L;
private int id;
+
+ public void writeExternal(ObjectOutput out) throws IOException {
+ out.writeInt(id);
+ }
+ public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
+ id = in.readInt();
+ }
+
public MockFactHandle(final int id) {
this.id = id;
}
Modified: labs/jbossrules/branches/temporal_rete/drools-core/src/test/java/org/drools/TestWorkingMemoryEventListener.java
===================================================================
--- labs/jbossrules/branches/temporal_rete/drools-core/src/test/java/org/drools/TestWorkingMemoryEventListener.java 2008-03-20 18:57:07 UTC (rev 19163)
+++ labs/jbossrules/branches/temporal_rete/drools-core/src/test/java/org/drools/TestWorkingMemoryEventListener.java 2008-03-20 19:32:10 UTC (rev 19164)
@@ -2,13 +2,13 @@
/*
* Copyright 2005 JBoss Inc
- *
+ *
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -16,7 +16,10 @@
* limitations under the License.
*/
-import java.io.Serializable;
+import java.io.Externalizable;
+import java.io.ObjectOutput;
+import java.io.ObjectInput;
+import java.io.IOException;
import org.drools.event.ActivationCancelledEvent;
import org.drools.event.ActivationCreatedEvent;
@@ -29,10 +32,10 @@
public class TestWorkingMemoryEventListener
implements
WorkingMemoryEventListener,
- Serializable {
+ Externalizable {
/**
- *
+ *
*/
private static final long serialVersionUID = 400L;
public int asserted;
@@ -47,6 +50,26 @@
// intentionally left blank
}
+ public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
+ asserted = in.readInt();
+ modified = in.readInt();
+ retracted = in.readInt();
+ tested = in.readInt();
+ created = in.readInt();
+ cancelled = in.readInt();
+ fired = in.readInt();
+ }
+
+ public void writeExternal(ObjectOutput out) throws IOException {
+ out.writeInt(asserted);
+ out.writeInt(modified);
+ out.writeInt(retracted);
+ out.writeInt(tested);
+ out.writeInt(created);
+ out.writeInt(cancelled);
+ out.writeInt(fired);
+ }
+
public void objectInserted(final ObjectInsertedEvent event) {
this.asserted++;
}
Modified: labs/jbossrules/branches/temporal_rete/drools-core/src/test/java/org/drools/agent/RuleAgentTest.java
===================================================================
--- labs/jbossrules/branches/temporal_rete/drools-core/src/test/java/org/drools/agent/RuleAgentTest.java 2008-03-20 18:57:07 UTC (rev 19163)
+++ labs/jbossrules/branches/temporal_rete/drools-core/src/test/java/org/drools/agent/RuleAgentTest.java 2008-03-20 19:32:10 UTC (rev 19164)
@@ -250,7 +250,7 @@
RuleBase rb = ag.getRuleBase();
assertNotNull(rb);
- assertEquals(1, rb.getPackages().length);
+// assertEquals(1, rb.getPackages().length);
}
public void testCustomRuleBaseConfiguration() throws Exception {
Modified: labs/jbossrules/branches/temporal_rete/drools-core/src/test/java/org/drools/agent/RuleBaseAssemblerTest.java
===================================================================
--- labs/jbossrules/branches/temporal_rete/drools-core/src/test/java/org/drools/agent/RuleBaseAssemblerTest.java 2008-03-20 18:57:07 UTC (rev 19163)
+++ labs/jbossrules/branches/temporal_rete/drools-core/src/test/java/org/drools/agent/RuleBaseAssemblerTest.java 2008-03-20 19:32:10 UTC (rev 19164)
@@ -5,51 +5,54 @@
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
-import java.io.ObjectInputStream;
-import java.io.ObjectOutputStream;
+import java.io.ObjectInput;
+import java.io.ObjectOutput;
import org.drools.RuleBase;
import org.drools.RuleBaseFactory;
import org.drools.common.DroolsObjectInputStream;
+import org.drools.common.DroolsObjectOutputStream;
import org.drools.rule.Package;
import junit.framework.TestCase;
+import junit.framework.TestSuite;
+import junit.framework.Test;
public class RuleBaseAssemblerTest extends TestCase {
-
+
public void testAssemblePackages() throws Exception {
RuleBase rb = RuleBaseFactory.newRuleBase();
rb.addPackage( new Package("goober") );
-
+
Package p1 = new Package("p1");
-
+
File f = getTempDirectory();
-
+
File p1file = new File(f, "p1.pkg");
-
+
writePackage( p1, p1file );
-
+
Package p1_ = readPackage( p1file );
-
+
rb = RuleBaseFactory.newRuleBase();
rb.addPackage( p1_ );
-
-
+
+
}
public static Package readPackage(File p1file) throws IOException,
- FileNotFoundException,
- ClassNotFoundException {
- ObjectInputStream in = new DroolsObjectInputStream(new FileInputStream(p1file));
+ FileNotFoundException,
+ ClassNotFoundException {
+ ObjectInput in = new DroolsObjectInputStream(new FileInputStream(p1file));
Package p1_ = (Package) in.readObject();
in.close();
return p1_;
}
public static void writePackage(Package pkg, File p1file) throws IOException,
- FileNotFoundException {
- ObjectOutputStream out = new ObjectOutputStream(new FileOutputStream(p1file));
+ FileNotFoundException {
+ ObjectOutput out = new DroolsObjectOutputStream(new FileOutputStream(p1file));
out.writeObject( pkg );
out.flush(); out.close();
}
@@ -70,30 +73,48 @@
private static File tempDir() {
File tmp = new File(System.getProperty( "java.io.tmpdir" ));
-
+
return new File(tmp, "__temp_test_drools_packages");
}
-
+
public static boolean deleteDir(File dir) {
-
+
if (dir.isDirectory()) {
String[] children = dir.list();
- for (int i=0; i<children.length; i++) {
- boolean success = deleteDir(new File(dir, children[i]));
+ for (String child : children) {
+ boolean success = deleteDir(new File(dir, child));
if (!success) {
//throw new RuntimeException("Unable to delete !");
return false;
}
}
}
-
+
// The directory is now empty so delete it
return dir.delete();
}
public static void clearTempDirectory() {
deleteDir( tempDir() );
-
- }
-
+
+ }
+
+ /**
+ * Assembles and returns a test suite for
+ * all the test methods of this test case.
+ *
+ * @return a non-null test suite.
+ */
+ public static Test suite()
+ {
+ return new TestSuite(RuleBaseAssemblerTest.class);
+ }
+
+ /**
+ * Run the test case.
+ */
+ public static void main(String args[])
+ {
+ RuleBaseAssemblerTest.suite();
+ }
}
Modified: labs/jbossrules/branches/temporal_rete/drools-core/src/test/java/org/drools/agent/URLScannerTest.java
===================================================================
--- labs/jbossrules/branches/temporal_rete/drools-core/src/test/java/org/drools/agent/URLScannerTest.java 2008-03-20 18:57:07 UTC (rev 19163)
+++ labs/jbossrules/branches/temporal_rete/drools-core/src/test/java/org/drools/agent/URLScannerTest.java 2008-03-20 19:32:10 UTC (rev 19164)
@@ -33,6 +33,7 @@
DroolsObjectInputStream in = new DroolsObjectInputStream( new FileInputStream( f ) );
Package p_ = (Package) in.readObject();
+ in.close();
assertEquals( "x", p_.getName() );
}
Modified: labs/jbossrules/branches/temporal_rete/drools-core/src/test/java/org/drools/base/EvaluatorFactoryTest.java
===================================================================
--- labs/jbossrules/branches/temporal_rete/drools-core/src/test/java/org/drools/base/EvaluatorFactoryTest.java 2008-03-20 18:57:07 UTC (rev 19163)
+++ labs/jbossrules/branches/temporal_rete/drools-core/src/test/java/org/drools/base/EvaluatorFactoryTest.java 2008-03-20 19:32:10 UTC (rev 19164)
@@ -26,6 +26,9 @@
import java.util.Date;
import java.util.List;
import java.util.Locale;
+import java.io.ObjectOutput;
+import java.io.IOException;
+import java.io.ObjectInput;
import junit.framework.TestCase;
@@ -103,7 +106,6 @@
{Boolean.FALSE, "!=", "xyz", Boolean.FALSE},
{Boolean.FALSE, "!=", "true", Boolean.TRUE},
{Boolean.FALSE, "!=", "false", Boolean.FALSE}
-
};
runEvaluatorTest( data,
@@ -158,6 +160,10 @@
{"foo", "matches", ".*foo", Boolean.TRUE},
{"foo", "matches", "bar", Boolean.FALSE},
{null, "matches", ".*foo", Boolean.FALSE},
+ {"something", "matches", "something", Boolean.TRUE},
+ {"something", "matches", "hello ;=", Boolean.FALSE},
+ {"something", "not matches", "something", Boolean.FALSE},
+ {"something", "not matches", "hello ;=", Boolean.TRUE},
{"foo", "==", null, Boolean.FALSE},
{"foo", "!=", null, Boolean.TRUE},
{null, "==", null, Boolean.TRUE},
@@ -738,7 +744,7 @@
extractor,
null );
final ValueType coerced = evaluator.getCoercedValueType();
-
+
if ( coerced.isIntegerNumber() ) {
final LongVariableContextEntry context = new LongVariableContextEntry( extractor,
declaration,
@@ -831,6 +837,11 @@
private static final long serialVersionUID = 400L;
+ public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
+ }
+
+ public void writeExternal(ObjectOutput out) throws IOException {
+ }
public boolean getBooleanValue(InternalWorkingMemory workingMemory, final Object object) {
return object != null ? ((Boolean) object).booleanValue() : false;
}
Modified: labs/jbossrules/branches/temporal_rete/drools-core/src/test/java/org/drools/base/TemporalEvaluatorFactoryTest.java
===================================================================
--- labs/jbossrules/branches/temporal_rete/drools-core/src/test/java/org/drools/base/TemporalEvaluatorFactoryTest.java 2008-03-20 18:57:07 UTC (rev 19163)
+++ labs/jbossrules/branches/temporal_rete/drools-core/src/test/java/org/drools/base/TemporalEvaluatorFactoryTest.java 2008-03-20 19:32:10 UTC (rev 19164)
@@ -21,6 +21,9 @@
import java.util.Arrays;
import java.util.Collection;
import java.util.List;
+import java.io.IOException;
+import java.io.ObjectOutput;
+import java.io.ObjectInput;
import org.drools.RuntimeDroolsException;
import org.drools.base.evaluators.EvaluatorDefinition;
@@ -43,7 +46,7 @@
/**
* Test coverage for the temporal evaluators.
- *
+ *
* @author Tino Breddin
*/
public class TemporalEvaluatorFactoryTest extends TestCase {
@@ -130,7 +133,7 @@
EventFactHandle bar = new EventFactHandle(2, "bar", 1, 2, 2);
EventFactHandle drool = new EventFactHandle(1, "drool", 1, 5, 3);
- final Object[][] data = {
+ final Object[][] data = {
{ foo, "before", drool, Boolean.TRUE },
{ foo, "before", bar, Boolean.FALSE },
{ drool, "before", foo, Boolean.FALSE },
@@ -194,7 +197,7 @@
runEvaluatorTest(data, ValueType.OBJECT_TYPE);
}
-
+
public void testCoincides() {
registry
.addEvaluatorDefinition("org.drools.base.evaluators.CoincidesEvaluatorDefinition");
@@ -204,7 +207,7 @@
EventFactHandle drool = new EventFactHandle(1, "drool", 1, 2, 2);
EventFactHandle mole = new EventFactHandle(1, "mole", 1, 1, 2);
- final Object[][] data = {
+ final Object[][] data = {
{ foo, "coincides", bar, Boolean.TRUE },
{ foo, "coincides", drool, Boolean.FALSE },
{ foo, "coincides", mole, Boolean.FALSE },
@@ -272,8 +275,8 @@
evaluator);
checkEvaluatorMethodCachedLeft(valueType, extractor, row, evaluator);
checkEvaluatorMethodWithFieldValue(valueType, extractor, row, evaluator);
-
+
assertEquals(valueType, evaluator.getValueType());
}
@@ -435,10 +438,15 @@
}
}
- private static class MockExtractor implements FieldExtractor {
+ public static class MockExtractor implements FieldExtractor {
private static final long serialVersionUID = 400L;
+ public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
+ }
+
+ public void writeExternal(ObjectOutput out) throws IOException {
+ }
public boolean getBooleanValue(InternalWorkingMemory workingMemory,
final Object object) {
return object != null ? ((Boolean) object).booleanValue() : false;
Copied: labs/jbossrules/branches/temporal_rete/drools-core/src/test/java/org/drools/common/DroolsObjectIOTest.java (from rev 19160, labs/jbossrules/dev_tags/before_righttuple_merge_20080320/drools-core/src/test/java/org/drools/common/DroolsObjectIOTest.java)
===================================================================
--- labs/jbossrules/branches/temporal_rete/drools-core/src/test/java/org/drools/common/DroolsObjectIOTest.java (rev 0)
+++ labs/jbossrules/branches/temporal_rete/drools-core/src/test/java/org/drools/common/DroolsObjectIOTest.java 2008-03-20 19:32:10 UTC (rev 19164)
@@ -0,0 +1,144 @@
+package org.drools.common;
+
+import junit.framework.TestCase;
+
+import java.io.File;
+import java.io.ByteArrayOutputStream;
+import java.io.InputStream;
+import java.io.ObjectInput;
+import java.io.FileOutputStream;
+import java.io.FileInputStream;
+import java.io.Externalizable;
+import java.io.IOException;
+import java.io.ObjectOutput;
+import java.io.ByteArrayInputStream;
+import java.io.Serializable;
+import java.io.ObjectOutputStream;
+import java.io.ObjectInputStream;
+import java.net.URL;
+
+import org.drools.rule.GroupElement;
+import org.drools.rule.Package;
+
+/**
+ * Created by IntelliJ IDEA. User: SG0521861 Date: Mar 3, 2008 Time: 11:19:44 AM To change this template use File |
+ * Settings | File Templates.
+ */
+public class DroolsObjectIOTest extends TestCase {
+
+ private static final String TEST_FILE = "test.dat";
+ private static final GroupElement testGroupElement = new GroupElement();
+
+ static class Test implements Serializable {
+ String str = TEST_FILE;
+ }
+ public void testFileIO() throws Exception {
+ File file = new File(getClass().getResource("DroolsObjectIOTest.class").getFile());
+ ByteArrayOutputStream bytes = new ByteArrayOutputStream();
+ new ObjectOutputStream(bytes).writeObject(new Test());
+ Test t = (Test)new ObjectInputStream(new ByteArrayInputStream(bytes.toByteArray())).readObject();
+ String str = TEST_FILE;
+ file = new File(file.getParent().replaceAll("%20", " "), str);
+
+ DroolsObjectOutputStream out = new DroolsObjectOutputStream(new FileOutputStream(file));
+
+ out.writeObject(testGroupElement);
+ out.flush();
+ out.close();
+
+ InputStream fis = getClass().getResourceAsStream(TEST_FILE);
+ System.out.println(fis.available());
+ ObjectInput ois = new DroolsObjectInputStream(fis);
+
+ GroupElement that = (GroupElement)ois.readObject();
+ assertEquals(that, testGroupElement);
+ }
+
+ public static class ExternalizableObject extends SerializableObject implements Externalizable {
+
+ public ExternalizableObject() {
+ super("ExternalizableObject");
+ }
+ public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
+ value = in.readInt();
+ name = (String)in.readObject();
+ }
+ public void writeExternal(ObjectOutput out) throws IOException {
+ out.writeInt(value);
+ out.writeObject(name);
+ }
+ }
+
+ public static class SerializableObject implements Serializable {
+ protected int value = 123;
+ protected String name;
+
+ public SerializableObject() {
+ this("SerializableObject");
+ }
+ public SerializableObject(String name) {
+ this.name = name;
+ }
+
+ public boolean equals(Object obj) {
+ if (obj instanceof SerializableObject) {
+ return value == ((SerializableObject)obj).value;
+ }
+ return false;
+ }
+ public String toString() {
+ return new StringBuilder(name).append('|').append(value).toString();
+ }
+ }
+
+ public void testObject() throws Exception {
+ SerializableObject obj = new ExternalizableObject();
+
+ byte[] buf = serialize(obj);
+ assertEquals(deserialize(buf), obj);
+
+ obj = new SerializableObject();
+ buf = serialize(obj);
+ assertEquals(deserialize(buf), obj);
+ }
+
+ private static Object deserialize(byte[] buf) throws Exception {
+ return new DroolsObjectInputStream(new ByteArrayInputStream(buf)).readObject();
+ }
+
+ private static byte[] serialize(Object obj) throws IOException {
+ ByteArrayOutputStream bytes = new ByteArrayOutputStream();
+ ObjectOutput out = new DroolsObjectOutputStream(bytes);
+
+ out.writeObject(obj);
+ out.flush();
+ out.close();
+
+ return bytes.toByteArray();
+ }
+
+ private static Object unmarshal(byte[] buf) throws Exception {
+ return new ObjectInputStream(new ByteArrayInputStream(buf)).readObject();
+ }
+
+ private static byte[] marshal(Object obj) throws IOException {
+ ByteArrayOutputStream bytes = new ByteArrayOutputStream();
+ ObjectOutput out = new ObjectOutputStream(bytes);
+
+ out.writeObject(obj);
+ out.flush();
+ out.close();
+
+ return bytes.toByteArray();
+ }
+
+ public void testStreaming() throws Exception {
+ Package pkg = new Package("test");
+
+ byte[] buf = marshal(pkg);
+ assertEquals(unmarshal(buf), pkg);
+
+ buf = serialize(pkg);
+ assertEquals(deserialize(buf), pkg);
+ }
+}
Modified: labs/jbossrules/branches/temporal_rete/drools-core/src/test/java/org/drools/event/AgendaEventSupportTest.java
===================================================================
--- labs/jbossrules/branches/temporal_rete/drools-core/src/test/java/org/drools/event/AgendaEventSupportTest.java 2008-03-20 18:57:07 UTC (rev 19163)
+++ labs/jbossrules/branches/temporal_rete/drools-core/src/test/java/org/drools/event/AgendaEventSupportTest.java 2008-03-20 19:32:10 UTC (rev 19164)
@@ -2,13 +2,13 @@
/*
* Copyright 2005 JBoss Inc
- *
+ *
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -17,6 +17,9 @@
*/
import java.io.Serializable;
+import java.io.ObjectOutput;
+import java.io.IOException;
+import java.io.ObjectInput;
import java.util.ArrayList;
import java.util.List;
@@ -98,6 +101,13 @@
public void evaluate(final KnowledgeHelper knowledgeHelper,
final WorkingMemory workingMemory) throws Exception {
}
+ public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
+
+ }
+
+ public void writeExternal(ObjectOutput out) throws IOException {
+
+ }
} );
pkg.addRule( rule );
rb.addPackage( pkg );
@@ -153,7 +163,7 @@
unwrapShadow( createdEvent.getActivation().getTuple().get( 0 ).getObject() ) );
agendaList.clear();
- // update results in a ActivationCancelledEvent and an ActivationCreatedEvent, note the object is always resolvable
+ // update results in a ActivationCancelledEvent and an ActivationCreatedEvent, note the object is always resolvable
cheddar.setPrice( 14 );
wm.update( cheddarHandle,
cheddar );
Modified: labs/jbossrules/branches/temporal_rete/drools-core/src/test/java/org/drools/event/RuleBaseEventListenerTest.java
===================================================================
--- labs/jbossrules/branches/temporal_rete/drools-core/src/test/java/org/drools/event/RuleBaseEventListenerTest.java 2008-03-20 18:57:07 UTC (rev 19163)
+++ labs/jbossrules/branches/temporal_rete/drools-core/src/test/java/org/drools/event/RuleBaseEventListenerTest.java 2008-03-20 19:32:10 UTC (rev 19164)
@@ -1,12 +1,12 @@
/*
* Copyright 2007 JBoss Inc
- *
+ *
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -39,6 +39,10 @@
import org.drools.spi.FieldValue;
import org.drools.spi.KnowledgeHelper;
+import java.io.ObjectOutput;
+import java.io.IOException;
+import java.io.ObjectInput;
+
/**
* @author etirelli
*
@@ -87,6 +91,13 @@
public void evaluate(final KnowledgeHelper knowledgeHelper,
final WorkingMemory workingMemory) throws Exception {
}
+ public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
+
+ }
+
+ public void writeExternal(ObjectOutput out) throws IOException {
+
+ }
} );
final Rule rule2 = new Rule( "test2" );
@@ -108,6 +119,13 @@
public void evaluate(final KnowledgeHelper knowledgeHelper,
final WorkingMemory workingMemory) throws Exception {
}
+ public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
+
+ }
+
+ public void writeExternal(ObjectOutput out) throws IOException {
+
+ }
} );
pkg = new Package( "org.drools.test1" );
@@ -216,11 +234,38 @@
private int beforeRuleRemoved = 0;
private int afterRuleRemoved = 0;
+ public TestRuleBaseListener() {
+ }
+
public TestRuleBaseListener(String id) {
super();
this.id = id;
}
+ public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
+ id = (String)in.readObject();
+ beforePackageAdded = in.readInt();
+ afterPackageAdded = in.readInt();
+ beforePackageRemoved = in.readInt();
+ afterPackageRemoved = in.readInt();
+ beforeRuleAdded = in.readInt();
+ afterRuleAdded = in.readInt();
+ beforeRuleRemoved = in.readInt();
+ afterRuleRemoved = in.readInt();
+ }
+
+ public void writeExternal(ObjectOutput out) throws IOException {
+ out.writeObject(id);
+ out.writeInt(beforePackageAdded);
+ out.writeInt(afterPackageAdded);
+ out.writeInt(beforePackageRemoved);
+ out.writeInt(afterPackageRemoved);
+ out.writeInt(beforeRuleAdded);
+ out.writeInt(afterRuleAdded);
+ out.writeInt(beforeRuleRemoved);
+ out.writeInt(afterRuleRemoved);
+ }
+
public void afterPackageAdded(AfterPackageAddedEvent event) {
// System.out.println( this.id + event );
this.afterPackageAdded++;
@@ -299,32 +344,32 @@
public void afterFunctionRemoved(AfterFunctionRemovedEvent event) {
// TODO Auto-generated method stub
-
+
}
public void afterRuleBaseLocked(AfterRuleBaseLockedEvent event) {
// TODO Auto-generated method stub
-
+
}
public void afterRuleBaseUnlocked(AfterRuleBaseUnlockedEvent event) {
// TODO Auto-generated method stub
-
+
}
public void beforeFunctionRemoved(BeforeFunctionRemovedEvent event) {
// TODO Auto-generated method stub
-
+
}
public void beforeRuleBaseLocked(BeforeRuleBaseLockedEvent event) {
// TODO Auto-generated method stub
-
+
}
public void beforeRuleBaseUnlocked(BeforeRuleBaseUnlockedEvent event) {
// TODO Auto-generated method stub
-
+
}
}
Modified: labs/jbossrules/branches/temporal_rete/drools-core/src/test/java/org/drools/examples/manners/BaseMannersTest.java
===================================================================
--- labs/jbossrules/branches/temporal_rete/drools-core/src/test/java/org/drools/examples/manners/BaseMannersTest.java 2008-03-20 18:57:07 UTC (rev 19163)
+++ labs/jbossrules/branches/temporal_rete/drools-core/src/test/java/org/drools/examples/manners/BaseMannersTest.java 2008-03-20 19:32:10 UTC (rev 19164)
@@ -2,13 +2,13 @@
/*
* Copyright 2005 JBoss Inc
- *
+ *
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -25,6 +25,8 @@
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.StringWriter;
+import java.io.ObjectOutput;
+import java.io.ObjectInput;
import java.util.ArrayList;
import java.util.List;
import java.util.Random;
@@ -144,15 +146,15 @@
* drools.assert( new Seating( count.getValue(), 1, true, 1, guestName, 1, guestName) );
* drools.assert( new Path( count.getValue(), 1, guestName ) );
* count.setCount( count.getValue() + 1 );
- *
+ *
* System.err.println( "seat 1 " + guest.getName() + " );
- *
+ *
* context.setPath( Context.ASSIGN_SEATS );
* }
- * }
+ * }
* </pre>
- *
- *
+ *
+ *
* @return
* @throws IntrospectionException
* @throws InvalidRuleException
@@ -237,7 +239,7 @@
context.setState( Context.ASSIGN_SEATS );
// drools.update( tuple.get( contextDeclaration ),
// context );
-
+
drools.modifyInsert( context );
System.err.println( "assign first seat : " + seating + " : " + path );
@@ -248,6 +250,13 @@
}
}
+ public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
+
+ }
+
+ public void writeExternal(ObjectOutput out) throws IOException {
+
+ }
};
rule.setConsequence( consequence );
@@ -264,16 +273,16 @@
* Sex rightGuestSex;
* Hobby rightGuestHobby;
* Count count;
- *
+ *
* when {
* context : Context( state == Context.ASSIGN_SEATS )
- * Seating( seatingId:id, seatingPid:pid, pathDone == true
+ * Seating( seatingId:id, seatingPid:pid, pathDone == true
* seatingRightSeat:rightSeat seatingRightGuestName:rightGuestName )
* Guest( name == seatingRightGuestName, rightGuestSex:sex, rightGuestHobby:hobby )
* Guest( leftGuestName:name , sex != rightGuestSex, hobby == rightGuestHobby )
- *
+ *
* count : Count()
- *
+ *
* not ( Path( id == seatingId, guestName == leftGuestName) )
* not ( Chosen( id == seatingId, guestName == leftGuestName, hobby == rightGuestHobby) )
* } then {
@@ -281,15 +290,15 @@
* drools.assert( new Seating( coung.getValue(), rightSeat, rightSeatName, leftGuestName, newSeat, countValue, id, false );
* drools.assert( new Path( countValue, leftGuestName, newSeat );
* drools.assert( new Chosen( id, leftGuestName, rightGuestHobby ) );
- *
+ *
* System.err.println( "seat " + rightSeat + " " + rightSeatName + " " + leftGuestName );
- *
+ *
* count.setCount( countValue + 1 );
* context.setPath( Context.MAKE_PATH );
* }
- * }
+ * }
* </pre>
- *
+ *
* @return
* @throws IntrospectionException
* @throws InvalidRuleException
@@ -459,7 +468,7 @@
// rightSeatName, leftGuestName, newSeat, countValue, id, false );
// drools.assert( new Path( countValue, leftGuestName, newSeat );
// drools.assert( new Chosen( id, leftGuestName, rightGuestHobby ) );
- //
+ //
// System.err.println( "seat " + rightSeat + " " + rightSeatName + " " +
// leftGuestName );
//
@@ -514,7 +523,7 @@
// drools.retractObject( tuple.getFactHandleForDeclaration( countDeclaration ) );
// } else {
// drools.update( tuple.getFactHandleForDeclaration( countDeclaration ),
- // count );
+ // count );
// }
drools.update( tuple.get( countDeclaration ),
@@ -531,6 +540,13 @@
throw new ConsequenceException( e );
}
}
+ public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
+
+ }
+
+ public void writeExternal(ObjectOutput out) throws IOException {
+
+ }
};
rule.setConsequence( consequence );
@@ -544,7 +560,7 @@
* Context context;
* int seatingId, seatingPid, pathSeat;
* String pathGuestName;
- *
+ *
* when {
* Context( state == Context.MAKE_PATH )
* Seating( seatingId:id, seatingPid:pid, pathDone == false )
@@ -552,11 +568,11 @@
* (not Path( id == seatingId, guestName == pathGuestName )
* } else {
* drools.assert( new Path( seatingId, pathSeat, pathGuestName ) );
- *
+ *
* }
- * }
+ * }
* </pre>
- *
+ *
* @return
* @throws IntrospectionException
* @throws InvalidRuleException
@@ -676,6 +692,13 @@
}
}
+ public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
+
+ }
+
+ public void writeExternal(ObjectOutput out) throws IOException {
+
+ }
};
rule.setConsequence( consequence );
@@ -684,20 +707,20 @@
}
/**
- *
+ *
* <pre>
- * rule pathDone() {
- * Context context; Seating seating;
- * when {
- * context : Context( state == Context.MAKE_PATH )
- * seating : Seating( pathDone == false )
- * } then {
- * seating.setPathDone( true );
- * context.setName( Context.CHECK_DONE );
- * }
+ * rule pathDone() {
+ * Context context; Seating seating;
+ * when {
+ * context : Context( state == Context.MAKE_PATH )
+ * seating : Seating( pathDone == false )
+ * } then {
+ * seating.setPathDone( true );
+ * context.setName( Context.CHECK_DONE );
+ * }
* }
* </pre>
- *
+ *
* @return
* @throws IntrospectionException
* @throws InvalidRuleException
@@ -770,6 +793,13 @@
}
}
+ public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
+
+ }
+
+ public void writeExternal(ObjectOutput out) throws IOException {
+
+ }
};
rule.setConsequence( consequence );
@@ -779,18 +809,18 @@
/**
* <pre>
- * rule areWeDone() {
- * Context context; LastSeat lastSear;
- * when {
- * context : Context( state == Context.CHECK_DONE )
+ * rule areWeDone() {
+ * Context context; LastSeat lastSear;
+ * when {
+ * context : Context( state == Context.CHECK_DONE )
* LastSeat( lastSeat: seat )
- * Seating( rightSeat == lastSeat )
- * } then {
- * context.setState(Context.PRINT_RESULTS );
- * }
+ * Seating( rightSeat == lastSeat )
+ * } then {
+ * context.setState(Context.PRINT_RESULTS );
+ * }
* }
* </pre>
- *
+ *
* @return
* @throws IntrospectionException
* @throws InvalidRuleException
@@ -863,6 +893,13 @@
}
}
+ public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
+
+ }
+
+ public void writeExternal(ObjectOutput out) throws IOException {
+
+ }
};
rule.setConsequence( consequence );
@@ -872,13 +909,13 @@
/**
* <pre>
- * rule continue() {
- * Context context;
- * when {
- * context : Context( state == Context.CHECK_DONE )
- * } then {
- * context.setState( Context.ASSIGN_SEATS );
- * }
+ * rule continue() {
+ * Context context;
+ * when {
+ * context : Context( state == Context.CHECK_DONE )
+ * } then {
+ * context.setState( Context.ASSIGN_SEATS );
+ * }
* }
* </pre>
* @return
@@ -928,6 +965,13 @@
}
}
+ public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
+
+ }
+
+ public void writeExternal(ObjectOutput out) throws IOException {
+
+ }
};
rule.setConsequence( consequence );
@@ -937,15 +981,15 @@
/**
* <pre>
- * rule all_done() {
- * Context context;
- * when {
- * context : Context( state == Context.PRINT_RESULTS )
+ * rule all_done() {
+ * Context context;
+ * when {
+ * context : Context( state == Context.PRINT_RESULTS )
* } then {
- * }
+ * }
* }
* </pre>
- *
+ *
* @return
* @throws IntrospectionException
* @throws InvalidRuleException
@@ -969,7 +1013,7 @@
final Declaration contextDeclaration = rule.getDeclaration( "context" );
// ------------
- //
+ //
// ------------
final Consequence consequence = new Consequence() {
@@ -982,6 +1026,13 @@
}
}
+ public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
+
+ }
+
+ public void writeExternal(ObjectOutput out) throws IOException {
+
+ }
};
rule.setConsequence( consequence );
Modified: labs/jbossrules/branches/temporal_rete/drools-core/src/test/java/org/drools/examples/manners/Chosen.java
===================================================================
--- labs/jbossrules/branches/temporal_rete/drools-core/src/test/java/org/drools/examples/manners/Chosen.java 2008-03-20 18:57:07 UTC (rev 19163)
+++ labs/jbossrules/branches/temporal_rete/drools-core/src/test/java/org/drools/examples/manners/Chosen.java 2008-03-20 19:32:10 UTC (rev 19164)
@@ -1,12 +1,12 @@
/*
* Copyright 2005 JBoss Inc
- *
+ *
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -16,13 +16,17 @@
package org.drools.examples.manners;
import java.io.Serializable;
+import java.io.Externalizable;
+import java.io.ObjectInput;
+import java.io.IOException;
+import java.io.ObjectOutput;
public class Chosen
implements
- Serializable {
+ Externalizable {
/**
- *
+ *
*/
private static final long serialVersionUID = 400L;
@@ -44,6 +48,18 @@
this.hobby = hobby;
}
+ public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
+ id = in.readInt();
+ guestName = (String)in.readObject();
+ hobby = (Hobby)in.readObject();
+ }
+
+ public void writeExternal(ObjectOutput out) throws IOException {
+ out.writeInt(id);
+ out.writeObject(guestName);
+ out.writeObject(hobby);
+ }
+
public int getId() {
return this.id;
}
Modified: labs/jbossrules/branches/temporal_rete/drools-core/src/test/java/org/drools/examples/manners/Context.java
===================================================================
--- labs/jbossrules/branches/temporal_rete/drools-core/src/test/java/org/drools/examples/manners/Context.java 2008-03-20 18:57:07 UTC (rev 19163)
+++ labs/jbossrules/branches/temporal_rete/drools-core/src/test/java/org/drools/examples/manners/Context.java 2008-03-20 19:32:10 UTC (rev 19164)
@@ -1,12 +1,12 @@
/*
* Copyright 2005 JBoss Inc
- *
+ *
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -15,14 +15,17 @@
*/
package org.drools.examples.manners;
-import java.io.Serializable;
+import java.io.Externalizable;
+import java.io.IOException;
+import java.io.ObjectInput;
+import java.io.ObjectOutput;
public class Context
implements
- Serializable {
+ Externalizable {
/**
- *
+ *
*/
private static final long serialVersionUID = 400L;
public static final int START_UP = 0;
@@ -50,6 +53,14 @@
this.state = state;
}
+ public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
+ state = in.readInt();
+ }
+
+ public void writeExternal(ObjectOutput out) throws IOException {
+ out.writeInt(state);
+ }
+
public void setState(final int state) {
this.state = state;
}
Modified: labs/jbossrules/branches/temporal_rete/drools-core/src/test/java/org/drools/examples/manners/Guest.java
===================================================================
--- labs/jbossrules/branches/temporal_rete/drools-core/src/test/java/org/drools/examples/manners/Guest.java 2008-03-20 18:57:07 UTC (rev 19163)
+++ labs/jbossrules/branches/temporal_rete/drools-core/src/test/java/org/drools/examples/manners/Guest.java 2008-03-20 19:32:10 UTC (rev 19164)
@@ -1,12 +1,12 @@
/*
* Copyright 2005 JBoss Inc
- *
+ *
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -15,13 +15,16 @@
*/
package org.drools.examples.manners;
-import java.io.Serializable;
+import java.io.Externalizable;
+import java.io.ObjectOutput;
+import java.io.ObjectInput;
+import java.io.IOException;
public class Guest
implements
- Serializable {
+ Externalizable {
/**
- *
+ *
*/
private static final long serialVersionUID = 400L;
@@ -42,6 +45,18 @@
this.hobby = hobby;
}
+ public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
+ name = (String)in.readObject();
+ sex = (Sex)in.readObject();
+ hobby = (Hobby)in.readObject();
+ }
+
+ public void writeExternal(ObjectOutput out) throws IOException {
+ out.writeObject(name);
+ out.writeObject(sex);
+ out.writeObject(hobby);
+ }
+
public String getName() {
return this.name;
}
Modified: labs/jbossrules/branches/temporal_rete/drools-core/src/test/java/org/drools/examples/manners/LastSeat.java
===================================================================
--- labs/jbossrules/branches/temporal_rete/drools-core/src/test/java/org/drools/examples/manners/LastSeat.java 2008-03-20 18:57:07 UTC (rev 19163)
+++ labs/jbossrules/branches/temporal_rete/drools-core/src/test/java/org/drools/examples/manners/LastSeat.java 2008-03-20 19:32:10 UTC (rev 19164)
@@ -1,12 +1,12 @@
/*
* Copyright 2005 JBoss Inc
- *
+ *
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -15,13 +15,16 @@
*/
package org.drools.examples.manners;
-import java.io.Serializable;
+import java.io.Externalizable;
+import java.io.ObjectInput;
+import java.io.IOException;
+import java.io.ObjectOutput;
public class LastSeat
implements
- Serializable {
+ Externalizable {
/**
- *
+ *
*/
private static final long serialVersionUID = 400L;
private int seat;
@@ -33,6 +36,14 @@
this.seat = seat;
}
+ public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
+ seat = in.readInt();
+ }
+
+ public void writeExternal(ObjectOutput out) throws IOException {
+ out.writeInt(seat);
+ }
+
public int getSeat() {
return this.seat;
}
Modified: labs/jbossrules/branches/temporal_rete/drools-core/src/test/java/org/drools/examples/manners/ReteooMannersTest.java
===================================================================
--- labs/jbossrules/branches/temporal_rete/drools-core/src/test/java/org/drools/examples/manners/ReteooMannersTest.java 2008-03-20 18:57:07 UTC (rev 19163)
+++ labs/jbossrules/branches/temporal_rete/drools-core/src/test/java/org/drools/examples/manners/ReteooMannersTest.java 2008-03-20 19:32:10 UTC (rev 19164)
@@ -65,7 +65,7 @@
};
//workingMemory.addEventListener(listener );
- final InputStream is = getClass().getResourceAsStream( "/manners32.dat" );
+ final InputStream is = getClass().getResourceAsStream( "/manners128.dat" );
final List list = getInputObjects( is );
for ( final Iterator it = list.iterator(); it.hasNext(); ) {
final Object object = it.next();
Modified: labs/jbossrules/branches/temporal_rete/drools-core/src/test/java/org/drools/examples/manners/Seating.java
===================================================================
--- labs/jbossrules/branches/temporal_rete/drools-core/src/test/java/org/drools/examples/manners/Seating.java 2008-03-20 18:57:07 UTC (rev 19163)
+++ labs/jbossrules/branches/temporal_rete/drools-core/src/test/java/org/drools/examples/manners/Seating.java 2008-03-20 19:32:10 UTC (rev 19164)
@@ -1,12 +1,12 @@
/*
* Copyright 2005 JBoss Inc
- *
+ *
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -15,13 +15,16 @@
*/
package org.drools.examples.manners;
-import java.io.Serializable;
+import java.io.Externalizable;
+import java.io.IOException;
+import java.io.ObjectOutput;
+import java.io.ObjectInput;
public class Seating
implements
- Serializable {
+ Externalizable {
/**
- *
+ *
*/
private static final long serialVersionUID = 400L;
@@ -53,6 +56,27 @@
this.rightGuestName = rightGuestName;
}
+ public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
+ id = in.readInt();
+ pid = in.readInt();
+ leftSeat = in.readInt();
+ rightSeat = in.readInt();
+ leftGuestName = (String)in.readObject();
+ rightGuestName = (String)in.readObject();
+ pathDone = in.readBoolean();
+
+ }
+
+ public void writeExternal(ObjectOutput out) throws IOException {
+ out.writeInt(id);
+ out.writeInt(pid);
+ out.writeInt(leftSeat);
+ out.writeInt(rightSeat);
+ out.writeObject(leftGuestName);
+ out.writeObject(rightGuestName);
+ out.writeBoolean(pathDone);
+ }
+
public boolean isPathDone() {
return this.pathDone;
}
Copied: labs/jbossrules/branches/temporal_rete/drools-core/src/test/java/org/drools/integrationtests (from rev 19160, labs/jbossrules/dev_tags/before_righttuple_merge_20080320/drools-core/src/test/java/org/drools/integrationtests)
Deleted: labs/jbossrules/branches/temporal_rete/drools-core/src/test/java/org/drools/integrationtests/SerializationHelper.java
===================================================================
--- labs/jbossrules/dev_tags/before_righttuple_merge_20080320/drools-core/src/test/java/org/drools/integrationtests/SerializationHelper.java 2008-03-20 15:24:55 UTC (rev 19160)
+++ labs/jbossrules/branches/temporal_rete/drools-core/src/test/java/org/drools/integrationtests/SerializationHelper.java 2008-03-20 19:32:10 UTC (rev 19164)
@@ -1,29 +0,0 @@
-package org.drools.integrationtests;
-
-import org.drools.common.DroolsObjectOutputStream;
-import org.drools.common.DroolsObjectInputStream;
-
-import java.io.ByteArrayOutputStream;
-import java.io.IOException;
-import java.io.ByteArrayInputStream;
-
-/**
- * Marshalling helper class to perform serialize/de-serialize a given object
- */
-public class SerializationHelper {
- public static <T> T serializeObject(T obj) throws IOException, ClassNotFoundException {
- return (T)serializeIn(serializeOut(obj));
- }
-
- public static byte[] serializeOut(Object obj) throws IOException {
- ByteArrayOutputStream out = new ByteArrayOutputStream();
- new DroolsObjectOutputStream(out).writeObject(obj);
- out.close();
- return out.toByteArray();
- }
-
- public static Object serializeIn(byte[] bytes)
- throws IOException, ClassNotFoundException {
- return new DroolsObjectInputStream(new ByteArrayInputStream(bytes)).readObject();
- }
-}
Copied: labs/jbossrules/branches/temporal_rete/drools-core/src/test/java/org/drools/integrationtests/SerializationHelper.java (from rev 19160, labs/jbossrules/dev_tags/before_righttuple_merge_20080320/drools-core/src/test/java/org/drools/integrationtests/SerializationHelper.java)
===================================================================
--- labs/jbossrules/branches/temporal_rete/drools-core/src/test/java/org/drools/integrationtests/SerializationHelper.java (rev 0)
+++ labs/jbossrules/branches/temporal_rete/drools-core/src/test/java/org/drools/integrationtests/SerializationHelper.java 2008-03-20 19:32:10 UTC (rev 19164)
@@ -0,0 +1,29 @@
+package org.drools.integrationtests;
+
+import org.drools.common.DroolsObjectOutputStream;
+import org.drools.common.DroolsObjectInputStream;
+
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+import java.io.ByteArrayInputStream;
+
+/**
+ * Marshalling helper class to perform serialize/de-serialize a given object
+ */
+public class SerializationHelper {
+ public static <T> T serializeObject(T obj) throws IOException, ClassNotFoundException {
+ return (T)serializeIn(serializeOut(obj));
+ }
+
+ public static byte[] serializeOut(Object obj) throws IOException {
+ ByteArrayOutputStream out = new ByteArrayOutputStream();
+ new DroolsObjectOutputStream(out).writeObject(obj);
+ out.close();
+ return out.toByteArray();
+ }
+
+ public static Object serializeIn(byte[] bytes)
+ throws IOException, ClassNotFoundException {
+ return new DroolsObjectInputStream(new ByteArrayInputStream(bytes)).readObject();
+ }
+}
Modified: labs/jbossrules/branches/temporal_rete/drools-core/src/test/java/org/drools/reteoo/AgendaTest.java
===================================================================
--- labs/jbossrules/branches/temporal_rete/drools-core/src/test/java/org/drools/reteoo/AgendaTest.java 2008-03-20 18:57:07 UTC (rev 19163)
+++ labs/jbossrules/branches/temporal_rete/drools-core/src/test/java/org/drools/reteoo/AgendaTest.java 2008-03-20 19:32:10 UTC (rev 19164)
@@ -2,13 +2,13 @@
/*
* Copyright 2005 JBoss Inc
- *
+ *
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -20,6 +20,9 @@
import java.util.HashMap;
import java.util.List;
import java.util.Map;
+import java.io.IOException;
+import java.io.ObjectOutput;
+import java.io.ObjectInput;
import org.drools.Agenda;
import org.drools.DroolsTestCase;
@@ -58,12 +61,12 @@
public class AgendaTest extends DroolsTestCase {
private InternalRuleBase ruleBase;
private BuildContext buildContext;
-
+
protected void setUp() throws Exception {
ruleBase = ( InternalRuleBase ) RuleBaseFactory.newRuleBase();
buildContext = new BuildContext( ruleBase, ((ReteooRuleBase)ruleBase).getReteooBuilder().getIdGenerator() );
}
-
+
public void testClearAgenda() {
final ReteooWorkingMemory workingMemory = (ReteooWorkingMemory) ruleBase.newStatefulSession();
@@ -77,12 +80,12 @@
rule1,
rule1.getLhs(),
buildContext );
-
+
final RuleTerminalNode node2 = new RuleTerminalNode( 5,
new MockTupleSource( 4 ),
rule2,
rule2.getLhs(),
- buildContext );
+ buildContext );
final ReteTuple tuple = new ReteTuple( new DefaultFactHandle( 1,
"cheese" ) );
@@ -96,7 +99,7 @@
// is itself
rule1.setConsequence( new org.drools.spi.Consequence() {
/**
- *
+ *
*/
private static final long serialVersionUID = 400L;
@@ -104,13 +107,20 @@
final WorkingMemory workingMemory) {
// do nothing
}
+ public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
+
+ }
+
+ public void writeExternal(ObjectOutput out) throws IOException {
+
+ }
} );
-
+
// Add consequence. Notice here the context here for the add to ageyunda
// is itself
rule2.setConsequence( new org.drools.spi.Consequence() {
/**
- *
+ *
*/
private static final long serialVersionUID = 400L;
@@ -118,42 +128,49 @@
final WorkingMemory workingMemory) {
// do nothing
}
- } );
+ public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
+ }
+
+ public void writeExternal(ObjectOutput out) throws IOException {
+
+ }
+ } );
+
assertEquals( 0,
agenda.getFocus().size() );
rule1.setNoLoop( false );
rule2.setDuration( 5000 );
-
+
node1.assertTuple( tuple,
context1,
workingMemory );
-
+
node2.assertTuple( tuple,
context1,
- workingMemory );
+ workingMemory );
// make sure we have an activation in the current focus
assertEquals( 1,
agenda.getFocus().size() );
-
+
assertEquals( 1,
agenda.getScheduledActivations().length );
-
+
agenda.clearAgenda();
assertEquals( 0,
agenda.getFocus().size() );
-
+
assertEquals( 0,
- agenda.getScheduledActivations().length );
+ agenda.getScheduledActivations().length );
}
public void testFilters() throws Exception {
final ReteooWorkingMemory workingMemory = (ReteooWorkingMemory) ruleBase.newStatefulSession();
-
+
final InternalAgenda agenda = (InternalAgenda) workingMemory.getAgenda();
final Rule rule = new Rule( "test-rule" );
@@ -167,7 +184,7 @@
// add consequence
rule.setConsequence( new org.drools.spi.Consequence() {
/**
- *
+ *
*/
private static final long serialVersionUID = 400L;
@@ -176,6 +193,13 @@
results.put( "fired",
new Boolean( true ) );
}
+ public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
+
+ }
+
+ public void writeExternal(ObjectOutput out) throws IOException {
+
+ }
} );
final ReteTuple tuple = new ReteTuple( new DefaultFactHandle( 1,
@@ -254,6 +278,13 @@
WorkingMemory workingMemory) {
// do nothing
}
+ public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
+
+ }
+
+ public void writeExternal(ObjectOutput out) throws IOException {
+
+ }
};
final ReteTuple tuple = new ReteTuple( new DefaultFactHandle( 1,
@@ -310,7 +341,7 @@
PropagationContext.ASSERTION,
rule3,
null );
-
+
final InternalAgenda agenda = (InternalAgenda) workingMemory.getAgenda();
// create the AgendaGroups
@@ -321,7 +352,7 @@
agenda.addAgendaGroup( agendaGroup2 );
final AgendaGroup agendaGroup3 = new BinaryHeapQueueAgendaGroup( "agendaGroup3", ruleBase );
- agenda.addAgendaGroup( agendaGroup3 );
+ agenda.addAgendaGroup( agendaGroup3 );
// focus at this point is MAIN
assertEquals( 0,
@@ -475,7 +506,7 @@
// create the consequence
final Consequence consequence = new Consequence() {
/**
- *
+ *
*/
private static final long serialVersionUID = 400L;
@@ -483,6 +514,13 @@
WorkingMemory workingMemory) {
// do nothing
}
+ public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
+
+ }
+
+ public void writeExternal(ObjectOutput out) throws IOException {
+
+ }
};
final ReteTuple tuple = new ReteTuple( new DefaultFactHandle( 1,
@@ -607,7 +645,7 @@
// create the consequence
final Consequence consequence = new Consequence() {
/**
- *
+ *
*/
private static final long serialVersionUID = 400L;
@@ -615,6 +653,13 @@
WorkingMemory workingMemory) {
list.add( knowledgeHelper.getRule() );
}
+ public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
+
+ }
+
+ public void writeExternal(ObjectOutput out) throws IOException {
+
+ }
};
final ReteTuple tuple = new ReteTuple( new DefaultFactHandle( 1,
@@ -695,7 +740,7 @@
assertEquals( 1,
activationGroup0.size() );
- // Assert another tuple and check it was added to activation-group-0
+ // Assert another tuple and check it was added to activation-group-0
node1.assertTuple( tuple,
context1,
workingMemory );
@@ -706,7 +751,7 @@
assertEquals( 2,
agenda.focusStackSize() );
- // The first tuple should fire, adding itself to the List and clearing and cancelling the other Activations in the activation-group-0
+ // The first tuple should fire, adding itself to the List and clearing and cancelling the other Activations in the activation-group-0
agenda.fireNextItem( null );
// Make sure the activation-group-0 is clear
@@ -779,7 +824,7 @@
}
- /**
+ /**
* Basic RuleFlowGroup test where there are three rules, each in their own
* RuleFlowGroup. First only rule-flow-group-0 is activated and rule0 is
* executed. When the two remaining groups are activated, the rule with the
@@ -797,7 +842,7 @@
// create the consequence
final Consequence consequence = new Consequence() {
/**
- *
+ *
*/
private static final long serialVersionUID = 400L;
@@ -805,6 +850,13 @@
WorkingMemory workingMemory) {
list.add( knowledgeHelper.getRule() );
}
+ public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
+
+ }
+
+ public void writeExternal(ObjectOutput out) throws IOException {
+
+ }
};
// create a rule for each rule flow groups
@@ -955,6 +1007,13 @@
WorkingMemory workingMemory) {
// do nothing
}
+ public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
+
+ }
+
+ public void writeExternal(ObjectOutput out) throws IOException {
+
+ }
};
final Rule rule1 = new Rule( "test-rule1" );
@@ -986,6 +1045,13 @@
context0,
workingMemory );
}
+ public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
+
+ }
+
+ public void writeExternal(ObjectOutput out) throws IOException {
+
+ }
};
final Rule rule0 = new Rule( "test-rule0" );
@@ -1020,7 +1086,7 @@
assertEquals( 1,
agenda.agendaSize() );
- // As we fire the rule, an new activation is created for rule1, and it should be added to group AND the agenda.
+ // As we fire the rule, an new activation is created for rule1, and it should be added to group AND the agenda.
agenda.fireNextItem( null );
assertEquals( 1,
ruleFlowGroup0.size() );
@@ -1054,6 +1120,13 @@
WorkingMemory workingMemory) {
// do nothing
}
+ public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
+
+ }
+
+ public void writeExternal(ObjectOutput out) throws IOException {
+
+ }
};
final Rule rule1 = new Rule( "test-rule1" );
@@ -1086,6 +1159,13 @@
context0,
workingMemory );
}
+ public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
+
+ }
+
+ public void writeExternal(ObjectOutput out) throws IOException {
+
+ }
};
final Rule rule0 = new Rule( "test-rule0" );
@@ -1138,7 +1218,7 @@
/**
* RuleFlowGroup test that makes sure that, when deactivating a RuleFlowGroup,
* all activations for that group are no longer on the agenda. When
- * reactivating the RuleFlowGroup however, they get added to the agenda again.
+ * reactivating the RuleFlowGroup however, they get added to the agenda again.
*/
public void testRuleFlowGroup3() {
final RuleBase ruleBase = RuleBaseFactory.newRuleBase();
@@ -1155,6 +1235,13 @@
WorkingMemory w) {
// do nothing
}
+ public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
+
+ }
+
+ public void writeExternal(ObjectOutput out) throws IOException {
+
+ }
};
final Rule rule0 = new Rule( "test-rule0" );
@@ -1193,7 +1280,7 @@
assertEquals( 0,
agenda.agendaSize() );
- // Activate the RuleFlowGroup, the activations stay in the group, but
+ // Activate the RuleFlowGroup, the activations stay in the group, but
// should now also be in the Agenda
agenda.activateRuleFlowGroup( "rule-flow-group-0" );
assertEquals( 2,
@@ -1216,7 +1303,7 @@
assertEquals( 0,
agenda.agendaSize() );
- // Reactivate the RuleFlowGroup, the activations stay in the group, but
+ // Reactivate the RuleFlowGroup, the activations stay in the group, but
// should now also be in the Agenda again
agenda.activateRuleFlowGroup( "rule-flow-group-0" );
assertEquals( 2,
@@ -1227,7 +1314,7 @@
}
/**
- * Test auto-deactivation of RuleFlowGroup.
+ * Test auto-deactivation of RuleFlowGroup.
*/
public void testRuleFlowGroup4() {
ReteooRuleBase ruleBase = (ReteooRuleBase) RuleBaseFactory.newRuleBase();
@@ -1244,6 +1331,13 @@
WorkingMemory w) {
// do nothing
}
+ public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
+
+ }
+
+ public void writeExternal(ObjectOutput out) throws IOException {
+
+ }
};
final Rule rule0 = new Rule( "test-rule0" );
@@ -1280,7 +1374,7 @@
assertEquals( 0,
agenda.agendaSize() );
- // Activate the RuleFlowGroup, the activations stay in the group, but
+ // Activate the RuleFlowGroup, the activations stay in the group, but
// should now also be in the Agenda
agenda.activateRuleFlowGroup( "rule-flow-group-0" );
assertEquals( 1,
@@ -1323,7 +1417,7 @@
workingMemory.executeQueuedActions();
assertFalse( ruleFlowGroup0.isActive() );
- // A new activation should now be added to the RuleFlowGroup but not to the agenda
+ // A new activation should now be added to the RuleFlowGroup but not to the agenda
final ReteTuple tuple2 = new ReteTuple( new DefaultFactHandle( 1,
"cheese" ) );
node0.assertTuple( tuple2,
@@ -1334,9 +1428,9 @@
assertEquals( 0,
agenda.agendaSize() );
}
-
+
/**
- * Test auto-deactivation of empty ruleflow group.
+ * Test auto-deactivation of empty ruleflow group.
*/
public void testRuleFlowGroup5() {
final RuleBase ruleBase = RuleBaseFactory.newRuleBase();
@@ -1353,6 +1447,13 @@
WorkingMemory w) {
// do nothing
}
+ public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
+
+ }
+
+ public void writeExternal(ObjectOutput out) throws IOException {
+
+ }
};
final Rule rule0 = new Rule( "test-rule0" );
@@ -1368,7 +1469,7 @@
assertEquals( 0,
agenda.agendaSize() );
- // Activate the RuleFlowGroup, the activations stay in the group, but
+ // Activate the RuleFlowGroup, the activations stay in the group, but
// should now also be in the Agenda
agenda.activateRuleFlowGroup( "rule-flow-group-0" );
assertEquals( 0,
@@ -1437,17 +1538,17 @@
assertEquals( 2,
ruleFlowGroup.size() );
}
-
+
public void testSequentialAgenda() {
RuleBaseConfiguration conf = new RuleBaseConfiguration();
conf.setSequential( true );
InternalRuleBase ruleBase = ( InternalRuleBase ) RuleBaseFactory.newRuleBase( conf );
-
+
// create the consequence
final Consequence consequence = new Consequence() {
/**
- *
+ *
*/
private static final long serialVersionUID = 400L;
@@ -1455,6 +1556,13 @@
WorkingMemory workingMemory) {
// do nothing
}
+ public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
+
+ }
+
+ public void writeExternal(ObjectOutput out) throws IOException {
+
+ }
};
final ReteTuple tuple = new ReteTuple( new DefaultFactHandle( 1,
@@ -1515,7 +1623,7 @@
PropagationContext.ASSERTION,
rule3,
null );
-
+
ruleBase.getAgendaGroupRuleTotals().put( "MAIN", new Integer( 100 ) );
ruleBase.getAgendaGroupRuleTotals().put( "agendaGroup1", new Integer( 10 ) );
ruleBase.getAgendaGroupRuleTotals().put( "agendaGroup2", new Integer( 1 ) );
@@ -1528,8 +1636,8 @@
agenda.addAgendaGroup( agendaGroup1 );
final AgendaGroup agendaGroup2 = new ArrayAgendaGroup( "agendaGroup2", ruleBase );
- agenda.addAgendaGroup( agendaGroup2 );
-
+ agenda.addAgendaGroup( agendaGroup2 );
+
// focus at this point is MAIN
assertEquals( 0,
agenda.focusStackSize() );
@@ -1602,7 +1710,7 @@
// agendaGroup2 now has 2 activations
assertEquals( 2,
agenda.getFocus().size() );
-
+
// check totalAgendaSize still works
assertEquals( 5,
agenda.agendaSize() );
@@ -1662,8 +1770,8 @@
assertEquals( 0,
agenda.getFocus().size() );
assertEquals( 0,
- agenda.agendaSize() );
-
+ agenda.agendaSize() );
+
}
}
Modified: labs/jbossrules/branches/temporal_rete/drools-core/src/test/java/org/drools/reteoo/BaseNodeTest.java
===================================================================
--- labs/jbossrules/branches/temporal_rete/drools-core/src/test/java/org/drools/reteoo/BaseNodeTest.java 2008-03-20 18:57:07 UTC (rev 19163)
+++ labs/jbossrules/branches/temporal_rete/drools-core/src/test/java/org/drools/reteoo/BaseNodeTest.java 2008-03-20 19:32:10 UTC (rev 19164)
@@ -2,13 +2,13 @@
/*
* Copyright 2005 JBoss Inc
- *
+ *
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -36,10 +36,13 @@
class MockBaseNode extends BaseNode {
/**
- *
+ *
*/
private static final long serialVersionUID = 400L;
+ public MockBaseNode() {
+ }
+
public MockBaseNode(final int id) {
super( id );
}
@@ -75,6 +78,12 @@
return true;
}
+ @Override
+ public void networkUpdated() {
+ // TODO Auto-generated method stub
+
+ }
+
}
}
\ No newline at end of file
Modified: labs/jbossrules/branches/temporal_rete/drools-core/src/test/java/org/drools/reteoo/CompositeObjectSinkAdapterTest.java
===================================================================
--- labs/jbossrules/branches/temporal_rete/drools-core/src/test/java/org/drools/reteoo/CompositeObjectSinkAdapterTest.java 2008-03-20 18:57:07 UTC (rev 19163)
+++ labs/jbossrules/branches/temporal_rete/drools-core/src/test/java/org/drools/reteoo/CompositeObjectSinkAdapterTest.java 2008-03-20 19:32:10 UTC (rev 19164)
@@ -1,6 +1,9 @@
package org.drools.reteoo;
import java.lang.reflect.Method;
+import java.io.IOException;
+import java.io.ObjectInput;
+import java.io.ObjectOutput;
import junit.framework.TestCase;
@@ -24,7 +27,7 @@
public class CompositeObjectSinkAdapterTest extends TestCase {
private ReteooRuleBase ruleBase;
private BuildContext buildContext;
-
+
private EqualityEvaluatorsDefinition equals = new EqualityEvaluatorsDefinition();
protected void setUp() throws Exception {
@@ -176,7 +179,7 @@
FieldExtractor extractor = ClassFieldExtractorCache.getInstance().getExtractor( Cheese.class,
"type",
this.getClass().getClassLoader() );
-
+
final LiteralConstraint lit = new LiteralConstraint( extractor,
equals.getEvaluator( ValueType.STRING_TYPE, Operator.EQUAL ),
new ObjectFieldImpl( "stilton" ) );
@@ -235,7 +238,7 @@
FieldExtractor extractor = ClassFieldExtractorCache.getInstance().getExtractor( Cheese.class,
"charType",
this.getClass().getClassLoader() );
-
+
final LiteralConstraint lit = new LiteralConstraint( extractor,
equals.getEvaluator( extractor.getValueType(), Operator.EQUAL ),
new LongFieldImpl( 65 ) ); // chars are handled as integers
@@ -279,12 +282,12 @@
//this should now be nicely hashed.
assertNotNull( ad.hashedSinkMap );
assertNull( ad.hashableSinks );
-
+
// test propagation
Cheese cheese = new Cheese();
cheese.setCharType( 'B' );
CompositeObjectSinkAdapter.HashKey hashKey = new CompositeObjectSinkAdapter.HashKey();
-
+
// should find this
hashKey.setValue( extractor.getIndex(),
cheese,
@@ -354,10 +357,15 @@
}
- static class MockExtractor
+ public static class MockExtractor
implements
FieldExtractor {
+ public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
+ }
+
+ public void writeExternal(ObjectOutput out) throws IOException {
+ }
public int getIndex() {
// Auto-generated method stub
return 0;
Modified: labs/jbossrules/branches/temporal_rete/drools-core/src/test/java/org/drools/reteoo/CrossProductTest.java
===================================================================
--- labs/jbossrules/branches/temporal_rete/drools-core/src/test/java/org/drools/reteoo/CrossProductTest.java 2008-03-20 18:57:07 UTC (rev 19163)
+++ labs/jbossrules/branches/temporal_rete/drools-core/src/test/java/org/drools/reteoo/CrossProductTest.java 2008-03-20 19:32:10 UTC (rev 19164)
@@ -2,13 +2,13 @@
/*
* Copyright 2005 JBoss Inc
- *
+ *
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -18,6 +18,9 @@
import java.util.ArrayList;
import java.util.List;
+import java.io.ObjectInput;
+import java.io.ObjectOutput;
+import java.io.IOException;
import junit.framework.TestCase;
@@ -63,7 +66,7 @@
rule.setConsequence( new Consequence() {
/**
- *
+ *
*/
private static final long serialVersionUID = 400L;
@@ -74,6 +77,13 @@
CrossProductTest.this.values.add( new String[]{s1, s2} );
}
+ public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
+
+ }
+
+ public void writeExternal(ObjectOutput out) throws IOException {
+
+ }
} );
this.pkg = new Package( "org.drools" );
Modified: labs/jbossrules/branches/temporal_rete/drools-core/src/test/java/org/drools/reteoo/LogicalAssertionTest.java
===================================================================
--- labs/jbossrules/branches/temporal_rete/drools-core/src/test/java/org/drools/reteoo/LogicalAssertionTest.java 2008-03-20 18:57:07 UTC (rev 19163)
+++ labs/jbossrules/branches/temporal_rete/drools-core/src/test/java/org/drools/reteoo/LogicalAssertionTest.java 2008-03-20 19:32:10 UTC (rev 19164)
@@ -2,13 +2,13 @@
/*
* Copyright 2005 JBoss Inc
- *
+ *
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -37,11 +37,15 @@
import org.drools.spi.KnowledgeHelper;
import org.drools.spi.PropagationContext;
+import java.io.ObjectOutput;
+import java.io.ObjectInput;
+import java.io.IOException;
+
public class LogicalAssertionTest extends DroolsTestCase {
private ReteooRuleBase ruleBase;
private BuildContext buildContext;
private EntryPointNode entryPoint;
-
+
protected void setUp() throws Exception {
ruleBase = ( ReteooRuleBase ) RuleBaseFactory.newRuleBase();
buildContext = new BuildContext( ruleBase, ((ReteooRuleBase)ruleBase).getReteooBuilder().getIdGenerator() );
@@ -50,7 +54,7 @@
buildContext );
this.entryPoint.attach();
}
-
+
public void testSingleLogicalRelationship() throws Exception {
IdGenerator idGenerator = ruleBase.getReteooBuilder().getIdGenerator();
@@ -77,7 +81,7 @@
final Consequence consequence = new Consequence() {
/**
- *
+ *
*/
private static final long serialVersionUID = 400L;
@@ -85,6 +89,13 @@
WorkingMemory workingMemory) {
// do nothing
}
+ public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
+
+ }
+
+ public void writeExternal(ObjectOutput out) throws IOException {
+
+ }
};
rule1.setConsequence( consequence );
@@ -180,7 +191,7 @@
final Consequence consequence = new Consequence() {
/**
- *
+ *
*/
private static final long serialVersionUID = 400L;
@@ -188,6 +199,13 @@
WorkingMemory workingMemory) {
// do nothing
}
+ public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
+
+ }
+
+ public void writeExternal(ObjectOutput out) throws IOException {
+
+ }
};
rule1.setConsequence( consequence );
@@ -226,9 +244,9 @@
logicalHandle1 = workingMemory.insert( logicalString1 );
logicalHandle2 = workingMemory.insert( logicalString2 );
- // If assert behavior in working memory is IDENTITY,
- // returned handles must not be the same
- if ( RuleBaseConfiguration.AssertBehaviour.IDENTITY == ((ReteooRuleBase) ruleBase).getConfiguration().getAssertBehaviour() ) {
+ // If assert behavior in working memory is IDENTITY,
+ // returned handles must not be the same
+ if ( RuleBaseConfiguration.AssertBehaviour.IDENTITY.equals(((ReteooRuleBase) ruleBase).getConfiguration().getAssertBehaviour() )) {
assertNotSame( logicalHandle1,
logicalHandle2 );
@@ -241,7 +259,7 @@
/**
* This tests that Stated asserts always take precedent
- *
+ *
* @throws Exception
*/
public void testStatedOverrideDiscard() throws Exception {
@@ -270,7 +288,7 @@
final Consequence consequence = new Consequence() {
/**
- *
+ *
*/
private static final long serialVersionUID = 400L;
@@ -278,6 +296,13 @@
WorkingMemory workingMemory) {
// do nothing
}
+ public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
+
+ }
+
+ public void writeExternal(ObjectOutput out) throws IOException {
+
+ }
};
rule1.setConsequence( consequence );
@@ -378,7 +403,7 @@
/**
* This tests that Stated asserts always take precedent
- *
+ *
* @throws Exception
*/
public void testStatedOverridePreserve() throws Exception {
@@ -388,9 +413,9 @@
RuleBaseConfiguration conf = new RuleBaseConfiguration();
conf.setLogicalOverride( LogicalOverride.PRESERVE );
ReteooRuleBase ruleBase = (ReteooRuleBase) RuleBaseFactory.newRuleBase(conf);
-
+
BuildContext buildContext = new BuildContext( ruleBase, ruleBase.getReteooBuilder().getIdGenerator() );
-
+
IdGenerator idGenerator = ruleBase.getReteooBuilder().getIdGenerator();
final Rete rete = ruleBase.getRete();
@@ -398,7 +423,7 @@
rete,
buildContext );
entryPoint.attach();
-
+
final ObjectTypeNode objectTypeNode = new ObjectTypeNode( idGenerator.getNextId(),
entryPoint,
new ClassObjectType( String.class ),
@@ -417,7 +442,7 @@
final Consequence consequence = new Consequence() {
/**
- *
+ *
*/
private static final long serialVersionUID = 400L;
@@ -425,6 +450,13 @@
WorkingMemory workingMemory) {
// do nothing
}
+ public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
+
+ }
+
+ public void writeExternal(ObjectOutput out) throws IOException {
+
+ }
};
rule1.setConsequence( consequence );
@@ -505,7 +537,7 @@
final Consequence consequence = new Consequence() {
/**
- *
+ *
*/
private static final long serialVersionUID = 400L;
@@ -513,6 +545,13 @@
WorkingMemory workingMemory) {
// do nothing
}
+ public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
+
+ }
+
+ public void writeExternal(ObjectOutput out) throws IOException {
+
+ }
};
// create the first activation which will justify the fact "logical"
@@ -607,7 +646,7 @@
final Consequence consequence = new Consequence() {
/**
- *
+ *
*/
private static final long serialVersionUID = 400L;
@@ -615,6 +654,13 @@
WorkingMemory workingMemory) {
// do nothing
}
+ public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
+
+ }
+
+ public void writeExternal(ObjectOutput out) throws IOException {
+
+ }
};
// Create first justifier
@@ -636,10 +682,10 @@
// Create the second justifer
final Rule rule2 = new Rule( "test-rule2" );
final RuleTerminalNode node2 = new RuleTerminalNode( idGenerator.getNextId(),
- new MockTupleSource( idGenerator.getNextId() ),
- rule2,
- rule2.getLhs(),
- buildContext );
+ new MockTupleSource( idGenerator.getNextId() ),
+ rule2,
+ rule2.getLhs(),
+ buildContext );
rule2.setConsequence( consequence );
final DefaultFactHandle handle2 = new DefaultFactHandle( 2,
@@ -709,8 +755,8 @@
/**
* This tests that when multiple not identical, but equals facts, are asserted
- * into WM, only when all are removed, a logical assert will succeed
- *
+ * into WM, only when all are removed, a logical assert will succeed
+ *
* @throws Exception
*/
public void testMultipleAssert() throws Exception {
@@ -739,7 +785,7 @@
final Consequence consequence = new Consequence() {
/**
- *
+ *
*/
private static final long serialVersionUID = 400L;
@@ -747,6 +793,13 @@
WorkingMemory workingMemory) {
// do nothing
}
+ public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
+
+ }
+
+ public void writeExternal(ObjectOutput out) throws IOException {
+
+ }
};
rule1.setConsequence( consequence );
@@ -778,13 +831,13 @@
rule1,
tuple1.getActivation() );
- // Checks that previous LogicalAssert failed
+ // Checks that previous LogicalAssert failed
assertNull( logicalHandle3 );
- // If assert behavior in working memory is IDENTITY,
- // we need to retract object 2 times before being able to
+ // If assert behavior in working memory is IDENTITY,
+ // we need to retract object 2 times before being able to
// succesfully logically assert a new fact
- if ( RuleBaseConfiguration.AssertBehaviour.IDENTITY == ((ReteooRuleBase) ruleBase).getConfiguration().getAssertBehaviour() ) {
+ if ( RuleBaseConfiguration.AssertBehaviour.IDENTITY.equals(((ReteooRuleBase) ruleBase).getConfiguration().getAssertBehaviour()) ) {
workingMemory.retract( statedHandle2 );
@@ -794,7 +847,7 @@
rule1,
tuple1.getActivation() );
- // Checks that previous LogicalAssert failed
+ // Checks that previous LogicalAssert failed
assertNull( logicalHandle3 );
}
@@ -813,7 +866,7 @@
}
/**
- * This test checks that truth maintenance is correctly maintained for modified objects
+ * This test checks that truth maintenance is correctly maintained for modified objects
*/
public void testMutableObject() {
// create a RuleBase with a single ObjectTypeNode we attach a
@@ -840,7 +893,7 @@
final Consequence consequence = new Consequence() {
/**
- *
+ *
*/
private static final long serialVersionUID = 400L;
@@ -848,6 +901,13 @@
WorkingMemory workingMemory) {
// do nothing
}
+ public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
+
+ }
+
+ public void writeExternal(ObjectOutput out) throws IOException {
+
+ }
};
rule1.setConsequence( consequence );
Modified: labs/jbossrules/branches/temporal_rete/drools-core/src/test/java/org/drools/reteoo/MockAccumulator.java
===================================================================
--- labs/jbossrules/branches/temporal_rete/drools-core/src/test/java/org/drools/reteoo/MockAccumulator.java 2008-03-20 18:57:07 UTC (rev 19163)
+++ labs/jbossrules/branches/temporal_rete/drools-core/src/test/java/org/drools/reteoo/MockAccumulator.java 2008-03-20 19:32:10 UTC (rev 19164)
@@ -1,12 +1,12 @@
/*
* Copyright 2005 JBoss Inc
- *
+ *
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -18,6 +18,9 @@
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
+import java.io.ObjectOutput;
+import java.io.ObjectInput;
+import java.io.IOException;
import org.drools.WorkingMemory;
import org.drools.common.InternalFactHandle;
@@ -27,7 +30,7 @@
/**
* A Mock accumulate object.
- *
+ *
* @author etirelli
*
*/
@@ -41,6 +44,17 @@
private List matchingObjects = Collections.EMPTY_LIST;
private WorkingMemory workingMemory = null;
+ public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
+ leftTuple = (Tuple)in.readObject();
+ matchingObjects = (List)in.readObject();
+ workingMemory = (WorkingMemory)in.readObject();
+ }
+
+ public void writeExternal(ObjectOutput out) throws IOException {
+ out.writeObject(leftTuple);
+ out.writeObject(matchingObjects);
+ out.writeObject(workingMemory);
+ }
public Tuple getLeftTuple() {
return this.leftTuple;
}
@@ -52,7 +66,7 @@
public WorkingMemory getWorkingMemory() {
return this.workingMemory;
}
-
+
public Object createContext() {
return this;
}
Modified: labs/jbossrules/branches/temporal_rete/drools-core/src/test/java/org/drools/reteoo/MockEvalCondition.java
===================================================================
--- labs/jbossrules/branches/temporal_rete/drools-core/src/test/java/org/drools/reteoo/MockEvalCondition.java 2008-03-20 18:57:07 UTC (rev 19163)
+++ labs/jbossrules/branches/temporal_rete/drools-core/src/test/java/org/drools/reteoo/MockEvalCondition.java 2008-03-20 19:32:10 UTC (rev 19164)
@@ -2,13 +2,13 @@
/*
* Copyright 2005 JBoss Inc
- *
+ *
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -22,10 +22,14 @@
import org.drools.spi.EvalExpression;
import org.drools.spi.Tuple;
+import java.io.ObjectOutput;
+import java.io.ObjectInput;
+import java.io.IOException;
+
public class MockEvalCondition extends EvalCondition {
/**
- *
+ *
*/
private static final long serialVersionUID = 400L;
@@ -33,10 +37,10 @@
private final EvalExpression expression = new EvalExpression() {
/**
- *
+ *
*/
private static final long serialVersionUID = 400L;
-
+
public Object createContext() { return null; }
public boolean evaluate(Tuple tuple,
@@ -45,6 +49,13 @@
Object context ) {
return MockEvalCondition.this.isAllowed.booleanValue();
}
+ public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
+
+ }
+
+ public void writeExternal(ObjectOutput out) throws IOException {
+
+ }
};
public MockEvalCondition(final boolean isAllowed) {
Modified: labs/jbossrules/branches/temporal_rete/drools-core/src/test/java/org/drools/reteoo/MockObjectSource.java
===================================================================
--- labs/jbossrules/branches/temporal_rete/drools-core/src/test/java/org/drools/reteoo/MockObjectSource.java 2008-03-20 18:57:07 UTC (rev 19163)
+++ labs/jbossrules/branches/temporal_rete/drools-core/src/test/java/org/drools/reteoo/MockObjectSource.java 2008-03-20 19:32:10 UTC (rev 19164)
@@ -16,15 +16,18 @@
* limitations under the License.
*/
-import java.util.ArrayList;
-import java.util.Iterator;
-import java.util.List;
-
import org.drools.common.BaseNode;
import org.drools.common.InternalFactHandle;
import org.drools.common.InternalWorkingMemory;
import org.drools.spi.PropagationContext;
+import java.io.IOException;
+import java.io.ObjectInput;
+import java.io.ObjectOutput;
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+
public class MockObjectSource extends ObjectSource {
/**
*
@@ -37,11 +40,28 @@
private List facts;
+ public MockObjectSource() {
+ }
+
public MockObjectSource(final int id) {
super( id );
this.facts = new ArrayList();
}
+ public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
+ super.readExternal(in);
+ attached = in.readInt();
+ updated = in.readInt();
+ facts = (List)in.readObject();
+ }
+
+ public void writeExternal(ObjectOutput out) throws IOException {
+ super.writeExternal(out);
+ out.writeInt(attached);
+ out.writeInt(updated);
+ out.writeObject(facts);
+ }
+
public void attach() {
this.attached++;
Modified: labs/jbossrules/branches/temporal_rete/drools-core/src/test/java/org/drools/reteoo/MockTupleSink.java
===================================================================
--- labs/jbossrules/branches/temporal_rete/drools-core/src/test/java/org/drools/reteoo/MockTupleSink.java 2008-03-20 18:57:07 UTC (rev 19163)
+++ labs/jbossrules/branches/temporal_rete/drools-core/src/test/java/org/drools/reteoo/MockTupleSink.java 2008-03-20 19:32:10 UTC (rev 19164)
@@ -159,4 +159,10 @@
}
+ @Override
+ public void networkUpdated() {
+ // TODO Auto-generated method stub
+
+ }
+
}
\ No newline at end of file
Modified: labs/jbossrules/branches/temporal_rete/drools-core/src/test/java/org/drools/reteoo/MockTupleSource.java
===================================================================
--- labs/jbossrules/branches/temporal_rete/drools-core/src/test/java/org/drools/reteoo/MockTupleSource.java 2008-03-20 18:57:07 UTC (rev 19163)
+++ labs/jbossrules/branches/temporal_rete/drools-core/src/test/java/org/drools/reteoo/MockTupleSource.java 2008-03-20 19:32:10 UTC (rev 19164)
@@ -64,4 +64,10 @@
}
+ @Override
+ public void networkUpdated() {
+ // TODO Auto-generated method stub
+
+ }
+
}
\ No newline at end of file
Modified: labs/jbossrules/branches/temporal_rete/drools-core/src/test/java/org/drools/reteoo/OtherwiseTest.java
===================================================================
--- labs/jbossrules/branches/temporal_rete/drools-core/src/test/java/org/drools/reteoo/OtherwiseTest.java 2008-03-20 18:57:07 UTC (rev 19163)
+++ labs/jbossrules/branches/temporal_rete/drools-core/src/test/java/org/drools/reteoo/OtherwiseTest.java 2008-03-20 19:32:10 UTC (rev 19164)
@@ -15,6 +15,10 @@
import junit.framework.TestCase;
+import java.io.IOException;
+import java.io.ObjectInput;
+import java.io.ObjectOutput;
+
/**
* This tests the "otherwise" feature.
* @author Michael Neale
@@ -67,7 +71,7 @@
}
/**
- * @TODO: this is a future to be implemented in the future
+ * @TODO: this is a future to be implemented in the future
* @throws Exception
*/
public void FIXME_testOtherwiseFiringWithOneRule() throws Exception {
@@ -92,7 +96,7 @@
}
/**
- * @TODO: this is a future to be implemented in the future
+ * @TODO: this is a future to be implemented in the future
* @throws Exception
*/
public void FIXME_testOtherwiseFiringMultipleRules() throws Exception {
@@ -125,7 +129,7 @@
private Rule getOtherwise(final String name) {
final Rule rule = new Rule( name );
final Pattern pat = new Pattern( 0,
- new ClassObjectType( Otherwise.class) );
+ new ClassObjectType( Otherwise.class) );
rule.addPattern( pat );
rule.setConsequence( new MockConsequence() );
return rule;
@@ -135,7 +139,7 @@
final Rule rule = new Rule( name );
final Pattern pat = new Pattern( 0,
- new ClassObjectType( TestBean.class ) );
+ new ClassObjectType( TestBean.class ) );
rule.addPattern( pat );
rule.setConsequence( new MockConsequence() );
@@ -154,6 +158,13 @@
this.fired = true;
}
+ public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
+
+ }
+
+ public void writeExternal(ObjectOutput out) throws IOException {
+
+ }
}
}
Modified: labs/jbossrules/branches/temporal_rete/drools-core/src/test/java/org/drools/reteoo/ReteooBuilderTest.java
===================================================================
--- labs/jbossrules/branches/temporal_rete/drools-core/src/test/java/org/drools/reteoo/ReteooBuilderTest.java 2008-03-20 18:57:07 UTC (rev 19163)
+++ labs/jbossrules/branches/temporal_rete/drools-core/src/test/java/org/drools/reteoo/ReteooBuilderTest.java 2008-03-20 19:32:10 UTC (rev 19164)
@@ -9,81 +9,92 @@
import junit.framework.TestCase;
+import java.io.IOException;
+import java.io.ObjectOutput;
+import java.io.ObjectInput;
+
public class ReteooBuilderTest extends TestCase {
-
+
public void testOrder() {
//ReteooBuilder
RuleBaseConfiguration conf = new RuleBaseConfiguration();
conf.setSequential( true );
ReteooRuleBase ruleBase = new ReteooRuleBase( conf );
ReteooBuilder builder = new ReteooBuilder( ruleBase );
-
-
+
+
final Consequence consequence = new Consequence() {
public void evaluate(KnowledgeHelper knowledgeHelper,
WorkingMemory workingMemory) throws Exception {
System.out.println( "Consequence!" );
}
- };
-
+ public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
+
+ }
+
+ public void writeExternal(ObjectOutput out) throws IOException {
+
+ }
+ };
+
Rule rule0 = new Rule( "rule0" );
rule0.setAgendaGroup( "group 0" );
rule0.setConsequence( consequence );
builder.addRule( rule0 );
-
+
Rule rule1 = new Rule( "rule1" );
rule1.setAgendaGroup( "group 0" );
rule1.setConsequence( consequence );
builder.addRule( rule1 );
-
+
Rule rule2 = new Rule( "rule2" );
rule2.setAgendaGroup( "group 1" );
rule2.setConsequence( consequence );
builder.addRule( rule2 );
-
+
Rule rule3 = new Rule( "rule3" );
rule3.setAgendaGroup( "group 0" );
rule3.setConsequence( consequence );
builder.addRule( rule3 );
Rule rule4 = new Rule( "rule4" );
- rule4.setAgendaGroup( "group 2" );
+ rule4.setAgendaGroup( "group 2" );
rule4.setConsequence( consequence );
builder.addRule( rule4 );
-
+
Rule rule5 = new Rule( "rule5" );
- rule5.setAgendaGroup( "group 1" );
+ rule5.setAgendaGroup( "group 1" );
rule5.setConsequence( consequence );
builder.addRule( rule5 );
-
+
Rule rule6 = new Rule( "rule6" );
rule6.setSalience( new SalienceInteger( 5 ) );
- rule6.setAgendaGroup( "group 2" );
+ rule6.setAgendaGroup( "group 2" );
rule6.setConsequence( consequence );
- builder.addRule( rule6 );
+ builder.addRule( rule6 );
Rule rule7 = new Rule( "rule7" );
rule7.setAgendaGroup( "group 0" );
rule7.setConsequence( consequence );
- builder.addRule( rule7 );
+ builder.addRule( rule7 );
Rule rule8 = new Rule( "rule8" );
rule8.setSalience( new SalienceInteger( 10 ) );
- rule8.setAgendaGroup( "group 2" );
+ rule8.setAgendaGroup( "group 2" );
rule8.setConsequence( consequence );
- builder.addRule( rule8 );
-
+ builder.addRule( rule8 );
+
builder.order();
-
+
assertEquals( 0, ((RuleTerminalNode) builder.getTerminalNodes( rule0 )[0]).getSequence() );
assertEquals( 1, ((RuleTerminalNode) builder.getTerminalNodes( rule1 )[0]).getSequence() );
- assertEquals( 0, ((RuleTerminalNode) builder.getTerminalNodes( rule2 )[0]).getSequence() );
+ assertEquals( 0, ((RuleTerminalNode) builder.getTerminalNodes( rule2 )[0]).getSequence() );
assertEquals( 2, ((RuleTerminalNode) builder.getTerminalNodes( rule3 )[0]).getSequence() );
assertEquals( 2, ((RuleTerminalNode) builder.getTerminalNodes( rule4 )[0]).getSequence() );
- assertEquals( 1, ((RuleTerminalNode) builder.getTerminalNodes( rule5 )[0]).getSequence() );
- assertEquals( 1, ((RuleTerminalNode) builder.getTerminalNodes( rule6 )[0]).getSequence() );
- assertEquals( 3, ((RuleTerminalNode) builder.getTerminalNodes( rule7 )[0]).getSequence() );
- assertEquals( 0, ((RuleTerminalNode) builder.getTerminalNodes( rule8 )[0]).getSequence() );
-
+ assertEquals( 1, ((RuleTerminalNode) builder.getTerminalNodes( rule5 )[0]).getSequence() );
+ assertEquals( 1, ((RuleTerminalNode) builder.getTerminalNodes( rule6 )[0]).getSequence() );
+ assertEquals( 3, ((RuleTerminalNode) builder.getTerminalNodes( rule7 )[0]).getSequence() );
+ assertEquals( 0, ((RuleTerminalNode) builder.getTerminalNodes( rule8 )[0]).getSequence() );
+
}
}
Modified: labs/jbossrules/branches/temporal_rete/drools-core/src/test/java/org/drools/reteoo/RuleFlowGroupTest.java
===================================================================
--- labs/jbossrules/branches/temporal_rete/drools-core/src/test/java/org/drools/reteoo/RuleFlowGroupTest.java 2008-03-20 18:57:07 UTC (rev 19163)
+++ labs/jbossrules/branches/temporal_rete/drools-core/src/test/java/org/drools/reteoo/RuleFlowGroupTest.java 2008-03-20 19:32:10 UTC (rev 19164)
@@ -2,13 +2,13 @@
/*
* Copyright 2005 JBoss Inc
- *
+ *
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -18,6 +18,9 @@
import java.util.ArrayList;
import java.util.List;
+import java.io.ObjectOutput;
+import java.io.ObjectInput;
+import java.io.IOException;
import org.drools.DroolsTestCase;
import org.drools.RuleBaseFactory;
@@ -69,7 +72,7 @@
// create the consequence
final Consequence consequence = new Consequence() {
/**
- *
+ *
*/
private static final long serialVersionUID = 400L;
@@ -77,6 +80,13 @@
WorkingMemory workingMemory) {
list.add( knowledgeHelper.getRule() );
}
+ public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
+
+ }
+
+ public void writeExternal(ObjectOutput out) throws IOException {
+
+ }
};
// create a rule for each rule flow groups
@@ -257,7 +267,7 @@
assertEquals( 1,
agenda.agendaSize() );
- // on firing the last activation the child rule flow groups should
+ // on firing the last activation the child rule flow groups should
// activate and thus repopulate the agenda
agenda.fireNextItem( null );
workingMemory.executeQueuedActions();
@@ -279,7 +289,7 @@
assertEquals( 1,
agenda.agendaSize() );
- // executing rule1, which should activate AND-join and thus group 3
+ // executing rule1, which should activate AND-join and thus group 3
agenda.fireNextItem( null );
workingMemory.executeQueuedActions();
assertEquals( 0,
@@ -321,7 +331,7 @@
// create the consequence
final Consequence consequence = new Consequence() {
/**
- *
+ *
*/
private static final long serialVersionUID = 400L;
@@ -329,6 +339,13 @@
WorkingMemory workingMemory) {
list.add( knowledgeHelper.getRule() );
}
+ public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
+
+ }
+
+ public void writeExternal(ObjectOutput out) throws IOException {
+
+ }
};
// create a rule for each rule flow groups
@@ -567,7 +584,7 @@
assertEquals( 1,
agenda.agendaSize() );
- // executing group1, XOR join should activate group3
+ // executing group1, XOR join should activate group3
agenda.fireNextItem( null );
workingMemory.executeQueuedActions();
assertEquals( 0,
Modified: labs/jbossrules/branches/temporal_rete/drools-core/src/test/java/org/drools/reteoo/SchedulerTest.java
===================================================================
--- labs/jbossrules/branches/temporal_rete/drools-core/src/test/java/org/drools/reteoo/SchedulerTest.java 2008-03-20 18:57:07 UTC (rev 19163)
+++ labs/jbossrules/branches/temporal_rete/drools-core/src/test/java/org/drools/reteoo/SchedulerTest.java 2008-03-20 19:32:10 UTC (rev 19164)
@@ -2,13 +2,13 @@
/*
* Copyright 2005 JBoss Inc
- *
+ *
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -18,6 +18,9 @@
import java.util.ArrayList;
import java.util.List;
+import java.io.ObjectOutput;
+import java.io.IOException;
+import java.io.ObjectInput;
import org.drools.Agenda;
import org.drools.DroolsTestCase;
@@ -42,13 +45,13 @@
public class SchedulerTest extends DroolsTestCase {
private ReteooRuleBase ruleBase;
private BuildContext buildContext;
-
+
protected void setUp() throws Exception {
ruleBase = ( ReteooRuleBase ) RuleBaseFactory.newRuleBase();
buildContext = new BuildContext( ruleBase, ((ReteooRuleBase)ruleBase).getReteooBuilder().getIdGenerator() );
}
-
-
+
+
public void testScheduledActivation() throws Exception {
IdGenerator idGenerator = ruleBase.getReteooBuilder().getIdGenerator();
InternalWorkingMemory workingMemory = ( InternalWorkingMemory ) ruleBase.newStatefulSession();
@@ -64,7 +67,7 @@
// add consequence
rule.setConsequence( new org.drools.spi.Consequence() {
/**
- *
+ *
*/
private static final long serialVersionUID = 400L;
@@ -72,12 +75,19 @@
final WorkingMemory workingMemory) {
data.add( "tested" );
}
+ public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
+
+ }
+
+ public void writeExternal(ObjectOutput out) throws IOException {
+
+ }
} );
/* 1/10th of a second */
final Duration duration = new Duration() {
/**
- *
+ *
*/
private static final long serialVersionUID = 400L;
@@ -128,7 +138,7 @@
/* 1/10th of a second */
final Duration duration = new Duration() {
/**
- *
+ *
*/
private static final long serialVersionUID = 400L;
@@ -143,7 +153,7 @@
// add consequence
rule.setConsequence( new org.drools.spi.Consequence() {
/**
- *
+ *
*/
private static final long serialVersionUID = 400L;
@@ -163,6 +173,13 @@
}
data.add( "tested" );
}
+ public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
+
+ }
+
+ public void writeExternal(ObjectOutput out) throws IOException {
+
+ }
} );
final PropagationContext context1 = new PropagationContextImpl( 0,
@@ -208,7 +225,7 @@
/* 1/10th of a second */
final Duration duration = new Duration() {
/**
- *
+ *
*/
private static final long serialVersionUID = 400L;
@@ -224,7 +241,7 @@
// add consequence
rule.setConsequence( new org.drools.spi.Consequence() {
/**
- *
+ *
*/
private static final long serialVersionUID = 400L;
@@ -244,6 +261,13 @@
}
data.add( "tested" );
}
+ public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
+
+ }
+
+ public void writeExternal(ObjectOutput out) throws IOException {
+
+ }
} );
final PropagationContext context1 = new PropagationContextImpl( 0,
Modified: labs/jbossrules/branches/temporal_rete/drools-core/src/test/java/org/drools/reteoo/builder/ReteooRuleBuilderTest.java
===================================================================
--- labs/jbossrules/branches/temporal_rete/drools-core/src/test/java/org/drools/reteoo/builder/ReteooRuleBuilderTest.java 2008-03-20 18:57:07 UTC (rev 19163)
+++ labs/jbossrules/branches/temporal_rete/drools-core/src/test/java/org/drools/reteoo/builder/ReteooRuleBuilderTest.java 2008-03-20 19:32:10 UTC (rev 19164)
@@ -1,12 +1,12 @@
/*
* Copyright 2006 JBoss Inc
- *
+ *
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -17,6 +17,9 @@
package org.drools.reteoo.builder;
import java.util.List;
+import java.io.ObjectOutput;
+import java.io.ObjectInput;
+import java.io.IOException;
import junit.framework.Assert;
import junit.framework.TestCase;
@@ -85,6 +88,13 @@
System.out.println( "Consequence!" );
}
+ public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
+
+ }
+
+ public void writeExternal(ObjectOutput out) throws IOException {
+
+ }
};
rule.setConsequence( consequence );
Copied: labs/jbossrules/branches/temporal_rete/drools-core/src/test/java/org/drools/rule/EnumSerialiationTest.java (from rev 19160, labs/jbossrules/dev_tags/before_righttuple_merge_20080320/drools-core/src/test/java/org/drools/rule/EnumSerialiationTest.java)
===================================================================
--- labs/jbossrules/branches/temporal_rete/drools-core/src/test/java/org/drools/rule/EnumSerialiationTest.java (rev 0)
+++ labs/jbossrules/branches/temporal_rete/drools-core/src/test/java/org/drools/rule/EnumSerialiationTest.java 2008-03-20 19:32:10 UTC (rev 19164)
@@ -0,0 +1,20 @@
+package org.drools.rule;
+
+import junit.framework.TestCase;
+import org.drools.integrationtests.SerializationHelper;
+
+/**
+ * Created by IntelliJ IDEA. User: Ming Jin Date: Mar 19, 2008 Time: 11:11:45 AM To change this template use File |
+ * Settings | File Templates.
+ */
+public class EnumSerialiationTest extends TestCase {
+ private static final String TEST_NAME = "test name";
+
+ public void testTypeDeclaration() throws Exception {
+ TypeDeclaration typeDec1 = new TypeDeclaration(TEST_NAME);
+
+ TypeDeclaration typeDec2 = SerializationHelper.serializeObject(typeDec1);
+
+ assertEquals(typeDec1, typeDec2);
+ }
+}
Modified: labs/jbossrules/branches/temporal_rete/drools-core/src/test/java/org/drools/rule/FieldConstraintTest.java
===================================================================
--- labs/jbossrules/branches/temporal_rete/drools-core/src/test/java/org/drools/rule/FieldConstraintTest.java 2008-03-20 18:57:07 UTC (rev 19163)
+++ labs/jbossrules/branches/temporal_rete/drools-core/src/test/java/org/drools/rule/FieldConstraintTest.java 2008-03-20 19:32:10 UTC (rev 19164)
@@ -2,13 +2,13 @@
/*
* Copyright 2005 JBoss Inc
- *
+ *
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -17,6 +17,9 @@
*/
import java.beans.IntrospectionException;
+import java.io.ObjectInput;
+import java.io.ObjectOutput;
+import java.io.IOException;
import junit.framework.TestCase;
@@ -58,16 +61,16 @@
/**
* <pre>
- *
- *
+ *
+ *
* ( Cheese (type "cheddar") )
- *
- *
+ *
+ *
* </pre>
- *
+ *
* This is currently the same as using a ReturnValueConstraint just that it
* doesn't need any requiredDeclarations
- *
+ *
* @throws IntrospectionException
*/
public void testLiteralConstraint() throws IntrospectionException {
@@ -110,13 +113,13 @@
/**
* <pre>
- *
- *
+ *
+ *
* Cheese( price == 5 )
- *
- *
+ *
+ *
* </pre>
- *
+ *
* @throws IntrospectionException
*/
public void testPrimitiveLiteralConstraint() throws IntrospectionException {
@@ -159,14 +162,14 @@
/**
* <pre>
- *
- *
- * (Cheese (price ?price1 )
+ *
+ *
+ * (Cheese (price ?price1 )
* (Cheese (price ?price2&:(= ?price2 (* 2 ?price1) )
- *
- *
+ *
+ *
* </pre>
- *
+ *
* @throws IntrospectionException
*/
public void testPredicateConstraint() throws IntrospectionException {
@@ -198,7 +201,7 @@
final PredicateExpression evaluator = new PredicateExpression() {
/**
- *
+ *
*/
private static final long serialVersionUID = 400L;
@@ -221,6 +224,11 @@
return null;
}
+ public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
+ }
+
+ public void writeExternal(ObjectOutput out) throws IOException {
+ }
};
final PredicateConstraint constraint1 = new PredicateConstraint( evaluator,
@@ -249,15 +257,15 @@
/**
* <pre>
- *
- *
- * (Cheese (price ?price )
+ *
+ *
+ * (Cheese (price ?price )
* (Cheese (price =(* 2 ?price) )
* (Cheese (price >(* 2 ?price) )
- *
- *
+ *
+ *
* </pre>
- *
+ *
* @throws IntrospectionException
*/
public void testReturnValueConstraint() throws IntrospectionException {
@@ -279,7 +287,7 @@
final ReturnValueExpression isDoubleThePrice = new ReturnValueExpression() {
/**
- *
+ *
*/
private static final long serialVersionUID = 400L;
@@ -298,6 +306,13 @@
public Object createContext() {
return null;
}
+ public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
+
+ }
+
+ public void writeExternal(ObjectOutput out) throws IOException {
+
+ }
};
final ReturnValueRestriction restriction1 = new ReturnValueRestriction( priceExtractor,
@@ -355,16 +370,16 @@
/**
* <pre>
- *
- *
- * type == "cheddar" && price > 10
- *
- *
+ *
+ *
+ * type == "cheddar" && price > 10
+ *
+ *
* </pre>
- *
+ *
* Test the use of the composite AND constraint. Composite AND constraints are only
* used when nested inside other field constraints, as the top level AND is implicit
- *
+ *
* @throws IntrospectionException
*/
public void testCompositeAndConstraint() {
@@ -432,15 +447,15 @@
/**
* <pre>
- *
- *
- * Cheese( type == "cheddar" || price > 10 )
- *
- *
+ *
+ *
+ * Cheese( type == "cheddar" || price > 10 )
+ *
+ *
* </pre>
- *
- * Test the use of the composite OR constraint.
- *
+ *
+ * Test the use of the composite OR constraint.
+ *
* @throws IntrospectionException
*/
public void testCompositeOrConstraint() {
@@ -507,15 +522,15 @@
/**
* <pre>
- *
- *
- * Cheese( ( type == "cheddar" && price > 10) || ( type == "e;stilton"e; && price < 10 ) )
- *
- *
+ *
+ *
+ * Cheese( ( type == "cheddar" && price > 10) || ( type == "e;stilton"e; && price < 10 ) )
+ *
+ *
* </pre>
- *
- * Test the use of the composite OR constraint.
- *
+ *
+ * Test the use of the composite OR constraint.
+ *
* @throws IntrospectionException
*/
public void testNestedCompositeConstraints() {
Modified: labs/jbossrules/branches/temporal_rete/drools-core/src/test/java/org/drools/rule/LogicTransformerTest.java
===================================================================
--- labs/jbossrules/branches/temporal_rete/drools-core/src/test/java/org/drools/rule/LogicTransformerTest.java 2008-03-20 18:57:07 UTC (rev 19163)
+++ labs/jbossrules/branches/temporal_rete/drools-core/src/test/java/org/drools/rule/LogicTransformerTest.java 2008-03-20 19:32:10 UTC (rev 19164)
@@ -2,13 +2,13 @@
/*
* Copyright 2005 JBoss Inc
- *
+ *
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -19,34 +19,38 @@
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
-import java.io.ObjectInputStream;
-import java.io.ObjectOutputStream;
+import java.io.ObjectInput;
+import java.io.ObjectOutput;
+import java.util.Arrays;
+import java.net.URL;
import org.drools.DroolsTestCase;
+import org.drools.common.DroolsObjectOutputStream;
+import org.drools.common.DroolsObjectInputStream;
import org.drools.base.ClassObjectType;
import org.drools.spi.ObjectType;
public class LogicTransformerTest extends DroolsTestCase {
/**
* (a||b)&&c
- *
+ *
* <pre>
* and
* / \
- * or c
+ * or c
* / \
* a b
* </pre>
- *
+ *
* Should become (a&&c)||(b&&c)
- *
+ *
* <pre>
- *
+ *
* or
- * / \
- * / \
- * / \
- * and and
+ * / \
+ * / \
+ * / \
+ * and and
* / \ / \
* a c b c
* </pre>
@@ -99,19 +103,19 @@
/**
* (a||b)&&c
- *
+ *
* <pre>
* And
* /|\ \__
* _/ | \_ \_
- * / | \ \
+ * / | \ \
* or | or not
* / \ | / \ |
* a b c d e f
* </pre>
- *
+ *
* Should become (a&&c)||(b&&c)
- *
+ *
* <pre>
* /\
* _/ \_
@@ -237,28 +241,28 @@
/**
* This data structure is now valid
- *
+ *
* (Not (OR (A B) ) )
- *
+ *
* <pre>
* Not
- * |
- * or
+ * |
+ * or
* / \
* a b
* </pre>
- *
+ *
* Should become:
- *
+ *
* <pre>
* And
- * / \
- * Not Not
+ * / \
+ * Not Not
* | |
* a b
* </pre>
- *
- *
+ *
+ *
*/
public void testNotOrTransformation() throws InvalidPatternException {
final ObjectType type = new ClassObjectType( String.class );
@@ -301,21 +305,21 @@
/**
* This data structure is now valid (Exists (OR (A B) ) )
- *
+ *
* <pre>
* Exists
- * |
- * or
+ * |
+ * or
* / \
* a b
* </pre>
- *
+ *
* Should become:
- *
+ *
* <pre>
* Or
- * / \
- * Exists Exists
+ * / \
+ * Exists Exists
* | |
* a b
* </pre>
@@ -410,25 +414,25 @@
* <pre>
* _/|\_
* __/ | \__
- * / | \
+ * / | \
* __/ | \__
* / | \
* And and Not
* / | \ / \ |
* a And d e Or i
- * / \ / \
- * b Not h Exists
- * | |
- * Not g
- * |
- * c
+ * / \ / \
+ * b Not h Exists
+ * | |
+ * Not g
+ * |
+ * c
* </pre>
- *
+ *
* It is important to ensure that the order of
* the elements is not changed after transformation
- *
+ *
* <pre>
- * Or
+ * Or
* _/ \__
* __/ \___
* / \__
@@ -444,12 +448,12 @@
* | |
* c c
* </pre>
- *
+ *
* @throws IOException
* @throws ClassNotFoundException
- *
- *
- *
+ *
+ *
+ *
*/
public void testProcessTree() throws IOException,
ClassNotFoundException,
@@ -521,9 +525,9 @@
// Uncomment this when you need to output a new known correct tree
// result
-// writeTree( result,
-// "correct_processTree1.dat" );
- final ObjectInputStream ois = new ObjectInputStream( this.getClass().getResourceAsStream( "/correct_processTree1.dat" ) );
+ writeTree( result,
+ "correct_processTree1.dat" );
+ final ObjectInput ois = new DroolsObjectInputStream( this.getClass().getResourceAsStream( "correct_processTree1.dat" ));
final GroupElement[] correctResultRoot = (GroupElement[]) ois.readObject();
@@ -590,51 +594,51 @@
}
/**
- *
- *
+ *
+ *
* /**
- *
+ *
* <pre>
* _/|\_
* __/ | \__
- * / | \
+ * / | \
* __/ | \__
* / | \
* And or And
* / \ / \ / \
* a Or d e Not OR
- * / \ | / |
+ * / \ | / |
* b c f g Not
* |
* h
- *
- *
- *
+ *
+ *
+ *
* </pre>
- *
+ *
* Each And is a Rete sub rule
- *
+ *
* <pre>
- *
- *
- * And___ And___ And___ And___ And__ And___ And___ And___
- * ||| | \ ||| | \ ||| | \ ||| | \ ||| | \ ||| | \ ||| | \ ||| | \
+ *
+ *
+ * And___ And___ And___ And___ And__ And___ And___ And___
+ * ||| | \ ||| | \ ||| | \ ||| | \ ||| | \ ||| | \ ||| | \ ||| | \
* abd Not g abd Not Not abe Not g abe Not Not acd Not g acd Not Not ace Not g ace Not Not
- * | | | | | | | | | | | |
+ * | | | | | | | | | | | |
* f f h f f h f f h f f h
- *
- *
+ *
+ *
* </pre>
- *
+ *
* @throws IOException
* @throws ClassNotFoundException
- *
- *
- *
- *
+ *
+ *
+ *
+ *
* @throws IOException
* @throws ClassNotFoundException
- *
+ *
*/
public void testTransform() throws IOException,
ClassNotFoundException,
@@ -698,14 +702,14 @@
// Uncomment this when you need to output a new known correct tree
// result
-// writeTree( ands,
-// "correct_transform1.dat" );
+ writeTree( ands,
+ "correct_transform1.dat" );
// Now check the main tree
// Get known correct tree
// The binary stream was created from a handchecked correct output
- final ObjectInputStream ois = new ObjectInputStream( this.getClass().getResourceAsStream( "/correct_transform1.dat" ) );
+ final ObjectInput ois = new DroolsObjectInputStream( this.getClass().getResourceAsStream( "correct_transform1.dat" ) );
final GroupElement[] correctResultAnds = (GroupElement[]) ois.readObject();
for ( int j = 0; j < ands.length; j++ ) {
@@ -720,10 +724,13 @@
File file = new File( this.getClass().getResource( className.substring( className.lastIndexOf( '.' ) + 1 ) + ".class" ).getFile() );
- file = new File( file.getParent(),
- fileName );
+ file = new File( file.getParent().replaceAll("%20", " "), fileName );
- new ObjectOutputStream( new FileOutputStream( file ) ).writeObject( object );
+ ObjectOutput out = new DroolsObjectOutputStream(new FileOutputStream( file ) );
+
+ out.writeObject( object );
+ out.flush();
+ out.close();
}
}
\ No newline at end of file
Modified: labs/jbossrules/branches/temporal_rete/drools-core/src/test/java/org/drools/rule/PackageCompilationDataTest.java
===================================================================
--- labs/jbossrules/branches/temporal_rete/drools-core/src/test/java/org/drools/rule/PackageCompilationDataTest.java 2008-03-20 18:57:07 UTC (rev 19163)
+++ labs/jbossrules/branches/temporal_rete/drools-core/src/test/java/org/drools/rule/PackageCompilationDataTest.java 2008-03-20 19:32:10 UTC (rev 19164)
@@ -3,6 +3,8 @@
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.InputStream;
+import java.io.ObjectOutput;
+import java.io.ObjectInput;
import java.security.CodeSource;
import junit.framework.TestCase;
@@ -17,11 +19,18 @@
public boolean evaluate(Tuple t, Declaration[] d, WorkingMemory w, Object context ) {
return false;
}
+ public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
+
+ }
+
+ public void writeExternal(ObjectOutput out) throws IOException {
+
+ }
}
public void testCodeSourceUrl() throws IOException {
final String className = TestEvalExpression.class.getName();
-
+
final JavaDialectData pcData = new JavaDialectData( new DialectDatas(getClass().getClassLoader()) );
final EvalCondition invoker = new EvalCondition(null);
pcData.putInvoker(className, invoker);
Modified: labs/jbossrules/branches/temporal_rete/drools-core/src/test/java/org/drools/spi/MockConstraint.java
===================================================================
--- labs/jbossrules/branches/temporal_rete/drools-core/src/test/java/org/drools/spi/MockConstraint.java 2008-03-20 18:57:07 UTC (rev 19163)
+++ labs/jbossrules/branches/temporal_rete/drools-core/src/test/java/org/drools/spi/MockConstraint.java 2008-03-20 19:32:10 UTC (rev 19164)
@@ -2,13 +2,13 @@
/*
* Copyright 2005 JBoss Inc
- *
+ *
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -23,12 +23,16 @@
import org.drools.rule.ContextEntry;
import org.drools.rule.Declaration;
+import java.io.ObjectOutput;
+import java.io.IOException;
+import java.io.ObjectInput;
+
public class MockConstraint
implements
BetaNodeFieldConstraint {
/**
- *
+ *
*/
private static final long serialVersionUID = 400L;
@@ -36,6 +40,16 @@
public boolean isAllowed = true;
+ public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
+ declarations = (Declaration[])in.readObject();
+ isAllowed = in.readBoolean();
+ }
+
+ public void writeExternal(ObjectOutput out) throws IOException {
+ out.writeObject(declarations);
+ out.writeBoolean(isAllowed);
+ }
+
public boolean isAllowed(final InternalFactHandle handle,
final Tuple tuple,
final WorkingMemory workingMemory) {
@@ -45,7 +59,7 @@
public Declaration[] getRequiredDeclarations() {
return this.declarations;
}
-
+
public void replaceDeclaration(Declaration oldDecl,
Declaration newDecl) {
}
@@ -53,7 +67,7 @@
public Object clone() {
return this;
}
-
+
public ContextEntry createContextEntry() {
return new ContextEntry() {
private static final long serialVersionUID = 400L;
@@ -80,8 +94,15 @@
public void resetTuple() {
// TODO Auto-generated method stub
-
+
}
+ public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
+ next = (ContextEntry)in.readObject();
+ }
+
+ public void writeExternal(ObjectOutput out) throws IOException {
+ out.writeObject(next);
+ }
};
}
Modified: labs/jbossrules/branches/temporal_rete/drools-core/src/test/java/org/drools/spi/MockObjectType.java
===================================================================
--- labs/jbossrules/branches/temporal_rete/drools-core/src/test/java/org/drools/spi/MockObjectType.java 2008-03-20 18:57:07 UTC (rev 19163)
+++ labs/jbossrules/branches/temporal_rete/drools-core/src/test/java/org/drools/spi/MockObjectType.java 2008-03-20 19:32:10 UTC (rev 19164)
@@ -3,15 +3,19 @@
import org.drools.base.ClassObjectType;
import org.drools.base.ValueType;
+import java.io.ObjectOutput;
+import java.io.ObjectInput;
+import java.io.IOException;
+
/*
* Copyright 2005 JBoss Inc
- *
+ *
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -21,9 +25,9 @@
/**
* Java class semantics <code>ObjectType</code>.
- *
+ *
* @author <a href="mailto:bob at werken.com">bob at werken.com </a>
- *
+ *
* @version $Id: MockObjectType.java,v 1.1 2005/07/26 01:06:34 mproctor Exp $
*/
public class MockObjectType
@@ -34,21 +38,24 @@
// ------------------------------------------------------------
/**
- *
+ *
*/
private static final long serialVersionUID = 400L;
/** Java object class. */
private boolean matches;
-
+
private boolean isEvent;
// ------------------------------------------------------------
// Constructors
// ------------------------------------------------------------
+ public MockObjectType() {
+ this(true);
+ }
/**
* Construct.
- *
+ *
* @param objectTypeClass
* Java object class.
*/
@@ -56,6 +63,15 @@
this.matches = matches;
}
+ public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
+ matches = in.readBoolean();
+ isEvent = in.readBoolean();
+ }
+
+ public void writeExternal(ObjectOutput out) throws IOException {
+ out.writeBoolean(matches);
+ out.writeBoolean(isEvent);
+ }
// ------------------------------------------------------------
// Instance methods
// ------------------------------------------------------------
@@ -67,24 +83,24 @@
/**
* Determine if the passed <code>Object</code> belongs to the object type
* defined by this <code>objectType</code> instance.
- *
+ *
* @param object
* The <code>Object</code> to test.
- *
+ *
* @return <code>true</code> if the <code>Object</code> matches this
* object type, else <code>false</code>.
*/
public boolean matches(final Object object) {
return this.matches;
}
-
+
public boolean isAssignableFrom(Object object) {
return this.matches;
}
-
+
public boolean isAssignableFrom(ObjectType objectType) {
return this.matches;
- }
+ }
public ValueType getValueType() {
return ValueType.OBJECT_TYPE;
Modified: labs/jbossrules/branches/temporal_rete/drools-decisiontables/src/test/java/org/drools/decisiontable/parser/ExternalSheetListenerTest.java
===================================================================
--- labs/jbossrules/branches/temporal_rete/drools-decisiontables/src/test/java/org/drools/decisiontable/parser/ExternalSheetListenerTest.java 2008-03-20 18:57:07 UTC (rev 19163)
+++ labs/jbossrules/branches/temporal_rete/drools-decisiontables/src/test/java/org/drools/decisiontable/parser/ExternalSheetListenerTest.java 2008-03-20 19:32:10 UTC (rev 19164)
@@ -1,14 +1,6 @@
package org.drools.decisiontable.parser;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-
import junit.framework.TestCase;
-
import org.drools.Agenda;
import org.drools.FactException;
import org.drools.FactHandle;
@@ -32,6 +24,16 @@
import org.drools.spi.GlobalResolver;
import org.drools.temporal.SessionClock;
+import java.io.IOException;
+import java.io.ObjectInput;
+import java.io.ObjectOutput;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+
public class ExternalSheetListenerTest extends TestCase {
private ExternalSheetListener esl;
@@ -438,6 +440,12 @@
// TODO Auto-generated method stub
return null;
}
+
+ public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
+ }
+
+ public void writeExternal(ObjectOutput out) throws IOException {
+ }
};
}
}
Modified: labs/jbossrules/branches/temporal_rete/drools-docs/drools-docs-examples/en/Chapter-Examples/Section-Examples.xml
===================================================================
--- labs/jbossrules/branches/temporal_rete/drools-docs/drools-docs-examples/en/Chapter-Examples/Section-Examples.xml 2008-03-20 18:57:07 UTC (rev 19163)
+++ labs/jbossrules/branches/temporal_rete/drools-docs/drools-docs-examples/en/Chapter-Examples/Section-Examples.xml 2008-03-20 19:32:10 UTC (rev 19164)
@@ -31,7 +31,7 @@
PackageBuilder builder = new PackageBuilder();
-//this wil parse and compile in one step
+//this will parse and compile in one step
builder.addPackageFromDrl( source );
// Check the builder for errors
Modified: labs/jbossrules/branches/temporal_rete/drools-docs/drools-docs-examples/en/master.xml
===================================================================
--- labs/jbossrules/branches/temporal_rete/drools-docs/drools-docs-examples/en/master.xml 2008-03-20 18:57:07 UTC (rev 19163)
+++ labs/jbossrules/branches/temporal_rete/drools-docs/drools-docs-examples/en/master.xml 2008-03-20 19:32:10 UTC (rev 19164)
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
-<book xmlns:xi="http://www.w3.org/2003/XInclude">
+<book xmlns:xi="http://www.w3.org/2001/XInclude">
<bookinfo>
<title>Drools Examples</title>
Modified: labs/jbossrules/branches/temporal_rete/drools-docs/drools-docs-solver/en/master.xml
===================================================================
--- labs/jbossrules/branches/temporal_rete/drools-docs/drools-docs-solver/en/master.xml 2008-03-20 18:57:07 UTC (rev 19163)
+++ labs/jbossrules/branches/temporal_rete/drools-docs/drools-docs-solver/en/master.xml 2008-03-20 19:32:10 UTC (rev 19164)
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
-<book xmlns:xi="http://www.w3.org/2003/XInclude">
+<book xmlns:xi="http://www.w3.org/2001/XInclude">
<bookinfo>
<title>Drools Solver (experimental)</title>
Copied: labs/jbossrules/branches/temporal_rete/drools-docs/drools-docs-userguide/en/Chapter-Decision_Tables/Key.png (from rev 19160, labs/jbossrules/dev_tags/before_righttuple_merge_20080320/drools-docs/drools-docs-userguide/en/Chapter-Decision_Tables/Key.png)
===================================================================
(Binary files differ)
Modified: labs/jbossrules/branches/temporal_rete/drools-docs/drools-docs-userguide/en/Chapter-Decision_Tables/Section-Spreadsheet.xml
===================================================================
--- labs/jbossrules/branches/temporal_rete/drools-docs/drools-docs-userguide/en/Chapter-Decision_Tables/Section-Spreadsheet.xml 2008-03-20 18:57:07 UTC (rev 19163)
+++ labs/jbossrules/branches/temporal_rete/drools-docs/drools-docs-userguide/en/Chapter-Decision_Tables/Section-Spreadsheet.xml 2008-03-20 19:32:10 UTC (rev 19164)
@@ -175,7 +175,7 @@
case, it will generate: Person(age=="42") etc (where 42 comes from row
18). In the above example, the "==" is implicit (if you just put a field
name, it will assume that you are looking for exact matches). Also note
- that you can have a ObjectType declaration span columns (via merged cells)
+ that you can have an ObjectType declaration span columns (via merged cells)
- and that means that all columns below the merged range will be combined
into the one set of constraints.</para>
@@ -312,7 +312,7 @@
<entry>Description</entry>
- <entry>Is required?</entry>
+ <entry>Inclusion Status</entry>
</row>
</thead>
@@ -340,7 +340,7 @@
<entry>Import</entry>
<entry>The cell to the right contains a comma separated list of
- java classes to import</entry>
+ Java classes to import</entry>
<entry>optional</entry>
</row>
@@ -419,7 +419,7 @@
<entry>Variables</entry>
<entry>The cell immediately to the right can contain global
- declarations which drools supports. This is a type, followed by a
+ declarations which Drools supports. This is a type, followed by a
variable name. (if multiple variables are needed, comma separate
them).</entry>
@@ -427,10 +427,9 @@
</row>
<row>
- <entry>UNLOOP</entry>
+ <entry>No-loop or Unloop</entry>
- <entry>Indicates that if there cell values in this column, the
- no-loop attribute should be set</entry>
+ <entry>Placed in the header of a table, no-loop or unloop will both complete the same function of not allowing a rule (row) to loop. For this option to function correctly, there must be a value (true or false) in the cell for the option to take effect. If the cell is left blank then this option will not be set for the row.</entry>
<entry>optional</entry>
</row>
@@ -464,6 +463,17 @@
<mediaobject>
<imageobject>
+ <imagedata fileref="Key.png" />
+ </imageobject>
+ </mediaobject>
+ </screenshot>
+
+ <screenshot>
+ <screeninfo>Example usage of keywords for imports, functions
+ etc.</screeninfo>
+
+ <mediaobject>
+ <imageobject>
<imagedata fileref="keywords.png" />
</imageobject>
</mediaobject>
@@ -484,7 +494,7 @@
the rules if needed).</para>
<para>To get started, you can find a sample spreadsheet and base it on
- that. Alternatively, if you are using the plug in (Rule Workbench IDE) the
+ that. Alternatively, if you are using the plug-in (Rule Workbench IDE) the
wizard can generate a spreadsheet for you from a template (to edit it you
will need to use an xls compatible spreadsheet editor). <screenshot>
<screeninfo>Wizard in the IDE</screeninfo>
@@ -577,4 +587,5 @@
http://www.drools.org/Business+rules+in+decision+tables+explained</para>
</section>
</section>
-</section>
\ No newline at end of file
+
+</section>
Modified: labs/jbossrules/branches/temporal_rete/drools-docs/drools-docs-userguide/en/Chapter-Deployment/Section-Deployment.xml
===================================================================
--- labs/jbossrules/branches/temporal_rete/drools-docs/drools-docs-userguide/en/Chapter-Deployment/Section-Deployment.xml 2008-03-20 18:57:07 UTC (rev 19163)
+++ labs/jbossrules/branches/temporal_rete/drools-docs/drools-docs-userguide/en/Chapter-Deployment/Section-Deployment.xml 2008-03-20 19:32:10 UTC (rev 19164)
@@ -212,7 +212,7 @@
<para>Use the PackageBuilder class out of process, and then use
getPackage() to get the Package object. You can then (for example)
- serialize the Package object to a file (using standard java
+ serialize the Package object to a file (using standard Java
serialization). The runtime system, which only needs drools-core, can
then load the file using
RuleBaseFactory.newRuleBase().addPackage(deserialized package
@@ -287,4 +287,5 @@
<para>A future release of Drools will contain a rule repository (server)
component that will directly support the above patterns, and more.</para>
</section>
+
</section>
\ No newline at end of file
Modified: labs/jbossrules/branches/temporal_rete/drools-docs/drools-docs-userguide/en/Chapter-IDE/Section-QuickStart.xml
===================================================================
--- labs/jbossrules/branches/temporal_rete/drools-docs/drools-docs-userguide/en/Chapter-IDE/Section-QuickStart.xml 2008-03-20 18:57:07 UTC (rev 19163)
+++ labs/jbossrules/branches/temporal_rete/drools-docs/drools-docs-userguide/en/Chapter-IDE/Section-QuickStart.xml 2008-03-20 19:32:10 UTC (rev 19164)
@@ -7,7 +7,7 @@
<para>
The IDE provides developers (and very technical users) with an environment to edit and test rules in various formats, and integrate it deeply with their applications. In cases where you prefer business rules and web tooling, you will want to look at the BRMS (but using the BRMS and the IDE together is not uncommon).</para>
- <para>The Drools IDE is delivered as an eclipse plugin, which
+ <para>The Drools IDE is delivered as an Eclipse plug-in, which
allows you to author and manage rules from within Eclipse, as well as
integrate rules with your application. This is an optional tool, and not all
components are required to be used, you can use what components are relevant
@@ -20,7 +20,7 @@
on Eclipse, and integrators are free to use their tools of choice, as always
! Plenty of people use IntelliJ with rules, for instance.</para>
- <para>Note you can get the plug in either as a zip to download, or from an
+ <para>Note you can get the plug-in either as a zip to download, or from an
update site (refer to the chapter on installation).</para>
<figure>
@@ -106,7 +106,7 @@
</orderedlist>
<para>You can see the above features make use of Eclipse infrastructure
- and features. All of the power of eclipse is available.</para>
+ and features. All of the power of Eclipse is available.</para>
</section>
<section>
@@ -126,7 +126,7 @@
</mediaobject>
</figure>
- <para>When you choose to create a new "rule project" - you will get a choice to add some default artifacts to it (like rules, decision tables, ruleflows etc). These can serve as a starting point, and will give you something executable to play with (which you can then modify and mould to your needs). The simplest case (a hello world rule) is shown below. Feel free to experiment with the plugin at this point.</para>
+ <para>When you choose to create a new "rule project" - you will get a choice to add some default artifacts to it (like rules, decision tables, ruleflows etc). These can serve as a starting point, and will give you something executable to play with (which you can then modify and mould to your needs). The simplest case (a hello world rule) is shown below. Feel free to experiment with the plug-in at this point.</para>
<figure>
<title>New rule project result</title>
@@ -139,16 +139,16 @@
</figure>
<para>The newly created project contains an example rule file (Sample.drl)
- in the src/rules dir and an example java file (DroolsTest.java) that can
- be used to execute the rules in a Drools engine in the folder src/java, in
+ in the src/rules dir and an example Java file (DroolsTest.Java) that can
+ be used to execute the rules in a Drools engine in the folder src/Java, in
the com.sample package. All the others jars that are necessary during
execution are also added to the classpath in a custom classpath container
- called Drools Library. Rules do not have to be kept in "java"
+ called Drools Library. Rules do not have to be kept in "Java"
projects at all, this is just a convenience for people who are already
- using eclipse as their Java IDE.</para>
+ using Eclipse as their Java IDE.</para>
- <para>Important note: The Drools plug in adds a "Drools Builder"
- capability to your eclipse instance. This means you can enable a builder
+ <para>Important note: The Drools plug-in adds a "Drools Builder"
+ capability to your Eclipse instance. This means you can enable a builder
on any project that will build and validate your rules when resources
change. This happens automatically with the Rule Project Wizard, but you
can also enable it manually on any project. One downside of this is if you
@@ -183,7 +183,7 @@
of location, typically you would create a top level /rules directory to
store your rules if you are creating a rule project, and store it in a
suitably named subdirectory. The package name is mandatory, and is similar
- to a package name in java (ie. its a namespace that groups like rules
+ to a package name in Java (ie. its a namespace that groups like rules
together).</para>
<figure>
@@ -206,7 +206,7 @@
<para>The rule editor is where rule managers and developers will be
spending most of their time. The rule editor follows the pattern of a
- normal text editor in eclipse, with all the normal features of a text
+ normal text editor in Eclipse, with all the normal features of a text
editor. On top of this, the rule editor provides pop up content
assistance. You invoke popup content assistance the "normal" way by
pressing Control + Space at the same time.</para>
@@ -536,7 +536,7 @@
loaded for editing). The Rule language mapping is the "code" for the
rules - which the language expression will be compiled to by the rule
engine compiler. For form of this Rule language depends if it is for a
- condition or action part of a rule (it may be a snippet of java, for
+ condition or action part of a rule (it may be a snippet of Java, for
instance). The "scope" item indicates where the expression is targeted:
is it for the "when" part of the rule (LHS)? the "then" part (RHS)? Or
anywhere?</para>
@@ -567,7 +567,7 @@
to 2 constraints on a fact of type Person (ie the person object has the
age field as less than {age}, and the location value is the string of
{value}, where {age} and {value} are pulled out of the original rule
- source. The Rule mapping may be a java expression (such as if the scope
+ source. The Rule mapping may be a Java expression (such as if the scope
was "then"). If you did not wish to use a language mapping for a
particular rule in a drl, prefix the expression with > and the
compiler will not try to translate it according to the language
@@ -590,7 +590,7 @@
<para>There is no export function, which creates a gif or jpeg picture, in
the current release. Please use ctrl + alt + print to create a copy of
- your current eclipse window and cut it off.</para>
+ your current Eclipse window and cut it off.</para>
<mediaobject>
<imageobject>
@@ -621,10 +621,10 @@
permanent generation max size. Both SUN and IBM jdk have a permanent
generation, whereas BEA JRockit does not.</para>
- <para>To increase the permanent generation, start eclipse with
+ <para>To increase the permanent generation, start Eclipse with
-XX:MaxPermSize=###m</para>
- <para>Example: c:\eclipse\eclipse.exe -XX:MaxPermSize=128m</para>
+ <para>Example: c:\Eclipse\Eclipse.exe -XX:MaxPermSize=128m</para>
<para>Rulesets of 4,000 rules or greater should set the permanent
generation to atleast 128Mb.</para>
@@ -715,11 +715,11 @@
<listitem>
<para>Change the name of your debug configuration to something meaningful.
You can just accept the defaults for all other properties. For more information
- about these properties, please check the eclipse jdt documentation.</para>
+ about these properties, please check the Eclipse jdt documentation.</para>
</listitem>
<listitem>
<para>Click the "Debug" button on the bottom to start debugging your application. You only have to define your debug configuration once. The next time you try to run your Drools application, you don't have to create a new one but select the one you defined previously by selecting it in the tree on the left, as a sub-element of the "Drools Application"
- tree node, and then click the Debug button. The eclipse toolbar also contains shortcut
+ tree node, and then click the Debug button. The Eclipse toolbar also contains shortcut
buttons to quickly re-execute the one of your previous configurations (at least when the
Java, Java Debug, or Drools perspective has been selected).
</para>
Modified: labs/jbossrules/branches/temporal_rete/drools-docs/drools-docs-userguide/en/Chapter-Install/Section-Checkout.xml
===================================================================
--- labs/jbossrules/branches/temporal_rete/drools-docs/drools-docs-userguide/en/Chapter-Install/Section-Checkout.xml 2008-03-20 18:57:07 UTC (rev 19163)
+++ labs/jbossrules/branches/temporal_rete/drools-docs/drools-docs-userguide/en/Chapter-Install/Section-Checkout.xml 2008-03-20 19:32:10 UTC (rev 19164)
@@ -20,7 +20,7 @@
</listitem>
</itemizedlist>
-To checkout drools source code just execute the following command.
+To checkout Drools source code just execute the following command.
<programlisting>fmeyer:~/jboss $ svn checkout http://anonsvn.labs.jboss.com/labs/jbossrules/trunk/ jbossrules</programlisting>
@@ -93,7 +93,7 @@
- <para>Although, we highly recommend command line tools to work with repository you can also use both eclipse's integrated SVN client or TortoiseSVN</para>
+ <para>Although, we highly recommend command line tools to work with repository you can also use both Eclipse's integrated SVN client or TortoiseSVN</para>
<para>Setup TortoiseSVN to checkout from the subversion repository and click
<literal>'OK'</literal> Once the checkout has finished you should see the
Modified: labs/jbossrules/branches/temporal_rete/drools-docs/drools-docs-userguide/en/Chapter-Install/Section-Eclipse.xml
===================================================================
--- labs/jbossrules/branches/temporal_rete/drools-docs/drools-docs-userguide/en/Chapter-Install/Section-Eclipse.xml 2008-03-20 18:57:07 UTC (rev 19163)
+++ labs/jbossrules/branches/temporal_rete/drools-docs/drools-docs-userguide/en/Chapter-Install/Section-Eclipse.xml 2008-03-20 19:32:10 UTC (rev 19164)
@@ -5,20 +5,20 @@
<section>
<title>Generating Eclipse Projects</title>
- <para>The drools project has eclipse projects checked in for convenience.
+ <para>The Drools project has Eclipse projects checked in for convenience.
However, these are originally generated by maven 2. If you have maven 2
- installed, you can also regenerate the eclipse projects automatically, or
+ installed, you can also regenerate the Eclipse projects automatically, or
even generate it for IntelliJ etc, see the instructions below for this
(most people can ignore this section)</para>
<para><indexterm>
<primary>maven</primary>
</indexterm>Maven is able to generate standard <indexterm>
- <primary>eclipse</primary>
+ <primary>Eclipse</primary>
</indexterm>Eclipse projects, but it is not able to generate Eclipse
- plugin projects. To generate the Eclipse projects for drools-core,
+ plug-in projects. To generate the Eclipse projects for drools-core,
drools-compiler and drools-jsr94 type <literal>'mvn
- eclipse:eclipse'</literal>.</para>
+ Eclipse:Eclipse'</literal>.</para>
<screenshot>
<screeninfo>Start Maven Eclipse project generation</screeninfo>
@@ -45,9 +45,9 @@
<title>Importing Eclipse Projects</title>
<para>With the <indexterm>
- <primary>eclipse</primary>
+ <primary>Eclipse</primary>
</indexterm>Eclispe project files generated they can now be imported
- into eclipse. When starting Eclipse open the workspace in the root of your
+ into Eclipse. When starting Eclipse open the workspace in the root of your
subversion checkout.</para>
<screenshot>
@@ -137,7 +137,7 @@
</section>
<section>
- <title>Exporting the IDE Plugin</title>
+ <title>Exporting the IDE plug-in</title>
<para>The drools-ide project was checked out out using subversion and is
ready for exporting.</para>
@@ -173,7 +173,7 @@
</screenshot>
<screenshot>
- <screeninfo>Wait while the plugin is built and exported</screeninfo>
+ <screeninfo>Wait while the plug-in is built and exported</screeninfo>
<mediaobject>
<imageobject>
@@ -182,8 +182,8 @@
</mediaobject>
</screenshot>
- <para>Once the plugin has been built open the output directory and copy
- the jar to the Eclipse plugin directory.</para>
+ <para>Once the plug-in has been built open the output directory and copy
+ the jar to the Eclipse plug-in directory.</para>
<screenshot>
<screeninfo>Open the directory with the build jar</screeninfo>
@@ -196,7 +196,7 @@
</screenshot>
<screenshot>
- <screeninfo>Copy the jar to the Eclipse plugin directory</screeninfo>
+ <screeninfo>Copy the jar to the Eclipse plug-in directory</screeninfo>
<mediaobject>
<imageobject>
@@ -234,17 +234,17 @@
<section>
<title>Building the update site</title>
- <para>There is also an update site for the plug in. For developers who
+ <para>There is also an update site for the plug-in. For developers who
want to update the update site (ha) you will need to get to the update
site project (or create a new one). They are kept in SVN, but in
- /jbossrules/update instead of /trunk. They are plain vanilla eclipse
+ /jbossrules/update instead of /trunk. They are plain vanilla Eclipse
feature and site projects.</para>
- <para>PLEASE REMEMBER that the plug in in the downloads directory, as a
+ <para>PLEASE REMEMBER that the plug-in in the downloads directory, as a
zip, should also be updated at the same time as the update site (as they
- are alternative ways ot getting the same plug in).</para>
+ are alternative ways ot getting the same plug-in).</para>
- <para>Eclipse refreshing plugins in features and sites seems to not work,
+ <para>Eclipse refreshing plug-ins in features and sites seems to not work,
so what is best is to manually edit the site.xml project and the
feature.xml. To do this, open the site.xml file in the drools-ide-update
project, it should look something like this: <programlisting><?xml version="1.0" encoding="UTF-8"?>
@@ -290,23 +290,24 @@
limitations under the License.
</license>
- <plugin
+ <plug-in
id="org.drools.ide"
download-size="0"
install-size="0"
- version="1.0.0"/> <!-- THIS JUST HAS TO BE CONSISTENT WITH THE PLUG IN -->
+ version="1.0.0"/> <!-- THIS JUST HAS TO BE CONSISTENT WITH THE plug-in -->
</feature>
</programlisting> Change the version number in the FEATURE tag to be the same
as what you referred to in the site.xml. If you changed the version number
- of the main plug in, you will need to put the version number in the plug
- in tag (which refers to org.drools.ide plugin). Then zip up the
+ of the main plug-in, you will need to put the version number in the plug
+ in tag (which refers to org.drools.ide plug-in). Then zip up the
feature.xml into a jar with the same name as you referred to in the
site.xml.</para>
- <para>Finally, drop the plugin jar into the /plugins jar directory of the
- update site (get the actual plug in from the exported plugin in the
+ <para>Finally, drop the plug-in jar into the /plugins jar directory of the
+ update site (get the actual plug-in from the exported plug-in in the
previous step). Now you can upload the site as is, and it will show up as
a new version for Eclipse clients.</para>
</section>
+
</section>
\ No newline at end of file
Modified: labs/jbossrules/branches/temporal_rete/drools-docs/drools-docs-userguide/en/Chapter-Install/Section-Install.xml
===================================================================
--- labs/jbossrules/branches/temporal_rete/drools-docs/drools-docs-userguide/en/Chapter-Install/Section-Install.xml 2008-03-20 18:57:07 UTC (rev 19163)
+++ labs/jbossrules/branches/temporal_rete/drools-docs/drools-docs-userguide/en/Chapter-Install/Section-Install.xml 2008-03-20 19:32:10 UTC (rev 19164)
@@ -2,19 +2,19 @@
<section>
<title>Installing and using</title>
- <para>Drools provides an eclipse based IDE (which is optional), but at its
+ <para>Drools provides an Eclipse-based IDE (which is optional), but at its
core only Java 1.4 (J2SE) is required.</para>
- <para>A simple way to get started is to download and install the eclipse
- plug in - this will also require the Eclipse GEF framework to be installed
+ <para>A simple way to get started is to download and install the Eclipse
+ plug-in - this will also require the Eclipse GEF framework to be installed
(see below, if you don't have it installed already). This will provide you
with all the dependencies you need to get going: you can simply create a new
rule project and everything will be done for you. Refer to the chapter on
the Rule Workbench and IDE for detailed instructions on this. Installing the
- eclipse plugin is generally as simple as unzipping a file into your eclipse
- plugin directory.</para>
+ Eclipse plug-in is generally as simple as unzipping a file into your Eclipse
+ plug-in directory.</para>
- <para>Use of the eclipse plug in is not required. Rule files are just
+ <para>Use of the Eclipse plug-in is not required. Rule files are just
textual input (or spreadsheets as the case may be) and the IDE (also known
as the Rule Workbench) is just a convenience. People have integrated the
rule engine in many ways, there is no "one size fits all".</para>
@@ -60,7 +60,7 @@
this is essentially a layer over the drools-compiler component. Note
that due to the nature of the JSR-94 specification, not all features
are easily exposed via this interface. In some cases, it will be
- easier to go direct to the drools API, but in some environments the
+ easier to go direct to the Drools API, but in some environments the
JSR-94 is mandated.</para>
</listitem>
@@ -107,23 +107,23 @@
<section>
<title>Installing IDE (Rule Workbench)</title>
- <para>The rule workbench (for Eclipse) requires that you have eclipse 3.2
+ <para>The rule workbench (for Eclipse) requires that you have Eclipse 3.2
or greater, as well as Eclipse GEF 3.2 or greater. You can install it
- either by downloading the plugin or, or using the update site.</para>
+ either by downloading the plug-in or, or using the update site.</para>
<para>Another option is to use the JBoss IDE, which comes with all the
- plug in requirements pre packaged, as well as a choice of other tools
+ plug-in requirements pre packaged, as well as a choice of other tools
separate to rules. You can choose just to install rules from the "bundle"
that JBoss IDE ships with.</para>
<section>
<title>Installing GEF (a required dependency)</title>
- <para>GEF is the eclipse Graphical Editing Framework, which is used for
- graph viewing components in the plug in.</para>
+ <para>GEF is the Eclipse Graphical Editing Framework, which is used for
+ graph viewing components in the plug-in.</para>
<para>If you don't have GEF installed, you can install it using the
- built in update mechanism (or downloading GEF from the eclipse.org
+ built in update mechanism (or downloading GEF from the Eclipse.org
website not recommended). JBoss IDE has GEF already, as do many other "distributions" of
Eclipse, so this step may be redundant for some people.</para>
@@ -131,7 +131,7 @@
from the help menu. Then you choose the Calisto update site:</para>
<para>If you aren't using Calisto you can use the following update site do download GEF</para>
- <programlisting>http://europa-mirror1.eclipse.org/tools/gef/update-site/releases/</programlisting>
+ <programlisting>http://europa-mirror1.Eclipse.org/tools/gef/update-site/releases/</programlisting>
<screenshot>
<mediaobject>
@@ -141,7 +141,7 @@
</mediaobject>
</screenshot>
- <para>Next you choose the GEF plug in:</para>
+ <para>Next you choose the GEF plug-in:</para>
<screenshot>
<mediaobject>
@@ -151,34 +151,34 @@
</mediaobject>
</screenshot>
- <para>Press next, and agree to install the plug in (an eclipse restart
+ <para>Press next, and agree to install the plug-in (an Eclipse restart
may be required). Once this is completed, then you can continue on
- installing the rules plug in.</para>
+ installing the rules plug-in.</para>
</section>
<section>
<title>Installing from zip file</title>
<para>To install from the zip file, download and unzip the file. Inside
- the zip you will see a plugin directory, and the plugin jar itself. You
- place the plugin jar into your eclipse applications plugin directory,
- and restart eclipse.</para>
+ the zip you will see a plug-in directory, and the plug-in jar itself. You
+ place the plug-in jar into your Eclipse applications plug-in directory,
+ and restart Eclipse.</para>
</section>
<section>
<title>Installing from the update site</title>
- <para>Using the update site is a handy way to install the plug in, and
- keep it up to date (the eclipse platform will check for updates as
+ <para>Using the update site is a handy way to install the plug-in, and
+ keep it up to date (the Eclipse platform will check for updates as
needed). It gives you a good chance of staying up to date with
improvements, fixes etc.</para>
<para>Some firewalls may cause trouble with using update sites in
- eclipse, if you have issues, then install it manually from the plugin.
- Also, if you have previously installed the plug in manually, you will
- need to manually remove it from your plug in directory.</para>
+ Eclipse, if you have issues, then install it manually from the plug-in.
+ Also, if you have previously installed the plug-in manually, you will
+ need to manually remove it from your plug-in directory.</para>
- <para>Step 1. Use the eclipse help menu to find the feature installer.
+ <para>Step 1. Use the Eclipse help menu to find the feature installer.
<screenshot>
<screeninfo>Access the software updates menu</screeninfo>
Modified: labs/jbossrules/branches/temporal_rete/drools-docs/drools-docs-userguide/en/Chapter-Install/Section-Maven_build.xml
===================================================================
--- labs/jbossrules/branches/temporal_rete/drools-docs/drools-docs-userguide/en/Chapter-Install/Section-Maven_build.xml 2008-03-20 18:57:07 UTC (rev 19163)
+++ labs/jbossrules/branches/temporal_rete/drools-docs/drools-docs-userguide/en/Chapter-Install/Section-Maven_build.xml 2008-03-20 19:32:10 UTC (rev 19164)
@@ -8,21 +8,21 @@
<para>Now that we have the source the next step is to build and install
the source. Since version 3.1 Drools uses <indexterm> Maven 2 </indexterm> to build the system. There are two profiles
available which enable the associated modules "documentation" and
- "eclipse"; this enables quicker building of the core modules for
- developers. The eclipse profile will download eclipse into the
- drools-eclipse folder, which is over 100MB download (It depends on your operating system), however this only
- needs to be done once; if you wish you can move that eclipse download into
+ "Eclipse"; this enables quicker building of the core modules for
+ developers. The Eclipse profile will download Eclipse into the
+ drools-Eclipse folder, which is over 100MB download (It depends on your operating system), however this only
+ needs to be done once; if you wish you can move that Eclipse download into
another location and specify it with
- -DlocalEclipseDrop=/folder/jboss-rules/local-eclipse-drop-mirror. The
- following builds all the jars, the documentation and the eclipse zip with
- a local folder specified to avoid downloading eclipse:</para>
+ -DlocalEclipseDrop=/folder/jboss-rules/local-Eclipse-drop-mirror. The
+ following builds all the jars, the documentation and the Eclipse zip with
+ a local folder specified to avoid downloading Eclipse:</para>
- <para><programlisting>mvn -Declipse -Ddocumentation clean install -DlocalEclipseDrop=/folder/jboss-rules/local-eclipse-drop-mirror </programlisting></para>
+ <para><programlisting>mvn -Declipse -Ddocumentation clean install -DlocalEclipseDrop=/folder/jboss-rules/local-Eclipse-drop-mirror </programlisting></para>
<para>You can produce distribution builds, which puts everything into
zips, as follows:
-<programlisting>mvn -Declipse -Ddocumentation clean install -DlocalEclipseDrop=/folder/jboss-rules/local-eclipse-drop-mirror
-mvn -Ddocumentation -Declipse -Dmaven.test.skip package javadoc:javadoc assembly:assembly -DlocalEclipseDrop=/folder/jboss-rules/local-eclipse-drop-mirror
+<programlisting>mvn -Declipse -Ddocumentation clean install -DlocalEclipseDrop=/folder/jboss-rules/local-Eclipse-drop-mirror
+mvn -Ddocumentation -Declipse -Dmaven.test.skip package javadoc:javadoc assembly:assembly -DlocalEclipseDrop=/folder/jboss-rules/local-Eclipse-drop-mirror
</programlisting></para>
<para>Note that install must be done first as javadoc:javadoc won't work
@@ -82,9 +82,9 @@
</listitem>
<listitem>
- <para>eclipse</para>
+ <para>Eclipse</para>
- <para>Documentation suitable for including in an eclipse plugin</para>
+ <para>Documentation suitable for including in an Eclipse plug-in</para>
</listitem>
</itemizedlist>
Modified: labs/jbossrules/branches/temporal_rete/drools-docs/drools-docs-userguide/en/Chapter-Release_Notes/Section-Upgrade_tips.xml
===================================================================
--- labs/jbossrules/branches/temporal_rete/drools-docs/drools-docs-userguide/en/Chapter-Release_Notes/Section-Upgrade_tips.xml 2008-03-20 18:57:07 UTC (rev 19163)
+++ labs/jbossrules/branches/temporal_rete/drools-docs/drools-docs-userguide/en/Chapter-Release_Notes/Section-Upgrade_tips.xml 2008-03-20 19:32:10 UTC (rev 19164)
@@ -184,7 +184,7 @@
and as so, it is a safe tool to use for upgrade large sets of rule
files.</para>
- <para>The drools update tool can be found as a maven project in the
+ <para>The Drools update tool can be found as a maven project in the
following source repository
http://anonsvn.labs.jboss.com/labs/jbossrules/trunk/experimental/drools-update/
you just need to check it out, and execute the maven clean install action
@@ -248,7 +248,7 @@
<title>Rule flow Update for 4.0.2</title>
<para>
- The Rule flow feature was updated for 4.0.2, and now all your ruleflows must decalre a package name.
+ The Rule flow feature was updated for 4.0.2, and now all your ruleflows must declare a package name.
</para>
<figure>
@@ -263,4 +263,5 @@
</figure>
</section>
+
</section>
\ No newline at end of file
Modified: labs/jbossrules/branches/temporal_rete/drools-docs/drools-docs-userguide/en/Chapter-Rule_Engine/Section-Rete_Algorithm.xml
===================================================================
--- labs/jbossrules/branches/temporal_rete/drools-docs/drools-docs-userguide/en/Chapter-Rule_Engine/Section-Rete_Algorithm.xml 2008-03-20 18:57:07 UTC (rev 19163)
+++ labs/jbossrules/branches/temporal_rete/drools-docs/drools-docs-userguide/en/Chapter-Rule_Engine/Section-Rete_Algorithm.xml 2008-03-20 19:32:10 UTC (rev 19164)
@@ -41,8 +41,7 @@
it. This way, if an application asserts a new account, it won't propagate to
the nodes for the Order object. In Drools when an object is asserted it
retrieves a list of valid ObjectTypesNodes via a lookup in a HashMap from
- the object's Class; if this list doesn't exist it scans all the ObjectTypde
- nodes finding valid matches which it caches in the list. This enables Drools
+ the object's Class; if this list doesn't exist it scans all the ObjectTypeNodes finding valid matches which it caches in the list. This enables Drools
to match against any Class type that matches with an
<literal>instanceof</literal> check.</para>
@@ -56,7 +55,7 @@
</mediaobject>
</figure>
- <para>ObjectTypdeNodes can propagate to AlphaNodes, LeftInputAdapterNodes
+ <para>ObjectTypeNodes can propagate to AlphaNodes, LeftInputAdapterNodes
and BetaNodes. AlphaNodes are used to evaluate literal conditions. Although
the 1982 paper only covers equality conditions, many RETE implementations
support other operations. For example, Account.name == "Mr Trout" is a
@@ -78,10 +77,10 @@
</mediaobject>
</figure>
- <para>Drools extends Rete by optimizing the propagation from ObjectTypdeNode
+ <para>Drools extends Rete by optimizing the propagation from ObjectTypeNode
to AlphaNode using hashing. Each time an AlphaNode is added to an
- ObjectTypdeNode it adds the literal value as a key to the HashMap with the
- AlphaNode as the value. When a new instance enters the ObjectTypde node,
+ ObjectTypeNode it adds the literal value as a key to the HashMap with the
+ AlphaNode as the value. When a new instance enters the ObjectType node,
rather than propagating to each AlphaNode, it can instead retrieve the
correct AlphaNode from the HashMap - avoiding unnecessary literal
checks.</para>
Modified: labs/jbossrules/branches/temporal_rete/drools-docs/drools-docs-userguide/en/Chapter-Rule_Engine/Section-Rules.xml
===================================================================
--- labs/jbossrules/branches/temporal_rete/drools-docs/drools-docs-userguide/en/Chapter-Rule_Engine/Section-Rules.xml 2008-03-20 18:57:07 UTC (rev 19163)
+++ labs/jbossrules/branches/temporal_rete/drools-docs/drools-docs-userguide/en/Chapter-Rule_Engine/Section-Rules.xml 2008-03-20 19:32:10 UTC (rev 19164)
@@ -314,6 +314,7 @@
private String studentName;
private int score;
+ }
</programlisting>
<para>Java is Turing complete in that you can write code, among other
@@ -345,7 +346,7 @@
<programlisting>
- select
+select
*
from
Students s
Modified: labs/jbossrules/branches/temporal_rete/drools-docs/drools-docs-userguide/en/Chapter-Rule_Engine/Section-The_Drools_Rule_Engine.xml
===================================================================
--- labs/jbossrules/branches/temporal_rete/drools-docs/drools-docs-userguide/en/Chapter-Rule_Engine/Section-The_Drools_Rule_Engine.xml 2008-03-20 18:57:07 UTC (rev 19163)
+++ labs/jbossrules/branches/temporal_rete/drools-docs/drools-docs-userguide/en/Chapter-Rule_Engine/Section-The_Drools_Rule_Engine.xml 2008-03-20 19:32:10 UTC (rev 19164)
@@ -512,7 +512,7 @@
does not help to use update(). The only way to safely change an
attribute of a fact whose shadow fact is disabled is to call
modifyRetract() before changing the attribute, change the attribute and
- call modifyAssert().</remark>
+ call modifyInsert().</remark>
</section>
<section>
@@ -523,7 +523,7 @@
means that the engine will automatically know when a fact has changed,
and behave accordingly (you don't need to tell it that it is modified).
There are proxy libraries that can help automate this (a future version
- of drools will bundle some to make it easier). To use the Object in
+ of Drools will bundle some to make it easier). To use the Object in
dynamic mode specify true for the second assertObject parameter.</para>
<programlisting>Cheese stilton = new Cheese("stilton");
@@ -568,7 +568,7 @@
external source). For instance, if a new working memory is created, and
no facts are asserted, calling the fireAllRules will cause the Initial
Fact to propagate, possibly activating rules (otherwise, nothing would
- happen as there area no other facts to start with).</para>
+ happen as there are no other facts to start with).</para>
</section>
</section>
@@ -633,14 +633,14 @@
need access to any results information they can use the executeWithResults
method, which returns a StatelessSessionResult. The reason for this is in
remoting situations you do not always want the return payload, so this way
- its optional.</para>
+ it's optional.</para>
<para>setAgendaFilter, setGlobal and setGlobalResolver share their state
across sessions; so each call to execute() will use the set AgendaFilter,
or see any previous set globals etc.</para>
<para>StatelessSessions do not currently support
- propertyChangeLissteners.</para>
+ propertyChangeListeners.</para>
<para>Async versions of the Execute method are supported, remember to
override the ExecutorService implementation when in special managed thread
@@ -663,7 +663,7 @@
</figure>
<para>StatelessSession.executeWithResults(....) returns a minimal api to
- examine the sessions data. The inserted Objects can be iterated over,
+ examine the session's data. The inserted Objects can be iterated over,
queries can be executed and globals retrieved. Once the
StatelessSessionResult is serialized it loses the reference to the
underlying WorkingMemory and RuleBase, so queries can no longer be
@@ -679,7 +679,7 @@
ReferenceOriginalGlobalExporter just passes a reference to the original
Global Resolver; the latter should be used with care as identifier
instances can be changed at any time by the StatelessSession and the
- GlobalResolver may not be serializable freindly.</para>
+ GlobalResolver may not be serializable friendly.</para>
<example>
<title>GlobalExporter with StatelessSessions</title>
@@ -716,7 +716,7 @@
<orderedlist>
<listitem>
<para>Working Memory Actions - this is where most of the work takes
- place - in either the Consequence or the main java application
+ place - in either the Consequence or the main Java application
process. Once the Consequence has finished or the main Java
application process calls fireAllRules() the engine switches to the
Agenda Evaluation phase.</para>
@@ -791,7 +791,7 @@
<para>Each time setFocus(...) is called it pushes that Agenda Group onto
a stack, when the focus group is empty it is popped off and the next one
- of the stack evaluates. An Agenda Group can appear in multiple locations
+ on the stack evaluates. An Agenda Group can appear in multiple locations
on the stack. The default Agenda Group is "MAIN", all rules which do not
specify an Agenda Group are placed there, it is also always the first
group on the Stack and given focus as default.</para>
@@ -817,7 +817,7 @@
<itemizedlist>
<listitem>
- <para>RuleNameEndWithAgendaFilter</para>
+ <para>RuleNameEndsWithAgendaFilter</para>
</listitem>
<listitem>
@@ -834,8 +834,7 @@
</itemizedlist>
<para>To use a filter specify it while calling FireAllRules. The
- following example will filter out all rules ending with the text
- "Test":</para>
+ following example will only allow activation of rules ending with the test <emphasis>Test</emphasis>. All others will be filtered out:</para>
<programlisting>workingMemory.fireAllRules( new RuleNameEndsWithAgendaFilter( "Test" ) ); </programlisting>
</section>
@@ -1031,7 +1030,7 @@
<programlisting>session.addEventListener( new DebugWorkingMemoryEventListener() ); </programlisting>
- <para>The Eclipse based Rule IDE also provides an audit logger and
+ <para>The Eclipse-based Rule IDE also provides an audit logger and
graphical viewer, so that the rule engine can log events for later
viewing, and auditing.</para>
</section>
Modified: labs/jbossrules/branches/temporal_rete/drools-docs/drools-docs-userguide/en/Chapter-Rule_Engine/Section-Why_use_a_Rule_Engine.xml
===================================================================
--- labs/jbossrules/branches/temporal_rete/drools-docs/drools-docs-userguide/en/Chapter-Rule_Engine/Section-Why_use_a_Rule_Engine.xml 2008-03-20 18:57:07 UTC (rev 19163)
+++ labs/jbossrules/branches/temporal_rete/drools-docs/drools-docs-userguide/en/Chapter-Rule_Engine/Section-Why_use_a_Rule_Engine.xml 2008-03-20 19:32:10 UTC (rev 19164)
@@ -66,7 +66,7 @@
<para>Speed and Scalability</para>
<para>The Rete algorithm, Leaps algorithm, and its descendants such as
- Drools' Reteoo (and Leaps), provide very efficient ways of matching
+ Drools' ReteOO (and Leaps), provide very efficient ways of matching
rule patterns to your domain object data. These are especially
efficient when you have datasets that do not change entirely (as the
rule engine can remember past matches). These algorithms are battle
Modified: labs/jbossrules/branches/temporal_rete/drools-docs/drools-docs-userguide/en/Chapter-Rule_Language/Section-DSL.xml
===================================================================
--- labs/jbossrules/branches/temporal_rete/drools-docs/drools-docs-userguide/en/Chapter-Rule_Language/Section-DSL.xml 2008-03-20 18:57:07 UTC (rev 19163)
+++ labs/jbossrules/branches/temporal_rete/drools-docs/drools-docs-userguide/en/Chapter-Rule_Language/Section-DSL.xml 2008-03-20 19:32:10 UTC (rev 19164)
@@ -67,7 +67,7 @@
part on the right of the "=" is the mapping into the rule language (of
course the form of this depends on if you are talking about the RHS or the
LHS - if its the LHS, then its the normal LHS syntax, if its the RHS then
- its fragments of java code for instance).</para>
+ its fragments of Java code for instance).</para>
<para>The parser will take the expression you specify, and extract the
values that match where the {something} (named Tokens) appear in the
Modified: labs/jbossrules/branches/temporal_rete/drools-docs/drools-docs-userguide/en/Chapter-Rule_Language/Section-Function.xml
===================================================================
--- labs/jbossrules/branches/temporal_rete/drools-docs/drools-docs-userguide/en/Chapter-Rule_Language/Section-Function.xml 2008-03-20 18:57:07 UTC (rev 19163)
+++ labs/jbossrules/branches/temporal_rete/drools-docs/drools-docs-userguide/en/Chapter-Rule_Language/Section-Function.xml 2008-03-20 19:32:10 UTC (rev 19164)
@@ -19,7 +19,7 @@
</figure>
<para>Functions are a way to put semantic code in your rule source file, as
- opposed to in normal java classes. They can't do anything more then what you
+ opposed to in normal Java classes. They can't do anything more then what you
can do with helper classes (in fact, the compiler generates the helper class
for you behind the scenes). The main advantage of using functions in a rule
is that you can keep the logic all in one place, and you can change the
@@ -37,7 +37,7 @@
</programlisting>
<para>Note that the "function" keyword is used, even though its not really
- part of java. Parameters to the function are just like a normal method (and
+ part of Java. Parameters to the function are just like a normal method (and
you don't have to have parameters if they are not needed). Return type is
just like a normal method.</para>
Modified: labs/jbossrules/branches/temporal_rete/drools-docs/drools-docs-userguide/en/Chapter-Rule_Language/Section-Package.xml
===================================================================
--- labs/jbossrules/branches/temporal_rete/drools-docs/drools-docs-userguide/en/Chapter-Rule_Language/Section-Package.xml 2008-03-20 18:57:07 UTC (rev 19163)
+++ labs/jbossrules/branches/temporal_rete/drools-docs/drools-docs-userguide/en/Chapter-Rule_Language/Section-Package.xml 2008-03-20 19:32:10 UTC (rev 19164)
@@ -25,7 +25,7 @@
<para>The following rail road diagram shows all the components that may make
up a package. Note that a package MUST have a namespace and be declared
- using standard java conventions for package names; i.e. no spaces, unlike
+ using standard Java conventions for package names; i.e. no spaces, unlike
rule names which allow spaces. In terms of the order of elements, they can
appear in any order in the rule file, with the exception of the "package"
and "expander" statements being at the top of the file, before any rules
@@ -59,7 +59,7 @@
<para>Import statements work like import statements in Java. You need to
specify the fully qualified paths and type names for any objects you want
to use in the rules. Drools automatically imports classes from the same
- named java package and from the java.lang package.</para>
+ named Java package and from the java.lang package.</para>
</section>
<section>
Modified: labs/jbossrules/branches/temporal_rete/drools-docs/drools-docs-userguide/en/Chapter-Rule_Language/Section-Rule.xml
===================================================================
--- labs/jbossrules/branches/temporal_rete/drools-docs/drools-docs-userguide/en/Chapter-Rule_Language/Section-Rule.xml 2008-03-20 18:57:07 UTC (rev 19163)
+++ labs/jbossrules/branches/temporal_rete/drools-docs/drools-docs-userguide/en/Chapter-Rule_Language/Section-Rule.xml 2008-03-20 19:32:10 UTC (rev 19164)
@@ -480,7 +480,7 @@
<title>JavaBeans as facts</title>
<para>A field is an accessible method on the object. If your model
- objects follow the java bean pattern, then fields are exposed using
+ objects follow the Java bean pattern, then fields are exposed using
"getXXX" or "isXXX" methods (these are methods that take no
arguments, and return something). You can access fields either by
using the bean-name convention (so "getType" can be accessed as
@@ -607,7 +607,7 @@
</indexterm>Regular Expression. Typically that regexp is a
String, but variables that resolve to a valid regexp are also
allowed. It is important to note that <emphasis>different from
- java</emphasis>, if you write a String regexp directly on the
+ Java</emphasis>, if you write a String regexp directly on the
source file, <emphasis>you don't need to escape '\'</emphasis>.
Example:</para>
@@ -627,7 +627,7 @@
fields. Returns true when the match is false. Typically that
regexp is a String, but variables that resolve to a valid regexp
are also allowed.It is important to note that
- <emphasis>different from java</emphasis>, if you write a String
+ <emphasis>different from Java</emphasis>, if you write a String
regexp directly on the source file, <emphasis>you don't need to
escape '\'</emphasis>. Example:</para>
@@ -751,7 +751,7 @@
<simplesect>
<title>Numeric</title>
- <para>All standard java numeric primitives are supported.</para>
+ <para>All standard Java numeric primitives are supported.</para>
<example>
<title>Numeric Literal Restriction</title>
@@ -851,7 +851,7 @@
<para>'likes' is our variable, our Declaration, that is bound to
the favouriteCheese field for any matching Person instance and
is used to constrain the type of Cheese in the following
- Pattern. Any valid java variable name can be used, including
+ Pattern. Any valid Java variable name can be used, including
'$'; which you will often see used to help differentiate
declarations from fields. The example below shows a declaration
bound to the Patterns Object Type instance itself and used with
@@ -1530,7 +1530,7 @@
<para>The <emphasis role="bold">collect</emphasis> CE result pattern can
be any concrete class that implements tha java.util.Collection interface
and provides a default no-arg public constructor. I.e., you can use
- default java collections like ArrayList, LinkedList, HashSet, etc, or
+ default Java collections like ArrayList, LinkedList, HashSet, etc, or
your own class, as long as it implements the java.util.Collection
interface and provide a default no-arg public constructor.</para>
@@ -1675,7 +1675,7 @@
result with the Number() pattern and if the double value is greater than
100, the rule will fire.</para>
- <para>The example used java as the semantic dialect, and as such, note
+ <para>The example used Java as the semantic dialect, and as such, note
that the usage of ';' is mandatory in the init, action and reverse code
blocks. The result is an expression and as such, it does not admit ';'.
If the user uses any other dialect, he must comply to that dialect
@@ -1775,7 +1775,7 @@
needed, custom, domain specific functions can easily be added to the
engine and rules can start to use them without any restrictions. To
implement a new Accumulate Functions all one needs to do is to create
- a java class that implements the
+ a Java class that implements the
org.drools.base.acumulators.AccumulateFunction interface and add a
line to the configuration file or set a system property to let the
engine know about the new function. As an example of an Accumulate
@@ -1919,7 +1919,7 @@
cuts to the KnowldgeHelper instance (refer to the KnowledgeHelper
interface for more advanced operations). The KnowledgeHelper interface is
made available to the RHS code block as a variable called "drools". If you
- provide "Property Change Listeners" to your java beans that you are
+ provide "Property Change Listeners" to your Java beans that you are
inserting into the engine, you can avoid the need to call "update" when
the object changes.</para>
</section>
Modified: labs/jbossrules/branches/temporal_rete/drools-docs/drools-docs-userguide/en/Chapter-Rule_Language/Section-RuleFlow.xml
===================================================================
--- labs/jbossrules/branches/temporal_rete/drools-docs/drools-docs-userguide/en/Chapter-Rule_Language/Section-RuleFlow.xml 2008-03-20 18:57:07 UTC (rev 19163)
+++ labs/jbossrules/branches/temporal_rete/drools-docs/drools-docs-userguide/en/Chapter-Rule_Language/Section-RuleFlow.xml 2008-03-20 19:32:10 UTC (rev 19164)
@@ -80,7 +80,7 @@
<title>How to build a rule flow</title>
<para>Ruleflows can only be created by using the graphical ruleflow editor which is
- part of the Drools plugin for Eclipse. Once you have set up a Drools project (check
+ part of the Drools plug-in for Eclipse. Once you have set up a Drools project (check
the IDE chapter if you do not know how to do this), you can start adding ruleflows.
When in a project, use "control+N" to launch the new wizard, or right-click the directory
you would like to put your ruleflow in and select "New ... Other ...":</para>
@@ -102,7 +102,7 @@
<para>Next you will see the graphical ruleflow editor. Now would be a good time to
switch to the "Drools perspective" (if you haven't done so already) - this will tweak the UI so
it is optimal for rules. Then ensure that you can see the "properties"
- panel down the bottom of the eclipse window, as it will be necessary to fill in the different
+ panel down the bottom of the Eclipse window, as it will be necessary to fill in the different
properties of the elements in your ruleflow. If you cannot see the properties view, open it using
the Menu Window - Show View - Other ..., and under the General folder select the Properties view.</para>
Modified: labs/jbossrules/branches/temporal_rete/drools-docs/drools-docs-userguide/en/Chapter-Rule_Language/Section-XML.xml
===================================================================
--- labs/jbossrules/branches/temporal_rete/drools-docs/drools-docs-userguide/en/Chapter-Rule_Language/Section-XML.xml 2008-03-20 18:57:07 UTC (rev 19163)
+++ labs/jbossrules/branches/temporal_rete/drools-docs/drools-docs-userguide/en/Chapter-Rule_Language/Section-XML.xml 2008-03-20 19:32:10 UTC (rev 19164)
@@ -33,7 +33,7 @@
between XML formats). Note you can always generate normal DRL as
well.</para>
- <para>Alternatively you may be embedding drools in a product that already
+ <para>Alternatively you may be embedding Drools in a product that already
uses XML for configuration, so you would like the rules to be in an XML
format. You may be creating your own rule language on XML - note that you
can always use the AST objects directly to create your own rule language
@@ -283,7 +283,7 @@
specify a type (class) and perhaps bind a variable to an instance of that
class. Nested under the pattern object are constraints and conditional
elements that have to be met. The Predicate and Return Value constraints
- allow java expressions to be embedded.</para>
+ allow Java expressions to be embedded.</para>
<para>That leaves the conditional elements, not, exists, and, or etc. They
work like their DRL counterparts. Elements that are nested under and an
@@ -292,7 +292,7 @@
for the existence or non existence of a fact meeting its
constraints.</para>
- <para>The Eval element allows the execution of a valid snippet of java
+ <para>The Eval element allows the execution of a valid snippet of Java
code - as long as it evaluates to a boolean (do not end it with a
semi-colon, as it is just a fragment) - this can include calling a
function. The Eval is less efficient then then columns, as the rule engine
Modified: labs/jbossrules/branches/temporal_rete/drools-docs/drools-docs-userguide/en/master.xml
===================================================================
--- labs/jbossrules/branches/temporal_rete/drools-docs/drools-docs-userguide/en/master.xml 2008-03-20 18:57:07 UTC (rev 19163)
+++ labs/jbossrules/branches/temporal_rete/drools-docs/drools-docs-userguide/en/master.xml 2008-03-20 19:32:10 UTC (rev 19164)
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
-<book xmlns:xi="http://www.w3.org/2003/XInclude">
+<book xmlns:xi="http://www.w3.org/2001/XInclude">
<bookinfo>
<title>Drools User Guide</title>
Modified: labs/jbossrules/branches/temporal_rete/drools-eclipse/drools-eclipse-plugin/src/main/resources/org/drools/eclipse/wizard/project/RuleFlowLauncherSample.java.template
===================================================================
--- labs/jbossrules/branches/temporal_rete/drools-eclipse/drools-eclipse-plugin/src/main/resources/org/drools/eclipse/wizard/project/RuleFlowLauncherSample.java.template 2008-03-20 18:57:07 UTC (rev 19163)
+++ labs/jbossrules/branches/temporal_rete/drools-eclipse/drools-eclipse-plugin/src/main/resources/org/drools/eclipse/wizard/project/RuleFlowLauncherSample.java.template 2008-03-20 19:32:10 UTC (rev 19164)
@@ -50,7 +50,7 @@
PackageBuilder builder = new PackageBuilder();
- //this wil parse and compile in one step
+ //this will parse and compile in one step
//NOTE: There are 2 methods here, the one argument one is for normal DRL.
builder.addPackageFromDrl( source );
Modified: labs/jbossrules/branches/temporal_rete/drools-eclipse/drools-eclipse-plugin/src/main/resources/org/drools/eclipse/wizard/project/RuleLauncherSample.java.template
===================================================================
--- labs/jbossrules/branches/temporal_rete/drools-eclipse/drools-eclipse-plugin/src/main/resources/org/drools/eclipse/wizard/project/RuleLauncherSample.java.template 2008-03-20 18:57:07 UTC (rev 19163)
+++ labs/jbossrules/branches/temporal_rete/drools-eclipse/drools-eclipse-plugin/src/main/resources/org/drools/eclipse/wizard/project/RuleLauncherSample.java.template 2008-03-20 19:32:10 UTC (rev 19164)
@@ -49,7 +49,7 @@
PackageBuilder builder = new PackageBuilder();
- //this wil parse and compile in one step
+ //this will parse and compile in one step
//NOTE: There are 2 methods here, the one argument one is for normal DRL.
builder.addPackageFromDrl( source );
Modified: labs/jbossrules/branches/temporal_rete/drools-examples/drools-examples-drl/src/main/java/org/drools/benchmark/manners/MannersBenchmark.java
===================================================================
--- labs/jbossrules/branches/temporal_rete/drools-examples/drools-examples-drl/src/main/java/org/drools/benchmark/manners/MannersBenchmark.java 2008-03-20 18:57:07 UTC (rev 19163)
+++ labs/jbossrules/branches/temporal_rete/drools-examples/drools-examples-drl/src/main/java/org/drools/benchmark/manners/MannersBenchmark.java 2008-03-20 19:32:10 UTC (rev 19164)
@@ -2,6 +2,7 @@
import java.io.BufferedReader;
import java.io.ByteArrayInputStream;
+import java.io.File;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
@@ -9,13 +10,17 @@
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
+import java.util.Properties;
import java.util.Random;
import java.util.StringTokenizer;
import org.drools.RuleBase;
+import org.drools.RuleBaseConfiguration;
+import org.drools.RuleBaseConfigurationTest;
import org.drools.RuleBaseFactory;
import org.drools.StatefulSession;
import org.drools.compiler.PackageBuilder;
+import org.drools.compiler.PackageBuilderConfiguration;
import org.drools.rule.Package;
public class MannersBenchmark {
@@ -32,13 +37,20 @@
private int maxHobbies = 3;
public static void main(final String[] args) throws Exception {
- PackageBuilder builder = new PackageBuilder();
+ PackageBuilderConfiguration config = new PackageBuilderConfiguration();
+ config.setDumpDir( new File("/stash") );
+
+ PackageBuilder builder = new PackageBuilder(config);
builder.addPackageFromDrl(new InputStreamReader(MannersBenchmark.class
.getResourceAsStream("manners.drl")));
Package pkg = builder.getPackage();
+
- // add the package to a rulebase
- final RuleBase ruleBase = RuleBaseFactory.newRuleBase();
+ RuleBaseConfiguration conf = new RuleBaseConfiguration();
+ conf.setShadowProxy( false );
+
+ // add the package to a rulebase
+ final RuleBase ruleBase = RuleBaseFactory.newRuleBase(conf);
ruleBase.addPackage(pkg);
StatefulSession session = ruleBase.newStatefulSession();
Modified: labs/jbossrules/branches/temporal_rete/drools-examples/drools-examples-drl/src/main/java/org/drools/benchmark/waltz/WaltzBenchmark.java
===================================================================
--- labs/jbossrules/branches/temporal_rete/drools-examples/drools-examples-drl/src/main/java/org/drools/benchmark/waltz/WaltzBenchmark.java 2008-03-20 18:57:07 UTC (rev 19163)
+++ labs/jbossrules/branches/temporal_rete/drools-examples/drools-examples-drl/src/main/java/org/drools/benchmark/waltz/WaltzBenchmark.java 2008-03-20 19:32:10 UTC (rev 19164)
@@ -40,10 +40,10 @@
PackageBuilder builder = new PackageBuilder();
builder.addPackageFromDrl( new InputStreamReader( WaltzBenchmark.class.getResourceAsStream( "waltz.drl" ) ) );
Package pkg = builder.getPackage();
-
//add the package to a rulebase
RuleBaseConfiguration conf = new RuleBaseConfiguration();
//conf.setAlphaMemory( true );
+ conf.setShadowProxy( false );
final RuleBase ruleBase = RuleBaseFactory.newRuleBase( conf );
ruleBase.addPackage( pkg );
Modified: labs/jbossrules/branches/temporal_rete/drools-examples/drools-examples-drl/src/main/java/org/drools/examples/HelloWorldExample.java
===================================================================
--- labs/jbossrules/branches/temporal_rete/drools-examples/drools-examples-drl/src/main/java/org/drools/examples/HelloWorldExample.java 2008-03-20 18:57:07 UTC (rev 19163)
+++ labs/jbossrules/branches/temporal_rete/drools-examples/drools-examples-drl/src/main/java/org/drools/examples/HelloWorldExample.java 2008-03-20 19:32:10 UTC (rev 19164)
@@ -28,7 +28,7 @@
final PackageBuilder builder = new PackageBuilder();
- //this wil parse and compile in one step
+ //this will parse and compile in one step
builder.addPackageFromDrl( source );
// Check the builder for errors
Modified: labs/jbossrules/branches/temporal_rete/drools-examples/drools-examples-drl/src/main/java/org/drools/examples/sudoku/rules/DroolsUtil.java
===================================================================
--- labs/jbossrules/branches/temporal_rete/drools-examples/drools-examples-drl/src/main/java/org/drools/examples/sudoku/rules/DroolsUtil.java 2008-03-20 18:57:07 UTC (rev 19163)
+++ labs/jbossrules/branches/temporal_rete/drools-examples/drools-examples-drl/src/main/java/org/drools/examples/sudoku/rules/DroolsUtil.java 2008-03-20 19:32:10 UTC (rev 19164)
@@ -48,7 +48,7 @@
PackageBuilder builder = new PackageBuilder();
- //this wil parse and compile in one step
+ //this will parse and compile in one step
//NOTE: There are 2 methods here, the one argument one is for normal DRL.
builder.addPackageFromDrl( source );
Modified: labs/jbossrules/branches/temporal_rete/drools-examples/drools-examples-drl/src/main/rules/org/drools/benchmark/manners/manners.drl
===================================================================
--- labs/jbossrules/branches/temporal_rete/drools-examples/drools-examples-drl/src/main/rules/org/drools/benchmark/manners/manners.drl 2008-03-20 18:57:07 UTC (rev 19163)
+++ labs/jbossrules/branches/temporal_rete/drools-examples/drools-examples-drl/src/main/rules/org/drools/benchmark/manners/manners.drl 2008-03-20 19:32:10 UTC (rev 19164)
@@ -14,13 +14,11 @@
Path path = new Path( count.getValue(), 1, guestName );
insert( path );
- count.setValue( count.getValue() + 1 );
- update( count );
+ modify( count ) { setValue ( count.getValue() + 1 ) }
System.out.println( "assign first seat : " + seating + " : " + path );
- context.setState( Context.ASSIGN_SEATS );
- update( context );
+ modify( context ) { setState( Context.ASSIGN_SEATS ) }
end
rule findSeating
@@ -50,11 +48,8 @@
System.err.println( "find seating : " + seating + " : " + path + " : " + chosen);
- count.setValue( countValue + 1 );
- update( count );
-
- context.setState( Context.MAKE_PATH );
- update( context );
+ modify( count ) {setValue( countValue + 1 )}
+ modify( context ) {setState( Context.MAKE_PATH )}
end
rule makePath
@@ -72,11 +67,9 @@
context : Context( state == Context.MAKE_PATH )
seating : Seating( pathDone == false )
then
- seating.setPathDone( true );
- update( seating );
+ modify( seating ) {setPathDone( true )}
- context.setState( Context.CHECK_DONE );
- update( context );
+ modify( context ) {setState( Context.CHECK_DONE)}
end
@@ -86,16 +79,14 @@
LastSeat( lastSeat: seat )
Seating( rightSeat == lastSeat )
then
- context.setState(Context.PRINT_RESULTS );
- update( context );
+ modify( context ) {setState(Context.PRINT_RESULTS )}
end
rule continue
when
context : Context( state == Context.CHECK_DONE )
then
- context.setState( Context.ASSIGN_SEATS );
- update( context );
+ modify( context ) {setState( Context.ASSIGN_SEATS )}
end
Modified: labs/jbossrules/branches/temporal_rete/drools-examples/drools-examples-drl/src/main/rules/org/drools/benchmark/waltz/waltz.drl
===================================================================
--- labs/jbossrules/branches/temporal_rete/drools-examples/drools-examples-drl/src/main/rules/org/drools/benchmark/waltz/waltz.drl 2008-03-20 18:57:07 UTC (rev 19163)
+++ labs/jbossrules/branches/temporal_rete/drools-examples/drools-examples-drl/src/main/rules/org/drools/benchmark/waltz/waltz.drl 2008-03-20 19:32:10 UTC (rev 19164)
@@ -30,8 +30,7 @@
$stage: Stage ( value == Stage.DUPLICATE )
not ( Line() )
then
- $stage.setValue ( Stage.DETECT_JUNCTIONS );
- update($stage);
+ modify($stage) {setValue ( Stage.DETECT_JUNCTIONS )}
long current = System.currentTimeMillis();
System.out.println("reversing done : " + ( current - time ) );
drools.getWorkingMemory().setGlobal( "time", current);
@@ -52,12 +51,9 @@
Junction junction = WaltzUtil.make_3_junction( $basePoint, $edge1P2, $edge2P2, $edge3P2 );
System.out.println( junction );
insert( junction );
- $edge1.setJoined(true);
- $edge2.setJoined(true);
- $edge3.setJoined(true);
- update( $edge1 );
- update( $edge2 );
- update( $edge3 );
+ modify( $edge1 ) {setJoined(true)}
+ modify( $edge2 ) {setJoined(true)}
+ modify( $edge3 ) {setJoined(true)}
end
#If two, and only two, edges meet that have not already been joined, then
@@ -70,10 +66,8 @@
not Edge( p1==$basePoint, p2 != $edge1P2, p2 != $edge2P2 )
then
insert( new Junction($edge1P2, $edge2P2, 0, $basePoint, Junction.L) );
- $edge1.setJoined(true);
- $edge2.setJoined(true);
- update( $edge1 );
- update( $edge2 );
+ modify( $edge1 ) {setJoined(true)}
+ modify( $edge2 ) {setJoined(true)}
System.out.println("make L");
end
@@ -83,8 +77,7 @@
when
$stage : Stage ( value == Stage.DETECT_JUNCTIONS )
then
- $stage.setValue( Stage.FIND_INITIAL_BOUNDARY );
- update( $stage );
+ modify( $stage ) {setValue( Stage.FIND_INITIAL_BOUNDARY )}
System.out.println("detecting done");
end
@@ -97,12 +90,9 @@
$edge2 : Edge ( p1 == $basePoint, p2 == $p2 )
not Junction( basePoint > $basePoint )
then
- $edge1.setLabel( Edge.B );
- $edge2.setLabel( Edge.B );
- $stage.setValue( Stage.FIND_SECOND_BOUNDARY );
- update( $edge1 );
- update( $edge2 );
- update( $stage );
+ modify( $edge1 ) {setLabel( Edge.B )}
+ modify( $edge2 ) {setLabel( Edge.B )}
+ modify( $stage ) {setValue( Stage.FIND_SECOND_BOUNDARY )}
System.out.println("initial boundary junction L");
end
@@ -116,14 +106,10 @@
$edge3 : Edge ( p1 == $basePoint, p2 == $p3 )
not Junction( basePoint > $basePoint )
then
- $edge1.setLabel( Edge.B );
- $edge2.setLabel( Edge.PLUS );
- $edge3.setLabel( Edge.B );
- $stage.setValue( Stage.FIND_SECOND_BOUNDARY );
- update( $edge1 );
- update( $edge2 );
- update( $edge3 );
- update( $stage );
+ modify( $edge1 ) {setLabel( Edge.B )}
+ modify( $edge2 ) {setLabel( Edge.PLUS )}
+ modify( $edge3 ) {setLabel( Edge.B )}
+ modify( $stage ) {setValue( Stage.FIND_SECOND_BOUNDARY )}
System.out.println("initial boundary junction arrow");
end
@@ -137,12 +123,9 @@
$edge2 : Edge ( p1 == $basePoint, p2 == $p2 )
not Junction( basePoint < $basePoint )
then
- $edge1.setLabel( Edge.B );
- $edge2.setLabel( Edge.B );
- $stage.setValue( Stage.LABELING );
- update( $edge1 );
- update( $edge2 );
- update( $stage );
+ modify( $edge1 ) {setLabel( Edge.B )}
+ modify( $edge2 ) {setLabel( Edge.B )}
+ modify( $stage ) {setValue( Stage.LABELING )}
System.out.println("second boundary junction L");
end
@@ -156,14 +139,10 @@
$edge3 : Edge ( p1 == $basePoint, p2 == $p3 )
not Junction( basePoint < $basePoint )
then
- $edge1.setLabel( Edge.B );
- $edge2.setLabel( Edge.PLUS );
- $edge3.setLabel( Edge.B );
- $stage.setValue( Stage.LABELING );
- update( $edge1 );
- update( $edge2 );
- update( $edge3 );
- update( $stage );
+ modify( $edge1 ) {setLabel( Edge.B )}
+ modify( $edge2 ) {setLabel( Edge.PLUS )}
+ modify( $edge3 ) {setLabel( Edge.B )}
+ modify( $stage ) {setValue( Stage.LABELING )}
System.out.println("second boundary junction arrow");
end
@@ -175,11 +154,8 @@
$edge1: Edge( $p1:p1, $p2:p2, $label:label in ( Edge.PLUS, Edge.MINUS, Edge.B ) )
$edge2: Edge( p1 == $p2, p2 == $p1, label == Edge.NIL )
then
- $edge1.setPlotted( true );
- $edge2.setLabel( $label );
- $edge2.setPlotted( true );
- update( $edge1 );
- update( $edge2 );
+ modify( $edge1 ) {setPlotted( true )}
+ modify( $edge2 ) {setLabel( $label ), setPlotted( true ) }
System.out.println("match edge - Plot "+$label+" "+$p1+" "+$p2);
end
@@ -197,8 +173,7 @@
Edge( p1 == $basePoint, $Edge1P2 : p2, label in ( Edge.PLUS, Edge.MINUS ) )
$edge: Edge( p1 == $basePoint, p2 != $Edge1P2, label == Edge.NIL )
then
- $edge.setLabel( Edge.B );
- update( $edge );
+ modify( $edge ) {setLabel( Edge.B )}
System.out.println("Label L");
end
@@ -209,10 +184,8 @@
$edge1: Edge( p1 == $basePoint, p2 == $p1, label == Edge.NIL )
$edge2: Edge( p1 == $basePoint, p2 == $p3 )
then
- $edge1.setLabel( Edge.B );
- $edge2.setLabel( Edge.B );
- update( $edge1 );
- update( $edge2 );
+ modify( $edge1 ) {setLabel( Edge.B )}
+ modify( $edge2 ) {setLabel( Edge.B )}
System.out.println("Label tee A");
end
@@ -224,10 +197,8 @@
$edge1: Edge( p1 == $basePoint, p2 == $p1 )
$edge2: Edge( p1 == $basePoint, p2 == $p3, label == Edge.NIL )
then
- $edge1.setLabel( Edge.B );
- $edge2.setLabel( Edge.B );
- update( $edge1 );
- update( $edge2 );
+ modify( $edge1 ) {setLabel( Edge.B )}
+ modify( $edge2 ) {setLabel( Edge.B )}
System.out.println("Label tee B");
end
@@ -239,10 +210,8 @@
$edge1: Edge( p1 == $basePoint, $p2:p2 != $p1, label == Edge.NIL )
$edge2: Edge( p1 == $basePoint, p2 != $p1, p2 != $p2 )
then
- $edge1.setLabel( Edge.PLUS );
- $edge2.setLabel( Edge.PLUS );
- update( $edge1 );
- update( $edge2 );
+ modify( $edge1 ) {setLabel( Edge.PLUS )}
+ modify( $edge2 ) {setLabel( Edge.PLUS )}
System.out.println("label fork 1");
end
@@ -254,8 +223,7 @@
Edge( p1 == $basePoint, $p2:p2 != $p1, label == Edge.MINUS )
$edge: Edge( p1 == $basePoint, p2 != $p1, p2 != $p2, label == Edge.NIL )
then
- $edge.setLabel( Edge.B );
- update( $edge );
+ modify( $edge ) {setLabel( Edge.B )}
System.out.println("label fork 2");
end
@@ -267,8 +235,7 @@
Edge( p1 == $basePoint, $p2:p2 != $p1, label == Edge.B )
$edge: Edge( p1 == $basePoint, p2 != $p1, p2 != $p2, label == Edge.NIL )
then
- $edge.setLabel( Edge.MINUS );
- update( $edge );
+ modify( $edge ) {setLabel( Edge.MINUS )}
System.out.println("label fork 3");
end
@@ -280,8 +247,7 @@
Edge( p1 == $basePoint, $p2:p2 != $p1, label == Edge.MINUS )
$edge: Edge( p1 == $basePoint, p2 != $p1, p2 != $p2, label == Edge.NIL )
then
- $edge.setLabel( Edge.MINUS );
- update( $edge );
+ modify( $edge ) {setLabel( Edge.MINUS )}
System.out.println("label fork 4");
end
@@ -293,10 +259,8 @@
$edge1: Edge( p1 == $basePoint, p2 == $p2, label == Edge.NIL )
$edge2: Edge( p1 == $basePoint, p2 == $p3 )
then
- $edge1.setLabel( Edge.PLUS );
- $edge2.setLabel( $label );
- update( $edge1 );
- update( $edge2 );
+ modify( $edge1 ) {setLabel( Edge.PLUS )}
+ modify( $edge2 ) {setLabel( $label )}
System.out.println("label arrow 1A");
end
@@ -308,10 +272,8 @@
$edge1: Edge( p1 == $basePoint, p2 == $p2 )
$edge2: Edge( p1 == $basePoint, p2 == $p3, label == Edge.NIL )
then
- $edge1.setLabel( Edge.PLUS );
- $edge2.setLabel( $label );
- update( $edge1 );
- update( $edge2 );
+ modify( $edge1 ) {setLabel( Edge.PLUS )}
+ modify( $edge2 ) {setLabel( $label )}
System.out.println("label arrow 1B");
end
@@ -323,10 +285,8 @@
$edge1: Edge( p1 == $basePoint, p2 == $p2, label == Edge.NIL )
$edge2: Edge( p1 == $basePoint, p2 == $p1 )
then
- $edge1.setLabel( Edge.PLUS );
- $edge2.setLabel( $label );
- update( $edge1 );
- update( $edge2 );
+ modify( $edge1 ) {setLabel( Edge.PLUS )}
+ modify( $edge2 ) {setLabel( $label )}
System.out.println("label arrow 2A");
end
@@ -338,10 +298,8 @@
$edge1: Edge( p1 == $basePoint, p2 == $p2 )
$edge2: Edge( p1 == $basePoint, p2 == $p1, label == Edge.NIL )
then
- $edge1.setLabel( Edge.PLUS );
- $edge2.setLabel( $label );
- update( $edge1 );
- update( $edge2 );
+ modify( $edge1 ) {setLabel( Edge.PLUS )}
+ modify( $edge2 ) {setLabel( $label )}
System.out.println("label arrow 2B");
end
@@ -353,10 +311,8 @@
$edge1: Edge( p1 == $basePoint, p2 == $p2, label == Edge.NIL )
$edge2: Edge( p1 == $basePoint, p2 == $p3 )
then
- $edge1.setLabel( Edge.MINUS );
- $edge2.setLabel( Edge.PLUS );
- update( $edge1 );
- update( $edge2 );
+ modify( $edge1 ) {setLabel( Edge.MINUS )}
+ modify( $edge2 ) {setLabel( Edge.PLUS )}
System.out.println("label arrow 3A");
end
@@ -368,10 +324,8 @@
$edge1: Edge( p1 == $basePoint, p2 == $p2 )
$edge2: Edge( p1 == $basePoint, p2 == $p3, label == Edge.NIL )
then
- $edge1.setLabel( Edge.MINUS );
- $edge2.setLabel( Edge.PLUS );
- update( $edge1 );
- update( $edge2 );
+ modify( $edge1 ) {setLabel( Edge.MINUS )}
+ modify( $edge2 ) {setLabel( Edge.PLUS )}
System.out.println("label arrow 3B");
end
@@ -383,10 +337,8 @@
$edge1: Edge( p1 == $basePoint, p2 == $p2, label == Edge.NIL )
$edge2: Edge( p1 == $basePoint, p2 == $p1 )
then
- $edge1.setLabel( Edge.MINUS );
- $edge2.setLabel( Edge.PLUS );
- update( $edge1 );
- update( $edge2 );
+ modify( $edge1 ) {setLabel( Edge.MINUS )}
+ modify( $edge2 ) {setLabel( Edge.PLUS )}
System.out.println("label arrow 4A");
end
@@ -398,10 +350,8 @@
$edge1: Edge( p1 == $basePoint, p2 == $p2 )
$edge2: Edge( p1 == $basePoint, p2 == $p1, label == Edge.NIL )
then
- $edge1.setLabel( Edge.MINUS );
- $edge2.setLabel( Edge.PLUS );
- update( $edge1 );
- update( $edge2 );
+ modify( $edge1 ) {setLabel( Edge.MINUS )}
+ modify( $edge2 ) {setLabel( Edge.PLUS )}
System.out.println("label arrow 4B");
end
@@ -413,10 +363,8 @@
$edge1: Edge( p1 == $basePoint, p2 == $p1 )
$edge2: Edge( p1 == $basePoint, p2 == $p3, label == Edge.NIL )
then
- $edge1.setLabel( Edge.PLUS );
- $edge2.setLabel( Edge.PLUS );
- update( $edge1 );
- update( $edge2 );
+ modify( $edge1 ) {setLabel( Edge.PLUS )}
+ modify( $edge2 ) {setLabel( Edge.PLUS )}
System.out.println("label arrow 5A");
end
@@ -428,10 +376,8 @@
$edge1: Edge( p1 == $basePoint, p2 == $p1, label == Edge.NIL )
$edge2: Edge( p1 == $basePoint, p2 == $p3 )
then
- $edge1.setLabel( Edge.PLUS );
- $edge2.setLabel( Edge.PLUS );
- update( $edge1 );
- update( $edge2 );
+ modify( $edge1 ) {setLabel( Edge.PLUS )}
+ modify( $edge2 ) {setLabel( Edge.PLUS )}
System.out.println("label arrow 5B");
end
@@ -443,8 +389,7 @@
when
$stage: Stage( value == Stage.LABELING )
then
- $stage.setValue( Stage.PLOT_REMAINING_EDGES );
- update( $stage );
+ modify( $stage ) {setValue( Stage.PLOT_REMAINING_EDGES )}
System.out.println("done labeling");
end
@@ -455,8 +400,7 @@
$edge: Edge( plotted == false, $label:label != Edge.NIL, $p1:p1, $p2:p2 )
then
System.out.println("Plot "+$label+" "+$p1+" "+$p2);
- $edge.setPlotted( true );
- update( $edge );
+ modify( $edge ) {setPlotted( true )}
end
# If we have been un able to label an edge, assume that it is a boundary.
@@ -468,8 +412,7 @@
$edge: Edge( plotted == false, label == Edge.NIL, $p1:p1, $p2:p2 )
then
System.out.println("Plot B "+$p1+" "+$p2);
- $edge.setPlotted( true );
- update( $edge );
+ modify( $edge ) {setPlotted( true )}
end
# If there is no more work to do, then we are done and flag it.
@@ -477,7 +420,6 @@
when
$stage: Stage( value == Stage.PLOT_REMAINING_EDGES )
then
- $stage.setValue( Stage.DONE );
- update( $stage );
+ modify( $stage ) {setValue( Stage.DONE )}
System.out.println("Stage: done");
end
\ No newline at end of file
Modified: labs/jbossrules/branches/temporal_rete/drools-examples/drools-examples-drl/src/main/rules/org/drools/benchmark/waltzdb/waltzdb.drl
===================================================================
--- labs/jbossrules/branches/temporal_rete/drools-examples/drools-examples-drl/src/main/rules/org/drools/benchmark/waltzdb/waltzdb.drl 2008-03-20 18:57:07 UTC (rev 19163)
+++ labs/jbossrules/branches/temporal_rete/drools-examples/drools-examples-drl/src/main/rules/org/drools/benchmark/waltzdb/waltzdb.drl 2008-03-20 19:32:10 UTC (rev 19164)
@@ -40,8 +40,7 @@
$stage : Stage( value == Stage.DUPLICATE )
not ( Line( ) )
then
- $stage.setValue( Stage.DETECT_JUNCTIONS );
- update( $stage );
+ modify( $stage ) {setValue( Stage.DETECT_JUNCTIONS )}
System.out.println( "Stage.DETECT_JUNCTIONS" );
end
@@ -71,15 +70,9 @@
Junction junction = new Junction( $basePoint, "3j", "make_3_junction " + $basePoint + " " + $p1 + " " + " " + $p2 + " " + $p3, "no" );
insert( junction );
System.out.println( junction.toString( ) );
- $edge1.setJoined( true );
- $edge1.setType( "3j" );
- $edge2.setJoined( true );
- $edge2.setType( "3j" );
- $edge3.setJoined( true );
- $edge3.setType( "3j" );
- update( $edge1 );
- update( $edge2 );
- update( $edge3 );
+ modify( $edge1 ) {setJoined( true ), setType( "3j" )}
+ modify( $edge2 ) {setJoined( true ), setType( "3j" )}
+ modify( $edge3 ) {setJoined( true ), setType( "3j" )}
end
/*
(p make_L
@@ -109,12 +102,8 @@
Junction junction = new Junction( "2j", "L", $basePoint, $p2, $p3, "no" );
insert( junction );
System.out.println( junction.toString() );
- $edge1.setJoined( true );
- $edge1.setType( "2j" );
- $edge2.setJoined( true );
- $edge2.setType( "2j" );
- update( $edge1 );
- update( $edge2 );
+ modify( $edge1 ) {setJoined( true ), setType( "2j" )}
+ modify( $edge2 ) {setJoined( true ), setType( "2j" )}
end
/*
@@ -130,8 +119,7 @@
$stage : Stage( value == Stage.DETECT_JUNCTIONS )
not( Edge ( joined == false ) )
then
- $stage.setValue( Stage.FIND_INITIAL_BOUNDARY );
- update( $stage );
+ modify( $stage ) {setValue( Stage.FIND_INITIAL_BOUNDARY )}
System.out.println( "Stage: FIND_INITIAL_BOUNDARY" );
end
@@ -156,12 +144,10 @@
Edge( p1 == $basePoint, p2 == $p2 )
not Junction( type == "2j", basePoint > $basePoint )//type == "2j" not in original
then
- $junction.setVisited( "yes" );
- update( $junction );
+ modify( $junction ) {setVisited( "yes" )}
insert( new EdgeLabel( $basePoint, $p1, "B", "1" ) );
insert( new EdgeLabel( $basePoint, $p2, "B", "1" ) );
- $stage.setValue( Stage.FIND_SECOND_BOUDARY );
- update( $stage );
+ modify( $stage ) {setValue( Stage.FIND_SECOND_BOUDARY )}
System.out.println( "Stage.FIND_SECOND_BOUDARY" );
end
/*
@@ -190,13 +176,11 @@
$edge3 : Edge( p1 == $basePoint, p2 == $p3 ) //@FIXME, is this correct? I changed edge2 to edge3
not ( Junction( basePoint > $basePoint ) )
then
- $junction.setVisited( "yes" );
- update( $junction );
+ modify( $junction ) {setVisited( "yes" )}
insert( new EdgeLabel( $basePoint, $p1, "B", "14" ) );
insert( new EdgeLabel( $basePoint, $p2, "+", "14" ) );
insert( new EdgeLabel( $basePoint, $p3, "B", "14" ) );
- $stage.setValue( Stage.FIND_SECOND_BOUDARY );
- update( $stage );
+ modify( $stage ) {setValue( Stage.FIND_SECOND_BOUDARY )}
System.out.println( "Stage.FIND_SECOND_BOUDARY" );
end
@@ -223,12 +207,10 @@
Edge( p1 == $basePoint, p2 == $p2)
not (Junction ( basePoint < $basePoint ) )
then
- $junction.setVisited( "yes" );
- update( $junction );
+ modify( $junction ) {setVisited( "yes" )}
insert( new EdgeLabel( $basePoint, $p1, "B", "1" ) );
insert( new EdgeLabel($basePoint, $p2, "B", "1" ) );
- $stage.setValue( Stage.LABELING );
- update( $stage );
+ modify( $stage ) {setValue( Stage.LABELING )}
System.out.println( "Stage.LABELING" );
end
@@ -258,13 +240,11 @@
Edge( p1 == $basePoint, p2 == $p3 )
not ( Junction( basePoint < $basePoint ) )
then
- $junction.setVisited( "yes" );
- update( $junction );
+ modify( $junction ) {setVisited( "yes" )}
insert( new EdgeLabel( $basePoint, $p1, "B", "14" ) );
insert( new EdgeLabel( $basePoint, $p2, "+", "14" ) );
insert( new EdgeLabel( $basePoint, $p3, "B", "14" ) );
- $stage.setValue( Stage.LABELING );
- update( $stage );
+ modify( $stage ) {setValue( Stage.LABELING )}
System.out.println( "Stage.LABELING" );
end
@@ -282,10 +262,8 @@
$stage : Stage( value == Stage.LABELING )
$junction : Junction( type == "3j", $basePoint : basePoint, $p1 : p1, $p2 : p2, $p3 : p3, visited == "no" )
then
- $stage.setValue( Stage.VISITING_3J );
- update( $stage );
- $junction.setVisited( "now" );
- update( $junction );
+ modify( $stage ) {setValue( Stage.VISITING_3J )}
+ modify( $junction ) {setVisited( "now" )}
System.out.println( "Stage.VISITING_3J" );
end
@@ -599,11 +577,9 @@
$stage : Stage( value == Stage.LABELING )
$junction : Junction( $basePoint : basePoint, type == "2j", $p1 : p1, $p2 : p2, visited == "no" )
then
- $stage.setValue( Stage.VISITING_2J );
- update( $stage );
+ modify( $stage ) {setValue( Stage.VISITING_2J )}
System.out.println( "Stage.VISITING_2J" );
- $junction.setVisited( "now" );
- update( $junction );
+ modify( $junction ) {setVisited( "now" )}
end
/*
@@ -746,8 +722,7 @@
$stage : ( Stage( value == Stage.VISITING_2J ) || Stage( value == Stage.VISITING_3J ) )
$junction : Junction( visited == "now" )
then
- $stage.setValue( Stage.MARKING );
- update( $stage );
+ modify( $stage ) {setValue( Stage.MARKING )}
System.out.println( "Stage.MARKING" );
end
/*
@@ -767,8 +742,7 @@
Edge( $p1 : p1, p2 == $basePoint )
$junction : Junction( basePoint == $p1, visited == "yes" )
then
- $junction.setVisited( "check" );
- update( $junction );
+ modify( $junction ) {setVisited( "check" )}
end
/*
@@ -784,8 +758,7 @@
Stage( value == Stage.MARKING )
$junction : Junction( $basePoint : basePoint, visited == "now" )
then
- $junction.setVisited( "yes" );
- update( $junction );
+ modify( $junction ) {setVisited( "yes" )}
end
/*
@@ -798,8 +771,7 @@
when
$stage : Stage( value == Stage.MARKING )
then
- $stage.setValue( Stage.CHECKING );
- update( $stage );
+ modify( $stage ) {setValue( Stage.CHECKING )}
System.out.println( "Stage.CHECKING" );
end
@@ -822,8 +794,7 @@
Junction( basePoint == $p2, visited == "yes" )
not ( EdgeLabel( p1 == $p2, p2 == $basePoint, labelName == $labelName ) )
then
- $stage.setValue( Stage.REMOVE_LABEL );
- update( $stage );
+ modify( $stage ) {setValue( Stage.REMOVE_LABEL )}
System.out.println( "Stage.REMOVE_LABEL" );
insert ( new Illegal( $basePoint, $labelId ) );
end
@@ -854,8 +825,7 @@
$edgeLabel2 : EdgeLabel( p1 == $basePoint, p2 == $p2, labelId == $labelId )
$edgeLabel3 : EdgeLabel( p1 == $basePoint, p2 == $p3, labelId == $labelId )
then
- $stage.setValue( Stage.CHECKING );
- update( $stage );
+ modify( $stage ) {setValue( Stage.CHECKING )}
System.out.println( "Stage.CHECKING" );
retract( $illegal );
retract( $edgeLabel1 );
@@ -886,8 +856,7 @@
$edgeLabel1 : EdgeLabel( p1 == $basePoint, p2 == $p1, labelId == $labelId )
$edgeLabel2 : EdgeLabel( p1 == $basePoint, p2 == $p2, labelId == $labelId )
then
- $stage.setValue( Stage.CHECKING );
- update( $stage );
+ modify( $stage ) {setValue( Stage.CHECKING )}
System.out.println( "Stage.CHECKING" );
retract( $illegal );
retract( $edgeLabel1 );
@@ -907,8 +876,7 @@
Stage( value == Stage.CHECKING )
$junction : Junction( $basePoint : basePoint, visited == "check" )
then
- $junction.setVisited( "yes" );
- update( $junction );
+ modify( $junction ) {setVisited( "yes" )}
end
/*
@@ -921,8 +889,7 @@
when
$stage : Stage( value == Stage.CHECKING )
then
- $stage.setValue( Stage.LABELING );
- update( $stage );
+ modify( $stage ) {setValue( Stage.LABELING )}
System.out.println( "Stage.LABELING" );
end
/*
@@ -935,8 +902,7 @@
when
$stage : Stage( value == Stage.LABELING )
then
- $stage.setValue( Stage.PRINTING );
- update( $stage );
+ modify( $stage ) {setValue( Stage.PRINTING )}
System.out.println( "Stage.PRINTING" );
end
Modified: labs/jbossrules/branches/temporal_rete/drools-examples/drools-examples-drl/src/main/rules/org/drools/examples/HonestPolitician.drl
===================================================================
--- labs/jbossrules/branches/temporal_rete/drools-examples/drools-examples-drl/src/main/rules/org/drools/examples/HonestPolitician.drl 2008-03-20 18:57:07 UTC (rev 19163)
+++ labs/jbossrules/branches/temporal_rete/drools-examples/drools-examples-drl/src/main/rules/org/drools/examples/HonestPolitician.drl 2008-03-20 19:32:10 UTC (rev 19164)
@@ -32,7 +32,6 @@
exists( Hope() )
then
System.out.println( "I'm an evil corporation and I have corrupted " + politician.getName() );
- politician.setHonest( false );
- update( politician );
+ modify( politician ) {setHonest( false )}
end
Modified: labs/jbossrules/branches/temporal_rete/drools-examples/drools-examples-drl/src/main/rules/org/drools/examples/conway/conway-agendagroup.drl
===================================================================
--- labs/jbossrules/branches/temporal_rete/drools-examples/drools-examples-drl/src/main/rules/org/drools/examples/conway/conway-agendagroup.drl 2008-03-20 18:57:07 UTC (rev 19163)
+++ labs/jbossrules/branches/temporal_rete/drools-examples/drools-examples-drl/src/main/rules/org/drools/examples/conway/conway-agendagroup.drl 2008-03-20 19:32:10 UTC (rev 19164)
@@ -59,8 +59,7 @@
# A live cell has fewer than 2 live neighbors
theCell: Cell(liveNeighbors < 2, cellState == CellState.LIVE, phase == Phase.EVALUATE)
then
- theCell.setPhase(Phase.KILL);
- update( theCell );
+ modify( theCell ) {setPhase(Phase.KILL)}
end
rule "Kill The Overcrowded"
@@ -70,8 +69,7 @@
# A live cell has more than 3 live neighbors
theCell: Cell(liveNeighbors > 3, cellState == CellState.LIVE, phase == Phase.EVALUATE)
then
- theCell.setPhase(Phase.KILL);
- update( theCell );
+ modify( theCell ) {setPhase(Phase.KILL)}
end
rule "Give Birth"
@@ -81,8 +79,7 @@
# A dead cell has 3 live neighbors
theCell: Cell(liveNeighbors == 3, cellState == CellState.DEAD, phase == Phase.EVALUATE)
then
- theCell.setPhase(Phase.BIRTH);
- update( theCell );
+ modify( theCell ){setPhase(Phase.BIRTH)}
end
rule "reset calculate"
@@ -99,9 +96,7 @@
when
theCell: Cell(phase == Phase.KILL)
then
- theCell.setCellState(CellState.DEAD);
- theCell.setPhase(Phase.DONE);
- update( theCell );
+ modify( theCell ) {setCellState(CellState.DEAD), setPhase(Phase.DONE) }
end
rule "birth"
@@ -110,9 +105,7 @@
when
theCell: Cell(phase == Phase.BIRTH)
then
- theCell.setCellState(CellState.LIVE);
- theCell.setPhase(Phase.DONE);
- update( theCell );
+ modify( theCell ){setCellState(CellState.LIVE), setPhase(Phase.DONE) }
end
rule "Calculate Live"
@@ -122,9 +115,7 @@
theCell: Cell(cellState == CellState.LIVE)
Neighbor(cell == theCell, $neighbor : neighbor)
then
- $neighbor.setLiveNeighbors( $neighbor.getLiveNeighbors() + 1 );
- $neighbor.setPhase( Phase.EVALUATE );
- update( $neighbor );
+ modify( $neighbor ) {setLiveNeighbors( $neighbor.getLiveNeighbors() + 1 ), setPhase( Phase.EVALUATE )}
end
rule "Calculate Dead"
@@ -134,9 +125,7 @@
theCell: Cell(cellState == CellState.DEAD)
Neighbor(cell == theCell, $neighbor : neighbor )
then
- $neighbor.setLiveNeighbors( $neighbor.getLiveNeighbors() - 1 );
- $neighbor.setPhase( Phase.EVALUATE );
- update( $neighbor );
+ modify( $neighbor ) {setLiveNeighbors( $neighbor.getLiveNeighbors() - 1 ), setPhase( Phase.EVALUATE )}
end
rule "Kill All"
@@ -145,6 +134,5 @@
when
theCell: Cell(cellState == CellState.LIVE)
then
- theCell.setCellState(CellState.DEAD);
- update( theCell );
+ modify( theCell ) {setCellState(CellState.DEAD)}
end
\ No newline at end of file
Modified: labs/jbossrules/branches/temporal_rete/drools-examples/drools-examples-drl/src/main/rules/org/drools/examples/conway/conway-ruleflow.drl
===================================================================
--- labs/jbossrules/branches/temporal_rete/drools-examples/drools-examples-drl/src/main/rules/org/drools/examples/conway/conway-ruleflow.drl 2008-03-20 18:57:07 UTC (rev 19163)
+++ labs/jbossrules/branches/temporal_rete/drools-examples/drools-examples-drl/src/main/rules/org/drools/examples/conway/conway-ruleflow.drl 2008-03-20 19:32:10 UTC (rev 19164)
@@ -59,8 +59,7 @@
# A live cell has fewer than 2 live neighbors
theCell: Cell(liveNeighbors < 2, cellState == CellState.LIVE, phase == Phase.EVALUATE)
then
- theCell.setPhase(Phase.KILL);
- update( theCell );
+ modify( theCell ) {setPhase(Phase.KILL)}
end
rule "Kill The Overcrowded"
@@ -70,8 +69,7 @@
# A live cell has more than 3 live neighbors
theCell: Cell(liveNeighbors > 3, cellState == CellState.LIVE, phase == Phase.EVALUATE)
then
- theCell.setPhase(Phase.KILL);
- update( theCell );
+ modify( theCell ) {setPhase(Phase.KILL)}
end
rule "Give Birth"
@@ -81,8 +79,7 @@
# A dead cell has 3 live neighbors
theCell: Cell(liveNeighbors == 3, cellState == CellState.DEAD, phase == Phase.EVALUATE)
then
- theCell.setPhase(Phase.BIRTH);
- update( theCell );
+ modify( theCell ) {setPhase(Phase.BIRTH)}
end
rule "reset calculate"
@@ -99,9 +96,7 @@
when
theCell: Cell(phase == Phase.KILL)
then
- theCell.setCellState(CellState.DEAD);
- theCell.setPhase(Phase.DONE);
- update( theCell );
+ modify( theCell ) {setCellState(CellState.DEAD), setPhase(Phase.DONE)}
end
rule "birth"
@@ -110,9 +105,7 @@
when
theCell: Cell(phase == Phase.BIRTH)
then
- theCell.setCellState(CellState.LIVE);
- theCell.setPhase(Phase.DONE);
- update( theCell );
+ modify( theCell ) {setCellState(CellState.LIVE), setPhase(Phase.DONE)}
end
rule "Calculate Live"
@@ -122,9 +115,7 @@
theCell: Cell(cellState == CellState.LIVE)
Neighbor(cell == theCell, $neighbor : neighbor)
then
- $neighbor.setLiveNeighbors( $neighbor.getLiveNeighbors() + 1 );
- $neighbor.setPhase( Phase.EVALUATE );
- update( $neighbor );
+ modify( $neighbor ) {setLiveNeighbors( $neighbor.getLiveNeighbors() + 1 ), setPhase( Phase.EVALUATE )}
end
rule "Calculate Dead"
@@ -134,9 +125,7 @@
theCell: Cell(cellState == CellState.DEAD)
Neighbor(cell == theCell, $neighbor : neighbor )
then
- $neighbor.setLiveNeighbors( $neighbor.getLiveNeighbors() - 1 );
- $neighbor.setPhase( Phase.EVALUATE );
- update( $neighbor );
+ modify( $neighbor ) {setLiveNeighbors( $neighbor.getLiveNeighbors() - 1 ), setPhase( Phase.EVALUATE )}
end
rule "Kill All"
@@ -145,6 +134,5 @@
when
theCell: Cell(cellState == CellState.LIVE)
then
- theCell.setCellState(CellState.DEAD);
- update( theCell );
+ modify( theCell ) {setCellState(CellState.DEAD)}
end
\ No newline at end of file
Modified: labs/jbossrules/branches/temporal_rete/drools-examples/drools-examples-drl/src/main/rules/org/drools/examples/troubleticket/ticketing.dsl
===================================================================
--- labs/jbossrules/branches/temporal_rete/drools-examples/drools-examples-drl/src/main/rules/org/drools/examples/troubleticket/ticketing.dsl 2008-03-20 18:57:07 UTC (rev 19163)
+++ labs/jbossrules/branches/temporal_rete/drools-examples/drools-examples-drl/src/main/rules/org/drools/examples/troubleticket/ticketing.dsl 2008-03-20 19:32:10 UTC (rev 19164)
@@ -1,5 +1,5 @@
[condition][]There is a customer ticket with status of "{status}"=customer : Customer( ) ticket : Ticket( customer == customer, status == "{status}" )
[condition][]There is a "{subscription}" customer with a ticket status of "{status}"=customer : Customer(subscription == "{subscription}") ticket : Ticket( customer == customer, status == "{status}")
[consequence][]Log "{message}"=System.out.println("{message} ");
-[consequence][]Escalate the ticket=ticket.setStatus("Escalate"); update(ticket);
+[consequence][]Escalate the ticket=modify(ticket) {setStatus("Escalate")}
[consequence][]Send escalation email=sendEscalationEmail( customer, ticket );
Deleted: labs/jbossrules/branches/temporal_rete/drools-jbrms/build-readme.html
===================================================================
--- labs/jbossrules/branches/temporal_rete/drools-jbrms/build-readme.html 2008-03-20 18:57:07 UTC (rev 19163)
+++ labs/jbossrules/branches/temporal_rete/drools-jbrms/build-readme.html 2008-03-20 19:32:10 UTC (rev 19164)
@@ -1,3 +0,0 @@
-<html><head>
- <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
- <title>Introduction</title><link rel="stylesheet" href="html.css" type="text/css"><meta name="generator" content="DocBook XSL Stylesheets V1.70.1"></head><body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF"><div class="section" lang="en"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="d0e1"></a>Introduction</h2></div></div><hr></div><p>This section covers the innards of the BRMS - it is not neccesary to use this if you are integrating or an end user of the BRMS application. However, JBoss Rules is open source, so build instructions form part of the manual.</p><p>You may want to build from source if you want to re-use components, or embed the application in your own.</p><div class="section" lang="en"><div class="titlepage"><div><div><h3 class="title"><a name="d0e8"></a>Design</h3></div></div></div></div><div class="section" lang="en"><div class="titlepage"><div><div><h3 class="title"><a name="d0e11"></a>Building!
from source</h3></div></div></div><p>This section will go over the steps you will need to take to build various components. Mostly this is automated, but the manual process is described for thoroughness.</p><div class="section" lang="en"><div class="titlepage"><div><div><h4 class="title"><a name="d0e16"></a>Modules</h4></div></div></div><p>There are 2 modules: drools-repository (back end) and drools-jbrms (front end and rules integration). The drools-jbrms module depends on the drools-repository module, as well as other components.</p></div><div class="section" lang="en"><div class="titlepage"><div><div><h4 class="title"><a name="d0e21"></a>Working with Maven 2</h4></div></div></div><p>Maven 2 is used as the underlying build system. To get started, you will need to check out the WHOLE of the source tree for JBoss Rules. This includes the other modules, and the top level lib and repository directories (which are needed by the build). As the BRMS build is part of the main dr!
ools build.</p><p>Initially, you should go into the root of the jboss-
rules checked out source tree, and run mvn install to install all the components for the inter project depedencies. If the build is broken (no ! say it isn't so !) you can use the flag -Dmaven.test.skip=true to prevent failing unit tests from preventing the build.</p><p>As the BRMS depends on drools-repository (which is the back end version storage subsystem), you then go into the drools-repository directory, and run "mvn install" to make it available. Finally, you can go into the drools-jbrms directory and run "mvn test" to check it all works, or "mvn package" to generate the web application (as well as run the tests). You should now be good to go !</p></div><div class="section" lang="en"><div class="titlepage"><div><div><h4 class="title"><a name="d0e30"></a>Working with GWT</h4></div></div></div><p>The GUI widgets for the web front end are developed with GWT (google web toolkit). If you need to make changes to or build the GUI, you will need to download GWT seperately. Onc!
e GWT is downloaded, you can modify the build.properties file in the drools-jbrms directory to point to where you installed GWT. Once you have this, you can use the ant tasks to build the GWT components, as well as launch GWT in debug/hosted mode should you desire. If you run the build, it will update the webapp directory in the project with the new "compiled" artifacts (GWT does not use JSP, only html and javascript at runtime).</p></div><div class="section" lang="en"><div class="titlepage"><div><div><h4 class="title"><a name="d0e35"></a>Debugging, Editing and running with Eclipse</h4></div></div></div><p>Each module has a ready to go and up to date eclipse project configuration, so you can just import them into your eclipse workspace. These projects are generated by maven (mvn eclipse:eclipse to refresh them). They have been manually modified to have project dependencies (means you can step through code when debugging).</p><p>Some environment variables are required in ecl!
ipse (Window->Preferences->Java->Build path->Classpath var
iables): the M2_REPO, as normal, to point to where maven downloads shared dependencies. GWT_HOME should point to where you installed GWT. GWT_DEV must point to the platform specific "dev" jar that ships with the version of GWT you have.</p><p>How you launch from eclipse: you can launch unit test, as normal (in which case you only need M2_REPO setup - you don't even need to download GWT seperately) - OR, you can launch it in "hosted mode" using the GWT browser, which is great for debugging (from GUI to back end, you can step through code, and make changes on the fly and simply hit refresh). There is a JBRMS.launch file in in the drools-jbrms directory. This should allow Eclipse to launch the JBRMS in debug mode - open the Run dialog (Run->Run), and then choose "JBRMS" from the list. Launching this will open a new window, with the BRMS in debug mode, ready to go.</p><p>Downloading and debugging the BRMS with GWT is optional, and if you are only working on non GUI issues, yo!
u can skip this step.</p></div></div><div class="section" lang="en"><div class="titlepage"><div><div><h3 class="title"><a name="d0e46"></a>Re-usable components</h3></div></div></div></div><div class="section" lang="en"><div class="titlepage"><div><div><h3 class="title"><a name="d0e49"></a>Versioning and Storage</h3></div></div></div></div></div></body></html>
\ No newline at end of file
Modified: labs/jbossrules/branches/temporal_rete/drools-jbrms/build.xml
===================================================================
--- labs/jbossrules/branches/temporal_rete/drools-jbrms/build.xml 2008-03-20 18:57:07 UTC (rev 19163)
+++ labs/jbossrules/branches/temporal_rete/drools-jbrms/build.xml 2008-03-20 19:32:10 UTC (rev 19164)
@@ -17,7 +17,7 @@
<gwt:compile outDir="src/main/webapp"
gwtHome="${gwt.home}"
classBase="org.drools.brms.JBRMS"
- sourceclasspath="src/main/java; ../drools-compiler/src/main/java; ../m2_repo/com/gwtext/gwtext/0.9.3/gwtext-0.9.3.jar"
+ sourceclasspath="src/main/java; ../drools-compiler/src/main/java; ../m2_repo/com/gwtext/gwtext/2.0.1/gwtext-2.0.1.jar"
/>
</target>
Modified: labs/jbossrules/branches/temporal_rete/drools-jbrms/src/main/java/org/drools/brms/client/admin/CategoryManager.java
===================================================================
--- labs/jbossrules/branches/temporal_rete/drools-jbrms/src/main/java/org/drools/brms/client/admin/CategoryManager.java 2008-03-20 18:57:07 UTC (rev 19163)
+++ labs/jbossrules/branches/temporal_rete/drools-jbrms/src/main/java/org/drools/brms/client/admin/CategoryManager.java 2008-03-20 19:32:10 UTC (rev 19164)
@@ -29,8 +29,12 @@
import org.drools.brms.client.modeldriven.dt.AttributeCol;
import org.drools.brms.client.modeldriven.dt.ConditionCol;
import org.drools.brms.client.modeldriven.dt.GuidedDecisionTable;
+import org.drools.brms.client.packages.SuggestionCompletionCache;
+import org.drools.brms.client.rpc.MetaData;
import org.drools.brms.client.rpc.RepositoryServiceFactory;
+import org.drools.brms.client.rpc.RuleAsset;
+import com.google.gwt.user.client.Command;
import com.google.gwt.user.client.Window;
import com.google.gwt.user.client.ui.ClickListener;
import com.google.gwt.user.client.ui.Composite;
@@ -101,28 +105,40 @@
GuidedDecisionTable dt = new GuidedDecisionTable();
- dt.data = new String[][] {
- new String[] {"1", "des1","", "a", "b", "c"},
- new String[] {"2", "des1","" , "d", "e", "f"},
- new String[] {"3", "des3", "groupA", "d", "q", "x"}
- };
- ConditionCol c1 = new ConditionCol();
- c1.header = "Driver 1 age";
- dt.conditionCols.add(c1);
- ConditionCol c2 = new ConditionCol();
- c2.header = "Driver 2 age";
- dt.conditionCols.add(c2);
+// dt.data = new String[][] {
+// new String[] {"1", "des1","", "a", "b", "c"},
+// new String[] {"2", "des1","" , "d", "e", "f"},
+// new String[] {"3", "des3", "groupA", "d", "q", "x"}
+// };
+// ConditionCol c1 = new ConditionCol();
+// c1.header = "Driver 1 age";
+//
+// dt.conditionCols.add(c1);
+// ConditionCol c2 = new ConditionCol();
+// c2.header = "Driver 2 age";
+// dt.conditionCols.add(c2);
+//
+// AttributeCol attr = new AttributeCol();
+// attr.attr = "rule-flow";
+// dt.attributeCols.add(attr);
+//
+// ActionCol a1 = new ActionSetFieldCol();
+// a1.header = "Do something !";
+// dt.actionCols.add(a1);
- AttributeCol attr = new AttributeCol();
- attr.attr = "rule-flow";
- dt.attributeCols.add(attr);
+ //initWidget( form );
+ final RuleAsset asset_ = new RuleAsset();
+ asset_.metaData = new MetaData();
+ asset_.metaData.packageName = "com.billasurf.manufacturing.plant";
+ asset_.content = dt;
+ initWidget( new GuidedDecisionTableWidget(asset_) );
+ SuggestionCompletionCache.getInstance().doAction("com.billasurf.manufacturing.plant", new Command() {
+ public void execute() {
+ System.err.println("loaded SCE");
- ActionCol a1 = new ActionSetFieldCol();
- a1.header = "Do something !";
- dt.actionCols.add(a1);
+ }
+ });
- initWidget( form );
- //initWidget( new GuidedDecisionTableWidget(dt) );
}
Modified: labs/jbossrules/branches/temporal_rete/drools-jbrms/src/main/java/org/drools/brms/client/common/FormStylePopup.java
===================================================================
--- labs/jbossrules/branches/temporal_rete/drools-jbrms/src/main/java/org/drools/brms/client/common/FormStylePopup.java 2008-03-20 18:57:07 UTC (rev 19163)
+++ labs/jbossrules/branches/temporal_rete/drools-jbrms/src/main/java/org/drools/brms/client/common/FormStylePopup.java 2008-03-20 19:32:10 UTC (rev 19164)
@@ -38,6 +38,9 @@
private Boolean shadow;
private Integer width;
private Integer height;
+ private boolean modal = true;
+ private int popLeft = -1;
+ private int popTop;
public FormStylePopup(String image,
final String title) {
@@ -72,19 +75,27 @@
this.dialog.destroy();
}
+ public void setPopupPosition(int left, int top) {
+ this.popLeft = left;
+ this.popTop = top;
+ }
+
public void show() {
dialog = new Window();
dialog.setAutoScroll(true);
- dialog.setModal(true);
+ dialog.setModal(modal );
dialog.setWidth((width == null)? 500 : width.intValue());
//dialog.setHeight((height == null)? form.getNumAttributes() * 40 + 100 : height.intValue());
dialog.setShadow((shadow == null)? true : shadow.booleanValue());
dialog.setResizable(true);
dialog.setClosable(true);
dialog.setTitle(title);
+ if (popLeft > -1) {
+ dialog.setPosition(popLeft, popTop);
+ }
@@ -96,5 +107,17 @@
this.dialog.show();
}
+ public void setModal(boolean m) {
+ this.modal = m;
+ }
+ public void setTitle(String t) {
+ this.title = t;
+ }
+
+ public void setWidth(int i) {
+ this.width = new Integer(i);
+ }
+
+
}
\ No newline at end of file
Copied: labs/jbossrules/branches/temporal_rete/drools-jbrms/src/main/java/org/drools/brms/client/decisiontable/ActionInsertColumn.java (from rev 19160, labs/jbossrules/dev_tags/before_righttuple_merge_20080320/drools-jbrms/src/main/java/org/drools/brms/client/decisiontable/ActionInsertColumn.java)
===================================================================
--- labs/jbossrules/branches/temporal_rete/drools-jbrms/src/main/java/org/drools/brms/client/decisiontable/ActionInsertColumn.java (rev 0)
+++ labs/jbossrules/branches/temporal_rete/drools-jbrms/src/main/java/org/drools/brms/client/decisiontable/ActionInsertColumn.java 2008-03-20 19:32:10 UTC (rev 19164)
@@ -0,0 +1,249 @@
+package org.drools.brms.client.decisiontable;
+
+import java.util.HashSet;
+import java.util.Set;
+
+import org.drools.brms.client.common.FormStylePopup;
+import org.drools.brms.client.common.ImageButton;
+import org.drools.brms.client.common.InfoPopup;
+import org.drools.brms.client.common.SmallLabel;
+import org.drools.brms.client.modeldriven.SuggestionCompletionEngine;
+import org.drools.brms.client.modeldriven.dt.ActionCol;
+import org.drools.brms.client.modeldriven.dt.ActionInsertFactCol;
+import org.drools.brms.client.modeldriven.dt.ConditionCol;
+import org.drools.brms.client.modeldriven.dt.GuidedDecisionTable;
+
+import com.google.gwt.user.client.Command;
+import com.google.gwt.user.client.ui.Button;
+import com.google.gwt.user.client.ui.ChangeListener;
+import com.google.gwt.user.client.ui.ClickListener;
+import com.google.gwt.user.client.ui.HTML;
+import com.google.gwt.user.client.ui.HorizontalPanel;
+import com.google.gwt.user.client.ui.Image;
+import com.google.gwt.user.client.ui.ListBox;
+import com.google.gwt.user.client.ui.TextBox;
+import com.google.gwt.user.client.ui.Widget;
+
+/**
+ * This is an editor for columns that are for inserting facts.
+ * @author Michael Neale
+ *
+ */
+public class ActionInsertColumn extends FormStylePopup {
+
+ private GuidedDecisionTable dt;
+ private SuggestionCompletionEngine sce;
+ private ActionInsertFactCol editingCol;
+ private SmallLabel patternLabel = new SmallLabel();
+ private SmallLabel fieldLabel = new SmallLabel();
+
+ public ActionInsertColumn(SuggestionCompletionEngine sce, final GuidedDecisionTable dt, final Command refreshGrid, final ActionInsertFactCol col, final boolean isNew) {
+ this.setModal(false);
+ this.dt = dt;
+ this.sce = sce;
+ this.editingCol = new ActionInsertFactCol();
+ editingCol.boundName = col.boundName;
+ editingCol.type = col.type;
+ editingCol.factField = col.factField;
+ editingCol.factType = col.factType;
+ editingCol.header = col.header;
+ editingCol.valueList = col.valueList;
+
+ setTitle("Action column configuration (inserting a new fact)");
+
+ final TextBox header = new TextBox();
+ header.setText(col.header);
+ header.addChangeListener(new ChangeListener() {
+ public void onChange(Widget w) {
+ editingCol.header = header.getText();
+ } });
+ addAttribute("Column header (description):", header);
+
+
+ HorizontalPanel pattern = new HorizontalPanel();
+ pattern.add(patternLabel );
+ doPatternLabel();
+
+ Image changePattern = new ImageButton("images/edit.gif", "Choose a pattern that this column adds data to", new ClickListener() {
+ public void onClick(Widget w) {
+ showChangePattern(w);
+ }
+ });
+ pattern.add(changePattern);
+ addAttribute("Pattern:", pattern);
+
+ HorizontalPanel field = new HorizontalPanel();
+ field.add(fieldLabel);
+ Image editField = new ImageButton("images/edit.gif", "Edit the field that this column operates on", new ClickListener() {
+ public void onClick(Widget w) {
+ showFieldChange();
+ }
+ });
+ field.add(editField);
+ addAttribute("Field:", field);
+ doFieldLabel();
+
+
+ final TextBox valueList = new TextBox();
+ valueList.setText(editingCol.valueList);
+ valueList.addChangeListener(new ChangeListener() {
+ public void onChange(Widget w) {
+ editingCol.valueList = valueList.getText();
+ }
+ });
+ HorizontalPanel vl = new HorizontalPanel();
+ vl.add(valueList);
+ vl.add(new InfoPopup("Value list", "Value lists are an optional comma separated list of values to show as a drop down."));
+ addAttribute("(optional) value list:", vl);
+
+ Button apply = new Button("Apply changes");
+ apply.addClickListener(new ClickListener() {
+ public void onClick(Widget w) {
+ if (isNew) {
+ dt.actionCols.add(editingCol);
+ } else {
+ col.boundName = editingCol.boundName;
+ col.type = editingCol.type;
+ col.factField = editingCol.factField;
+ col.factType = editingCol.factType;
+ col.header = editingCol.header;
+ col.valueList = editingCol.valueList;
+ }
+ refreshGrid.execute();
+ hide();
+ }
+ });
+ addAttribute("", apply);
+
+ }
+
+ private void showFieldChange() {
+ final FormStylePopup pop = new FormStylePopup();
+ pop.setModal(false);
+ String[] fields = this.sce.getFieldCompletions(this.editingCol.factType);
+ final ListBox box = new ListBox();
+ for (int i = 0; i < fields.length; i++) {
+ box.addItem(fields[i]);
+ }
+ pop.addAttribute("Field:", box);
+ Button b = new Button("OK");
+ pop.addAttribute("", b);
+ b.addClickListener(new ClickListener() {
+ public void onClick(Widget w) {
+ editingCol.factField = box.getItemText(box.getSelectedIndex());
+ editingCol.type = sce.getFieldType(editingCol.factType, editingCol.factField);
+ doFieldLabel();
+ pop.hide();
+ }
+ });
+ pop.show();
+
+ }
+
+ private void doFieldLabel() {
+ if (nil(this.editingCol.factField)) {
+ fieldLabel.setText("(please choose fact type)");
+ } else {
+ fieldLabel.setText(editingCol.factField);
+ }
+
+ }
+
+ private boolean nil(String s) {
+ return s == null || s.equals("");
+ }
+
+ private void doPatternLabel() {
+ if (this.editingCol.factType != null) {
+ this.patternLabel.setText(this.editingCol.factType + " [" + editingCol.boundName + "]");
+ }
+ }
+
+ protected void showChangePattern(Widget w) {
+
+ final ListBox pats = this.loadPatterns();
+ if (pats.getItemCount() == 0) {
+ showNewPatternDialog();
+ return;
+ }
+ final FormStylePopup pop = new FormStylePopup();
+ Button ok = new Button("OK");
+ HorizontalPanel hp = new HorizontalPanel();
+ hp.add(pats);
+ hp.add(ok);
+
+
+ pop.addAttribute("Choose existing pattern to add column to:", hp);
+ pop.addAttribute("", new HTML("<i><b>---OR---</i></b>"));
+
+ Button createPattern = new Button("Create new fact pattern");
+ createPattern.addClickListener(new ClickListener() {
+ public void onClick(Widget w) {
+ pop.hide();
+ showNewPatternDialog();
+ }
+ });
+ pop.addAttribute("", createPattern);
+
+
+
+
+ ok.addClickListener(new ClickListener() {
+ public void onClick(Widget w) {
+ String[] val = pats.getValue(pats.getSelectedIndex()).split("\\s");
+ editingCol.factType = val[0];
+ editingCol.boundName = val[1];
+ doPatternLabel();
+ pop.hide();
+ }
+ });
+
+ pop.show();
+ }
+
+ protected void showNewPatternDialog() {
+ final FormStylePopup pop = new FormStylePopup();
+ pop.setTitle("New fact - select the type");
+ final ListBox types = new ListBox();
+ for (int i = 0; i < sce.factTypes.length; i++) {
+ types.addItem(sce.factTypes[i]);
+ }
+ pop.addAttribute("Fact type:", types);
+ final TextBox binding = new TextBox();
+ pop.addAttribute("name:", binding);
+
+ Button ok = new Button("OK");
+ ok.addClickListener(new ClickListener() {
+ public void onClick(Widget w) {
+ editingCol.boundName = binding.getText();
+ editingCol.factType = types.getItemText(types.getSelectedIndex());
+ doPatternLabel();
+ pop.hide();
+ }
+ });
+ pop.addAttribute("", ok);
+
+ pop.show();
+ }
+
+ private ListBox loadPatterns() {
+ Set vars = new HashSet();
+ ListBox patterns = new ListBox();
+ for (int i = 0; i < dt.conditionCols.size(); i++) {
+ ActionCol col = (ActionCol) dt.actionCols.get(i);
+ if (col instanceof ActionInsertFactCol) {
+ ActionInsertFactCol c = (ActionInsertFactCol) col;
+ if (!vars.contains(c.boundName)) {
+ patterns.addItem(c.factType + " [" + c.boundName + "]", c.factType + " " + c.boundName);
+ vars.add(c.boundName);
+ }
+ }
+ }
+
+ return patterns;
+
+ }
+
+
+
+}
Copied: labs/jbossrules/branches/temporal_rete/drools-jbrms/src/main/java/org/drools/brms/client/decisiontable/ActionSetColumn.java (from rev 19160, labs/jbossrules/dev_tags/before_righttuple_merge_20080320/drools-jbrms/src/main/java/org/drools/brms/client/decisiontable/ActionSetColumn.java)
===================================================================
--- labs/jbossrules/branches/temporal_rete/drools-jbrms/src/main/java/org/drools/brms/client/decisiontable/ActionSetColumn.java (rev 0)
+++ labs/jbossrules/branches/temporal_rete/drools-jbrms/src/main/java/org/drools/brms/client/decisiontable/ActionSetColumn.java 2008-03-20 19:32:10 UTC (rev 19164)
@@ -0,0 +1,206 @@
+package org.drools.brms.client.decisiontable;
+
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.Set;
+
+import org.drools.brms.client.common.FormStylePopup;
+import org.drools.brms.client.common.ImageButton;
+import org.drools.brms.client.common.InfoPopup;
+import org.drools.brms.client.common.SmallLabel;
+import org.drools.brms.client.modeldriven.SuggestionCompletionEngine;
+import org.drools.brms.client.modeldriven.dt.ActionSetFieldCol;
+import org.drools.brms.client.modeldriven.dt.ConditionCol;
+import org.drools.brms.client.modeldriven.dt.GuidedDecisionTable;
+
+import com.google.gwt.user.client.Command;
+import com.google.gwt.user.client.ui.Button;
+import com.google.gwt.user.client.ui.ChangeListener;
+import com.google.gwt.user.client.ui.ClickListener;
+import com.google.gwt.user.client.ui.HorizontalPanel;
+import com.google.gwt.user.client.ui.Image;
+import com.google.gwt.user.client.ui.ListBox;
+import com.google.gwt.user.client.ui.TextBox;
+import com.google.gwt.user.client.ui.Widget;
+
+public class ActionSetColumn extends FormStylePopup {
+
+ private ActionSetFieldCol editingCol;
+ private SmallLabel bindingLabel = new SmallLabel();
+ private SmallLabel fieldLabel = new SmallLabel();
+ private GuidedDecisionTable dt;
+ private SuggestionCompletionEngine sce;
+
+ public ActionSetColumn(SuggestionCompletionEngine sce, final GuidedDecisionTable dt, final Command refreshGrid, final ActionSetFieldCol col, final boolean isNew) {
+ this.editingCol = new ActionSetFieldCol();
+ this.dt = dt;
+ this.sce = sce;
+
+ editingCol.boundName = col.boundName;
+ editingCol.factField = col.factField;
+ editingCol.header = col.header;
+ editingCol.type = col.type;
+ editingCol.valueList = col.valueList;
+ super.setModal(false);
+ setTitle("Column configuration (set a field on a fact)");
+
+ final TextBox header = new TextBox();
+ header.setText(col.header);
+ header.addChangeListener(new ChangeListener() {
+ public void onChange(Widget w) {
+ editingCol.header = header.getText();
+ } });
+ addAttribute("Column header (description):", header);
+
+ HorizontalPanel pattern = new HorizontalPanel();
+ pattern.add(bindingLabel);
+ doBindingLabel();
+
+ Image changePattern = new ImageButton("images/edit.gif", "Choose a bound fact that this column pertains to", new ClickListener() {
+ public void onClick(Widget w) {
+ showChangeFact(w);
+ }
+ });
+ pattern.add(changePattern);
+ addAttribute("Fact:", pattern);
+
+
+ HorizontalPanel field = new HorizontalPanel();
+ field.add(fieldLabel);
+ Image editField = new ImageButton("images/edit.gif", "Edit the field that this column operates on", new ClickListener() {
+ public void onClick(Widget w) {
+ showFieldChange();
+ }
+ });
+ field.add(editField);
+ addAttribute("Field:", field);
+ doFieldLabel();
+
+ final TextBox valueList = new TextBox();
+ valueList.setText(editingCol.valueList);
+ valueList.addChangeListener(new ChangeListener() {
+ public void onChange(Widget w) {
+ editingCol.valueList = valueList.getText();
+ }
+ });
+ HorizontalPanel vl = new HorizontalPanel();
+ vl.add(valueList);
+ vl.add(new InfoPopup("Value list", "Value lists are an optional comma separated list of values to show as a drop down."));
+ addAttribute("(optional) value list:", vl);
+
+ Button apply = new Button("Apply changes");
+ apply.addClickListener(new ClickListener() {
+ public void onClick(Widget w) {
+ if (isNew) {
+ dt.actionCols.add(editingCol);
+
+ } else {
+ col.boundName = editingCol.boundName;
+ col.factField = editingCol.factField;
+ col.header = editingCol.header;
+ col.type = editingCol.type;
+ col.valueList = editingCol.valueList;
+ }
+ refreshGrid.execute();
+ hide();
+
+ }
+ });
+ addAttribute("", apply);
+
+
+ }
+
+ private void showFieldChange() {
+ final FormStylePopup pop = new FormStylePopup();
+ pop.setModal(false);
+ final String factType = getFactType(this.editingCol.boundName);
+ String[] fields = this.sce.getFieldCompletions(factType);
+ final ListBox box = new ListBox();
+ for (int i = 0; i < fields.length; i++) {
+ box.addItem(fields[i]);
+ }
+ pop.addAttribute("Field:", box);
+ Button b = new Button("OK");
+ pop.addAttribute("", b);
+ b.addClickListener(new ClickListener() {
+ public void onClick(Widget w) {
+ editingCol.factField = box.getItemText(box.getSelectedIndex());
+ editingCol.type = sce.getFieldType(factType, editingCol.factField);
+ doFieldLabel();
+ pop.hide();
+ }
+ });
+ pop.show();
+
+ }
+
+ private void doFieldLabel() {
+ if (this.editingCol.factField != null) {
+ this.fieldLabel.setText(this.editingCol.factField);
+ } else {
+ this.fieldLabel.setText("(please choose a fact pattern first)");
+ }
+ }
+
+ private String getFactType(String boundName) {
+ for (Iterator iterator = dt.conditionCols.iterator(); iterator.hasNext();) {
+ ConditionCol col = (ConditionCol) iterator.next();
+ if (col.boundName.equals(boundName)) {
+ return col.factType;
+ }
+ }
+ return "";
+ }
+
+ private void showChangeFact(Widget w) {
+ final FormStylePopup pop = new FormStylePopup();
+
+ final ListBox pats = this.loadBoundFacts();
+ pop.addAttribute("Choose fact:", pats);
+ Button ok = new Button("OK");
+ pop.addAttribute("", ok);
+
+ ok.addClickListener(new ClickListener() {
+ public void onClick(Widget w) {
+ String val = pats.getValue(pats.getSelectedIndex());
+ editingCol.boundName = val;
+ doBindingLabel();
+ pop.hide();
+ }
+ });
+
+ pop.show();
+
+ }
+
+ private ListBox loadBoundFacts() {
+ Set facts = new HashSet();
+ for (int i = 0; i < this.dt.conditionCols.size(); i++) {
+ ConditionCol c = (ConditionCol) dt.conditionCols.get(i);
+ facts.add(c.boundName);
+ }
+
+ ListBox box = new ListBox();
+ for (Iterator iterator = facts.iterator(); iterator.hasNext();) {
+ String b = (String) iterator.next();
+ box.addItem(b);
+ }
+
+ String[] globs = this.sce.getGlobalVariables();
+ for (int i = 0; i < globs.length; i++) {
+ box.addItem(globs[i]);
+ }
+
+ return box;
+ }
+
+ private void doBindingLabel() {
+ if (this.editingCol.boundName != null) {
+ this.bindingLabel.setText("" + this.editingCol.boundName);
+ } else {
+ this.bindingLabel.setText("(please choose a bound fact for this column)");
+ }
+ }
+
+}
Deleted: labs/jbossrules/branches/temporal_rete/drools-jbrms/src/main/java/org/drools/brms/client/decisiontable/DeleteAction.java
===================================================================
--- labs/jbossrules/branches/temporal_rete/drools-jbrms/src/main/java/org/drools/brms/client/decisiontable/DeleteAction.java 2008-03-20 18:57:07 UTC (rev 19163)
+++ labs/jbossrules/branches/temporal_rete/drools-jbrms/src/main/java/org/drools/brms/client/decisiontable/DeleteAction.java 2008-03-20 19:32:10 UTC (rev 19164)
@@ -1,70 +0,0 @@
-package org.drools.brms.client.decisiontable;
-/*
- * Copyright 2005 JBoss Inc
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-
-
-import org.drools.brms.client.decisiontable.EditableDTGrid.RowClickListener;
-
-import com.google.gwt.user.client.ui.ClickListener;
-import com.google.gwt.user.client.ui.Composite;
-import com.google.gwt.user.client.ui.HorizontalPanel;
-import com.google.gwt.user.client.ui.Image;
-import com.google.gwt.user.client.ui.Widget;
-
-/**
- * This shows the widget for deleting a row.
- * @author Steven Williams
- */
-public class DeleteAction extends Composite {
-
- private HorizontalPanel panel = new HorizontalPanel();
- private Image delete;
- private int row;
-
-
-
-
- /**
- * Pass in the click listener delegate for when the respective action is clicked
- * @param clickListener
- * @param okClickListener
- */
- public DeleteAction(final int currentRow, final RowClickListener clickListener) {
- row = currentRow;
- delete = new Image("images/clear_item.gif");
- delete.setTitle( "Delete row " + row );
- delete.addClickListener( new ClickListener() {
- public void onClick(final Widget w) {
- clickListener.onClick(w, row);
- }
- });
-
- panel.add( delete);
-
- initWidget( panel );
- }
-
- public void setRow(final int row) {
- this.row = row;
- delete.setTitle("Delete row " + row);
- }
-
- public int getRow() {
- return row;
- }
-
-}
\ No newline at end of file
Deleted: labs/jbossrules/branches/temporal_rete/drools-jbrms/src/main/java/org/drools/brms/client/decisiontable/EditActions.java
===================================================================
--- labs/jbossrules/branches/temporal_rete/drools-jbrms/src/main/java/org/drools/brms/client/decisiontable/EditActions.java 2008-03-20 18:57:07 UTC (rev 19163)
+++ labs/jbossrules/branches/temporal_rete/drools-jbrms/src/main/java/org/drools/brms/client/decisiontable/EditActions.java 2008-03-20 19:32:10 UTC (rev 19164)
@@ -1,101 +0,0 @@
-package org.drools.brms.client.decisiontable;
-/*
- * Copyright 2005 JBoss Inc
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-
-
-import org.drools.brms.client.decisiontable.EditableDTGrid.RowClickListener;
-
-import com.google.gwt.user.client.ui.ClickListener;
-import com.google.gwt.user.client.ui.Composite;
-import com.google.gwt.user.client.ui.HorizontalPanel;
-import com.google.gwt.user.client.ui.Image;
-import com.google.gwt.user.client.ui.Widget;
-
-/**
- * This shows the widgets for editing a row.
- * @author Michael Neale
- */
-public class EditActions extends Composite {
-
- private HorizontalPanel panel = new HorizontalPanel();
- private Image edit;
- private Image ok;
- private int row;
-
-
-
-
- /**
- * Pass in the click listener delegates for when the respective action is clicked
- * @param editClickListener
- * @param okClickListener
- */
- public EditActions(final int currentRow,
- final RowClickListener editClickListener,
- final RowClickListener okClickListener) {
- row = currentRow;
- edit = new Image("images/edit.gif");
- edit.setTitle( "Edit this row" );
- edit.addClickListener( new ClickListener() {
-
- public void onClick(Widget w) {
- makeEditable();
- editClickListener.onClick( w, row );
- }
-
- });
-
- ok = new Image("images/tick.gif");
- ok.setTitle( "Apply the edit changes to this row." );
- ok.addClickListener( new ClickListener() {
-
- public void onClick(Widget w) {
- makeReadOnly();
- okClickListener.onClick( w, row );
- }
-
- });
-
- panel.add( edit );
- panel.add( ok );
- ok.setVisible( false );
-
- initWidget( panel );
- }
-
- public void makeEditable() {
- edit.setVisible( false );
- ok.setVisible( true );
-
- }
-
- public void makeReadOnly() {
- edit.setVisible( true );
- ok.setVisible( false );
- }
-
- public int getRow() {
- return row;
- }
-
- public void setRow(int row) {
- this.row = row;
- }
-
-
-
-}
\ No newline at end of file
Deleted: labs/jbossrules/branches/temporal_rete/drools-jbrms/src/main/java/org/drools/brms/client/decisiontable/EditableDTGrid.java
===================================================================
--- labs/jbossrules/branches/temporal_rete/drools-jbrms/src/main/java/org/drools/brms/client/decisiontable/EditableDTGrid.java 2008-03-20 18:57:07 UTC (rev 19163)
+++ labs/jbossrules/branches/temporal_rete/drools-jbrms/src/main/java/org/drools/brms/client/decisiontable/EditableDTGrid.java 2008-03-20 19:32:10 UTC (rev 19164)
@@ -1,470 +0,0 @@
-package org.drools.brms.client.decisiontable;
-/*
- * Copyright 2005 JBoss Inc
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-
-
-import java.util.Iterator;
-
-import org.drools.brms.client.decisiontable.model.Cell;
-import org.drools.brms.client.decisiontable.model.Column;
-import org.drools.brms.client.decisiontable.model.DecisionTable;
-import org.drools.brms.client.decisiontable.model.Row;
-
-import com.google.gwt.user.client.ui.Composite;
-import com.google.gwt.user.client.ui.FlexTable;
-import com.google.gwt.user.client.ui.HorizontalPanel;
-import com.google.gwt.user.client.ui.Image;
-import com.google.gwt.user.client.ui.Label;
-import com.google.gwt.user.client.ui.SourcesTableEvents;
-import com.google.gwt.user.client.ui.TableListener;
-import com.google.gwt.user.client.ui.TextBox;
-import com.google.gwt.user.client.ui.VerticalPanel;
-import com.google.gwt.user.client.ui.Widget;
-import com.google.gwt.user.client.ui.FlexTable.FlexCellFormatter;
-
-/**
- * The decision table viewer and editor.
- *
- * @author Michael Neale
- * @author Steven Williams
- *
- * TODO: add editors for header stuff, and ability to add rows/cols and shift
- * rows around This probably can be done from a seperate "editor" such that it
- * is re-rendered when you need to add/move a col or row.
- *
- * Should be able to add/shift stuff around by entering a row number to deal
- * with.
- *
- */
-public class EditableDTGrid extends Composite {
-
- private static final int START_DATA_ROW = 1;
-
- private DecisionTable dt;
-
- private FlexTable table = new FlexTable();
-
- private int currentRow;
-
- private int currentCol;
-
- private Cell currentCell;
-
- private FlexCellFormatter cellFormatter = table.getFlexCellFormatter();
-
- public EditableDTGrid(String dtName) {
- this(dtName, createDecisionTable());
- }
-
- private static DecisionTable createDecisionTable() {
- DecisionTable dt = new DecisionTable();
- Column[] columns = { dt.createColumn(), dt.createColumn(),
- dt.createColumn(), dt.createColumn(), dt.createColumn(),
- dt.createColumn() };
- createHeader(dt, columns);
- for (int i = 0; i < 15; i++) {
- Row row = dt.createRow();
- for (int j = 0; j < columns.length; j++) {
- Cell cell = dt.createCell(row, columns[j]);
- cell.setValue("boo " + i + ":" + j);
- }
- }
- return dt;
- }
-
- private static void createHeader(DecisionTable dt, Column[] columns) {
- Row row = dt.getHeaderRow();
- for (int i = 0; i < 6; i++) {
- Cell cell = dt.createCell(row, columns[i]);
- cell.setValue("some header " + i);
- }
- }
-
- public EditableDTGrid(final String dtName, final DecisionTable dt) {
- this.dt = dt;
- VerticalPanel vert = new VerticalPanel();
-
- Label title = new Label(dtName);
- title.setStyleName("dt-editor-Title");
-
- HorizontalPanel header = new HorizontalPanel();
- header.add(new Image("images/decision_table.gif"));
- header.add(title);
-
- Toolbar toolbar = new Toolbar(this);
-
- vert.add(header);
- vert.add(toolbar);
- vert.add(table);
-
- table.setStyleName("dt-editor-Grid");
- table.addTableListener(new TableListener() {
-
- public void onCellClicked(SourcesTableEvents ste, int row, int col) {
- setCurrentCell(row, col);
- }
- });
-
- // set up the header
- populateHeader();
-
- // and the data follows
- populateDataGrid();
-
- // needed for Composite
- initWidget(vert);
- }
-
- protected void setCurrentCell(int row, int column) {
- if (column > 0 && column <= numCols() && row >= START_DATA_ROW) {
- Cell selectedCell = dt.getRow(row - 1).getCell(column - 1);
- if (selectedCell != currentCell) {
- int col = selectedCell.getColumnIndex() + 1;
-
- if (currentRow >= START_DATA_ROW) {
- TextBox text = (TextBox) table.getWidget(currentRow,
- currentCol);
- newCell(currentRow, currentCol, text.getText());
- }
- if (currentCell == null || currentRow != row) {
- if (currentCell != null) {
- cellFormatter.setStyleName(currentRow, 0,
- "dt-editor-CountColumn");
- }
- cellFormatter.setStyleName(row, 0,
- "dt-editor-CountColumn-selected");
- }
- if (currentCell == null || (currentCell.getColumnIndex() + 1) != col) {
- if (currentCell != null) {
- cellFormatter.setStyleName(0, currentCell
- .getColumnIndex() + 1,
- "dt-editor-DescriptionCell");
- }
- cellFormatter.setStyleName(0, col,
- "dt-editor-DescriptionCell-selected");
- }
- cellFormatter.setStyleName(row, column,
- "dt-editor-Cell-selected");
- currentRow = row;
- currentCol = column;
- currentCell = selectedCell;
- editColumn(row, column);
- }
- }
- }
-
- private void populateHeader() {
- Row row = dt.getHeaderRow();
- // for the count column
- cellFormatter.setStyleName(0, 0, "dt-editor-DescriptionCell");
-
- table.setText(0, 0, "");
- cellFormatter.setStyleName(0, 0, "dt-editor-CountColumn");
-
- for (Iterator it = dt.getColumns().iterator(); it.hasNext();) {
- Column column = (Column) it.next();
- newHeaderCell(row.getCell(column));
- }
-
- }
-
- /**
- * This populates the "data" part of the decision table (not the header
- * bits). It starts at the row offset.
- *
- * @param cellFormatter
- * So it can set the style of each cell that is created.
- */
- private void populateDataGrid() {
- int i = 1;
- for (Iterator it = dt.getRows().iterator(); it.hasNext(); i++) {
- Row row = (Row) it.next();
- table.setText(i, 0, Integer.toString(i));
- cellFormatter.setStyleName(i, 0, "dt-editor-CountColumn");
- for (Iterator it2 = dt.getColumns().iterator(); it2.hasNext();) {
- Column column = (Column) it2.next();
- newCell(row.getCell(column));
- }
-
- }
- }
-
- private void newCell(Cell cell) {
- int rowIndex = cell.getRowIndex() + START_DATA_ROW;
- int columnIndex = cell.getColumnIndex() + 1;
- newCell(cell, rowIndex, columnIndex, "dt-editor-Cell");
- }
-
- private void newHeaderCell(Cell cell) {
- int columnIndex = cell.getColumnIndex() + 1;
- newCell(cell, 0, columnIndex, "dt-editor-DescriptionCell");
- }
-
- private void newCell(Cell cell, int rowIndex, int columnIndex, String style) {
- table.setText(rowIndex, columnIndex, cell.getValue());
- cellFormatter.setStyleName(rowIndex, columnIndex, style);
- cellFormatter.setColSpan(rowIndex, columnIndex, cell.getColspan());
- cellFormatter.setRowSpan(rowIndex, columnIndex, cell.getRowspan());
- }
-
- private void newCell(int row, int column, String text) {
- table.setText(row, column, text);
- cellFormatter.setStyleName(row, column, "dt-editor-Cell");
- }
-
- public void mergeCol() {
- if (currentCell != null) {
- dt.mergeCol(currentCell);
- // if (currentRow >= START_DATA_ROW && currentCol > 0) {
- int currentSpan = cellFormatter.getColSpan(currentRow, currentCol);
- if (currentCol + currentSpan <= numCols()) {
- int nextSpan = cellFormatter.getColSpan(currentRow,
- currentCol + 1);
- int currentRowSpan = cellFormatter.getRowSpan(currentRow,
- currentCol);
- int nextRowSpan = cellFormatter.getRowSpan(currentRow,
- currentCol + 1);
- while (nextRowSpan < currentRowSpan) {
- mergeRow(currentRow, currentCol + 1);
- nextRowSpan++;
- }
- table.removeCell(currentRow, currentCol + 1);
- cellFormatter.setColSpan(currentRow, currentCol, currentSpan
- + nextSpan);
- }
- }
- }
-
- public void mergeRow() {
- if (currentCell != null) {
- // if (currentRow >= START_DATA_ROW && currentCol > 0) {
- mergeRow(currentRow, currentCol);
- }
- }
-
- private void mergeRow(int row, int col) {
- dt.mergeRow(currentCell);
- int currentSpan = cellFormatter.getRowSpan(row, col);
- if (row + currentSpan <= numRows) {
- int nextSpan = cellFormatter.getRowSpan(row + currentSpan, col);
- table.removeCell(row + currentSpan, col);
- cellFormatter.setRowSpan(row, col, currentSpan + nextSpan);
- }
- }
-
- public void splitCol() {
- if (currentRow >= START_DATA_ROW && currentCol > 0) {
- int currentSpan = cellFormatter.getColSpan(currentRow, currentCol);
- if (currentSpan > 1) {
- cellFormatter.setColSpan(currentRow, currentCol,
- currentSpan - 1);
- int newCol = currentCol + 1;
- table.insertCell(currentRow, newCol);
- newCell(currentRow, newCol, "");
- cellFormatter
- .setStyleName(currentRow, newCol, "dt-editor-Cell");
- }
- }
- }
-
- public void splitRow() {
- if (currentRow >= START_DATA_ROW && currentCol > 0) {
- int currentSpan = cellFormatter.getRowSpan(currentRow, currentCol);
- if (currentSpan > 1) {
- cellFormatter.setRowSpan(currentRow, currentCol,
- currentSpan - 1);
- int newRow = currentRow + currentSpan - 1;
- table.insertCell(newRow, currentCol);
- newCell(newRow, currentCol, "");
- cellFormatter
- .setStyleName(newRow, currentCol, "dt-editor-Cell");
- }
- }
- }
-
- /**
- * Listener for click events that affect a whole row
- */
- interface RowClickListener {
- void onClick(Widget w, int row);
- }
-
- private int numRows = 14;
-
- /**
- * Shuffle the given row up one
- *
- * @param row
- */
- void moveUp() {
- if (currentRow > START_DATA_ROW) {
- // create a new row above the given row
- // remember that insertRow will insert above the given row
- // so this is two above the original row
- int newRow = addNewRow(currentRow - 1);
-
- copyRow(currentRow + 1, newRow);
-
- // remove the original row
- table.removeRow(currentRow + 1);
-
- renumberRow(currentRow);
- currentRow = -1;
- setCurrentCell(newRow, currentCol);
- }
-
- }
-
- /**
- * Copy the data from the source row to the target row
- *
- * @param sourceRow
- * @param targetRow
- */
- private void copyRow(int sourceRow, int targetRow) {
- int column = 1;
- int colIndex = 1;
- while (column <= numCols()) {
- if (column == currentCol) {
- TextBox box = (TextBox) table.getWidget(sourceRow, column);
- newCell(targetRow, colIndex, box.getText());
- } else {
- newCell(targetRow, colIndex, table.getText(sourceRow, colIndex));
- }
- int colSpan = cellFormatter.getColSpan(sourceRow, colIndex);
- column = column + colSpan;
- cellFormatter.setColSpan(targetRow, colIndex++, colSpan);
- }
- }
-
- /**
- * Add a new row and set the row number
- *
- * @param row
- * @return
- */
- private int addNewRow(int row) {
- int newRow = table.insertRow(row);
- table.setText(newRow, 0, Integer.toString(newRow));
- cellFormatter.setStyleName(newRow, 0, "dt-editor-CountColumn");
- return newRow;
- }
-
- /**
- * Shuffle the given row down one
- *
- * @param row
- */
- void moveDown() {
- if (currentRow < numRows) {
- // create a new row below the given row
- // remember that insertRow will insert above the given row
- // so this is two below the original row
- int newRow = addNewRow(currentRow + 2);
-
- copyRow(currentRow, newRow);
- // remove row before adding action widgets so that the row number
- // is correct (otherwise the shuffle down button may not be
- // displayed
- table.removeRow(currentRow);
- renumberRow(currentRow);
- renumberRow(currentRow + 1);
- currentRow = -1;
- setCurrentCell(newRow - 1, currentCol);
- }
- }
-
- /**
- * Delete the specified row
- */
- void deleteRow() {
- numRows--;
- table.removeRow(currentRow);
- reorderRows(currentRow);
- currentRow = -1;
- clearCurrentCell();
- }
-
- private void clearCurrentCell() {
- if (currentRow > 0) {
- cellFormatter
- .setStyleName(currentRow, currentCol, "dt-editor-Cell");
- currentRow = -1;
- }
- if (currentCol > 0) {
- cellFormatter.setStyleName(0, currentCol,
- "dt-editor-DescriptionCell");
- currentCol = -1;
- }
- }
-
- /**
- * Renumber the rows from the start row and change the row the actions will
- * act on
- *
- * @param startRow
- */
- private void reorderRows(final int startRow) {
- for (int r = startRow; r < table.getRowCount(); r++) {
- renumberRow(r);
- }
- }
-
- /**
- * Renumber the given row and change the row the actions will act on
- *
- * @param row
- */
- private void renumberRow(int row) {
- table.setText(row, 0, Integer.toString(row));
- }
-
- /**
- * Add a new row after the specified row
- */
- void insertRow() {
- if (currentRow >= START_DATA_ROW) {
- numRows++;
- int newRow = addNewRow(currentRow + 1);
- int column = 1;
- for (; column < numCols() + 1; column++) {
- newCell(newRow, column, "");
- }
- // addActions(column, newRow, true);
- reorderRows(newRow);
- setCurrentCell(newRow, 1);
- }
- }
-
- private void editColumn(int row, int column) {
- String text = table.getText(row, column);
- editColumn(row, column, text);
- }
-
- private void editColumn(int row, int column, String text) {
- TextBox box = new TextBox();
- box.setText(text);
- box.setStyleName("dt-field-TextBox");
- table.setWidget(row, column, box);
- box.setFocus(true);
- }
-
- private int numCols() {
- return 6;
- }
-
-}
\ No newline at end of file
Copied: labs/jbossrules/branches/temporal_rete/drools-jbrms/src/main/java/org/drools/brms/client/decisiontable/GuidedDTColumnConfig.java (from rev 19160, labs/jbossrules/dev_tags/before_righttuple_merge_20080320/drools-jbrms/src/main/java/org/drools/brms/client/decisiontable/GuidedDTColumnConfig.java)
===================================================================
--- labs/jbossrules/branches/temporal_rete/drools-jbrms/src/main/java/org/drools/brms/client/decisiontable/GuidedDTColumnConfig.java (rev 0)
+++ labs/jbossrules/branches/temporal_rete/drools-jbrms/src/main/java/org/drools/brms/client/decisiontable/GuidedDTColumnConfig.java 2008-03-20 19:32:10 UTC (rev 19164)
@@ -0,0 +1,366 @@
+package org.drools.brms.client.decisiontable;
+
+import java.util.HashSet;
+import java.util.Set;
+
+import org.drools.brms.client.common.FormStylePopup;
+import org.drools.brms.client.common.ImageButton;
+import org.drools.brms.client.common.InfoPopup;
+import org.drools.brms.client.common.SmallLabel;
+import org.drools.brms.client.modeldriven.HumanReadable;
+import org.drools.brms.client.modeldriven.SuggestionCompletionEngine;
+import org.drools.brms.client.modeldriven.brl.ISingleFieldConstraint;
+import org.drools.brms.client.modeldriven.dt.ConditionCol;
+import org.drools.brms.client.modeldriven.dt.GuidedDecisionTable;
+
+import com.google.gwt.user.client.Command;
+import com.google.gwt.user.client.ui.Button;
+import com.google.gwt.user.client.ui.ChangeListener;
+import com.google.gwt.user.client.ui.ClickListener;
+import com.google.gwt.user.client.ui.HTML;
+import com.google.gwt.user.client.ui.HorizontalPanel;
+import com.google.gwt.user.client.ui.Image;
+import com.google.gwt.user.client.ui.ListBox;
+import com.google.gwt.user.client.ui.RadioButton;
+import com.google.gwt.user.client.ui.TextBox;
+import com.google.gwt.user.client.ui.Widget;
+
+/**
+ * This is a configuration editor for a column in a the guided decision table.
+ * @author Michael Neale
+ *
+ */
+public class GuidedDTColumnConfig extends FormStylePopup {
+
+ private GuidedDecisionTable dt;
+ private SuggestionCompletionEngine sce;
+ private ConditionCol editingCol;
+ private SmallLabel patternLabel = new SmallLabel();
+ private SmallLabel fieldLabel = new SmallLabel();
+ private SmallLabel operatorLabel = new SmallLabel();
+
+ /**
+ * Pass in a null col and it will create a new one.
+ */
+ public GuidedDTColumnConfig(SuggestionCompletionEngine sce, final GuidedDecisionTable dt, final Command refreshGrid, final ConditionCol col, final boolean isNew) {
+ super();
+ this.setModal(false);
+ this.dt = dt;
+ this.sce = sce;
+ this.editingCol = new ConditionCol();
+ editingCol.boundName = col.boundName;
+ editingCol.constraintValueType = col.constraintValueType;
+ editingCol.factField = col.factField;
+ editingCol.factType = col.factType;
+ editingCol.header = col.header;
+ editingCol.operator = col.operator;
+ editingCol.valueList = col.valueList;
+
+
+ setTitle("Condition column configuration");
+
+ final TextBox header = new TextBox();
+ header.setText(col.header);
+ header.addChangeListener(new ChangeListener() {
+ public void onChange(Widget w) {
+ editingCol.header = header.getText();
+ } });
+ addAttribute("Column header (description):", header);
+
+
+ HorizontalPanel pattern = new HorizontalPanel();
+ pattern.add(patternLabel);
+ doPatternLabel();
+
+ Image changePattern = new ImageButton("images/edit.gif", "Choose an existing pattern that this column adds to", new ClickListener() {
+ public void onClick(Widget w) {
+ showChangePattern(w);
+ }
+ });
+ pattern.add(changePattern);
+
+
+ addAttribute("Pattern:", pattern);
+
+ //now a radio button with the type
+ RadioButton literal = new RadioButton("constraintValueType", "Literal value");
+ RadioButton formula = new RadioButton("constraintValueType", "Formula");
+ RadioButton predicate = new RadioButton("constraintValueType", "Predicate");
+
+
+ HorizontalPanel valueTypes = new HorizontalPanel();
+ valueTypes.add(literal);
+ valueTypes.add(formula);
+ valueTypes.add(predicate);
+ addAttribute("Calculation type:", valueTypes);
+
+ switch (editingCol.constraintValueType) {
+ case ISingleFieldConstraint.TYPE_LITERAL:
+ literal.setChecked(true);
+ break;
+ case ISingleFieldConstraint.TYPE_RET_VALUE :
+ formula.setChecked(true);
+ break;
+ case ISingleFieldConstraint.TYPE_PREDICATE :
+ predicate.setChecked(true);
+ }
+
+ literal.addClickListener(new ClickListener() {
+ public void onClick(Widget w) {
+ applyConsTypeChange(ISingleFieldConstraint.TYPE_LITERAL);
+ }
+ });
+
+
+ formula.addClickListener(new ClickListener() {
+ public void onClick(Widget w) {
+ applyConsTypeChange(ISingleFieldConstraint.TYPE_RET_VALUE);
+ }
+ });
+ predicate.addClickListener(new ClickListener() {
+ public void onClick(Widget w) {
+ applyConsTypeChange(ISingleFieldConstraint.TYPE_PREDICATE);
+ }
+ });
+
+
+ HorizontalPanel field = new HorizontalPanel();
+ field.add(fieldLabel);
+ Image editField = new ImageButton("images/edit.gif", "Edit the field that this column operates on", new ClickListener() {
+ public void onClick(Widget w) {
+ showFieldChange();
+ }
+ });
+ field.add(editField);
+ addAttribute("Field:", field);
+ doFieldLabel();
+
+
+ HorizontalPanel operator = new HorizontalPanel();
+ operator.add(operatorLabel);
+ Image editOp = new ImageButton("images/edit.gif", "Edit the operator that is used to compare data with this field", new ClickListener() {
+ public void onClick(Widget w) {
+ showOperatorChange();
+ }
+ });
+ operator.add(editOp);
+ addAttribute("Operator:", operator);
+ doOperatorLabel();
+
+ final TextBox valueList = new TextBox();
+ valueList.setText(editingCol.valueList);
+ valueList.addChangeListener(new ChangeListener() {
+ public void onChange(Widget w) {
+ editingCol.valueList = valueList.getText();
+ }
+ });
+ HorizontalPanel vl = new HorizontalPanel();
+ vl.add(valueList);
+ vl.add(new InfoPopup("Value list", "Value lists are an optional comma separated list of values to show as a drop down."));
+ addAttribute("(optional) value list:", vl);
+
+ Button apply = new Button("Apply changes");
+ apply.addClickListener(new ClickListener() {
+ public void onClick(Widget w) {
+ if (isNew) {
+ dt.conditionCols.add(editingCol);
+ } else {
+ col.boundName = editingCol.boundName;
+ col.constraintValueType = editingCol.constraintValueType;
+ col.factField = editingCol.factField;
+ col.factType = editingCol.factType;
+ col.header = editingCol.header;
+ col.operator = editingCol.operator;
+ col.valueList = editingCol.valueList;
+ }
+ refreshGrid.execute();
+ hide();
+
+ }
+ });
+ addAttribute("", apply);
+
+
+
+
+
+ }
+
+ private void applyConsTypeChange(int newType) {
+ editingCol.constraintValueType = newType;
+ doFieldLabel();
+ doOperatorLabel();
+ }
+
+
+ private void doOperatorLabel() {
+ if (editingCol.constraintValueType == ISingleFieldConstraint.TYPE_PREDICATE) {
+ operatorLabel.setText("(not needed for predicate)");
+ } else if (nil(editingCol.factType)) {
+ operatorLabel.setText("(please select a pattern first)");
+ } else if (nil(editingCol.factField)) {
+ operatorLabel.setText("(please choose a field first)");
+ } else if (nil(editingCol.operator)) {
+ operatorLabel.setText("(please select a field)");
+ } else {
+ operatorLabel.setText(HumanReadable.getOperatorDisplayName(editingCol.operator));
+ }
+ }
+
+ private void showOperatorChange() {
+ final FormStylePopup pop = new FormStylePopup();
+ pop.setTitle("Set the operator");
+ pop.setModal(false);
+ String[] ops = this.sce.getOperatorCompletions(editingCol.factType, editingCol.factField);
+ final ListBox box = new ListBox();
+ for (int i = 0; i < ops.length; i++) {
+ box.addItem(HumanReadable.getOperatorDisplayName(ops[i]), ops[i]);
+ }
+ pop.addAttribute("Operator:", box);
+ Button b = new Button("OK");
+ pop.addAttribute("", b);
+ b.addClickListener(new ClickListener() {
+ public void onClick(Widget w) {
+ editingCol.operator = box.getValue(box.getSelectedIndex());
+ doOperatorLabel();
+ pop.hide();
+ }
+ });
+ pop.show();
+
+ }
+
+ private void doFieldLabel() {
+ if (editingCol.constraintValueType == ISingleFieldConstraint.TYPE_PREDICATE) {
+ fieldLabel.setText("(not needed for predicate)");
+ } else if (nil(editingCol.factType)) {
+ fieldLabel.setText("(please select a pattern first)");
+ }
+ else if (nil(editingCol.factField)) {
+ fieldLabel.setText("(please select a field)");
+ } else {
+ fieldLabel.setText(this.editingCol.factField);
+ }
+ }
+
+ private boolean nil(String s) {
+ return s == null || s.equals("");
+ }
+
+ protected void showFieldChange() {
+ final FormStylePopup pop = new FormStylePopup();
+ pop.setModal(false);
+ String[] fields = this.sce.getFieldCompletions(this.editingCol.factType);
+ final ListBox box = new ListBox();
+ for (int i = 0; i < fields.length; i++) {
+ box.addItem(fields[i]);
+ }
+ pop.addAttribute("Field:", box);
+ Button b = new Button("OK");
+ pop.addAttribute("", b);
+ b.addClickListener(new ClickListener() {
+ public void onClick(Widget w) {
+ editingCol.factField = box.getItemText(box.getSelectedIndex());
+ doFieldLabel();
+ doOperatorLabel();
+ pop.hide();
+ }
+ });
+ pop.show();
+ }
+
+ private void doPatternLabel() {
+ if (this.editingCol.factType != null) {
+ this.patternLabel.setText(this.editingCol.factType + " [" + editingCol.boundName + "]");
+ }
+ doFieldLabel();
+ doOperatorLabel();
+
+ }
+
+ protected void showChangePattern(Widget w) {
+
+ final ListBox pats = this.loadPatterns();
+ if (pats.getItemCount() == 0) {
+ showNewPatternDialog();
+ return;
+ }
+ final FormStylePopup pop = new FormStylePopup();
+ Button ok = new Button("OK");
+ HorizontalPanel hp = new HorizontalPanel();
+ hp.add(pats);
+ hp.add(ok);
+
+
+ pop.addAttribute("Choose existing pattern to add column to:", hp);
+ pop.addAttribute("", new HTML("<i><b>---OR---</i></b>"));
+
+ Button createPattern = new Button("Create new fact pattern");
+ createPattern.addClickListener(new ClickListener() {
+ public void onClick(Widget w) {
+ pop.hide();
+ showNewPatternDialog();
+ }
+ });
+ pop.addAttribute("", createPattern);
+
+
+
+
+ ok.addClickListener(new ClickListener() {
+ public void onClick(Widget w) {
+ String[] val = pats.getValue(pats.getSelectedIndex()).split("\\s");
+ editingCol.factType = val[0];
+ editingCol.boundName = val[1];
+ doPatternLabel();
+ pop.hide();
+ }
+ });
+
+ pop.show();
+ }
+
+ protected void showNewPatternDialog() {
+ final FormStylePopup pop = new FormStylePopup();
+ pop.setTitle("Create a new fact pattern");
+ final ListBox types = new ListBox();
+ for (int i = 0; i < sce.factTypes.length; i++) {
+ types.addItem(sce.factTypes[i]);
+ }
+ pop.addAttribute("Fact type:", types);
+ final TextBox binding = new TextBox();
+ pop.addAttribute("name:", binding);
+
+ Button ok = new Button("OK");
+ ok.addClickListener(new ClickListener() {
+ public void onClick(Widget w) {
+ editingCol.boundName = binding.getText();
+ editingCol.factType = types.getItemText(types.getSelectedIndex());
+ doPatternLabel();
+ pop.hide();
+ }
+ });
+ pop.addAttribute("", ok);
+
+ pop.show();
+
+ }
+
+ private ListBox loadPatterns() {
+ Set vars = new HashSet();
+ ListBox patterns = new ListBox();
+ for (int i = 0; i < dt.conditionCols.size(); i++) {
+ ConditionCol c = (ConditionCol) dt.conditionCols.get(i);
+ if (!vars.contains(c.boundName)) {
+ patterns.addItem(c.factType + " [" + c.boundName + "]", c.factType + " " + c.boundName);
+ vars.add(c.boundName);
+ }
+ }
+
+ return patterns;
+
+ }
+
+
+
+}
Modified: labs/jbossrules/branches/temporal_rete/drools-jbrms/src/main/java/org/drools/brms/client/decisiontable/GuidedDecisionTableWidget.java
===================================================================
--- labs/jbossrules/branches/temporal_rete/drools-jbrms/src/main/java/org/drools/brms/client/decisiontable/GuidedDecisionTableWidget.java 2008-03-20 18:57:07 UTC (rev 19163)
+++ labs/jbossrules/branches/temporal_rete/drools-jbrms/src/main/java/org/drools/brms/client/decisiontable/GuidedDecisionTableWidget.java 2008-03-20 19:32:10 UTC (rev 19164)
@@ -1,13 +1,37 @@
package org.drools.brms.client.decisiontable;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+
+import org.drools.brms.client.common.FormStylePopup;
+import org.drools.brms.client.common.ImageButton;
+import org.drools.brms.client.common.PrettyFormLayout;
+import org.drools.brms.client.common.SmallLabel;
+import org.drools.brms.client.modeldriven.SuggestionCompletionEngine;
+import org.drools.brms.client.modeldriven.brl.ISingleFieldConstraint;
import org.drools.brms.client.modeldriven.dt.ActionCol;
+import org.drools.brms.client.modeldriven.dt.ActionInsertFactCol;
+import org.drools.brms.client.modeldriven.dt.ActionSetFieldCol;
import org.drools.brms.client.modeldriven.dt.AttributeCol;
import org.drools.brms.client.modeldriven.dt.ConditionCol;
+import org.drools.brms.client.modeldriven.dt.DTColumnConfig;
import org.drools.brms.client.modeldriven.dt.GuidedDecisionTable;
+import org.drools.brms.client.modeldriven.ui.ActionValueEditor;
+import org.drools.brms.client.packages.SuggestionCompletionCache;
+import org.drools.brms.client.rpc.RuleAsset;
+import com.google.gwt.user.client.Command;
+import com.google.gwt.user.client.ui.Button;
+import com.google.gwt.user.client.ui.ClickListener;
import com.google.gwt.user.client.ui.Composite;
+import com.google.gwt.user.client.ui.HTML;
+import com.google.gwt.user.client.ui.HorizontalPanel;
+import com.google.gwt.user.client.ui.Image;
import com.google.gwt.user.client.ui.KeyboardListener;
import com.google.gwt.user.client.ui.KeyboardListenerAdapter;
+import com.google.gwt.user.client.ui.ListBox;
import com.google.gwt.user.client.ui.TextBox;
import com.google.gwt.user.client.ui.VerticalPanel;
import com.google.gwt.user.client.ui.Widget;
@@ -26,6 +50,8 @@
import com.gwtext.client.widgets.Toolbar;
import com.gwtext.client.widgets.ToolbarMenuButton;
import com.gwtext.client.widgets.Window;
+import com.gwtext.client.widgets.form.FieldSet;
+import com.gwtext.client.widgets.form.FormPanel;
import com.gwtext.client.widgets.grid.BaseColumnConfig;
import com.gwtext.client.widgets.grid.CellMetadata;
import com.gwtext.client.widgets.grid.ColumnConfig;
@@ -34,6 +60,7 @@
import com.gwtext.client.widgets.grid.GroupingView;
import com.gwtext.client.widgets.grid.Renderer;
import com.gwtext.client.widgets.grid.event.GridCellListenerAdapter;
+import com.gwtext.client.widgets.grid.event.GridColumnListenerAdapter;
import com.gwtext.client.widgets.menu.BaseItem;
import com.gwtext.client.widgets.menu.Item;
import com.gwtext.client.widgets.menu.Menu;
@@ -46,24 +73,437 @@
public class GuidedDecisionTableWidget extends Composite {
private GuidedDecisionTable dt;
+ private VerticalPanel layout;
+ private GridPanel grid;
+ private FieldDef[] fds;
+ private VerticalPanel attributeConfigWidget;
+ private VerticalPanel conditionsConfigWidget;
+ private String packageName;
+ private VerticalPanel actionsConfigWidget;
+ private Map colMap;
+ private SuggestionCompletionEngine sce;
- public GuidedDecisionTableWidget(GuidedDecisionTable dt) {
+ public GuidedDecisionTableWidget(RuleAsset asset) {
- this.dt = dt;
- GridPanel grid = doGrid();
- VerticalPanel p = new VerticalPanel();
- p.add(grid);
+ this.dt = (GuidedDecisionTable) asset.content;
+ this.packageName = asset.metaData.packageName;
- initWidget(p);
+ layout = new VerticalPanel();
+
+ FormPanel config = new FormPanel();
+ config.setTitle("Decision table");
+
+ config.setBodyBorder(false);
+ config.setCollapsed(true);
+ config.setCollapsible(true);
+
+
+ FieldSet attributes = new FieldSet("Attribute columns");
+ attributes.setCollapsible(true);
+
+ attributes.setFrame(true);
+ attributes.add(getAttributes());
+ attributes.setCollapsed(dt.attributeCols.size() == 0);
+ config.add(attributes);
+
+
+ FieldSet conditions = new FieldSet("Condition columns");
+ conditions.setCollapsible(true);
+ conditions.add(getConditions());
+ config.add(conditions);
+
+
+ FieldSet actions = new FieldSet("Action columns");
+ actions.setCollapsible(true);
+ actions.add(getActions());
+ config.add(actions);
+
+
+ layout.add(config);
+
+ refreshGrid();
+
+
+ initWidget(layout);
}
+ private Widget getActions() {
+ actionsConfigWidget = new VerticalPanel();
+ refreshActionsWidget();
+ return actionsConfigWidget;
+ }
+
+ private void refreshActionsWidget() {
+ this.actionsConfigWidget.clear();
+ for (int i = 0; i < dt.actionCols.size(); i++) {
+ ActionCol c = (ActionCol) dt.actionCols.get(i);
+ HorizontalPanel hp = new HorizontalPanel();
+ hp.add(removeAction(c));
+ hp.add(editAction(c));
+ hp.add(new SmallLabel(c.header));
+ actionsConfigWidget.add(hp);
+ }
+ actionsConfigWidget.add(newAction());
+
+ }
+
+ private Widget editAction(final ActionCol c) {
+ return new ImageButton("images/edit.gif", "Edit this action column configuration", new ClickListener() {
+ public void onClick(Widget w) {
+ if (c instanceof ActionSetFieldCol) {
+ ActionSetFieldCol asf = (ActionSetFieldCol) c;
+ ActionSetColumn ed = new ActionSetColumn(getSCE(), dt, new Command() {
+ public void execute() {
+ scrapeData(-1);
+ refreshGrid();
+ refreshActionsWidget();
+ }
+ }
+ , asf, false);
+ ed.show();
+ } else if (c instanceof ActionInsertFactCol) {
+ ActionInsertFactCol asf = (ActionInsertFactCol) c;
+ ActionInsertColumn ed = new ActionInsertColumn(getSCE(), dt, new Command() {
+ public void execute() {
+ scrapeData(-1);
+ refreshGrid();
+ refreshActionsWidget();
+ }
+ }
+ , asf, false);
+ ed.show();
+ }
+
+ }
+ });
+
+ }
+
+ private Widget newAction() {
+ return new ImageButton( "images/new_item.gif", "Create a new action column", new ClickListener() {
+ public void onClick(Widget w) {
+ final FormStylePopup pop = new FormStylePopup();
+ pop.setModal(false);
+
+ final ListBox choice = new ListBox();
+ choice.addItem("Set the value of a field", "set");
+ choice.addItem("Set the value of a field on a new fact", "insert");
+ Button ok = new Button("OK");
+ ok.addClickListener(new ClickListener() {
+ public void onClick(Widget w) {
+ String s = choice.getValue(choice.getSelectedIndex());
+ if (s.equals("set")) {
+ showSet();
+ } else if (s.equals("insert")) {
+ showInsert();
+ }
+ pop.hide();
+ }
+
+ private void showInsert() {
+ ActionInsertColumn ins = new ActionInsertColumn(getSCE(), dt, new Command() {
+ public void execute() { newActionAdded(); }
+ }, new ActionInsertFactCol(), true);
+ ins.show();
+ }
+
+ private void showSet() {
+ ActionSetColumn set = new ActionSetColumn(getSCE(), dt, new Command() {
+ public void execute() { newActionAdded(); }
+ }, new ActionSetFieldCol(), true);
+ set.show();
+ }
+
+ private void newActionAdded() {
+ //want to add in a blank row into the data
+ scrapeData(dt.attributeCols.size() + dt.conditionCols.size() + dt.actionCols.size() + 1);
+ refreshGrid();
+ refreshActionsWidget();
+
+ }
+ });
+ pop.addAttribute("Type of action column:", choice);
+ pop.addAttribute("", ok);
+ pop.show();
+ }
+
+ });
+
+
+ }
+
+ private Widget removeAction(final ActionCol c) {
+ Image del = new ImageButton("images/delete_item_small.gif", "Remove this action column", new ClickListener() {
+ public void onClick(Widget w) {
+ if (com.google.gwt.user.client.Window.confirm("Are you sure you want to delete the column for " + c.header + " - all data in that column will be removed?")) {
+ dt.actionCols.remove(c);
+ removeField(c.header);
+ scrapeData(-1);
+ refreshGrid();
+ refreshActionsWidget();
+ }
+ }
+ });
+
+ return del;
+ }
+
+ private Widget getConditions() {
+ conditionsConfigWidget = new VerticalPanel();
+ refreshConditionsWidget();
+ return conditionsConfigWidget;
+ }
+
+ private void refreshConditionsWidget() {
+ this.conditionsConfigWidget.clear();
+ for (int i = 0; i < dt.conditionCols.size(); i++) {
+ ConditionCol c = (ConditionCol) dt.conditionCols.get(i);
+ HorizontalPanel hp = new HorizontalPanel();
+ hp.add(removeCondition(c));
+ hp.add(editCondition(c));
+ hp.add(new SmallLabel(c.header));
+ conditionsConfigWidget.add(hp);
+ }
+ conditionsConfigWidget.add(newCondition());
+
+
+
+ }
+
+ private Widget newCondition() {
+ final ConditionCol newCol = new ConditionCol();
+ newCol.constraintValueType = ISingleFieldConstraint.TYPE_LITERAL;
+ return new ImageButton("images/new_item.gif", "Add a new condition column", new ClickListener() {
+ public void onClick(Widget w) {
+ GuidedDTColumnConfig dialog = new GuidedDTColumnConfig(getSCE(), dt, new Command() {
+ public void execute() {
+ //want to add in a blank row into the data
+ scrapeData(dt.attributeCols.size() + dt.conditionCols.size() + 1);
+ refreshGrid();
+ refreshConditionsWidget();
+ }
+ }, newCol, true);
+ dialog.show();
+ }
+ });
+ }
+
+ private Widget editCondition(final ConditionCol c) {
+ return new ImageButton("images/edit.gif", "Edit this columns configuration", new ClickListener() {
+ public void onClick(Widget w) {
+ GuidedDTColumnConfig dialog = new GuidedDTColumnConfig(getSCE(), dt, new Command() {
+ public void execute() {
+ scrapeData(-1);
+ refreshGrid();
+ refreshConditionsWidget();
+ }
+ }, c, false);
+ dialog.show();
+ }
+ });
+ }
+
+ private SuggestionCompletionEngine getSCE() {
+ if (sce == null) {
+ this.sce = SuggestionCompletionCache.getInstance().getEngineFromCache(this.packageName);
+ }
+ return sce;
+ }
+
+ private Widget removeCondition(final ConditionCol c) {
+ Image del = new ImageButton("images/delete_item_small.gif", "Remove this condition column", new ClickListener() {
+ public void onClick(Widget w) {
+ if (com.google.gwt.user.client.Window.confirm("Are you sure you want to delete the column for " + c.header + " - all data in that column will be removed?")) {
+ dt.conditionCols.remove(c);
+ removeField(c.header);
+ scrapeData(-1);
+ refreshGrid();
+ refreshConditionsWidget();
+ }
+ }
+ });
+
+ return del;
+ }
+
+ private Widget getAttributes() {
+ attributeConfigWidget = new VerticalPanel();
+ refreshAttributeWidget();
+ return attributeConfigWidget;
+ }
+
+ private void refreshAttributeWidget() {
+ this.attributeConfigWidget.clear();
+ for (int i = 0; i < dt.attributeCols.size(); i++) {
+ AttributeCol at = (AttributeCol) dt.attributeCols.get(i);
+ HorizontalPanel hp = new HorizontalPanel();
+ hp.add(removeAttr(at));
+ hp.add(new SmallLabel(at.attr));
+ attributeConfigWidget.add(hp);
+ }
+ attributeConfigWidget.add(newAttr());
+ }
+
+ private Widget newAttr() {
+ ImageButton but = new ImageButton("images/new_item.gif", "Add a new attribute.", new ClickListener() {
+ public void onClick(Widget w) {
+ //show choice of attributes
+ final FormStylePopup pop = new FormStylePopup();
+ final ListBox list = new ListBox();
+ list.addItem( "Choose..." );
+
+
+ addItem( "salience",list);
+ addItem( "enabled", list );
+ addItem( "date-effective", list );
+ addItem( "date-expires", list );
+ addItem( "no-loop", list );
+ addItem( "agenda-group", list );
+ addItem( "activation-group", list );
+ addItem( "duration", list );
+ addItem( "auto-focus", list );
+ addItem( "lock-on-active", list );
+ addItem( "ruleflow-group", list );
+
+ pop.addAttribute("New attribute:", list);
+
+ Button ok = new Button("Add");
+ ok.addClickListener(new ClickListener() {
+ public void onClick(Widget w) {
+
+ AttributeCol attr = new AttributeCol();
+ attr.attr = list.getItemText(list.getSelectedIndex());
+ if (attr.attr.equals("Choose...")) {
+ com.google.gwt.user.client.Window.alert("Please pick a valid attribute");
+ return;
+ }
+ dt.attributeCols.add(attr);
+ scrapeData(dt.attributeCols.size() + 1);
+ refreshGrid();
+ refreshAttributeWidget();
+ pop.hide();
+ }
+ });
+
+ pop.addAttribute("", ok);
+ pop.show();
+ }
+
+ private void addItem(String at, final ListBox list) {
+ if (!hasAttribute(at, dt.attributeCols)) list.addItem( at );
+ }
+
+ private boolean hasAttribute(String at, List attributeCols) {
+ for (Iterator iterator = attributeCols.iterator(); iterator
+ .hasNext();) {
+ AttributeCol c = (AttributeCol) iterator.next();
+ if (c.attr.equals(at)) {
+ return true;
+ }
+ }
+ return false;
+ }
+ });
+ return but;
+ }
+
+ private Widget removeAttr(final AttributeCol at) {
+ Image del = new ImageButton("images/delete_item_small.gif", "Remove this attribute", new ClickListener() {
+ public void onClick(Widget w) {
+ if (com.google.gwt.user.client.Window.confirm("Are you sure you want to delete the column for " + at.attr + " - all data in that column will be removed?")) {
+ dt.attributeCols.remove(at);
+ removeField(at.attr);
+ scrapeData(-1);
+ refreshGrid();
+ refreshAttributeWidget();
+ }
+ }
+ });
+
+ return del;
+ }
+
+ /**
+ * Here we read the record data from the grid into the data in the model.
+ * if we have an insertCol - then a new empty column of data will be added in that
+ * row position.
+ */
+ private void scrapeData(int insertCol) {
+ Record[] recs = grid.getStore().getRecords();
+ dt.data = new String[recs.length][];
+ for (int i = 0; i < recs.length; i++) {
+ Record r = recs[i];
+ if (insertCol == -1) {
+ String[] row = new String[fds.length];
+ dt.data[i] = row;
+ for (int j = 0; j < fds.length; j++) {
+ row[j] = r.getAsString(fds[j].getName());
+ }
+ } else {
+ String[] row = new String[fds.length + 1];
+ dt.data[i] = row;
+ for (int j = 0; j < fds.length; j++) {
+ if (j < insertCol) {
+ row[j] = r.getAsString(fds[j].getName());
+ } else if (j >= insertCol) {
+ row[j + 1] = r.getAsString(fds[j].getName());
+ }
+ }
+ }
+ }
+ }
+
+ /**
+ * removes the field from the field def.
+ * @param headerName
+ */
+ private void removeField(String headerName) {
+ FieldDef[] fds_ = new FieldDef[fds.length -1];
+ int new_i = 0;
+ for (int i = 0; i < fds.length; i++) {
+ FieldDef fd = fds[i];
+ if (!fd.getName().equals(headerName)) {
+ fds_[new_i] = fd;
+ new_i++;
+ }
+ }
+ this.fds = fds_;
+
+ }
+
+
+ private void refreshGrid() {
+ if (layout.getWidgetCount() > 1) {
+ layout.remove(1);
+ }
+ if (dt.actionCols.size() == 0 && dt.conditionCols.size() == 0 && dt.actionCols.size() == 0) {
+ VerticalPanel vp = new VerticalPanel();
+ vp.setWidth("100%");
+ PrettyFormLayout pfl = new PrettyFormLayout();
+ pfl.startSection();
+ pfl.addRow(new HTML("<img src='images/information.gif'/> Configure the columns first, then add rows (rules)."));
+
+ pfl.endSection();
+ vp.add(pfl);
+ grid = doGrid();
+ vp.add(grid);
+ layout.add(vp);
+
+ } else {
+ grid = doGrid();
+ layout.add(grid);
+ }
+ }
+
private GridPanel doGrid() {
- FieldDef[] fds = new FieldDef[dt.attributeCols.size() + dt.actionCols.size() + dt.conditionCols.size() + 2]; //its +2 as we have counter and description data
+ fds = new FieldDef[dt.attributeCols.size() + dt.actionCols.size() + dt.conditionCols.size() + 2]; //its +2 as we have counter and description data
+ colMap = new HashMap();
+
fds[0] = new StringFieldDef("num");
fds[1] = new StringFieldDef("desc");
@@ -104,8 +544,13 @@
setHeader(attr.attr);
setDataIndex(attr.attr);
setSortable(true);
+ if (attr.width != -1) {
+ setWidth(attr.width);
+ }
+
}
};
+ colMap.put(attr.attr, attr);
colCount++;
}
@@ -120,8 +565,12 @@
setHeader(c.header);
setDataIndex(c.header);
setSortable(true);
+ if (c.width != -1) {
+ setWidth(c.width);
+ }
}
};
+ colMap.put(c.header, c);
colCount++;
}
@@ -156,8 +605,12 @@
setDataIndex(c.header);
//and here we do the appropriate editor
setSortable(true);
+ if (c.width != -1) {
+ setWidth(-1);
+ }
}
};
+ colMap.put(c.header, c);
colCount++;
}
@@ -166,8 +619,6 @@
MemoryProxy proxy = new MemoryProxy( dt.data );
-
-
ColumnModel cm = new ColumnModel(cols);
final GroupingStore store = new GroupingStore();
store.setReader(reader);
@@ -190,46 +641,45 @@
grid.setStore(store);
- grid.setWidth(500);
- grid.setHeight(300);
+ grid.setWidth(700);
+ grid.setHeight(500);
grid.addGridCellListener(new GridCellListenerAdapter() {
public void onCellDblClick(GridPanel grid, int rowIndex,
int colIndex, EventObject e) {
- final String dta = grid.getColumnModel().getDataIndex(colIndex);
-
+ final String dataIdx = grid.getColumnModel().getDataIndex(colIndex);
final Record r = store.getAt(rowIndex);
+ String val = r.getAsString(dataIdx);
+ DTColumnConfig colConf = (DTColumnConfig) colMap.get(dataIdx);
+ String[] vals = dt.getValueList(colConf, getSCE());
+ if (vals.length == 0) {
+ showTextEditor(e, dataIdx, r, val, colConf);
+ } else {
+ showDropDownEditor(e, dataIdx, r, val, vals);
+ }
- String val = r.getAsString(dta);
+ //box.setFocus(true);
- final Window w = new Window();
- w.setWidth(168);
- w.setAutoDestroy(true);
- final TextBox box = new TextBox();
- box.setText(val);
- box.addKeyboardListener(new KeyboardListenerAdapter() {
- public void onKeyUp(Widget sender, char keyCode,
- int modifiers) {
- if (keyCode == KeyboardListener.KEY_ENTER) {
- r.set(dta, box.getText());
- w.destroy();
- }
- }
- });
- Panel p = new Panel();
- p.add(box);
- w.add(p);
- w.setBorder(false);
+ }
- w.setPosition(e.getPageX(), e.getPageY());
- w.show();
- //box.setFocus(true);
+ });
-
+ //remember any size changes
+ grid.addGridColumnListener(new GridColumnListenerAdapter() {
+ public void onColumnResize(GridPanel grid, int colIndex, int newSize) {
+ final String dta = grid.getColumnModel().getDataIndex(colIndex);
+ if (dta.equals("desc")) {
+ dt.descriptionWidth = newSize;
+ } else {
+ if (colMap.containsKey(dta)) {
+ DTColumnConfig col = (DTColumnConfig) colMap.get(dta);
+ col.width = newSize;
+ }
+ }
}
});
@@ -261,11 +711,61 @@
+ return grid;
+ }
- return grid;
+ /**
+ * Show a drop down editor, obviously.
+ */
+
+ private void showDropDownEditor(EventObject e, final String dataIdx, final Record r, String val, String[] vals) {
+ final Window w = new Window();
+ w.setWidth(200);
+ w.setPlain(true);
+ w.setBodyBorder(false);
+ w.setAutoDestroy(true);
+ w.setTitle("Select value for " + dataIdx);
+ final ListBox drop = new ListBox();
+ for (int i = 0; i < vals.length; i++) {
+ String v = vals[i].trim();
+ drop.addItem(v);
+ if (v.equals(val)) {
+ drop.setSelectedIndex(i);
+ }
+ }
+ drop.addKeyboardListener(new KeyboardListenerAdapter() {
+ public void onKeyUp(Widget sender, char keyCode,
+ int modifiers) {
+ if (keyCode == KeyboardListener.KEY_ENTER) {
+ r.set(dataIdx, drop.getItemText(drop.getSelectedIndex()));
+ w.destroy();
+ }
+ }
+ });
+
+
+
+
+ Panel p = new Panel();
+ p.add(drop);
+ w.add(p);
+ w.setBorder(false);
+
+ Button ok = new Button("OK");
+ ok.addClickListener(new ClickListener() {
+ public void onClick(Widget wg) {
+ r.set(dataIdx, drop.getItemText(drop.getSelectedIndex()));
+ w.destroy();
+ }
+ });
+ p.add(ok);
+
+ w.setPosition(e.getPageX(), e.getPageY());
+ w.show();
+
}
private void renumber(Record[] rs) {
@@ -274,4 +774,51 @@
}
}
+
+ /**
+ * Show a plain old text editor for a cell.
+ */
+ private void showTextEditor(EventObject e, final String dta,
+ final Record r, String val, DTColumnConfig colConf) {
+ final Window w = new Window();
+ w.setWidth(200);
+ w.setAutoDestroy(true);
+ w.setPlain(true);
+ w.setBodyBorder(false);
+ w.setTitle("Set value for " + dta);
+ final TextBox box = new TextBox();
+ box.setText(val);
+ box.addKeyboardListener(new KeyboardListenerAdapter() {
+ public void onKeyUp(Widget sender, char keyCode,
+ int modifiers) {
+ if (keyCode == KeyboardListener.KEY_ENTER) {
+ r.set(dta, box.getText());
+ w.destroy();
+ }
+ }
+ });
+
+ if (dt.isNumeric(colConf, getSCE())) {
+ box.addKeyboardListener(ActionValueEditor.getNumericFilter(box));
+ }
+
+ Panel p = new Panel();
+ p.add(box);
+ w.add(p);
+ w.setBorder(false);
+
+ Button ok = new Button("OK");
+ ok.addClickListener(new ClickListener() {
+ public void onClick(Widget wg) {
+ r.set(dta, box.getText());
+ w.destroy();
+ }
+ });
+ p.add(ok);
+
+ w.setPosition(e.getPageX(), e.getPageY());
+ w.show();
+ }
+
+
}
Deleted: labs/jbossrules/branches/temporal_rete/drools-jbrms/src/main/java/org/drools/brms/client/decisiontable/InsertAction.java
===================================================================
--- labs/jbossrules/branches/temporal_rete/drools-jbrms/src/main/java/org/drools/brms/client/decisiontable/InsertAction.java 2008-03-20 18:57:07 UTC (rev 19163)
+++ labs/jbossrules/branches/temporal_rete/drools-jbrms/src/main/java/org/drools/brms/client/decisiontable/InsertAction.java 2008-03-20 19:32:10 UTC (rev 19164)
@@ -1,71 +0,0 @@
-package org.drools.brms.client.decisiontable;
-/*
- * Copyright 2005 JBoss Inc
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-
-
-import org.drools.brms.client.decisiontable.EditableDTGrid.RowClickListener;
-
-import com.google.gwt.user.client.ui.ClickListener;
-import com.google.gwt.user.client.ui.Composite;
-import com.google.gwt.user.client.ui.HorizontalPanel;
-import com.google.gwt.user.client.ui.Image;
-import com.google.gwt.user.client.ui.Widget;
-
-/**
- * This shows the widget for inserting a row.
- * @author Steven Williams
- */
-public class InsertAction extends Composite {
-
- private HorizontalPanel panel = new HorizontalPanel();
- private Image insert;
- private int row;
-
-
-
-
- /**
- * Pass in the click listener delegate for when the respective action is clicked
- * @param clickListener
- * @param okClickListener
- */
- public InsertAction(final int currentRow, final RowClickListener clickListener) {
- row = currentRow;
- insert = new Image("images/new_item.gif");
- insert.setTitle( "Insert row after row " + row );
- insert.addClickListener( new ClickListener() {
- public void onClick(final Widget w) {
- clickListener.onClick(w, row);
- }
- });
-
- panel.add( insert);
-
- initWidget( panel );
- }
-
- public void setRow(final int row) {
- this.row = row;
- insert.setTitle( "Insert row after row " + row );
-
- }
-
- public int getRow() {
- return row;
- }
-
-}
\ No newline at end of file
Deleted: labs/jbossrules/branches/temporal_rete/drools-jbrms/src/main/java/org/drools/brms/client/decisiontable/MergeAction.java
===================================================================
--- labs/jbossrules/branches/temporal_rete/drools-jbrms/src/main/java/org/drools/brms/client/decisiontable/MergeAction.java 2008-03-20 18:57:07 UTC (rev 19163)
+++ labs/jbossrules/branches/temporal_rete/drools-jbrms/src/main/java/org/drools/brms/client/decisiontable/MergeAction.java 2008-03-20 19:32:10 UTC (rev 19164)
@@ -1,69 +0,0 @@
-package org.drools.brms.client.decisiontable;
-/*
- * Copyright 2005 JBoss Inc
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-
-
-import org.drools.brms.client.decisiontable.EditableDTGrid.RowClickListener;
-
-import com.google.gwt.user.client.ui.ClickListener;
-import com.google.gwt.user.client.ui.Composite;
-import com.google.gwt.user.client.ui.HorizontalPanel;
-import com.google.gwt.user.client.ui.Image;
-import com.google.gwt.user.client.ui.Widget;
-
-/**
- * This shows the widget for merging cells in a row.
- * @author Steven Williams
- */
-public class MergeAction extends Composite {
-
- private HorizontalPanel panel = new HorizontalPanel();
- private Image merge;
- private int row;
-
-
-
-
- /**
- * Pass in the click listener delegate for when the respective action is clicked
- * @param clickListener
- * @param okClickListener
- */
- public MergeAction(final int currentRow, final RowClickListener clickListener) {
- row = currentRow;
- merge = new Image("images/refresh.gif");
- merge.setTitle( "Merge cells in this row" );
- merge.addClickListener( new ClickListener() {
- public void onClick(final Widget w) {
- clickListener.onClick(w, row);
- }
- });
-
- panel.add( merge);
-
- initWidget( panel );
- }
-
- public void setRow(final int row) {
- this.row = row;
- }
-
- public int getRow() {
- return row;
- }
-
-}
\ No newline at end of file
Deleted: labs/jbossrules/branches/temporal_rete/drools-jbrms/src/main/java/org/drools/brms/client/decisiontable/ShuffleAction.java
===================================================================
--- labs/jbossrules/branches/temporal_rete/drools-jbrms/src/main/java/org/drools/brms/client/decisiontable/ShuffleAction.java 2008-03-20 18:57:07 UTC (rev 19163)
+++ labs/jbossrules/branches/temporal_rete/drools-jbrms/src/main/java/org/drools/brms/client/decisiontable/ShuffleAction.java 2008-03-20 19:32:10 UTC (rev 19164)
@@ -1,75 +0,0 @@
-package org.drools.brms.client.decisiontable;
-/*
- * Copyright 2005 JBoss Inc
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-
-
-import org.drools.brms.client.decisiontable.EditableDTGrid.RowClickListener;
-
-import com.google.gwt.user.client.ui.ClickListener;
-import com.google.gwt.user.client.ui.Composite;
-import com.google.gwt.user.client.ui.HorizontalPanel;
-import com.google.gwt.user.client.ui.Image;
-import com.google.gwt.user.client.ui.Widget;
-
-/**
- * This shows the widget for moving a row up or down.
- * @author Steven Williams
- */
-public class ShuffleAction extends Composite {
-
- private HorizontalPanel panel = new HorizontalPanel();
- private Image shuffle;
- private int row;
-
- public final static ShuffleAction EMPTY1 = new ShuffleAction() {
-
- };
-
- public ShuffleAction() {
- initWidget(panel);
- }
- /**
- * Pass in the click listener delegate for when the respective action is clicked and the
- * direction to move the row
- * @param currentRow
- * @param clickListener
- * @param direction
- */
- public ShuffleAction(final int currentRow, final RowClickListener clickListener, final String direction) {
- row = currentRow;
- shuffle = new Image("images/shuffle_" + direction + ".gif");
- shuffle.setTitle( "Move this row " + direction );
- shuffle.addClickListener( new ClickListener() {
- public void onClick(final Widget w) {
- clickListener.onClick(w, row);
- }
- });
-
- panel.add( shuffle);
-
- initWidget( panel );
- }
-
- public void setRow(final int row) {
- this.row = row;
- }
-
- public int getRow() {
- return row;
- }
-
-}
\ No newline at end of file
Deleted: labs/jbossrules/branches/temporal_rete/drools-jbrms/src/main/java/org/drools/brms/client/decisiontable/ShuffleDownAction.java
===================================================================
--- labs/jbossrules/branches/temporal_rete/drools-jbrms/src/main/java/org/drools/brms/client/decisiontable/ShuffleDownAction.java 2008-03-20 18:57:07 UTC (rev 19163)
+++ labs/jbossrules/branches/temporal_rete/drools-jbrms/src/main/java/org/drools/brms/client/decisiontable/ShuffleDownAction.java 2008-03-20 19:32:10 UTC (rev 19164)
@@ -1,37 +0,0 @@
-package org.drools.brms.client.decisiontable;
-/*
- * Copyright 2005 JBoss Inc
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-
-
-import org.drools.brms.client.decisiontable.EditableDTGrid.RowClickListener;
-
-/**
- * This shows the widget for moving a row down.
- * @author Steven Williams
- */
-public class ShuffleDownAction extends ShuffleAction {
-
- /**
- * Pass in the click listener delegate for when the respective action is clicked
- * @param clickListener
- * @param okClickListener
- */
- public ShuffleDownAction(final int currentRow, final RowClickListener clickListener) {
- super(currentRow, clickListener, "down");
- }
-
-}
\ No newline at end of file
Deleted: labs/jbossrules/branches/temporal_rete/drools-jbrms/src/main/java/org/drools/brms/client/decisiontable/ShuffleUpAction.java
===================================================================
--- labs/jbossrules/branches/temporal_rete/drools-jbrms/src/main/java/org/drools/brms/client/decisiontable/ShuffleUpAction.java 2008-03-20 18:57:07 UTC (rev 19163)
+++ labs/jbossrules/branches/temporal_rete/drools-jbrms/src/main/java/org/drools/brms/client/decisiontable/ShuffleUpAction.java 2008-03-20 19:32:10 UTC (rev 19164)
@@ -1,37 +0,0 @@
-package org.drools.brms.client.decisiontable;
-/*
- * Copyright 2005 JBoss Inc
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-
-
-import org.drools.brms.client.decisiontable.EditableDTGrid.RowClickListener;
-
-/**
- * This shows the widget for moving a row up.
- * @author Steven Williams
- */
-public class ShuffleUpAction extends ShuffleAction {
-
- /**
- * Pass in the click listener delegate for when the respective action is clicked
- * @param clickListener
- * @param okClickListener
- */
- public ShuffleUpAction(final int currentRow, final RowClickListener clickListener) {
- super(currentRow, clickListener, "up");
- }
-
-}
\ No newline at end of file
Deleted: labs/jbossrules/branches/temporal_rete/drools-jbrms/src/main/java/org/drools/brms/client/decisiontable/Toolbar.java
===================================================================
--- labs/jbossrules/branches/temporal_rete/drools-jbrms/src/main/java/org/drools/brms/client/decisiontable/Toolbar.java 2008-03-20 18:57:07 UTC (rev 19163)
+++ labs/jbossrules/branches/temporal_rete/drools-jbrms/src/main/java/org/drools/brms/client/decisiontable/Toolbar.java 2008-03-20 19:32:10 UTC (rev 19164)
@@ -1,143 +0,0 @@
-package org.drools.brms.client.decisiontable;
-/*
- * Copyright 2005 JBoss Inc
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-
-
-import com.google.gwt.user.client.ui.ClickListener;
-import com.google.gwt.user.client.ui.Composite;
-import com.google.gwt.user.client.ui.HorizontalPanel;
-import com.google.gwt.user.client.ui.Image;
-import com.google.gwt.user.client.ui.Widget;
-
-/**
- * This shows the widget for moving a row up or down.
- * @author Steven Williams
- */
-public class Toolbar extends Composite {
-
- private HorizontalPanel toolbar = new HorizontalPanel();
- private int row;
-
- public Toolbar() {
- initWidget(toolbar);
- }
- /**
- * Pass in the click listener delegate for when the respective action is clicked and the
- * direction to move the row
- * @param currentRow
- * @param clickListener
- * @param direction
- */
- public Toolbar(final EditableDTGrid grid) {
- toolbar.add(createInsertRow(grid));
- toolbar.add(createDeleteRow(grid));
- toolbar.add(createMoveUp(grid));
- toolbar.add(createMoveDown(grid));
- toolbar.add(createMergeCol(grid));
- toolbar.add(createSplitCol(grid));
- toolbar.add(createMergeRow(grid));
- toolbar.add(createSplitRow(grid));
- toolbar.setStyleName("dt-editor-Toolbar");
-
- initWidget( toolbar );
- }
- private Image createSplitRow(final EditableDTGrid grid) {
- Image split = new Image("images/split_row.gif");
- split.addClickListener(new ClickListener() {
-
- public void onClick(Widget w) {
- grid.splitRow();
- }});
- return split;
- }
- private Image createMergeRow(final EditableDTGrid grid) {
- Image merge = new Image("images/merge_row.gif");
- merge.addClickListener(new ClickListener() {
-
- public void onClick(Widget w) {
- grid.mergeRow();
- }});
- return merge;
- }
- private Image createSplitCol(final EditableDTGrid grid) {
- Image split = new Image("images/split_col.gif");
- split.addClickListener(new ClickListener() {
-
- public void onClick(Widget w) {
- grid.splitCol();
- }});
- return split;
- }
- private Image createMergeCol(final EditableDTGrid grid) {
- Image merge = new Image("images/merge_col.gif");
- merge.addClickListener(new ClickListener() {
-
- public void onClick(Widget w) {
- grid.mergeCol();
- }});
- return merge;
- }
- private Image createMoveDown(final EditableDTGrid grid) {
- Image moveDown = new Image("images/shuffle_down.gif");
- moveDown.addClickListener(new ClickListener() {
-
- public void onClick(Widget w) {
- grid.moveDown();
- }});
- return moveDown;
- }
- private Image createMoveUp(final EditableDTGrid grid) {
- Image moveUp = new Image("images/shuffle_up.gif");
- moveUp.addClickListener(new ClickListener() {
-
- public void onClick(Widget w) {
- grid.moveUp();
- }
- });
- return moveUp;
- }
- private Image createDeleteRow(final EditableDTGrid grid) {
- Image delete = new Image("images/clear_item.gif");
- delete.setTitle( "Delete row" );
- delete.addClickListener(new ClickListener() {
-
- public void onClick(Widget w) {
- grid.deleteRow();
- }
- });
- return delete;
- }
- private Image createInsertRow(final EditableDTGrid grid) {
- Image insert = new Image("images/new_item.gif");
- insert.addClickListener(new ClickListener() {
-
- public void onClick(Widget w) {
- grid.insertRow();
- }
- });
- return insert;
- }
-
- public void setRow(final int row) {
- this.row = row;
- }
-
- public int getRow() {
- return row;
- }
-
-}
\ No newline at end of file
Deleted: labs/jbossrules/branches/temporal_rete/drools-jbrms/src/main/java/org/drools/brms/client/decisiontable/model/Cell.java
===================================================================
--- labs/jbossrules/branches/temporal_rete/drools-jbrms/src/main/java/org/drools/brms/client/decisiontable/model/Cell.java 2008-03-20 18:57:07 UTC (rev 19163)
+++ labs/jbossrules/branches/temporal_rete/drools-jbrms/src/main/java/org/drools/brms/client/decisiontable/model/Cell.java 2008-03-20 19:32:10 UTC (rev 19164)
@@ -1,75 +0,0 @@
-package org.drools.brms.client.decisiontable.model;
-/*
- * Copyright 2005 JBoss Inc
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-
-
-public
-class Cell {
- private int rowspan;
- private int colspan;
- private String value;
- private Row row;
- private Column column;
-
- Cell(Row row, Column col) {
- this(row, col, 1, 1);
- }
- Cell(final Row r, final Column c, final int colspan, final int rowspan) {
- this.row = r;
- this.column = c;
- this.colspan = colspan;
- this.rowspan = rowspan;
- }
- public void setValue(final String value) {
- this.value = value;
- }
- public int getRowIndex() {
- return row.getIndex();
- }
- public int getColumnIndex() {
- return column.getIndex();
- }
- public Row getRow() {
- return row;
- }
- public void setRow(Row row) {
- this.row = row;
- }
- public int getRowspan() {
- return rowspan;
- }
- public void setRowspan(int rowspan) {
- this.rowspan = rowspan;
- }
- public int getColspan() {
- return colspan;
- }
- public Column getColumn() {
- return column;
- }
- public String getValue() {
- return value;
- }
- public String toString() {
- return "Cell[" + getRowIndex() + ", " + getColumnIndex() + ", " + getValue() + "]";
- }
- public void setColspan(int colspan) {
- this.colspan = colspan;
- }
-
-
-}
Deleted: labs/jbossrules/branches/temporal_rete/drools-jbrms/src/main/java/org/drools/brms/client/decisiontable/model/Column.java
===================================================================
--- labs/jbossrules/branches/temporal_rete/drools-jbrms/src/main/java/org/drools/brms/client/decisiontable/model/Column.java 2008-03-20 18:57:07 UTC (rev 19163)
+++ labs/jbossrules/branches/temporal_rete/drools-jbrms/src/main/java/org/drools/brms/client/decisiontable/model/Column.java 2008-03-20 19:32:10 UTC (rev 19164)
@@ -1,40 +0,0 @@
-package org.drools.brms.client.decisiontable.model;
-/*
- * Copyright 2005 JBoss Inc
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-
-
-import java.util.ArrayList;
-import java.util.List;
-
-public class Column {
- private List cells = new ArrayList();
- private DecisionTable parent;
-
- Column(DecisionTable dt) {
- this.parent = dt;
- }
- void addCell(final Cell cell) {
- cells.add(cell);
- }
-
- public int getIndex() {
- return parent.getColumnIndex(this);
- }
- public void removeCell(Cell cell) {
- cells.remove(cell);
- }
-}
Deleted: labs/jbossrules/branches/temporal_rete/drools-jbrms/src/main/java/org/drools/brms/client/decisiontable/model/DecisionTable.java
===================================================================
--- labs/jbossrules/branches/temporal_rete/drools-jbrms/src/main/java/org/drools/brms/client/decisiontable/model/DecisionTable.java 2008-03-20 18:57:07 UTC (rev 19163)
+++ labs/jbossrules/branches/temporal_rete/drools-jbrms/src/main/java/org/drools/brms/client/decisiontable/model/DecisionTable.java 2008-03-20 19:32:10 UTC (rev 19164)
@@ -1,98 +0,0 @@
-package org.drools.brms.client.decisiontable.model;
-/*
- * Copyright 2005 JBoss Inc
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-
-
-import java.util.ArrayList;
-import java.util.List;
-
-public class DecisionTable {
- private Row headerRow = new HeaderRow(this);
- private List rows = new ArrayList();
- private List columns = new ArrayList();
-
- void addRow() {
-
- }
-
- void addColumn(final Column column) {
- columns.add(column);
- }
-
- public Row createRow() {
- Row row = new Row(this);
- rows.add(row);
- return row;
- }
-
- public Column createColumn() {
- Column column = new Column(this);
- columns.add(column);
- return column;
- }
-
- public Cell createCell(Row row, Column column) {
- Cell cell = new Cell(row, column);
- row.addCell(cell);
- column.addCell(cell);
- return cell;
- }
-
- public Row getHeaderRow() {
- return headerRow;
- }
-
- public List getColumns() {
- return columns;
- }
-
- public List getRows() {
- return rows;
- }
- public Row getRow(int index) {
- return (Row) rows.get(index);
- }
-
- public int getRowIndex(Row row) {
- return rows.indexOf(row);
- }
- public int getColumnIndex(Column column) {
- return columns.indexOf(column);
- }
-
- public void mergeCol(Cell currentCell) {
- Row row = currentCell.getRow();
- int currentColspan = currentCell.getColspan();
- int nextCellColumnIndex = currentCell.getColumnIndex() + currentColspan;
- Column nextColumn = (Column) columns.get(nextCellColumnIndex);
- Cell nextCell = row.getCell(nextColumn);
- currentCell.setColspan(currentColspan + nextCell.getColspan());
- row.removeColumn(nextColumn);
- nextColumn.removeCell(nextCell);
- }
-
- public void mergeRow(Cell currentCell) {
- Column column = currentCell.getColumn();
- int currentRowspan = currentCell.getRowspan();
- int nextCellRowIndex = currentCell.getRowIndex() + currentRowspan;
- Row nextRow = (Row) rows.get(nextCellRowIndex);
- Cell nextCell = nextRow.getCell(column);
- currentCell.setRowspan(currentRowspan + nextCell.getRowspan());
- nextRow.removeColumn(column);
- column.removeCell(nextCell);
- }
-}
Deleted: labs/jbossrules/branches/temporal_rete/drools-jbrms/src/main/java/org/drools/brms/client/decisiontable/model/HeaderRow.java
===================================================================
--- labs/jbossrules/branches/temporal_rete/drools-jbrms/src/main/java/org/drools/brms/client/decisiontable/model/HeaderRow.java 2008-03-20 18:57:07 UTC (rev 19163)
+++ labs/jbossrules/branches/temporal_rete/drools-jbrms/src/main/java/org/drools/brms/client/decisiontable/model/HeaderRow.java 2008-03-20 19:32:10 UTC (rev 19164)
@@ -1,32 +0,0 @@
-package org.drools.brms.client.decisiontable.model;
-/*
- * Copyright 2005 JBoss Inc
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-
-
-public class HeaderRow extends Row {
-
- HeaderRow(DecisionTable dt) {
- super(dt);
- }
-
- int getIndex() {
- return -1;
- }
-
-
-
-}
Deleted: labs/jbossrules/branches/temporal_rete/drools-jbrms/src/main/java/org/drools/brms/client/decisiontable/model/Row.java
===================================================================
--- labs/jbossrules/branches/temporal_rete/drools-jbrms/src/main/java/org/drools/brms/client/decisiontable/model/Row.java 2008-03-20 18:57:07 UTC (rev 19163)
+++ labs/jbossrules/branches/temporal_rete/drools-jbrms/src/main/java/org/drools/brms/client/decisiontable/model/Row.java 2008-03-20 19:32:10 UTC (rev 19164)
@@ -1,56 +0,0 @@
-package org.drools.brms.client.decisiontable.model;
-/*
- * Copyright 2005 JBoss Inc
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-
-
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.Map;
-
-public class Row {
- private Map cells = new HashMap();
- private DecisionTable parent;
-
- Row(DecisionTable dt) {
- this.parent = dt;
- }
- void addCell(final Cell cell) {
- cells.put(cell.getColumn(), cell);
- }
- int getIndex() {
- return parent.getRowIndex(this);
- }
- public Cell getCell(Column column) {
- return (Cell) cells.get(column);
- }
- public Cell getCell(int col) {
- Iterator columns = parent.getColumns().iterator();
- int i = 0;
- Column column = null;
- while (i <= col) {
- column = (Column) columns.next();
- Cell cell = (Cell) cells.get(column);
- if (cell != null) {
- i++;
- }
- }
- return getCell(column);
- }
- public void removeColumn(Column nextColumn) {
- cells.remove(nextColumn);
- }
-}
Modified: labs/jbossrules/branches/temporal_rete/drools-jbrms/src/main/java/org/drools/brms/server/ServiceImplementation.java
===================================================================
--- labs/jbossrules/branches/temporal_rete/drools-jbrms/src/main/java/org/drools/brms/server/ServiceImplementation.java 2008-03-20 18:57:07 UTC (rev 19163)
+++ labs/jbossrules/branches/temporal_rete/drools-jbrms/src/main/java/org/drools/brms/server/ServiceImplementation.java 2008-03-20 19:32:10 UTC (rev 19164)
@@ -20,7 +20,7 @@
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
-import java.io.ObjectOutputStream;
+import java.io.ObjectOutput;
import java.text.DateFormat;
import java.util.ArrayList;
import java.util.Calendar;
@@ -80,6 +80,7 @@
import org.drools.common.AbstractRuleBase;
import org.drools.common.DroolsObjectInputStream;
import org.drools.common.InternalWorkingMemory;
+import org.drools.common.DroolsObjectOutputStream;
import org.drools.compiler.DrlParser;
import org.drools.compiler.DroolsParserException;
import org.drools.compiler.PackageBuilderConfiguration;
@@ -895,7 +896,7 @@
} else {
try {
ByteArrayOutputStream bout = new ByteArrayOutputStream();
- ObjectOutputStream out = new ObjectOutputStream(bout);
+ ObjectOutput out = new DroolsObjectOutputStream(bout);
out.writeObject( asm.getBinaryPackage() );
item.updateCompiledPackage( new ByteArrayInputStream( bout.toByteArray()) );
Modified: labs/jbossrules/branches/temporal_rete/drools-jbrms/src/main/java/org/drools/brms/server/security/SecurityServiceImpl.java
===================================================================
--- labs/jbossrules/branches/temporal_rete/drools-jbrms/src/main/java/org/drools/brms/server/security/SecurityServiceImpl.java 2008-03-20 18:57:07 UTC (rev 19163)
+++ labs/jbossrules/branches/temporal_rete/drools-jbrms/src/main/java/org/drools/brms/server/security/SecurityServiceImpl.java 2008-03-20 19:32:10 UTC (rev 19164)
@@ -76,7 +76,8 @@
} else {
HashSet<String> disabled = new HashSet<String>();
//disabled.add("QA");
- return new UserSecurityContext(null, new HashSet());//new UserSecurityContext("SINGLE USER MODE (DEBUG) USE ONLY", disabled);
+ //return new UserSecurityContext(null, new HashSet());
+ return new UserSecurityContext("SINGLE USER MODE (DEBUG) USE ONLY", disabled);
}
}
Modified: labs/jbossrules/branches/temporal_rete/drools-jbrms/src/test/java/org/drools/brms/server/ServiceImplementationTest.java
===================================================================
--- labs/jbossrules/branches/temporal_rete/drools-jbrms/src/test/java/org/drools/brms/server/ServiceImplementationTest.java 2008-03-20 18:57:07 UTC (rev 19163)
+++ labs/jbossrules/branches/temporal_rete/drools-jbrms/src/test/java/org/drools/brms/server/ServiceImplementationTest.java 2008-03-20 19:32:10 UTC (rev 19164)
@@ -43,6 +43,7 @@
import java.io.InputStreamReader;
import java.io.ObjectInputStream;
import java.io.StringReader;
+import java.io.ObjectInput;
import java.util.*;
public class ServiceImplementationTest extends TestCase {
@@ -906,7 +907,7 @@
assertNotNull(binPackage);
ByteArrayInputStream bin = new ByteArrayInputStream(binPackage);
- ObjectInputStream in = new DroolsObjectInputStream(bin);
+ ObjectInput in = new DroolsObjectInputStream(bin);
Package binPkg = (Package) in.readObject();
assertNotNull(binPkg);
@@ -1002,7 +1003,7 @@
assertNotNull(binPackage);
ByteArrayInputStream bin = new ByteArrayInputStream(binPackage);
- ObjectInputStream in = new DroolsObjectInputStream(bin);
+ ObjectInput in = new DroolsObjectInputStream(bin);
Package binPkg = (Package) in.readObject();
assertNotNull(binPkg);
Modified: labs/jbossrules/branches/temporal_rete/src/main/assembly/bin.xml
===================================================================
--- labs/jbossrules/branches/temporal_rete/src/main/assembly/bin.xml 2008-03-20 18:57:07 UTC (rev 19163)
+++ labs/jbossrules/branches/temporal_rete/src/main/assembly/bin.xml 2008-03-20 19:32:10 UTC (rev 19164)
@@ -36,7 +36,7 @@
<include>org.drools:drools-compiler</include>
<include>org.drools:drools-jsr94</include>
<include>org.drools:drools-decisiontables</include>
- <!-- <include>org.drools:drools-analytics</include> -->
+ <include>org.drools:drools-analytics</include>
<include>org.drools:drools-ant</include>
<!--include>org.drools:drools-clips</include-->
<include>org.drools:drools-examples</include>
Modified: labs/jbossrules/branches/temporal_rete/src/main/assembly/src.xml
===================================================================
--- labs/jbossrules/branches/temporal_rete/src/main/assembly/src.xml 2008-03-20 18:57:07 UTC (rev 19163)
+++ labs/jbossrules/branches/temporal_rete/src/main/assembly/src.xml 2008-03-20 19:32:10 UTC (rev 19164)
@@ -15,10 +15,11 @@
<include>drools-compiler/**</include>
<include>drools-decisiontables/**</include>
<include>drools-jsr94/**</include>
- <include>drools-eclipse/**</include>
- <include>drools-repository/**</include>
+ <include>drools-eclipse/**</include>
+ <include>drools-repository/**</include>
<include>drools-jbrms/**</include>
- <include>drools-ant</include>
+ <include>drools-ant/**</include>
+ <include>drools-analytics/**</include>
<include>documentation/**</include>
<include>m2_repo/**</include>
<include>*.xml</include>
@@ -38,4 +39,4 @@
</excludes>
</fileSet>
</fileSets>
-</assembly>
+</assembly>
More information about the jboss-svn-commits
mailing list