[jboss-svn-commits] JBL Code SVN: r36988 - in labs/jbossrules/soa_branches/BRMS-5.1.x/drools-core/src: main/java/org/drools/core/util and 2 other directories.

jboss-svn-commits at lists.jboss.org jboss-svn-commits at lists.jboss.org
Mon May 9 14:32:02 EDT 2011


Author: tsurdilovic
Date: 2011-05-09 14:32:01 -0400 (Mon, 09 May 2011)
New Revision: 36988

Removed:
   labs/jbossrules/soa_branches/BRMS-5.1.x/drools-core/src/main/java/org/drools/common/SimpleAgendaGroup.java
Modified:
   labs/jbossrules/soa_branches/BRMS-5.1.x/drools-core/src/main/java/org/drools/common/ArrayAgendaGroup.java
   labs/jbossrules/soa_branches/BRMS-5.1.x/drools-core/src/main/java/org/drools/common/BinaryHeapQueueAgendaGroup.java
   labs/jbossrules/soa_branches/BRMS-5.1.x/drools-core/src/main/java/org/drools/common/DefaultAgenda.java
   labs/jbossrules/soa_branches/BRMS-5.1.x/drools-core/src/main/java/org/drools/common/InternalAgendaGroup.java
   labs/jbossrules/soa_branches/BRMS-5.1.x/drools-core/src/main/java/org/drools/core/util/BinaryHeapQueue.java
   labs/jbossrules/soa_branches/BRMS-5.1.x/drools-core/src/main/java/org/drools/runtime/rule/impl/AgendaGroupImpl.java
   labs/jbossrules/soa_branches/BRMS-5.1.x/drools-core/src/test/java/org/drools/reteoo/test/dsl/IsTuple.java
Log:
BRMS-586: Rules do not fire according to salience after multiple fact updates

Modified: labs/jbossrules/soa_branches/BRMS-5.1.x/drools-core/src/main/java/org/drools/common/ArrayAgendaGroup.java
===================================================================
--- labs/jbossrules/soa_branches/BRMS-5.1.x/drools-core/src/main/java/org/drools/common/ArrayAgendaGroup.java	2011-05-09 17:06:37 UTC (rev 36987)
+++ labs/jbossrules/soa_branches/BRMS-5.1.x/drools-core/src/main/java/org/drools/common/ArrayAgendaGroup.java	2011-05-09 18:32:01 UTC (rev 36988)
@@ -24,6 +24,7 @@
 import org.drools.core.util.Iterator;
 import org.drools.core.util.LinkedList;
 import org.drools.core.util.LinkedListEntry;
