[jboss-svn-commits] JBL Code SVN: r19201 - in labs/jbossrules/branches/ming-serialization: drools-core/src/main/java/org/drools and 11 other directories.
jboss-svn-commits at lists.jboss.org
jboss-svn-commits at lists.jboss.org
Fri Mar 21 21:58:05 EDT 2008
Author: mingjin
Date: 2008-03-21 21:58:04 -0400 (Fri, 21 Mar 2008)
New Revision: 19201
Added:
labs/jbossrules/branches/ming-serialization/drools-compiler/src/test/java/org/drools/reteoo/ReteooBuilderPerformanceTest.java
labs/jbossrules/branches/ming-serialization/drools-core/src/main/java/org/drools/WorkingMemoryEntryPoint.java
labs/jbossrules/branches/ming-serialization/drools-core/src/main/java/org/drools/common/InternalWorkingMemoryEntryPoint.java
labs/jbossrules/branches/ming-serialization/drools-core/src/main/java/org/drools/common/NamedEntryPoint.java
labs/jbossrules/branches/ming-serialization/drools-core/src/main/java/org/drools/common/ObjectTypeConfigurationRegistry.java
labs/jbossrules/branches/ming-serialization/drools-core/src/main/java/org/drools/common/SharedTemporalWorkingMemoryContext.java
labs/jbossrules/branches/ming-serialization/drools-core/src/main/java/org/drools/common/SharedWorkingMemoryContext.java
labs/jbossrules/branches/ming-serialization/drools-core/src/main/java/org/drools/reteoo/LeftTuple.java
labs/jbossrules/branches/ming-serialization/drools-core/src/main/java/org/drools/reteoo/LeftTupleMemory.java
labs/jbossrules/branches/ming-serialization/drools-core/src/main/java/org/drools/reteoo/LeftTupleSink.java
labs/jbossrules/branches/ming-serialization/drools-core/src/main/java/org/drools/reteoo/LeftTupleSinkNode.java
labs/jbossrules/branches/ming-serialization/drools-core/src/main/java/org/drools/reteoo/LeftTupleSinkNodeList.java
labs/jbossrules/branches/ming-serialization/drools-core/src/main/java/org/drools/reteoo/LeftTupleSource.java
labs/jbossrules/branches/ming-serialization/drools-core/src/main/java/org/drools/reteoo/ObjectSink.java
labs/jbossrules/branches/ming-serialization/drools-core/src/main/java/org/drools/rule/TypeDeclaration.java
labs/jbossrules/branches/ming-serialization/drools-core/src/main/java/org/drools/util/ArrayIterator.java
labs/jbossrules/branches/ming-serialization/drools-core/src/main/java/org/drools/util/ObjenesisFactory.java
labs/jbossrules/branches/ming-serialization/drools-core/src/test/java/org/drools/integrationtests/
labs/jbossrules/branches/ming-serialization/drools-core/src/test/java/org/drools/integrationtests/SerializationHelper.java
labs/jbossrules/branches/ming-serialization/drools-core/src/test/java/org/drools/rule/EnumSerialiationTest.java
labs/jbossrules/branches/ming-serialization/drools-jbrms/src/main/java/org/drools/brms/client/decisiontable/ActionInsertColumn.java
labs/jbossrules/branches/ming-serialization/drools-jbrms/src/main/java/org/drools/brms/client/ruleeditor/SaveEventListener.java
labs/jbossrules/branches/ming-serialization/drools-jbrms/src/main/java/org/drools/brms/public/images/gdst.gif
Removed:
labs/jbossrules/branches/ming-serialization/drools-core/src/main/java/org/drools/WorkingMemoryEntryPoint.java
labs/jbossrules/branches/ming-serialization/drools-core/src/main/java/org/drools/common/InternalWorkingMemoryEntryPoint.java
labs/jbossrules/branches/ming-serialization/drools-core/src/main/java/org/drools/common/NamedEntryPoint.java
labs/jbossrules/branches/ming-serialization/drools-core/src/main/java/org/drools/common/ObjectTypeConfigurationRegistry.java
labs/jbossrules/branches/ming-serialization/drools-core/src/main/java/org/drools/common/SharedTemporalWorkingMemoryContext.java
labs/jbossrules/branches/ming-serialization/drools-core/src/main/java/org/drools/common/SharedWorkingMemoryContext.java
labs/jbossrules/branches/ming-serialization/drools-core/src/main/java/org/drools/reteoo/LeftTuple.java
labs/jbossrules/branches/ming-serialization/drools-core/src/main/java/org/drools/reteoo/LeftTupleMemory.java
labs/jbossrules/branches/ming-serialization/drools-core/src/main/java/org/drools/reteoo/LeftTupleSink.java
labs/jbossrules/branches/ming-serialization/drools-core/src/main/java/org/drools/reteoo/LeftTupleSinkNode.java
labs/jbossrules/branches/ming-serialization/drools-core/src/main/java/org/drools/reteoo/LeftTupleSinkNodeList.java
labs/jbossrules/branches/ming-serialization/drools-core/src/main/java/org/drools/reteoo/LeftTupleSource.java
labs/jbossrules/branches/ming-serialization/drools-core/src/main/java/org/drools/reteoo/ObjectSink.java
labs/jbossrules/branches/ming-serialization/drools-core/src/main/java/org/drools/rule/TypeDeclaration.java
labs/jbossrules/branches/ming-serialization/drools-core/src/main/java/org/drools/util/ArrayIterator.java
labs/jbossrules/branches/ming-serialization/drools-core/src/main/java/org/drools/util/ObjenesisFactory.java
labs/jbossrules/branches/ming-serialization/drools-core/src/test/java/org/drools/integrationtests/
labs/jbossrules/branches/ming-serialization/drools-core/src/test/java/org/drools/integrationtests/SerializationHelper.java
labs/jbossrules/branches/ming-serialization/drools-core/src/test/java/org/drools/rule/EnumSerialiationTest.java
labs/jbossrules/branches/ming-serialization/drools-jbrms/src/main/java/org/drools/brms/client/decisiontable/ActionInsertColumn.java
labs/jbossrules/branches/ming-serialization/drools-jbrms/src/main/java/org/drools/brms/client/ruleeditor/SaveEventListener.java
labs/jbossrules/branches/ming-serialization/drools-jbrms/src/main/java/org/drools/brms/public/images/gdst.gif
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/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/LeftTupleSinkPropagator.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/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/builder/BuildUtils.java
Log:
JBRULES-1095 Rete build performance optimization/trunk merging
Added: labs/jbossrules/branches/ming-serialization/drools-compiler/src/test/java/org/drools/reteoo/ReteooBuilderPerformanceTest.java
===================================================================
--- labs/jbossrules/branches/ming-serialization/drools-compiler/src/test/java/org/drools/reteoo/ReteooBuilderPerformanceTest.java (rev 0)
+++ labs/jbossrules/branches/ming-serialization/drools-compiler/src/test/java/org/drools/reteoo/ReteooBuilderPerformanceTest.java 2008-03-22 01:58:04 UTC (rev 19201)
@@ -0,0 +1,87 @@
+package org.drools.reteoo;
+
+import org.drools.integrationtests.LargeRuleBase;
+import org.drools.compiler.DrlParser;
+import org.drools.compiler.PackageBuilder;
+import org.drools.compiler.DroolsParserException;
+import org.drools.compiler.PackageBuilderConfiguration;
+import org.drools.lang.descr.PackageDescr;
+import org.drools.RuleBaseConfiguration;
+
+import java.io.StringReader;
+
+import org.drools.rule.Package;
+import org.drools.rule.Rule;
+import junit.framework.TestCase;
+
+/**
+ * Created by IntelliJ IDEA. User: SG0521861 Date: Mar 20, 2008 Time: 2:36:47 PM To change this template use File |
+ * Settings | File Templates.
+ */
+public class ReteooBuilderPerformanceTest extends TestCase {
+ private static final int RULE_COUNT = Integer.parseInt(System.getProperty("rule.count", "1000"));
+ private static final int RETEBUILDER_COUNT = Integer.parseInt(System.getProperty("retebuilder.count", "1"));
+
+ public void testReteBuilder() throws DroolsParserException {
+ Package pkg = generatePackage(RULE_COUNT);
+ ReteooBuilder[] reteBuilders = getReteBuilders(RETEBUILDER_COUNT);
+
+ System.out.println("Adding rules to ReteBuilder");
+ long start = System.currentTimeMillis();
+ for (ReteooBuilder reteBuilder : reteBuilders) {
+ for (Rule rule : pkg.getRules())
+ reteBuilder.addRule(rule);
+ }
+ System.out.println("Added rules "+RULE_COUNT+" to each ReteBuilder's in "+
+ format(System.currentTimeMillis()-start));
+ }
+
+ private static ReteooBuilder[] getReteBuilders(int count) {
+ System.out.println("Creating "+count+" ReteBuilder's");
+ ReteooBuilder[] reteBuilders = new ReteooBuilder[count];
+ RuleBaseConfiguration conf = new RuleBaseConfiguration();
+
+ for (int i = 0; i < reteBuilders.length; i++) {
+ reteBuilders[i] = new ReteooBuilder(new ReteooRuleBase( conf ));
+ }
+ return reteBuilders;
+ }
+
+ private static Package generatePackage(int ruleCount) throws DroolsParserException {
+ StringReader reader = new StringReader(generateRules(ruleCount));
+
+ System.out.println("Parsing rules");
+ PackageDescr pkgDescr = new DrlParser().parse(reader);
+
+ System.out.println("Generating packages");
+ PackageBuilder pkgBuilder = new PackageBuilder(new PackageBuilderConfiguration());
+ pkgBuilder.addPackage(pkgDescr);
+
+ return pkgBuilder.getPackage();
+ }
+
+ private static String generateRules(int ruleCount) {
+ System.out.println("Generating "+ruleCount+" rules");
+ StringBuilder sb = new StringBuilder(LargeRuleBase.getHeader());
+
+ for (int i = 1; i <= ruleCount; i++) {
+ sb.append(LargeRuleBase.getTemplate1("testrule"+i, i));
+ }
+ return sb.toString();
+ }
+
+ private static final int MILLIS_IN_SECOND = 1000;
+ private static final int MILLIS_IN_MINUTE = MILLIS_IN_SECOND*60;
+ private static final int MILLIS_IN_HOUR = MILLIS_IN_MINUTE*60;
+
+ private static String format(long time) {
+ StringBuilder sb = new StringBuilder();
+
+ sb.append(time/MILLIS_IN_HOUR).append(':');
+ time = time % MILLIS_IN_HOUR;
+ sb.append(time/MILLIS_IN_MINUTE).append(':');
+ time = time % MILLIS_IN_MINUTE;
+ sb.append(time*1.0/MILLIS_IN_SECOND);
+ return sb.toString();
+ }
+}
\ No newline at end of file
Deleted: labs/jbossrules/branches/ming-serialization/drools-core/src/main/java/org/drools/WorkingMemoryEntryPoint.java
===================================================================
--- labs/jbossrules/branches/ming-serialization/drools-core/src/main/java/org/drools/WorkingMemoryEntryPoint.java 2008-03-22 00:35:33 UTC (rev 19200)
+++ labs/jbossrules/branches/ming-serialization/drools-core/src/main/java/org/drools/WorkingMemoryEntryPoint.java 2008-03-22 01:58:04 UTC (rev 19201)
@@ -1,105 +0,0 @@
-/*
- * 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.
- *
- * Created on Dec 14, 2007
- */
-package org.drools;
-
-import java.io.Serializable;
-
-/**
- * An interface for instances that allow handling of entry-point-scoped
- * facts
- *
- * @author etirelli
- */
-public interface WorkingMemoryEntryPoint
- extends
- Serializable {
- /**
- * 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;
-
- /**
- * 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;
-
- /**
- * Retract a fact.
- *
- * @param handle
- * The fact-handle associated with the fact to retract.
- *
- * @throws FactException
- * If a RuntimeException error occurs.
- */
- void retract(FactHandle handle) throws FactException;
-
- /**
- * 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);
-
- public WorkingMemoryEntryPoint getWorkingMemoryEntryPoint(String name);
-
-}
Copied: labs/jbossrules/branches/ming-serialization/drools-core/src/main/java/org/drools/WorkingMemoryEntryPoint.java (from rev 19199, labs/jbossrules/branches/ming-serialization/drools-core/src/main/java/org/drools/WorkingMemoryEntryPoint.java)
===================================================================
--- labs/jbossrules/branches/ming-serialization/drools-core/src/main/java/org/drools/WorkingMemoryEntryPoint.java (rev 0)
+++ labs/jbossrules/branches/ming-serialization/drools-core/src/main/java/org/drools/WorkingMemoryEntryPoint.java 2008-03-22 01:58:04 UTC (rev 19201)
@@ -0,0 +1,105 @@
+/*
+ * 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.
+ *
+ * Created on Dec 14, 2007
+ */
+package org.drools;
+
+import java.io.Serializable;
+
+/**
+ * An interface for instances that allow handling of entry-point-scoped
+ * facts
+ *
+ * @author etirelli
+ */
+public interface WorkingMemoryEntryPoint
+ extends
+ Serializable {
+ /**
+ * 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;
+
+ /**
+ * 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;
+
+ /**
+ * Retract a fact.
+ *
+ * @param handle
+ * The fact-handle associated with the fact to retract.
+ *
+ * @throws FactException
+ * If a RuntimeException error occurs.
+ */
+ void retract(FactHandle handle) throws FactException;
+
+ /**
+ * 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);
+
+ public WorkingMemoryEntryPoint getWorkingMemoryEntryPoint(String name);
+
+}
Deleted: labs/jbossrules/branches/ming-serialization/drools-core/src/main/java/org/drools/common/InternalWorkingMemoryEntryPoint.java
===================================================================
--- labs/jbossrules/branches/ming-serialization/drools-core/src/main/java/org/drools/common/InternalWorkingMemoryEntryPoint.java 2008-03-22 00:35:33 UTC (rev 19200)
+++ labs/jbossrules/branches/ming-serialization/drools-core/src/main/java/org/drools/common/InternalWorkingMemoryEntryPoint.java 2008-03-22 01:58:04 UTC (rev 19201)
@@ -1,7 +0,0 @@
-package org.drools.common;
-
-import org.drools.WorkingMemoryEntryPoint;
-
-public interface InternalWorkingMemoryEntryPoint extends WorkingMemoryEntryPoint {
- ObjectTypeConfigurationRegistry getObjectTypeConfigurationRegistry();
-}
Copied: labs/jbossrules/branches/ming-serialization/drools-core/src/main/java/org/drools/common/InternalWorkingMemoryEntryPoint.java (from rev 19199, labs/jbossrules/branches/ming-serialization/drools-core/src/main/java/org/drools/common/InternalWorkingMemoryEntryPoint.java)
===================================================================
--- labs/jbossrules/branches/ming-serialization/drools-core/src/main/java/org/drools/common/InternalWorkingMemoryEntryPoint.java (rev 0)
+++ labs/jbossrules/branches/ming-serialization/drools-core/src/main/java/org/drools/common/InternalWorkingMemoryEntryPoint.java 2008-03-22 01:58:04 UTC (rev 19201)
@@ -0,0 +1,7 @@
+package org.drools.common;
+
+import org.drools.WorkingMemoryEntryPoint;
+
+public interface InternalWorkingMemoryEntryPoint extends WorkingMemoryEntryPoint {
+ ObjectTypeConfigurationRegistry getObjectTypeConfigurationRegistry();
+}
Deleted: labs/jbossrules/branches/ming-serialization/drools-core/src/main/java/org/drools/common/NamedEntryPoint.java
===================================================================
--- labs/jbossrules/branches/ming-serialization/drools-core/src/main/java/org/drools/common/NamedEntryPoint.java 2008-03-22 00:35:33 UTC (rev 19200)
+++ labs/jbossrules/branches/ming-serialization/drools-core/src/main/java/org/drools/common/NamedEntryPoint.java 2008-03-22 01:58:04 UTC (rev 19201)
@@ -1,468 +0,0 @@
-/**
- *
- */
-package org.drools.common;
-
-import java.beans.PropertyChangeListener;
-import java.lang.reflect.InvocationTargetException;
-import java.lang.reflect.Method;
-import java.util.concurrent.locks.ReentrantLock;
-
-import org.drools.WorkingMemoryEntryPoint;
-import org.drools.FactException;
-import org.drools.FactHandle;
-import org.drools.RuntimeDroolsException;
-import org.drools.WorkingMemory;
-import org.drools.RuleBaseConfiguration.AssertBehaviour;
-import org.drools.base.ShadowProxy;
-import org.drools.event.WorkingMemoryEventSupport;
-import org.drools.reteoo.EntryPointNode;
-import org.drools.reteoo.ObjectTypeConf;
-import org.drools.rule.EntryPoint;
-import org.drools.rule.Rule;
-import org.drools.spi.Activation;
-import org.drools.spi.FactHandleFactory;
-import org.drools.spi.PropagationContext;
-
-public class NamedEntryPoint
- implements
- InternalWorkingMemoryEntryPoint {
- /** The arguments used when adding/removing a property change listener. */
- protected final Object[] addRemovePropertyChangeListenerArgs = new Object[]{this};
-
- private static final long serialVersionUID = 500;
-
- protected ObjectStore objectStore;
-
- protected transient InternalRuleBase ruleBase;
-
- protected EntryPoint entryPoint;
- protected EntryPointNode entryPointNode;
-
- private ObjectTypeConfigurationRegistry typeConfReg;
-
- private final AbstractWorkingMemory wm;
-
- private FactHandleFactory handleFactory;
-
- protected final ReentrantLock lock;
-
- public NamedEntryPoint(EntryPoint entryPoint,
- EntryPointNode entryPointNode,
- AbstractWorkingMemory wm) {
- this( entryPoint,
- entryPointNode,
- wm,
- new ReentrantLock() );
- }
-
- public NamedEntryPoint(EntryPoint entryPoint,
- EntryPointNode entryPointNode,
- AbstractWorkingMemory wm,
- ReentrantLock lock) {
- this.entryPoint = entryPoint;
- this.entryPointNode = entryPointNode;
- this.wm = wm;
- this.ruleBase = (InternalRuleBase) this.wm.getRuleBase();
- this.lock = lock;
- this.typeConfReg = new ObjectTypeConfigurationRegistry( this.ruleBase );
- this.handleFactory = this.wm.getFactHandleFactory();
- this.objectStore = new SingleThreadedObjectStore( this.ruleBase.getConfiguration(),
- this.lock );
- }
-
- /**
- * @see WorkingMemory
- */
- public FactHandle insert(final Object object) throws FactException {
- return insert( object, /* Not-Dynamic */
- false,
- false,
- null,
- null );
- }
-
- public FactHandle insert(final Object object,
- final boolean dynamic) throws FactException {
- return insert( object,
- dynamic,
- false,
- null,
- null );
- }
-
- protected FactHandle insert(final Object object,
- final boolean dynamic,
- boolean logical,
- final Rule rule,
- final Activation activation) throws FactException {
- if ( object == null ) {
- // you cannot assert a null object
- return null;
- }
-
- ObjectTypeConf typeConf = this.typeConfReg.getObjectTypeConf( this.entryPoint,
- object );
-
- InternalFactHandle handle = this.handleFactory.newFactHandle( object,
- typeConf.isEvent(),
- wm );
- this.objectStore.addHandle( handle,
- object );
-
- if ( dynamic ) {
- addPropertyChangeListener( object );
- }
-
- try {
- this.lock.lock();
- insert( handle,
- object,
- rule,
- activation );
-
- } finally {
- this.lock.unlock();
- }
- return handle;
- }
-
- protected void insert(final InternalFactHandle handle,
- final Object object,
- final Rule rule,
- final Activation activation) {
- this.ruleBase.executeQueuedActions();
-
- if ( activation != null ) {
- // release resources so that they can be GC'ed
- activation.getPropagationContext().releaseResources();
- }
- final PropagationContext propagationContext = new PropagationContextImpl( this.wm.getNextPropagationIdCounter(),
- PropagationContext.ASSERTION,
- rule,
- activation,
- -1,
- -1,
- this.entryPoint );
-
- this.entryPointNode.assertObject( handle,
- propagationContext,
- this.typeConfReg.getObjectTypeConf( this.entryPoint,
- object ),
- this.wm );
-
- this.wm.executeQueuedActions();
-
- this.wm.getWorkingMemoryEventSupport().fireObjectInserted( propagationContext,
- handle,
- object,
- wm );
- }
-
- public void update(final FactHandle handle,
- final Object object) throws FactException {
- update( handle,
- object,
- null,
- null );
- }
-
- protected void update(final FactHandle factHandle,
- final Object object,
- final Rule rule,
- final Activation activation) throws FactException {
- try {
- this.lock.lock();
- this.ruleBase.executeQueuedActions();
-
- final InternalFactHandle handle = (InternalFactHandle) factHandle;
- final Object originalObject = (handle.isShadowFact()) ? ((ShadowProxy) handle.getObject()).getShadowedObject() : handle.getObject();
-
- if ( handle.getId() == -1 || object == null ) {
- // the handle is invalid, most likely already retracted, so
- // return
- // and we cannot assert a null object
- return;
- }
-
- ObjectTypeConf typeConf = this.typeConfReg.getObjectTypeConf( this.entryPoint,
- object );
-
- if ( activation != null ) {
- // release resources so that they can be GC'ed
- activation.getPropagationContext().releaseResources();
- }
- // Nowretract any trace of the original fact
- final PropagationContext propagationContext = new PropagationContextImpl( this.wm.getNextPropagationIdCounter(),
- PropagationContext.MODIFICATION,
- rule,
- activation,
- -1,
- -1,
- this.entryPoint );
-
- this.entryPointNode.retractObject( handle,
- propagationContext,
- typeConf,
- this.wm );
-
- if ( (originalObject != object) || (this.ruleBase.getConfiguration().getAssertBehaviour() != AssertBehaviour.IDENTITY) ) {
- this.objectStore.removeHandle( handle );
-
- // set anyway, so that it updates the hashCodes
- handle.setObject( object );
- this.objectStore.addHandle( handle,
- object );
- }
-
- this.handleFactory.increaseFactHandleRecency( handle );
-
- this.entryPointNode.assertObject( handle,
- propagationContext,
- typeConf,
- this.wm );
-
- this.wm.getWorkingMemoryEventSupport().fireObjectUpdated( propagationContext,
- factHandle,
- originalObject,
- object,
- this.wm );
-
- propagationContext.clearRetractedTuples();
-
- this.wm.executeQueuedActions();
- } finally {
- this.lock.unlock();
- }
- }
-
- public void retract(final FactHandle handle) throws FactException {
- retract( handle,
- true,
- true,
- null,
- null );
- }
-
- public void retract(final FactHandle factHandle,
- final boolean removeLogical,
- final boolean updateEqualsMap,
- final Rule rule,
- final Activation activation) throws FactException {
- try {
- this.lock.lock();
- this.ruleBase.executeQueuedActions();
-
- final InternalFactHandle handle = (InternalFactHandle) factHandle;
- if ( handle.getId() == -1 ) {
- // can't retract an already retracted handle
- return;
- }
- removePropertyChangeListener( handle );
-
- if ( activation != null ) {
- // release resources so that they can be GC'ed
- activation.getPropagationContext().releaseResources();
- }
- final PropagationContext propagationContext = new PropagationContextImpl( this.wm.getNextPropagationIdCounter(),
- PropagationContext.RETRACTION,
- rule,
- activation,
- -1,
- -1,
- this.entryPoint );
-
- this.entryPointNode.retractObject( handle,
- propagationContext,
- this.wm );
-
- final Object object = handle.getObject();
-
- this.wm.getWorkingMemoryEventSupport().fireObjectRetracted( propagationContext,
- handle,
- object,
- this.wm );
-
- this.objectStore.removeHandle( handle );
-
- this.handleFactory.destroyFactHandle( handle );
-
- this.wm.executeQueuedActions();
- } finally {
- this.lock.unlock();
- }
- }
-
- public void modifyRetract(final FactHandle factHandle) {
- modifyRetract( factHandle,
- null,
- null );
- }
-
- public void modifyRetract(final FactHandle factHandle,
- final Rule rule,
- final Activation activation) {
- try {
- this.lock.lock();
- this.ruleBase.executeQueuedActions();
-
- final InternalFactHandle handle = (InternalFactHandle) factHandle;
- // final Object originalObject = (handle.isShadowFact()) ?
- // ((ShadowProxy) handle.getObject()).getShadowedObject() :
- // handle.getObject();
-
- if ( handle.getId() == -1 ) {
- // the handle is invalid, most likely already retracted, so
- // return
- return;
- }
-
- if ( activation != null ) {
- // release resources so that they can be GC'ed
- activation.getPropagationContext().releaseResources();
- }
- // Nowretract any trace of the original fact
- final PropagationContext propagationContext = new PropagationContextImpl( this.wm.getNextPropagationIdCounter(),
- PropagationContext.MODIFICATION,
- rule,
- activation,
- -1,
- -1,
- entryPoint );
-
- this.entryPointNode.retractObject( handle,
- propagationContext,
- this.wm );
-
- } finally {
- this.lock.unlock();
- }
- }
-
- public void modifyInsert(final FactHandle factHandle,
- final Object object) {
- modifyInsert( factHandle,
- object,
- null,
- null );
- }
-
- public void modifyInsert(final FactHandle factHandle,
- final Object object,
- final Rule rule,
- final Activation activation) {
- this.modifyInsert( EntryPoint.DEFAULT,
- factHandle,
- object,
- rule,
- activation );
- }
-
- protected void modifyInsert(final EntryPoint entryPoint,
- final FactHandle factHandle,
- final Object object,
- final Rule rule,
- final Activation activation) {
- try {
- this.lock.lock();
- this.ruleBase.executeQueuedActions();
-
- final InternalFactHandle handle = (InternalFactHandle) factHandle;
- final Object originalObject = (handle.isShadowFact()) ? ((ShadowProxy) handle.getObject()).getShadowedObject() : handle.getObject();
-
- this.handleFactory.increaseFactHandleRecency( handle );
-
- if ( activation != null ) {
- // release resources so that they can be GC'ed
- activation.getPropagationContext().releaseResources();
- }
- // Nowretract any trace of the original fact
- final PropagationContext propagationContext = new PropagationContextImpl( this.wm.getNextPropagationIdCounter(),
- PropagationContext.MODIFICATION,
- rule,
- activation,
- -1,
- -1,
- entryPoint );
-
- this.entryPointNode.assertObject( handle,
- propagationContext,
- this.wm );
-
- this.wm.getWorkingMemoryEventSupport().fireObjectUpdated( propagationContext,
- factHandle,
- originalObject,
- object,
- this.wm );
-
- propagationContext.clearRetractedTuples();
-
- this.wm.executeQueuedActions();
- } finally {
- this.lock.unlock();
- }
- }
-
- protected void addPropertyChangeListener(final Object object) {
- try {
- final Method method = object.getClass().getMethod( "addPropertyChangeListener",
- AbstractWorkingMemory.ADD_REMOVE_PROPERTY_CHANGE_LISTENER_ARG_TYPES );
-
- method.invoke( object,
- this.addRemovePropertyChangeListenerArgs );
- } catch ( final NoSuchMethodException e ) {
- System.err.println( "Warning: Method addPropertyChangeListener not found" + " on the class " + object.getClass() + " so Drools will be unable to process JavaBean" + " PropertyChangeEvents on the asserted Object" );
- } catch ( final IllegalArgumentException e ) {
- System.err.println( "Warning: The addPropertyChangeListener method" + " on the class " + object.getClass() + " does not take" + " a simple PropertyChangeListener argument" + " so Drools will be unable to process JavaBean"
- + " PropertyChangeEvents on the asserted Object" );
- } catch ( final IllegalAccessException e ) {
- System.err.println( "Warning: The addPropertyChangeListener method" + " on the class " + object.getClass() + " is not public" + " so Drools will be unable to process JavaBean" + " PropertyChangeEvents on the asserted Object" );
- } catch ( final InvocationTargetException e ) {
- System.err.println( "Warning: The addPropertyChangeListener method" + " on the class " + object.getClass() + " threw an InvocationTargetException" + " so Drools will be unable to process JavaBean"
- + " PropertyChangeEvents on the asserted Object: " + e.getMessage() );
- } catch ( final SecurityException e ) {
- System.err.println( "Warning: The SecurityManager controlling the class " + object.getClass() + " did not allow the lookup of a" + " addPropertyChangeListener method" + " so Drools will be unable to process JavaBean"
- + " PropertyChangeEvents on the asserted Object: " + e.getMessage() );
- }
- }
-
- protected void removePropertyChangeListener(final FactHandle handle) {
- Object object = null;
- try {
- object = ((InternalFactHandle) handle).getObject();
-
- if ( object != null ) {
- final Method mehod = object.getClass().getMethod( "removePropertyChangeListener",
- AbstractWorkingMemory.ADD_REMOVE_PROPERTY_CHANGE_LISTENER_ARG_TYPES );
-
- mehod.invoke( object,
- this.addRemovePropertyChangeListenerArgs );
- }
- } catch ( final NoSuchMethodException e ) {
- // The removePropertyChangeListener method on the class
- // was not found so Drools will be unable to
- // stop processing JavaBean PropertyChangeEvents
- // on the retracted Object
- } catch ( final IllegalArgumentException e ) {
- throw new RuntimeDroolsException( "Warning: The removePropertyChangeListener method on the class " + object.getClass() + " does not take a simple PropertyChangeListener argument so Drools will be unable to stop processing JavaBean"
- + " PropertyChangeEvents on the retracted Object" );
- } catch ( final IllegalAccessException e ) {
- throw new RuntimeDroolsException( "Warning: The removePropertyChangeListener method on the class " + object.getClass() + " is not public so Drools will be unable to stop processing JavaBean PropertyChangeEvents on the retracted Object" );
- } catch ( final InvocationTargetException e ) {
- throw new RuntimeDroolsException( "Warning: The removePropertyChangeL istener method on the class " + object.getClass() + " threw an InvocationTargetException so Drools will be unable to stop processing JavaBean"
- + " PropertyChangeEvents on the retracted Object: " + e.getMessage() );
- } catch ( final SecurityException e ) {
- throw new RuntimeDroolsException( "Warning: The SecurityManager controlling the class " + object.getClass() + " did not allow the lookup of a removePropertyChangeListener method so Drools will be unable to stop processing JavaBean"
- + " PropertyChangeEvents on the retracted Object: " + e.getMessage() );
- }
- }
-
- public WorkingMemoryEntryPoint getWorkingMemoryEntryPoint(String name) {
- return this.wm.getWorkingMemoryEntryPoint( name );
- }
-
- public ObjectTypeConfigurationRegistry getObjectTypeConfigurationRegistry() {
- return this.typeConfReg;
- }
-
-}
\ No newline at end of file
Copied: labs/jbossrules/branches/ming-serialization/drools-core/src/main/java/org/drools/common/NamedEntryPoint.java (from rev 19199, labs/jbossrules/branches/ming-serialization/drools-core/src/main/java/org/drools/common/NamedEntryPoint.java)
===================================================================
--- labs/jbossrules/branches/ming-serialization/drools-core/src/main/java/org/drools/common/NamedEntryPoint.java (rev 0)
+++ labs/jbossrules/branches/ming-serialization/drools-core/src/main/java/org/drools/common/NamedEntryPoint.java 2008-03-22 01:58:04 UTC (rev 19201)
@@ -0,0 +1,468 @@
+/**
+ *
+ */
+package org.drools.common;
+
+import java.beans.PropertyChangeListener;
+import java.lang.reflect.InvocationTargetException;
+import java.lang.reflect.Method;
+import java.util.concurrent.locks.ReentrantLock;
+
+import org.drools.WorkingMemoryEntryPoint;
+import org.drools.FactException;
+import org.drools.FactHandle;
+import org.drools.RuntimeDroolsException;
+import org.drools.WorkingMemory;
+import org.drools.RuleBaseConfiguration.AssertBehaviour;
+import org.drools.base.ShadowProxy;
+import org.drools.event.WorkingMemoryEventSupport;
+import org.drools.reteoo.EntryPointNode;
+import org.drools.reteoo.ObjectTypeConf;
+import org.drools.rule.EntryPoint;
+import org.drools.rule.Rule;
+import org.drools.spi.Activation;
+import org.drools.spi.FactHandleFactory;
+import org.drools.spi.PropagationContext;
+
+public class NamedEntryPoint
+ implements
+ InternalWorkingMemoryEntryPoint {
+ /** The arguments used when adding/removing a property change listener. */
+ protected final Object[] addRemovePropertyChangeListenerArgs = new Object[]{this};
+
+ private static final long serialVersionUID = 500;
+
+ protected ObjectStore objectStore;
+
+ protected transient InternalRuleBase ruleBase;
+
+ protected EntryPoint entryPoint;
+ protected EntryPointNode entryPointNode;
+
+ private ObjectTypeConfigurationRegistry typeConfReg;
+
+ private final AbstractWorkingMemory wm;
+
+ private FactHandleFactory handleFactory;
+
+ protected final ReentrantLock lock;
+
+ public NamedEntryPoint(EntryPoint entryPoint,
+ EntryPointNode entryPointNode,
+ AbstractWorkingMemory wm) {
+ this( entryPoint,
+ entryPointNode,
+ wm,
+ new ReentrantLock() );
+ }
+
+ public NamedEntryPoint(EntryPoint entryPoint,
+ EntryPointNode entryPointNode,
+ AbstractWorkingMemory wm,
+ ReentrantLock lock) {
+ this.entryPoint = entryPoint;
+ this.entryPointNode = entryPointNode;
+ this.wm = wm;
+ this.ruleBase = (InternalRuleBase) this.wm.getRuleBase();
+ this.lock = lock;
+ this.typeConfReg = new ObjectTypeConfigurationRegistry( this.ruleBase );
+ this.handleFactory = this.wm.getFactHandleFactory();
+ this.objectStore = new SingleThreadedObjectStore( this.ruleBase.getConfiguration(),
+ this.lock );
+ }
+
+ /**
+ * @see WorkingMemory
+ */
+ public FactHandle insert(final Object object) throws FactException {
+ return insert( object, /* Not-Dynamic */
+ false,
+ false,
+ null,
+ null );
+ }
+
+ public FactHandle insert(final Object object,
+ final boolean dynamic) throws FactException {
+ return insert( object,
+ dynamic,
+ false,
+ null,
+ null );
+ }
+
+ protected FactHandle insert(final Object object,
+ final boolean dynamic,
+ boolean logical,
+ final Rule rule,
+ final Activation activation) throws FactException {
+ if ( object == null ) {
+ // you cannot assert a null object
+ return null;
+ }
+
+ ObjectTypeConf typeConf = this.typeConfReg.getObjectTypeConf( this.entryPoint,
+ object );
+
+ InternalFactHandle handle = this.handleFactory.newFactHandle( object,
+ typeConf.isEvent(),
+ wm );
+ this.objectStore.addHandle( handle,
+ object );
+
+ if ( dynamic ) {
+ addPropertyChangeListener( object );
+ }
+
+ try {
+ this.lock.lock();
+ insert( handle,
+ object,
+ rule,
+ activation );
+
+ } finally {
+ this.lock.unlock();
+ }
+ return handle;
+ }
+
+ protected void insert(final InternalFactHandle handle,
+ final Object object,
+ final Rule rule,
+ final Activation activation) {
+ this.ruleBase.executeQueuedActions();
+
+ if ( activation != null ) {
+ // release resources so that they can be GC'ed
+ activation.getPropagationContext().releaseResources();
+ }
+ final PropagationContext propagationContext = new PropagationContextImpl( this.wm.getNextPropagationIdCounter(),
+ PropagationContext.ASSERTION,
+ rule,
+ activation,
+ -1,
+ -1,
+ this.entryPoint );
+
+ this.entryPointNode.assertObject( handle,
+ propagationContext,
+ this.typeConfReg.getObjectTypeConf( this.entryPoint,
+ object ),
+ this.wm );
+
+ this.wm.executeQueuedActions();
+
+ this.wm.getWorkingMemoryEventSupport().fireObjectInserted( propagationContext,
+ handle,
+ object,
+ wm );
+ }
+
+ public void update(final FactHandle handle,
+ final Object object) throws FactException {
+ update( handle,
+ object,
+ null,
+ null );
+ }
+
+ protected void update(final FactHandle factHandle,
+ final Object object,
+ final Rule rule,
+ final Activation activation) throws FactException {
+ try {
+ this.lock.lock();
+ this.ruleBase.executeQueuedActions();
+
+ final InternalFactHandle handle = (InternalFactHandle) factHandle;
+ final Object originalObject = (handle.isShadowFact()) ? ((ShadowProxy) handle.getObject()).getShadowedObject() : handle.getObject();
+
+ if ( handle.getId() == -1 || object == null ) {
+ // the handle is invalid, most likely already retracted, so
+ // return
+ // and we cannot assert a null object
+ return;
+ }
+
+ ObjectTypeConf typeConf = this.typeConfReg.getObjectTypeConf( this.entryPoint,
+ object );
+
+ if ( activation != null ) {
+ // release resources so that they can be GC'ed
+ activation.getPropagationContext().releaseResources();
+ }
+ // Nowretract any trace of the original fact
+ final PropagationContext propagationContext = new PropagationContextImpl( this.wm.getNextPropagationIdCounter(),
+ PropagationContext.MODIFICATION,
+ rule,
+ activation,
+ -1,
+ -1,
+ this.entryPoint );
+
+ this.entryPointNode.retractObject( handle,
+ propagationContext,
+ typeConf,
+ this.wm );
+
+ if ( (originalObject != object) || (this.ruleBase.getConfiguration().getAssertBehaviour() != AssertBehaviour.IDENTITY) ) {
+ this.objectStore.removeHandle( handle );
+
+ // set anyway, so that it updates the hashCodes
+ handle.setObject( object );
+ this.objectStore.addHandle( handle,
+ object );
+ }
+
+ this.handleFactory.increaseFactHandleRecency( handle );
+
+ this.entryPointNode.assertObject( handle,
+ propagationContext,
+ typeConf,
+ this.wm );
+
+ this.wm.getWorkingMemoryEventSupport().fireObjectUpdated( propagationContext,
+ factHandle,
+ originalObject,
+ object,
+ this.wm );
+
+ propagationContext.clearRetractedTuples();
+
+ this.wm.executeQueuedActions();
+ } finally {
+ this.lock.unlock();
+ }
+ }
+
+ public void retract(final FactHandle handle) throws FactException {
+ retract( handle,
+ true,
+ true,
+ null,
+ null );
+ }
+
+ public void retract(final FactHandle factHandle,
+ final boolean removeLogical,
+ final boolean updateEqualsMap,
+ final Rule rule,
+ final Activation activation) throws FactException {
+ try {
+ this.lock.lock();
+ this.ruleBase.executeQueuedActions();
+
+ final InternalFactHandle handle = (InternalFactHandle) factHandle;
+ if ( handle.getId() == -1 ) {
+ // can't retract an already retracted handle
+ return;
+ }
+ removePropertyChangeListener( handle );
+
+ if ( activation != null ) {
+ // release resources so that they can be GC'ed
+ activation.getPropagationContext().releaseResources();
+ }
+ final PropagationContext propagationContext = new PropagationContextImpl( this.wm.getNextPropagationIdCounter(),
+ PropagationContext.RETRACTION,
+ rule,
+ activation,
+ -1,
+ -1,
+ this.entryPoint );
+
+ this.entryPointNode.retractObject( handle,
+ propagationContext,
+ this.wm );
+
+ final Object object = handle.getObject();
+
+ this.wm.getWorkingMemoryEventSupport().fireObjectRetracted( propagationContext,
+ handle,
+ object,
+ this.wm );
+
+ this.objectStore.removeHandle( handle );
+
+ this.handleFactory.destroyFactHandle( handle );
+
+ this.wm.executeQueuedActions();
+ } finally {
+ this.lock.unlock();
+ }
+ }
+
+ public void modifyRetract(final FactHandle factHandle) {
+ modifyRetract( factHandle,
+ null,
+ null );
+ }
+
+ public void modifyRetract(final FactHandle factHandle,
+ final Rule rule,
+ final Activation activation) {
+ try {
+ this.lock.lock();
+ this.ruleBase.executeQueuedActions();
+
+ final InternalFactHandle handle = (InternalFactHandle) factHandle;
+ // final Object originalObject = (handle.isShadowFact()) ?
+ // ((ShadowProxy) handle.getObject()).getShadowedObject() :
+ // handle.getObject();
+
+ if ( handle.getId() == -1 ) {
+ // the handle is invalid, most likely already retracted, so
+ // return
+ return;
+ }
+
+ if ( activation != null ) {
+ // release resources so that they can be GC'ed
+ activation.getPropagationContext().releaseResources();
+ }
+ // Nowretract any trace of the original fact
+ final PropagationContext propagationContext = new PropagationContextImpl( this.wm.getNextPropagationIdCounter(),
+ PropagationContext.MODIFICATION,
+ rule,
+ activation,
+ -1,
+ -1,
+ entryPoint );
+
+ this.entryPointNode.retractObject( handle,
+ propagationContext,
+ this.wm );
+
+ } finally {
+ this.lock.unlock();
+ }
+ }
+
+ public void modifyInsert(final FactHandle factHandle,
+ final Object object) {
+ modifyInsert( factHandle,
+ object,
+ null,
+ null );
+ }
+
+ public void modifyInsert(final FactHandle factHandle,
+ final Object object,
+ final Rule rule,
+ final Activation activation) {
+ this.modifyInsert( EntryPoint.DEFAULT,
+ factHandle,
+ object,
+ rule,
+ activation );
+ }
+
+ protected void modifyInsert(final EntryPoint entryPoint,
+ final FactHandle factHandle,
+ final Object object,
+ final Rule rule,
+ final Activation activation) {
+ try {
+ this.lock.lock();
+ this.ruleBase.executeQueuedActions();
+
+ final InternalFactHandle handle = (InternalFactHandle) factHandle;
+ final Object originalObject = (handle.isShadowFact()) ? ((ShadowProxy) handle.getObject()).getShadowedObject() : handle.getObject();
+
+ this.handleFactory.increaseFactHandleRecency( handle );
+
+ if ( activation != null ) {
+ // release resources so that they can be GC'ed
+ activation.getPropagationContext().releaseResources();
+ }
+ // Nowretract any trace of the original fact
+ final PropagationContext propagationContext = new PropagationContextImpl( this.wm.getNextPropagationIdCounter(),
+ PropagationContext.MODIFICATION,
+ rule,
+ activation,
+ -1,
+ -1,
+ entryPoint );
+
+ this.entryPointNode.assertObject( handle,
+ propagationContext,
+ this.wm );
+
+ this.wm.getWorkingMemoryEventSupport().fireObjectUpdated( propagationContext,
+ factHandle,
+ originalObject,
+ object,
+ this.wm );
+
+ propagationContext.clearRetractedTuples();
+
+ this.wm.executeQueuedActions();
+ } finally {
+ this.lock.unlock();
+ }
+ }
+
+ protected void addPropertyChangeListener(final Object object) {
+ try {
+ final Method method = object.getClass().getMethod( "addPropertyChangeListener",
+ AbstractWorkingMemory.ADD_REMOVE_PROPERTY_CHANGE_LISTENER_ARG_TYPES );
+
+ method.invoke( object,
+ this.addRemovePropertyChangeListenerArgs );
+ } catch ( final NoSuchMethodException e ) {
+ System.err.println( "Warning: Method addPropertyChangeListener not found" + " on the class " + object.getClass() + " so Drools will be unable to process JavaBean" + " PropertyChangeEvents on the asserted Object" );
+ } catch ( final IllegalArgumentException e ) {
+ System.err.println( "Warning: The addPropertyChangeListener method" + " on the class " + object.getClass() + " does not take" + " a simple PropertyChangeListener argument" + " so Drools will be unable to process JavaBean"
+ + " PropertyChangeEvents on the asserted Object" );
+ } catch ( final IllegalAccessException e ) {
+ System.err.println( "Warning: The addPropertyChangeListener method" + " on the class " + object.getClass() + " is not public" + " so Drools will be unable to process JavaBean" + " PropertyChangeEvents on the asserted Object" );
+ } catch ( final InvocationTargetException e ) {
+ System.err.println( "Warning: The addPropertyChangeListener method" + " on the class " + object.getClass() + " threw an InvocationTargetException" + " so Drools will be unable to process JavaBean"
+ + " PropertyChangeEvents on the asserted Object: " + e.getMessage() );
+ } catch ( final SecurityException e ) {
+ System.err.println( "Warning: The SecurityManager controlling the class " + object.getClass() + " did not allow the lookup of a" + " addPropertyChangeListener method" + " so Drools will be unable to process JavaBean"
+ + " PropertyChangeEvents on the asserted Object: " + e.getMessage() );
+ }
+ }
+
+ protected void removePropertyChangeListener(final FactHandle handle) {
+ Object object = null;
+ try {
+ object = ((InternalFactHandle) handle).getObject();
+
+ if ( object != null ) {
+ final Method mehod = object.getClass().getMethod( "removePropertyChangeListener",
+ AbstractWorkingMemory.ADD_REMOVE_PROPERTY_CHANGE_LISTENER_ARG_TYPES );
+
+ mehod.invoke( object,
+ this.addRemovePropertyChangeListenerArgs );
+ }
+ } catch ( final NoSuchMethodException e ) {
+ // The removePropertyChangeListener method on the class
+ // was not found so Drools will be unable to
+ // stop processing JavaBean PropertyChangeEvents
+ // on the retracted Object
+ } catch ( final IllegalArgumentException e ) {
+ throw new RuntimeDroolsException( "Warning: The removePropertyChangeListener method on the class " + object.getClass() + " does not take a simple PropertyChangeListener argument so Drools will be unable to stop processing JavaBean"
+ + " PropertyChangeEvents on the retracted Object" );
+ } catch ( final IllegalAccessException e ) {
+ throw new RuntimeDroolsException( "Warning: The removePropertyChangeListener method on the class " + object.getClass() + " is not public so Drools will be unable to stop processing JavaBean PropertyChangeEvents on the retracted Object" );
+ } catch ( final InvocationTargetException e ) {
+ throw new RuntimeDroolsException( "Warning: The removePropertyChangeL istener method on the class " + object.getClass() + " threw an InvocationTargetException so Drools will be unable to stop processing JavaBean"
+ + " PropertyChangeEvents on the retracted Object: " + e.getMessage() );
+ } catch ( final SecurityException e ) {
+ throw new RuntimeDroolsException( "Warning: The SecurityManager controlling the class " + object.getClass() + " did not allow the lookup of a removePropertyChangeListener method so Drools will be unable to stop processing JavaBean"
+ + " PropertyChangeEvents on the retracted Object: " + e.getMessage() );
+ }
+ }
+
+ public WorkingMemoryEntryPoint getWorkingMemoryEntryPoint(String name) {
+ return this.wm.getWorkingMemoryEntryPoint( name );
+ }
+
+ public ObjectTypeConfigurationRegistry getObjectTypeConfigurationRegistry() {
+ return this.typeConfReg;
+ }
+
+}
\ No newline at end of file
Deleted: labs/jbossrules/branches/ming-serialization/drools-core/src/main/java/org/drools/common/ObjectTypeConfigurationRegistry.java
===================================================================
--- labs/jbossrules/branches/ming-serialization/drools-core/src/main/java/org/drools/common/ObjectTypeConfigurationRegistry.java 2008-03-22 00:35:33 UTC (rev 19200)
+++ labs/jbossrules/branches/ming-serialization/drools-core/src/main/java/org/drools/common/ObjectTypeConfigurationRegistry.java 2008-03-22 01:58:04 UTC (rev 19201)
@@ -1,76 +0,0 @@
-package org.drools.common;
-
-import java.io.Serializable;
-import java.util.Collection;
-import java.util.HashMap;
-import java.util.Map;
-
-import org.drools.base.ShadowProxy;
-import org.drools.facttemplates.Fact;
-import org.drools.reteoo.ClassObjectTypeConf;
-import org.drools.reteoo.FactTemplateTypeConf;
-import org.drools.reteoo.ObjectTypeConf;
-import org.drools.rule.EntryPoint;
-
-public class ObjectTypeConfigurationRegistry implements Serializable {
- private InternalRuleBase ruleBase;
- private Map<Object, ObjectTypeConf> typeConfMap;
-
-
-
- public ObjectTypeConfigurationRegistry(InternalRuleBase ruleBase ) {
- super();
- this.ruleBase = ruleBase;
- this.typeConfMap = new HashMap<Object, ObjectTypeConf>();
- }
-
-
-
- /**
- * Returns the ObjectTypeConfiguration object for the given object or
- * creates a new one if none is found in the cache
- *
- * @param object
- * @return
- */
- public ObjectTypeConf getObjectTypeConf(EntryPoint entrypoint,
- Object object) {
-
- // first see if it's a ClassObjectTypeConf
- Class cls = null;
- if ( object instanceof ShadowProxy ) {
- cls = ((ShadowProxy) object).getShadowedObject().getClass();
- } else {
- cls = object.getClass();
- }
- ObjectTypeConf objectTypeConf = this.typeConfMap.get( cls );
-
- // Now see if it's something else
- if ( objectTypeConf == null ) {
- objectTypeConf = this.typeConfMap.get( object );
- }
-
-
- // it doesn't exist, so create it.
- if ( objectTypeConf == null ) {
- if ( object instanceof Fact ) {
- objectTypeConf = new FactTemplateTypeConf( entrypoint,
- ((Fact) object).getFactTemplate(),
- this.ruleBase );
- this.typeConfMap.put( object, objectTypeConf );
- } else {
- objectTypeConf = new ClassObjectTypeConf( entrypoint,
- cls,
- this.ruleBase );
- this.typeConfMap.put( cls, objectTypeConf );
- }
- }
-
- return objectTypeConf;
- }
-
-
- public Collection<ObjectTypeConf> values() {
- return this.typeConfMap.values();
- }
-}
Copied: labs/jbossrules/branches/ming-serialization/drools-core/src/main/java/org/drools/common/ObjectTypeConfigurationRegistry.java (from rev 19199, labs/jbossrules/branches/ming-serialization/drools-core/src/main/java/org/drools/common/ObjectTypeConfigurationRegistry.java)
===================================================================
--- labs/jbossrules/branches/ming-serialization/drools-core/src/main/java/org/drools/common/ObjectTypeConfigurationRegistry.java (rev 0)
+++ labs/jbossrules/branches/ming-serialization/drools-core/src/main/java/org/drools/common/ObjectTypeConfigurationRegistry.java 2008-03-22 01:58:04 UTC (rev 19201)
@@ -0,0 +1,76 @@
+package org.drools.common;
+
+import java.io.Serializable;
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.Map;
+
+import org.drools.base.ShadowProxy;
+import org.drools.facttemplates.Fact;
+import org.drools.reteoo.ClassObjectTypeConf;
+import org.drools.reteoo.FactTemplateTypeConf;
+import org.drools.reteoo.ObjectTypeConf;
+import org.drools.rule.EntryPoint;
+
+public class ObjectTypeConfigurationRegistry implements Serializable {
+ private InternalRuleBase ruleBase;
+ private Map<Object, ObjectTypeConf> typeConfMap;
+
+
+
+ public ObjectTypeConfigurationRegistry(InternalRuleBase ruleBase ) {
+ super();
+ this.ruleBase = ruleBase;
+ this.typeConfMap = new HashMap<Object, ObjectTypeConf>();
+ }
+
+
+
+ /**
+ * Returns the ObjectTypeConfiguration object for the given object or
+ * creates a new one if none is found in the cache
+ *
+ * @param object
+ * @return
+ */
+ public ObjectTypeConf getObjectTypeConf(EntryPoint entrypoint,
+ Object object) {
+
+ // first see if it's a ClassObjectTypeConf
+ Class cls = null;
+ if ( object instanceof ShadowProxy ) {
+ cls = ((ShadowProxy) object).getShadowedObject().getClass();
+ } else {
+ cls = object.getClass();
+ }
+ ObjectTypeConf objectTypeConf = this.typeConfMap.get( cls );
+
+ // Now see if it's something else
+ if ( objectTypeConf == null ) {
+ objectTypeConf = this.typeConfMap.get( object );
+ }
+
+
+ // it doesn't exist, so create it.
+ if ( objectTypeConf == null ) {
+ if ( object instanceof Fact ) {
+ objectTypeConf = new FactTemplateTypeConf( entrypoint,
+ ((Fact) object).getFactTemplate(),
+ this.ruleBase );
+ this.typeConfMap.put( object, objectTypeConf );
+ } else {
+ objectTypeConf = new ClassObjectTypeConf( entrypoint,
+ cls,
+ this.ruleBase );
+ this.typeConfMap.put( cls, objectTypeConf );
+ }
+ }
+
+ return objectTypeConf;
+ }
+
+
+ public Collection<ObjectTypeConf> values() {
+ return this.typeConfMap.values();
+ }
+}
Deleted: labs/jbossrules/branches/ming-serialization/drools-core/src/main/java/org/drools/common/SharedTemporalWorkingMemoryContext.java
===================================================================
--- labs/jbossrules/branches/ming-serialization/drools-core/src/main/java/org/drools/common/SharedTemporalWorkingMemoryContext.java 2008-03-22 00:35:33 UTC (rev 19200)
+++ labs/jbossrules/branches/ming-serialization/drools-core/src/main/java/org/drools/common/SharedTemporalWorkingMemoryContext.java 2008-03-22 01:58:04 UTC (rev 19201)
@@ -1,33 +0,0 @@
-package org.drools.common;
-
-import java.util.HashMap;
-import java.util.LinkedList;
-import java.util.List;
-import java.util.Map;
-
-import org.drools.base.MapGlobalResolver;
-import org.drools.event.AgendaEventSupport;
-import org.drools.event.RuleFlowEventSupport;
-import org.drools.event.WorkingMemoryEventSupport;
-import org.drools.process.instance.ProcessInstanceFactory;
-import org.drools.process.instance.WorkItemManager;
-import org.drools.rule.TimeMachine;
-import org.drools.spi.FactHandleFactory;
-import org.drools.spi.GlobalResolver;
-import org.drools.temporal.SessionClock;
-
-public class SharedTemporalWorkingMemoryContext<T extends SessionClock> extends SharedWorkingMemoryContext {
- protected T sessionClock;
-
- public SharedTemporalWorkingMemoryContext(FactHandleFactory handleFactory, T sessionClock) {
- super( handleFactory );
- this.sessionClock = sessionClock;
- }
-
- public T getSessionClock() {
- return sessionClock;
- }
-
-
-
-}
Copied: labs/jbossrules/branches/ming-serialization/drools-core/src/main/java/org/drools/common/SharedTemporalWorkingMemoryContext.java (from rev 19199, labs/jbossrules/branches/ming-serialization/drools-core/src/main/java/org/drools/common/SharedTemporalWorkingMemoryContext.java)
===================================================================
--- labs/jbossrules/branches/ming-serialization/drools-core/src/main/java/org/drools/common/SharedTemporalWorkingMemoryContext.java (rev 0)
+++ labs/jbossrules/branches/ming-serialization/drools-core/src/main/java/org/drools/common/SharedTemporalWorkingMemoryContext.java 2008-03-22 01:58:04 UTC (rev 19201)
@@ -0,0 +1,33 @@
+package org.drools.common;
+
+import java.util.HashMap;
+import java.util.LinkedList;
+import java.util.List;
+import java.util.Map;
+
+import org.drools.base.MapGlobalResolver;
+import org.drools.event.AgendaEventSupport;
+import org.drools.event.RuleFlowEventSupport;
+import org.drools.event.WorkingMemoryEventSupport;
+import org.drools.process.instance.ProcessInstanceFactory;
+import org.drools.process.instance.WorkItemManager;
+import org.drools.rule.TimeMachine;
+import org.drools.spi.FactHandleFactory;
+import org.drools.spi.GlobalResolver;
+import org.drools.temporal.SessionClock;
+
+public class SharedTemporalWorkingMemoryContext<T extends SessionClock> extends SharedWorkingMemoryContext {
+ protected T sessionClock;
+
+ public SharedTemporalWorkingMemoryContext(FactHandleFactory handleFactory, T sessionClock) {
+ super( handleFactory );
+ this.sessionClock = sessionClock;
+ }
+
+ public T getSessionClock() {
+ return sessionClock;
+ }
+
+
+
+}
Deleted: labs/jbossrules/branches/ming-serialization/drools-core/src/main/java/org/drools/common/SharedWorkingMemoryContext.java
===================================================================
--- labs/jbossrules/branches/ming-serialization/drools-core/src/main/java/org/drools/common/SharedWorkingMemoryContext.java 2008-03-22 00:35:33 UTC (rev 19200)
+++ labs/jbossrules/branches/ming-serialization/drools-core/src/main/java/org/drools/common/SharedWorkingMemoryContext.java 2008-03-22 01:58:04 UTC (rev 19201)
@@ -1,119 +0,0 @@
-package org.drools.common;
-
-import java.util.HashMap;
-import java.util.LinkedList;
-import java.util.List;
-import java.util.Map;
-
-import org.drools.base.MapGlobalResolver;
-import org.drools.event.AgendaEventSupport;
-import org.drools.event.RuleFlowEventSupport;
-import org.drools.event.WorkingMemoryEventSupport;
-import org.drools.process.instance.ProcessInstanceFactory;
-import org.drools.process.instance.WorkItemManager;
-import org.drools.rule.TimeMachine;
-import org.drools.spi.FactHandleFactory;
-import org.drools.spi.GlobalResolver;
-import org.drools.temporal.SessionClock;
-
-public class SharedWorkingMemoryContext {
- protected InternalRuleBase ruleBase;
-
- protected FactHandleFactory handleFactory;
-
- /** Global values which are associated with this memory. */
- protected GlobalResolver globalResolver;
-
- /** The eventSupport */
- protected WorkingMemoryEventSupport workingMemoryEventSupport;
-
- protected AgendaEventSupport agendaEventSupport;
-
- protected RuleFlowEventSupport workflowEventSupport;
-
- protected List __ruleBaseEventListeners;
-
- protected long propagationIdCounter;
-
- private Map processInstances;
-
- private int processCounter;
-
- private WorkItemManager workItemManager;
-
- private Map<String, ProcessInstanceFactory> processInstanceFactories;
-
- private TimeMachine timeMachine;
-
- public SharedWorkingMemoryContext(FactHandleFactory handleFactory) {
- this.handleFactory = handleFactory;
-
- this.globalResolver = new MapGlobalResolver();
-
- this.workingMemoryEventSupport = new WorkingMemoryEventSupport();
- this.agendaEventSupport = new AgendaEventSupport();
- this.workflowEventSupport = new RuleFlowEventSupport();
- this.__ruleBaseEventListeners = new LinkedList();
-
- processInstanceFactories = new HashMap();
-
- timeMachine = new TimeMachine();
- }
-
- public Map getProcessInstances() {
- return processInstances;
- }
-
- public void setProcessInstances(Map processInstances) {
- this.processInstances = processInstances;
- }
-
- public WorkItemManager getWorkItemManager() {
- return workItemManager;
- }
-
- public void setWorkItemManager(WorkItemManager workItemManager) {
- this.workItemManager = workItemManager;
- }
-
- public TimeMachine getTimeMachine() {
- return timeMachine;
- }
-
- public void setTimeMachine(TimeMachine timeMachine) {
- this.timeMachine = timeMachine;
- }
-
- public FactHandleFactory getHandleFactory() {
- return handleFactory;
- }
-
- public GlobalResolver getGlobalResolver() {
- return globalResolver;
- }
-
- public WorkingMemoryEventSupport getWorkingMemoryEventSupport() {
- return workingMemoryEventSupport;
- }
-
- public AgendaEventSupport getAgendaEventSupport() {
- return agendaEventSupport;
- }
-
- public RuleFlowEventSupport getWorkflowEventSupport() {
- return workflowEventSupport;
- }
-
- public List get__ruleBaseEventListeners() {
- return __ruleBaseEventListeners;
- }
-
- public int getProcessCounter() {
- return processCounter;
- }
-
- public Map<String, ProcessInstanceFactory> getProcessInstanceFactories() {
- return processInstanceFactories;
- }
-
-}
Copied: labs/jbossrules/branches/ming-serialization/drools-core/src/main/java/org/drools/common/SharedWorkingMemoryContext.java (from rev 19199, labs/jbossrules/branches/ming-serialization/drools-core/src/main/java/org/drools/common/SharedWorkingMemoryContext.java)
===================================================================
--- labs/jbossrules/branches/ming-serialization/drools-core/src/main/java/org/drools/common/SharedWorkingMemoryContext.java (rev 0)
+++ labs/jbossrules/branches/ming-serialization/drools-core/src/main/java/org/drools/common/SharedWorkingMemoryContext.java 2008-03-22 01:58:04 UTC (rev 19201)
@@ -0,0 +1,119 @@
+package org.drools.common;
+
+import java.util.HashMap;
+import java.util.LinkedList;
+import java.util.List;
+import java.util.Map;
+
+import org.drools.base.MapGlobalResolver;
+import org.drools.event.AgendaEventSupport;
+import org.drools.event.RuleFlowEventSupport;
+import org.drools.event.WorkingMemoryEventSupport;
+import org.drools.process.instance.ProcessInstanceFactory;
+import org.drools.process.instance.WorkItemManager;
+import org.drools.rule.TimeMachine;
+import org.drools.spi.FactHandleFactory;
+import org.drools.spi.GlobalResolver;
+import org.drools.temporal.SessionClock;
+
+public class SharedWorkingMemoryContext {
+ protected InternalRuleBase ruleBase;
+
+ protected FactHandleFactory handleFactory;
+
+ /** Global values which are associated with this memory. */
+ protected GlobalResolver globalResolver;
+
+ /** The eventSupport */
+ protected WorkingMemoryEventSupport workingMemoryEventSupport;
+
+ protected AgendaEventSupport agendaEventSupport;
+
+ protected RuleFlowEventSupport workflowEventSupport;
+
+ protected List __ruleBaseEventListeners;
+
+ protected long propagationIdCounter;
+
+ private Map processInstances;
+
+ private int processCounter;
+
+ private WorkItemManager workItemManager;
+
+ private Map<String, ProcessInstanceFactory> processInstanceFactories;
+
+ private TimeMachine timeMachine;
+
+ public SharedWorkingMemoryContext(FactHandleFactory handleFactory) {
+ this.handleFactory = handleFactory;
+
+ this.globalResolver = new MapGlobalResolver();
+
+ this.workingMemoryEventSupport = new WorkingMemoryEventSupport();
+ this.agendaEventSupport = new AgendaEventSupport();
+ this.workflowEventSupport = new RuleFlowEventSupport();
+ this.__ruleBaseEventListeners = new LinkedList();
+
+ processInstanceFactories = new HashMap();
+
+ timeMachine = new TimeMachine();
+ }
+
+ public Map getProcessInstances() {
+ return processInstances;
+ }
+
+ public void setProcessInstances(Map processInstances) {
+ this.processInstances = processInstances;
+ }
+
+ public WorkItemManager getWorkItemManager() {
+ return workItemManager;
+ }
+
+ public void setWorkItemManager(WorkItemManager workItemManager) {
+ this.workItemManager = workItemManager;
+ }
+
+ public TimeMachine getTimeMachine() {
+ return timeMachine;
+ }
+
+ public void setTimeMachine(TimeMachine timeMachine) {
+ this.timeMachine = timeMachine;
+ }
+
+ public FactHandleFactory getHandleFactory() {
+ return handleFactory;
+ }
+
+ public GlobalResolver getGlobalResolver() {
+ return globalResolver;
+ }
+
+ public WorkingMemoryEventSupport getWorkingMemoryEventSupport() {
+ return workingMemoryEventSupport;
+ }
+
+ public AgendaEventSupport getAgendaEventSupport() {
+ return agendaEventSupport;
+ }
+
+ public RuleFlowEventSupport getWorkflowEventSupport() {
+ return workflowEventSupport;
+ }
+
+ public List get__ruleBaseEventListeners() {
+ return __ruleBaseEventListeners;
+ }
+
+ public int getProcessCounter() {
+ return processCounter;
+ }
+
+ public Map<String, ProcessInstanceFactory> getProcessInstanceFactories() {
+ return processInstanceFactories;
+ }
+
+}
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-22 00:35:33 UTC (rev 19200)
+++ labs/jbossrules/branches/ming-serialization/drools-core/src/main/java/org/drools/reteoo/CompositeObjectSinkAdapter.java 2008-03-22 01:58:04 UTC (rev 19201)
@@ -11,6 +11,7 @@
import org.drools.base.evaluators.Operator;
import org.drools.common.InternalFactHandle;
import org.drools.common.InternalWorkingMemory;
+import org.drools.common.BaseNode;
import org.drools.rule.LiteralConstraint;
import org.drools.spi.AlphaNodeFieldConstraint;
import org.drools.spi.Evaluator;
@@ -398,6 +399,35 @@
}
}
+ public BaseNode getMatchingNode(BaseNode candidate) {
+ if ( this.otherSinks != null ) {
+ for ( ObjectSinkNode sink = this.otherSinks.getFirst(); sink != null; sink = sink.getNextObjectSinkNode() ) {
+ if (candidate.equals( sink )) {
+ return (BaseNode)sink;
+ }
+ }
+ }
+
+ if ( this.hashableSinks != null ) {
+ for ( ObjectSinkNode sink = this.hashableSinks.getFirst(); sink != null; sink = sink.getNextObjectSinkNode() ) {
+ if (candidate.equals( sink )) {
+ return (BaseNode)sink;
+ }
+ }
+ }
+
+ if ( this.hashedSinkMap != null ) {
+ final Iterator it = this.hashedSinkMap.newIterator();
+ for ( ObjectEntry entry = (ObjectEntry) it.next(); entry != null; entry = (ObjectEntry) it.next() ) {
+ final ObjectSink sink = (ObjectSink) entry.getValue();
+ if (candidate.equals( sink )) {
+ return (BaseNode)sink;
+ }
+ }
+ }
+ return null;
+ }
+
public ObjectSink[] getSinks() {
final List list = new ArrayList();
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-22 00:35:33 UTC (rev 19200)
+++ labs/jbossrules/branches/ming-serialization/drools-core/src/main/java/org/drools/reteoo/CompositeTupleSinkAdapter.java 2008-03-22 01:58:04 UTC (rev 19201)
@@ -2,6 +2,7 @@
import org.drools.common.InternalFactHandle;
import org.drools.common.InternalWorkingMemory;
+import org.drools.common.BaseNode;
import org.drools.spi.PropagationContext;
import java.io.IOException;
@@ -98,6 +99,15 @@
}
}
+ public BaseNode getMatchingNode(BaseNode candidate) {
+ for ( LeftTupleSinkNode sink = this.sinks.getFirst(); sink != null; sink = sink.getNextLeftTupleSinkNode() ) {
+ if (candidate.equals(sink)) {
+ return (BaseNode)sink;
+ }
+ }
+ return null;
+ }
+
public LeftTupleSink[] getSinks() {
final LeftTupleSink[] sinkArray = new LeftTupleSink[this.sinks.size()];
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-22 00:35:33 UTC (rev 19200)
+++ labs/jbossrules/branches/ming-serialization/drools-core/src/main/java/org/drools/reteoo/EmptyObjectSinkAdapter.java 2008-03-22 01:58:04 UTC (rev 19201)
@@ -2,6 +2,7 @@
import org.drools.common.InternalFactHandle;
import org.drools.common.InternalWorkingMemory;
+import org.drools.common.BaseNode;
import org.drools.spi.PropagationContext;
import java.io.ObjectOutput;
@@ -43,6 +44,10 @@
final boolean useHash) {
}
+ public BaseNode getMatchingNode(BaseNode candidate) {
+ return null;
+ }
+
public ObjectSink[] getSinks() {
return SINK_LIST;
}
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-22 00:35:33 UTC (rev 19200)
+++ labs/jbossrules/branches/ming-serialization/drools-core/src/main/java/org/drools/reteoo/EmptyTupleSinkAdapter.java 2008-03-22 01:58:04 UTC (rev 19201)
@@ -2,6 +2,7 @@
import org.drools.common.InternalFactHandle;
import org.drools.common.InternalWorkingMemory;
+import org.drools.common.BaseNode;
import org.drools.spi.PropagationContext;
import java.io.ObjectOutput;
@@ -59,6 +60,10 @@
final InternalWorkingMemory workingMemory) {
}
+ public BaseNode getMatchingNode(BaseNode candidate) {
+ return null;
+ }
+
public LeftTupleSink[] getSinks() {
return new LeftTupleSink[]{};
}
Deleted: labs/jbossrules/branches/ming-serialization/drools-core/src/main/java/org/drools/reteoo/LeftTuple.java
===================================================================
--- labs/jbossrules/branches/ming-serialization/drools-core/src/main/java/org/drools/reteoo/LeftTuple.java 2008-03-22 00:35:33 UTC (rev 19200)
+++ labs/jbossrules/branches/ming-serialization/drools-core/src/main/java/org/drools/reteoo/LeftTuple.java 2008-03-22 01:58:04 UTC (rev 19201)
@@ -1,246 +0,0 @@
-package org.drools.reteoo;
-
-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;
-import org.drools.rule.Declaration;
-import org.drools.spi.Activation;
-import org.drools.spi.Tuple;
-import org.drools.util.Entry;
-
-public class LeftTuple
- implements
- Tuple,
- Entry {
- private static final long serialVersionUID = 400L;
-
- private int index;
-
- private InternalFactHandle handle;
-
- private LeftTuple parent;
-
- private Activation activation;
-
- private long recency;
-
- private int hashCode;
-
- private InternalFactHandle match;
-
- private Entry next;
-
- // ------------------------------------------------------------
- // Constructors
- // ------------------------------------------------------------
- public LeftTuple() {
-
- }
- public LeftTuple(final InternalFactHandle handle) {
- this.recency = handle.getRecency();
- this.handle = handle;
- int h = handle.hashCode();
- h += ~(h << 9);
- h ^= (h >>> 14);
- h += (h << 4);
- h ^= (h >>> 10);
- this.hashCode = h;
- }
-
- public LeftTuple(final LeftTuple tuple) {
- this.index = tuple.index;
- this.parent = tuple.parent;
- this.recency = tuple.recency;
- this.handle = tuple.handle;
- this.hashCode = tuple.hashCode();
- }
-
- public LeftTuple(final LeftTuple parentTuple,
- final InternalFactHandle handle) {
- this.index = parentTuple.index + 1;
- this.parent = parentTuple;
- this.recency = parentTuple.recency + handle.getRecency();
- this.handle = handle;
- this.hashCode = parentTuple.hashCode ^ (handle.hashCode() * 31);
- }
-
- public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
- index = in.readInt();
- handle = (InternalFactHandle)in.readObject();
- parent = (LeftTuple)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) {
- LeftTuple entry = this;
- while ( entry.index != index ) {
- entry = entry.parent;
- }
- return entry.handle;
- }
-
- public void setNext(final Entry next) {
- this.next = next;
- }
-
- public Entry getNext() {
- return this.next;
- }
-
- public InternalFactHandle getLastHandle() {
- return this.handle;
- }
-
- public InternalFactHandle get(final Declaration declaration) {
- return get( declaration.getPattern().getOffset() );
- }
-
- public Activation getActivation() {
- return this.activation;
- }
-
- /**
- * Returns the fact handles in reverse order
- */
- public InternalFactHandle[] getFactHandles() {
- final List list = new ArrayList();
- LeftTuple entry = this;
- while ( entry != null ) {
- list.add( entry.handle );
- entry = entry.parent;
- }
-
- return (InternalFactHandle[]) list.toArray( new InternalFactHandle[list.size()] );
- }
-
- public long getRecency() {
- return this.recency;
- }
-
-
- public InternalFactHandle getMatch() {
- return match;
- }
-
- public void setMatch(InternalFactHandle match) {
- this.match = match;
- }
-
- public void setActivation(final Activation activation) {
- this.activation = activation;
- }
-
- public int hashCode() {
- return this.hashCode;
- }
-
- public String toString() {
- final StringBuffer buffer = new StringBuffer();
-
- LeftTuple entry = this;
- while ( entry != null ) {
- //buffer.append( entry.handle );
- buffer.append( entry.handle + "\n" );
- entry = entry.parent;
- }
- return buffer.toString();
- }
-
- /**
- * We use this equals method to avoid the cast
- * @param tuple
- * @return
- */
- public boolean equals(final LeftTuple other) {
- // we know the object is never null and always of the type ReteTuple
- if ( other == this ) {
- return true;
- }
-
- // A ReteTuple is only the same if it has the same hashCode, factId and parent
- if ( (other == null) || (this.hashCode != other.hashCode) ) {
- return false;
- }
-
- if ( this.handle != other.handle ) {
- return false;
- }
-
- if ( this.parent == null ) {
- return (other.parent == null);
- } else {
- return this.parent.equals( other.parent );
- }
- }
-
- public boolean equals(final Object object) {
- // we know the object is never null and always of the type ReteTuple
- return equals( (LeftTuple) object );
- }
-
- public int size() {
- return this.index + 1;
- }
-
- /**
- * 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;
- */
- public LeftTuple getSubTuple(final int elements) {
- LeftTuple entry = this;
- if ( elements < this.size() ) {
- final int lastindex = elements - 1;
-
- while ( entry.index != lastindex ) {
- entry = entry.parent;
- }
- }
- return entry;
- }
-
- public Object[] toObjectArray() {
- Object[] objects = new Object[ this.index + 1 ];
- LeftTuple entry = this;
- while ( entry != null ) {
- Object object = entry.getLastHandle().getObject();
- if ( object instanceof ShadowProxy ) {
- object = ((ShadowProxy)object).getShadowedObject();
- }
- objects[entry.index] = object;
- entry = entry.parent;
- }
- return objects;
- }
-}
Copied: labs/jbossrules/branches/ming-serialization/drools-core/src/main/java/org/drools/reteoo/LeftTuple.java (from rev 19199, labs/jbossrules/branches/ming-serialization/drools-core/src/main/java/org/drools/reteoo/LeftTuple.java)
===================================================================
--- labs/jbossrules/branches/ming-serialization/drools-core/src/main/java/org/drools/reteoo/LeftTuple.java (rev 0)
+++ labs/jbossrules/branches/ming-serialization/drools-core/src/main/java/org/drools/reteoo/LeftTuple.java 2008-03-22 01:58:04 UTC (rev 19201)
@@ -0,0 +1,246 @@
+package org.drools.reteoo;
+
+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;
+import org.drools.rule.Declaration;
+import org.drools.spi.Activation;
+import org.drools.spi.Tuple;
+import org.drools.util.Entry;
+
+public class LeftTuple
+ implements
+ Tuple,
+ Entry {
+ private static final long serialVersionUID = 400L;
+
+ private int index;
+
+ private InternalFactHandle handle;
+
+ private LeftTuple parent;
+
+ private Activation activation;
+
+ private long recency;
+
+ private int hashCode;
+
+ private InternalFactHandle match;
+
+ private Entry next;
+
+ // ------------------------------------------------------------
+ // Constructors
+ // ------------------------------------------------------------
+ public LeftTuple() {
+
+ }
+ public LeftTuple(final InternalFactHandle handle) {
+ this.recency = handle.getRecency();
+ this.handle = handle;
+ int h = handle.hashCode();
+ h += ~(h << 9);
+ h ^= (h >>> 14);
+ h += (h << 4);
+ h ^= (h >>> 10);
+ this.hashCode = h;
+ }
+
+ public LeftTuple(final LeftTuple tuple) {
+ this.index = tuple.index;
+ this.parent = tuple.parent;
+ this.recency = tuple.recency;
+ this.handle = tuple.handle;
+ this.hashCode = tuple.hashCode();
+ }
+
+ public LeftTuple(final LeftTuple parentTuple,
+ final InternalFactHandle handle) {
+ this.index = parentTuple.index + 1;
+ this.parent = parentTuple;
+ this.recency = parentTuple.recency + handle.getRecency();
+ this.handle = handle;
+ this.hashCode = parentTuple.hashCode ^ (handle.hashCode() * 31);
+ }
+
+ public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
+ index = in.readInt();
+ handle = (InternalFactHandle)in.readObject();
+ parent = (LeftTuple)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) {
+ LeftTuple entry = this;
+ while ( entry.index != index ) {
+ entry = entry.parent;
+ }
+ return entry.handle;
+ }
+
+ public void setNext(final Entry next) {
+ this.next = next;
+ }
+
+ public Entry getNext() {
+ return this.next;
+ }
+
+ public InternalFactHandle getLastHandle() {
+ return this.handle;
+ }
+
+ public InternalFactHandle get(final Declaration declaration) {
+ return get( declaration.getPattern().getOffset() );
+ }
+
+ public Activation getActivation() {
+ return this.activation;
+ }
+
+ /**
+ * Returns the fact handles in reverse order
+ */
+ public InternalFactHandle[] getFactHandles() {
+ final List list = new ArrayList();
+ LeftTuple entry = this;
+ while ( entry != null ) {
+ list.add( entry.handle );
+ entry = entry.parent;
+ }
+
+ return (InternalFactHandle[]) list.toArray( new InternalFactHandle[list.size()] );
+ }
+
+ public long getRecency() {
+ return this.recency;
+ }
+
+
+ public InternalFactHandle getMatch() {
+ return match;
+ }
+
+ public void setMatch(InternalFactHandle match) {
+ this.match = match;
+ }
+
+ public void setActivation(final Activation activation) {
+ this.activation = activation;
+ }
+
+ public int hashCode() {
+ return this.hashCode;
+ }
+
+ public String toString() {
+ final StringBuffer buffer = new StringBuffer();
+
+ LeftTuple entry = this;
+ while ( entry != null ) {
+ //buffer.append( entry.handle );
+ buffer.append( entry.handle + "\n" );
+ entry = entry.parent;
+ }
+ return buffer.toString();
+ }
+
+ /**
+ * We use this equals method to avoid the cast
+ * @param tuple
+ * @return
+ */
+ public boolean equals(final LeftTuple other) {
+ // we know the object is never null and always of the type ReteTuple
+ if ( other == this ) {
+ return true;
+ }
+
+ // A ReteTuple is only the same if it has the same hashCode, factId and parent
+ if ( (other == null) || (this.hashCode != other.hashCode) ) {
+ return false;
+ }
+
+ if ( this.handle != other.handle ) {
+ return false;
+ }
+
+ if ( this.parent == null ) {
+ return (other.parent == null);
+ } else {
+ return this.parent.equals( other.parent );
+ }
+ }
+
+ public boolean equals(final Object object) {
+ // we know the object is never null and always of the type ReteTuple
+ return equals( (LeftTuple) object );
+ }
+
+ public int size() {
+ return this.index + 1;
+ }
+
+ /**
+ * 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;
+ */
+ public LeftTuple getSubTuple(final int elements) {
+ LeftTuple entry = this;
+ if ( elements < this.size() ) {
+ final int lastindex = elements - 1;
+
+ while ( entry.index != lastindex ) {
+ entry = entry.parent;
+ }
+ }
+ return entry;
+ }
+
+ public Object[] toObjectArray() {
+ Object[] objects = new Object[ this.index + 1 ];
+ LeftTuple entry = this;
+ while ( entry != null ) {
+ Object object = entry.getLastHandle().getObject();
+ if ( object instanceof ShadowProxy ) {
+ object = ((ShadowProxy)object).getShadowedObject();
+ }
+ objects[entry.index] = object;
+ entry = entry.parent;
+ }
+ return objects;
+ }
+}
Deleted: labs/jbossrules/branches/ming-serialization/drools-core/src/main/java/org/drools/reteoo/LeftTupleMemory.java
===================================================================
--- labs/jbossrules/branches/ming-serialization/drools-core/src/main/java/org/drools/reteoo/LeftTupleMemory.java 2008-03-22 00:35:33 UTC (rev 19200)
+++ labs/jbossrules/branches/ming-serialization/drools-core/src/main/java/org/drools/reteoo/LeftTupleMemory.java 2008-03-22 01:58:04 UTC (rev 19201)
@@ -1,26 +0,0 @@
-package org.drools.reteoo;
-
-import org.drools.common.InternalFactHandle;
-import org.drools.util.Entry;
-import org.drools.util.Iterator;
-
-public interface LeftTupleMemory {
- public Iterator iterator();
-
- public Iterator iterator(InternalFactHandle handle);
-
- public void add(LeftTuple tuple);
-
- public LeftTuple remove(LeftTuple leftTuple);
-
- public boolean contains(LeftTuple leftTuple);
-
- public boolean isIndexed();
-
- public int size();
-
- public Entry[] getTable();
-
- public Entry[] toArray();
-
-}
Copied: labs/jbossrules/branches/ming-serialization/drools-core/src/main/java/org/drools/reteoo/LeftTupleMemory.java (from rev 19199, labs/jbossrules/branches/ming-serialization/drools-core/src/main/java/org/drools/reteoo/LeftTupleMemory.java)
===================================================================
--- labs/jbossrules/branches/ming-serialization/drools-core/src/main/java/org/drools/reteoo/LeftTupleMemory.java (rev 0)
+++ labs/jbossrules/branches/ming-serialization/drools-core/src/main/java/org/drools/reteoo/LeftTupleMemory.java 2008-03-22 01:58:04 UTC (rev 19201)
@@ -0,0 +1,26 @@
+package org.drools.reteoo;
+
+import org.drools.common.InternalFactHandle;
+import org.drools.util.Entry;
+import org.drools.util.Iterator;
+
+public interface LeftTupleMemory {
+ public Iterator iterator();
+
+ public Iterator iterator(InternalFactHandle handle);
+
+ public void add(LeftTuple tuple);
+
+ public LeftTuple remove(LeftTuple leftTuple);
+
+ public boolean contains(LeftTuple leftTuple);
+
+ public boolean isIndexed();
+
+ public int size();
+
+ public Entry[] getTable();
+
+ public Entry[] toArray();
+
+}
Deleted: labs/jbossrules/branches/ming-serialization/drools-core/src/main/java/org/drools/reteoo/LeftTupleSink.java
===================================================================
--- labs/jbossrules/branches/ming-serialization/drools-core/src/main/java/org/drools/reteoo/LeftTupleSink.java 2008-03-22 00:35:33 UTC (rev 19200)
+++ labs/jbossrules/branches/ming-serialization/drools-core/src/main/java/org/drools/reteoo/LeftTupleSink.java 2008-03-22 01:58:04 UTC (rev 19201)
@@ -1,60 +0,0 @@
-package org.drools.reteoo;
-
-/*
- * 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.Externalizable;
-
-import org.drools.common.InternalWorkingMemory;
-import org.drools.spi.PropagationContext;
-
-/**
- * Receiver of propagated <code>ReteTuple</code>s from a
- * <code>TupleSource</code>.
- *
- * @see LeftTupleSource
- *
- * @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 LeftTupleSink
- extends
- Externalizable,
- Sink {
-
- /**
- * Assert a new <code>ReteTuple</code>.
- *
- * @param leftTuple
- * The <code>ReteTuple</code> to propagate.
- * @param context
- * The <code>PropagationContext</code> of the <code>WorkingMemory<code> action
- * @param workingMemory
- * the <code>WorkingMemory</code> session.
- */
- void assertLeftTuple(LeftTuple leftTuple,
- PropagationContext context,
- InternalWorkingMemory workingMemory);
-
- void retractLeftTuple(LeftTuple leftTuple,
- PropagationContext context,
- InternalWorkingMemory workingMemory);
-
- public boolean isLeftTupleMemoryEnabled();
-
- public void setLeftTupleMemoryEnabled(boolean tupleMemoryEnabled);
-}
Copied: labs/jbossrules/branches/ming-serialization/drools-core/src/main/java/org/drools/reteoo/LeftTupleSink.java (from rev 19199, labs/jbossrules/branches/ming-serialization/drools-core/src/main/java/org/drools/reteoo/LeftTupleSink.java)
===================================================================
--- labs/jbossrules/branches/ming-serialization/drools-core/src/main/java/org/drools/reteoo/LeftTupleSink.java (rev 0)
+++ labs/jbossrules/branches/ming-serialization/drools-core/src/main/java/org/drools/reteoo/LeftTupleSink.java 2008-03-22 01:58:04 UTC (rev 19201)
@@ -0,0 +1,60 @@
+package org.drools.reteoo;
+
+/*
+ * 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.Externalizable;
+
+import org.drools.common.InternalWorkingMemory;
+import org.drools.spi.PropagationContext;
+
+/**
+ * Receiver of propagated <code>ReteTuple</code>s from a
+ * <code>TupleSource</code>.
+ *
+ * @see LeftTupleSource
+ *
+ * @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 LeftTupleSink
+ extends
+ Externalizable,
+ Sink {
+
+ /**
+ * Assert a new <code>ReteTuple</code>.
+ *
+ * @param leftTuple
+ * The <code>ReteTuple</code> to propagate.
+ * @param context
+ * The <code>PropagationContext</code> of the <code>WorkingMemory<code> action
+ * @param workingMemory
+ * the <code>WorkingMemory</code> session.
+ */
+ void assertLeftTuple(LeftTuple leftTuple,
+ PropagationContext context,
+ InternalWorkingMemory workingMemory);
+
+ void retractLeftTuple(LeftTuple leftTuple,
+ PropagationContext context,
+ InternalWorkingMemory workingMemory);
+
+ public boolean isLeftTupleMemoryEnabled();
+
+ public void setLeftTupleMemoryEnabled(boolean tupleMemoryEnabled);
+}
Deleted: labs/jbossrules/branches/ming-serialization/drools-core/src/main/java/org/drools/reteoo/LeftTupleSinkNode.java
===================================================================
--- labs/jbossrules/branches/ming-serialization/drools-core/src/main/java/org/drools/reteoo/LeftTupleSinkNode.java 2008-03-22 00:35:33 UTC (rev 19200)
+++ labs/jbossrules/branches/ming-serialization/drools-core/src/main/java/org/drools/reteoo/LeftTupleSinkNode.java 2008-03-22 01:58:04 UTC (rev 19201)
@@ -1,59 +0,0 @@
-package org.drools.reteoo;
-
-/*
- * 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.
- */
-
-/**
- * Items placed in a <code>LinkedList<code> must implement this interface .
- *
- * @see LeftTupleSinkNodeList
- *
- * @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 LeftTupleSinkNode
- extends
- LeftTupleSink {
-
- /**
- * Returns the next node
- * @return
- * The next LinkedListNode
- */
- public LeftTupleSinkNode getNextLeftTupleSinkNode();
-
- /**
- * Sets the next node
- * @param next
- * The next LinkedListNode
- */
- public void setNextLeftTupleSinkNode(LeftTupleSinkNode next);
-
- /**
- * Returns the previous node
- * @return
- * The previous LinkedListNode
- */
- public LeftTupleSinkNode getPreviousLeftTupleSinkNode();
-
- /**
- * Sets the previous node
- * @param previous
- * The previous LinkedListNode
- */
- public void setPreviousLeftTupleSinkNode(LeftTupleSinkNode previous);
-
-}
Copied: labs/jbossrules/branches/ming-serialization/drools-core/src/main/java/org/drools/reteoo/LeftTupleSinkNode.java (from rev 19199, labs/jbossrules/branches/ming-serialization/drools-core/src/main/java/org/drools/reteoo/LeftTupleSinkNode.java)
===================================================================
--- labs/jbossrules/branches/ming-serialization/drools-core/src/main/java/org/drools/reteoo/LeftTupleSinkNode.java (rev 0)
+++ labs/jbossrules/branches/ming-serialization/drools-core/src/main/java/org/drools/reteoo/LeftTupleSinkNode.java 2008-03-22 01:58:04 UTC (rev 19201)
@@ -0,0 +1,59 @@
+package org.drools.reteoo;
+
+/*
+ * 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.
+ */
+
+/**
+ * Items placed in a <code>LinkedList<code> must implement this interface .
+ *
+ * @see LeftTupleSinkNodeList
+ *
+ * @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 LeftTupleSinkNode
+ extends
+ LeftTupleSink {
+
+ /**
+ * Returns the next node
+ * @return
+ * The next LinkedListNode
+ */
+ public LeftTupleSinkNode getNextLeftTupleSinkNode();
+
+ /**
+ * Sets the next node
+ * @param next
+ * The next LinkedListNode
+ */
+ public void setNextLeftTupleSinkNode(LeftTupleSinkNode next);
+
+ /**
+ * Returns the previous node
+ * @return
+ * The previous LinkedListNode
+ */
+ public LeftTupleSinkNode getPreviousLeftTupleSinkNode();
+
+ /**
+ * Sets the previous node
+ * @param previous
+ * The previous LinkedListNode
+ */
+ public void setPreviousLeftTupleSinkNode(LeftTupleSinkNode previous);
+
+}
Deleted: labs/jbossrules/branches/ming-serialization/drools-core/src/main/java/org/drools/reteoo/LeftTupleSinkNodeList.java
===================================================================
--- labs/jbossrules/branches/ming-serialization/drools-core/src/main/java/org/drools/reteoo/LeftTupleSinkNodeList.java 2008-03-22 00:35:33 UTC (rev 19200)
+++ labs/jbossrules/branches/ming-serialization/drools-core/src/main/java/org/drools/reteoo/LeftTupleSinkNodeList.java 2008-03-22 01:58:04 UTC (rev 19201)
@@ -1,243 +0,0 @@
-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.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/**
- * 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
- * ways to iterate the list.
- * <p>
- * Simple iterator:
- * <pre>
- * 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() ) {
- * }
- * </pre>
- *
- *
- * @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 LeftTupleSinkNodeList
- implements
- Externalizable {
- private static final long serialVersionUID = 400L;
-
- private LeftTupleSinkNode firstNode;
- private LeftTupleSinkNode lastNode;
-
- private int size;
-
- /**
- * Construct an empty <code>LinkedList</code>
- */
- public LeftTupleSinkNodeList() {
- }
-
- public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
- firstNode = (LeftTupleSinkNode)in.readObject();
- lastNode = (LeftTupleSinkNode)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
- * last nodes are set to the added node.
- *
- * @param node
- * The <code>TupleSinkNode</code> to be added
- */
- public void add(final LeftTupleSinkNode node) {
- if ( this.firstNode == null ) {
- this.firstNode = node;
- this.lastNode = node;;
- } else {
- this.lastNode.setNextLeftTupleSinkNode( node );
- node.setPreviousLeftTupleSinkNode( this.lastNode );
- this.lastNode = node;
- }
- this.size++;
- }
-
- /**
- * 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.
- */
- public void remove(final LeftTupleSinkNode node) {
- if ( (this.firstNode != node) && (this.lastNode != node) ) {
- node.getPreviousLeftTupleSinkNode().setNextLeftTupleSinkNode( node.getNextLeftTupleSinkNode() );
- node.getNextLeftTupleSinkNode().setPreviousLeftTupleSinkNode( node.getPreviousLeftTupleSinkNode() );
- this.size--;
- node.setPreviousLeftTupleSinkNode( null );
- node.setNextLeftTupleSinkNode( null );
-
- } else {
- if ( this.firstNode == node ) {
- removeFirst();
- } else if ( this.lastNode == node ) {
- removeLast();
- }
- }
- }
-
- /**
- * Return the first node in the list
- * @return
- * The first <code>TupleSinkNode</code>.
- */
- public final LeftTupleSinkNode getFirst() {
- return this.firstNode;
- }
-
- /**
- * Return the last node in the list
- * @return
- * The last <code>TupleSinkNode</code>.
- */
- public final LeftTupleSinkNode getLast() {
- return this.lastNode;
- }
-
- /**
- * 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>.
- */
- public LeftTupleSinkNode removeFirst() {
- if ( this.firstNode == null ) {
- return null;
- }
- final LeftTupleSinkNode node = this.firstNode;
- this.firstNode = node.getNextLeftTupleSinkNode();
- node.setNextLeftTupleSinkNode( null );
- if ( this.firstNode != null ) {
- this.firstNode.setPreviousLeftTupleSinkNode( null );
- } else {
- this.lastNode = null;
- }
- this.size--;
- return node;
- }
-
- /**
- * 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>.
- */
- public LeftTupleSinkNode removeLast() {
- if ( this.lastNode == null ) {
- return null;
- }
- final LeftTupleSinkNode node = this.lastNode;
- this.lastNode = node.getPreviousLeftTupleSinkNode();
- node.setPreviousLeftTupleSinkNode( null );
- if ( this.lastNode != null ) {
- this.lastNode.setNextLeftTupleSinkNode( null );
- } else {
- this.firstNode = this.lastNode;
- }
- this.size--;
- return node;
- }
-
- /**
- * @return
- * boolean value indicating the empty status of the list
- */
- public final boolean isEmpty() {
- return (this.firstNode == null);
- }
-
- /**
- * Iterates the list removing all the nodes until there are no more nodes to remove.
- */
- public void clear() {
- while ( removeFirst() != null ) {
- }
- }
-
- /**
- * @return
- * return size of the list as an int
- */
- public final int size() {
- return this.size;
- }
-
- /**
- * Returns a list iterator
- * @return
- */
- public Iterator iterator() {
- return new Iterator() {
- private LeftTupleSinkNode currentNode = null;
- private LeftTupleSinkNode nextNode = getFirst();
-
- public boolean hasNext() {
- return (this.nextNode != null);
- }
-
- public Object next() {
- this.currentNode = this.nextNode;
- if ( this.currentNode != null ) {
- this.nextNode = this.currentNode.getNextLeftTupleSinkNode();
- } else {
- throw new NoSuchElementException( "No more elements to return" );
- }
- return this.currentNode;
- }
-
- public void remove() {
- if ( this.currentNode != null ) {
- LeftTupleSinkNodeList.this.remove( this.currentNode );
- this.currentNode = null;
- } else {
- throw new IllegalStateException( "No item to remove. Call next() before calling remove()." );
- }
- }
- };
- }
-
-}
Copied: labs/jbossrules/branches/ming-serialization/drools-core/src/main/java/org/drools/reteoo/LeftTupleSinkNodeList.java (from rev 19199, labs/jbossrules/branches/ming-serialization/drools-core/src/main/java/org/drools/reteoo/LeftTupleSinkNodeList.java)
===================================================================
--- labs/jbossrules/branches/ming-serialization/drools-core/src/main/java/org/drools/reteoo/LeftTupleSinkNodeList.java (rev 0)
+++ labs/jbossrules/branches/ming-serialization/drools-core/src/main/java/org/drools/reteoo/LeftTupleSinkNodeList.java 2008-03-22 01:58:04 UTC (rev 19201)
@@ -0,0 +1,243 @@
+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.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/**
+ * 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
+ * ways to iterate the list.
+ * <p>
+ * Simple iterator:
+ * <pre>
+ * 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() ) {
+ * }
+ * </pre>
+ *
+ *
+ * @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 LeftTupleSinkNodeList
+ implements
+ Externalizable {
+ private static final long serialVersionUID = 400L;
+
+ private LeftTupleSinkNode firstNode;
+ private LeftTupleSinkNode lastNode;
+
+ private int size;
+
+ /**
+ * Construct an empty <code>LinkedList</code>
+ */
+ public LeftTupleSinkNodeList() {
+ }
+
+ public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
+ firstNode = (LeftTupleSinkNode)in.readObject();
+ lastNode = (LeftTupleSinkNode)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
+ * last nodes are set to the added node.
+ *
+ * @param node
+ * The <code>TupleSinkNode</code> to be added
+ */
+ public void add(final LeftTupleSinkNode node) {
+ if ( this.firstNode == null ) {
+ this.firstNode = node;
+ this.lastNode = node;;
+ } else {
+ this.lastNode.setNextLeftTupleSinkNode( node );
+ node.setPreviousLeftTupleSinkNode( this.lastNode );
+ this.lastNode = node;
+ }
+ this.size++;
+ }
+
+ /**
+ * 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.
+ */
+ public void remove(final LeftTupleSinkNode node) {
+ if ( (this.firstNode != node) && (this.lastNode != node) ) {
+ node.getPreviousLeftTupleSinkNode().setNextLeftTupleSinkNode( node.getNextLeftTupleSinkNode() );
+ node.getNextLeftTupleSinkNode().setPreviousLeftTupleSinkNode( node.getPreviousLeftTupleSinkNode() );
+ this.size--;
+ node.setPreviousLeftTupleSinkNode( null );
+ node.setNextLeftTupleSinkNode( null );
+
+ } else {
+ if ( this.firstNode == node ) {
+ removeFirst();
+ } else if ( this.lastNode == node ) {
+ removeLast();
+ }
+ }
+ }
+
+ /**
+ * Return the first node in the list
+ * @return
+ * The first <code>TupleSinkNode</code>.
+ */
+ public final LeftTupleSinkNode getFirst() {
+ return this.firstNode;
+ }
+
+ /**
+ * Return the last node in the list
+ * @return
+ * The last <code>TupleSinkNode</code>.
+ */
+ public final LeftTupleSinkNode getLast() {
+ return this.lastNode;
+ }
+
+ /**
+ * 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>.
+ */
+ public LeftTupleSinkNode removeFirst() {
+ if ( this.firstNode == null ) {
+ return null;
+ }
+ final LeftTupleSinkNode node = this.firstNode;
+ this.firstNode = node.getNextLeftTupleSinkNode();
+ node.setNextLeftTupleSinkNode( null );
+ if ( this.firstNode != null ) {
+ this.firstNode.setPreviousLeftTupleSinkNode( null );
+ } else {
+ this.lastNode = null;
+ }
+ this.size--;
+ return node;
+ }
+
+ /**
+ * 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>.
+ */
+ public LeftTupleSinkNode removeLast() {
+ if ( this.lastNode == null ) {
+ return null;
+ }
+ final LeftTupleSinkNode node = this.lastNode;
+ this.lastNode = node.getPreviousLeftTupleSinkNode();
+ node.setPreviousLeftTupleSinkNode( null );
+ if ( this.lastNode != null ) {
+ this.lastNode.setNextLeftTupleSinkNode( null );
+ } else {
+ this.firstNode = this.lastNode;
+ }
+ this.size--;
+ return node;
+ }
+
+ /**
+ * @return
+ * boolean value indicating the empty status of the list
+ */
+ public final boolean isEmpty() {
+ return (this.firstNode == null);
+ }
+
+ /**
+ * Iterates the list removing all the nodes until there are no more nodes to remove.
+ */
+ public void clear() {
+ while ( removeFirst() != null ) {
+ }
+ }
+
+ /**
+ * @return
+ * return size of the list as an int
+ */
+ public final int size() {
+ return this.size;
+ }
+
+ /**
+ * Returns a list iterator
+ * @return
+ */
+ public Iterator iterator() {
+ return new Iterator() {
+ private LeftTupleSinkNode currentNode = null;
+ private LeftTupleSinkNode nextNode = getFirst();
+
+ public boolean hasNext() {
+ return (this.nextNode != null);
+ }
+
+ public Object next() {
+ this.currentNode = this.nextNode;
+ if ( this.currentNode != null ) {
+ this.nextNode = this.currentNode.getNextLeftTupleSinkNode();
+ } else {
+ throw new NoSuchElementException( "No more elements to return" );
+ }
+ return this.currentNode;
+ }
+
+ public void remove() {
+ if ( this.currentNode != null ) {
+ LeftTupleSinkNodeList.this.remove( this.currentNode );
+ this.currentNode = null;
+ } else {
+ throw new IllegalStateException( "No item to remove. Call next() before calling remove()." );
+ }
+ }
+ };
+ }
+
+}
Modified: labs/jbossrules/branches/ming-serialization/drools-core/src/main/java/org/drools/reteoo/LeftTupleSinkPropagator.java
===================================================================
--- labs/jbossrules/branches/ming-serialization/drools-core/src/main/java/org/drools/reteoo/LeftTupleSinkPropagator.java 2008-03-22 00:35:33 UTC (rev 19200)
+++ labs/jbossrules/branches/ming-serialization/drools-core/src/main/java/org/drools/reteoo/LeftTupleSinkPropagator.java 2008-03-22 01:58:04 UTC (rev 19201)
@@ -4,6 +4,7 @@
import org.drools.common.InternalFactHandle;
import org.drools.common.InternalWorkingMemory;
+import org.drools.common.BaseNode;
import org.drools.spi.PropagationContext;
public interface LeftTupleSinkPropagator
@@ -35,6 +36,8 @@
PropagationContext context,
InternalWorkingMemory workingMemory);
+ public BaseNode getMatchingNode(BaseNode candidate);
+
public LeftTupleSink[] getSinks();
// public void propagateNewTupleSink(TupleMatch tupleMatch,
Deleted: labs/jbossrules/branches/ming-serialization/drools-core/src/main/java/org/drools/reteoo/LeftTupleSource.java
===================================================================
--- labs/jbossrules/branches/ming-serialization/drools-core/src/main/java/org/drools/reteoo/LeftTupleSource.java 2008-03-22 00:35:33 UTC (rev 19200)
+++ labs/jbossrules/branches/ming-serialization/drools-core/src/main/java/org/drools/reteoo/LeftTupleSource.java 2008-03-22 01:58:04 UTC (rev 19201)
@@ -1,136 +0,0 @@
-package org.drools.reteoo;
-
-/*
- * 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.Externalizable;
-import java.io.IOException;
-import java.io.ObjectOutput;
-import java.io.ObjectInput;
-
-import org.drools.common.BaseNode;
-import org.drools.common.InternalWorkingMemory;
-import org.drools.spi.PropagationContext;
-
-/**
- * A source of <code>ReteTuple</code> s for a <code>TupleSink</code>.
- *
- * <p>
- * Nodes that propagate <code>Tuples</code> extend this class.
- * </p>
- *
- * @see LeftTupleSource
- * @see LeftTuple
- *
- * @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 LeftTupleSource extends BaseNode
- implements
- Externalizable {
- // ------------------------------------------------------------
- // Instance members
- // ------------------------------------------------------------
-
- /** The destination for <code>Tuples</code>. */
- protected LeftTupleSinkPropagator sink;
-
- // ------------------------------------------------------------
- // Constructors
- // ------------------------------------------------------------
- public LeftTupleSource() {
-
- }
-
- /**
- * Single parameter constructor that specifies the unique id of the node.
- *
- * @param id
- */
- LeftTupleSource(final int id) {
- super( id );
- this.sink = EmptyTupleSinkAdapter.getInstance();
- }
-
- // ------------------------------------------------------------
- // Instance methods
- // ------------------------------------------------------------
- public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
- super.readExternal(in);
- sink = (LeftTupleSinkPropagator)in.readObject();
- }
-
- public void writeExternal(ObjectOutput out) throws IOException {
- super.writeExternal(out);
- out.writeObject(sink);
- }
-
- /**
- * Adds the <code>TupleSink</code> so that it may receive
- * <code>Tuples</code> propagated from this <code>TupleSource</code>.
- *
- * @param tupleSink
- * The <code>TupleSink</code> to receive propagated
- * <code>Tuples</code>.
- */
- protected void addTupleSink(final LeftTupleSink tupleSink) {
- if ( this.sink instanceof EmptyTupleSinkAdapter ) {
- this.sink = new SingleTupleSinkAdapter( tupleSink );
- } else if ( this.sink instanceof SingleTupleSinkAdapter ) {
- final CompositeTupleSinkAdapter sinkAdapter = new CompositeTupleSinkAdapter();
- sinkAdapter.addTupleSink( this.sink.getSinks()[0] );
- sinkAdapter.addTupleSink( tupleSink );
- this.sink = sinkAdapter;
- } else {
- ((CompositeTupleSinkAdapter) this.sink).addTupleSink( tupleSink );
- }
- }
-
- /**
- * Removes the <code>TupleSink</code>
- *
- * @param tupleSink
- * The <code>TupleSink</code> to remove
- */
- protected void removeTupleSink(final LeftTupleSink tupleSink) {
- if ( this.sink instanceof EmptyTupleSinkAdapter ) {
- throw new IllegalArgumentException( "Cannot remove a sink, when the list of sinks is null" );
- }
-
- if ( this.sink instanceof SingleTupleSinkAdapter ) {
- this.sink = EmptyTupleSinkAdapter.getInstance();
- } else {
- final CompositeTupleSinkAdapter sinkAdapter = (CompositeTupleSinkAdapter) this.sink;
- sinkAdapter.removeTupleSink( tupleSink );
- if ( sinkAdapter.size() == 1 ) {
- this.sink = new SingleTupleSinkAdapter( sinkAdapter.getSinks()[0] );
- }
- }
- }
-
- public LeftTupleSinkPropagator getSinkPropagator() {
- return this.sink;
- }
-
- public abstract void updateSink(LeftTupleSink sink,
- PropagationContext context,
- InternalWorkingMemory workingMemory);
-
- public boolean isInUse() {
- return this.sink.size() > 0;
- }
-}
Copied: labs/jbossrules/branches/ming-serialization/drools-core/src/main/java/org/drools/reteoo/LeftTupleSource.java (from rev 19199, labs/jbossrules/branches/ming-serialization/drools-core/src/main/java/org/drools/reteoo/LeftTupleSource.java)
===================================================================
--- labs/jbossrules/branches/ming-serialization/drools-core/src/main/java/org/drools/reteoo/LeftTupleSource.java (rev 0)
+++ labs/jbossrules/branches/ming-serialization/drools-core/src/main/java/org/drools/reteoo/LeftTupleSource.java 2008-03-22 01:58:04 UTC (rev 19201)
@@ -0,0 +1,136 @@
+package org.drools.reteoo;
+
+/*
+ * 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.Externalizable;
+import java.io.IOException;
+import java.io.ObjectOutput;
+import java.io.ObjectInput;
+
+import org.drools.common.BaseNode;
+import org.drools.common.InternalWorkingMemory;
+import org.drools.spi.PropagationContext;
+
+/**
+ * A source of <code>ReteTuple</code> s for a <code>TupleSink</code>.
+ *
+ * <p>
+ * Nodes that propagate <code>Tuples</code> extend this class.
+ * </p>
+ *
+ * @see LeftTupleSource
+ * @see LeftTuple
+ *
+ * @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 LeftTupleSource extends BaseNode
+ implements
+ Externalizable {
+ // ------------------------------------------------------------
+ // Instance members
+ // ------------------------------------------------------------
+
+ /** The destination for <code>Tuples</code>. */
+ protected LeftTupleSinkPropagator sink;
+
+ // ------------------------------------------------------------
+ // Constructors
+ // ------------------------------------------------------------
+ public LeftTupleSource() {
+
+ }
+
+ /**
+ * Single parameter constructor that specifies the unique id of the node.
+ *
+ * @param id
+ */
+ LeftTupleSource(final int id) {
+ super( id );
+ this.sink = EmptyTupleSinkAdapter.getInstance();
+ }
+
+ // ------------------------------------------------------------
+ // Instance methods
+ // ------------------------------------------------------------
+ public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
+ super.readExternal(in);
+ sink = (LeftTupleSinkPropagator)in.readObject();
+ }
+
+ public void writeExternal(ObjectOutput out) throws IOException {
+ super.writeExternal(out);
+ out.writeObject(sink);
+ }
+
+ /**
+ * Adds the <code>TupleSink</code> so that it may receive
+ * <code>Tuples</code> propagated from this <code>TupleSource</code>.
+ *
+ * @param tupleSink
+ * The <code>TupleSink</code> to receive propagated
+ * <code>Tuples</code>.
+ */
+ protected void addTupleSink(final LeftTupleSink tupleSink) {
+ if ( this.sink instanceof EmptyTupleSinkAdapter ) {
+ this.sink = new SingleTupleSinkAdapter( tupleSink );
+ } else if ( this.sink instanceof SingleTupleSinkAdapter ) {
+ final CompositeTupleSinkAdapter sinkAdapter = new CompositeTupleSinkAdapter();
+ sinkAdapter.addTupleSink( this.sink.getSinks()[0] );
+ sinkAdapter.addTupleSink( tupleSink );
+ this.sink = sinkAdapter;
+ } else {
+ ((CompositeTupleSinkAdapter) this.sink).addTupleSink( tupleSink );
+ }
+ }
+
+ /**
+ * Removes the <code>TupleSink</code>
+ *
+ * @param tupleSink
+ * The <code>TupleSink</code> to remove
+ */
+ protected void removeTupleSink(final LeftTupleSink tupleSink) {
+ if ( this.sink instanceof EmptyTupleSinkAdapter ) {
+ throw new IllegalArgumentException( "Cannot remove a sink, when the list of sinks is null" );
+ }
+
+ if ( this.sink instanceof SingleTupleSinkAdapter ) {
+ this.sink = EmptyTupleSinkAdapter.getInstance();
+ } else {
+ final CompositeTupleSinkAdapter sinkAdapter = (CompositeTupleSinkAdapter) this.sink;
+ sinkAdapter.removeTupleSink( tupleSink );
+ if ( sinkAdapter.size() == 1 ) {
+ this.sink = new SingleTupleSinkAdapter( sinkAdapter.getSinks()[0] );
+ }
+ }
+ }
+
+ public LeftTupleSinkPropagator getSinkPropagator() {
+ return this.sink;
+ }
+
+ public abstract void updateSink(LeftTupleSink sink,
+ PropagationContext context,
+ InternalWorkingMemory workingMemory);
+
+ public boolean isInUse() {
+ return this.sink.size() > 0;
+ }
+}
Deleted: labs/jbossrules/branches/ming-serialization/drools-core/src/main/java/org/drools/reteoo/ObjectSink.java
===================================================================
--- labs/jbossrules/branches/ming-serialization/drools-core/src/main/java/org/drools/reteoo/ObjectSink.java 2008-03-22 00:35:33 UTC (rev 19200)
+++ labs/jbossrules/branches/ming-serialization/drools-core/src/main/java/org/drools/reteoo/ObjectSink.java 2008-03-22 01:58:04 UTC (rev 19201)
@@ -1,68 +0,0 @@
-package org.drools.reteoo;
-
-/*
- * Copyright 2005 JBoss Inc
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-import org.drools.common.InternalFactHandle;
-import org.drools.common.InternalWorkingMemory;
-import org.drools.spi.PropagationContext;
-
-/**
- * Receiver of propagated <code>FactHandleImpl</code>s from a
- * <code>ObjectSource</code>.
- *
- * @see ObectSource
- *
- * @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 ObjectSink
- extends
- Sink {
-
- /**
- * Assert a new <code>FactHandleImpl</code>.
- *
- * @param handle
- * The asserted <code>FactHandle/code>.
- * @param context
- * The <code>PropagationContext</code> of the <code>WorkingMemory<code> action.
- * @param workingMemory
- * the <code>WorkingMemory</code> session.
- */
- void assertObject(InternalFactHandle handle,
- PropagationContext context,
- InternalWorkingMemory workingMemory);
-
- /**
- * Retract an existing <code>FactHandleImpl</code>.
- *
- * @param handle
- * The <code>FactHandle/code> to retract.
- * @param context
- * The <code>PropagationContext</code> of the <code>WorkingMemory<code> action.
- * @param workingMemory
- * the <code>WorkingMemory</code> session.
- */
- void retractObject(InternalFactHandle handle,
- PropagationContext context,
- InternalWorkingMemory workingMemory);
-
- public boolean isObjectMemoryEnabled();
-
- public void setObjectMemoryEnabled(boolean objectMemoryOn);
-}
Copied: labs/jbossrules/branches/ming-serialization/drools-core/src/main/java/org/drools/reteoo/ObjectSink.java (from rev 19199, labs/jbossrules/branches/ming-serialization/drools-core/src/main/java/org/drools/reteoo/ObjectSink.java)
===================================================================
--- labs/jbossrules/branches/ming-serialization/drools-core/src/main/java/org/drools/reteoo/ObjectSink.java (rev 0)
+++ labs/jbossrules/branches/ming-serialization/drools-core/src/main/java/org/drools/reteoo/ObjectSink.java 2008-03-22 01:58:04 UTC (rev 19201)
@@ -0,0 +1,68 @@
+package org.drools.reteoo;
+
+/*
+ * Copyright 2005 JBoss Inc
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import org.drools.common.InternalFactHandle;
+import org.drools.common.InternalWorkingMemory;
+import org.drools.spi.PropagationContext;
+
+/**
+ * Receiver of propagated <code>FactHandleImpl</code>s from a
+ * <code>ObjectSource</code>.
+ *
+ * @see ObectSource
+ *
+ * @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 ObjectSink
+ extends
+ Sink {
+
+ /**
+ * Assert a new <code>FactHandleImpl</code>.
+ *
+ * @param handle
+ * The asserted <code>FactHandle/code>.
+ * @param context
+ * The <code>PropagationContext</code> of the <code>WorkingMemory<code> action.
+ * @param workingMemory
+ * the <code>WorkingMemory</code> session.
+ */
+ void assertObject(InternalFactHandle handle,
+ PropagationContext context,
+ InternalWorkingMemory workingMemory);
+
+ /**
+ * Retract an existing <code>FactHandleImpl</code>.
+ *
+ * @param handle
+ * The <code>FactHandle/code> to retract.
+ * @param context
+ * The <code>PropagationContext</code> of the <code>WorkingMemory<code> action.
+ * @param workingMemory
+ * the <code>WorkingMemory</code> session.
+ */
+ void retractObject(InternalFactHandle handle,
+ PropagationContext context,
+ InternalWorkingMemory workingMemory);
+
+ public boolean isObjectMemoryEnabled();
+
+ public void setObjectMemoryEnabled(boolean objectMemoryOn);
+}
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-22 00:35:33 UTC (rev 19200)
+++ labs/jbossrules/branches/ming-serialization/drools-core/src/main/java/org/drools/reteoo/ObjectSinkPropagator.java 2008-03-22 01:58:04 UTC (rev 19201)
@@ -5,6 +5,7 @@
import org.drools.common.InternalFactHandle;
import org.drools.common.InternalWorkingMemory;
+import org.drools.common.BaseNode;
import org.drools.spi.PropagationContext;
public interface ObjectSinkPropagator
@@ -19,6 +20,8 @@
InternalWorkingMemory workingMemory,
boolean useHash);
+ public BaseNode getMatchingNode(BaseNode candidate);
+
public ObjectSink[] getSinks();
public int size();
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-22 00:35:33 UTC (rev 19200)
+++ labs/jbossrules/branches/ming-serialization/drools-core/src/main/java/org/drools/reteoo/SingleObjectSinkAdapter.java 2008-03-22 01:58:04 UTC (rev 19201)
@@ -2,6 +2,7 @@
import org.drools.common.InternalFactHandle;
import org.drools.common.InternalWorkingMemory;
+import org.drools.common.BaseNode;
import org.drools.spi.PropagationContext;
import java.io.Externalizable;
@@ -50,6 +51,13 @@
}
+ public BaseNode getMatchingNode(BaseNode candidate) {
+ if (candidate.equals(sink)) {
+ return (BaseNode)sink;
+ }
+ return null;
+ }
+
public ObjectSink[] getSinks() {
return new ObjectSink[]{this.sink};
}
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-22 00:35:33 UTC (rev 19200)
+++ labs/jbossrules/branches/ming-serialization/drools-core/src/main/java/org/drools/reteoo/SingleTupleSinkAdapter.java 2008-03-22 01:58:04 UTC (rev 19201)
@@ -2,6 +2,7 @@
import org.drools.common.InternalFactHandle;
import org.drools.common.InternalWorkingMemory;
+import org.drools.common.BaseNode;
import org.drools.spi.PropagationContext;
import java.io.ObjectInput;
@@ -81,6 +82,12 @@
workingMemory );
}
+ public BaseNode getMatchingNode(BaseNode candidate) {
+ if (candidate.equals(sink))
+ return (BaseNode)sink;
+ return null;
+ }
+
public LeftTupleSink[] getSinks() {
return new LeftTupleSink[]{this.sink};
}
Modified: labs/jbossrules/branches/ming-serialization/drools-core/src/main/java/org/drools/reteoo/builder/BuildUtils.java
===================================================================
--- labs/jbossrules/branches/ming-serialization/drools-core/src/main/java/org/drools/reteoo/builder/BuildUtils.java 2008-03-22 00:35:33 UTC (rev 19200)
+++ labs/jbossrules/branches/ming-serialization/drools-core/src/main/java/org/drools/reteoo/builder/BuildUtils.java 2008-03-22 01:58:04 UTC (rev 19201)
@@ -107,21 +107,9 @@
}
} else if( isSharingEnabledForNode( context, candidate ) ) {
if ( (context.getTupleSource() != null) && ( candidate instanceof LeftTupleSink ) ) {
- LeftTupleSink[] sinks = context.getTupleSource().getSinkPropagator().getSinks();
- for( int i = 0; i < sinks.length; i++ ) {
- if( candidate.equals( sinks[i] ) ) {
- node = (BaseNode) sinks[i];
- break;
- }
- }
+ node = context.getTupleSource().getSinkPropagator().getMatchingNode(candidate);
} else if ( (context.getObjectSource() != null) && (candidate instanceof ObjectSink) ) {
- ObjectSink[] sinks = context.getObjectSource().getSinkPropagator().getSinks();
- for( int i = 0; i < sinks.length; i++ ) {
- if( candidate.equals( sinks[i] ) ) {
- node = (BaseNode) sinks[i];
- break;
- }
- }
+ node = context.getObjectSource().getSinkPropagator().getMatchingNode(candidate);
} else {
throw new RuntimeDroolsException( "This is a bug on node sharing verification. Please report to development team." );
}
@@ -132,7 +120,6 @@
}
}
-
if ( node == null ) {
// only attach() if it is a new node
node = candidate;
Deleted: labs/jbossrules/branches/ming-serialization/drools-core/src/main/java/org/drools/rule/TypeDeclaration.java
===================================================================
--- labs/jbossrules/branches/ming-serialization/drools-core/src/main/java/org/drools/rule/TypeDeclaration.java 2008-03-22 00:35:33 UTC (rev 19200)
+++ labs/jbossrules/branches/ming-serialization/drools-core/src/main/java/org/drools/rule/TypeDeclaration.java 2008-03-22 01:58:04 UTC (rev 19201)
@@ -1,276 +0,0 @@
-/*
- * Copyright 2008 JBoss Inc
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- * Created on Jan 23, 2008
- */
-
-package org.drools.rule;
-
-import org.drools.facttemplates.FactTemplate;
-
-import java.io.Serializable;
-import java.io.Externalizable;
-import java.io.ObjectInput;
-import java.io.IOException;
-import java.io.ObjectOutput;
-
-/**
- * The type declaration class stores all type's metadata
- * declared in source files.
- *
- * @author etirelli
- */
-public class TypeDeclaration implements Externalizable {
-
- public static enum Role {
- FACT,
- EVENT;
-
- public static Role parseRole( String role ) {
- if( "event".equalsIgnoreCase( role ) ) {
- return EVENT;
- } else if( "fact".equalsIgnoreCase( role ) ) {
- return FACT;
- }
- return null;
- }
- }
-
- public static enum Format {
- POJO,
- TEMPLATE;
-
- public static Format parseFormat( String format ) {
- if( "pojo".equalsIgnoreCase( format ) ) {
- return POJO;
- } else if( "template".equalsIgnoreCase( format ) ) {
- return TEMPLATE;
- }
- return null;
- }
- }
-
- public static enum ClockStrategy {
- NONE,
- PSEUDO,
- SYSTEM,
- HEARTBEAT,
- ATTRIBUTE;
-
- public static ClockStrategy parseClockStrategy( String clockStrategy ) {
- if( "none".equalsIgnoreCase( clockStrategy ) ) {
- return NONE;
- } else if( "pseudo".equalsIgnoreCase( clockStrategy ) ) {
- return PSEUDO;
- } else if( "system".equalsIgnoreCase( clockStrategy ) ) {
- return SYSTEM;
- } else if( "heartbeat".equalsIgnoreCase( clockStrategy ) ) {
- return HEARTBEAT;
- } else if( "attribute".equalsIgnoreCase( clockStrategy ) ) {
- return ATTRIBUTE;
- }
- return null;
- }
- }
-
- private String typeName;
- private Role role;
- private Format format;
- private ClockStrategy clockStrategy;
- private String timestampAttribute;
- private String durationAttribute;
- private Class<?> typeClass;
- private FactTemplate typeTemplate;
-
- public TypeDeclaration() {
- }
-
- public TypeDeclaration( String typeName ) {
- this.typeName = typeName;
- this.role = Role.FACT;
- this.format = Format.POJO;
- this.clockStrategy = ClockStrategy.NONE;
- this.durationAttribute = null;
- this.timestampAttribute = null;
- this.typeClass = null;
- this.typeTemplate = null;
- }
-
- public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
- this.typeName = (String)in.readObject();
- this.role = (Role)in.readObject();
- this.format = (Format)in.readObject();
- this.clockStrategy = (ClockStrategy)in.readObject();
- this.durationAttribute = (String)in.readObject();
- this.timestampAttribute = (String)in.readObject();
- this.typeClass = (Class<?>)in.readObject();
- this.typeTemplate = (FactTemplate)in.readObject();
- }
-
- public void writeExternal(ObjectOutput out) throws IOException {
- out.writeObject(typeName);
- out.writeObject(role);
- out.writeObject(format);
- out.writeObject(clockStrategy);
- out.writeObject(durationAttribute);
- out.writeObject(timestampAttribute);
- out.writeObject(typeClass);
- out.writeObject(typeTemplate);
- }
-
- /**
- * @return the type
- */
- public String getTypeName() {
- return typeName;
- }
-
- /**
- * @return the category
- */
- public Role getRole() {
- return role;
- }
-
- /**
- * @param role the category to set
- */
- public void setRole(Role role) {
- this.role = role;
- }
-
- /**
- * @return the format
- */
- public Format getFormat() {
- return format;
- }
-
- /**
- * @param format the format to set
- */
- public void setFormat(Format format) {
- this.format = format;
- }
-
- /**
- * @return the clockStrategy
- */
- public ClockStrategy getClockStrategy() {
- return clockStrategy;
- }
-
- /**
- * @param clockStrategy the clockStrategy to set
- */
- public void setClockStrategy(ClockStrategy clockStrategy) {
- this.clockStrategy = clockStrategy;
- }
-
- /**
- * @return the timestampAttribute
- */
- public String getTimestampAttribute() {
- return timestampAttribute;
- }
-
- /**
- * @param timestampAttribute the timestampAttribute to set
- */
- public void setTimestampAttribute(String timestampAttribute) {
- this.timestampAttribute = timestampAttribute;
- }
-
- /**
- * @return the durationAttribute
- */
- public String getDurationAttribute() {
- return durationAttribute;
- }
-
- /**
- * @param durationAttribute the durationAttribute to set
- */
- public void setDurationAttribute(String durationAttribute) {
- this.durationAttribute = durationAttribute;
- }
-
- /**
- * @return the typeClass
- */
- public Class< ? > getTypeClass() {
- return typeClass;
- }
-
- /**
- * @param typeClass the typeClass to set
- */
- public void setTypeClass(Class< ? > typeClass) {
- this.typeClass = typeClass;
- }
-
- /**
- * @return the typeTemplate
- */
- public FactTemplate getTypeTemplate() {
- return typeTemplate;
- }
-
- /**
- * @param typeTemplate the typeTemplate to set
- */
- public void setTypeTemplate(FactTemplate typeTemplate) {
- this.typeTemplate = typeTemplate;
- }
-
- /**
- * Returns true if the given parameter matches this type declaration
- *
- * @param clazz
- * @return
- */
- public boolean matches( Object clazz ) {
- boolean matches = false;
- if( clazz instanceof FactTemplate ) {
- matches = this.typeTemplate.equals( clazz );
- } else {
- matches = this.typeClass.isAssignableFrom( (Class<?>) clazz );
- }
- return matches;
- }
-
- public boolean equals(Object obj) {
- if (obj == this) {
- return true;
- } else if (obj instanceof TypeDeclaration) {
- TypeDeclaration that = (TypeDeclaration)obj;
- return isObjectEqual(typeName, that.typeName) &&
- role == that.role &&
- format == that.format &&
- clockStrategy == that.clockStrategy &&
- isObjectEqual(timestampAttribute, that.timestampAttribute) &&
- isObjectEqual(durationAttribute, that.durationAttribute) &&
- typeClass == that.typeClass &&
- isObjectEqual(typeTemplate, that.typeTemplate);
- }
- return false;
- }
-
-
- private static boolean isObjectEqual(Object a, Object b) {
- return a == b || a != null && a.equals(b);
- }
-
-}
Copied: labs/jbossrules/branches/ming-serialization/drools-core/src/main/java/org/drools/rule/TypeDeclaration.java (from rev 19199, labs/jbossrules/branches/ming-serialization/drools-core/src/main/java/org/drools/rule/TypeDeclaration.java)
===================================================================
--- labs/jbossrules/branches/ming-serialization/drools-core/src/main/java/org/drools/rule/TypeDeclaration.java (rev 0)
+++ labs/jbossrules/branches/ming-serialization/drools-core/src/main/java/org/drools/rule/TypeDeclaration.java 2008-03-22 01:58:04 UTC (rev 19201)
@@ -0,0 +1,276 @@
+/*
+ * Copyright 2008 JBoss Inc
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * Created on Jan 23, 2008
+ */
+
+package org.drools.rule;
+
+import org.drools.facttemplates.FactTemplate;
+
+import java.io.Serializable;
+import java.io.Externalizable;
+import java.io.ObjectInput;
+import java.io.IOException;
+import java.io.ObjectOutput;
+
+/**
+ * The type declaration class stores all type's metadata
+ * declared in source files.
+ *
+ * @author etirelli
+ */
+public class TypeDeclaration implements Externalizable {
+
+ public static enum Role {
+ FACT,
+ EVENT;
+
+ public static Role parseRole( String role ) {
+ if( "event".equalsIgnoreCase( role ) ) {
+ return EVENT;
+ } else if( "fact".equalsIgnoreCase( role ) ) {
+ return FACT;
+ }
+ return null;
+ }
+ }
+
+ public static enum Format {
+ POJO,
+ TEMPLATE;
+
+ public static Format parseFormat( String format ) {
+ if( "pojo".equalsIgnoreCase( format ) ) {
+ return POJO;
+ } else if( "template".equalsIgnoreCase( format ) ) {
+ return TEMPLATE;
+ }
+ return null;
+ }
+ }
+
+ public static enum ClockStrategy {
+ NONE,
+ PSEUDO,
+ SYSTEM,
+ HEARTBEAT,
+ ATTRIBUTE;
+
+ public static ClockStrategy parseClockStrategy( String clockStrategy ) {
+ if( "none".equalsIgnoreCase( clockStrategy ) ) {
+ return NONE;
+ } else if( "pseudo".equalsIgnoreCase( clockStrategy ) ) {
+ return PSEUDO;
+ } else if( "system".equalsIgnoreCase( clockStrategy ) ) {
+ return SYSTEM;
+ } else if( "heartbeat".equalsIgnoreCase( clockStrategy ) ) {
+ return HEARTBEAT;
+ } else if( "attribute".equalsIgnoreCase( clockStrategy ) ) {
+ return ATTRIBUTE;
+ }
+ return null;
+ }
+ }
+
+ private String typeName;
+ private Role role;
+ private Format format;
+ private ClockStrategy clockStrategy;
+ private String timestampAttribute;
+ private String durationAttribute;
+ private Class<?> typeClass;
+ private FactTemplate typeTemplate;
+
+ public TypeDeclaration() {
+ }
+
+ public TypeDeclaration( String typeName ) {
+ this.typeName = typeName;
+ this.role = Role.FACT;
+ this.format = Format.POJO;
+ this.clockStrategy = ClockStrategy.NONE;
+ this.durationAttribute = null;
+ this.timestampAttribute = null;
+ this.typeClass = null;
+ this.typeTemplate = null;
+ }
+
+ public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
+ this.typeName = (String)in.readObject();
+ this.role = (Role)in.readObject();
+ this.format = (Format)in.readObject();
+ this.clockStrategy = (ClockStrategy)in.readObject();
+ this.durationAttribute = (String)in.readObject();
+ this.timestampAttribute = (String)in.readObject();
+ this.typeClass = (Class<?>)in.readObject();
+ this.typeTemplate = (FactTemplate)in.readObject();
+ }
+
+ public void writeExternal(ObjectOutput out) throws IOException {
+ out.writeObject(typeName);
+ out.writeObject(role);
+ out.writeObject(format);
+ out.writeObject(clockStrategy);
+ out.writeObject(durationAttribute);
+ out.writeObject(timestampAttribute);
+ out.writeObject(typeClass);
+ out.writeObject(typeTemplate);
+ }
+
+ /**
+ * @return the type
+ */
+ public String getTypeName() {
+ return typeName;
+ }
+
+ /**
+ * @return the category
+ */
+ public Role getRole() {
+ return role;
+ }
+
+ /**
+ * @param role the category to set
+ */
+ public void setRole(Role role) {
+ this.role = role;
+ }
+
+ /**
+ * @return the format
+ */
+ public Format getFormat() {
+ return format;
+ }
+
+ /**
+ * @param format the format to set
+ */
+ public void setFormat(Format format) {
+ this.format = format;
+ }
+
+ /**
+ * @return the clockStrategy
+ */
+ public ClockStrategy getClockStrategy() {
+ return clockStrategy;
+ }
+
+ /**
+ * @param clockStrategy the clockStrategy to set
+ */
+ public void setClockStrategy(ClockStrategy clockStrategy) {
+ this.clockStrategy = clockStrategy;
+ }
+
+ /**
+ * @return the timestampAttribute
+ */
+ public String getTimestampAttribute() {
+ return timestampAttribute;
+ }
+
+ /**
+ * @param timestampAttribute the timestampAttribute to set
+ */
+ public void setTimestampAttribute(String timestampAttribute) {
+ this.timestampAttribute = timestampAttribute;
+ }
+
+ /**
+ * @return the durationAttribute
+ */
+ public String getDurationAttribute() {
+ return durationAttribute;
+ }
+
+ /**
+ * @param durationAttribute the durationAttribute to set
+ */
+ public void setDurationAttribute(String durationAttribute) {
+ this.durationAttribute = durationAttribute;
+ }
+
+ /**
+ * @return the typeClass
+ */
+ public Class< ? > getTypeClass() {
+ return typeClass;
+ }
+
+ /**
+ * @param typeClass the typeClass to set
+ */
+ public void setTypeClass(Class< ? > typeClass) {
+ this.typeClass = typeClass;
+ }
+
+ /**
+ * @return the typeTemplate
+ */
+ public FactTemplate getTypeTemplate() {
+ return typeTemplate;
+ }
+
+ /**
+ * @param typeTemplate the typeTemplate to set
+ */
+ public void setTypeTemplate(FactTemplate typeTemplate) {
+ this.typeTemplate = typeTemplate;
+ }
+
+ /**
+ * Returns true if the given parameter matches this type declaration
+ *
+ * @param clazz
+ * @return
+ */
+ public boolean matches( Object clazz ) {
+ boolean matches = false;
+ if( clazz instanceof FactTemplate ) {
+ matches = this.typeTemplate.equals( clazz );
+ } else {
+ matches = this.typeClass.isAssignableFrom( (Class<?>) clazz );
+ }
+ return matches;
+ }
+
+ public boolean equals(Object obj) {
+ if (obj == this) {
+ return true;
+ } else if (obj instanceof TypeDeclaration) {
+ TypeDeclaration that = (TypeDeclaration)obj;
+ return isObjectEqual(typeName, that.typeName) &&
+ role == that.role &&
+ format == that.format &&
+ clockStrategy == that.clockStrategy &&
+ isObjectEqual(timestampAttribute, that.timestampAttribute) &&
+ isObjectEqual(durationAttribute, that.durationAttribute) &&
+ typeClass == that.typeClass &&
+ isObjectEqual(typeTemplate, that.typeTemplate);
+ }
+ return false;
+ }
+
+
+ private static boolean isObjectEqual(Object a, Object b) {
+ return a == b || a != null && a.equals(b);
+ }
+
+}
Deleted: labs/jbossrules/branches/ming-serialization/drools-core/src/main/java/org/drools/util/ArrayIterator.java
===================================================================
--- labs/jbossrules/branches/ming-serialization/drools-core/src/main/java/org/drools/util/ArrayIterator.java 2008-03-22 00:35:33 UTC (rev 19200)
+++ labs/jbossrules/branches/ming-serialization/drools-core/src/main/java/org/drools/util/ArrayIterator.java 2008-03-22 01:58:04 UTC (rev 19201)
@@ -1,158 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.drools.util;
-
-import java.lang.reflect.Array;
-import java.util.NoSuchElementException;
-
-/**
- * Implements an {@link java.util.Iterator Iterator} over any array.
- * <p>
- * The array can be either an array of object or of primitives. If you know
- * that you have an object array, the
- * {@link org.apache.commons.collections.iterators.ObjectArrayIterator ObjectArrayIterator}
- * class is a better choice, as it will perform better.
- * <p>
- * The iterator implements a {@link #reset} method, allowing the reset of
- * the iterator back to the start if required.
- *
- * @since Commons Collections 1.0
- * @version $Revision$ $Date$
- *
- * @author James Strachan
- * @author Mauricio S. Moura
- * @author Michael A. Smith
- * @author Neil O'Toole
- * @author Stephen Colebourne
- */
-public class ArrayIterator implements java.util.Iterator {
-
- /** The array to iterate over */
- protected Object array;
- /** The end index to loop to */
- protected int endIndex = 0;
- /** The current iterator index */
- protected int index = 0;
-
-
- /**
- * Constructs an ArrayIterator that will iterate over the values in the
- * specified array.
- *
- * @param array the array to iterate over.
- * @throws IllegalArgumentException if <code>array</code> is not an array.
- * @throws NullPointerException if <code>array</code> is <code>null</code>
- */
- public ArrayIterator(final Object array) {
- setArray(array);
- }
-
- /**
- * Checks whether the index is valid or not.
- *
- * @param bound the index to check
- * @param type the index type (for error messages)
- * @throws IndexOutOfBoundsException if the index is invalid
- */
- protected void checkBound(final int bound, final String type ) {
- if (bound > this.endIndex) {
- throw new ArrayIndexOutOfBoundsException(
- "Attempt to make an ArrayIterator that " + type +
- "s beyond the end of the array. "
- );
- }
- if (bound < 0) {
- throw new ArrayIndexOutOfBoundsException(
- "Attempt to make an ArrayIterator that " + type +
- "s before the start of the array. "
- );
- }
- }
-
- // Iterator interface
- //-----------------------------------------------------------------------
- /**
- * Returns true if there are more elements to return from the array.
- *
- * @return true if there is a next element to return
- */
- public boolean hasNext() {
- return (index < endIndex);
- }
-
- /**
- * Returns the next element in the array.
- *
- * @return the next element in the array
- * @throws NoSuchElementException if all the elements in the array
- * have already been returned
- */
- public Object next() {
- if (hasNext() == false) {
- throw new NoSuchElementException();
- }
- return Array.get(array, index++);
- }
-
- /**
- * Throws {@link UnsupportedOperationException}.
- *
- * @throws UnsupportedOperationException always
- */
- public void remove() {
- throw new UnsupportedOperationException("remove() method is not supported");
- }
-
- // Properties
- //-----------------------------------------------------------------------
- /**
- * Gets the array that this iterator is iterating over.
- *
- * @return the array this iterator iterates over, or <code>null</code> if
- * the no-arg constructor was used and {@link #setArray(Object)} has never
- * been called with a valid array.
- */
- public Object getArray() {
- return array;
- }
-
- /**
- * Sets the array that the ArrayIterator should iterate over.
- * <p>
- * If an array has previously been set (using the single-arg constructor
- * or this method) then that array is discarded in favour of this one.
- * Iteration is restarted at the start of the new array.
- * Although this can be used to reset iteration, the {@link #reset()} method
- * is a more effective choice.
- *
- * @param array the array that the iterator should iterate over.
- * @throws IllegalArgumentException if <code>array</code> is not an array.
- * @throws NullPointerException if <code>array</code> is <code>null</code>
- */
- private void setArray(final Object array) {
- // Array.getLength throws IllegalArgumentException if the object is not
- // an array or NullPointerException if the object is null. This call
- // is made before saving the array and resetting the index so that the
- // array iterator remains in a consistent state if the argument is not
- // an array or is null.
- this.endIndex = Array.getLength(array);
- this.array = array;
- this.index = 0;
- }
-
-}
Copied: labs/jbossrules/branches/ming-serialization/drools-core/src/main/java/org/drools/util/ArrayIterator.java (from rev 19199, labs/jbossrules/branches/ming-serialization/drools-core/src/main/java/org/drools/util/ArrayIterator.java)
===================================================================
--- labs/jbossrules/branches/ming-serialization/drools-core/src/main/java/org/drools/util/ArrayIterator.java (rev 0)
+++ labs/jbossrules/branches/ming-serialization/drools-core/src/main/java/org/drools/util/ArrayIterator.java 2008-03-22 01:58:04 UTC (rev 19201)
@@ -0,0 +1,158 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.drools.util;
+
+import java.lang.reflect.Array;
+import java.util.NoSuchElementException;
+
+/**
+ * Implements an {@link java.util.Iterator Iterator} over any array.
+ * <p>
+ * The array can be either an array of object or of primitives. If you know
+ * that you have an object array, the
+ * {@link org.apache.commons.collections.iterators.ObjectArrayIterator ObjectArrayIterator}
+ * class is a better choice, as it will perform better.
+ * <p>
+ * The iterator implements a {@link #reset} method, allowing the reset of
+ * the iterator back to the start if required.
+ *
+ * @since Commons Collections 1.0
+ * @version $Revision$ $Date$
+ *
+ * @author James Strachan
+ * @author Mauricio S. Moura
+ * @author Michael A. Smith
+ * @author Neil O'Toole
+ * @author Stephen Colebourne
+ */
+public class ArrayIterator implements java.util.Iterator {
+
+ /** The array to iterate over */
+ protected Object array;
+ /** The end index to loop to */
+ protected int endIndex = 0;
+ /** The current iterator index */
+ protected int index = 0;
+
+
+ /**
+ * Constructs an ArrayIterator that will iterate over the values in the
+ * specified array.
+ *
+ * @param array the array to iterate over.
+ * @throws IllegalArgumentException if <code>array</code> is not an array.
+ * @throws NullPointerException if <code>array</code> is <code>null</code>
+ */
+ public ArrayIterator(final Object array) {
+ setArray(array);
+ }
+
+ /**
+ * Checks whether the index is valid or not.
+ *
+ * @param bound the index to check
+ * @param type the index type (for error messages)
+ * @throws IndexOutOfBoundsException if the index is invalid
+ */
+ protected void checkBound(final int bound, final String type ) {
+ if (bound > this.endIndex) {
+ throw new ArrayIndexOutOfBoundsException(
+ "Attempt to make an ArrayIterator that " + type +
+ "s beyond the end of the array. "
+ );
+ }
+ if (bound < 0) {
+ throw new ArrayIndexOutOfBoundsException(
+ "Attempt to make an ArrayIterator that " + type +
+ "s before the start of the array. "
+ );
+ }
+ }
+
+ // Iterator interface
+ //-----------------------------------------------------------------------
+ /**
+ * Returns true if there are more elements to return from the array.
+ *
+ * @return true if there is a next element to return
+ */
+ public boolean hasNext() {
+ return (index < endIndex);
+ }
+
+ /**
+ * Returns the next element in the array.
+ *
+ * @return the next element in the array
+ * @throws NoSuchElementException if all the elements in the array
+ * have already been returned
+ */
+ public Object next() {
+ if (hasNext() == false) {
+ throw new NoSuchElementException();
+ }
+ return Array.get(array, index++);
+ }
+
+ /**
+ * Throws {@link UnsupportedOperationException}.
+ *
+ * @throws UnsupportedOperationException always
+ */
+ public void remove() {
+ throw new UnsupportedOperationException("remove() method is not supported");
+ }
+
+ // Properties
+ //-----------------------------------------------------------------------
+ /**
+ * Gets the array that this iterator is iterating over.
+ *
+ * @return the array this iterator iterates over, or <code>null</code> if
+ * the no-arg constructor was used and {@link #setArray(Object)} has never
+ * been called with a valid array.
+ */
+ public Object getArray() {
+ return array;
+ }
+
+ /**
+ * Sets the array that the ArrayIterator should iterate over.
+ * <p>
+ * If an array has previously been set (using the single-arg constructor
+ * or this method) then that array is discarded in favour of this one.
+ * Iteration is restarted at the start of the new array.
+ * Although this can be used to reset iteration, the {@link #reset()} method
+ * is a more effective choice.
+ *
+ * @param array the array that the iterator should iterate over.
+ * @throws IllegalArgumentException if <code>array</code> is not an array.
+ * @throws NullPointerException if <code>array</code> is <code>null</code>
+ */
+ private void setArray(final Object array) {
+ // Array.getLength throws IllegalArgumentException if the object is not
+ // an array or NullPointerException if the object is null. This call
+ // is made before saving the array and resetting the index so that the
+ // array iterator remains in a consistent state if the argument is not
+ // an array or is null.
+ this.endIndex = Array.getLength(array);
+ this.array = array;
+ this.index = 0;
+ }
+
+}
Deleted: labs/jbossrules/branches/ming-serialization/drools-core/src/main/java/org/drools/util/ObjenesisFactory.java
===================================================================
--- labs/jbossrules/branches/ming-serialization/drools-core/src/main/java/org/drools/util/ObjenesisFactory.java 2008-03-22 00:35:33 UTC (rev 19200)
+++ labs/jbossrules/branches/ming-serialization/drools-core/src/main/java/org/drools/util/ObjenesisFactory.java 2008-03-22 01:58:04 UTC (rev 19201)
@@ -1,54 +0,0 @@
-/*
- * Copyright 2008 JBoss Inc
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- * Created on Mar 17, 2008
- */
-package org.drools.util;
-
-import java.io.Serializable;
-
-import org.drools.objenesis.Objenesis;
-import org.drools.objenesis.ObjenesisStd;
-
-/**
- * A factory interface for Objenesis instances
- *
- * @author etirelli
- */
-public class ObjenesisFactory implements Serializable {
-
- private static final long serialVersionUID = 969174504278340793L;
- private static Objenesis OBJENESIS_INSTANCE = null;
-
- private ObjenesisFactory() {}
-
- /**
- * Returns a statically cached objenesis instance
- */
- public static Objenesis getStaticObjenesis() {
- if( OBJENESIS_INSTANCE == null ) {
- OBJENESIS_INSTANCE = new ObjenesisStd(true);
- }
- return OBJENESIS_INSTANCE;
- }
-
- /**
- * Returns a newly instantiated objenesis instance
- */
- public static Objenesis getDefaultObjenesis() {
- return new ObjenesisStd(true);
- }
-
-}
Copied: labs/jbossrules/branches/ming-serialization/drools-core/src/main/java/org/drools/util/ObjenesisFactory.java (from rev 19199, labs/jbossrules/branches/ming-serialization/drools-core/src/main/java/org/drools/util/ObjenesisFactory.java)
===================================================================
--- labs/jbossrules/branches/ming-serialization/drools-core/src/main/java/org/drools/util/ObjenesisFactory.java (rev 0)
+++ labs/jbossrules/branches/ming-serialization/drools-core/src/main/java/org/drools/util/ObjenesisFactory.java 2008-03-22 01:58:04 UTC (rev 19201)
@@ -0,0 +1,54 @@
+/*
+ * Copyright 2008 JBoss Inc
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * Created on Mar 17, 2008
+ */
+package org.drools.util;
+
+import java.io.Serializable;
+
+import org.drools.objenesis.Objenesis;
+import org.drools.objenesis.ObjenesisStd;
+
+/**
+ * A factory interface for Objenesis instances
+ *
+ * @author etirelli
+ */
+public class ObjenesisFactory implements Serializable {
+
+ private static final long serialVersionUID = 969174504278340793L;
+ private static Objenesis OBJENESIS_INSTANCE = null;
+
+ private ObjenesisFactory() {}
+
+ /**
+ * Returns a statically cached objenesis instance
+ */
+ public static Objenesis getStaticObjenesis() {
+ if( OBJENESIS_INSTANCE == null ) {
+ OBJENESIS_INSTANCE = new ObjenesisStd(true);
+ }
+ return OBJENESIS_INSTANCE;
+ }
+
+ /**
+ * Returns a newly instantiated objenesis instance
+ */
+ public static Objenesis getDefaultObjenesis() {
+ return new ObjenesisStd(true);
+ }
+
+}
Copied: labs/jbossrules/branches/ming-serialization/drools-core/src/test/java/org/drools/integrationtests (from rev 19199, labs/jbossrules/branches/ming-serialization/drools-core/src/test/java/org/drools/integrationtests)
Deleted: labs/jbossrules/branches/ming-serialization/drools-core/src/test/java/org/drools/integrationtests/SerializationHelper.java
===================================================================
--- labs/jbossrules/branches/ming-serialization/drools-core/src/test/java/org/drools/integrationtests/SerializationHelper.java 2008-03-21 23:50:09 UTC (rev 19199)
+++ labs/jbossrules/branches/ming-serialization/drools-core/src/test/java/org/drools/integrationtests/SerializationHelper.java 2008-03-22 01:58:04 UTC (rev 19201)
@@ -1,29 +0,0 @@
-package org.drools.integrationtests;
-
-import org.drools.common.DroolsObjectOutputStream;
-import org.drools.common.DroolsObjectInputStream;
-
-import java.io.ByteArrayOutputStream;
-import java.io.IOException;
-import java.io.ByteArrayInputStream;
-
-/**
- * Marshalling helper class to perform serialize/de-serialize a given object
- */
-public class SerializationHelper {
- public static <T> T serializeObject(T obj) throws IOException, ClassNotFoundException {
- return (T)serializeIn(serializeOut(obj));
- }
-
- public static byte[] serializeOut(Object obj) throws IOException {
- ByteArrayOutputStream out = new ByteArrayOutputStream();
- new DroolsObjectOutputStream(out).writeObject(obj);
- out.close();
- return out.toByteArray();
- }
-
- public static Object serializeIn(byte[] bytes)
- throws IOException, ClassNotFoundException {
- return new DroolsObjectInputStream(new ByteArrayInputStream(bytes)).readObject();
- }
-}
Copied: labs/jbossrules/branches/ming-serialization/drools-core/src/test/java/org/drools/integrationtests/SerializationHelper.java (from rev 19199, labs/jbossrules/branches/ming-serialization/drools-core/src/test/java/org/drools/integrationtests/SerializationHelper.java)
===================================================================
--- labs/jbossrules/branches/ming-serialization/drools-core/src/test/java/org/drools/integrationtests/SerializationHelper.java (rev 0)
+++ labs/jbossrules/branches/ming-serialization/drools-core/src/test/java/org/drools/integrationtests/SerializationHelper.java 2008-03-22 01:58:04 UTC (rev 19201)
@@ -0,0 +1,29 @@
+package org.drools.integrationtests;
+
+import org.drools.common.DroolsObjectOutputStream;
+import org.drools.common.DroolsObjectInputStream;
+
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+import java.io.ByteArrayInputStream;
+
+/**
+ * Marshalling helper class to perform serialize/de-serialize a given object
+ */
+public class SerializationHelper {
+ public static <T> T serializeObject(T obj) throws IOException, ClassNotFoundException {
+ return (T)serializeIn(serializeOut(obj));
+ }
+
+ public static byte[] serializeOut(Object obj) throws IOException {
+ ByteArrayOutputStream out = new ByteArrayOutputStream();
+ new DroolsObjectOutputStream(out).writeObject(obj);
+ out.close();
+ return out.toByteArray();
+ }
+
+ public static Object serializeIn(byte[] bytes)
+ throws IOException, ClassNotFoundException {
+ return new DroolsObjectInputStream(new ByteArrayInputStream(bytes)).readObject();
+ }
+}
Deleted: labs/jbossrules/branches/ming-serialization/drools-core/src/test/java/org/drools/rule/EnumSerialiationTest.java
===================================================================
--- labs/jbossrules/branches/ming-serialization/drools-core/src/test/java/org/drools/rule/EnumSerialiationTest.java 2008-03-22 00:35:33 UTC (rev 19200)
+++ labs/jbossrules/branches/ming-serialization/drools-core/src/test/java/org/drools/rule/EnumSerialiationTest.java 2008-03-22 01:58:04 UTC (rev 19201)
@@ -1,20 +0,0 @@
-package org.drools.rule;
-
-import junit.framework.TestCase;
-import org.drools.integrationtests.SerializationHelper;
-
-/**
- * Created by IntelliJ IDEA. User: Ming Jin Date: Mar 19, 2008 Time: 11:11:45 AM To change this template use File |
- * Settings | File Templates.
- */
-public class EnumSerialiationTest extends TestCase {
- private static final String TEST_NAME = "test name";
-
- public void testTypeDeclaration() throws Exception {
- TypeDeclaration typeDec1 = new TypeDeclaration(TEST_NAME);
-
- TypeDeclaration typeDec2 = SerializationHelper.serializeObject(typeDec1);
-
- assertEquals(typeDec1, typeDec2);
- }
-}
Copied: labs/jbossrules/branches/ming-serialization/drools-core/src/test/java/org/drools/rule/EnumSerialiationTest.java (from rev 19199, labs/jbossrules/branches/ming-serialization/drools-core/src/test/java/org/drools/rule/EnumSerialiationTest.java)
===================================================================
--- labs/jbossrules/branches/ming-serialization/drools-core/src/test/java/org/drools/rule/EnumSerialiationTest.java (rev 0)
+++ labs/jbossrules/branches/ming-serialization/drools-core/src/test/java/org/drools/rule/EnumSerialiationTest.java 2008-03-22 01:58:04 UTC (rev 19201)
@@ -0,0 +1,20 @@
+package org.drools.rule;
+
+import junit.framework.TestCase;
+import org.drools.integrationtests.SerializationHelper;
+
+/**
+ * Created by IntelliJ IDEA. User: Ming Jin Date: Mar 19, 2008 Time: 11:11:45 AM To change this template use File |
+ * Settings | File Templates.
+ */
+public class EnumSerialiationTest extends TestCase {
+ private static final String TEST_NAME = "test name";
+
+ public void testTypeDeclaration() throws Exception {
+ TypeDeclaration typeDec1 = new TypeDeclaration(TEST_NAME);
+
+ TypeDeclaration typeDec2 = SerializationHelper.serializeObject(typeDec1);
+
+ assertEquals(typeDec1, typeDec2);
+ }
+}
Deleted: labs/jbossrules/branches/ming-serialization/drools-jbrms/src/main/java/org/drools/brms/client/decisiontable/ActionInsertColumn.java
===================================================================
--- labs/jbossrules/branches/ming-serialization/drools-jbrms/src/main/java/org/drools/brms/client/decisiontable/ActionInsertColumn.java 2008-03-22 00:35:33 UTC (rev 19200)
+++ labs/jbossrules/branches/ming-serialization/drools-jbrms/src/main/java/org/drools/brms/client/decisiontable/ActionInsertColumn.java 2008-03-22 01:58:04 UTC (rev 19201)
@@ -1,249 +0,0 @@
-package org.drools.brms.client.decisiontable;
-
-import java.util.HashSet;
-import java.util.Set;
-
-import org.drools.brms.client.common.FormStylePopup;
-import org.drools.brms.client.common.ImageButton;
-import org.drools.brms.client.common.InfoPopup;
-import org.drools.brms.client.common.SmallLabel;
-import org.drools.brms.client.modeldriven.SuggestionCompletionEngine;
-import org.drools.brms.client.modeldriven.dt.ActionCol;
-import org.drools.brms.client.modeldriven.dt.ActionInsertFactCol;
-import org.drools.brms.client.modeldriven.dt.ConditionCol;
-import org.drools.brms.client.modeldriven.dt.GuidedDecisionTable;
-
-import com.google.gwt.user.client.Command;
-import com.google.gwt.user.client.ui.Button;
-import com.google.gwt.user.client.ui.ChangeListener;
-import com.google.gwt.user.client.ui.ClickListener;
-import com.google.gwt.user.client.ui.HTML;
-import com.google.gwt.user.client.ui.HorizontalPanel;
-import com.google.gwt.user.client.ui.Image;
-import com.google.gwt.user.client.ui.ListBox;
-import com.google.gwt.user.client.ui.TextBox;
-import com.google.gwt.user.client.ui.Widget;
-
-/**
- * This is an editor for columns that are for inserting facts.
- * @author Michael Neale
- *
- */
-public class ActionInsertColumn extends FormStylePopup {
-
- private GuidedDecisionTable dt;
- private SuggestionCompletionEngine sce;
- private ActionInsertFactCol editingCol;
- private SmallLabel patternLabel = new SmallLabel();
- private SmallLabel fieldLabel = new SmallLabel();
-
- public ActionInsertColumn(SuggestionCompletionEngine sce, final GuidedDecisionTable dt, final Command refreshGrid, final ActionInsertFactCol col, final boolean isNew) {
- this.setModal(false);
- this.dt = dt;
- this.sce = sce;
- this.editingCol = new ActionInsertFactCol();
- editingCol.boundName = col.boundName;
- editingCol.type = col.type;
- editingCol.factField = col.factField;
- editingCol.factType = col.factType;
- editingCol.header = col.header;
- editingCol.valueList = col.valueList;
-
- setTitle("Action column configuration (inserting a new fact)");
-
- final TextBox header = new TextBox();
- header.setText(col.header);
- header.addChangeListener(new ChangeListener() {
- public void onChange(Widget w) {
- editingCol.header = header.getText();
- } });
- addAttribute("Column header (description):", header);
-
-
- HorizontalPanel pattern = new HorizontalPanel();
- pattern.add(patternLabel );
- doPatternLabel();
-
- Image changePattern = new ImageButton("images/edit.gif", "Choose a pattern that this column adds data to", new ClickListener() {
- public void onClick(Widget w) {
- showChangePattern(w);
- }
- });
- pattern.add(changePattern);
- addAttribute("Pattern:", pattern);
-
- HorizontalPanel field = new HorizontalPanel();
- field.add(fieldLabel);
- Image editField = new ImageButton("images/edit.gif", "Edit the field that this column operates on", new ClickListener() {
- public void onClick(Widget w) {
- showFieldChange();
- }
- });
- field.add(editField);
- addAttribute("Field:", field);
- doFieldLabel();
-
-
- final TextBox valueList = new TextBox();
- valueList.setText(editingCol.valueList);
- valueList.addChangeListener(new ChangeListener() {
- public void onChange(Widget w) {
- editingCol.valueList = valueList.getText();
- }
- });
- HorizontalPanel vl = new HorizontalPanel();
- vl.add(valueList);
- vl.add(new InfoPopup("Value list", "Value lists are an optional comma separated list of values to show as a drop down."));
- addAttribute("(optional) value list:", vl);
-
- Button apply = new Button("Apply changes");
- apply.addClickListener(new ClickListener() {
- public void onClick(Widget w) {
- if (isNew) {
- dt.actionCols.add(editingCol);
- } else {
- col.boundName = editingCol.boundName;
- col.type = editingCol.type;
- col.factField = editingCol.factField;
- col.factType = editingCol.factType;
- col.header = editingCol.header;
- col.valueList = editingCol.valueList;
- }
- refreshGrid.execute();
- hide();
- }
- });
- addAttribute("", apply);
-
- }
-
- private void showFieldChange() {
- final FormStylePopup pop = new FormStylePopup();
- pop.setModal(false);
- String[] fields = this.sce.getFieldCompletions(this.editingCol.factType);
- final ListBox box = new ListBox();
- for (int i = 0; i < fields.length; i++) {
- box.addItem(fields[i]);
- }
- pop.addAttribute("Field:", box);
- Button b = new Button("OK");
- pop.addAttribute("", b);
- b.addClickListener(new ClickListener() {
- public void onClick(Widget w) {
- editingCol.factField = box.getItemText(box.getSelectedIndex());
- editingCol.type = sce.getFieldType(editingCol.factType, editingCol.factField);
- doFieldLabel();
- pop.hide();
- }
- });
- pop.show();
-
- }
-
- private void doFieldLabel() {
- if (nil(this.editingCol.factField)) {
- fieldLabel.setText("(please choose fact type)");
- } else {
- fieldLabel.setText(editingCol.factField);
- }
-
- }
-
- private boolean nil(String s) {
- return s == null || s.equals("");
- }
-
- private void doPatternLabel() {
- if (this.editingCol.factType != null) {
- this.patternLabel.setText(this.editingCol.factType + " [" + editingCol.boundName + "]");
- }
- }
-
- protected void showChangePattern(Widget w) {
-
- final ListBox pats = this.loadPatterns();
- if (pats.getItemCount() == 0) {
- showNewPatternDialog();
- return;
- }
- final FormStylePopup pop = new FormStylePopup();
- Button ok = new Button("OK");
- HorizontalPanel hp = new HorizontalPanel();
- hp.add(pats);
- hp.add(ok);
-
-
- pop.addAttribute("Choose existing pattern to add column to:", hp);
- pop.addAttribute("", new HTML("<i><b>---OR---</i></b>"));
-
- Button createPattern = new Button("Create new fact pattern");
- createPattern.addClickListener(new ClickListener() {
- public void onClick(Widget w) {
- pop.hide();
- showNewPatternDialog();
- }
- });
- pop.addAttribute("", createPattern);
-
-
-
-
- ok.addClickListener(new ClickListener() {
- public void onClick(Widget w) {
- String[] val = pats.getValue(pats.getSelectedIndex()).split("\\s");
- editingCol.factType = val[0];
- editingCol.boundName = val[1];
- doPatternLabel();
- pop.hide();
- }
- });
-
- pop.show();
- }
-
- protected void showNewPatternDialog() {
- final FormStylePopup pop = new FormStylePopup();
- pop.setTitle("New fact - select the type");
- final ListBox types = new ListBox();
- for (int i = 0; i < sce.factTypes.length; i++) {
- types.addItem(sce.factTypes[i]);
- }
- pop.addAttribute("Fact type:", types);
- final TextBox binding = new TextBox();
- pop.addAttribute("name:", binding);
-
- Button ok = new Button("OK");
- ok.addClickListener(new ClickListener() {
- public void onClick(Widget w) {
- editingCol.boundName = binding.getText();
- editingCol.factType = types.getItemText(types.getSelectedIndex());
- doPatternLabel();
- pop.hide();
- }
- });
- pop.addAttribute("", ok);
-
- pop.show();
- }
-
- private ListBox loadPatterns() {
- Set vars = new HashSet();
- ListBox patterns = new ListBox();
- for (int i = 0; i < dt.conditionCols.size(); i++) {
- ActionCol col = (ActionCol) dt.actionCols.get(i);
- if (col instanceof ActionInsertFactCol) {
- ActionInsertFactCol c = (ActionInsertFactCol) col;
- if (!vars.contains(c.boundName)) {
- patterns.addItem(c.factType + " [" + c.boundName + "]", c.factType + " " + c.boundName);
- vars.add(c.boundName);
- }
- }
- }
-
- return patterns;
-
- }
-
-
-
-}
Copied: labs/jbossrules/branches/ming-serialization/drools-jbrms/src/main/java/org/drools/brms/client/decisiontable/ActionInsertColumn.java (from rev 19199, labs/jbossrules/branches/ming-serialization/drools-jbrms/src/main/java/org/drools/brms/client/decisiontable/ActionInsertColumn.java)
===================================================================
--- labs/jbossrules/branches/ming-serialization/drools-jbrms/src/main/java/org/drools/brms/client/decisiontable/ActionInsertColumn.java (rev 0)
+++ labs/jbossrules/branches/ming-serialization/drools-jbrms/src/main/java/org/drools/brms/client/decisiontable/ActionInsertColumn.java 2008-03-22 01:58:04 UTC (rev 19201)
@@ -0,0 +1,249 @@
+package org.drools.brms.client.decisiontable;
+
+import java.util.HashSet;
+import java.util.Set;
+
+import org.drools.brms.client.common.FormStylePopup;
+import org.drools.brms.client.common.ImageButton;
+import org.drools.brms.client.common.InfoPopup;
+import org.drools.brms.client.common.SmallLabel;
+import org.drools.brms.client.modeldriven.SuggestionCompletionEngine;
+import org.drools.brms.client.modeldriven.dt.ActionCol;
+import org.drools.brms.client.modeldriven.dt.ActionInsertFactCol;
+import org.drools.brms.client.modeldriven.dt.ConditionCol;
+import org.drools.brms.client.modeldriven.dt.GuidedDecisionTable;
+
+import com.google.gwt.user.client.Command;
+import com.google.gwt.user.client.ui.Button;
+import com.google.gwt.user.client.ui.ChangeListener;
+import com.google.gwt.user.client.ui.ClickListener;
+import com.google.gwt.user.client.ui.HTML;
+import com.google.gwt.user.client.ui.HorizontalPanel;
+import com.google.gwt.user.client.ui.Image;
+import com.google.gwt.user.client.ui.ListBox;
+import com.google.gwt.user.client.ui.TextBox;
+import com.google.gwt.user.client.ui.Widget;
+
+/**
+ * This is an editor for columns that are for inserting facts.
+ * @author Michael Neale
+ *
+ */
+public class ActionInsertColumn extends FormStylePopup {
+
+ private GuidedDecisionTable dt;
+ private SuggestionCompletionEngine sce;
+ private ActionInsertFactCol editingCol;
+ private SmallLabel patternLabel = new SmallLabel();
+ private SmallLabel fieldLabel = new SmallLabel();
+
+ public ActionInsertColumn(SuggestionCompletionEngine sce, final GuidedDecisionTable dt, final Command refreshGrid, final ActionInsertFactCol col, final boolean isNew) {
+ this.setModal(false);
+ this.dt = dt;
+ this.sce = sce;
+ this.editingCol = new ActionInsertFactCol();
+ editingCol.boundName = col.boundName;
+ editingCol.type = col.type;
+ editingCol.factField = col.factField;
+ editingCol.factType = col.factType;
+ editingCol.header = col.header;
+ editingCol.valueList = col.valueList;
+
+ setTitle("Action column configuration (inserting a new fact)");
+
+ final TextBox header = new TextBox();
+ header.setText(col.header);
+ header.addChangeListener(new ChangeListener() {
+ public void onChange(Widget w) {
+ editingCol.header = header.getText();
+ } });
+ addAttribute("Column header (description):", header);
+
+
+ HorizontalPanel pattern = new HorizontalPanel();
+ pattern.add(patternLabel );
+ doPatternLabel();
+
+ Image changePattern = new ImageButton("images/edit.gif", "Choose a pattern that this column adds data to", new ClickListener() {
+ public void onClick(Widget w) {
+ showChangePattern(w);
+ }
+ });
+ pattern.add(changePattern);
+ addAttribute("Pattern:", pattern);
+
+ HorizontalPanel field = new HorizontalPanel();
+ field.add(fieldLabel);
+ Image editField = new ImageButton("images/edit.gif", "Edit the field that this column operates on", new ClickListener() {
+ public void onClick(Widget w) {
+ showFieldChange();
+ }
+ });
+ field.add(editField);
+ addAttribute("Field:", field);
+ doFieldLabel();
+
+
+ final TextBox valueList = new TextBox();
+ valueList.setText(editingCol.valueList);
+ valueList.addChangeListener(new ChangeListener() {
+ public void onChange(Widget w) {
+ editingCol.valueList = valueList.getText();
+ }
+ });
+ HorizontalPanel vl = new HorizontalPanel();
+ vl.add(valueList);
+ vl.add(new InfoPopup("Value list", "Value lists are an optional comma separated list of values to show as a drop down."));
+ addAttribute("(optional) value list:", vl);
+
+ Button apply = new Button("Apply changes");
+ apply.addClickListener(new ClickListener() {
+ public void onClick(Widget w) {
+ if (isNew) {
+ dt.actionCols.add(editingCol);
+ } else {
+ col.boundName = editingCol.boundName;
+ col.type = editingCol.type;
+ col.factField = editingCol.factField;
+ col.factType = editingCol.factType;
+ col.header = editingCol.header;
+ col.valueList = editingCol.valueList;
+ }
+ refreshGrid.execute();
+ hide();
+ }
+ });
+ addAttribute("", apply);
+
+ }
+
+ private void showFieldChange() {
+ final FormStylePopup pop = new FormStylePopup();
+ pop.setModal(false);
+ String[] fields = this.sce.getFieldCompletions(this.editingCol.factType);
+ final ListBox box = new ListBox();
+ for (int i = 0; i < fields.length; i++) {
+ box.addItem(fields[i]);
+ }
+ pop.addAttribute("Field:", box);
+ Button b = new Button("OK");
+ pop.addAttribute("", b);
+ b.addClickListener(new ClickListener() {
+ public void onClick(Widget w) {
+ editingCol.factField = box.getItemText(box.getSelectedIndex());
+ editingCol.type = sce.getFieldType(editingCol.factType, editingCol.factField);
+ doFieldLabel();
+ pop.hide();
+ }
+ });
+ pop.show();
+
+ }
+
+ private void doFieldLabel() {
+ if (nil(this.editingCol.factField)) {
+ fieldLabel.setText("(please choose fact type)");
+ } else {
+ fieldLabel.setText(editingCol.factField);
+ }
+
+ }
+
+ private boolean nil(String s) {
+ return s == null || s.equals("");
+ }
+
+ private void doPatternLabel() {
+ if (this.editingCol.factType != null) {
+ this.patternLabel.setText(this.editingCol.factType + " [" + editingCol.boundName + "]");
+ }
+ }
+
+ protected void showChangePattern(Widget w) {
+
+ final ListBox pats = this.loadPatterns();
+ if (pats.getItemCount() == 0) {
+ showNewPatternDialog();
+ return;
+ }
+ final FormStylePopup pop = new FormStylePopup();
+ Button ok = new Button("OK");
+ HorizontalPanel hp = new HorizontalPanel();
+ hp.add(pats);
+ hp.add(ok);
+
+
+ pop.addAttribute("Choose existing pattern to add column to:", hp);
+ pop.addAttribute("", new HTML("<i><b>---OR---</i></b>"));
+
+ Button createPattern = new Button("Create new fact pattern");
+ createPattern.addClickListener(new ClickListener() {
+ public void onClick(Widget w) {
+ pop.hide();
+ showNewPatternDialog();
+ }
+ });
+ pop.addAttribute("", createPattern);
+
+
+
+
+ ok.addClickListener(new ClickListener() {
+ public void onClick(Widget w) {
+ String[] val = pats.getValue(pats.getSelectedIndex()).split("\\s");
+ editingCol.factType = val[0];
+ editingCol.boundName = val[1];
+ doPatternLabel();
+ pop.hide();
+ }
+ });
+
+ pop.show();
+ }
+
+ protected void showNewPatternDialog() {
+ final FormStylePopup pop = new FormStylePopup();
+ pop.setTitle("New fact - select the type");
+ final ListBox types = new ListBox();
+ for (int i = 0; i < sce.factTypes.length; i++) {
+ types.addItem(sce.factTypes[i]);
+ }
+ pop.addAttribute("Fact type:", types);
+ final TextBox binding = new TextBox();
+ pop.addAttribute("name:", binding);
+
+ Button ok = new Button("OK");
+ ok.addClickListener(new ClickListener() {
+ public void onClick(Widget w) {
+ editingCol.boundName = binding.getText();
+ editingCol.factType = types.getItemText(types.getSelectedIndex());
+ doPatternLabel();
+ pop.hide();
+ }
+ });
+ pop.addAttribute("", ok);
+
+ pop.show();
+ }
+
+ private ListBox loadPatterns() {
+ Set vars = new HashSet();
+ ListBox patterns = new ListBox();
+ for (int i = 0; i < dt.conditionCols.size(); i++) {
+ ActionCol col = (ActionCol) dt.actionCols.get(i);
+ if (col instanceof ActionInsertFactCol) {
+ ActionInsertFactCol c = (ActionInsertFactCol) col;
+ if (!vars.contains(c.boundName)) {
+ patterns.addItem(c.factType + " [" + c.boundName + "]", c.factType + " " + c.boundName);
+ vars.add(c.boundName);
+ }
+ }
+ }
+
+ return patterns;
+
+ }
+
+
+
+}
Deleted: labs/jbossrules/branches/ming-serialization/drools-jbrms/src/main/java/org/drools/brms/client/ruleeditor/SaveEventListener.java
===================================================================
--- labs/jbossrules/branches/ming-serialization/drools-jbrms/src/main/java/org/drools/brms/client/ruleeditor/SaveEventListener.java 2008-03-22 00:35:33 UTC (rev 19200)
+++ labs/jbossrules/branches/ming-serialization/drools-jbrms/src/main/java/org/drools/brms/client/ruleeditor/SaveEventListener.java 2008-03-22 01:58:04 UTC (rev 19201)
@@ -1,12 +0,0 @@
-package org.drools.brms.client.ruleeditor;
-
-/**
- * This is used to notify that a save even is about to occur.
- * @author Michael Neale
- *
- */
-public interface SaveEventListener {
-
- void onSave();
-
-}
Copied: labs/jbossrules/branches/ming-serialization/drools-jbrms/src/main/java/org/drools/brms/client/ruleeditor/SaveEventListener.java (from rev 19199, labs/jbossrules/branches/ming-serialization/drools-jbrms/src/main/java/org/drools/brms/client/ruleeditor/SaveEventListener.java)
===================================================================
--- labs/jbossrules/branches/ming-serialization/drools-jbrms/src/main/java/org/drools/brms/client/ruleeditor/SaveEventListener.java (rev 0)
+++ labs/jbossrules/branches/ming-serialization/drools-jbrms/src/main/java/org/drools/brms/client/ruleeditor/SaveEventListener.java 2008-03-22 01:58:04 UTC (rev 19201)
@@ -0,0 +1,12 @@
+package org.drools.brms.client.ruleeditor;
+
+/**
+ * This is used to notify that a save even is about to occur.
+ * @author Michael Neale
+ *
+ */
+public interface SaveEventListener {
+
+ void onSave();
+
+}
Deleted: labs/jbossrules/branches/ming-serialization/drools-jbrms/src/main/java/org/drools/brms/public/images/gdst.gif
===================================================================
(Binary files differ)
Copied: labs/jbossrules/branches/ming-serialization/drools-jbrms/src/main/java/org/drools/brms/public/images/gdst.gif (from rev 19199, labs/jbossrules/branches/ming-serialization/drools-jbrms/src/main/java/org/drools/brms/public/images/gdst.gif)
===================================================================
(Binary files differ)
More information about the jboss-svn-commits
mailing list