1 package org.jacorb.notification.engine; 2 3 23 24 import java.util.ArrayList ; 25 import java.util.Iterator ; 26 import java.util.List ; 27 28 import org.jacorb.notification.interfaces.FilterStage; 29 30 34 35 public class FilterConsumerAdminTask extends AbstractFilterTask 36 { 37 private static int sCount = 0; 38 39 private int id_ = ++sCount; 40 41 44 private final List listOfFilterStageWithMessageConsumer_ = new ArrayList (); 45 46 48 public FilterConsumerAdminTask(TaskFactory taskFactory, TaskExecutor taskExecutor) 49 { 50 super(taskFactory, taskExecutor); 51 } 52 53 55 public String toString() 56 { 57 return "[FilterConsumerAdminTask#" + id_ + "]"; 58 } 59 60 63 public FilterStage[] getFilterStagesWithMessageConsumer() 64 { 65 return (FilterStage[]) listOfFilterStageWithMessageConsumer_.toArray(EMPTY_FILTERSTAGE); 66 } 67 68 private void clearFilterStagesWithMessageConsumer() 69 { 70 listOfFilterStageWithMessageConsumer_.clear(); 71 } 72 73 public void reset() 74 { 75 super.reset(); 76 77 clearFilterStagesWithMessageConsumer(); 78 arrayCurrentFilterStage_ = EMPTY_FILTERSTAGE; 79 } 80 81 public void doFilter() throws InterruptedException 82 { 83 filter(); 84 85 pushToConsumers(); 86 } 87 88 private void pushToConsumers() throws InterruptedException 89 { 90 95 FilterStage[] _filterStagesWithMessageConsumer = getFilterStagesWithMessageConsumer(); 96 97 if (_filterStagesWithMessageConsumer.length > 0) 98 { 99 getTaskFactory() 100 .enqueueMessage(_filterStagesWithMessageConsumer, getMessage()); 101 } 102 103 Schedulable _filterTaskToBeScheduled = _filterTaskToBeScheduled = getTaskFactory() 104 .newFilterProxySupplierTask(this); 105 106 _filterTaskToBeScheduled.schedule(); 107 } 108 109 private void filter() throws InterruptedException 110 { 111 for (int x = 0; x < arrayCurrentFilterStage_.length; ++x) 112 { 113 checkInterrupt(); 114 115 boolean _filterForCurrentFilterStageMatched = false; 116 117 if (!arrayCurrentFilterStage_[x].isDisposed()) 118 { 119 _filterForCurrentFilterStageMatched = getMessage().match(arrayCurrentFilterStage_[x]); 120 } 121 122 if (_filterForCurrentFilterStageMatched) 123 { 124 if (arrayCurrentFilterStage_[x].hasInterFilterGroupOperatorOR()) 125 { 126 132 listOfFilterStageWithMessageConsumer_.addAll(arrayCurrentFilterStage_[x] 133 .getSubsequentFilterStages()); 134 } 135 else 136 { 137 140 addFilterStage(arrayCurrentFilterStage_[x].getSubsequentFilterStages()); 141 } 142 } 143 else 144 { 145 151 Iterator _i = arrayCurrentFilterStage_[x].getSubsequentFilterStages().iterator(); 152 153 while (_i.hasNext()) 154 { 155 FilterStage _filterStage = (FilterStage) _i.next(); 156 157 if (_filterStage.hasInterFilterGroupOperatorOR()) 158 { 159 addFilterStage(_filterStage); 160 } 161 } 162 } 163 } 164 } 165 } | Popular Tags |