KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > jacorb > notification > engine > FilterSupplierAdminTask


1 package org.jacorb.notification.engine;
2
3 /*
4  * JacORB - a free Java ORB
5  *
6  * Copyright (C) 1999-2004 Gerald Brose
7  *
8  * This library is free software; you can redistribute it and/or
9  * modify it under the terms of the GNU Library General Public
10  * License as published by the Free Software Foundation; either
11  * version 2 of the License, or (at your option) any later version.
12  *
13  * This library is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16  * Library General Public License for more details.
17  *
18  * You should have received a copy of the GNU Library General Public
19  * License along with this library; if not, write to the Free
20  * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
21  *
22  */

23
24 /**
25  * @author Alphonse Bendt
26  * @version $Id: FilterSupplierAdminTask.java,v 1.14 2005/04/27 10:48:40 alphonse.bendt Exp $
27  */

28
29 public class FilterSupplierAdminTask extends AbstractFilterTask
30 {
31     private static int sCount = 0;
32
33     private int id_ = ++sCount;
34
35     private boolean skip_ = false;
36
37     ////////////////////////////////////////
38

39     public FilterSupplierAdminTask(TaskFactory taskFactory, TaskExecutor taskExecutor)
40     {
41         super(taskFactory, taskExecutor);
42     }
43
44     ////////////////////////////////////////
45

46     public String JavaDoc toString()
47     {
48         return "[FilterSupplierAdminTask#" + id_ + "]";
49     }
50
51     public void setSkip(boolean skip)
52     {
53         skip_ = skip;
54     }
55
56     public void reset()
57     {
58         super.reset();
59
60         skip_ = false;
61     }
62
63     public void doFilter() throws InterruptedException JavaDoc
64     {
65         final boolean _forward = filter();
66
67         if (_forward)
68         {
69             getTaskFactory().newFilterConsumerAdminTask(this).schedule();
70         }
71     }
72
73     private boolean filter()
74     {
75         final boolean _forward;
76
77         // process attached filters. as an Event passes only 1
78
// SupplierAdmin we can assume constant array size here
79

80         if (!skip_)
81         {
82             _forward = getMessage().match(arrayCurrentFilterStage_[0]);
83         }
84         else
85         {
86             _forward = true;
87         }
88
89         if (_forward)
90         {
91             addFilterStage(arrayCurrentFilterStage_[0].getSubsequentFilterStages());
92         }
93
94         return _forward;
95     }
96 }
Popular Tags