+import org.drools.core.util.Queueable;
 import org.drools.spi.Activation;
 
 /**
@@ -119,6 +120,12 @@
     public int size() {
         return this.size;
     }
+    
+    public Activation[] getAndClear() {
+    	Activation[] queue = getActivations();
+    	clear();
+    	return queue;
+    } 
 
     public void add(final Activation activation) {
         AgendaItem item = (AgendaItem) activation;
@@ -196,10 +203,6 @@
         return activations;
     }
 
-    public Activation[] getQueue() {
-        return getActivations();
-    }
-
     public String toString() {
         return "AgendaGroup '" + this.name + "'";
     }   

Modified: labs/jbossrules/soa_branches/BRMS-5.1.x/drools-core/src/main/java/org/drools/common/BinaryHeapQueueAgendaGroup.java
===================================================================
--- labs/jbossrules/soa_branches/BRMS-5.1.x/drools-core/src/main/java/org/drools/common/BinaryHeapQueueAgendaGroup.java	2011-05-09 17:06:37 UTC (rev 36987)
+++ labs/jbossrules/soa_branches/BRMS-5.1.x/drools-core/src/main/java/org/drools/common/BinaryHeapQueueAgendaGroup.java	2011-05-09 18:32:01 UTC (rev 36988)
@@ -89,6 +89,10 @@
     public void clear() {
         this.queue.clear();
     }
+    
+    public Activation[] getAndClear() {
+    	return this.queue.getAndClear();
+    	}
 
     /* (non-Javadoc)
      * @see org.drools.spi.AgendaGroup#size()
@@ -128,10 +132,6 @@
         return (Activation[]) this.queue.toArray( new AgendaItem[this.queue.size()] );
     }
 
-    public Activation[] getQueue() {
-        return this.queue.getQueueable();
-    }
-
     public String toString() {
         return "AgendaGroup '" + this.name + "'";
     }

Modified: labs/jbossrules/soa_branches/BRMS-5.1.x/drools-core/src/main/java/org/drools/common/DefaultAgenda.java
===================================================================
--- labs/jbossrules/soa_branches/BRMS-5.1.x/drools-core/src/main/java/org/drools/common/DefaultAgenda.java	2011-05-09 17:06:37 UTC (rev 36987)
+++ labs/jbossrules/soa_branches/BRMS-5.1.x/drools-core/src/main/java/org/drools/common/DefaultAgenda.java	2011-05-09 18:32:01 UTC (rev 36988)
@@ -722,7 +722,9 @@
     public void clearAndCancelAgendaGroup(final AgendaGroup agendaGroup) {
         final EventSupport eventsupport = (EventSupport) this.workingMemory;
 
-        final Activation[] queueable = ((InternalAgendaGroup) agendaGroup).getQueue();
+        // this is thread safe for BinaryHeapQueue
+        // Binary Heap locks while it returns the array and reset's it's own internal array. Lock is released afer getAndClear()
+        final Activation[] queueable = ((InternalAgendaGroup) agendaGroup).getAndClear(); 
         for ( int i = 0, length = queueable.length; i < length; i++ ) {
             final AgendaItem item = (AgendaItem) queueable[i];
             if ( item == null ) {
@@ -747,7 +749,6 @@
                                                                           this.workingMemory,
                                                                           ActivationCancelledCause.CLEAR );
         }
-        ((InternalAgendaGroup) agendaGroup).clear();
     }
 
     /*

Modified: labs/jbossrules/soa_branches/BRMS-5.1.x/drools-core/src/main/java/org/drools/common/InternalAgendaGroup.java
===================================================================
--- labs/jbossrules/soa_branches/BRMS-5.1.x/drools-core/src/main/java/org/drools/common/InternalAgendaGroup.java	2011-05-09 17:06:37 UTC (rev 36987)
+++ labs/jbossrules/soa_branches/BRMS-5.1.x/drools-core/src/main/java/org/drools/common/InternalAgendaGroup.java	2011-05-09 18:32:01 UTC (rev 36988)
@@ -16,6 +16,7 @@
 
 package org.drools.common;
 
+import org.drools.core.util.Queueable;
 import org.drools.spi.Activation;
 import org.drools.spi.AgendaGroup;
 
@@ -26,7 +27,7 @@
     
     public void setActive(boolean activate);
     
-    public Activation[] getQueue();
+    public Activation[] getAndClear();
     
     public void clear();
 

Deleted: labs/jbossrules/soa_branches/BRMS-5.1.x/drools-core/src/main/java/org/drools/common/SimpleAgendaGroup.java
===================================================================
--- labs/jbossrules/soa_branches/BRMS-5.1.x/drools-core/src/main/java/org/drools/common/SimpleAgendaGroup.java	2011-05-09 17:06:37 UTC (rev 36987)
+++ labs/jbossrules/soa_branches/BRMS-5.1.x/drools-core/src/main/java/org/drools/common/SimpleAgendaGroup.java	2011-05-09 18:32:01 UTC (rev 36988)
@@ -1,277 +0,0 @@
-/**
- * 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.
- */
-
-package org.drools.common;
-
-import java.io.IOException;
-import java.io.ObjectInput;
-import java.io.ObjectOutput;
-import java.util.HashMap;
-import java.util.Map;
-import java.util.PriorityQueue;
-
-import org.drools.core.util.AbstractBaseLinkedListNode;
-import org.drools.core.util.BinaryHeapQueue;
-import org.drools.core.util.LinkedList;
-import org.drools.core.util.Queueable;
-import org.drools.spi.Activation;
-
-/**
- * <code>AgendaGroup</code> implementation that uses a
- * <code>ActivationQueue</code>s. The <code>AgendaGroup</code> also maintains a
- * <code>Map</code> of <code>ActivationQueues</code> for requested salience
- * values.
- * 
- * @see PriorityQueue
- * @see ActivationQueue
- * 
- * @author <a href="mailto:mark.proctor at jboss.com">Mark Proctor</a>
- * @author <a href="mailto:bob at werken.com">Bob McWhirter</a>
- * 
- */
-public class SimpleAgendaGroup
-    implements
-    InternalAgendaGroup {
-
-    private static final long serialVersionUID = 510l;
-
-    private String            name;
-
-    /** Items in the agenda. */
-    private LinkedList        salienceGroups;
-
-    private int               size;
-
-    private boolean           active;
-
-    public static class SalienceGroup extends AbstractBaseLinkedListNode {
-        private int        salience;
-        private LinkedList list;
-
-        public SalienceGroup(int salience) {
-            this.salience = salience;
-            this.list = new LinkedList();
-        }
-
-        public int getSalience() {
-            return salience;
-        }
-
-        public LinkedList getList() {
-            return this.list;
-        }
-    }
-
-    /**
-     * Construct an <code>AgendaGroup</code> with the given name.
-     * 
-     * @param name
-     *            The <AgendaGroup> name.
-     */
-    public SimpleAgendaGroup() {
-
-    }
-
-    public SimpleAgendaGroup(final String name,
-                             final InternalRuleBase ruleBase) {
-        this.name = name;
-        this.salienceGroups = new LinkedList();
-    }
-
-    public void readExternal(ObjectInput in) throws IOException,
-                                            ClassNotFoundException {
-        name = (String) in.readObject();
-        //queue = (BinaryHeapQueue) in.readObject();
-        active = in.readBoolean();
-    }
-
-    public void writeExternal(ObjectOutput out) throws IOException {
-        out.writeObject( name );
-        //out.writeObject(queue);
-        out.writeBoolean( active );
-    }
-
-    /*
-     * (non-Javadoc)
-     * 
-     * @see org.drools.spi.AgendaGroup#getName()
-     */
-    public String getName() {
-        return this.name;
-    }
-
-    public void clear() {
-        this.salienceGroups.clear();
-    }
-
-    /*
-     * (non-Javadoc)
-     * 
-     * @see org.drools.spi.AgendaGroup#size()
-     */
-    public int size() {
-        return this.size;
-    }
-
-    public void add(final Activation activation) {
-        int salience = activation.getSalience();
-        SalienceGroup group = null;
-
-        if ( !this.salienceGroups.isEmpty() ) {
-            SalienceGroup lastGroup = (SalienceGroup) this.salienceGroups.getLast();
-            
-            // optimisation to find out it's the lowest, and thus add get or add it.
-            if ( salience  <= lastGroup.getSalience() ) {
-                if ( salience == lastGroup.getSalience() ) {
-                    // get
-                    group = (SalienceGroup) lastGroup;
-                } else {
-                    // create and add
-                    SalienceGroup newGroup = new SalienceGroup( salience );
-                    this.salienceGroups.insertAfter( lastGroup, newGroup );
-                    group = newGroup;                    
-                }
-                //add or get to end
-            }
-            
-            
-            if ( group == null ) {
-                // we know this won't iterate to the end returning null, as we checked the end already.
-                for ( group = (SalienceGroup) this.salienceGroups.getFirst(); group != null && salience < group.getSalience(); group = (SalienceGroup) group.getNext() ) {
-                }
-                
-                if ( salience  == group.getSalience() ) {
-                    // get
-                    group = (SalienceGroup) group;
-                } else {
-                    // create and add before, as must be larger
-                    SalienceGroup newGroup = new SalienceGroup( salience );
-                    this.salienceGroups.insertAfter( group.getPrevious(), newGroup );
-                    group = newGroup;                    
-                }                
-            }
-            
-        } else {
-            //no groups so add
-            SalienceGroup newGroup = new SalienceGroup( salience );
-            this.salienceGroups.add( newGroup );
-            group = newGroup;
-        }
-
-        group.getList().add( new ActivationNode( activation,
-                                                 this ) );
-
-    }
-
-    public void remove(AgendaItem agendaItem) {
-        int salience = agendaItem.getSalience();
-
-        SalienceGroup group = null;
-        
-        SalienceGroup lastGroup = (SalienceGroup) this.salienceGroups.getLast();
-        
-        // optimisation to find out it's the lowest, and thus add get or add it.
-        if ( salience  == lastGroup.getSalience() ) {
-            group = lastGroup;
-        } else {        
-            // don't check for !
-            for ( group = (SalienceGroup) this.salienceGroups.getFirst(); group != null &&  group.getSalience() != salience; group = (SalienceGroup) group.getNext() ) {
-            }
-        }
-
-        if ( group == null ) {
-            throw new RuntimeException( "SalienceGroup does not exist, This should not be possible." );
-        }
-
-        group.getList().remove( agendaItem.getActivationNode() );
-    }
-
-    public Activation getNext() {
-        SalienceGroup group = (SalienceGroup) this.salienceGroups.getFirst();
-        
-        while ( !this.salienceGroups.isEmpty() && ( group == null || ( group != null && group.getList().isEmpty() ) ) ) {
-            this.salienceGroups.removeFirst();
-            group = (SalienceGroup) this.salienceGroups.getFirst();                       
-        }
-
-        if ( group != null ) {
-            ActivationNode node =  (ActivationNode) group.getList().removeFirst();
-                if ( group.getList().isEmpty() ) {
-                    this.salienceGroups.removeFirst();
-                }
-                
-                return node.getActivation();
-
-        }
-
-        return null;
-    }
-
-    public boolean isActive() {
-        return this.active;
-    }
-
-    public void setActive(final boolean activate) {
-        this.active = activate;
-    }
-
-    /**
-     * Iterates a PriorityQueue removing empty entries until it finds a
-     * populated entry and return true, otherwise it returns false;
-     * 
-     * @param priorityQueue
-     * @return
-     */
-    public boolean isEmpty() {
-        return this.salienceGroups.isEmpty();
-    }
-
-    public Activation[] getActivations() {
-        return null;
-        //		return (Activation[]) this.queue.toArray(new AgendaItem[this.queue
-        //				.size()]);
-    }
-
-    public Activation[] getQueue() {
-        return null;
-        //return this.queue.getQueueable();
-    }
-
-    public String toString() {
-        return "AgendaGroup '" + this.name + "'";
-    }
-
-    public boolean equal(final Object object) {
-        if ( (object == null) || !(object instanceof SimpleAgendaGroup) ) {
-            return false;
-        }
-
-        if ( ((SimpleAgendaGroup) object).name.equals( this.name ) ) {
-            return true;
-        }
-
-        return false;
-    }
-
-    public int hashCode() {
-        return this.name.hashCode();
-    }
-
-    public void setFocus() {
-        throw new UnsupportedOperationException();
-    }
-
-}

