KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > mr > kernel > services > queues > AbstractQueueService


1 /*
2  * Copyright © Coridan Inc.
3  *
4  * This program is free software; you can redistribute it and/or
5  * modify it under the terms of the GNU General Public License as
6  * published by the Free Software Foundation; either version 2 of the
7  * License, or (at your option) any later version.
8  *
9  * This program is distributed in the hope that it will be useful, but
10  * WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12  * General Public License for more details.
13  *
14  * You should have received a copy of the GNU General Public License
15  * along with this program; if not, write to the Free Software
16  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
17  * USA
18  *
19  * Support at:
20  * http://sourceforge.net/projects/mantaray/
21  * Or
22  * support@coridan.com
23  */

24
25 package org.mr.kernel.services.queues;
26
27 import org.mr.MantaException;
28 import org.mr.kernel.services.MantaService;
29 import org.mr.kernel.services.ServiceConsumer;
30 import org.mr.core.protocol.MantaBusMessage;
31
32
33 /**
34  * AbstractQueueService.java
35  *
36  *
37  * Created: Wed Apr 05 18:02:18 2006
38  *
39  * @author Uri Schneider
40  * @version 1.0
41  */

42
43 public abstract class AbstractQueueService extends MantaService {
44     public static final int THROW_EXCEPTION_STRATERGY =0;
45     public static final int RETURN_WITHOUT_ENQUEUE_STRATERGY =1;
46     public static final int THROTTLE_STRATERGY =2;
47
48     protected int overflowStrategy;
49
50     public AbstractQueueService(String JavaDoc serviceName) {
51         super(serviceName);
52     } // AbstractQueueService constructor
53

54     public abstract void active();
55     public abstract boolean isActive();
56     protected abstract void registerReceiverToQueue(ServiceConsumer consumer,
57                                                     long numberOfReceive);
58     public abstract void unregisterReceiverToQueue(ServiceConsumer consumer);
59     public abstract void close() throws MantaException;
60     protected abstract void sendQueueCopy(ServiceConsumer consumer);
61     public abstract void waitForQueueMaster(long timeToWait)
62         throws InterruptedException JavaDoc;
63     public abstract void setQueueMaster(QueueMaster master);
64     public abstract QueueMaster getQueueMaster();
65     public abstract boolean amIQueueMaster();
66     public abstract boolean isOverflow();
67     public abstract boolean isTempQueue();
68     protected abstract void enqueue(MantaBusMessage msg, boolean persistent);
69     public abstract int getUnsentCount();
70     /**
71      * returns the overFlowStrategy of the Queue
72      *
73      * @return int 0 means THROW_EXCEPTION_STRATERGY,
74      * 1 means RETURN_WITHOUT_ENQUEUE_STRATERGY
75      * 2 means THROTTLING
76      */

77     public int getOverflowStrategy() { return this.overflowStrategy; }
78     public void setOverflowStrategy(int overflowStrategy) {
79         this.overflowStrategy = overflowStrategy;
80     }
81     public abstract QueueSubscriberManager getSubscriberManager();
82     public abstract void doDequeue() throws InterruptedException JavaDoc;
83
84 } // AbstractQueueService
85
Popular Tags