KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > activemq > broker > region > QueueRegion


1 /**
2  *
3  * Licensed to the Apache Software Foundation (ASF) under one or more
4  * contributor license agreements. See the NOTICE file distributed with
5  * this work for additional information regarding copyright ownership.
6  * The ASF licenses this file to You under the Apache License, Version 2.0
7  * (the "License"); you may not use this file except in compliance with
8  * the License. You may obtain a copy of the License at
9  *
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 package org.apache.activemq.broker.region;
19
20 import org.apache.activemq.broker.ConnectionContext;
21 import org.apache.activemq.command.ActiveMQDestination;
22 import org.apache.activemq.command.ConsumerInfo;
23 import org.apache.activemq.memory.UsageManager;
24 import org.apache.activemq.thread.TaskRunnerFactory;
25
26 import javax.jms.InvalidSelectorException JavaDoc;
27
28 import java.util.Iterator JavaDoc;
29 import java.util.Set JavaDoc;
30
31 /**
32  *
33  * @version $Revision: 1.9 $
34  */

35 public class QueueRegion extends AbstractRegion {
36
37     
38
39     public QueueRegion(RegionBroker broker,DestinationStatistics destinationStatistics, UsageManager memoryManager, TaskRunnerFactory taskRunnerFactory,
40             DestinationFactory destinationFactory) {
41         super(broker,destinationStatistics, memoryManager, taskRunnerFactory, destinationFactory);
42     }
43
44     public String JavaDoc toString() {
45         return "QueueRegion: destinations=" + destinations.size() + ", subscriptions=" + subscriptions.size() + ", memory=" + memoryManager.getPercentUsage()
46                 + "%";
47     }
48
49     protected Subscription createSubscription(ConnectionContext context, ConsumerInfo info) throws InvalidSelectorException JavaDoc {
50         if (info.isBrowser()) {
51             return new QueueBrowserSubscription(broker,context, info);
52         }
53         else {
54             return new QueueSubscription(broker,context, info);
55         }
56     }
57
58     protected Set JavaDoc getInactiveDestinations() {
59         Set JavaDoc inactiveDestinations = super.getInactiveDestinations();
60         for (Iterator JavaDoc iter = inactiveDestinations.iterator(); iter.hasNext();) {
61             ActiveMQDestination dest = (ActiveMQDestination) iter.next();
62             if (!dest.isQueue())
63                 iter.remove();
64         }
65         return inactiveDestinations;
66     }
67 }
68
Popular Tags