1
2
3
4
5
6
7
8
9
10
11 package org.mule.transaction.constraints;
12
13 import org.mule.umo.UMOEvent;
14
15
16
17
18
19
20 public class BatchConstraint extends ConstraintFilter
21 {
22
23 private int batchSize = 1;
24
25 private int batchCount = 0;
26
27 public boolean accept(UMOEvent event)
28 {
29 synchronized (this)
30 {
31 batchCount++;
32 return batchCount == batchSize;
33 }
34 }
35
36 public int getBatchSize()
37 {
38 synchronized (this)
39 {
40 return batchSize;
41 }
42 }
43
44 public synchronized void setBatchSize(int batchSize)
45 {
46 synchronized (this)
47 {
48 this.batchSize = batchSize;
49 }
50 }
51
52 public Object clone() throws CloneNotSupportedException
53 {
54 synchronized (this)
55 {
56 BatchConstraint clone = (BatchConstraint) super.clone();
57 clone.setBatchSize(batchSize);
58 for (int i = 0; i < batchCount; i++)
59 {
60 clone.accept(null);
61 }
62 return clone;
63 }
64 }
65
66 }