Modified: labs/jbossrules/soa_branches/BRMS-5.1.x/drools-core/src/main/java/org/drools/core/util/BinaryHeapQueue.java
===================================================================
--- labs/jbossrules/soa_branches/BRMS-5.1.x/drools-core/src/main/java/org/drools/core/util/BinaryHeapQueue.java	2011-05-09 17:06:37 UTC (rev 36987)
+++ labs/jbossrules/soa_branches/BRMS-5.1.x/drools-core/src/main/java/org/drools/core/util/BinaryHeapQueue.java	2011-05-09 18:32:01 UTC (rev 36988)
@@ -1,4 +1,4 @@
-/**
+/*
  * Copyright 2005 JBoss Inc
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
@@ -16,13 +16,34 @@
 
 package org.drools.core.util;
 
+/*
+ * 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.
+ */
+
+
 import java.io.Externalizable;
 import java.io.IOException;
 import java.io.ObjectInput;
 import java.io.ObjectOutput;
 import java.util.Comparator;
 import java.util.NoSuchElementException;
+import java.util.concurrent.locks.ReentrantLock;
 
+import org.drools.spi.Activation;
+
 public class BinaryHeapQueue
     implements
     Queue,
@@ -38,6 +59,8 @@
 
     /** The elements in this heap. */
     private Queueable[]      elements;
