01: package org.jacorb.notification.queue;
02:
03: /*
04: * JacORB - a free Java ORB
05: *
06: * Copyright (C) 1999-2004 Gerald Brose
07: *
08: * This library is free software; you can redistribute it and/or
09: * 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: import org.jacorb.notification.interfaces.Message;
25:
26: /**
27: * @author Alphonse Bendt
28: * @version $Id: EventQueueOverflowStrategy.java,v 1.5 2006/02/25 15:28:40 alphonse.bendt Exp $
29: */
30:
31: public interface EventQueueOverflowStrategy {
32: Message removeElementFromQueue(AbstractBoundedEventQueue queue);
33:
34: String getDiscardPolicyName();
35:
36: EventQueueOverflowStrategy FIFO = new EventQueueOverflowStrategy() {
37: public Message removeElementFromQueue(
38: AbstractBoundedEventQueue queue) {
39: return queue.getOldestElement();
40: }
41:
42: public String getDiscardPolicyName() {
43: return "FifoOrder";
44: }
45: };
46:
47: EventQueueOverflowStrategy LIFO = new EventQueueOverflowStrategy() {
48: public Message removeElementFromQueue(
49: AbstractBoundedEventQueue queue) {
50: return queue.getYoungestElement();
51: }
52:
53: public String getDiscardPolicyName() {
54: return "LifoOrder";
55: }
56: };
57:
58: EventQueueOverflowStrategy LEAST_PRIORITY = new EventQueueOverflowStrategy() {
59: public Message removeElementFromQueue(
60: AbstractBoundedEventQueue queue) {
61: return queue.getLeastPriority();
62: }
63:
64: public String getDiscardPolicyName() {
65: return "PriorityOrder";
66: }
67: };
68:
69: EventQueueOverflowStrategy EARLIEST_TIMEOUT = new EventQueueOverflowStrategy() {
70: public Message removeElementFromQueue(
71: AbstractBoundedEventQueue queue) {
72: return queue.getEarliestTimeout();
73: }
74:
75: public String getDiscardPolicyName() {
76: return "TimeoutOrder";
77: }
78: };
79: }
|