[jboss-svn-commits] JBL Code SVN: r18901 - in labs/jbossrules/branches/ming-serialization/drools-core/src: main/java/org/drools/base and 24 other directories.
jboss-svn-commits at lists.jboss.org
jboss-svn-commits at lists.jboss.org
Wed Mar 12 17:20:58 EDT 2008
Author: mingjin
Date: 2008-03-12 17:20:57 -0400 (Wed, 12 Mar 2008)
New Revision: 18901
Modified:
labs/jbossrules/branches/ming-serialization/drools-core/src/main/java/org/drools/EntryPointInterface.java
labs/jbossrules/branches/ming-serialization/drools-core/src/main/java/org/drools/FactHandle.java
labs/jbossrules/branches/ming-serialization/drools-core/src/main/java/org/drools/RuleBase.java
labs/jbossrules/branches/ming-serialization/drools-core/src/main/java/org/drools/RuleBaseConfiguration.java
labs/jbossrules/branches/ming-serialization/drools-core/src/main/java/org/drools/WorkingMemory.java
labs/jbossrules/branches/ming-serialization/drools-core/src/main/java/org/drools/base/BaseClassFieldExtractor.java
labs/jbossrules/branches/ming-serialization/drools-core/src/main/java/org/drools/base/ClassFieldExtractor.java
labs/jbossrules/branches/ming-serialization/drools-core/src/main/java/org/drools/base/CopyIdentifiersGlobalExporter.java
labs/jbossrules/branches/ming-serialization/drools-core/src/main/java/org/drools/base/DefaultConsequenceExceptionHandler.java
labs/jbossrules/branches/ming-serialization/drools-core/src/main/java/org/drools/base/DefaultKnowledgeHelper.java
labs/jbossrules/branches/ming-serialization/drools-core/src/main/java/org/drools/base/MapGlobalResolver.java
labs/jbossrules/branches/ming-serialization/drools-core/src/main/java/org/drools/base/ReferenceOriginalGlobalExporter.java
labs/jbossrules/branches/ming-serialization/drools-core/src/main/java/org/drools/base/accumulators/AccumulateFunction.java
labs/jbossrules/branches/ming-serialization/drools-core/src/main/java/org/drools/base/accumulators/AverageAccumulateFunction.java
labs/jbossrules/branches/ming-serialization/drools-core/src/main/java/org/drools/base/accumulators/CountAccumulateFunction.java
labs/jbossrules/branches/ming-serialization/drools-core/src/main/java/org/drools/base/accumulators/JavaAccumulatorFunctionExecutor.java
labs/jbossrules/branches/ming-serialization/drools-core/src/main/java/org/drools/base/accumulators/MVELAccumulatorFunctionExecutor.java
labs/jbossrules/branches/ming-serialization/drools-core/src/main/java/org/drools/base/accumulators/MaxAccumulateFunction.java
labs/jbossrules/branches/ming-serialization/drools-core/src/main/java/org/drools/base/accumulators/MinAccumulateFunction.java
labs/jbossrules/branches/ming-serialization/drools-core/src/main/java/org/drools/base/accumulators/SumAccumulateFunction.java
labs/jbossrules/branches/ming-serialization/drools-core/src/main/java/org/drools/base/dataproviders/MVELDataProvider.java
labs/jbossrules/branches/ming-serialization/drools-core/src/main/java/org/drools/base/evaluators/AfterEvaluatorDefinition.java
labs/jbossrules/branches/ming-serialization/drools-core/src/main/java/org/drools/base/evaluators/BeforeEvaluatorDefinition.java
labs/jbossrules/branches/ming-serialization/drools-core/src/main/java/org/drools/base/evaluators/CoincidesEvaluatorDefinition.java
labs/jbossrules/branches/ming-serialization/drools-core/src/main/java/org/drools/base/evaluators/ComparableEvaluatorsDefinition.java
labs/jbossrules/branches/ming-serialization/drools-core/src/main/java/org/drools/base/evaluators/DuringEvaluatorDefinition.java
labs/jbossrules/branches/ming-serialization/drools-core/src/main/java/org/drools/base/evaluators/EqualityEvaluatorsDefinition.java
labs/jbossrules/branches/ming-serialization/drools-core/src/main/java/org/drools/base/evaluators/EvaluatorCache.java
labs/jbossrules/branches/ming-serialization/drools-core/src/main/java/org/drools/base/evaluators/EvaluatorDefinition.java
labs/jbossrules/branches/ming-serialization/drools-core/src/main/java/org/drools/base/evaluators/EvaluatorRegistry.java
labs/jbossrules/branches/ming-serialization/drools-core/src/main/java/org/drools/base/evaluators/FinishedByEvaluatorDefinition.java
labs/jbossrules/branches/ming-serialization/drools-core/src/main/java/org/drools/base/evaluators/FinishesEvaluatorDefinition.java
labs/jbossrules/branches/ming-serialization/drools-core/src/main/java/org/drools/base/evaluators/IncludesEvaluatorDefinition.java
labs/jbossrules/branches/ming-serialization/drools-core/src/main/java/org/drools/base/evaluators/MatchesEvaluatorsDefinition.java
labs/jbossrules/branches/ming-serialization/drools-core/src/main/java/org/drools/base/evaluators/MeetsEvaluatorDefinition.java
labs/jbossrules/branches/ming-serialization/drools-core/src/main/java/org/drools/base/evaluators/MetByEvaluatorDefinition.java
labs/jbossrules/branches/ming-serialization/drools-core/src/main/java/org/drools/base/evaluators/OverlappedByEvaluatorDefinition.java
labs/jbossrules/branches/ming-serialization/drools-core/src/main/java/org/drools/base/evaluators/OverlapsEvaluatorDefinition.java
labs/jbossrules/branches/ming-serialization/drools-core/src/main/java/org/drools/base/evaluators/SetEvaluatorsDefinition.java
labs/jbossrules/branches/ming-serialization/drools-core/src/main/java/org/drools/base/evaluators/SoundslikeEvaluatorsDefinition.java
labs/jbossrules/branches/ming-serialization/drools-core/src/main/java/org/drools/base/evaluators/StartedByEvaluatorDefinition.java
labs/jbossrules/branches/ming-serialization/drools-core/src/main/java/org/drools/base/evaluators/StartsEvaluatorDefinition.java
labs/jbossrules/branches/ming-serialization/drools-core/src/main/java/org/drools/base/extractors/ArrayExtractor.java
labs/jbossrules/branches/ming-serialization/drools-core/src/main/java/org/drools/base/extractors/BaseObjectClassFieldExtractor.java
labs/jbossrules/branches/ming-serialization/drools-core/src/main/java/org/drools/base/extractors/MVELClassFieldExtractor.java
labs/jbossrules/branches/ming-serialization/drools-core/src/main/java/org/drools/base/field/BooleanFieldImpl.java
labs/jbossrules/branches/ming-serialization/drools-core/src/main/java/org/drools/base/field/DoubleFieldImpl.java
labs/jbossrules/branches/ming-serialization/drools-core/src/main/java/org/drools/base/field/LongFieldImpl.java
labs/jbossrules/branches/ming-serialization/drools-core/src/main/java/org/drools/base/mvel/DroolsMVELFactory.java
labs/jbossrules/branches/ming-serialization/drools-core/src/main/java/org/drools/base/mvel/MVELAccumulator.java
labs/jbossrules/branches/ming-serialization/drools-core/src/main/java/org/drools/base/mvel/MVELConsequence.java
labs/jbossrules/branches/ming-serialization/drools-core/src/main/java/org/drools/base/mvel/MVELEvalExpression.java
labs/jbossrules/branches/ming-serialization/drools-core/src/main/java/org/drools/base/mvel/MVELPredicateExpression.java
labs/jbossrules/branches/ming-serialization/drools-core/src/main/java/org/drools/base/mvel/MVELSalienceExpression.java
labs/jbossrules/branches/ming-serialization/drools-core/src/main/java/org/drools/common/AbstractFactHandleFactory.java
labs/jbossrules/branches/ming-serialization/drools-core/src/main/java/org/drools/common/AbstractRuleBase.java
labs/jbossrules/branches/ming-serialization/drools-core/src/main/java/org/drools/common/AbstractWorkingMemory.java
labs/jbossrules/branches/ming-serialization/drools-core/src/main/java/org/drools/common/AgendaItem.java
labs/jbossrules/branches/ming-serialization/drools-core/src/main/java/org/drools/common/ArrayAgendaGroup.java
labs/jbossrules/branches/ming-serialization/drools-core/src/main/java/org/drools/common/BaseNode.java
labs/jbossrules/branches/ming-serialization/drools-core/src/main/java/org/drools/common/BetaConstraints.java
labs/jbossrules/branches/ming-serialization/drools-core/src/main/java/org/drools/common/BinaryHeapQueueAgendaGroup.java
labs/jbossrules/branches/ming-serialization/drools-core/src/main/java/org/drools/common/ConcurrentNodeMemories.java
labs/jbossrules/branches/ming-serialization/drools-core/src/main/java/org/drools/common/DefaultAgenda.java
labs/jbossrules/branches/ming-serialization/drools-core/src/main/java/org/drools/common/DefaultBetaConstraints.java
labs/jbossrules/branches/ming-serialization/drools-core/src/main/java/org/drools/common/DefaultFactHandle.java
labs/jbossrules/branches/ming-serialization/drools-core/src/main/java/org/drools/common/DoubleBetaConstraints.java
labs/jbossrules/branches/ming-serialization/drools-core/src/main/java/org/drools/common/DroolsObjectInputStream.java
labs/jbossrules/branches/ming-serialization/drools-core/src/main/java/org/drools/common/DroolsObjectOutputStream.java
labs/jbossrules/branches/ming-serialization/drools-core/src/main/java/org/drools/common/DroolsObjectStreamConstants.java
labs/jbossrules/branches/ming-serialization/drools-core/src/main/java/org/drools/common/EmptyBetaConstraints.java
labs/jbossrules/branches/ming-serialization/drools-core/src/main/java/org/drools/common/EqualityAssertMapComparator.java
labs/jbossrules/branches/ming-serialization/drools-core/src/main/java/org/drools/common/EqualityKey.java
labs/jbossrules/branches/ming-serialization/drools-core/src/main/java/org/drools/common/EqualityKeyComparator.java
labs/jbossrules/branches/ming-serialization/drools-core/src/main/java/org/drools/common/EventFactHandle.java
labs/jbossrules/branches/ming-serialization/drools-core/src/main/java/org/drools/common/IdentityAssertMapComparator.java
labs/jbossrules/branches/ming-serialization/drools-core/src/main/java/org/drools/common/InstanceEqualsConstraint.java
labs/jbossrules/branches/ming-serialization/drools-core/src/main/java/org/drools/common/InstanceNotEqualsConstraint.java
labs/jbossrules/branches/ming-serialization/drools-core/src/main/java/org/drools/common/InternalWorkingMemoryActions.java
labs/jbossrules/branches/ming-serialization/drools-core/src/main/java/org/drools/common/NetworkNode.java
labs/jbossrules/branches/ming-serialization/drools-core/src/main/java/org/drools/common/NodeMemories.java
labs/jbossrules/branches/ming-serialization/drools-core/src/main/java/org/drools/common/PriorityQueueAgendaGroupFactory.java
labs/jbossrules/branches/ming-serialization/drools-core/src/main/java/org/drools/common/PropagationContextImpl.java
labs/jbossrules/branches/ming-serialization/drools-core/src/main/java/org/drools/common/QuadroupleBetaConstraints.java
labs/jbossrules/branches/ming-serialization/drools-core/src/main/java/org/drools/common/RuleFlowGroupImpl.java
labs/jbossrules/branches/ming-serialization/drools-core/src/main/java/org/drools/common/ScheduledAgendaItem.java
labs/jbossrules/branches/ming-serialization/drools-core/src/main/java/org/drools/common/SequentialAgendaGroupImpl.java
labs/jbossrules/branches/ming-serialization/drools-core/src/main/java/org/drools/common/SingleBetaConstraints.java
labs/jbossrules/branches/ming-serialization/drools-core/src/main/java/org/drools/common/SingleThreadedObjectStore.java
labs/jbossrules/branches/ming-serialization/drools-core/src/main/java/org/drools/common/TripleBetaConstraints.java
labs/jbossrules/branches/ming-serialization/drools-core/src/main/java/org/drools/common/TruthMaintenanceSystem.java
labs/jbossrules/branches/ming-serialization/drools-core/src/main/java/org/drools/common/TupleStartEqualsConstraint.java
labs/jbossrules/branches/ming-serialization/drools-core/src/main/java/org/drools/common/WorkingMemoryAction.java
labs/jbossrules/branches/ming-serialization/drools-core/src/main/java/org/drools/conflict/DepthConflictResolver.java
labs/jbossrules/branches/ming-serialization/drools-core/src/main/java/org/drools/event/AgendaEventSupport.java
labs/jbossrules/branches/ming-serialization/drools-core/src/main/java/org/drools/event/RuleBaseEventSupport.java
labs/jbossrules/branches/ming-serialization/drools-core/src/main/java/org/drools/event/RuleFlowEventSupport.java
labs/jbossrules/branches/ming-serialization/drools-core/src/main/java/org/drools/event/WorkingMemoryEventSupport.java
labs/jbossrules/branches/ming-serialization/drools-core/src/main/java/org/drools/facttemplates/FactTemplate.java
labs/jbossrules/branches/ming-serialization/drools-core/src/main/java/org/drools/facttemplates/FactTemplateFieldExtractor.java
labs/jbossrules/branches/ming-serialization/drools-core/src/main/java/org/drools/facttemplates/FactTemplateImpl.java
labs/jbossrules/branches/ming-serialization/drools-core/src/main/java/org/drools/facttemplates/FactTemplateObjectType.java
labs/jbossrules/branches/ming-serialization/drools-core/src/main/java/org/drools/facttemplates/FieldTemplateImpl.java
labs/jbossrules/branches/ming-serialization/drools-core/src/main/java/org/drools/process/instance/WorkItemManager.java
labs/jbossrules/branches/ming-serialization/drools-core/src/main/java/org/drools/reteoo/AccumulateNode.java
labs/jbossrules/branches/ming-serialization/drools-core/src/main/java/org/drools/reteoo/AlphaNode.java
labs/jbossrules/branches/ming-serialization/drools-core/src/main/java/org/drools/reteoo/BetaMemory.java
labs/jbossrules/branches/ming-serialization/drools-core/src/main/java/org/drools/reteoo/BetaNode.java
labs/jbossrules/branches/ming-serialization/drools-core/src/main/java/org/drools/reteoo/ClassObjectTypeConf.java
labs/jbossrules/branches/ming-serialization/drools-core/src/main/java/org/drools/reteoo/CollectNode.java
labs/jbossrules/branches/ming-serialization/drools-core/src/main/java/org/drools/reteoo/CompositeObjectSinkAdapter.java
labs/jbossrules/branches/ming-serialization/drools-core/src/main/java/org/drools/reteoo/CompositeTupleSinkAdapter.java
labs/jbossrules/branches/ming-serialization/drools-core/src/main/java/org/drools/reteoo/EmptyObjectSinkAdapter.java
labs/jbossrules/branches/ming-serialization/drools-core/src/main/java/org/drools/reteoo/EmptyTupleSinkAdapter.java
labs/jbossrules/branches/ming-serialization/drools-core/src/main/java/org/drools/reteoo/EntryPointNode.java
labs/jbossrules/branches/ming-serialization/drools-core/src/main/java/org/drools/reteoo/EvalConditionNode.java
labs/jbossrules/branches/ming-serialization/drools-core/src/main/java/org/drools/reteoo/ExistsNode.java
labs/jbossrules/branches/ming-serialization/drools-core/src/main/java/org/drools/reteoo/FactTemplateTypeConf.java
labs/jbossrules/branches/ming-serialization/drools-core/src/main/java/org/drools/reteoo/FromNode.java
labs/jbossrules/branches/ming-serialization/drools-core/src/main/java/org/drools/reteoo/InitialFactHandle.java
labs/jbossrules/branches/ming-serialization/drools-core/src/main/java/org/drools/reteoo/InitialFactImpl.java
labs/jbossrules/branches/ming-serialization/drools-core/src/main/java/org/drools/reteoo/JoinNode.java
labs/jbossrules/branches/ming-serialization/drools-core/src/main/java/org/drools/reteoo/LIANodePropagation.java
labs/jbossrules/branches/ming-serialization/drools-core/src/main/java/org/drools/reteoo/LeftInputAdapterNode.java
labs/jbossrules/branches/ming-serialization/drools-core/src/main/java/org/drools/reteoo/MemoryVisitor.java
labs/jbossrules/branches/ming-serialization/drools-core/src/main/java/org/drools/reteoo/NotNode.java
labs/jbossrules/branches/ming-serialization/drools-core/src/main/java/org/drools/reteoo/ObjectSinkNodeList.java
labs/jbossrules/branches/ming-serialization/drools-core/src/main/java/org/drools/reteoo/ObjectSinkPropagator.java
labs/jbossrules/branches/ming-serialization/drools-core/src/main/java/org/drools/reteoo/ObjectSource.java
labs/jbossrules/branches/ming-serialization/drools-core/src/main/java/org/drools/reteoo/ObjectTypeNode.java
labs/jbossrules/branches/ming-serialization/drools-core/src/main/java/org/drools/reteoo/PropagationQueuingNode.java
labs/jbossrules/branches/ming-serialization/drools-core/src/main/java/org/drools/reteoo/QueryTerminalNode.java
labs/jbossrules/branches/ming-serialization/drools-core/src/main/java/org/drools/reteoo/Rete.java
labs/jbossrules/branches/ming-serialization/drools-core/src/main/java/org/drools/reteoo/ReteStatelessSessionResult.java
labs/jbossrules/branches/ming-serialization/drools-core/src/main/java/org/drools/reteoo/ReteTuple.java
labs/jbossrules/branches/ming-serialization/drools-core/src/main/java/org/drools/reteoo/ReteooBuilder.java
labs/jbossrules/branches/ming-serialization/drools-core/src/main/java/org/drools/reteoo/ReteooFactHandleFactory.java
labs/jbossrules/branches/ming-serialization/drools-core/src/main/java/org/drools/reteoo/ReteooRuleBase.java
labs/jbossrules/branches/ming-serialization/drools-core/src/main/java/org/drools/reteoo/ReteooStatefulSession.java
labs/jbossrules/branches/ming-serialization/drools-core/src/main/java/org/drools/reteoo/ReteooStatelessSession.java
labs/jbossrules/branches/ming-serialization/drools-core/src/main/java/org/drools/reteoo/ReteooTemporalSession.java
labs/jbossrules/branches/ming-serialization/drools-core/src/main/java/org/drools/reteoo/ReteooWorkingMemory.java
labs/jbossrules/branches/ming-serialization/drools-core/src/main/java/org/drools/reteoo/RightInputAdapterNode.java
labs/jbossrules/branches/ming-serialization/drools-core/src/main/java/org/drools/reteoo/RuleRemovalContext.java
labs/jbossrules/branches/ming-serialization/drools-core/src/main/java/org/drools/reteoo/RuleTerminalNode.java
labs/jbossrules/branches/ming-serialization/drools-core/src/main/java/org/drools/reteoo/SingleObjectSinkAdapter.java
labs/jbossrules/branches/ming-serialization/drools-core/src/main/java/org/drools/reteoo/SingleTupleSinkAdapter.java
labs/jbossrules/branches/ming-serialization/drools-core/src/main/java/org/drools/reteoo/TupleSink.java
labs/jbossrules/branches/ming-serialization/drools-core/src/main/java/org/drools/reteoo/TupleSinkNodeList.java
labs/jbossrules/branches/ming-serialization/drools-core/src/main/java/org/drools/reteoo/TupleSinkPropagator.java
labs/jbossrules/branches/ming-serialization/drools-core/src/main/java/org/drools/reteoo/TupleSource.java
labs/jbossrules/branches/ming-serialization/drools-core/src/main/java/org/drools/rule/AbstractCompositeConstraint.java
labs/jbossrules/branches/ming-serialization/drools-core/src/main/java/org/drools/rule/AbstractCompositeRestriction.java
labs/jbossrules/branches/ming-serialization/drools-core/src/main/java/org/drools/rule/Accumulate.java
labs/jbossrules/branches/ming-serialization/drools-core/src/main/java/org/drools/rule/AndCompositeRestriction.java
labs/jbossrules/branches/ming-serialization/drools-core/src/main/java/org/drools/rule/Collect.java
labs/jbossrules/branches/ming-serialization/drools-core/src/main/java/org/drools/rule/ContextEntry.java
labs/jbossrules/branches/ming-serialization/drools-core/src/main/java/org/drools/rule/DialectDatas.java
labs/jbossrules/branches/ming-serialization/drools-core/src/main/java/org/drools/rule/EntryPoint.java
labs/jbossrules/branches/ming-serialization/drools-core/src/main/java/org/drools/rule/EvalCondition.java
labs/jbossrules/branches/ming-serialization/drools-core/src/main/java/org/drools/rule/Forall.java
labs/jbossrules/branches/ming-serialization/drools-core/src/main/java/org/drools/rule/From.java
labs/jbossrules/branches/ming-serialization/drools-core/src/main/java/org/drools/rule/JavaDialectData.java
labs/jbossrules/branches/ming-serialization/drools-core/src/main/java/org/drools/rule/LiteralRestriction.java
labs/jbossrules/branches/ming-serialization/drools-core/src/main/java/org/drools/rule/MultiRestrictionFieldConstraint.java
labs/jbossrules/branches/ming-serialization/drools-core/src/main/java/org/drools/rule/OrCompositeRestriction.java
labs/jbossrules/branches/ming-serialization/drools-core/src/main/java/org/drools/rule/Package.java
labs/jbossrules/branches/ming-serialization/drools-core/src/main/java/org/drools/rule/PredicateConstraint.java
labs/jbossrules/branches/ming-serialization/drools-core/src/main/java/org/drools/rule/Query.java
labs/jbossrules/branches/ming-serialization/drools-core/src/main/java/org/drools/rule/ReturnValueRestriction.java
labs/jbossrules/branches/ming-serialization/drools-core/src/main/java/org/drools/rule/TimeMachine.java
labs/jbossrules/branches/ming-serialization/drools-core/src/main/java/org/drools/rule/VariableRestriction.java
labs/jbossrules/branches/ming-serialization/drools-core/src/main/java/org/drools/ruleflow/instance/RuleFlowProcessInstanceFactory.java
labs/jbossrules/branches/ming-serialization/drools-core/src/main/java/org/drools/spi/AgendaGroup.java
labs/jbossrules/branches/ming-serialization/drools-core/src/main/java/org/drools/spi/ConsequenceExceptionHandler.java
labs/jbossrules/branches/ming-serialization/drools-core/src/main/java/org/drools/spi/Extractor.java
labs/jbossrules/branches/ming-serialization/drools-core/src/main/java/org/drools/spi/GlobalExporter.java
labs/jbossrules/branches/ming-serialization/drools-core/src/main/java/org/drools/spi/GlobalExtractor.java
labs/jbossrules/branches/ming-serialization/drools-core/src/main/java/org/drools/spi/GlobalResolver.java
labs/jbossrules/branches/ming-serialization/drools-core/src/main/java/org/drools/spi/PredicateExpression.java
labs/jbossrules/branches/ming-serialization/drools-core/src/main/java/org/drools/spi/PropagationContext.java
labs/jbossrules/branches/ming-serialization/drools-core/src/main/java/org/drools/spi/Restriction.java
labs/jbossrules/branches/ming-serialization/drools-core/src/main/java/org/drools/spi/RuleComponent.java
labs/jbossrules/branches/ming-serialization/drools-core/src/main/java/org/drools/spi/RuleFlowGroup.java
labs/jbossrules/branches/ming-serialization/drools-core/src/main/java/org/drools/util/AbstractBaseLinkedListNode.java
labs/jbossrules/branches/ming-serialization/drools-core/src/main/java/org/drools/util/AbstractHashTable.java
labs/jbossrules/branches/ming-serialization/drools-core/src/main/java/org/drools/util/BinaryHeapQueue.java
labs/jbossrules/branches/ming-serialization/drools-core/src/main/java/org/drools/util/ChainedProperties.java
labs/jbossrules/branches/ming-serialization/drools-core/src/main/java/org/drools/util/Entry.java
labs/jbossrules/branches/ming-serialization/drools-core/src/main/java/org/drools/util/FactHandleIndexHashTable.java
labs/jbossrules/branches/ming-serialization/drools-core/src/main/java/org/drools/util/LinkedList.java
labs/jbossrules/branches/ming-serialization/drools-core/src/main/java/org/drools/util/LinkedListEntry.java
labs/jbossrules/branches/ming-serialization/drools-core/src/main/java/org/drools/util/LinkedListNode.java
labs/jbossrules/branches/ming-serialization/drools-core/src/main/java/org/drools/util/ObjectHashMap.java
labs/jbossrules/branches/ming-serialization/drools-core/src/main/java/org/drools/util/ObjectHashSet.java
labs/jbossrules/branches/ming-serialization/drools-core/src/main/java/org/drools/util/PrimitiveLongMap.java
labs/jbossrules/branches/ming-serialization/drools-core/src/main/java/org/drools/util/PrimitiveLongStack.java
labs/jbossrules/branches/ming-serialization/drools-core/src/main/java/org/drools/util/TupleIndexHashTable.java
labs/jbossrules/branches/ming-serialization/drools-core/src/test/java/org/drools/TestWorkingMemoryEventListener.java
labs/jbossrules/branches/ming-serialization/drools-core/src/test/java/org/drools/base/EvaluatorFactoryTest.java
labs/jbossrules/branches/ming-serialization/drools-core/src/test/java/org/drools/base/TemporalEvaluatorFactoryTest.java
labs/jbossrules/branches/ming-serialization/drools-core/src/test/java/org/drools/event/AgendaEventSupportTest.java
labs/jbossrules/branches/ming-serialization/drools-core/src/test/java/org/drools/event/RuleBaseEventListenerTest.java
labs/jbossrules/branches/ming-serialization/drools-core/src/test/java/org/drools/examples/manners/BaseMannersTest.java
labs/jbossrules/branches/ming-serialization/drools-core/src/test/java/org/drools/examples/manners/Chosen.java
labs/jbossrules/branches/ming-serialization/drools-core/src/test/java/org/drools/examples/manners/Context.java
labs/jbossrules/branches/ming-serialization/drools-core/src/test/java/org/drools/examples/manners/Guest.java
labs/jbossrules/branches/ming-serialization/drools-core/src/test/java/org/drools/examples/manners/LastSeat.java
labs/jbossrules/branches/ming-serialization/drools-core/src/test/java/org/drools/examples/manners/Seating.java
labs/jbossrules/branches/ming-serialization/drools-core/src/test/java/org/drools/reteoo/AgendaTest.java
labs/jbossrules/branches/ming-serialization/drools-core/src/test/java/org/drools/reteoo/BaseNodeTest.java
labs/jbossrules/branches/ming-serialization/drools-core/src/test/java/org/drools/reteoo/CompositeObjectSinkAdapterTest.java
labs/jbossrules/branches/ming-serialization/drools-core/src/test/java/org/drools/reteoo/CrossProductTest.java
labs/jbossrules/branches/ming-serialization/drools-core/src/test/java/org/drools/reteoo/LogicalAssertionTest.java
labs/jbossrules/branches/ming-serialization/drools-core/src/test/java/org/drools/reteoo/MockAccumulator.java
labs/jbossrules/branches/ming-serialization/drools-core/src/test/java/org/drools/reteoo/MockEvalCondition.java
labs/jbossrules/branches/ming-serialization/drools-core/src/test/java/org/drools/reteoo/OtherwiseTest.java
labs/jbossrules/branches/ming-serialization/drools-core/src/test/java/org/drools/reteoo/ReteooBuilderTest.java
labs/jbossrules/branches/ming-serialization/drools-core/src/test/java/org/drools/reteoo/RuleFlowGroupTest.java
labs/jbossrules/branches/ming-serialization/drools-core/src/test/java/org/drools/reteoo/SchedulerTest.java
labs/jbossrules/branches/ming-serialization/drools-core/src/test/java/org/drools/reteoo/builder/ReteooRuleBuilderTest.java
labs/jbossrules/branches/ming-serialization/drools-core/src/test/java/org/drools/rule/FieldConstraintTest.java
labs/jbossrules/branches/ming-serialization/drools-core/src/test/java/org/drools/rule/PackageCompilationDataTest.java
labs/jbossrules/branches/ming-serialization/drools-core/src/test/java/org/drools/spi/MockConstraint.java
Log:
serialization on rulebase is mostly working: except AccumulateTest and FirstOrderLogicTest
Modified: labs/jbossrules/branches/ming-serialization/drools-core/src/main/java/org/drools/EntryPointInterface.java
===================================================================
--- labs/jbossrules/branches/ming-serialization/drools-core/src/main/java/org/drools/EntryPointInterface.java 2008-03-12 20:58:14 UTC (rev 18900)
+++ labs/jbossrules/branches/ming-serialization/drools-core/src/main/java/org/drools/EntryPointInterface.java 2008-03-12 21:20:57 UTC (rev 18901)
@@ -17,7 +17,6 @@
*/
package org.drools;
-import java.io.Serializable;
import java.io.Externalizable;
/**
@@ -28,7 +27,7 @@
*/
public interface EntryPointInterface
extends
- Serializable {
+ Externalizable {
/**
* Assert a fact.
Modified: labs/jbossrules/branches/ming-serialization/drools-core/src/main/java/org/drools/FactHandle.java
===================================================================
--- labs/jbossrules/branches/ming-serialization/drools-core/src/main/java/org/drools/FactHandle.java 2008-03-12 20:58:14 UTC (rev 18900)
+++ labs/jbossrules/branches/ming-serialization/drools-core/src/main/java/org/drools/FactHandle.java 2008-03-12 21:20:57 UTC (rev 18901)
@@ -25,10 +25,11 @@
*/
import java.io.Serializable;
+import java.io.Externalizable;
public interface FactHandle
extends
- Serializable {
+ Externalizable {
/**
* Convert this handle to an external representation.
Modified: labs/jbossrules/branches/ming-serialization/drools-core/src/main/java/org/drools/RuleBase.java
===================================================================
--- labs/jbossrules/branches/ming-serialization/drools-core/src/main/java/org/drools/RuleBase.java 2008-03-12 20:58:14 UTC (rev 18900)
+++ labs/jbossrules/branches/ming-serialization/drools-core/src/main/java/org/drools/RuleBase.java 2008-03-12 21:20:57 UTC (rev 18901)
@@ -36,7 +36,7 @@
*/
public interface RuleBase
extends
- Serializable,
+ Externalizable,
RuleBaseEventManager {
public static final int RETEOO = 1;
Modified: labs/jbossrules/branches/ming-serialization/drools-core/src/main/java/org/drools/RuleBaseConfiguration.java
===================================================================
--- labs/jbossrules/branches/ming-serialization/drools-core/src/main/java/org/drools/RuleBaseConfiguration.java 2008-03-12 20:58:14 UTC (rev 18900)
+++ labs/jbossrules/branches/ming-serialization/drools-core/src/main/java/org/drools/RuleBaseConfiguration.java 2008-03-12 21:20:57 UTC (rev 18901)
@@ -740,7 +740,7 @@
public static class AssertBehaviour
implements
- Serializable {
+ Externalizable {
private static final long serialVersionUID = 400L;
public static final AssertBehaviour IDENTITY = new AssertBehaviour( 0 );
@@ -748,10 +748,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;
@@ -780,7 +803,7 @@
public static class LogicalOverride
implements
- Serializable {
+ Externalizable {
private static final long serialVersionUID = 400L;
public static final LogicalOverride PRESERVE = new LogicalOverride( 0 );
@@ -788,6 +811,18 @@
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;
}
@@ -813,6 +848,16 @@
}
}
+ 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");
}
@@ -820,7 +865,7 @@
public static class SequentialAgenda
implements
- Serializable {
+ Externalizable {
private static final long serialVersionUID = 400L;
public static final SequentialAgenda SEQUENTIAL = new SequentialAgenda( 0 );
@@ -828,6 +873,18 @@
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/ming-serialization/drools-core/src/main/java/org/drools/WorkingMemory.java
===================================================================
--- labs/jbossrules/branches/ming-serialization/drools-core/src/main/java/org/drools/WorkingMemory.java 2008-03-12 20:58:14 UTC (rev 18900)
+++ labs/jbossrules/branches/ming-serialization/drools-core/src/main/java/org/drools/WorkingMemory.java 2008-03-12 21:20:57 UTC (rev 18901)
@@ -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,7 @@
import java.util.Collection;
import java.util.Iterator;
import java.util.Map;
+import java.io.Externalizable;
import org.drools.process.instance.ProcessInstance;
import org.drools.process.instance.WorkItemManager;
@@ -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 {
+public interface WorkingMemory extends WorkingMemoryEventManager, 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,33 +201,33 @@
/**
* Set the focus to the specified AgendaGroup
* @param focus
- */
+ */
void setFocus(AgendaGroup focus);
-
+
/**
* Assert a fact.
- *
+ *
* @param object
* The fact object.
- *
+ *
* @return The new fact-handle associated with the object.
- *
+ *
* @throws FactException
* If a RuntimeException error occurs.
*/
FactHandle insert(Object object) throws FactException;
-
+
/**
* Assert a fact with inherent duration.
- *
+ *
* @param object
* The fact object.
* @param duration
* The duration of the fact.
- *
+ *
* @return The new fact-handle associated with the object.
- *
+ *
* @throws FactException
* If a RuntimeException error occurs.
*/
@@ -240,54 +241,54 @@
*
* @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);
/**
* Insert a fact registering JavaBean <code>PropertyChangeListeners</code>
* on the Object to automatically trigger <code>update</code> calls
* if <code>dynamic</code> is <code>true</code>.
- *
+ *
* @param object
* The fact object.
* @param dynamic
* true if Drools should add JavaBean
* <code>PropertyChangeListeners</code> to the object.
- *
+ *
* @return The new fact-handle associated with the object.
- *
+ *
* @throws FactException
* If a RuntimeException error occurs.
*/
FactHandle insert(Object object,
boolean dynamic) throws FactException;
-
+
/**
- * Insert a fact with inherent duration registering JavaBean
- * <code>PropertyChangeListeners</code> on the Object to
+ * Insert a fact with inherent duration registering JavaBean
+ * <code>PropertyChangeListeners</code> on the Object to
* automatically trigger <code>update</code> calls
* if <code>dynamic</code> is <code>true</code>.
- *
+ *
* @param object
* The fact object.
* @param duration
@@ -295,9 +296,9 @@
* @param dynamic
* true if Drools should add JavaBean
* <code>PropertyChangeListeners</code> to the object.
- *
+ *
* @return The new fact-handle associated with the object.
- *
+ *
* @throws FactException
* If a RuntimeException error occurs.
*/
@@ -307,10 +308,10 @@
/**
* Retract a fact.
- *
+ *
* @param handle
* The fact-handle associated with the fact to retract.
- *
+ *
* @throws FactException
* If a RuntimeException error occurs.
*/
@@ -319,36 +320,36 @@
/**
* Inform the WorkingMemory that a Fact has been modified and that it
* should now update the network.
- *
+ *
* @param handle
* The fact-handle associated with the fact to modify.
* @param object
* The new value of the fact.
- *
+ *
* @throws FactException
* If a RuntimeException error occurs.
*/
void update(FactHandle handle,
Object object) throws FactException;
-
+
/**
- *
+ *
* @param factHandle
*/
public void modifyRetract(final FactHandle factHandle);
-
+
/**
- *
+ *
* @param factHandle
* @param object
*/
public void modifyInsert(final FactHandle factHandle,
- final Object object);
+ final Object object);
/**
* Sets the AsyncExceptionHandler to handle exceptions thrown by the Agenda
* Scheduler used for duration rules.
- *
+ *
* @param handler
*/
void setAsyncExceptionHandler(AsyncExceptionHandler handler);
@@ -368,20 +369,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);
@@ -391,28 +392,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 EntryPointInterface getEntryPoint( String id );
-
+
}
\ No newline at end of file
Modified: labs/jbossrules/branches/ming-serialization/drools-core/src/main/java/org/drools/base/BaseClassFieldExtractor.java
===================================================================
--- labs/jbossrules/branches/ming-serialization/drools-core/src/main/java/org/drools/base/BaseClassFieldExtractor.java 2008-03-12 20:58:14 UTC (rev 18900)
+++ labs/jbossrules/branches/ming-serialization/drools-core/src/main/java/org/drools/base/BaseClassFieldExtractor.java 2008-03-12 21:20:57 UTC (rev 18901)
@@ -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,18 @@
}
}
+ public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
+ index = in.readInt();
+ fieldType = (Class)in.readObject();
+ valueType = (ValueType)in.readObject();
+ }
+
+ public void writeExternal(ObjectOutput out) throws IOException {
+ out.writeInt(index);
+ out.writeObject(fieldType);
+ out.writeObject(valueType);
+ }
+
public int getIndex() {
return this.index;
}
@@ -82,11 +102,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/ming-serialization/drools-core/src/main/java/org/drools/base/ClassFieldExtractor.java
===================================================================
--- labs/jbossrules/branches/ming-serialization/drools-core/src/main/java/org/drools/base/ClassFieldExtractor.java 2008-03-12 20:58:14 UTC (rev 18900)
+++ labs/jbossrules/branches/ming-serialization/drools-core/src/main/java/org/drools/base/ClassFieldExtractor.java 2008-03-12 21:20:57 UTC (rev 18901)
@@ -42,7 +42,7 @@
*/
public class ClassFieldExtractor
implements
- FieldExtractor, Externalizable {
+ FieldExtractor {
/**
*
*/
Modified: labs/jbossrules/branches/ming-serialization/drools-core/src/main/java/org/drools/base/CopyIdentifiersGlobalExporter.java
===================================================================
--- labs/jbossrules/branches/ming-serialization/drools-core/src/main/java/org/drools/base/CopyIdentifiersGlobalExporter.java 2008-03-12 20:58:14 UTC (rev 18900)
+++ labs/jbossrules/branches/ming-serialization/drools-core/src/main/java/org/drools/base/CopyIdentifiersGlobalExporter.java 2008-03-12 21:20:57 UTC (rev 18901)
@@ -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/ming-serialization/drools-core/src/main/java/org/drools/base/DefaultConsequenceExceptionHandler.java
===================================================================
--- labs/jbossrules/branches/ming-serialization/drools-core/src/main/java/org/drools/base/DefaultConsequenceExceptionHandler.java 2008-03-12 20:58:14 UTC (rev 18900)
+++ labs/jbossrules/branches/ming-serialization/drools-core/src/main/java/org/drools/base/DefaultConsequenceExceptionHandler.java 2008-03-12 21:20:57 UTC (rev 18901)
@@ -5,8 +5,19 @@
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) {
Modified: labs/jbossrules/branches/ming-serialization/drools-core/src/main/java/org/drools/base/DefaultKnowledgeHelper.java
===================================================================
--- labs/jbossrules/branches/ming-serialization/drools-core/src/main/java/org/drools/base/DefaultKnowledgeHelper.java 2008-03-12 20:58:14 UTC (rev 18900)
+++ labs/jbossrules/branches/ming-serialization/drools-core/src/main/java/org/drools/base/DefaultKnowledgeHelper.java 2008-03-12 21:20:57 UTC (rev 18901)
@@ -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;
@@ -59,70 +83,70 @@
public void insert(final Object object) throws FactException {
insert( object,
- 0,
+ 0,
false );
}
- public void insert(final Object object,
- final long duration) throws FactException {
+ public void insert(final Object object,
+ final long duration) throws FactException {
insert( object,
- duration,
+ duration,
false );
}
-
+
public void insert(final Object object,
final boolean dynamic) throws FactException {
this.workingMemory.insert( object,
- 0,
+ 0,
dynamic,
false,
this.rule,
this.activation );
}
-
+
public void insert(final Object object,
- final long duration,
- final boolean dynamic) throws FactException {
- this.workingMemory.insert( object,
- duration,
- dynamic,
- false,
- this.rule,
- this.activation );
- }
+ final long duration,
+ final boolean dynamic) throws FactException {
+ this.workingMemory.insert( object,
+ duration,
+ dynamic,
+ false,
+ this.rule,
+ this.activation );
+ }
public void insertLogical(final Object object) throws FactException {
insertLogical( object,
- 0,
+ 0,
false );
}
public void insertLogical(final Object object, final long duration) throws FactException {
insertLogical( object,
- duration,
+ duration,
false );
}
-
+
public void insertLogical(final Object object,
final boolean dynamic) throws FactException {
this.workingMemory.insert( object,
- 0,
+ 0,
dynamic,
true,
this.rule,
this.activation );
}
-
+
public void insertLogical(final Object object,
- final long duration,
- final boolean dynamic) throws FactException {
- this.workingMemory.insert( object,
- duration,
- dynamic,
- true,
- this.rule,
- this.activation );
- }
+ final long duration,
+ final boolean dynamic) throws FactException {
+ this.workingMemory.insert( object,
+ duration,
+ dynamic,
+ true,
+ this.rule,
+ this.activation );
+ }
public void update(final FactHandle handle,
final Object newObject) throws FactException {
@@ -181,7 +205,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() {
@@ -232,15 +256,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/ming-serialization/drools-core/src/main/java/org/drools/base/MapGlobalResolver.java
===================================================================
--- labs/jbossrules/branches/ming-serialization/drools-core/src/main/java/org/drools/base/MapGlobalResolver.java 2008-03-12 20:58:14 UTC (rev 18900)
+++ labs/jbossrules/branches/ming-serialization/drools-core/src/main/java/org/drools/base/MapGlobalResolver.java 2008-03-12 21:20:57 UTC (rev 18901)
@@ -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/ming-serialization/drools-core/src/main/java/org/drools/base/ReferenceOriginalGlobalExporter.java
===================================================================
--- labs/jbossrules/branches/ming-serialization/drools-core/src/main/java/org/drools/base/ReferenceOriginalGlobalExporter.java 2008-03-12 20:58:14 UTC (rev 18900)
+++ labs/jbossrules/branches/ming-serialization/drools-core/src/main/java/org/drools/base/ReferenceOriginalGlobalExporter.java 2008-03-12 21:20:57 UTC (rev 18901)
@@ -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/ming-serialization/drools-core/src/main/java/org/drools/base/accumulators/AccumulateFunction.java
===================================================================
--- labs/jbossrules/branches/ming-serialization/drools-core/src/main/java/org/drools/base/accumulators/AccumulateFunction.java 2008-03-12 20:58:14 UTC (rev 18900)
+++ labs/jbossrules/branches/ming-serialization/drools-core/src/main/java/org/drools/base/accumulators/AccumulateFunction.java 2008-03-12 21:20:57 UTC (rev 18901)
@@ -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,14 +18,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 +60,7 @@
/**
* Returns the current value in this accumulation session
- *
+ *
* @param context
* @return
* @throws Exception
@@ -68,7 +69,7 @@
/**
* True if the function supports reverse. False otherwise.
- *
+ *
* @return
*/
public boolean supportsReverse();
Modified: labs/jbossrules/branches/ming-serialization/drools-core/src/main/java/org/drools/base/accumulators/AverageAccumulateFunction.java
===================================================================
--- labs/jbossrules/branches/ming-serialization/drools-core/src/main/java/org/drools/base/accumulators/AverageAccumulateFunction.java 2008-03-12 20:58:14 UTC (rev 18900)
+++ labs/jbossrules/branches/ming-serialization/drools-core/src/main/java/org/drools/base/accumulators/AverageAccumulateFunction.java 2008-03-12 21:20:57 UTC (rev 18901)
@@ -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 average values
- *
+ *
* @author etirelli
*
*/
public class AverageAccumulateFunction implements AccumulateFunction {
+ public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
+
+ }
+
+ public void writeExternal(ObjectOutput out) throws IOException {
+
+ }
+
protected static class AverageData {
public int count = 0;
public double total = 0;
Modified: labs/jbossrules/branches/ming-serialization/drools-core/src/main/java/org/drools/base/accumulators/CountAccumulateFunction.java
===================================================================
--- labs/jbossrules/branches/ming-serialization/drools-core/src/main/java/org/drools/base/accumulators/CountAccumulateFunction.java 2008-03-12 20:58:14 UTC (rev 18900)
+++ labs/jbossrules/branches/ming-serialization/drools-core/src/main/java/org/drools/base/accumulators/CountAccumulateFunction.java 2008-03-12 21:20:57 UTC (rev 18901)
@@ -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 counting occurences
- *
+ *
* @author etirelli
*
*/
public class CountAccumulateFunction implements AccumulateFunction {
+ public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
+
+ }
+
+ public void writeExternal(ObjectOutput out) throws IOException {
+
+ }
+
protected static class CountData {
public long count = 0;
}
Modified: labs/jbossrules/branches/ming-serialization/drools-core/src/main/java/org/drools/base/accumulators/JavaAccumulatorFunctionExecutor.java
===================================================================
--- labs/jbossrules/branches/ming-serialization/drools-core/src/main/java/org/drools/base/accumulators/JavaAccumulatorFunctionExecutor.java 2008-03-12 20:58:14 UTC (rev 18900)
+++ labs/jbossrules/branches/ming-serialization/drools-core/src/main/java/org/drools/base/accumulators/JavaAccumulatorFunctionExecutor.java 2008-03-12 21:20:57 UTC (rev 18901)
@@ -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/ming-serialization/drools-core/src/main/java/org/drools/base/accumulators/MVELAccumulatorFunctionExecutor.java
===================================================================
--- labs/jbossrules/branches/ming-serialization/drools-core/src/main/java/org/drools/base/accumulators/MVELAccumulatorFunctionExecutor.java 2008-03-12 20:58:14 UTC (rev 18900)
+++ labs/jbossrules/branches/ming-serialization/drools-core/src/main/java/org/drools/base/accumulators/MVELAccumulatorFunctionExecutor.java 2008-03-12 21:20:57 UTC (rev 18901)
@@ -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/ming-serialization/drools-core/src/main/java/org/drools/base/accumulators/MaxAccumulateFunction.java
===================================================================
--- labs/jbossrules/branches/ming-serialization/drools-core/src/main/java/org/drools/base/accumulators/MaxAccumulateFunction.java 2008-03-12 20:58:14 UTC (rev 18900)
+++ labs/jbossrules/branches/ming-serialization/drools-core/src/main/java/org/drools/base/accumulators/MaxAccumulateFunction.java 2008-03-12 21:20:57 UTC (rev 18901)
@@ -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/ming-serialization/drools-core/src/main/java/org/drools/base/accumulators/MinAccumulateFunction.java
===================================================================
--- labs/jbossrules/branches/ming-serialization/drools-core/src/main/java/org/drools/base/accumulators/MinAccumulateFunction.java 2008-03-12 20:58:14 UTC (rev 18900)
+++ labs/jbossrules/branches/ming-serialization/drools-core/src/main/java/org/drools/base/accumulators/MinAccumulateFunction.java 2008-03-12 21:20:57 UTC (rev 18901)
@@ -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/ming-serialization/drools-core/src/main/java/org/drools/base/accumulators/SumAccumulateFunction.java
===================================================================
--- labs/jbossrules/branches/ming-serialization/drools-core/src/main/java/org/drools/base/accumulators/SumAccumulateFunction.java 2008-03-12 20:58:14 UTC (rev 18900)
+++ labs/jbossrules/branches/ming-serialization/drools-core/src/main/java/org/drools/base/accumulators/SumAccumulateFunction.java 2008-03-12 21:20:57 UTC (rev 18901)
@@ -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.IOException;
+import java.io.ObjectInput;
/**
* An implementation of an accumulator capable of calculating sum of values
- *
+ *
* @author etirelli
*
*/
public class SumAccumulateFunction implements AccumulateFunction {
+ public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
+
+ }
+
+ public void writeExternal(ObjectOutput out) throws IOException {
+
+ }
+
protected static class SumData {
public double total = 0;
}
Modified: labs/jbossrules/branches/ming-serialization/drools-core/src/main/java/org/drools/base/dataproviders/MVELDataProvider.java
===================================================================
--- labs/jbossrules/branches/ming-serialization/drools-core/src/main/java/org/drools/base/dataproviders/MVELDataProvider.java 2008-03-12 20:58:14 UTC (rev 18900)
+++ labs/jbossrules/branches/ming-serialization/drools-core/src/main/java/org/drools/base/dataproviders/MVELDataProvider.java 2008-03-12 21:20:57 UTC (rev 18901)
@@ -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;
@@ -16,24 +20,38 @@
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 +61,7 @@
final PropagationContext ctx,
final Object executionContext ) {
DroolsMVELFactory factory = (DroolsMVELFactory) executionContext;
-
+
factory.setContext( tuple,
null,
null,
Modified: labs/jbossrules/branches/ming-serialization/drools-core/src/main/java/org/drools/base/evaluators/AfterEvaluatorDefinition.java
===================================================================
--- labs/jbossrules/branches/ming-serialization/drools-core/src/main/java/org/drools/base/evaluators/AfterEvaluatorDefinition.java 2008-03-12 20:58:14 UTC (rev 18900)
+++ labs/jbossrules/branches/ming-serialization/drools-core/src/main/java/org/drools/base/evaluators/AfterEvaluatorDefinition.java 2008-03-12 21:20:57 UTC (rev 18901)
@@ -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
*/
@@ -162,7 +173,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 +230,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/ming-serialization/drools-core/src/main/java/org/drools/base/evaluators/BeforeEvaluatorDefinition.java
===================================================================
--- labs/jbossrules/branches/ming-serialization/drools-core/src/main/java/org/drools/base/evaluators/BeforeEvaluatorDefinition.java 2008-03-12 20:58:14 UTC (rev 18900)
+++ labs/jbossrules/branches/ming-serialization/drools-core/src/main/java/org/drools/base/evaluators/BeforeEvaluatorDefinition.java 2008-03-12 21:20:57 UTC (rev 18901)
@@ -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,7 +142,7 @@
*/
public static class BeforeEvaluator extends BaseEvaluator {
private static final long serialVersionUID = -4778826341073034320L;
-
+
private long initRange;
private long finalRange;
@@ -142,12 +153,12 @@
isNegated ? NOT_BEFORE : BEFORE );
this.parseParameters( parameters );
}
-
+
@Override
public Object prepareObject(InternalFactHandle handle) {
return handle;
}
-
+
public boolean evaluate(InternalWorkingMemory workingMemory,
final Extractor extractor,
final Object object1,
@@ -161,7 +172,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 +184,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 +232,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/ming-serialization/drools-core/src/main/java/org/drools/base/evaluators/CoincidesEvaluatorDefinition.java
===================================================================
--- labs/jbossrules/branches/ming-serialization/drools-core/src/main/java/org/drools/base/evaluators/CoincidesEvaluatorDefinition.java 2008-03-12 20:58:14 UTC (rev 18900)
+++ labs/jbossrules/branches/ming-serialization/drools-core/src/main/java/org/drools/base/evaluators/CoincidesEvaluatorDefinition.java 2008-03-12 21:20:57 UTC (rev 18901)
@@ -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,9 +140,9 @@
/**
* 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;
@@ -142,12 +153,12 @@
isNegated ? COINCIDES_NOT : COINCIDES );
this.parseParameters( parameters );
}
-
+
@Override
public Object prepareObject(InternalFactHandle handle) {
return handle;
}
-
+
public boolean evaluate(InternalWorkingMemory workingMemory,
final Extractor extractor,
final Object object1,
@@ -161,9 +172,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 +186,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 +236,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/ming-serialization/drools-core/src/main/java/org/drools/base/evaluators/ComparableEvaluatorsDefinition.java
===================================================================
--- labs/jbossrules/branches/ming-serialization/drools-core/src/main/java/org/drools/base/evaluators/ComparableEvaluatorsDefinition.java 2008-03-12 20:58:14 UTC (rev 18900)
+++ labs/jbossrules/branches/ming-serialization/drools-core/src/main/java/org/drools/base/evaluators/ComparableEvaluatorsDefinition.java 2008-03-12 21:20:57 UTC (rev 18901)
@@ -21,6 +21,9 @@
import java.math.BigInteger;
import java.util.Comparator;
import java.util.Date;
+import java.io.ObjectOutput;
+import java.io.IOException;
+import java.io.ObjectInput;
import org.drools.base.BaseEvaluator;
import org.drools.base.ShadowProxy;
@@ -124,6 +127,14 @@
}
};
+ public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
+ evaluators = (EvaluatorCache)in.readObject();
+ }
+
+ public void writeExternal(ObjectOutput out) throws IOException {
+ out.writeObject(evaluators);
+ }
+
/**
* @inheridDoc
*/
Modified: labs/jbossrules/branches/ming-serialization/drools-core/src/main/java/org/drools/base/evaluators/DuringEvaluatorDefinition.java
===================================================================
--- labs/jbossrules/branches/ming-serialization/drools-core/src/main/java/org/drools/base/evaluators/DuringEvaluatorDefinition.java 2008-03-12 20:58:14 UTC (rev 18900)
+++ labs/jbossrules/branches/ming-serialization/drools-core/src/main/java/org/drools/base/evaluators/DuringEvaluatorDefinition.java 2008-03-12 21:20:57 UTC (rev 18901)
@@ -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,7 +142,7 @@
*/
public static class DuringEvaluator extends BaseEvaluator {
private static final long serialVersionUID = -5856043346192967722L;
-
+
private long startMinDev, startMaxDev;
private long endMinDev, endMaxDev;
@@ -142,12 +153,12 @@
isNegated ? NOT_DURING : DURING );
this.parseParameters( parameters );
}
-
+
@Override
public Object prepareObject(InternalFactHandle handle) {
return handle;
}
-
+
public boolean evaluate(InternalWorkingMemory workingMemory,
final Extractor extractor,
final Object object1,
@@ -158,16 +169,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 +188,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 +203,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 +239,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 +257,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/ming-serialization/drools-core/src/main/java/org/drools/base/evaluators/EqualityEvaluatorsDefinition.java
===================================================================
--- labs/jbossrules/branches/ming-serialization/drools-core/src/main/java/org/drools/base/evaluators/EqualityEvaluatorsDefinition.java 2008-03-12 20:58:14 UTC (rev 18900)
+++ labs/jbossrules/branches/ming-serialization/drools-core/src/main/java/org/drools/base/evaluators/EqualityEvaluatorsDefinition.java 2008-03-12 21:20:57 UTC (rev 18901)
@@ -18,6 +18,10 @@
package org.drools.base.evaluators;
import java.util.Date;
+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.ShadowProxy;
@@ -95,6 +99,14 @@
}
};
+ public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
+ evaluators = (EvaluatorCache)in.readObject();
+ }
+
+ public void writeExternal(ObjectOutput out) throws IOException {
+ out.writeObject(evaluators);
+ }
+
/**
* @inheridDoc
*/
@@ -1293,7 +1305,7 @@
private static final long serialVersionUID = 400L;
public final static Evaluator INSTANCE = new FloatEqualEvaluator();
- private FloatEqualEvaluator() {
+ public FloatEqualEvaluator() {
super( ValueType.PFLOAT_TYPE,
Operator.EQUAL );
}
Modified: labs/jbossrules/branches/ming-serialization/drools-core/src/main/java/org/drools/base/evaluators/EvaluatorCache.java
===================================================================
--- labs/jbossrules/branches/ming-serialization/drools-core/src/main/java/org/drools/base/evaluators/EvaluatorCache.java 2008-03-12 20:58:14 UTC (rev 18900)
+++ labs/jbossrules/branches/ming-serialization/drools-core/src/main/java/org/drools/base/evaluators/EvaluatorCache.java 2008-03-12 21:20:57 UTC (rev 18901)
@@ -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.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;
@@ -25,20 +29,28 @@
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 {
+ evaluators = (Map<ValueType, Map<Operator, Evaluator>>)in.readObject();
+ }
+
+ 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 +59,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/ming-serialization/drools-core/src/main/java/org/drools/base/evaluators/EvaluatorDefinition.java
===================================================================
--- labs/jbossrules/branches/ming-serialization/drools-core/src/main/java/org/drools/base/evaluators/EvaluatorDefinition.java 2008-03-12 20:58:14 UTC (rev 18900)
+++ labs/jbossrules/branches/ming-serialization/drools-core/src/main/java/org/drools/base/evaluators/EvaluatorDefinition.java 2008-03-12 21:20:57 UTC (rev 18901)
@@ -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/ming-serialization/drools-core/src/main/java/org/drools/base/evaluators/EvaluatorRegistry.java
===================================================================
--- labs/jbossrules/branches/ming-serialization/drools-core/src/main/java/org/drools/base/evaluators/EvaluatorRegistry.java 2008-03-12 20:58:14 UTC (rev 18900)
+++ labs/jbossrules/branches/ming-serialization/drools-core/src/main/java/org/drools/base/evaluators/EvaluatorRegistry.java 2008-03-12 21:20:57 UTC (rev 18901)
@@ -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,21 +18,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 +46,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 +55,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 +79,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 +132,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 +145,7 @@
/**
* Returns the evaluator definition for the given evaluator ID
* or null if no one was found
- *
+ *
* @param evaluatorId
* @return
*/
@@ -132,7 +156,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 +167,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 +200,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 +228,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/ming-serialization/drools-core/src/main/java/org/drools/base/evaluators/FinishedByEvaluatorDefinition.java
===================================================================
--- labs/jbossrules/branches/ming-serialization/drools-core/src/main/java/org/drools/base/evaluators/FinishedByEvaluatorDefinition.java 2008-03-12 20:58:14 UTC (rev 18900)
+++ labs/jbossrules/branches/ming-serialization/drools-core/src/main/java/org/drools/base/evaluators/FinishedByEvaluatorDefinition.java 2008-03-12 21:20:57 UTC (rev 18901)
@@ -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,7 +142,7 @@
*/
public static class FinishedByEvaluator extends BaseEvaluator {
private static final long serialVersionUID = -5156972073099070733L;
-
+
private long startMinDev, startMaxDev;
private long endDev;
@@ -142,12 +153,12 @@
isNegated ? NOT_FINISHED_BY : FINISHED_BY );
this.parseParameters( parameters );
}
-
+
@Override
public Object prepareObject(InternalFactHandle handle) {
return handle;
}
-
+
public boolean evaluate(InternalWorkingMemory workingMemory,
final Extractor extractor,
final Object object1,
@@ -158,16 +169,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 +188,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 +203,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 +237,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 +261,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/ming-serialization/drools-core/src/main/java/org/drools/base/evaluators/FinishesEvaluatorDefinition.java
===================================================================
--- labs/jbossrules/branches/ming-serialization/drools-core/src/main/java/org/drools/base/evaluators/FinishesEvaluatorDefinition.java 2008-03-12 20:58:14 UTC (rev 18900)
+++ labs/jbossrules/branches/ming-serialization/drools-core/src/main/java/org/drools/base/evaluators/FinishesEvaluatorDefinition.java 2008-03-12 21:20:57 UTC (rev 18901)
@@ -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,7 +142,7 @@
*/
public static class FinishesEvaluator extends BaseEvaluator {
private static final long serialVersionUID = 6232789044144077522L;
-
+
private long startMinDev, startMaxDev;
private long endDev;
@@ -142,12 +153,12 @@
isNegated ? FINISHES_NOT : FINISHES );
this.parseParameters( parameters );
}
-
+
@Override
public Object prepareObject(InternalFactHandle handle) {
return handle;
}
-
+
public boolean evaluate(InternalWorkingMemory workingMemory,
final Extractor extractor,
final Object object1,
@@ -158,16 +169,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 +188,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 +203,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 +237,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 +261,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/ming-serialization/drools-core/src/main/java/org/drools/base/evaluators/IncludesEvaluatorDefinition.java
===================================================================
--- labs/jbossrules/branches/ming-serialization/drools-core/src/main/java/org/drools/base/evaluators/IncludesEvaluatorDefinition.java 2008-03-12 20:58:14 UTC (rev 18900)
+++ labs/jbossrules/branches/ming-serialization/drools-core/src/main/java/org/drools/base/evaluators/IncludesEvaluatorDefinition.java 2008-03-12 21:20:57 UTC (rev 18901)
@@ -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,7 +142,7 @@
*/
public static class IncludesEvaluator extends BaseEvaluator {
private static final long serialVersionUID = -5947397607962049251L;
-
+
private long startMinDev, startMaxDev;
private long endMinDev, endMaxDev;
@@ -142,12 +153,12 @@
isNegated ? INCLUDES_NOT : INCLUDES );
this.parseParameters( parameters );
}
-
+
@Override
public Object prepareObject(InternalFactHandle handle) {
return handle;
}
-
+
public boolean evaluate(InternalWorkingMemory workingMemory,
final Extractor extractor,
final Object object1,
@@ -158,16 +169,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 +188,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 +203,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 +239,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 +257,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/ming-serialization/drools-core/src/main/java/org/drools/base/evaluators/MatchesEvaluatorsDefinition.java
===================================================================
--- labs/jbossrules/branches/ming-serialization/drools-core/src/main/java/org/drools/base/evaluators/MatchesEvaluatorsDefinition.java 2008-03-12 20:58:14 UTC (rev 18900)
+++ labs/jbossrules/branches/ming-serialization/drools-core/src/main/java/org/drools/base/evaluators/MatchesEvaluatorsDefinition.java 2008-03-12 21:20:57 UTC (rev 18901)
@@ -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/ming-serialization/drools-core/src/main/java/org/drools/base/evaluators/MeetsEvaluatorDefinition.java
===================================================================
--- labs/jbossrules/branches/ming-serialization/drools-core/src/main/java/org/drools/base/evaluators/MeetsEvaluatorDefinition.java 2008-03-12 20:58:14 UTC (rev 18900)
+++ labs/jbossrules/branches/ming-serialization/drools-core/src/main/java/org/drools/base/evaluators/MeetsEvaluatorDefinition.java 2008-03-12 21:20:57 UTC (rev 18901)
@@ -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,7 +142,7 @@
*/
public static class MeetsEvaluator extends BaseEvaluator {
private static final long serialVersionUID = 9091548399308812447L;
-
+
private long finalRange;
public MeetsEvaluator(final ValueType type,
@@ -141,12 +152,12 @@
isNegated ? MEETS_NOT : MEETS );
this.parseParameters( parameters );
}
-
+
@Override
public Object prepareObject(InternalFactHandle handle) {
return handle;
}
-
+
public boolean evaluate(InternalWorkingMemory workingMemory,
final Extractor extractor,
final Object object1,
@@ -161,12 +172,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 +189,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 +232,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/ming-serialization/drools-core/src/main/java/org/drools/base/evaluators/MetByEvaluatorDefinition.java
===================================================================
--- labs/jbossrules/branches/ming-serialization/drools-core/src/main/java/org/drools/base/evaluators/MetByEvaluatorDefinition.java 2008-03-12 20:58:14 UTC (rev 18900)
+++ labs/jbossrules/branches/ming-serialization/drools-core/src/main/java/org/drools/base/evaluators/MetByEvaluatorDefinition.java 2008-03-12 21:20:57 UTC (rev 18901)
@@ -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,7 +142,7 @@
*/
public static class MetByEvaluator extends BaseEvaluator {
private static final long serialVersionUID = 7907908401657594347L;
-
+
private long finalRange;
public MetByEvaluator(final ValueType type,
@@ -141,12 +152,12 @@
isNegated ? NOT_MET_BY : MET_BY );
this.parseParameters( parameters );
}
-
+
@Override
public Object prepareObject(InternalFactHandle handle) {
return handle;
}
-
+
public boolean evaluate(InternalWorkingMemory workingMemory,
final Extractor extractor,
final Object object1,
@@ -175,7 +186,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 +232,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/ming-serialization/drools-core/src/main/java/org/drools/base/evaluators/OverlappedByEvaluatorDefinition.java
===================================================================
--- labs/jbossrules/branches/ming-serialization/drools-core/src/main/java/org/drools/base/evaluators/OverlappedByEvaluatorDefinition.java 2008-03-12 20:58:14 UTC (rev 18900)
+++ labs/jbossrules/branches/ming-serialization/drools-core/src/main/java/org/drools/base/evaluators/OverlappedByEvaluatorDefinition.java 2008-03-12 21:20:57 UTC (rev 18901)
@@ -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,7 +142,7 @@
*/
public static class OverlappedByEvaluator extends BaseEvaluator {
private static final long serialVersionUID = -2768899194494247889L;
-
+
private long startMinDev, startMaxDev;
private long endMinDev, endMaxDev;
@@ -142,12 +153,12 @@
isNegated ? NOT_OVERLAPPED_BY : OVERLAPPED_BY );
this.parseParameters( parameters );
}
-
+
@Override
public Object prepareObject(InternalFactHandle handle) {
return handle;
}
-
+
public boolean evaluate(InternalWorkingMemory workingMemory,
final Extractor extractor,
final Object object1,
@@ -165,7 +176,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 +191,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 +208,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 +244,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 +262,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/ming-serialization/drools-core/src/main/java/org/drools/base/evaluators/OverlapsEvaluatorDefinition.java
===================================================================
--- labs/jbossrules/branches/ming-serialization/drools-core/src/main/java/org/drools/base/evaluators/OverlapsEvaluatorDefinition.java 2008-03-12 20:58:14 UTC (rev 18900)
+++ labs/jbossrules/branches/ming-serialization/drools-core/src/main/java/org/drools/base/evaluators/OverlapsEvaluatorDefinition.java 2008-03-12 21:20:57 UTC (rev 18901)
@@ -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,7 +142,7 @@
*/
public static class OverlapsEvaluator extends BaseEvaluator {
private static final long serialVersionUID = -5108524288774833244L;
-
+
private long startMinDev, startMaxDev;
private long endMinDev, endMaxDev;
@@ -142,12 +153,12 @@
isNegated ? OVERLAPS_NOT : OVERLAPS );
this.parseParameters( parameters );
}
-
+
@Override
public Object prepareObject(InternalFactHandle handle) {
return handle;
}
-
+
public boolean evaluate(InternalWorkingMemory workingMemory,
final Extractor extractor,
final Object object1,
@@ -158,7 +169,7 @@
public boolean evaluateCachedRight(InternalWorkingMemory workingMemory,
final VariableContextEntry context,
final Object left) {
-
+
if ( context.rightNull ) {
return false;
}
@@ -166,10 +177,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 +192,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 +209,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 +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) {
@@ -252,19 +263,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/ming-serialization/drools-core/src/main/java/org/drools/base/evaluators/SetEvaluatorsDefinition.java
===================================================================
--- labs/jbossrules/branches/ming-serialization/drools-core/src/main/java/org/drools/base/evaluators/SetEvaluatorsDefinition.java 2008-03-12 20:58:14 UTC (rev 18900)
+++ labs/jbossrules/branches/ming-serialization/drools-core/src/main/java/org/drools/base/evaluators/SetEvaluatorsDefinition.java 2008-03-12 21:20:57 UTC (rev 18901)
@@ -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;
@@ -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
*/
@@ -159,7 +171,7 @@
* 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();
@@ -223,7 +235,7 @@
}
}
- static class ArrayExcludesEvaluator extends BaseEvaluator {
+ public static class ArrayExcludesEvaluator extends BaseEvaluator {
/**
*
*/
@@ -289,7 +301,7 @@
}
}
- static class ArrayMemberOfEvaluator extends BaseEvaluator {
+ public static class ArrayMemberOfEvaluator extends BaseEvaluator {
/**
*
*/
@@ -355,7 +367,7 @@
}
}
- static class ArrayNotMemberOfEvaluator extends BaseEvaluator {
+ public static class ArrayNotMemberOfEvaluator extends BaseEvaluator {
/**
*
*/
@@ -421,7 +433,7 @@
}
}
- static abstract class BaseMemberOfEvaluator extends BaseEvaluator {
+ public static abstract class BaseMemberOfEvaluator extends BaseEvaluator {
private static final long serialVersionUID = 2017803222427893249L;
@@ -511,7 +523,7 @@
}
- static abstract class BaseNotMemberOfEvaluator extends BaseEvaluator {
+ public static abstract class BaseNotMemberOfEvaluator extends BaseEvaluator {
private static final long serialVersionUID = -8730331781980886901L;
Modified: labs/jbossrules/branches/ming-serialization/drools-core/src/main/java/org/drools/base/evaluators/SoundslikeEvaluatorsDefinition.java
===================================================================
--- labs/jbossrules/branches/ming-serialization/drools-core/src/main/java/org/drools/base/evaluators/SoundslikeEvaluatorsDefinition.java 2008-03-12 20:58:14 UTC (rev 18900)
+++ labs/jbossrules/branches/ming-serialization/drools-core/src/main/java/org/drools/base/evaluators/SoundslikeEvaluatorsDefinition.java 2008-03-12 21:20:57 UTC (rev 18901)
@@ -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/ming-serialization/drools-core/src/main/java/org/drools/base/evaluators/StartedByEvaluatorDefinition.java
===================================================================
--- labs/jbossrules/branches/ming-serialization/drools-core/src/main/java/org/drools/base/evaluators/StartedByEvaluatorDefinition.java 2008-03-12 20:58:14 UTC (rev 18900)
+++ labs/jbossrules/branches/ming-serialization/drools-core/src/main/java/org/drools/base/evaluators/StartedByEvaluatorDefinition.java 2008-03-12 21:20:57 UTC (rev 18901)
@@ -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,7 +142,7 @@
*/
public static class StartedByEvaluator extends BaseEvaluator {
private static final long serialVersionUID = -2655549435451501420L;
-
+
private long startDev;
private long endMinDev, endMaxDev;
@@ -142,12 +153,12 @@
isNegated ? NOT_STARTED_BY : STARTED_BY );
this.parseParameters( parameters );
}
-
+
@Override
public Object prepareObject(InternalFactHandle handle) {
return handle;
}
-
+
public boolean evaluate(InternalWorkingMemory workingMemory,
final Extractor extractor,
final Object object1,
@@ -158,16 +169,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 +188,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 +203,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 +237,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 +261,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/ming-serialization/drools-core/src/main/java/org/drools/base/evaluators/StartsEvaluatorDefinition.java
===================================================================
--- labs/jbossrules/branches/ming-serialization/drools-core/src/main/java/org/drools/base/evaluators/StartsEvaluatorDefinition.java 2008-03-12 20:58:14 UTC (rev 18900)
+++ labs/jbossrules/branches/ming-serialization/drools-core/src/main/java/org/drools/base/evaluators/StartsEvaluatorDefinition.java 2008-03-12 21:20:57 UTC (rev 18901)
@@ -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,12 @@
isNegated ? STARTS_NOT : STARTS );
this.parseParameters( parameters );
}
-
+
@Override
public Object prepareObject(InternalFactHandle handle) {
return handle;
}
-
+
public boolean evaluate(InternalWorkingMemory workingMemory,
final Extractor extractor,
final Object object1,
@@ -158,16 +169,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 +188,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 +203,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 +237,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 +261,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/ming-serialization/drools-core/src/main/java/org/drools/base/extractors/ArrayExtractor.java
===================================================================
--- labs/jbossrules/branches/ming-serialization/drools-core/src/main/java/org/drools/base/extractors/ArrayExtractor.java 2008-03-12 20:58:14 UTC (rev 18900)
+++ labs/jbossrules/branches/ming-serialization/drools-core/src/main/java/org/drools/base/extractors/ArrayExtractor.java 2008-03-12 21:20:57 UTC (rev 18901)
@@ -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/ming-serialization/drools-core/src/main/java/org/drools/base/extractors/BaseObjectClassFieldExtractor.java
===================================================================
--- labs/jbossrules/branches/ming-serialization/drools-core/src/main/java/org/drools/base/extractors/BaseObjectClassFieldExtractor.java 2008-03-12 20:58:14 UTC (rev 18900)
+++ labs/jbossrules/branches/ming-serialization/drools-core/src/main/java/org/drools/base/extractors/BaseObjectClassFieldExtractor.java 2008-03-12 21:20:57 UTC (rev 18901)
@@ -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/ming-serialization/drools-core/src/main/java/org/drools/base/extractors/MVELClassFieldExtractor.java
===================================================================
--- labs/jbossrules/branches/ming-serialization/drools-core/src/main/java/org/drools/base/extractors/MVELClassFieldExtractor.java 2008-03-12 20:58:14 UTC (rev 18900)
+++ labs/jbossrules/branches/ming-serialization/drools-core/src/main/java/org/drools/base/extractors/MVELClassFieldExtractor.java 2008-03-12 21:20:57 UTC (rev 18901)
@@ -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/ming-serialization/drools-core/src/main/java/org/drools/base/field/BooleanFieldImpl.java
===================================================================
--- labs/jbossrules/branches/ming-serialization/drools-core/src/main/java/org/drools/base/field/BooleanFieldImpl.java 2008-03-12 20:58:14 UTC (rev 18900)
+++ labs/jbossrules/branches/ming-serialization/drools-core/src/main/java/org/drools/base/field/BooleanFieldImpl.java 2008-03-12 21:20:57 UTC (rev 18901)
@@ -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,21 +19,38 @@
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 +106,7 @@
public int hashCode() {
return this.value ? 1 : 0;
}
-
+
public boolean isNull() {
return false;
}
@@ -113,7 +130,7 @@
public boolean isCollectionField() {
return false;
}
-
+
public boolean isStringField() {
return false;
}
Modified: labs/jbossrules/branches/ming-serialization/drools-core/src/main/java/org/drools/base/field/DoubleFieldImpl.java
===================================================================
--- labs/jbossrules/branches/ming-serialization/drools-core/src/main/java/org/drools/base/field/DoubleFieldImpl.java 2008-03-12 20:58:14 UTC (rev 18900)
+++ labs/jbossrules/branches/ming-serialization/drools-core/src/main/java/org/drools/base/field/DoubleFieldImpl.java 2008-03-12 21:20:57 UTC (rev 18901)
@@ -3,17 +3,33 @@
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 +85,7 @@
public int hashCode() {
return (int) this.value;
}
-
+
public boolean isNull() {
return false;
}
@@ -89,7 +105,7 @@
public boolean isObjectField() {
return false;
}
-
+
public boolean isCollectionField() {
return false;
}
Modified: labs/jbossrules/branches/ming-serialization/drools-core/src/main/java/org/drools/base/field/LongFieldImpl.java
===================================================================
--- labs/jbossrules/branches/ming-serialization/drools-core/src/main/java/org/drools/base/field/LongFieldImpl.java 2008-03-12 20:58:14 UTC (rev 18900)
+++ labs/jbossrules/branches/ming-serialization/drools-core/src/main/java/org/drools/base/field/LongFieldImpl.java 2008-03-12 21:20:57 UTC (rev 18901)
@@ -3,17 +3,34 @@
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 +86,7 @@
public int hashCode() {
return (int) this.value;
}
-
+
public boolean isNull() {
return false;
}
Modified: labs/jbossrules/branches/ming-serialization/drools-core/src/main/java/org/drools/base/mvel/DroolsMVELFactory.java
===================================================================
--- labs/jbossrules/branches/ming-serialization/drools-core/src/main/java/org/drools/base/mvel/DroolsMVELFactory.java 2008-03-12 20:58:14 UTC (rev 18900)
+++ labs/jbossrules/branches/ming-serialization/drools-core/src/main/java/org/drools/base/mvel/DroolsMVELFactory.java 2008-03-12 21:20:57 UTC (rev 18901)
@@ -1,6 +1,10 @@
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 +27,7 @@
public class DroolsMVELFactory extends BaseVariableResolverFactory
implements
LocalVariableResolverFactory,
- Serializable,
+ Externalizable,
Cloneable {
private static final long serialVersionUID = 400L;
@@ -55,6 +59,10 @@
new MVELCalendarCoercion() );
}
+ public DroolsMVELFactory() {
+
+ }
+
public DroolsMVELFactory(final Map previousDeclarations,
final Map localDeclarations,
final Map globals) {
@@ -82,36 +90,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/ming-serialization/drools-core/src/main/java/org/drools/base/mvel/MVELAccumulator.java
===================================================================
--- labs/jbossrules/branches/ming-serialization/drools-core/src/main/java/org/drools/base/mvel/MVELAccumulator.java 2008-03-12 20:58:14 UTC (rev 18900)
+++ labs/jbossrules/branches/ming-serialization/drools-core/src/main/java/org/drools/base/mvel/MVELAccumulator.java 2008-03-12 21:20:57 UTC (rev 18901)
@@ -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/ming-serialization/drools-core/src/main/java/org/drools/base/mvel/MVELConsequence.java
===================================================================
--- labs/jbossrules/branches/ming-serialization/drools-core/src/main/java/org/drools/base/mvel/MVELConsequence.java 2008-03-12 20:58:14 UTC (rev 18900)
+++ labs/jbossrules/branches/ming-serialization/drools-core/src/main/java/org/drools/base/mvel/MVELConsequence.java 2008-03-12 21:20:57 UTC (rev 18901)
@@ -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.common.InternalRuleBase;
@@ -15,34 +19,48 @@
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/ming-serialization/drools-core/src/main/java/org/drools/base/mvel/MVELEvalExpression.java
===================================================================
--- labs/jbossrules/branches/ming-serialization/drools-core/src/main/java/org/drools/base/mvel/MVELEvalExpression.java 2008-03-12 20:58:14 UTC (rev 18900)
+++ labs/jbossrules/branches/ming-serialization/drools-core/src/main/java/org/drools/base/mvel/MVELEvalExpression.java 2008-03-12 21:20:57 UTC (rev 18901)
@@ -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/ming-serialization/drools-core/src/main/java/org/drools/base/mvel/MVELPredicateExpression.java
===================================================================
--- labs/jbossrules/branches/ming-serialization/drools-core/src/main/java/org/drools/base/mvel/MVELPredicateExpression.java 2008-03-12 20:58:14 UTC (rev 18900)
+++ labs/jbossrules/branches/ming-serialization/drools-core/src/main/java/org/drools/base/mvel/MVELPredicateExpression.java 2008-03-12 21:20:57 UTC (rev 18901)
@@ -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;
@@ -12,19 +16,32 @@
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 +58,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/ming-serialization/drools-core/src/main/java/org/drools/base/mvel/MVELSalienceExpression.java
===================================================================
--- labs/jbossrules/branches/ming-serialization/drools-core/src/main/java/org/drools/base/mvel/MVELSalienceExpression.java 2008-03-12 20:58:14 UTC (rev 18900)
+++ labs/jbossrules/branches/ming-serialization/drools-core/src/main/java/org/drools/base/mvel/MVELSalienceExpression.java 2008-03-12 21:20:57 UTC (rev 18901)
@@ -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/ming-serialization/drools-core/src/main/java/org/drools/common/AbstractFactHandleFactory.java
===================================================================
--- labs/jbossrules/branches/ming-serialization/drools-core/src/main/java/org/drools/common/AbstractFactHandleFactory.java 2008-03-12 20:58:14 UTC (rev 18900)
+++ labs/jbossrules/branches/ming-serialization/drools-core/src/main/java/org/drools/common/AbstractFactHandleFactory.java 2008-03-12 21:20:57 UTC (rev 18901)
@@ -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,16 +20,21 @@
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;
- protected final PrimitiveLongStack factHandlePool = new PrimitiveLongStack();
+ protected PrimitiveLongStack factHandlePool = new PrimitiveLongStack();
/** The fact id. */
private long id;
@@ -37,13 +42,26 @@
/** The number of facts created - used for recency. */
private long counter;
+
+ public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
+ id = in.readLong();
+ counter = in.readLong();
+ factHandlePool = (PrimitiveLongStack)in.readObject();
+ }
+
+ public void writeExternal(ObjectOutput out) throws IOException {
+ out.writeLong(id);
+ out.writeLong(counter);
+ out.writeObject(factHandlePool);
+ }
+
/* (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 ) {
if ( !this.factHandlePool.isEmpty() ) {
return newFactHandle( this.factHandlePool.pop(),
- object,
+ object,
isEvent,
0,
workingMemory );
@@ -55,14 +73,14 @@
0,
workingMemory );
}
-
+
/* (non-Javadoc)
- * @see org.drools.reteoo.FactHandleFactory#newFactHandle()
- */
+ * @see org.drools.reteoo.FactHandleFactory#newFactHandle()
+ */
public final InternalFactHandle newFactHandle( final Object object, final boolean isEvent, long duration, final WorkingMemory workingMemory ) {
if ( !this.factHandlePool.isEmpty() ) {
return newFactHandle( this.factHandlePool.pop(),
- object,
+ object,
isEvent,
duration,
workingMemory );
@@ -80,7 +98,7 @@
*/
protected final InternalFactHandle newFactHandle(final long id,
final Object object,
- final boolean isEvent,
+ final boolean isEvent,
final WorkingMemory workingMemory ) {
return newFactHandle( id,
object,
@@ -89,10 +107,10 @@
0,
workingMemory );
}
-
+
/* (non-Javadoc)
- * @see org.drools.reteoo.FactHandleFactory#newFactHandle(long)
- */
+ * @see org.drools.reteoo.FactHandleFactory#newFactHandle(long)
+ */
protected final InternalFactHandle newFactHandle(final long id,
final Object object,
final boolean isEvent,
@@ -112,12 +130,12 @@
protected abstract InternalFactHandle newFactHandle(final long id,
final Object object,
final long recency,
- final boolean isEvent,
+ final boolean isEvent,
final WorkingMemory workingMemory );
-
+
/* (non-Javadoc)
- * @see org.drools.reteoo.FactHandleFactory#newFactHandle(long)
- */
+ * @see org.drools.reteoo.FactHandleFactory#newFactHandle(long)
+ */
protected abstract InternalFactHandle newFactHandle(final long id,
final Object object,
final long recency,
Modified: labs/jbossrules/branches/ming-serialization/drools-core/src/main/java/org/drools/common/AbstractRuleBase.java
===================================================================
--- labs/jbossrules/branches/ming-serialization/drools-core/src/main/java/org/drools/common/AbstractRuleBase.java 2008-03-12 20:58:14 UTC (rev 18900)
+++ labs/jbossrules/branches/ming-serialization/drools-core/src/main/java/org/drools/common/AbstractRuleBase.java 2008-03-12 21:20:57 UTC (rev 18901)
@@ -22,6 +22,9 @@
import java.io.ObjectInput;
import java.io.ObjectOutput;
import java.io.Serializable;
+import java.io.ByteArrayOutputStream;
+import java.io.ObjectInputStream;
+import java.io.ByteArrayInputStream;
import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
@@ -113,7 +116,7 @@
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;
@@ -171,21 +174,45 @@
* 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) throws IOException {
- stream.writeObject( this.classLoader.getStore() );
- stream.writeObject( this.pkgs );
+ 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.classLoader.getStore() );
+ droolsStream.writeObject( this.pkgs );
+
// Rules must be restored by an ObjectInputStream that can resolve using a given ClassLoader to handle seaprately by storing as
// a byte[]
- stream.writeObject( this.id );
- stream.writeObject( this.processes );
- stream.writeObject( this.agendaGroupRuleTotals );
- stream.writeObject( this.factHandleFactory );
- stream.writeObject( this.globals );
- stream.writeObject( this.config );
+ droolsStream.writeObject( this.id );
+ droolsStream.writeInt(workingMemoryCounter);
+ droolsStream.writeObject( this.config );
+ droolsStream.writeObject( this.processes );
+ droolsStream.writeObject( this.agendaGroupRuleTotals );
+ droolsStream.writeObject( this.factHandleFactory );
+ droolsStream.writeObject( this.globals );
+ droolsStream.writeObject(reloadPackageCompilationData);
this.eventSupport.removeEventListener( RuleBaseEventListener.class );
- stream.writeObject( this.eventSupport );
+ 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());
+ }
}
/**
@@ -194,41 +221,57 @@
* 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) throws IOException,
+ 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 = stream instanceof DroolsObjectInput
- ? (DroolsObjectInput)stream
- : new DroolsObjectInputStream(stream);
+ DroolsObjectInput droolsStream = null;
+ boolean isDrools = in instanceof DroolsObjectInputStream;
+ if (isDrools) {
+ droolsStream = (DroolsObjectInput)in;
+ } else {
+ byte[] bytes = (byte[])in.readObject();
+
+ droolsStream = new DroolsObjectInputStream(new ByteArrayInputStream(bytes));
+ }
droolsStream.setRuleBase( this );
- Map store = (Map) stream.readObject();
+ Map store = (Map) droolsStream.readObject();
this.packageClassLoader = new CompositePackageClassLoader( droolsStream.getClassLoader() );
- this.classLoader = new MapBackedClassLoader( droolsStream.getClassLoader(), store );
+ this.classLoader = new MapBackedClassLoader( this.packageClassLoader, store );
this.packageClassLoader.addClassLoader( this.classLoader );
this.objenesis = createObjenesis();
- droolsStream.setClassLoader(this.packageClassLoader);
+ this.pkgs = (Map) droolsStream.readObject();
- this.pkgs = (Map) stream.readObject();
-
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) stream.readObject();
- this.processes = (Map) stream.readObject();
- this.agendaGroupRuleTotals = (Map) stream.readObject();
- this.factHandleFactory = (FactHandleFactory) stream.readObject();
- this.globals = (Map) stream.readObject();
- this.config = (RuleBaseConfiguration) stream.readObject();
+ this.id = (String) droolsStream.readObject();
+ this.workingMemoryCounter = droolsStream.readInt();
+ this.config = (RuleBaseConfiguration) droolsStream.readObject();
this.config.setClassLoader( droolsStream.getClassLoader() );
- this.eventSupport = (RuleBaseEventSupport) stream.readObject();
+ 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.eventSupport = (RuleBaseEventSupport) droolsStream.readObject();
this.eventSupport.setRuleBase( this );
this.statefulSessions = new ObjectHashSet();
+
+ wms = (InternalWorkingMemory[])droolsStream.readObject();
+ lastAquiredLock = droolsStream.readInt();
+ lock = (ReentrantLock)droolsStream.readObject();
+ additionsSinceLock = droolsStream.readInt();
+ removalsSinceLock = droolsStream.readInt();
+
+ if (!isDrools) {
+ droolsStream.close();
+ }
}
/**
@@ -766,6 +809,14 @@
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();
@@ -784,7 +835,7 @@
public static interface RuleBaseAction
extends
- Serializable {
+ Externalizable {
public void execute(InternalRuleBase ruleBase);
}
}
Modified: labs/jbossrules/branches/ming-serialization/drools-core/src/main/java/org/drools/common/AbstractWorkingMemory.java
===================================================================
--- labs/jbossrules/branches/ming-serialization/drools-core/src/main/java/org/drools/common/AbstractWorkingMemory.java 2008-03-12 20:58:14 UTC (rev 18900)
+++ labs/jbossrules/branches/ming-serialization/drools-core/src/main/java/org/drools/common/AbstractWorkingMemory.java 2008-03-12 21:20:57 UTC (rev 18901)
@@ -22,6 +22,7 @@
import java.io.ObjectOutput;
import java.io.IOException;
import java.io.ObjectInput;
+import java.io.Externalizable;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.util.ArrayList;
@@ -97,7 +98,7 @@
implements
InternalWorkingMemoryActions,
EventSupport,
- PropertyChangeListener {
+ PropertyChangeListener, Externalizable {
// ------------------------------------------------------------
// Constants
// ------------------------------------------------------------
@@ -110,12 +111,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;
@@ -134,26 +135,26 @@
/** 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 final ReentrantLock lock = new ReentrantLock();
+ protected ReentrantLock lock = new ReentrantLock();
- protected final boolean discardOnLogicalOverride;
+ protected boolean discardOnLogicalOverride;
protected long propagationIdCounter;
- private final boolean maintainTms;
+ private boolean maintainTms;
- private final boolean sequential;
+ private boolean sequential;
private List liaPropagations = Collections.EMPTY_LIST;
@@ -173,14 +174,16 @@
private TimeMachine timeMachine = new TimeMachine();
private Map<EntryPoint, Map<Object, ObjectTypeConf>> typeConfMap;
-
+
private EntryPoint entryPoint;
private EntryPointNode entryPointNode;
// ------------------------------------------------------------
// Constructors
// ------------------------------------------------------------
+ public AbstractWorkingMemory() {
+ }
/**
* Construct.
*
@@ -212,7 +215,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;
@@ -223,11 +226,81 @@
new RuleFlowProcessInstanceFactory() );
this.typeConfMap = new ConcurrentHashMap<EntryPoint, Map<Object, ObjectTypeConf>>();
-
+
// this.entryPoint = entryPoint;
// this.entryPointNode = this.ruleBase.getRete().getEntryPointNode( this.entryPoint );
}
+ public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
+ id = in.readLong();
+ evaluatingActionQueue = in.readBoolean();
+ discardOnLogicalOverride = in.readBoolean();
+ propagationIdCounter = in.readLong();
+ 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();
+ typeConfMap = (Map<EntryPoint, Map<Object, ObjectTypeConf>>)in.readObject();
+ entryPoint = (EntryPoint)in.readObject();
+ entryPointNode = (EntryPointNode)in.readObject();
+ }
+
+ public void writeExternal(ObjectOutput out) throws IOException {
+ out.writeLong(id);
+ out.writeBoolean(evaluatingActionQueue);
+ out.writeBoolean(discardOnLogicalOverride);
+ out.writeLong(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(typeConfMap);
+ out.writeObject(entryPoint);
+ out.writeObject(entryPointNode);
+ }
+
// ------------------------------------------------------------
// Instance methods
// ------------------------------------------------------------
@@ -838,7 +911,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,
@@ -1359,7 +1432,7 @@
doRetract( handle,
propagationContext );
- 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
@@ -1718,21 +1791,34 @@
this );
}
- protected static class EntryPointInterfaceImpl
+ public static class EntryPointInterfaceImpl
implements
EntryPointInterface {
private static final long serialVersionUID = 2917871170743358801L;
- private final EntryPoint entryPoint;
- private final AbstractWorkingMemory wm;
+ private EntryPoint entryPoint;
+ private AbstractWorkingMemory wm;
+ public EntryPointInterfaceImpl() {
+
+ }
public EntryPointInterfaceImpl(EntryPoint entryPoint,
AbstractWorkingMemory wm) {
this.entryPoint = entryPoint;
this.wm = wm;
}
+ public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
+ entryPoint = (EntryPoint)in.readObject();
+ wm = (AbstractWorkingMemory)in.readObject();
+ }
+
+ public void writeExternal(ObjectOutput out) throws IOException {
+ out.writeObject(entryPoint);
+ out.writeObject(wm);
+ }
+
public FactHandle insert(Object object) throws FactException {
return wm.insert( this.entryPoint,
object, /* Not-Dynamic */
Modified: labs/jbossrules/branches/ming-serialization/drools-core/src/main/java/org/drools/common/AgendaItem.java
===================================================================
--- labs/jbossrules/branches/ming-serialization/drools-core/src/main/java/org/drools/common/AgendaItem.java 2008-03-12 20:58:14 UTC (rev 18900)
+++ labs/jbossrules/branches/ming-serialization/drools-core/src/main/java/org/drools/common/AgendaItem.java 2008-03-12 21:20:57 UTC (rev 18901)
@@ -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/ming-serialization/drools-core/src/main/java/org/drools/common/ArrayAgendaGroup.java
===================================================================
--- labs/jbossrules/branches/ming-serialization/drools-core/src/main/java/org/drools/common/ArrayAgendaGroup.java 2008-03-12 20:58:14 UTC (rev 18900)
+++ labs/jbossrules/branches/ming-serialization/drools-core/src/main/java/org/drools/common/ArrayAgendaGroup.java 2008-03-12 21:20:57 UTC (rev 18901)
@@ -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/ming-serialization/drools-core/src/main/java/org/drools/common/BaseNode.java
===================================================================
--- labs/jbossrules/branches/ming-serialization/drools-core/src/main/java/org/drools/common/BaseNode.java 2008-03-12 20:58:14 UTC (rev 18900)
+++ labs/jbossrules/branches/ming-serialization/drools-core/src/main/java/org/drools/common/BaseNode.java 2008-03-12 21:20:57 UTC (rev 18901)
@@ -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()
*/
@@ -85,8 +102,8 @@
*/
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;
Modified: labs/jbossrules/branches/ming-serialization/drools-core/src/main/java/org/drools/common/BetaConstraints.java
===================================================================
--- labs/jbossrules/branches/ming-serialization/drools-core/src/main/java/org/drools/common/BetaConstraints.java 2008-03-12 20:58:14 UTC (rev 18900)
+++ labs/jbossrules/branches/ming-serialization/drools-core/src/main/java/org/drools/common/BetaConstraints.java 2008-03-12 21:20:57 UTC (rev 18901)
@@ -1,6 +1,7 @@
package org.drools.common;
import java.io.Serializable;
+import java.io.Externalizable;
import org.drools.RuleBaseConfiguration;
import org.drools.reteoo.BetaMemory;
@@ -10,7 +11,7 @@
public interface BetaConstraints
extends
- Serializable {
+ Externalizable {
public ContextEntry[] createContext();
Modified: labs/jbossrules/branches/ming-serialization/drools-core/src/main/java/org/drools/common/BinaryHeapQueueAgendaGroup.java
===================================================================
--- labs/jbossrules/branches/ming-serialization/drools-core/src/main/java/org/drools/common/BinaryHeapQueueAgendaGroup.java 2008-03-12 20:58:14 UTC (rev 18900)
+++ labs/jbossrules/branches/ming-serialization/drools-core/src/main/java/org/drools/common/BinaryHeapQueueAgendaGroup.java 2008-03-12 21:20:57 UTC (rev 18901)
@@ -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/ming-serialization/drools-core/src/main/java/org/drools/common/ConcurrentNodeMemories.java
===================================================================
--- labs/jbossrules/branches/ming-serialization/drools-core/src/main/java/org/drools/common/ConcurrentNodeMemories.java 2008-03-12 20:58:14 UTC (rev 18900)
+++ labs/jbossrules/branches/ming-serialization/drools-core/src/main/java/org/drools/common/ConcurrentNodeMemories.java 2008-03-12 21:20:57 UTC (rev 18901)
@@ -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/ming-serialization/drools-core/src/main/java/org/drools/common/DefaultAgenda.java
===================================================================
--- labs/jbossrules/branches/ming-serialization/drools-core/src/main/java/org/drools/common/DefaultAgenda.java 2008-03-12 20:58:14 UTC (rev 18900)
+++ labs/jbossrules/branches/ming-serialization/drools-core/src/main/java/org/drools/common/DefaultAgenda.java 2008-03-12 21:20:57 UTC (rev 18901)
@@ -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;
@@ -43,52 +47,52 @@
/**
* 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 +101,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 +140,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 +185,7 @@
/**
* Schedule an agenda item for delayed firing.
- *
+ *
* @param item
* The item to schedule.
*/
@@ -215,7 +252,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 +405,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 +489,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 +556,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/ming-serialization/drools-core/src/main/java/org/drools/common/DefaultBetaConstraints.java
===================================================================
--- labs/jbossrules/branches/ming-serialization/drools-core/src/main/java/org/drools/common/DefaultBetaConstraints.java 2008-03-12 20:58:14 UTC (rev 18900)
+++ labs/jbossrules/branches/ming-serialization/drools-core/src/main/java/org/drools/common/DefaultBetaConstraints.java 2008-03-12 21:20:57 UTC (rev 18901)
@@ -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 java.util.ArrayList;
import java.util.List;
@@ -41,18 +45,20 @@
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 +96,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 +278,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/ming-serialization/drools-core/src/main/java/org/drools/common/DefaultFactHandle.java
===================================================================
--- labs/jbossrules/branches/ming-serialization/drools-core/src/main/java/org/drools/common/DefaultFactHandle.java 2008-03-12 20:58:14 UTC (rev 18900)
+++ labs/jbossrules/branches/ming-serialization/drools-core/src/main/java/org/drools/common/DefaultFactHandle.java 2008-03-12 21:20:57 UTC (rev 18901)
@@ -68,7 +68,6 @@
// ----------------------------------------------------------------------
public DefaultFactHandle() {
-
}
public DefaultFactHandle(final long id,
Modified: labs/jbossrules/branches/ming-serialization/drools-core/src/main/java/org/drools/common/DoubleBetaConstraints.java
===================================================================
--- labs/jbossrules/branches/ming-serialization/drools-core/src/main/java/org/drools/common/DoubleBetaConstraints.java 2008-03-12 20:58:14 UTC (rev 18900)
+++ labs/jbossrules/branches/ming-serialization/drools-core/src/main/java/org/drools/common/DoubleBetaConstraints.java 2008-03-12 21:20:57 UTC (rev 18901)
@@ -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 java.util.ArrayList;
import java.util.List;
@@ -40,20 +44,22 @@
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 +76,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 +100,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 +270,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/ming-serialization/drools-core/src/main/java/org/drools/common/DroolsObjectInputStream.java
===================================================================
--- labs/jbossrules/branches/ming-serialization/drools-core/src/main/java/org/drools/common/DroolsObjectInputStream.java 2008-03-12 20:58:14 UTC (rev 18900)
+++ labs/jbossrules/branches/ming-serialization/drools-core/src/main/java/org/drools/common/DroolsObjectInputStream.java 2008-03-12 21:20:57 UTC (rev 18901)
@@ -11,12 +11,14 @@
import java.io.ObjectInputStream;
import java.io.ObjectStreamClass;
import java.io.ObjectInput;
+import java.io.ByteArrayInputStream;
import java.util.HashMap;
import java.util.Map;
import java.util.Set;
import java.util.Collections;
import java.util.List;
import java.util.Collection;
+import java.util.concurrent.atomic.AtomicReferenceArray;
import java.lang.reflect.Array;
import java.lang.reflect.Constructor;
import java.lang.reflect.InvocationTargetException;
@@ -137,7 +139,6 @@
public DroolsObjectInputStream(InputStream inputStream, ClassLoader classLoader) throws IOException {
dataInput = new DroolsInternalInputStream(inputStream, classLoader);
- setClassLoader(classLoader);
extractorFactory = ClassFieldExtractorCache.getInstance();
readStreamHeader();
}
@@ -211,62 +212,45 @@
public Object readObject() throws ClassNotFoundException, IOException {
byte type = readRecordType();
- Object object;
-
switch (type) {
case RT_NULL:
- object = readNull();
- break;
+ return readNull();
case RT_EMPTY_SET:
- object = readEmptySet();
- break;
+ return readEmptySet();
case RT_EMPTY_LIST:
- object = readEmptyList();
- break;
+ return readEmptyList();
case RT_EMPTY_MAP:
- object = readEmptyMap();
- break;
+ return readEmptyMap();
default:
- object = readObject(type);
+ return readObject(type);
}
-
- return object;
}
private Object readObject(byte type) throws IOException, ClassNotFoundException {
int handle = readHandle();
- Object object;
-
switch (type) {
case RT_EXTERNALIZABLE:
- object = readExternalizable(handle);
- break;
+ return readExternalizable(handle);
case RT_STRING:
- object = readString(handle);
- break;
+ return readString(handle);
case RT_MAP:
- object = readMap(handle);
- break;
+ return readMap(handle);
case RT_COLLECTION:
- object = readCollection(handle);
- break;
+ return readCollection(handle);
case RT_ARRAY:
- object = readArray(handle);
- break;
+ return readArray(handle);
case RT_CLASS:
- object = readClass(handle);
- break;
+ return readClass(handle);
case RT_REFERENCE:
return readReference(handle);
+ case RT_ATOMICREFERENCEARRAY:
+ return readAtomicReferenceArray(handle);
case RT_SERIALIZABLE:
- object = readSerializable();
- break;
+ return readSerializable(handle);
default:
throw new StreamCorruptedException("Unsupported object type: " + type);
}
-
- return object;
}
private Object readArray(int handle) throws IOException, ClassNotFoundException {
@@ -373,8 +357,10 @@
return Collections.EMPTY_MAP;
}
- private Object readSerializable() throws ClassNotFoundException, IOException {
- return dataInput.readObject();
+ 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 {
@@ -398,6 +384,17 @@
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();
@@ -432,7 +429,12 @@
} catch (InvocationTargetException e) {
throw newInvalidClassException(clazz, e);
} catch (NoSuchMethodException e) {
- throw newInvalidClassException(clazz, e);
+ try {
+ Constructor constructor = clazz.getConstructor();
+ collection = constructor.newInstance();
+ } catch (Exception e2) {
+ throw newInvalidClassException(clazz, e2);
+ }
}
registerObject(handle, collection);
return collection;
@@ -478,6 +480,9 @@
Class clazz = primClasses.get( className );
if ( clazz == null ) {
clazz = getClassLoader().loadClass( className );
+ if (className.endsWith("ShadowProxy")) {
+ System.out.println();
+ }
}
return clazz;
}
Modified: labs/jbossrules/branches/ming-serialization/drools-core/src/main/java/org/drools/common/DroolsObjectOutputStream.java
===================================================================
--- labs/jbossrules/branches/ming-serialization/drools-core/src/main/java/org/drools/common/DroolsObjectOutputStream.java 2008-03-12 20:58:14 UTC (rev 18900)
+++ labs/jbossrules/branches/ming-serialization/drools-core/src/main/java/org/drools/common/DroolsObjectOutputStream.java 2008-03-12 21:20:57 UTC (rev 18901)
@@ -7,10 +7,12 @@
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;
/**
*
@@ -57,6 +59,8 @@
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 {
@@ -182,17 +186,17 @@
writeObjectOrReference(clazz.getName(), String.class);
}
- private void writeReference(int handle) throws IOException {
- writeRecordType(RT_REFERENCE);
- writeHandle(handle);
- }
-
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);
@@ -206,6 +210,14 @@
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);
Modified: labs/jbossrules/branches/ming-serialization/drools-core/src/main/java/org/drools/common/DroolsObjectStreamConstants.java
===================================================================
--- labs/jbossrules/branches/ming-serialization/drools-core/src/main/java/org/drools/common/DroolsObjectStreamConstants.java 2008-03-12 20:58:14 UTC (rev 18900)
+++ labs/jbossrules/branches/ming-serialization/drools-core/src/main/java/org/drools/common/DroolsObjectStreamConstants.java 2008-03-12 21:20:57 UTC (rev 18901)
@@ -16,4 +16,5 @@
byte RT_NULL = 20;
byte RT_COLLECTION = 21;
byte RT_EXTERNALIZABLE = 22;
+ byte RT_ATOMICREFERENCEARRAY = 30;
}
Modified: labs/jbossrules/branches/ming-serialization/drools-core/src/main/java/org/drools/common/EmptyBetaConstraints.java
===================================================================
--- labs/jbossrules/branches/ming-serialization/drools-core/src/main/java/org/drools/common/EmptyBetaConstraints.java 2008-03-12 20:58:14 UTC (rev 18900)
+++ labs/jbossrules/branches/ming-serialization/drools-core/src/main/java/org/drools/common/EmptyBetaConstraints.java 2008-03-12 21:20:57 UTC (rev 18901)
@@ -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.ObjectInput;
+import java.io.IOException;
import org.drools.RuleBaseConfiguration;
import org.drools.reteoo.BetaMemory;
@@ -30,7 +34,6 @@
public class EmptyBetaConstraints
implements
- Serializable,
BetaConstraints {
private static final BetaConstraints INSTANCE = new EmptyBetaConstraints();
@@ -41,13 +44,20 @@
}
/**
- *
+ *
*/
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 +130,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/ming-serialization/drools-core/src/main/java/org/drools/common/EqualityAssertMapComparator.java
===================================================================
--- labs/jbossrules/branches/ming-serialization/drools-core/src/main/java/org/drools/common/EqualityAssertMapComparator.java 2008-03-12 20:58:14 UTC (rev 18900)
+++ labs/jbossrules/branches/ming-serialization/drools-core/src/main/java/org/drools/common/EqualityAssertMapComparator.java 2008-03-12 21:20:57 UTC (rev 18901)
@@ -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/ming-serialization/drools-core/src/main/java/org/drools/common/EqualityKey.java
===================================================================
--- labs/jbossrules/branches/ming-serialization/drools-core/src/main/java/org/drools/common/EqualityKey.java 2008-03-12 20:58:14 UTC (rev 18900)
+++ labs/jbossrules/branches/ming-serialization/drools-core/src/main/java/org/drools/common/EqualityKey.java 2008-03-12 21:20:57 UTC (rev 18901)
@@ -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/ming-serialization/drools-core/src/main/java/org/drools/common/EqualityKeyComparator.java
===================================================================
--- labs/jbossrules/branches/ming-serialization/drools-core/src/main/java/org/drools/common/EqualityKeyComparator.java 2008-03-12 20:58:14 UTC (rev 18900)
+++ labs/jbossrules/branches/ming-serialization/drools-core/src/main/java/org/drools/common/EqualityKeyComparator.java 2008-03-12 21:20:57 UTC (rev 18901)
@@ -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/ming-serialization/drools-core/src/main/java/org/drools/common/EventFactHandle.java
===================================================================
--- labs/jbossrules/branches/ming-serialization/drools-core/src/main/java/org/drools/common/EventFactHandle.java 2008-03-12 20:58:14 UTC (rev 18900)
+++ labs/jbossrules/branches/ming-serialization/drools-core/src/main/java/org/drools/common/EventFactHandle.java 2008-03-12 21:20:57 UTC (rev 18901)
@@ -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,28 +46,42 @@
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
* @param timestamp the timestamp of the occurrence of this event
* @param duration the duration of this event. May be 0 (zero) in case this is a primitive event.
*/
- public EventFactHandle( final long id,
+ public EventFactHandle( final long id,
final Object object,
final long recency,
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/ming-serialization/drools-core/src/main/java/org/drools/common/IdentityAssertMapComparator.java
===================================================================
--- labs/jbossrules/branches/ming-serialization/drools-core/src/main/java/org/drools/common/IdentityAssertMapComparator.java 2008-03-12 20:58:14 UTC (rev 18900)
+++ labs/jbossrules/branches/ming-serialization/drools-core/src/main/java/org/drools/common/IdentityAssertMapComparator.java 2008-03-12 21:20:57 UTC (rev 18901)
@@ -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/ming-serialization/drools-core/src/main/java/org/drools/common/InstanceEqualsConstraint.java
===================================================================
--- labs/jbossrules/branches/ming-serialization/drools-core/src/main/java/org/drools/common/InstanceEqualsConstraint.java 2008-03-12 20:58:14 UTC (rev 18900)
+++ labs/jbossrules/branches/ming-serialization/drools-core/src/main/java/org/drools/common/InstanceEqualsConstraint.java 2008-03-12 21:20:57 UTC (rev 18901)
@@ -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/ming-serialization/drools-core/src/main/java/org/drools/common/InstanceNotEqualsConstraint.java
===================================================================
--- labs/jbossrules/branches/ming-serialization/drools-core/src/main/java/org/drools/common/InstanceNotEqualsConstraint.java 2008-03-12 20:58:14 UTC (rev 18900)
+++ labs/jbossrules/branches/ming-serialization/drools-core/src/main/java/org/drools/common/InstanceNotEqualsConstraint.java 2008-03-12 21:20:57 UTC (rev 18901)
@@ -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/ming-serialization/drools-core/src/main/java/org/drools/common/InternalWorkingMemoryActions.java
===================================================================
--- labs/jbossrules/branches/ming-serialization/drools-core/src/main/java/org/drools/common/InternalWorkingMemoryActions.java 2008-03-12 20:58:14 UTC (rev 18900)
+++ labs/jbossrules/branches/ming-serialization/drools-core/src/main/java/org/drools/common/InternalWorkingMemoryActions.java 2008-03-12 21:20:57 UTC (rev 18901)
@@ -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,8 @@
import org.drools.rule.Rule;
import org.drools.spi.Activation;
+import java.io.Externalizable;
+
public interface InternalWorkingMemoryActions
extends
InternalWorkingMemory {
@@ -40,20 +42,20 @@
boolean logical,
Rule rule,
Activation activation) throws FactException;*/
-
+
FactHandle insert(Object object,
- long duration,
- boolean dynamic,
- boolean logical,
- Rule rule,
- Activation activation) throws FactException;
+ long duration,
+ boolean dynamic,
+ boolean logical,
+ Rule rule,
+ Activation activation) throws FactException;
/*public FactHandle insertLogical(Object object,
boolean dynamic) throws FactException;*/
-
+
public FactHandle insertLogical(Object object,
- long duration,
- boolean dynamic) throws FactException;
+ long duration,
+ boolean dynamic) throws FactException;
public void modifyRetract(final FactHandle factHandle,
final Rule rule,
@@ -63,5 +65,5 @@
final Object object,
final Rule rule,
final Activation activation);
-
+
}
\ No newline at end of file
Modified: labs/jbossrules/branches/ming-serialization/drools-core/src/main/java/org/drools/common/NetworkNode.java
===================================================================
--- labs/jbossrules/branches/ming-serialization/drools-core/src/main/java/org/drools/common/NetworkNode.java 2008-03-12 20:58:14 UTC (rev 18900)
+++ labs/jbossrules/branches/ming-serialization/drools-core/src/main/java/org/drools/common/NetworkNode.java 2008-03-12 21:20:57 UTC (rev 18901)
@@ -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/ming-serialization/drools-core/src/main/java/org/drools/common/NodeMemories.java
===================================================================
--- labs/jbossrules/branches/ming-serialization/drools-core/src/main/java/org/drools/common/NodeMemories.java 2008-03-12 20:58:14 UTC (rev 18900)
+++ labs/jbossrules/branches/ming-serialization/drools-core/src/main/java/org/drools/common/NodeMemories.java 2008-03-12 21:20:57 UTC (rev 18901)
@@ -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,16 +19,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/ming-serialization/drools-core/src/main/java/org/drools/common/PriorityQueueAgendaGroupFactory.java
===================================================================
--- labs/jbossrules/branches/ming-serialization/drools-core/src/main/java/org/drools/common/PriorityQueueAgendaGroupFactory.java 2008-03-12 20:58:14 UTC (rev 18900)
+++ labs/jbossrules/branches/ming-serialization/drools-core/src/main/java/org/drools/common/PriorityQueueAgendaGroupFactory.java 2008-03-12 21:20:57 UTC (rev 18901)
@@ -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/ming-serialization/drools-core/src/main/java/org/drools/common/PropagationContextImpl.java
===================================================================
--- labs/jbossrules/branches/ming-serialization/drools-core/src/main/java/org/drools/common/PropagationContextImpl.java 2008-03-12 20:58:14 UTC (rev 18900)
+++ labs/jbossrules/branches/ming-serialization/drools-core/src/main/java/org/drools/common/PropagationContextImpl.java 2008-03-12 21:20:57 UTC (rev 18901)
@@ -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/ming-serialization/drools-core/src/main/java/org/drools/common/QuadroupleBetaConstraints.java
===================================================================
--- labs/jbossrules/branches/ming-serialization/drools-core/src/main/java/org/drools/common/QuadroupleBetaConstraints.java 2008-03-12 20:58:14 UTC (rev 18900)
+++ labs/jbossrules/branches/ming-serialization/drools-core/src/main/java/org/drools/common/QuadroupleBetaConstraints.java 2008-03-12 21:20:57 UTC (rev 18901)
@@ -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 java.util.ArrayList;
import java.util.List;
@@ -40,24 +44,26 @@
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 +82,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 +147,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 +373,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/ming-serialization/drools-core/src/main/java/org/drools/common/RuleFlowGroupImpl.java
===================================================================
--- labs/jbossrules/branches/ming-serialization/drools-core/src/main/java/org/drools/common/RuleFlowGroupImpl.java 2008-03-12 20:58:14 UTC (rev 18900)
+++ labs/jbossrules/branches/ming-serialization/drools-core/src/main/java/org/drools/common/RuleFlowGroupImpl.java 2008-03-12 21:20:57 UTC (rev 18901)
@@ -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/ming-serialization/drools-core/src/main/java/org/drools/common/ScheduledAgendaItem.java
===================================================================
--- labs/jbossrules/branches/ming-serialization/drools-core/src/main/java/org/drools/common/ScheduledAgendaItem.java 2008-03-12 20:58:14 UTC (rev 18900)
+++ labs/jbossrules/branches/ming-serialization/drools-core/src/main/java/org/drools/common/ScheduledAgendaItem.java 2008-03-12 21:20:57 UTC (rev 18901)
@@ -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/ming-serialization/drools-core/src/main/java/org/drools/common/SequentialAgendaGroupImpl.java
===================================================================
--- labs/jbossrules/branches/ming-serialization/drools-core/src/main/java/org/drools/common/SequentialAgendaGroupImpl.java 2008-03-12 20:58:14 UTC (rev 18900)
+++ labs/jbossrules/branches/ming-serialization/drools-core/src/main/java/org/drools/common/SequentialAgendaGroupImpl.java 2008-03-12 21:20:57 UTC (rev 18901)
@@ -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/ming-serialization/drools-core/src/main/java/org/drools/common/SingleBetaConstraints.java
===================================================================
--- labs/jbossrules/branches/ming-serialization/drools-core/src/main/java/org/drools/common/SingleBetaConstraints.java 2008-03-12 20:58:14 UTC (rev 18900)
+++ labs/jbossrules/branches/ming-serialization/drools-core/src/main/java/org/drools/common/SingleBetaConstraints.java 2008-03-12 21:20:57 UTC (rev 18901)
@@ -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/ming-serialization/drools-core/src/main/java/org/drools/common/SingleThreadedObjectStore.java
===================================================================
--- labs/jbossrules/branches/ming-serialization/drools-core/src/main/java/org/drools/common/SingleThreadedObjectStore.java 2008-03-12 20:58:14 UTC (rev 18900)
+++ labs/jbossrules/branches/ming-serialization/drools-core/src/main/java/org/drools/common/SingleThreadedObjectStore.java 2008-03-12 21:20:57 UTC (rev 18901)
@@ -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/ming-serialization/drools-core/src/main/java/org/drools/common/TripleBetaConstraints.java
===================================================================
--- labs/jbossrules/branches/ming-serialization/drools-core/src/main/java/org/drools/common/TripleBetaConstraints.java 2008-03-12 20:58:14 UTC (rev 18900)
+++ labs/jbossrules/branches/ming-serialization/drools-core/src/main/java/org/drools/common/TripleBetaConstraints.java 2008-03-12 21:20:57 UTC (rev 18901)
@@ -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/ming-serialization/drools-core/src/main/java/org/drools/common/TruthMaintenanceSystem.java
===================================================================
--- labs/jbossrules/branches/ming-serialization/drools-core/src/main/java/org/drools/common/TruthMaintenanceSystem.java 2008-03-12 20:58:14 UTC (rev 18900)
+++ labs/jbossrules/branches/ming-serialization/drools-core/src/main/java/org/drools/common/TruthMaintenanceSystem.java 2008-03-12 21:20:57 UTC (rev 18901)
@@ -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/ming-serialization/drools-core/src/main/java/org/drools/common/TupleStartEqualsConstraint.java
===================================================================
--- labs/jbossrules/branches/ming-serialization/drools-core/src/main/java/org/drools/common/TupleStartEqualsConstraint.java 2008-03-12 20:58:14 UTC (rev 18900)
+++ labs/jbossrules/branches/ming-serialization/drools-core/src/main/java/org/drools/common/TupleStartEqualsConstraint.java 2008-03-12 21:20:57 UTC (rev 18901)
@@ -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/ming-serialization/drools-core/src/main/java/org/drools/common/WorkingMemoryAction.java
===================================================================
--- labs/jbossrules/branches/ming-serialization/drools-core/src/main/java/org/drools/common/WorkingMemoryAction.java 2008-03-12 20:58:14 UTC (rev 18900)
+++ labs/jbossrules/branches/ming-serialization/drools-core/src/main/java/org/drools/common/WorkingMemoryAction.java 2008-03-12 21:20:57 UTC (rev 18901)
@@ -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/ming-serialization/drools-core/src/main/java/org/drools/conflict/DepthConflictResolver.java
===================================================================
--- labs/jbossrules/branches/ming-serialization/drools-core/src/main/java/org/drools/conflict/DepthConflictResolver.java 2008-03-12 20:58:14 UTC (rev 18900)
+++ labs/jbossrules/branches/ming-serialization/drools-core/src/main/java/org/drools/conflict/DepthConflictResolver.java 2008-03-12 21:20:57 UTC (rev 18901)
@@ -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/ming-serialization/drools-core/src/main/java/org/drools/event/AgendaEventSupport.java
===================================================================
--- labs/jbossrules/branches/ming-serialization/drools-core/src/main/java/org/drools/event/AgendaEventSupport.java 2008-03-12 20:58:14 UTC (rev 18900)
+++ labs/jbossrules/branches/ming-serialization/drools-core/src/main/java/org/drools/event/AgendaEventSupport.java 2008-03-12 21:20:57 UTC (rev 18901)
@@ -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/ming-serialization/drools-core/src/main/java/org/drools/event/RuleBaseEventSupport.java
===================================================================
--- labs/jbossrules/branches/ming-serialization/drools-core/src/main/java/org/drools/event/RuleBaseEventSupport.java 2008-03-12 20:58:14 UTC (rev 18900)
+++ labs/jbossrules/branches/ming-serialization/drools-core/src/main/java/org/drools/event/RuleBaseEventSupport.java 2008-03-12 21:20:57 UTC (rev 18901)
@@ -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/ming-serialization/drools-core/src/main/java/org/drools/event/RuleFlowEventSupport.java
===================================================================
--- labs/jbossrules/branches/ming-serialization/drools-core/src/main/java/org/drools/event/RuleFlowEventSupport.java 2008-03-12 20:58:14 UTC (rev 18900)
+++ labs/jbossrules/branches/ming-serialization/drools-core/src/main/java/org/drools/event/RuleFlowEventSupport.java 2008-03-12 21:20:57 UTC (rev 18901)
@@ -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/ming-serialization/drools-core/src/main/java/org/drools/event/WorkingMemoryEventSupport.java
===================================================================
--- labs/jbossrules/branches/ming-serialization/drools-core/src/main/java/org/drools/event/WorkingMemoryEventSupport.java 2008-03-12 20:58:14 UTC (rev 18900)
+++ labs/jbossrules/branches/ming-serialization/drools-core/src/main/java/org/drools/event/WorkingMemoryEventSupport.java 2008-03-12 21:20:57 UTC (rev 18901)
@@ -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/ming-serialization/drools-core/src/main/java/org/drools/facttemplates/FactTemplate.java
===================================================================
--- labs/jbossrules/branches/ming-serialization/drools-core/src/main/java/org/drools/facttemplates/FactTemplate.java 2008-03-12 20:58:14 UTC (rev 18900)
+++ labs/jbossrules/branches/ming-serialization/drools-core/src/main/java/org/drools/facttemplates/FactTemplate.java 2008-03-12 21:20:57 UTC (rev 18901)
@@ -12,11 +12,12 @@
* 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 +30,7 @@
*/
public interface FactTemplate
extends
- Serializable {
+ Externalizable {
Package getPackage();
Modified: labs/jbossrules/branches/ming-serialization/drools-core/src/main/java/org/drools/facttemplates/FactTemplateFieldExtractor.java
===================================================================
--- labs/jbossrules/branches/ming-serialization/drools-core/src/main/java/org/drools/facttemplates/FactTemplateFieldExtractor.java 2008-03-12 20:58:14 UTC (rev 18900)
+++ labs/jbossrules/branches/ming-serialization/drools-core/src/main/java/org/drools/facttemplates/FactTemplateFieldExtractor.java 2008-03-12 21:20:57 UTC (rev 18901)
@@ -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/ming-serialization/drools-core/src/main/java/org/drools/facttemplates/FactTemplateImpl.java
===================================================================
--- labs/jbossrules/branches/ming-serialization/drools-core/src/main/java/org/drools/facttemplates/FactTemplateImpl.java 2008-03-12 20:58:14 UTC (rev 18900)
+++ labs/jbossrules/branches/ming-serialization/drools-core/src/main/java/org/drools/facttemplates/FactTemplateImpl.java 2008-03-12 21:20:57 UTC (rev 18901)
@@ -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/ming-serialization/drools-core/src/main/java/org/drools/facttemplates/FactTemplateObjectType.java
===================================================================
--- labs/jbossrules/branches/ming-serialization/drools-core/src/main/java/org/drools/facttemplates/FactTemplateObjectType.java 2008-03-12 20:58:14 UTC (rev 18900)
+++ labs/jbossrules/branches/ming-serialization/drools-core/src/main/java/org/drools/facttemplates/FactTemplateObjectType.java 2008-03-12 21:20:57 UTC (rev 18901)
@@ -50,7 +50,10 @@
// ------------------------------------------------------------
// Constructors
// ------------------------------------------------------------
+ public FactTemplateObjectType() {
+ }
+
/**
* Construct.
*
Modified: labs/jbossrules/branches/ming-serialization/drools-core/src/main/java/org/drools/facttemplates/FieldTemplateImpl.java
===================================================================
--- labs/jbossrules/branches/ming-serialization/drools-core/src/main/java/org/drools/facttemplates/FieldTemplateImpl.java 2008-03-12 20:58:14 UTC (rev 18900)
+++ labs/jbossrules/branches/ming-serialization/drools-core/src/main/java/org/drools/facttemplates/FieldTemplateImpl.java 2008-03-12 21:20:57 UTC (rev 18901)
@@ -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,17 @@
this.valueType = ValueType.determineValueType( clazz );
}
+ public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
+ name = (String)in.readObject();
+ index = in.readInt();
+ valueType = (ValueType)in.readObject();
+ }
+
+ 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/ming-serialization/drools-core/src/main/java/org/drools/process/instance/WorkItemManager.java
===================================================================
--- labs/jbossrules/branches/ming-serialization/drools-core/src/main/java/org/drools/process/instance/WorkItemManager.java 2008-03-12 20:58:14 UTC (rev 18900)
+++ labs/jbossrules/branches/ming-serialization/drools-core/src/main/java/org/drools/process/instance/WorkItemManager.java 2008-03-12 21:20:57 UTC (rev 18901)
@@ -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/ming-serialization/drools-core/src/main/java/org/drools/reteoo/AccumulateNode.java
===================================================================
--- labs/jbossrules/branches/ming-serialization/drools-core/src/main/java/org/drools/reteoo/AccumulateNode.java 2008-03-12 20:58:14 UTC (rev 18900)
+++ labs/jbossrules/branches/ming-serialization/drools-core/src/main/java/org/drools/reteoo/AccumulateNode.java 2008-03-12 21:20:57 UTC (rev 18901)
@@ -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,9 @@
package org.drools.reteoo;
import java.util.Arrays;
+import java.io.IOException;
+import java.io.ObjectInput;
+import java.io.ObjectOutput;
import org.drools.RuleBaseConfiguration;
import org.drools.RuntimeDroolsException;
@@ -39,7 +42,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 +50,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 +78,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 +147,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 +163,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 +210,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 +231,7 @@
context,
workingMemory );
- // Destroying the acumulate result object
+ // Destroying the acumulate result object
workingMemory.getFactHandleFactory().destroyFactHandle( accresult.handle );
}
@@ -217,12 +239,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 +285,13 @@
}
}
}
-
+
this.constraints.resetFactHandle( memory.betaMemory.getContext() );
}
/**
* @inheritDoc
- *
+ *
* If an object is retract, call modify tuple for each
* tuple match.
*/
@@ -306,7 +328,7 @@
}
}
}
-
+
this.constraints.resetFactHandle( memory.betaMemory.getContext() );
}
@@ -326,7 +348,7 @@
context,
workingMemory );
- // Destroying the acumulate result object
+ // Destroying the acumulate result object
workingMemory.getFactHandleFactory().destroyFactHandle( accresult.handle );
accresult.handle = null;
}
@@ -356,8 +378,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 +439,7 @@
} else {
workingMemory.getFactHandleFactory().destroyFactHandle( createdHandle );
}
-
+
this.resultBinder.resetTuple( memory.resultsContext );
} else {
workingMemory.getFactHandleFactory().destroyFactHandle( createdHandle );
@@ -490,7 +512,7 @@
public static class AccumulateMemory {
private static final long serialVersionUID = 400L;
-
+
public Object workingMemoryContext;
public BetaMemory betaMemory;
public ContextEntry[] resultsContext;
@@ -501,5 +523,5 @@
// keeping attributes public just for performance
public InternalFactHandle handle;
public Object context;
- }
+ }
}
Modified: labs/jbossrules/branches/ming-serialization/drools-core/src/main/java/org/drools/reteoo/AlphaNode.java
===================================================================
--- labs/jbossrules/branches/ming-serialization/drools-core/src/main/java/org/drools/reteoo/AlphaNode.java 2008-03-12 20:58:14 UTC (rev 18900)
+++ labs/jbossrules/branches/ming-serialization/drools-core/src/main/java/org/drools/reteoo/AlphaNode.java 2008-03-12 21:20:57 UTC (rev 18901)
@@ -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/ming-serialization/drools-core/src/main/java/org/drools/reteoo/BetaMemory.java
===================================================================
--- labs/jbossrules/branches/ming-serialization/drools-core/src/main/java/org/drools/reteoo/BetaMemory.java 2008-03-12 20:58:14 UTC (rev 18900)
+++ labs/jbossrules/branches/ming-serialization/drools-core/src/main/java/org/drools/reteoo/BetaMemory.java 2008-03-12 21:20:57 UTC (rev 18901)
@@ -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/ming-serialization/drools-core/src/main/java/org/drools/reteoo/BetaNode.java
===================================================================
--- labs/jbossrules/branches/ming-serialization/drools-core/src/main/java/org/drools/reteoo/BetaNode.java 2008-03-12 20:58:14 UTC (rev 18900)
+++ labs/jbossrules/branches/ming-serialization/drools-core/src/main/java/org/drools/reteoo/BetaNode.java 2008-03-12 21:20:57 UTC (rev 18901)
@@ -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();
@@ -170,7 +202,7 @@
}
this.rightInput.remove( context,
builder,
- this,
+ this,
workingMemories );
if( !context.alreadyVisited( this.leftInput )) {
this.leftInput.remove( context,
@@ -188,14 +220,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 +279,7 @@
}
/**
- * Sets the next node
+ * Sets the next node
* @param next
* The next TupleSinkNode
*/
@@ -265,7 +297,7 @@
}
/**
- * Sets the previous node
+ * Sets the previous node
* @param previous
* The previous TupleSinkNode
*/
@@ -283,7 +315,7 @@
}
/**
- * Sets the next node
+ * Sets the next node
* @param next
* The next ObjectSinkNode
*/
@@ -301,7 +333,7 @@
}
/**
- * Sets the previous node
+ * Sets the previous node
* @param previous
* The previous ObjectSinkNode
*/
Modified: labs/jbossrules/branches/ming-serialization/drools-core/src/main/java/org/drools/reteoo/ClassObjectTypeConf.java
===================================================================
--- labs/jbossrules/branches/ming-serialization/drools-core/src/main/java/org/drools/reteoo/ClassObjectTypeConf.java 2008-03-12 20:58:14 UTC (rev 18900)
+++ labs/jbossrules/branches/ming-serialization/drools-core/src/main/java/org/drools/reteoo/ClassObjectTypeConf.java 2008-03-12 21:20:57 UTC (rev 18901)
@@ -229,7 +229,8 @@
public void readExternal(ObjectInput stream) throws IOException,
ClassNotFoundException {
- this.ruleBase = ((DroolsObjectInput) stream).getRuleBase();
+ this.ruleBase = ((DroolsObjectInput) stream).getRuleBase();
+
cls = (Class)stream.readObject();
objectTypeNodes = (ObjectTypeNode[])stream.readObject();
shadowEnabled = stream.readBoolean();
@@ -238,7 +239,7 @@
entryPoint = (EntryPoint)stream.readObject();
defineShadowProxyData(cls);
}
-
+
public void writeExternal(ObjectOutput stream) throws IOException {
stream.writeObject(cls);
stream.writeObject(objectTypeNodes);
Modified: labs/jbossrules/branches/ming-serialization/drools-core/src/main/java/org/drools/reteoo/CollectNode.java
===================================================================
--- labs/jbossrules/branches/ming-serialization/drools-core/src/main/java/org/drools/reteoo/CollectNode.java 2008-03-12 20:58:14 UTC (rev 18900)
+++ labs/jbossrules/branches/ming-serialization/drools-core/src/main/java/org/drools/reteoo/CollectNode.java 2008-03-12 21:20:57 UTC (rev 18901)
@@ -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/ming-serialization/drools-core/src/main/java/org/drools/reteoo/CompositeObjectSinkAdapter.java
===================================================================
--- labs/jbossrules/branches/ming-serialization/drools-core/src/main/java/org/drools/reteoo/CompositeObjectSinkAdapter.java 2008-03-12 20:58:14 UTC (rev 18900)
+++ labs/jbossrules/branches/ming-serialization/drools-core/src/main/java/org/drools/reteoo/CompositeObjectSinkAdapter.java 2008-03-12 21:20:57 UTC (rev 18901)
@@ -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/ming-serialization/drools-core/src/main/java/org/drools/reteoo/CompositeTupleSinkAdapter.java
===================================================================
--- labs/jbossrules/branches/ming-serialization/drools-core/src/main/java/org/drools/reteoo/CompositeTupleSinkAdapter.java 2008-03-12 20:58:14 UTC (rev 18900)
+++ labs/jbossrules/branches/ming-serialization/drools-core/src/main/java/org/drools/reteoo/CompositeTupleSinkAdapter.java 2008-03-12 21:20:57 UTC (rev 18901)
@@ -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/ming-serialization/drools-core/src/main/java/org/drools/reteoo/EmptyObjectSinkAdapter.java
===================================================================
--- labs/jbossrules/branches/ming-serialization/drools-core/src/main/java/org/drools/reteoo/EmptyObjectSinkAdapter.java 2008-03-12 20:58:14 UTC (rev 18900)
+++ labs/jbossrules/branches/ming-serialization/drools-core/src/main/java/org/drools/reteoo/EmptyObjectSinkAdapter.java 2008-03-12 21:20:57 UTC (rev 18901)
@@ -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,7 +46,7 @@
public ObjectSink[] getSinks() {
return SINK_LIST;
}
-
+
public int size() {
return 0;
}
Modified: labs/jbossrules/branches/ming-serialization/drools-core/src/main/java/org/drools/reteoo/EmptyTupleSinkAdapter.java
===================================================================
--- labs/jbossrules/branches/ming-serialization/drools-core/src/main/java/org/drools/reteoo/EmptyTupleSinkAdapter.java 2008-03-12 20:58:14 UTC (rev 18900)
+++ labs/jbossrules/branches/ming-serialization/drools-core/src/main/java/org/drools/reteoo/EmptyTupleSinkAdapter.java 2008-03-12 21:20:57 UTC (rev 18901)
@@ -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/ming-serialization/drools-core/src/main/java/org/drools/reteoo/EntryPointNode.java
===================================================================
--- labs/jbossrules/branches/ming-serialization/drools-core/src/main/java/org/drools/reteoo/EntryPointNode.java 2008-03-12 20:58:14 UTC (rev 18900)
+++ labs/jbossrules/branches/ming-serialization/drools-core/src/main/java/org/drools/reteoo/EntryPointNode.java 2008-03-12 21:20:57 UTC (rev 18901)
@@ -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;
@@ -39,19 +42,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
@@ -62,17 +65,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) {
@@ -95,6 +101,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
*/
@@ -273,7 +290,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/ming-serialization/drools-core/src/main/java/org/drools/reteoo/EvalConditionNode.java
===================================================================
--- labs/jbossrules/branches/ming-serialization/drools-core/src/main/java/org/drools/reteoo/EvalConditionNode.java 2008-03-12 20:58:14 UTC (rev 18900)
+++ labs/jbossrules/branches/ming-serialization/drools-core/src/main/java/org/drools/reteoo/EvalConditionNode.java 2008-03-12 21:20:57 UTC (rev 18901)
@@ -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,19 @@
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();
+ }
+
+ public void writeExternal(ObjectOutput out) throws IOException {
+ super.writeExternal(out);
+ out.writeObject(condition);
+ out.writeObject(tupleSource);
+ out.writeBoolean(tupleMemoryEnabled);
+ }
/**
* Attaches this node into the network.
*/
@@ -119,7 +138,7 @@
/**
* Retrieve the <code>Test</code> associated with this node.
- *
+ *
* @return The <code>Test</code>.
*/
public EvalCondition getCondition() {
@@ -132,7 +151,7 @@
/**
* Assert a new <code>Tuple</code>.
- *
+ *
* @param tuple
* The <code>Tuple</code> being asserted.
* @param workingMemory
@@ -176,7 +195,7 @@
/**
* Produce a debug string.
- *
+ *
* @return The debug string.
*/
public String toString() {
@@ -202,7 +221,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 +261,14 @@
workingMemories );
}
}
-
+
public boolean isTupleMemoryEnabled() {
return tupleMemoryEnabled;
}
public void setTupleMemoryEnabled(boolean tupleMemoryEnabled) {
this.tupleMemoryEnabled = tupleMemoryEnabled;
- }
+ }
/**
* Returns the next node
@@ -261,7 +280,7 @@
}
/**
- * Sets the next node
+ * Sets the next node
* @param next
* The next TupleSinkNode
*/
@@ -279,27 +298,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/ming-serialization/drools-core/src/main/java/org/drools/reteoo/ExistsNode.java
===================================================================
--- labs/jbossrules/branches/ming-serialization/drools-core/src/main/java/org/drools/reteoo/ExistsNode.java 2008-03-12 20:58:14 UTC (rev 18900)
+++ labs/jbossrules/branches/ming-serialization/drools-core/src/main/java/org/drools/reteoo/ExistsNode.java 2008-03-12 21:20:57 UTC (rev 18901)
@@ -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/ming-serialization/drools-core/src/main/java/org/drools/reteoo/FactTemplateTypeConf.java
===================================================================
--- labs/jbossrules/branches/ming-serialization/drools-core/src/main/java/org/drools/reteoo/FactTemplateTypeConf.java 2008-03-12 20:58:14 UTC (rev 18900)
+++ labs/jbossrules/branches/ming-serialization/drools-core/src/main/java/org/drools/reteoo/FactTemplateTypeConf.java 2008-03-12 21:20:57 UTC (rev 18901)
@@ -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/ming-serialization/drools-core/src/main/java/org/drools/reteoo/FromNode.java
===================================================================
--- labs/jbossrules/branches/ming-serialization/drools-core/src/main/java/org/drools/reteoo/FromNode.java 2008-03-12 20:58:14 UTC (rev 18900)
+++ labs/jbossrules/branches/ming-serialization/drools-core/src/main/java/org/drools/reteoo/FromNode.java 2008-03-12 21:20:57 UTC (rev 18901)
@@ -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,
@@ -227,7 +254,7 @@
}
/**
- * Sets the next node
+ * Sets the next node
* @param next
* The next TupleSinkNode
*/
@@ -245,7 +272,7 @@
}
/**
- * Sets the previous node
+ * Sets the previous node
* @param previous
* The previous TupleSinkNode
*/
Modified: labs/jbossrules/branches/ming-serialization/drools-core/src/main/java/org/drools/reteoo/InitialFactHandle.java
===================================================================
--- labs/jbossrules/branches/ming-serialization/drools-core/src/main/java/org/drools/reteoo/InitialFactHandle.java 2008-03-12 20:58:14 UTC (rev 18900)
+++ labs/jbossrules/branches/ming-serialization/drools-core/src/main/java/org/drools/reteoo/InitialFactHandle.java 2008-03-12 21:20:57 UTC (rev 18901)
@@ -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/ming-serialization/drools-core/src/main/java/org/drools/reteoo/InitialFactImpl.java
===================================================================
--- labs/jbossrules/branches/ming-serialization/drools-core/src/main/java/org/drools/reteoo/InitialFactImpl.java 2008-03-12 20:58:14 UTC (rev 18900)
+++ labs/jbossrules/branches/ming-serialization/drools-core/src/main/java/org/drools/reteoo/InitialFactImpl.java 2008-03-12 21:20:57 UTC (rev 18901)
@@ -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/ming-serialization/drools-core/src/main/java/org/drools/reteoo/JoinNode.java
===================================================================
--- labs/jbossrules/branches/ming-serialization/drools-core/src/main/java/org/drools/reteoo/JoinNode.java 2008-03-12 20:58:14 UTC (rev 18900)
+++ labs/jbossrules/branches/ming-serialization/drools-core/src/main/java/org/drools/reteoo/JoinNode.java 2008-03-12 21:20:57 UTC (rev 18901)
@@ -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/ming-serialization/drools-core/src/main/java/org/drools/reteoo/LIANodePropagation.java
===================================================================
--- labs/jbossrules/branches/ming-serialization/drools-core/src/main/java/org/drools/reteoo/LIANodePropagation.java 2008-03-12 20:58:14 UTC (rev 18900)
+++ labs/jbossrules/branches/ming-serialization/drools-core/src/main/java/org/drools/reteoo/LIANodePropagation.java 2008-03-12 21:20:57 UTC (rev 18901)
@@ -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/ming-serialization/drools-core/src/main/java/org/drools/reteoo/LeftInputAdapterNode.java
===================================================================
--- labs/jbossrules/branches/ming-serialization/drools-core/src/main/java/org/drools/reteoo/LeftInputAdapterNode.java 2008-03-12 20:58:14 UTC (rev 18900)
+++ labs/jbossrules/branches/ming-serialization/drools-core/src/main/java/org/drools/reteoo/LeftInputAdapterNode.java 2008-03-12 21:20:57 UTC (rev 18901)
@@ -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()
*/
@@ -100,11 +123,11 @@
/**
* 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 +151,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 +215,15 @@
builder,
this,
workingMemories );
- }
-
+ }
+
public boolean isObjectMemoryEnabled() {
return this.objectMemoryEnabled;
}
public void setObjectMemoryEnabled(boolean objectMemoryEnabled) {
this.objectMemoryEnabled = objectMemoryEnabled;
- }
+ }
/**
* Returns the next node
@@ -212,7 +235,7 @@
}
/**
- * Sets the next node
+ * Sets the next node
* @param next
* The next ObjectSinkNode
*/
@@ -230,7 +253,7 @@
}
/**
- * Sets the previous node
+ * Sets the previous node
* @param previous
* The previous ObjectSinkNode
*/
@@ -295,14 +318,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/ming-serialization/drools-core/src/main/java/org/drools/reteoo/MemoryVisitor.java
===================================================================
--- labs/jbossrules/branches/ming-serialization/drools-core/src/main/java/org/drools/reteoo/MemoryVisitor.java 2008-03-12 20:58:14 UTC (rev 18900)
+++ labs/jbossrules/branches/ming-serialization/drools-core/src/main/java/org/drools/reteoo/MemoryVisitor.java 2008-03-12 21:20:57 UTC (rev 18901)
@@ -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/ming-serialization/drools-core/src/main/java/org/drools/reteoo/NotNode.java
===================================================================
--- labs/jbossrules/branches/ming-serialization/drools-core/src/main/java/org/drools/reteoo/NotNode.java 2008-03-12 20:58:14 UTC (rev 18900)
+++ labs/jbossrules/branches/ming-serialization/drools-core/src/main/java/org/drools/reteoo/NotNode.java 2008-03-12 21:20:57 UTC (rev 18901)
@@ -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/ming-serialization/drools-core/src/main/java/org/drools/reteoo/ObjectSinkNodeList.java
===================================================================
--- labs/jbossrules/branches/ming-serialization/drools-core/src/main/java/org/drools/reteoo/ObjectSinkNodeList.java 2008-03-12 20:58:14 UTC (rev 18900)
+++ labs/jbossrules/branches/ming-serialization/drools-core/src/main/java/org/drools/reteoo/ObjectSinkNodeList.java 2008-03-12 21:20:57 UTC (rev 18901)
@@ -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/ming-serialization/drools-core/src/main/java/org/drools/reteoo/ObjectSinkPropagator.java
===================================================================
--- labs/jbossrules/branches/ming-serialization/drools-core/src/main/java/org/drools/reteoo/ObjectSinkPropagator.java 2008-03-12 20:58:14 UTC (rev 18900)
+++ labs/jbossrules/branches/ming-serialization/drools-core/src/main/java/org/drools/reteoo/ObjectSinkPropagator.java 2008-03-12 21:20:57 UTC (rev 18901)
@@ -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/ming-serialization/drools-core/src/main/java/org/drools/reteoo/ObjectSource.java
===================================================================
--- labs/jbossrules/branches/ming-serialization/drools-core/src/main/java/org/drools/reteoo/ObjectSource.java 2008-03-12 20:58:14 UTC (rev 18900)
+++ labs/jbossrules/branches/ming-serialization/drools-core/src/main/java/org/drools/reteoo/ObjectSource.java 2008-03-12 21:20:57 UTC (rev 18901)
@@ -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,12 +89,25 @@
// ------------------------------------------------------------
// 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>.
@@ -107,7 +127,7 @@
/**
* Removes the <code>ObjectSink</code>
- *
+ *
* @param objectSink
* The <code>ObjectSink</code> to remove
*/
@@ -134,7 +154,7 @@
public ObjectSinkPropagator getSinkPropagator() {
return this.sink;
}
-
+
public boolean isInUse() {
return this.sink.size() > 0;
}
Modified: labs/jbossrules/branches/ming-serialization/drools-core/src/main/java/org/drools/reteoo/ObjectTypeNode.java
===================================================================
--- labs/jbossrules/branches/ming-serialization/drools-core/src/main/java/org/drools/reteoo/ObjectTypeNode.java 2008-03-12 20:58:14 UTC (rev 18900)
+++ labs/jbossrules/branches/ming-serialization/drools-core/src/main/java/org/drools/reteoo/ObjectTypeNode.java 2008-03-12 21:20:57 UTC (rev 18901)
@@ -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;
@@ -45,18 +49,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 +69,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 +104,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 +130,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 +147,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 +175,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 +224,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];
@@ -220,9 +241,9 @@
}
/**
- * 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,7 +309,7 @@
return this.objectType.equals( other.objectType ) && this.objectSource.equals( other.objectSource );
}
- /**
+ /**
* @inheritDoc
*/
protected void addObjectSink(final ObjectSink objectSink) {
@@ -307,7 +328,7 @@
/**
* Checks if a modify action on this object type may
* be skipped because no constraint is applied to it
- *
+ *
* @param sinks
* @return
*/
Modified: labs/jbossrules/branches/ming-serialization/drools-core/src/main/java/org/drools/reteoo/PropagationQueuingNode.java
===================================================================
--- labs/jbossrules/branches/ming-serialization/drools-core/src/main/java/org/drools/reteoo/PropagationQueuingNode.java 2008-03-12 20:58:14 UTC (rev 18900)
+++ labs/jbossrules/branches/ming-serialization/drools-core/src/main/java/org/drools/reteoo/PropagationQueuingNode.java 2008-03-12 21:20:57 UTC (rev 18901)
@@ -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;
@@ -55,7 +58,7 @@
* 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
@@ -126,7 +129,7 @@
}
this.objectSource.remove( context,
builder,
- this,
+ this,
workingMemories );
}
@@ -201,11 +204,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 +222,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 +243,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 +263,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 +296,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 +312,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,12 +346,21 @@
private static class RetractAction extends Action {
private static final long serialVersionUID = -84784886430845209L;
+ public RetractAction() {
+
+ }
public RetractAction(final InternalFactHandle handle,
final PropagationContext context) {
super( handle,
context );
}
+ public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
+ }
+
+ public void writeExternal(ObjectOutput out) throws IOException {
+ }
+
public void execute(final ObjectSinkPropagator sink,
final InternalWorkingMemory workingMemory) {
sink.propagateRetractObject( this.handle,
@@ -337,7 +373,7 @@
/**
* 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
*
*/
@@ -349,10 +385,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/ming-serialization/drools-core/src/main/java/org/drools/reteoo/QueryTerminalNode.java
===================================================================
--- labs/jbossrules/branches/ming-serialization/drools-core/src/main/java/org/drools/reteoo/QueryTerminalNode.java 2008-03-12 20:58:14 UTC (rev 18900)
+++ labs/jbossrules/branches/ming-serialization/drools-core/src/main/java/org/drools/reteoo/QueryTerminalNode.java 2008-03-12 21:20:57 UTC (rev 18901)
@@ -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
@@ -157,7 +181,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 +210,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 +228,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 +246,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/ming-serialization/drools-core/src/main/java/org/drools/reteoo/Rete.java
===================================================================
--- labs/jbossrules/branches/ming-serialization/drools-core/src/main/java/org/drools/reteoo/Rete.java 2008-03-12 20:58:14 UTC (rev 18900)
+++ labs/jbossrules/branches/ming-serialization/drools-core/src/main/java/org/drools/reteoo/Rete.java 2008-03-12 21:20:57 UTC (rev 18901)
@@ -38,6 +38,7 @@
import org.drools.util.FactHashTable;
import org.drools.util.Iterator;
import org.drools.util.ObjectHashMap;
+import org.drools.RuleBase;
/**
* The Rete-OO network.
@@ -220,11 +221,14 @@
}
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();
- this.ruleBase = ((DroolsObjectInput) in).getRuleBase();
+ ruleBase = (InternalRuleBase)in.readObject();
}
}
Modified: labs/jbossrules/branches/ming-serialization/drools-core/src/main/java/org/drools/reteoo/ReteStatelessSessionResult.java
===================================================================
--- labs/jbossrules/branches/ming-serialization/drools-core/src/main/java/org/drools/reteoo/ReteStatelessSessionResult.java 2008-03-12 20:58:14 UTC (rev 18900)
+++ labs/jbossrules/branches/ming-serialization/drools-core/src/main/java/org/drools/reteoo/ReteStatelessSessionResult.java 2008-03-12 21:20:57 UTC (rev 18901)
@@ -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/ming-serialization/drools-core/src/main/java/org/drools/reteoo/ReteTuple.java
===================================================================
--- labs/jbossrules/branches/ming-serialization/drools-core/src/main/java/org/drools/reteoo/ReteTuple.java 2008-03-12 20:58:14 UTC (rev 18900)
+++ labs/jbossrules/branches/ming-serialization/drools-core/src/main/java/org/drools/reteoo/ReteTuple.java 2008-03-12 21:20:57 UTC (rev 18901)
@@ -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/ming-serialization/drools-core/src/main/java/org/drools/reteoo/ReteooBuilder.java
===================================================================
--- labs/jbossrules/branches/ming-serialization/drools-core/src/main/java/org/drools/reteoo/ReteooBuilder.java 2008-03-12 20:58:14 UTC (rev 18900)
+++ labs/jbossrules/branches/ming-serialization/drools-core/src/main/java/org/drools/reteoo/ReteooBuilder.java 2008-03-12 21:20:57 UTC (rev 18901)
@@ -22,6 +22,11 @@
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;
@@ -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 ) {
@@ -272,23 +291,48 @@
}
public void writeExternal(ObjectOutput out) throws IOException {
- DroolsObjectOutputStream droolsStream = out instanceof DroolsObjectOutputStream
- ? (DroolsObjectOutputStream) out : new DroolsObjectOutputStream(out);
+ boolean isDrools = out instanceof DroolsObjectOutputStream;
+ DroolsObjectOutputStream droolsStream;
+ ByteArrayOutputStream bytes;
+ if (isDrools) {
+ bytes = null;
+ droolsStream = (DroolsObjectOutputStream)out;
+ } else {
+ bytes = new ByteArrayOutputStream();
+ droolsStream = new DroolsObjectOutputStream((OutputStream)new ObjectOutputStream(bytes));
+ }
droolsStream.writeObject(rules);
droolsStream.writeObject(idGenerator);
droolsStream.writeBoolean(ordered);
+ if (!isDrools) {
+ bytes.close();
+ out.writeObject(bytes.toByteArray());
+ }
}
public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
- DroolsObjectInputStream droolsInputStream = in instanceof DroolsObjectInputStream
- ? (DroolsObjectInputStream) in : new DroolsObjectInputStream(in);
- this.rules = (Map)droolsInputStream.readObject();
- this.idGenerator = (IdGenerator)droolsInputStream.readObject();
- this.ordered = droolsInputStream.readBoolean();
+ boolean isDrools = in instanceof DroolsObjectInputStream;
+ DroolsObjectInputStream droolsStream;
+ ByteArrayInputStream bytes;
- this.ruleBase = droolsInputStream.getRuleBase();
+ if (isDrools) {
+ bytes = null;
+ droolsStream = (DroolsObjectInputStream)in;
+ } else {
+ bytes = new ByteArrayInputStream((byte[])in.readObject());
+ droolsStream = new DroolsObjectInputStream((InputStream)new ObjectInputStream(bytes));
+ }
+ this.rules = (Map)in.readObject();
+ this.idGenerator = (IdGenerator)in.readObject();
+ this.ordered = in.readBoolean();
+
+ // TODO: possible null for rule base.
+ this.ruleBase = droolsStream.getRuleBase();
this.ruleBuilder = new ReteooRuleBuilder();
+ if (!isDrools) {
+ bytes.close();
+ }
}
}
Modified: labs/jbossrules/branches/ming-serialization/drools-core/src/main/java/org/drools/reteoo/ReteooFactHandleFactory.java
===================================================================
--- labs/jbossrules/branches/ming-serialization/drools-core/src/main/java/org/drools/reteoo/ReteooFactHandleFactory.java 2008-03-12 20:58:14 UTC (rev 18900)
+++ labs/jbossrules/branches/ming-serialization/drools-core/src/main/java/org/drools/reteoo/ReteooFactHandleFactory.java 2008-03-12 21:20:57 UTC (rev 18901)
@@ -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,10 +25,22 @@
import org.drools.spi.FactHandleFactory;
import org.drools.temporal.SessionClock;
+import java.io.ObjectInput;
+import java.io.IOException;
+import java.io.ObjectOutput;
+
public class ReteooFactHandleFactory extends AbstractFactHandleFactory {
private static final long serialVersionUID = 400L;
+ 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)
*/
@@ -38,7 +50,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,
@@ -50,10 +62,10 @@
recency );
}
}
-
+
/* (non-Javadoc)
- * @see org.drools.reteoo.FactHandleFactory#newFactHandle(long)
- */
+ * @see org.drools.reteoo.FactHandleFactory#newFactHandle(long)
+ */
protected final InternalFactHandle newFactHandle(final long id,
final Object object,
final long recency,
@@ -61,7 +73,7 @@
final long duration,
final WorkingMemory workingMemory ) {
if ( isEvent ) {
- SessionClock clock = ((TemporalSession) workingMemory).getSessionClock();
+ SessionClock clock = ((TemporalSession) workingMemory).getSessionClock();
return new EventFactHandle( id,
object,
recency,
Modified: labs/jbossrules/branches/ming-serialization/drools-core/src/main/java/org/drools/reteoo/ReteooRuleBase.java
===================================================================
--- labs/jbossrules/branches/ming-serialization/drools-core/src/main/java/org/drools/reteoo/ReteooRuleBase.java 2008-03-12 20:58:14 UTC (rev 18900)
+++ labs/jbossrules/branches/ming-serialization/drools-core/src/main/java/org/drools/reteoo/ReteooRuleBase.java 2008-03-12 21:20:57 UTC (rev 18901)
@@ -56,7 +56,7 @@
*
* @version $Id: RuleBaseImpl.java,v 1.5 2005/08/14 22:44:12 mproctor Exp $
*/
-public class ReteooRuleBase extends AbstractRuleBase implements Externalizable {
+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
@@ -83,7 +83,7 @@
/**
* Construct.
*
- * @param rete
+ * @param id
* The rete network.
*/
public ReteooRuleBase(final String id) {
@@ -121,7 +121,7 @@
/**
* Construct.
*
- * @param rete
+ * @param id
* The rete network.
*/
public ReteooRuleBase(final String id,
@@ -147,7 +147,7 @@
*
*/
public void writeExternal(final ObjectOutput stream) throws IOException {
- doWriteExternal( stream );
+ super.writeExternal( stream );
stream.writeObject(this.rete);
stream.writeObject(this.reteooBuilder);
}
@@ -160,7 +160,7 @@
*/
public void readExternal(final ObjectInput stream) throws IOException,
ClassNotFoundException {
- doReadExternal( stream );
+ super.readExternal( stream );
this.rete = (Rete) stream.readObject();
this.reteooBuilder = (ReteooBuilder) stream.readObject();
}
@@ -313,8 +313,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/ming-serialization/drools-core/src/main/java/org/drools/reteoo/ReteooStatefulSession.java
===================================================================
--- labs/jbossrules/branches/ming-serialization/drools-core/src/main/java/org/drools/reteoo/ReteooStatefulSession.java 2008-03-12 20:58:14 UTC (rev 18900)
+++ labs/jbossrules/branches/ming-serialization/drools-core/src/main/java/org/drools/reteoo/ReteooStatefulSession.java 2008-03-12 21:20:57 UTC (rev 18901)
@@ -26,9 +26,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) {
@@ -76,7 +80,7 @@
this.executor.submit( fireAllRules );
return fireAllRules;
}
-
+
public void dispose() {
this.ruleBase.disposeStatefulSession( this );
this.workingMemoryEventSupport.reset();
Modified: labs/jbossrules/branches/ming-serialization/drools-core/src/main/java/org/drools/reteoo/ReteooStatelessSession.java
===================================================================
--- labs/jbossrules/branches/ming-serialization/drools-core/src/main/java/org/drools/reteoo/ReteooStatelessSession.java 2008-03-12 20:58:14 UTC (rev 18900)
+++ labs/jbossrules/branches/ming-serialization/drools-core/src/main/java/org/drools/reteoo/ReteooStatelessSession.java 2008-03-12 21:20:57 UTC (rev 18901)
@@ -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;
@@ -30,13 +34,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 */
@@ -46,10 +50,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(),
@@ -106,7 +126,7 @@
public List getRuleFlowEventListeners() {
return this.ruleFlowEventSupport.getEventListeners();
}
-
+
public void addEventListener(RuleBaseEventListener listener) {
this.ruleBase.addEventListener( listener );
}
@@ -132,7 +152,7 @@
public void setGlobalResolver(GlobalResolver globalResolver) {
this.globalResolver = globalResolver;
}
-
+
public void setGlobalExporter(GlobalExporter globalExporter) {
this.globalExporter = globalExporter;
}
@@ -197,7 +217,7 @@
wm.insert( object );
wm.fireAllRules( this.agendaFilter );
-
+
GlobalResolver globalResolver = null;
if ( this.globalExporter != null ) {
globalResolver = this.globalExporter.export( wm );
@@ -213,7 +233,7 @@
wm.insert( array[i] );
}
wm.fireAllRules( this.agendaFilter );
-
+
GlobalResolver globalResolver = null;
if ( this.globalExporter != null ) {
globalResolver = this.globalExporter.export( wm );
@@ -235,6 +255,6 @@
globalResolver = this.globalExporter.export( wm );
}
return new ReteStatelessSessionResult( wm,
- globalResolver );
+ globalResolver );
}
}
Modified: labs/jbossrules/branches/ming-serialization/drools-core/src/main/java/org/drools/reteoo/ReteooTemporalSession.java
===================================================================
--- labs/jbossrules/branches/ming-serialization/drools-core/src/main/java/org/drools/reteoo/ReteooTemporalSession.java 2008-03-12 20:58:14 UTC (rev 18900)
+++ labs/jbossrules/branches/ming-serialization/drools-core/src/main/java/org/drools/reteoo/ReteooTemporalSession.java 2008-03-12 21:20:57 UTC (rev 18901)
@@ -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.
@@ -22,10 +22,14 @@
import org.drools.concurrent.ExecutorService;
import org.drools.temporal.SessionClock;
+import java.io.ObjectOutput;
+import java.io.IOException;
+import java.io.ObjectInput;
+
/**
* ReteooStatefulTemporalSession implements a temporal enabled session
* for Reteoo rulebases
- *
+ *
* @author etirelli
*/
public class ReteooTemporalSession<T extends SessionClock> extends ReteooStatefulSession
@@ -33,21 +37,34 @@
TemporalSession<T> {
private static final long serialVersionUID = -2129661675928809928L;
-
+
private T sessionClock;
+ public ReteooTemporalSession() {
+ }
+
public ReteooTemporalSession(int id,
- InternalRuleBase ruleBase,
- ExecutorService executorService,
- T clock) {
+ 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/ming-serialization/drools-core/src/main/java/org/drools/reteoo/ReteooWorkingMemory.java
===================================================================
--- labs/jbossrules/branches/ming-serialization/drools-core/src/main/java/org/drools/reteoo/ReteooWorkingMemory.java 2008-03-12 20:58:14 UTC (rev 18900)
+++ labs/jbossrules/branches/ming-serialization/drools-core/src/main/java/org/drools/reteoo/ReteooWorkingMemory.java 2008-03-12 21:20:57 UTC (rev 18901)
@@ -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;
@@ -40,21 +44,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.
*/
@@ -85,18 +93,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, 0, this );
-
+
insert( EntryPoint.DEFAULT, // query dummy objects always use default entry point
handle,
object,
null,
null );
-
+
final QueryTerminalNode node = (QueryTerminalNode) this.queryResults.remove( query );
Query queryObj = null;
List list = null;
@@ -113,27 +121,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 );
@@ -161,6 +169,10 @@
private Activation activationOrigin;
+ public WorkingMemoryReteAssertAction() {
+
+ }
+
public WorkingMemoryReteAssertAction(final InternalFactHandle factHandle,
final boolean removeLogical,
final boolean updateEqualsMap,
@@ -174,6 +186,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/ming-serialization/drools-core/src/main/java/org/drools/reteoo/RightInputAdapterNode.java
===================================================================
--- labs/jbossrules/branches/ming-serialization/drools-core/src/main/java/org/drools/reteoo/RightInputAdapterNode.java 2008-03-12 20:58:14 UTC (rev 18900)
+++ labs/jbossrules/branches/ming-serialization/drools-core/src/main/java/org/drools/reteoo/RightInputAdapterNode.java 2008-03-12 21:20:57 UTC (rev 18901)
@@ -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
@@ -179,7 +202,7 @@
workingMemories );
}
}
-
+
public boolean isTupleMemoryEnabled() {
return tupleMemoryEnabled;
}
@@ -198,7 +221,7 @@
}
/**
- * Sets the next node
+ * Sets the next node
* @param next
* The next TupleSinkNode
*/
@@ -216,7 +239,7 @@
}
/**
- * Sets the previous node
+ * Sets the previous node
* @param previous
* The previous TupleSinkNode
*/
@@ -230,7 +253,7 @@
/*
* (non-Javadoc)
- *
+ *
* @see java.lang.Object#equals(java.lang.Object)
*/
public boolean equals(final Object object) {
Modified: labs/jbossrules/branches/ming-serialization/drools-core/src/main/java/org/drools/reteoo/RuleRemovalContext.java
===================================================================
--- labs/jbossrules/branches/ming-serialization/drools-core/src/main/java/org/drools/reteoo/RuleRemovalContext.java 2008-03-12 20:58:14 UTC (rev 18900)
+++ labs/jbossrules/branches/ming-serialization/drools-core/src/main/java/org/drools/reteoo/RuleRemovalContext.java 2008-03-12 21:20:57 UTC (rev 18901)
@@ -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/ming-serialization/drools-core/src/main/java/org/drools/reteoo/RuleTerminalNode.java
===================================================================
--- labs/jbossrules/branches/ming-serialization/drools-core/src/main/java/org/drools/reteoo/RuleTerminalNode.java 2008-03-12 20:58:14 UTC (rev 18900)
+++ labs/jbossrules/branches/ming-serialization/drools-core/src/main/java/org/drools/reteoo/RuleTerminalNode.java 2008-03-12 21:20:57 UTC (rev 18901)
@@ -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.
*
@@ -540,9 +565,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 +582,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/ming-serialization/drools-core/src/main/java/org/drools/reteoo/SingleObjectSinkAdapter.java
===================================================================
--- labs/jbossrules/branches/ming-serialization/drools-core/src/main/java/org/drools/reteoo/SingleObjectSinkAdapter.java 2008-03-12 20:58:14 UTC (rev 18900)
+++ labs/jbossrules/branches/ming-serialization/drools-core/src/main/java/org/drools/reteoo/SingleObjectSinkAdapter.java 2008-03-12 21:20:57 UTC (rev 18901)
@@ -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/ming-serialization/drools-core/src/main/java/org/drools/reteoo/SingleTupleSinkAdapter.java
===================================================================
--- labs/jbossrules/branches/ming-serialization/drools-core/src/main/java/org/drools/reteoo/SingleTupleSinkAdapter.java 2008-03-12 20:58:14 UTC (rev 18900)
+++ labs/jbossrules/branches/ming-serialization/drools-core/src/main/java/org/drools/reteoo/SingleTupleSinkAdapter.java 2008-03-12 21:20:57 UTC (rev 18901)
@@ -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/ming-serialization/drools-core/src/main/java/org/drools/reteoo/TupleSink.java
===================================================================
--- labs/jbossrules/branches/ming-serialization/drools-core/src/main/java/org/drools/reteoo/TupleSink.java 2008-03-12 20:58:14 UTC (rev 18900)
+++ labs/jbossrules/branches/ming-serialization/drools-core/src/main/java/org/drools/reteoo/TupleSink.java 2008-03-12 21:20:57 UTC (rev 18901)
@@ -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/ming-serialization/drools-core/src/main/java/org/drools/reteoo/TupleSinkNodeList.java
===================================================================
--- labs/jbossrules/branches/ming-serialization/drools-core/src/main/java/org/drools/reteoo/TupleSinkNodeList.java 2008-03-12 20:58:14 UTC (rev 18900)
+++ labs/jbossrules/branches/ming-serialization/drools-core/src/main/java/org/drools/reteoo/TupleSinkNodeList.java 2008-03-12 21:20:57 UTC (rev 18901)
@@ -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/ming-serialization/drools-core/src/main/java/org/drools/reteoo/TupleSinkPropagator.java
===================================================================
--- labs/jbossrules/branches/ming-serialization/drools-core/src/main/java/org/drools/reteoo/TupleSinkPropagator.java 2008-03-12 20:58:14 UTC (rev 18900)
+++ labs/jbossrules/branches/ming-serialization/drools-core/src/main/java/org/drools/reteoo/TupleSinkPropagator.java 2008-03-12 21:20:57 UTC (rev 18901)
@@ -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/ming-serialization/drools-core/src/main/java/org/drools/reteoo/TupleSource.java
===================================================================
--- labs/jbossrules/branches/ming-serialization/drools-core/src/main/java/org/drools/reteoo/TupleSource.java 2008-03-12 20:58:14 UTC (rev 18900)
+++ labs/jbossrules/branches/ming-serialization/drools-core/src/main/java/org/drools/reteoo/TupleSource.java 2008-03-12 21:20:57 UTC (rev 18901)
@@ -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,11 +69,20 @@
// ------------------------------------------------------------
// 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>.
@@ -86,7 +102,7 @@
/**
* Removes the <code>TupleSink</code>
- *
+ *
* @param tupleSink
* The <code>TupleSink</code> to remove
*/
@@ -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/ming-serialization/drools-core/src/main/java/org/drools/rule/AbstractCompositeConstraint.java
===================================================================
--- labs/jbossrules/branches/ming-serialization/drools-core/src/main/java/org/drools/rule/AbstractCompositeConstraint.java 2008-03-12 20:58:14 UTC (rev 18900)
+++ labs/jbossrules/branches/ming-serialization/drools-core/src/main/java/org/drools/rule/AbstractCompositeConstraint.java 2008-03-12 21:20:57 UTC (rev 18901)
@@ -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,7 +97,7 @@
}
/**
- * 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) {
@@ -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/ming-serialization/drools-core/src/main/java/org/drools/rule/AbstractCompositeRestriction.java
===================================================================
--- labs/jbossrules/branches/ming-serialization/drools-core/src/main/java/org/drools/rule/AbstractCompositeRestriction.java 2008-03-12 20:58:14 UTC (rev 18900)
+++ labs/jbossrules/branches/ming-serialization/drools-core/src/main/java/org/drools/rule/AbstractCompositeRestriction.java 2008-03-12 21:20:57 UTC (rev 18901)
@@ -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/ming-serialization/drools-core/src/main/java/org/drools/rule/Accumulate.java
===================================================================
--- labs/jbossrules/branches/ming-serialization/drools-core/src/main/java/org/drools/rule/Accumulate.java 2008-03-12 20:58:14 UTC (rev 18900)
+++ labs/jbossrules/branches/ming-serialization/drools-core/src/main/java/org/drools/rule/Accumulate.java 2008-03-12 21:20:57 UTC (rev 18901)
@@ -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/ming-serialization/drools-core/src/main/java/org/drools/rule/AndCompositeRestriction.java
===================================================================
--- labs/jbossrules/branches/ming-serialization/drools-core/src/main/java/org/drools/rule/AndCompositeRestriction.java 2008-03-12 20:58:14 UTC (rev 18900)
+++ labs/jbossrules/branches/ming-serialization/drools-core/src/main/java/org/drools/rule/AndCompositeRestriction.java 2008-03-12 21:20:57 UTC (rev 18901)
@@ -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/ming-serialization/drools-core/src/main/java/org/drools/rule/Collect.java
===================================================================
--- labs/jbossrules/branches/ming-serialization/drools-core/src/main/java/org/drools/rule/Collect.java 2008-03-12 20:58:14 UTC (rev 18900)
+++ labs/jbossrules/branches/ming-serialization/drools-core/src/main/java/org/drools/rule/Collect.java 2008-03-12 21:20:57 UTC (rev 18901)
@@ -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/ming-serialization/drools-core/src/main/java/org/drools/rule/ContextEntry.java
===================================================================
--- labs/jbossrules/branches/ming-serialization/drools-core/src/main/java/org/drools/rule/ContextEntry.java 2008-03-12 20:58:14 UTC (rev 18900)
+++ labs/jbossrules/branches/ming-serialization/drools-core/src/main/java/org/drools/rule/ContextEntry.java 2008-03-12 21:20:57 UTC (rev 18901)
@@ -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/ming-serialization/drools-core/src/main/java/org/drools/rule/DialectDatas.java
===================================================================
--- labs/jbossrules/branches/ming-serialization/drools-core/src/main/java/org/drools/rule/DialectDatas.java 2008-03-12 20:58:14 UTC (rev 18900)
+++ labs/jbossrules/branches/ming-serialization/drools-core/src/main/java/org/drools/rule/DialectDatas.java 2008-03-12 21:20:57 UTC (rev 18901)
@@ -12,6 +12,7 @@
import org.drools.common.DroolsObjectInputStream;
import org.drools.common.DroolsObjectOutputStream;
+import org.drools.common.DroolsObjectInput;
public class DialectDatas implements Externalizable {
private ClassLoader parentClassLoader;
@@ -47,11 +48,8 @@
*
*/
public void writeExternal(final ObjectOutput stream) throws IOException {
- DroolsObjectOutputStream droolsStream = stream instanceof DroolsObjectOutputStream
- ? (DroolsObjectOutputStream)stream : new DroolsObjectOutputStream(stream);
-
- droolsStream.writeObject( this.lineMappings );
- droolsStream.writeObject(this.dialects);
+ stream.writeObject( this.lineMappings );
+ stream.writeObject(this.dialects);
}
/**
@@ -61,16 +59,19 @@
*
*/
public void readExternal(final ObjectInput stream) throws IOException,
- ClassNotFoundException {
- DroolsObjectInputStream droolsStream = stream instanceof DroolsObjectInputStream
- ? (DroolsObjectInputStream)stream : new DroolsObjectInputStream(stream);
-
- droolsStream.setClassLoader(new CompositePackageClassLoader(droolsStream.getClassLoader()));
-
+ ClassNotFoundException {
this.lineMappings = (Map) stream.readObject();
- this.dialects = (Map<String, DialectData>)stream.readObject();
+ this.dialects = (Map<String, DialectData>)stream.readObject();
+ if (((DroolsObjectInputStream)stream).getClassLoader() instanceof CompositePackageClassLoader) {
+ this.classLoader = (CompositePackageClassLoader)((DroolsObjectInputStream)stream).getClassLoader();
+ this.parentClassLoader = this.classLoader.getParent();
+ }
+ else {
+ this.parentClassLoader = ((DroolsObjectInputStream)stream).getClassLoader();
+ this.classLoader = new CompositePackageClassLoader(this.parentClassLoader);
+ }
- droolsStream.setDialectDatas(this);
+ ((DroolsObjectInput)stream).setDialectDatas(this);
}
public void addDialectData(String dialect, DialectData dialectData) {
Modified: labs/jbossrules/branches/ming-serialization/drools-core/src/main/java/org/drools/rule/EntryPoint.java
===================================================================
--- labs/jbossrules/branches/ming-serialization/drools-core/src/main/java/org/drools/rule/EntryPoint.java 2008-03-12 20:58:14 UTC (rev 18900)
+++ labs/jbossrules/branches/ming-serialization/drools-core/src/main/java/org/drools/rule/EntryPoint.java 2008-03-12 21:20:57 UTC (rev 18901)
@@ -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/ming-serialization/drools-core/src/main/java/org/drools/rule/EvalCondition.java
===================================================================
--- labs/jbossrules/branches/ming-serialization/drools-core/src/main/java/org/drools/rule/EvalCondition.java 2008-03-12 20:58:14 UTC (rev 18900)
+++ labs/jbossrules/branches/ming-serialization/drools-core/src/main/java/org/drools/rule/EvalCondition.java 2008-03-12 21:20:57 UTC (rev 18901)
@@ -37,7 +37,7 @@
private EvalExpression expression;
- private final Declaration[] requiredDeclarations;
+ private Declaration[] requiredDeclarations;
private static final Declaration[] EMPTY_DECLARATIONS = new Declaration[0];
@@ -64,10 +64,12 @@
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() {
Modified: labs/jbossrules/branches/ming-serialization/drools-core/src/main/java/org/drools/rule/Forall.java
===================================================================
--- labs/jbossrules/branches/ming-serialization/drools-core/src/main/java/org/drools/rule/Forall.java 2008-03-12 20:58:14 UTC (rev 18900)
+++ labs/jbossrules/branches/ming-serialization/drools-core/src/main/java/org/drools/rule/Forall.java 2008-03-12 21:20:57 UTC (rev 18901)
@@ -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/ming-serialization/drools-core/src/main/java/org/drools/rule/From.java
===================================================================
--- labs/jbossrules/branches/ming-serialization/drools-core/src/main/java/org/drools/rule/From.java 2008-03-12 20:58:14 UTC (rev 18900)
+++ labs/jbossrules/branches/ming-serialization/drools-core/src/main/java/org/drools/rule/From.java 2008-03-12 21:20:57 UTC (rev 18901)
@@ -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/ming-serialization/drools-core/src/main/java/org/drools/rule/JavaDialectData.java
===================================================================
--- labs/jbossrules/branches/ming-serialization/drools-core/src/main/java/org/drools/rule/JavaDialectData.java 2008-03-12 20:58:14 UTC (rev 18900)
+++ labs/jbossrules/branches/ming-serialization/drools-core/src/main/java/org/drools/rule/JavaDialectData.java 2008-03-12 21:20:57 UTC (rev 18901)
@@ -130,11 +130,10 @@
this.datas = (DialectDatas)droolsStream.readObject();
this.classLoader = new PackageClassLoader( this.datas.getParentClassLoader() );
this.datas.addClassLoader( this.classLoader );
- droolsStream.setClassLoader(this.classLoader);
-
this.store = (Map) stream.readObject();
this.AST = stream.readObject();
this.invokerLookups = (Map) droolsStream.readObject();
+ this.dirty = true;
}
public ClassLoader getClassLoader() {
Modified: labs/jbossrules/branches/ming-serialization/drools-core/src/main/java/org/drools/rule/LiteralRestriction.java
===================================================================
--- labs/jbossrules/branches/ming-serialization/drools-core/src/main/java/org/drools/rule/LiteralRestriction.java 2008-03-12 20:58:14 UTC (rev 18900)
+++ labs/jbossrules/branches/ming-serialization/drools-core/src/main/java/org/drools/rule/LiteralRestriction.java 2008-03-12 21:20:57 UTC (rev 18901)
@@ -157,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/ming-serialization/drools-core/src/main/java/org/drools/rule/MultiRestrictionFieldConstraint.java
===================================================================
--- labs/jbossrules/branches/ming-serialization/drools-core/src/main/java/org/drools/rule/MultiRestrictionFieldConstraint.java 2008-03-12 20:58:14 UTC (rev 18900)
+++ labs/jbossrules/branches/ming-serialization/drools-core/src/main/java/org/drools/rule/MultiRestrictionFieldConstraint.java 2008-03-12 21:20:57 UTC (rev 18901)
@@ -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/ming-serialization/drools-core/src/main/java/org/drools/rule/OrCompositeRestriction.java
===================================================================
--- labs/jbossrules/branches/ming-serialization/drools-core/src/main/java/org/drools/rule/OrCompositeRestriction.java 2008-03-12 20:58:14 UTC (rev 18900)
+++ labs/jbossrules/branches/ming-serialization/drools-core/src/main/java/org/drools/rule/OrCompositeRestriction.java 2008-03-12 21:20:57 UTC (rev 18901)
@@ -10,6 +10,9 @@
private static final long serialVersionUID = 400L;
+ public OrCompositeRestriction() {
+ }
+
public OrCompositeRestriction(final Restriction[] restriction) {
super( restriction );
}
Modified: labs/jbossrules/branches/ming-serialization/drools-core/src/main/java/org/drools/rule/Package.java
===================================================================
--- labs/jbossrules/branches/ming-serialization/drools-core/src/main/java/org/drools/rule/Package.java 2008-03-12 20:58:14 UTC (rev 18900)
+++ labs/jbossrules/branches/ming-serialization/drools-core/src/main/java/org/drools/rule/Package.java 2008-03-12 21:20:57 UTC (rev 18901)
@@ -191,7 +191,8 @@
this.dialectDatas = (DialectDatas)in.readObject();
// Not sure needs to do this, everything is already at this time.
- ((DroolsObjectInput)in).setClassLoader(this.dialectDatas.getClassLoader());
+ if (!isDroolsStream)
+ ((DroolsObjectInput)in).setClassLoader(this.dialectDatas.getClassLoader());
this.name = (String) in.readObject();
this.imports = (Map<String, ImportDeclaration>) in.readObject();
Modified: labs/jbossrules/branches/ming-serialization/drools-core/src/main/java/org/drools/rule/PredicateConstraint.java
===================================================================
--- labs/jbossrules/branches/ming-serialization/drools-core/src/main/java/org/drools/rule/PredicateConstraint.java 2008-03-12 20:58:14 UTC (rev 18900)
+++ labs/jbossrules/branches/ming-serialization/drools-core/src/main/java/org/drools/rule/PredicateConstraint.java 2008-03-12 21:20:57 UTC (rev 18901)
@@ -326,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;
}
Modified: labs/jbossrules/branches/ming-serialization/drools-core/src/main/java/org/drools/rule/Query.java
===================================================================
--- labs/jbossrules/branches/ming-serialization/drools-core/src/main/java/org/drools/rule/Query.java 2008-03-12 20:58:14 UTC (rev 18900)
+++ labs/jbossrules/branches/ming-serialization/drools-core/src/main/java/org/drools/rule/Query.java 2008-03-12 21:20:57 UTC (rev 18901)
@@ -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/ming-serialization/drools-core/src/main/java/org/drools/rule/ReturnValueRestriction.java
===================================================================
--- labs/jbossrules/branches/ming-serialization/drools-core/src/main/java/org/drools/rule/ReturnValueRestriction.java 2008-03-12 20:58:14 UTC (rev 18900)
+++ labs/jbossrules/branches/ming-serialization/drools-core/src/main/java/org/drools/rule/ReturnValueRestriction.java 2008-03-12 21:20:57 UTC (rev 18901)
@@ -36,7 +36,7 @@
public class ReturnValueRestriction
implements
- Restriction, Externalizable {
+ Restriction {
private static final long serialVersionUID = 400L;
@@ -326,6 +326,9 @@
public Object dialectContext;
+ public ReturnValueContextEntry() {
+ }
+
public ReturnValueContextEntry(final FieldExtractor fieldExtractor,
final Declaration[] previousDeclarations,
final Declaration[] localDeclarations) {
@@ -334,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/ming-serialization/drools-core/src/main/java/org/drools/rule/TimeMachine.java
===================================================================
--- labs/jbossrules/branches/ming-serialization/drools-core/src/main/java/org/drools/rule/TimeMachine.java 2008-03-12 20:58:14 UTC (rev 18900)
+++ labs/jbossrules/branches/ming-serialization/drools-core/src/main/java/org/drools/rule/TimeMachine.java 2008-03-12 21:20:57 UTC (rev 18901)
@@ -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/ming-serialization/drools-core/src/main/java/org/drools/rule/VariableRestriction.java
===================================================================
--- labs/jbossrules/branches/ming-serialization/drools-core/src/main/java/org/drools/rule/VariableRestriction.java 2008-03-12 20:58:14 UTC (rev 18900)
+++ labs/jbossrules/branches/ming-serialization/drools-core/src/main/java/org/drools/rule/VariableRestriction.java 2008-03-12 21:20:57 UTC (rev 18901)
@@ -33,7 +33,7 @@
public class VariableRestriction
implements
- Restriction, Externalizable {
+ Restriction {
private static final long serialVersionUID = 400L;
@@ -46,7 +46,6 @@
private FieldExtractor extractor;
public VariableRestriction() {
-
}
public VariableRestriction(final FieldExtractor fieldExtractor,
@@ -195,6 +194,9 @@
public boolean rightNull;
public InternalWorkingMemory workingMemory;
+ public VariableContextEntry() {
+ }
+
public VariableContextEntry(final FieldExtractor extractor,
final Declaration declaration,
final Evaluator evaluator) {
@@ -203,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;
}
@@ -250,6 +276,9 @@
public Object left;
public Object right;
+ public ObjectVariableContextEntry() {
+ }
+
public ObjectVariableContextEntry(final FieldExtractor extractor,
final Declaration declaration,
final Evaluator evaluator) {
@@ -258,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;
@@ -296,6 +337,9 @@
public long left;
public long right;
+ public LongVariableContextEntry() {
+ }
+
public LongVariableContextEntry(final FieldExtractor extractor,
final Declaration declaration,
final Evaluator evaluator) {
@@ -304,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;
@@ -342,6 +398,9 @@
public char left;
public char right;
+ public CharVariableContextEntry() {
+ }
+
public CharVariableContextEntry(final FieldExtractor extractor,
final Declaration declaration,
final Evaluator evaluator) {
@@ -350,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;
@@ -388,6 +459,9 @@
public double left;
public double right;
+ public DoubleVariableContextEntry() {
+ }
+
public DoubleVariableContextEntry(final FieldExtractor extractor,
final Declaration declaration,
final Evaluator evaluator) {
@@ -396,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;
@@ -433,6 +519,9 @@
public boolean left;
public boolean right;
+ public BooleanVariableContextEntry() {
+ }
+
public BooleanVariableContextEntry(final FieldExtractor extractor,
final Declaration declaration,
final Evaluator evaluator) {
@@ -441,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/ming-serialization/drools-core/src/main/java/org/drools/ruleflow/instance/RuleFlowProcessInstanceFactory.java
===================================================================
--- labs/jbossrules/branches/ming-serialization/drools-core/src/main/java/org/drools/ruleflow/instance/RuleFlowProcessInstanceFactory.java 2008-03-12 20:58:14 UTC (rev 18900)
+++ labs/jbossrules/branches/ming-serialization/drools-core/src/main/java/org/drools/ruleflow/instance/RuleFlowProcessInstanceFactory.java 2008-03-12 21:20:57 UTC (rev 18901)
@@ -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/ming-serialization/drools-core/src/main/java/org/drools/spi/AgendaGroup.java
===================================================================
--- labs/jbossrules/branches/ming-serialization/drools-core/src/main/java/org/drools/spi/AgendaGroup.java 2008-03-12 20:58:14 UTC (rev 18900)
+++ labs/jbossrules/branches/ming-serialization/drools-core/src/main/java/org/drools/spi/AgendaGroup.java 2008-03-12 21:20:57 UTC (rev 18901)
@@ -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/ming-serialization/drools-core/src/main/java/org/drools/spi/ConsequenceExceptionHandler.java
===================================================================
--- labs/jbossrules/branches/ming-serialization/drools-core/src/main/java/org/drools/spi/ConsequenceExceptionHandler.java 2008-03-12 20:58:14 UTC (rev 18900)
+++ labs/jbossrules/branches/ming-serialization/drools-core/src/main/java/org/drools/spi/ConsequenceExceptionHandler.java 2008-03-12 21:20:57 UTC (rev 18901)
@@ -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/ming-serialization/drools-core/src/main/java/org/drools/spi/Extractor.java
===================================================================
--- labs/jbossrules/branches/ming-serialization/drools-core/src/main/java/org/drools/spi/Extractor.java 2008-03-12 20:58:14 UTC (rev 18900)
+++ labs/jbossrules/branches/ming-serialization/drools-core/src/main/java/org/drools/spi/Extractor.java 2008-03-12 21:20:57 UTC (rev 18901)
@@ -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/ming-serialization/drools-core/src/main/java/org/drools/spi/GlobalExporter.java
===================================================================
--- labs/jbossrules/branches/ming-serialization/drools-core/src/main/java/org/drools/spi/GlobalExporter.java 2008-03-12 20:58:14 UTC (rev 18900)
+++ labs/jbossrules/branches/ming-serialization/drools-core/src/main/java/org/drools/spi/GlobalExporter.java 2008-03-12 21:20:57 UTC (rev 18901)
@@ -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/ming-serialization/drools-core/src/main/java/org/drools/spi/GlobalExtractor.java
===================================================================
--- labs/jbossrules/branches/ming-serialization/drools-core/src/main/java/org/drools/spi/GlobalExtractor.java 2008-03-12 20:58:14 UTC (rev 18900)
+++ labs/jbossrules/branches/ming-serialization/drools-core/src/main/java/org/drools/spi/GlobalExtractor.java 2008-03-12 21:20:57 UTC (rev 18901)
@@ -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/ming-serialization/drools-core/src/main/java/org/drools/spi/GlobalResolver.java
===================================================================
--- labs/jbossrules/branches/ming-serialization/drools-core/src/main/java/org/drools/spi/GlobalResolver.java 2008-03-12 20:58:14 UTC (rev 18900)
+++ labs/jbossrules/branches/ming-serialization/drools-core/src/main/java/org/drools/spi/GlobalResolver.java 2008-03-12 21:20:57 UTC (rev 18901)
@@ -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/ming-serialization/drools-core/src/main/java/org/drools/spi/PredicateExpression.java
===================================================================
--- labs/jbossrules/branches/ming-serialization/drools-core/src/main/java/org/drools/spi/PredicateExpression.java 2008-03-12 20:58:14 UTC (rev 18900)
+++ labs/jbossrules/branches/ming-serialization/drools-core/src/main/java/org/drools/spi/PredicateExpression.java 2008-03-12 21:20:57 UTC (rev 18901)
@@ -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/ming-serialization/drools-core/src/main/java/org/drools/spi/PropagationContext.java
===================================================================
--- labs/jbossrules/branches/ming-serialization/drools-core/src/main/java/org/drools/spi/PropagationContext.java 2008-03-12 20:58:14 UTC (rev 18900)
+++ labs/jbossrules/branches/ming-serialization/drools-core/src/main/java/org/drools/spi/PropagationContext.java 2008-03-12 21:20:57 UTC (rev 18901)
@@ -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/ming-serialization/drools-core/src/main/java/org/drools/spi/Restriction.java
===================================================================
--- labs/jbossrules/branches/ming-serialization/drools-core/src/main/java/org/drools/spi/Restriction.java 2008-03-12 20:58:14 UTC (rev 18900)
+++ labs/jbossrules/branches/ming-serialization/drools-core/src/main/java/org/drools/spi/Restriction.java 2008-03-12 21:20:57 UTC (rev 18901)
@@ -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/ming-serialization/drools-core/src/main/java/org/drools/spi/RuleComponent.java
===================================================================
--- labs/jbossrules/branches/ming-serialization/drools-core/src/main/java/org/drools/spi/RuleComponent.java 2008-03-12 20:58:14 UTC (rev 18900)
+++ labs/jbossrules/branches/ming-serialization/drools-core/src/main/java/org/drools/spi/RuleComponent.java 2008-03-12 21:20:57 UTC (rev 18901)
@@ -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/ming-serialization/drools-core/src/main/java/org/drools/spi/RuleFlowGroup.java
===================================================================
--- labs/jbossrules/branches/ming-serialization/drools-core/src/main/java/org/drools/spi/RuleFlowGroup.java 2008-03-12 20:58:14 UTC (rev 18900)
+++ labs/jbossrules/branches/ming-serialization/drools-core/src/main/java/org/drools/spi/RuleFlowGroup.java 2008-03-12 21:20:57 UTC (rev 18901)
@@ -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/ming-serialization/drools-core/src/main/java/org/drools/util/AbstractBaseLinkedListNode.java
===================================================================
--- labs/jbossrules/branches/ming-serialization/drools-core/src/main/java/org/drools/util/AbstractBaseLinkedListNode.java 2008-03-12 20:58:14 UTC (rev 18900)
+++ labs/jbossrules/branches/ming-serialization/drools-core/src/main/java/org/drools/util/AbstractBaseLinkedListNode.java 2008-03-12 21:20:57 UTC (rev 18901)
@@ -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/ming-serialization/drools-core/src/main/java/org/drools/util/AbstractHashTable.java
===================================================================
--- labs/jbossrules/branches/ming-serialization/drools-core/src/main/java/org/drools/util/AbstractHashTable.java 2008-03-12 20:58:14 UTC (rev 18900)
+++ labs/jbossrules/branches/ming-serialization/drools-core/src/main/java/org/drools/util/AbstractHashTable.java 2008-03-12 21:20:57 UTC (rev 18901)
@@ -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;
Modified: labs/jbossrules/branches/ming-serialization/drools-core/src/main/java/org/drools/util/BinaryHeapQueue.java
===================================================================
--- labs/jbossrules/branches/ming-serialization/drools-core/src/main/java/org/drools/util/BinaryHeapQueue.java 2008-03-12 20:58:14 UTC (rev 18900)
+++ labs/jbossrules/branches/ming-serialization/drools-core/src/main/java/org/drools/util/BinaryHeapQueue.java 2008-03-12 21:20:57 UTC (rev 18901)
@@ -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/ming-serialization/drools-core/src/main/java/org/drools/util/ChainedProperties.java
===================================================================
--- labs/jbossrules/branches/ming-serialization/drools-core/src/main/java/org/drools/util/ChainedProperties.java 2008-03-12 20:58:14 UTC (rev 18900)
+++ labs/jbossrules/branches/ming-serialization/drools-core/src/main/java/org/drools/util/ChainedProperties.java 2008-03-12 21:20:57 UTC (rev 18901)
@@ -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/ming-serialization/drools-core/src/main/java/org/drools/util/Entry.java
===================================================================
--- labs/jbossrules/branches/ming-serialization/drools-core/src/main/java/org/drools/util/Entry.java 2008-03-12 20:58:14 UTC (rev 18900)
+++ labs/jbossrules/branches/ming-serialization/drools-core/src/main/java/org/drools/util/Entry.java 2008-03-12 21:20:57 UTC (rev 18901)
@@ -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/ming-serialization/drools-core/src/main/java/org/drools/util/FactHandleIndexHashTable.java
===================================================================
--- labs/jbossrules/branches/ming-serialization/drools-core/src/main/java/org/drools/util/FactHandleIndexHashTable.java 2008-03-12 20:58:14 UTC (rev 18900)
+++ labs/jbossrules/branches/ming-serialization/drools-core/src/main/java/org/drools/util/FactHandleIndexHashTable.java 2008-03-12 21:20:57 UTC (rev 18901)
@@ -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/ming-serialization/drools-core/src/main/java/org/drools/util/LinkedList.java
===================================================================
--- labs/jbossrules/branches/ming-serialization/drools-core/src/main/java/org/drools/util/LinkedList.java 2008-03-12 20:58:14 UTC (rev 18900)
+++ labs/jbossrules/branches/ming-serialization/drools-core/src/main/java/org/drools/util/LinkedList.java 2008-03-12 21:20:57 UTC (rev 18901)
@@ -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/ming-serialization/drools-core/src/main/java/org/drools/util/LinkedListEntry.java
===================================================================
--- labs/jbossrules/branches/ming-serialization/drools-core/src/main/java/org/drools/util/LinkedListEntry.java 2008-03-12 20:58:14 UTC (rev 18900)
+++ labs/jbossrules/branches/ming-serialization/drools-core/src/main/java/org/drools/util/LinkedListEntry.java 2008-03-12 21:20:57 UTC (rev 18901)
@@ -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/ming-serialization/drools-core/src/main/java/org/drools/util/LinkedListNode.java
===================================================================
--- labs/jbossrules/branches/ming-serialization/drools-core/src/main/java/org/drools/util/LinkedListNode.java 2008-03-12 20:58:14 UTC (rev 18900)
+++ labs/jbossrules/branches/ming-serialization/drools-core/src/main/java/org/drools/util/LinkedListNode.java 2008-03-12 21:20:57 UTC (rev 18901)
@@ -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/ming-serialization/drools-core/src/main/java/org/drools/util/ObjectHashMap.java
===================================================================
--- labs/jbossrules/branches/ming-serialization/drools-core/src/main/java/org/drools/util/ObjectHashMap.java 2008-03-12 20:58:14 UTC (rev 18900)
+++ labs/jbossrules/branches/ming-serialization/drools-core/src/main/java/org/drools/util/ObjectHashMap.java 2008-03-12 21:20:57 UTC (rev 18901)
@@ -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/ming-serialization/drools-core/src/main/java/org/drools/util/ObjectHashSet.java
===================================================================
--- labs/jbossrules/branches/ming-serialization/drools-core/src/main/java/org/drools/util/ObjectHashSet.java 2008-03-12 20:58:14 UTC (rev 18900)
+++ labs/jbossrules/branches/ming-serialization/drools-core/src/main/java/org/drools/util/ObjectHashSet.java 2008-03-12 21:20:57 UTC (rev 18901)
@@ -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;
}
Modified: labs/jbossrules/branches/ming-serialization/drools-core/src/main/java/org/drools/util/PrimitiveLongMap.java
===================================================================
--- labs/jbossrules/branches/ming-serialization/drools-core/src/main/java/org/drools/util/PrimitiveLongMap.java 2008-03-12 20:58:14 UTC (rev 18900)
+++ labs/jbossrules/branches/ming-serialization/drools-core/src/main/java/org/drools/util/PrimitiveLongMap.java 2008-03-12 21:20:57 UTC (rev 18901)
@@ -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/ming-serialization/drools-core/src/main/java/org/drools/util/PrimitiveLongStack.java
===================================================================
--- labs/jbossrules/branches/ming-serialization/drools-core/src/main/java/org/drools/util/PrimitiveLongStack.java 2008-03-12 20:58:14 UTC (rev 18900)
+++ labs/jbossrules/branches/ming-serialization/drools-core/src/main/java/org/drools/util/PrimitiveLongStack.java 2008-03-12 21:20:57 UTC (rev 18901)
@@ -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/ming-serialization/drools-core/src/main/java/org/drools/util/TupleIndexHashTable.java
===================================================================
--- labs/jbossrules/branches/ming-serialization/drools-core/src/main/java/org/drools/util/TupleIndexHashTable.java 2008-03-12 20:58:14 UTC (rev 18900)
+++ labs/jbossrules/branches/ming-serialization/drools-core/src/main/java/org/drools/util/TupleIndexHashTable.java 2008-03-12 21:20:57 UTC (rev 18901)
@@ -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/ming-serialization/drools-core/src/test/java/org/drools/TestWorkingMemoryEventListener.java
===================================================================
--- labs/jbossrules/branches/ming-serialization/drools-core/src/test/java/org/drools/TestWorkingMemoryEventListener.java 2008-03-12 20:58:14 UTC (rev 18900)
+++ labs/jbossrules/branches/ming-serialization/drools-core/src/test/java/org/drools/TestWorkingMemoryEventListener.java 2008-03-12 21:20:57 UTC (rev 18901)
@@ -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/ming-serialization/drools-core/src/test/java/org/drools/base/EvaluatorFactoryTest.java
===================================================================
--- labs/jbossrules/branches/ming-serialization/drools-core/src/test/java/org/drools/base/EvaluatorFactoryTest.java 2008-03-12 20:58:14 UTC (rev 18900)
+++ labs/jbossrules/branches/ming-serialization/drools-core/src/test/java/org/drools/base/EvaluatorFactoryTest.java 2008-03-12 21:20:57 UTC (rev 18901)
@@ -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;
@@ -738,7 +741,7 @@
extractor,
null );
final ValueType coerced = evaluator.getCoercedValueType();
-
+
if ( coerced.isIntegerNumber() ) {
final LongVariableContextEntry context = new LongVariableContextEntry( extractor,
declaration,
@@ -831,6 +834,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/ming-serialization/drools-core/src/test/java/org/drools/base/TemporalEvaluatorFactoryTest.java
===================================================================
--- labs/jbossrules/branches/ming-serialization/drools-core/src/test/java/org/drools/base/TemporalEvaluatorFactoryTest.java 2008-03-12 20:58:14 UTC (rev 18900)
+++ labs/jbossrules/branches/ming-serialization/drools-core/src/test/java/org/drools/base/TemporalEvaluatorFactoryTest.java 2008-03-12 21:20:57 UTC (rev 18901)
@@ -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;
Modified: labs/jbossrules/branches/ming-serialization/drools-core/src/test/java/org/drools/event/AgendaEventSupportTest.java
===================================================================
--- labs/jbossrules/branches/ming-serialization/drools-core/src/test/java/org/drools/event/AgendaEventSupportTest.java 2008-03-12 20:58:14 UTC (rev 18900)
+++ labs/jbossrules/branches/ming-serialization/drools-core/src/test/java/org/drools/event/AgendaEventSupportTest.java 2008-03-12 21:20:57 UTC (rev 18901)
@@ -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/ming-serialization/drools-core/src/test/java/org/drools/event/RuleBaseEventListenerTest.java
===================================================================
--- labs/jbossrules/branches/ming-serialization/drools-core/src/test/java/org/drools/event/RuleBaseEventListenerTest.java 2008-03-12 20:58:14 UTC (rev 18900)
+++ labs/jbossrules/branches/ming-serialization/drools-core/src/test/java/org/drools/event/RuleBaseEventListenerTest.java 2008-03-12 21:20:57 UTC (rev 18901)
@@ -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" );
@@ -299,32 +317,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/ming-serialization/drools-core/src/test/java/org/drools/examples/manners/BaseMannersTest.java
===================================================================
--- labs/jbossrules/branches/ming-serialization/drools-core/src/test/java/org/drools/examples/manners/BaseMannersTest.java 2008-03-12 20:58:14 UTC (rev 18900)
+++ labs/jbossrules/branches/ming-serialization/drools-core/src/test/java/org/drools/examples/manners/BaseMannersTest.java 2008-03-12 21:20:57 UTC (rev 18901)
@@ -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/ming-serialization/drools-core/src/test/java/org/drools/examples/manners/Chosen.java
===================================================================
--- labs/jbossrules/branches/ming-serialization/drools-core/src/test/java/org/drools/examples/manners/Chosen.java 2008-03-12 20:58:14 UTC (rev 18900)
+++ labs/jbossrules/branches/ming-serialization/drools-core/src/test/java/org/drools/examples/manners/Chosen.java 2008-03-12 21:20:57 UTC (rev 18901)
@@ -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/ming-serialization/drools-core/src/test/java/org/drools/examples/manners/Context.java
===================================================================
--- labs/jbossrules/branches/ming-serialization/drools-core/src/test/java/org/drools/examples/manners/Context.java 2008-03-12 20:58:14 UTC (rev 18900)
+++ labs/jbossrules/branches/ming-serialization/drools-core/src/test/java/org/drools/examples/manners/Context.java 2008-03-12 21:20:57 UTC (rev 18901)
@@ -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/ming-serialization/drools-core/src/test/java/org/drools/examples/manners/Guest.java
===================================================================
--- labs/jbossrules/branches/ming-serialization/drools-core/src/test/java/org/drools/examples/manners/Guest.java 2008-03-12 20:58:14 UTC (rev 18900)
+++ labs/jbossrules/branches/ming-serialization/drools-core/src/test/java/org/drools/examples/manners/Guest.java 2008-03-12 21:20:57 UTC (rev 18901)
@@ -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/ming-serialization/drools-core/src/test/java/org/drools/examples/manners/LastSeat.java
===================================================================
--- labs/jbossrules/branches/ming-serialization/drools-core/src/test/java/org/drools/examples/manners/LastSeat.java 2008-03-12 20:58:14 UTC (rev 18900)
+++ labs/jbossrules/branches/ming-serialization/drools-core/src/test/java/org/drools/examples/manners/LastSeat.java 2008-03-12 21:20:57 UTC (rev 18901)
@@ -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/ming-serialization/drools-core/src/test/java/org/drools/examples/manners/Seating.java
===================================================================
--- labs/jbossrules/branches/ming-serialization/drools-core/src/test/java/org/drools/examples/manners/Seating.java 2008-03-12 20:58:14 UTC (rev 18900)
+++ labs/jbossrules/branches/ming-serialization/drools-core/src/test/java/org/drools/examples/manners/Seating.java 2008-03-12 21:20:57 UTC (rev 18901)
@@ -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;
}
Modified: labs/jbossrules/branches/ming-serialization/drools-core/src/test/java/org/drools/reteoo/AgendaTest.java
===================================================================
--- labs/jbossrules/branches/ming-serialization/drools-core/src/test/java/org/drools/reteoo/AgendaTest.java 2008-03-12 20:58:14 UTC (rev 18900)
+++ labs/jbossrules/branches/ming-serialization/drools-core/src/test/java/org/drools/reteoo/AgendaTest.java 2008-03-12 21:20:57 UTC (rev 18901)
@@ -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/ming-serialization/drools-core/src/test/java/org/drools/reteoo/BaseNodeTest.java
===================================================================
--- labs/jbossrules/branches/ming-serialization/drools-core/src/test/java/org/drools/reteoo/BaseNodeTest.java 2008-03-12 20:58:14 UTC (rev 18900)
+++ labs/jbossrules/branches/ming-serialization/drools-core/src/test/java/org/drools/reteoo/BaseNodeTest.java 2008-03-12 21:20:57 UTC (rev 18901)
@@ -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 );
}
Modified: labs/jbossrules/branches/ming-serialization/drools-core/src/test/java/org/drools/reteoo/CompositeObjectSinkAdapterTest.java
===================================================================
--- labs/jbossrules/branches/ming-serialization/drools-core/src/test/java/org/drools/reteoo/CompositeObjectSinkAdapterTest.java 2008-03-12 20:58:14 UTC (rev 18900)
+++ labs/jbossrules/branches/ming-serialization/drools-core/src/test/java/org/drools/reteoo/CompositeObjectSinkAdapterTest.java 2008-03-12 21:20:57 UTC (rev 18901)
@@ -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/ming-serialization/drools-core/src/test/java/org/drools/reteoo/CrossProductTest.java
===================================================================
--- labs/jbossrules/branches/ming-serialization/drools-core/src/test/java/org/drools/reteoo/CrossProductTest.java 2008-03-12 20:58:14 UTC (rev 18900)
+++ labs/jbossrules/branches/ming-serialization/drools-core/src/test/java/org/drools/reteoo/CrossProductTest.java 2008-03-12 21:20:57 UTC (rev 18901)
@@ -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/ming-serialization/drools-core/src/test/java/org/drools/reteoo/LogicalAssertionTest.java
===================================================================
--- labs/jbossrules/branches/ming-serialization/drools-core/src/test/java/org/drools/reteoo/LogicalAssertionTest.java 2008-03-12 20:58:14 UTC (rev 18900)
+++ labs/jbossrules/branches/ming-serialization/drools-core/src/test/java/org/drools/reteoo/LogicalAssertionTest.java 2008-03-12 21:20:57 UTC (rev 18901)
@@ -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/ming-serialization/drools-core/src/test/java/org/drools/reteoo/MockAccumulator.java
===================================================================
--- labs/jbossrules/branches/ming-serialization/drools-core/src/test/java/org/drools/reteoo/MockAccumulator.java 2008-03-12 20:58:14 UTC (rev 18900)
+++ labs/jbossrules/branches/ming-serialization/drools-core/src/test/java/org/drools/reteoo/MockAccumulator.java 2008-03-12 21:20:57 UTC (rev 18901)
@@ -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/ming-serialization/drools-core/src/test/java/org/drools/reteoo/MockEvalCondition.java
===================================================================
--- labs/jbossrules/branches/ming-serialization/drools-core/src/test/java/org/drools/reteoo/MockEvalCondition.java 2008-03-12 20:58:14 UTC (rev 18900)
+++ labs/jbossrules/branches/ming-serialization/drools-core/src/test/java/org/drools/reteoo/MockEvalCondition.java 2008-03-12 21:20:57 UTC (rev 18901)
@@ -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/ming-serialization/drools-core/src/test/java/org/drools/reteoo/OtherwiseTest.java
===================================================================
--- labs/jbossrules/branches/ming-serialization/drools-core/src/test/java/org/drools/reteoo/OtherwiseTest.java 2008-03-12 20:58:14 UTC (rev 18900)
+++ labs/jbossrules/branches/ming-serialization/drools-core/src/test/java/org/drools/reteoo/OtherwiseTest.java 2008-03-12 21:20:57 UTC (rev 18901)
@@ -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/ming-serialization/drools-core/src/test/java/org/drools/reteoo/ReteooBuilderTest.java
===================================================================
--- labs/jbossrules/branches/ming-serialization/drools-core/src/test/java/org/drools/reteoo/ReteooBuilderTest.java 2008-03-12 20:58:14 UTC (rev 18900)
+++ labs/jbossrules/branches/ming-serialization/drools-core/src/test/java/org/drools/reteoo/ReteooBuilderTest.java 2008-03-12 21:20:57 UTC (rev 18901)
@@ -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/ming-serialization/drools-core/src/test/java/org/drools/reteoo/RuleFlowGroupTest.java
===================================================================
--- labs/jbossrules/branches/ming-serialization/drools-core/src/test/java/org/drools/reteoo/RuleFlowGroupTest.java 2008-03-12 20:58:14 UTC (rev 18900)
+++ labs/jbossrules/branches/ming-serialization/drools-core/src/test/java/org/drools/reteoo/RuleFlowGroupTest.java 2008-03-12 21:20:57 UTC (rev 18901)
@@ -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/ming-serialization/drools-core/src/test/java/org/drools/reteoo/SchedulerTest.java
===================================================================
--- labs/jbossrules/branches/ming-serialization/drools-core/src/test/java/org/drools/reteoo/SchedulerTest.java 2008-03-12 20:58:14 UTC (rev 18900)
+++ labs/jbossrules/branches/ming-serialization/drools-core/src/test/java/org/drools/reteoo/SchedulerTest.java 2008-03-12 21:20:57 UTC (rev 18901)
@@ -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/ming-serialization/drools-core/src/test/java/org/drools/reteoo/builder/ReteooRuleBuilderTest.java
===================================================================
--- labs/jbossrules/branches/ming-serialization/drools-core/src/test/java/org/drools/reteoo/builder/ReteooRuleBuilderTest.java 2008-03-12 20:58:14 UTC (rev 18900)
+++ labs/jbossrules/branches/ming-serialization/drools-core/src/test/java/org/drools/reteoo/builder/ReteooRuleBuilderTest.java 2008-03-12 21:20:57 UTC (rev 18901)
@@ -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 );
Modified: labs/jbossrules/branches/ming-serialization/drools-core/src/test/java/org/drools/rule/FieldConstraintTest.java
===================================================================
--- labs/jbossrules/branches/ming-serialization/drools-core/src/test/java/org/drools/rule/FieldConstraintTest.java 2008-03-12 20:58:14 UTC (rev 18900)
+++ labs/jbossrules/branches/ming-serialization/drools-core/src/test/java/org/drools/rule/FieldConstraintTest.java 2008-03-12 21:20:57 UTC (rev 18901)
@@ -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/ming-serialization/drools-core/src/test/java/org/drools/rule/PackageCompilationDataTest.java
===================================================================
--- labs/jbossrules/branches/ming-serialization/drools-core/src/test/java/org/drools/rule/PackageCompilationDataTest.java 2008-03-12 20:58:14 UTC (rev 18900)
+++ labs/jbossrules/branches/ming-serialization/drools-core/src/test/java/org/drools/rule/PackageCompilationDataTest.java 2008-03-12 21:20:57 UTC (rev 18901)
@@ -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/ming-serialization/drools-core/src/test/java/org/drools/spi/MockConstraint.java
===================================================================
--- labs/jbossrules/branches/ming-serialization/drools-core/src/test/java/org/drools/spi/MockConstraint.java 2008-03-12 20:58:14 UTC (rev 18900)
+++ labs/jbossrules/branches/ming-serialization/drools-core/src/test/java/org/drools/spi/MockConstraint.java 2008-03-12 21:20:57 UTC (rev 18901)
@@ -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);
+ }
};
}
More information about the jboss-svn-commits
mailing list