01: package org.drools.audit.event;
02:
03: /*
04: * Copyright 2005 JBoss Inc
05: *
06: * Licensed under the Apache License, Version 2.0 (the "License");
07: * you may not use this file except in compliance with the License.
08: * You may obtain a copy of the License at
09: *
10: * http://www.apache.org/licenses/LICENSE-2.0
11: *
12: * Unless required by applicable law or agreed to in writing, software
13: * distributed under the License is distributed on an "AS IS" BASIS,
14: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15: * See the License for the specific language governing permissions and
16: * limitations under the License.
17: */
18:
19: /**
20: * An event filter that can be used to filter assertion events.
21: * By default, all events are allowed. You can filter out any of the
22: * four types of assertion events by setting the allow boolean
23: * for that type to false.
24: *
25: * @author <a href="mailto:kris_verlaenen@hotmail.com">Kris Verlaenen </a>
26: */
27: public class ActivationLogEventFilter implements ILogEventFilter {
28:
29: private boolean allowActivationCreatedEvents = true;
30: private boolean allowActivationCancelledEvents = true;
31: private boolean allowBeforeActivationFireEvents = true;
32: private boolean allowAfterActivationFireEvents = true;
33:
34: public ActivationLogEventFilter(
35: final boolean allowActivationCreatedEvents,
36: final boolean allowActivationCancelledEvents,
37: final boolean allowBeforeActivationFireEvents,
38: final boolean allowAfterActivationFireEvents) {
39: setAllowActivationCreatedEvents(allowActivationCreatedEvents);
40: setAllowActivationCancelledEvents(allowActivationCancelledEvents);
41: setAllowBeforeActivationFireEvents(allowBeforeActivationFireEvents);
42: setAllowAfterActivationFireEvents(allowAfterActivationFireEvents);
43: }
44:
45: /**
46: * @see org.drools.audit.event.ILogEventFilter
47: */
48: public boolean acceptEvent(final LogEvent event) {
49: switch (event.getType()) {
50: case LogEvent.ACTIVATION_CREATED:
51: return this .allowActivationCreatedEvents;
52: case LogEvent.ACTIVATION_CANCELLED:
53: return this .allowActivationCancelledEvents;
54: case LogEvent.BEFORE_ACTIVATION_FIRE:
55: return this .allowBeforeActivationFireEvents;
56: case LogEvent.AFTER_ACTIVATION_FIRE:
57: return this .allowAfterActivationFireEvents;
58: default:
59: return true;
60: }
61: }
62:
63: public void setAllowActivationCreatedEvents(
64: final boolean allowActivationCreatedEvents) {
65: this .allowActivationCreatedEvents = allowActivationCreatedEvents;
66: }
67:
68: public void setAllowActivationCancelledEvents(
69: final boolean allowActivationCancelledEvents) {
70: this .allowActivationCancelledEvents = allowActivationCancelledEvents;
71: }
72:
73: public void setAllowBeforeActivationFireEvents(
74: final boolean allowBeforeActivationFireEvents) {
75: this .allowBeforeActivationFireEvents = allowBeforeActivationFireEvents;
76: }
77:
78: public void setAllowAfterActivationFireEvents(
79: final boolean allowAfterActivationFireEvents) {
80: this.allowAfterActivationFireEvents = allowAfterActivationFireEvents;
81: }
82: }
|