+    
+    private ReentrantLock    lock;
 
     public BinaryHeapQueue() {
 
@@ -71,6 +94,7 @@
         //+1 as 0 is noop
         this.elements = new Queueable[capacity + 1];
         this.comparator = comparator;
+        this.lock = new ReentrantLock();
     }
 
     //-----------------------------------------------------------------------
@@ -90,9 +114,26 @@
      * Clears all elements from queue.
      */
     public void clear() {
-        this.elements = new Queueable[this.elements.length]; // for gc
-        this.size = 0;
+        try {
+            this.lock.lock();            
+            this.elements = new Queueable[this.elements.length]; // for gc
+            this.size = 0;
+        } finally {
+            this.lock.unlock();
+        }        
     }
+    
+    public Activation[] getAndClear() {
+        try {
+           this.lock.lock();
+           Activation[] queue = ( Activation[] )this.elements;
+           this.elements = new Queueable[this.elements.length]; // for gc
+           this.size = 0;
+           return queue;
+        } finally {
+            this.lock.unlock();
+        }
+    }
 
     /**
      * Tests if queue is empty.
@@ -129,12 +170,17 @@
      *
      * @param element the Queueable to be inserted
      */
-    public synchronized void enqueue(final Queueable element) {
-        if ( isFull() ) {
-            grow();
+    public void enqueue(final Queueable element) {
+        try {
+            this.lock.lock();
+            if ( isFull() ) {
+                grow();
+            }
+    
+            percolateUpMaxHeap( element );
+        } finally {
+            this.lock.unlock();
         }
-
-        percolateUpMaxHeap( element );
     }
 
     /**
@@ -143,56 +189,56 @@
      * @return the Queueable at top of heap
      * @throws NoSuchElementException if <code>isEmpty() == true</code>
      */
-    public synchronized Queueable dequeue() throws NoSuchElementException {
-        if ( isEmpty() ) {
-            return null;
-        }
-
-        final Queueable result = this.elements[1];
-        result.dequeue();
-
-        // Code bellow was removed because it is already executed
-        // inside result.dequeue()
-        //
-        //        setElement(1, this.elements[this.size--]);
-        //        this.elements[this.size + 1] = null;
-        //
-        //        if (this.size != 0) {
-        //            percolateDownMinHeap(1);
-        //        }
-
-        return result;
+    public Queueable dequeue() throws NoSuchElementException {
+        try {
+            this.lock.lock();
+            if ( isEmpty() ) {
+                return null;
+            }
+    
+            final Queueable result = this.elements[1];
+            result.dequeue();
+            
+            return result;
+        } finally {
+            this.lock.unlock();
+        }        
     }
 
     /**
      *
      * @param index
      */
-    public synchronized Queueable dequeue(final int index) {
-        if ( index < 1 || index > this.size ) {
-            //throw new NoSuchElementException();
-            return null;
-        }
-
-        final Queueable result = this.elements[index];
-        setElement( index,
-                    this.elements[this.size] );
-        this.elements[this.size] = null;
-        this.size--;
-        if ( this.size != 0 && index <= this.size ) {
-            int compareToParent = 0;
-            if ( index > 1 ) {
-                compareToParent = compare( this.elements[index],
-                                           this.elements[index / 2] );
+    public Queueable dequeue(final int index) {
+        try {
+            this.lock.lock();        
+            if ( index < 1 || index > this.size ) {
+                //throw new NoSuchElementException();
+                return null;
             }
-            if ( index > 1 && compareToParent < 0 ) {
-                percolateUpMaxHeap( index );
-            } else {
-                percolateDownMaxHeap( index );
+    
+            final Queueable result = this.elements[index];
+            setElement( index,
+                        this.elements[this.size] );
+            this.elements[this.size] = null;
+            this.size--;
+            if ( this.size != 0 && index <= this.size ) {
+                int compareToParent = 0;
+                if ( index > 1 ) {
+                    compareToParent = compare( this.elements[index],
+                                               this.elements[index / 2] );
+                }
+                if ( index > 1 && compareToParent > 0 ) {
+                    percolateUpMaxHeap( index );
+                } else {
+                    percolateDownMaxHeap( index );
+                }
             }
-        }
-
-        return result;
+    
+            return result;
+        } finally {
+            this.lock.unlock();
+        }               
     }
 
 //    /**
@@ -373,36 +419,28 @@
         element.enqueued( index );
     }
 
-    public Queueable[] getQueueable() {
-        return this.elements;
-    }
-
-    public Object[] toArray() {
-        final Object[] result = new Object[this.size];
-        System.arraycopy( this.elements,
-                          1,
-                          result,
-                          0,
-                          this.size );
-        return result;
-    }
-
     public Object[] toArray(Object a[]) {
-        if ( a.length < this.size ) {
-            a = (Object[]) java.lang.reflect.Array.newInstance( a.getClass().getComponentType(),
-                                                                this.size );
+        try {
+            this.lock.lock();
+        
+            if ( a.length < this.size ) {
+                a = (Object[]) java.lang.reflect.Array.newInstance( a.getClass().getComponentType(),
+                                                                    this.size );
+            }
+    
+            System.arraycopy( this.elements,
+                              1,
+                              a,
+                              0,
+                              this.size );
+    
+            if ( a.length > this.size ) {
+                a[this.size] = null;
+            }
+    
+            return a;
+        } finally {
+            this.lock.unlock();
         }
-
-        System.arraycopy( this.elements,
-                          1,
-                          a,
-                          0,
-                          this.size );
-
-        if ( a.length > this.size ) {
-            a[this.size] = null;
-        }
-
-        return a;
     }
 }

Modified: labs/jbossrules/soa_branches/BRMS-5.1.x/drools-core/src/main/java/org/drools/runtime/rule/impl/AgendaGroupImpl.java
===================================================================
--- labs/jbossrules/soa_branches/BRMS-5.1.x/drools-core/src/main/java/org/drools/runtime/rule/impl/AgendaGroupImpl.java	2011-05-09 17:06:37 UTC (rev 36987)
+++ labs/jbossrules/soa_branches/BRMS-5.1.x/drools-core/src/main/java/org/drools/runtime/rule/impl/AgendaGroupImpl.java	2011-05-09 18:32:01 UTC (rev 36988)
@@ -20,8 +20,11 @@
 import java.io.IOException;
 import java.io.ObjectInput;
 import java.io.ObjectOutput;
+import java.util.Arrays;
+import java.util.Collection;
 
 import org.drools.common.InternalAgenda;
+import org.drools.runtime.rule.Activation;
 import org.drools.runtime.rule.AgendaGroup;
 
 public class AgendaGroupImpl implements AgendaGroup, Externalizable {
@@ -59,5 +62,10 @@
     public void setFocus() {
         this.agenda.setFocus( this.name );
     }
+    
+//  public Collection<Activation> getActivations() {
+//  return this.agenda.getAgendaGroup( this.name ).getActivations();
+//}
 
+
 }

Modified: labs/jbossrules/soa_branches/BRMS-5.1.x/drools-core/src/test/java/org/drools/reteoo/test/dsl/IsTuple.java
===================================================================
--- labs/jbossrules/soa_branches/BRMS-5.1.x/drools-core/src/test/java/org/drools/reteoo/test/dsl/IsTuple.java	2011-05-09 17:06:37 UTC (rev 36987)
+++ labs/jbossrules/soa_branches/BRMS-5.1.x/drools-core/src/test/java/org/drools/reteoo/test/dsl/IsTuple.java	2011-05-09 18:32:01 UTC (rev 36988)
@@ -1,67 +1,67 @@
-/**
- * Copyright 2010 JBoss Inc
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in 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.reteoo.test.dsl;
-
-import java.util.Arrays;
-import java.util.List;
-
-import org.drools.common.InternalFactHandle;
-import org.hamcrest.BaseMatcher;
-import org.hamcrest.Description;
-import org.hamcrest.Factory;
-import org.hamcrest.Matcher;
-
-public class IsTuple extends BaseMatcher<List<InternalFactHandle>> {
-    private final InternalFactHandle[] expected;
-
-    public IsTuple(List<InternalFactHandle> tupleAsList) {
-        expected = tupleAsList.toArray( new InternalFactHandle[tupleAsList.size()] );
-    }
-
-    public IsTuple(InternalFactHandle[] tuple) {
-        expected = tuple;
-    }
-
-    public boolean matches(Object arg) {
-        if( arg == null || ! ( arg.getClass().isArray() && InternalFactHandle.class.isAssignableFrom( arg.getClass().getComponentType() ) ) ) {
-            return false;
-        }
-        InternalFactHandle[] actual = (InternalFactHandle[]) arg;
-        return Arrays.equals( expected, actual );
-    }
-
-    public void describeTo(Description description) {
-        description.appendValue(expected);
-    }
-    
-    /**
-     * Is the value equal to another value, as tested by the
-     * {@link java.lang.Object#equals} invokedMethod?
-     */
-    @Factory
-    public static Matcher<List<InternalFactHandle>> isTuple(List<InternalFactHandle> operand) {
-        return new IsTuple(operand);
-    }
-
-    public static Matcher<? super List<InternalFactHandle>> isTuple(InternalFactHandle... operands) {
-        return new IsTuple(operands);
-    }
-
+/**
+ * Copyright 2010 JBoss Inc
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in 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.reteoo.test.dsl;
+
+import java.util.Arrays;
+import java.util.List;
+
+import org.drools.common.InternalFactHandle;
+import org.hamcrest.BaseMatcher;
+import org.hamcrest.Description;
+import org.hamcrest.Factory;
+import org.hamcrest.Matcher;
+
+public class IsTuple extends BaseMatcher<List<InternalFactHandle>> {
+    private final InternalFactHandle[] expected;
+
+    public IsTuple(List<InternalFactHandle> tupleAsList) {
+        expected = tupleAsList.toArray( new InternalFactHandle[tupleAsList.size()] );
+    }
+
+    public IsTuple(InternalFactHandle[] tuple) {
+        expected = tuple;
+    }
+
+    public boolean matches(Object arg) {
+        if( arg == null || ! ( arg.getClass().isArray() && InternalFactHandle.class.isAssignableFrom( arg.getClass().getComponentType() ) ) ) {
+            return false;
+        }
+        InternalFactHandle[] actual = (InternalFactHandle[]) arg;
+        return Arrays.equals( expected, actual );
+    }
+
+    public void describeTo(Description description) {
+        description.appendValue(expected);
+    }
+    
+    /**
+     * Is the value equal to another value, as tested by the
+     * {@link java.lang.Object#equals} invokedMethod?
+     */
+    @Factory
+    public static Matcher<List<InternalFactHandle>> isTuple(List<InternalFactHandle> operand) {
+        return new IsTuple(operand);
+    }
+
+    public static Matcher<? super List<InternalFactHandle>> isTuple(InternalFactHandle... operands) {
+        return new IsTuple(operands);
+    }
+
 }
\ No newline at end of file



More information about the jboss-svn-commits mailing list