KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > activemq > broker > region > cursors > AbstractPendingMessageCursor


1 /**
2  *
3  * Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements. See the NOTICE
4  * file distributed with this work for additional information regarding copyright ownership. The ASF licenses this file
5  * to You under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the
6  * License. You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on
11  * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the
12  * specific language governing permissions and limitations under the License.
13  */

14
15 package org.apache.activemq.broker.region.cursors;
16
17 import java.util.LinkedList JavaDoc;
18 import org.apache.activemq.broker.ConnectionContext;
19 import org.apache.activemq.broker.region.Destination;
20 import org.apache.activemq.broker.region.MessageReference;
21 import org.apache.activemq.memory.UsageManager;
22
23 /**
24  * Abstract method holder for pending message (messages awaiting disptach to a consumer) cursor
25  *
26  * @version $Revision: 500862 $
27  */

28 public class AbstractPendingMessageCursor implements PendingMessageCursor{
29     protected int memoryUsageHighWaterMark = 90;
30     protected int maxBatchSize=100;
31     protected UsageManager usageManager;
32
33     public void start() throws Exception JavaDoc {
34     }
35
36     public void stop() throws Exception JavaDoc {
37         gc();
38     }
39
40     public void add(ConnectionContext context,Destination destination) throws Exception JavaDoc{
41     }
42
43     public void remove(ConnectionContext context,Destination destination) throws Exception JavaDoc{
44     }
45
46     public boolean isRecoveryRequired(){
47         return true;
48     }
49
50     public void addMessageFirst(MessageReference node) throws Exception JavaDoc{
51     }
52
53     public void addMessageLast(MessageReference node) throws Exception JavaDoc{
54     }
55     
56     public void addRecoveredMessage(MessageReference node) throws Exception JavaDoc{
57         addMessageLast(node);
58     }
59
60     public void clear(){
61     }
62
63     public boolean hasNext(){
64         return false;
65     }
66
67     public boolean isEmpty(){
68         return false;
69     }
70     
71     public boolean isEmpty(Destination destination) {
72         return isEmpty();
73     }
74
75     public MessageReference next(){
76         return null;
77     }
78
79     public void remove(){
80     }
81
82     public void reset(){
83     }
84
85     public int size(){
86         return 0;
87     }
88
89     public int getMaxBatchSize(){
90         return maxBatchSize;
91     }
92
93     public void setMaxBatchSize(int maxBatchSize){
94         this.maxBatchSize=maxBatchSize;
95     }
96
97     protected void fillBatch() throws Exception JavaDoc{
98     }
99
100     public void resetForGC(){
101         reset();
102     }
103
104     public void remove(MessageReference node){
105     }
106     
107     public void gc(){
108     }
109
110    
111     public void setUsageManager(UsageManager usageManager){
112        this.usageManager = usageManager;
113     }
114     
115     public boolean hasSpace() {
116         return usageManager != null ? (usageManager.getPercentUsage() < memoryUsageHighWaterMark): true;
117     }
118     
119     public boolean isFull() {
120         return usageManager != null ? usageManager.isFull() : false;
121     }
122
123     
124     public void release(){
125     }
126     
127     public boolean hasMessagesBufferedToDeliver() {
128         return false;
129     }
130
131     
132     /**
133      * @return the memoryUsageHighWaterMark
134      */

135     public int getMemoryUsageHighWaterMark(){
136         return this.memoryUsageHighWaterMark;
137     }
138
139     
140     /**
141      * @param memoryUsageHighWaterMark the memoryUsageHighWaterMark to set
142      */

143     public void setMemoryUsageHighWaterMark(int memoryUsageHighWaterMark){
144         this.memoryUsageHighWaterMark=memoryUsageHighWaterMark;
145     }
146
147     
148     /**
149      * @return the usageManager
150      */

151     public UsageManager getUsageManager(){
152         return this.usageManager;
153     }
154     
155     /**
156      * destroy the cursor
157      * @throws Exception
158      */

159     public void destroy() throws Exception JavaDoc {
160         stop();
161     }
162     
163     /**
164      * Page in a restricted number of messages
165      * @param maxItems
166      * @return a list of paged in messages
167      */

168     public LinkedList JavaDoc pageInList(int maxItems) {
169         throw new RuntimeException JavaDoc("Not supported");
170     }
171 }
172
Popular Tags