KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > activemq > broker > jmx > ManagedTempQueueRegion


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.jmx;
19
20 import javax.jms.InvalidSelectorException JavaDoc;
21 import javax.management.ObjectName JavaDoc;
22
23 import org.apache.activemq.broker.ConnectionContext;
24 import org.apache.activemq.broker.region.Destination;
25 import org.apache.activemq.broker.region.DestinationFactory;
26 import org.apache.activemq.broker.region.DestinationStatistics;
27 import org.apache.activemq.broker.region.Subscription;
28 import org.apache.activemq.broker.region.TempQueueRegion;
29 import org.apache.activemq.command.ActiveMQDestination;
30 import org.apache.activemq.command.ConsumerInfo;
31 import org.apache.activemq.memory.UsageManager;
32 import org.apache.activemq.thread.TaskRunnerFactory;
33
34 public class ManagedTempQueueRegion extends TempQueueRegion {
35
36     private final ManagedRegionBroker regionBroker;
37     
38     public ManagedTempQueueRegion(ManagedRegionBroker regionBroker, DestinationStatistics destinationStatistics, UsageManager memoryManager, TaskRunnerFactory taskRunnerFactory, DestinationFactory destinationFactory) {
39         super(regionBroker,destinationStatistics, memoryManager, taskRunnerFactory, destinationFactory);
40         this.regionBroker = regionBroker;
41     }
42     
43     protected Subscription createSubscription(ConnectionContext context, ConsumerInfo info) throws InvalidSelectorException JavaDoc {
44         Subscription sub = super.createSubscription(context, info);
45         ObjectName JavaDoc name = regionBroker.registerSubscription(context,sub);
46         sub.setObjectName(name);
47         return sub;
48     }
49     
50     protected void destroySubscription(Subscription sub) {
51         regionBroker.unregisterSubscription(sub);
52         super.destroySubscription(sub);
53     }
54
55     protected Destination createDestination(ConnectionContext context, ActiveMQDestination destination) throws Exception JavaDoc {
56         Destination rc = super.createDestination(context, destination);
57         regionBroker.register(destination, rc);
58         return rc;
59     }
60     
61     public void removeDestination(ConnectionContext context, ActiveMQDestination destination, long timeout) throws Exception JavaDoc {
62         super.removeDestination(context, destination, timeout);
63         regionBroker.unregister(destination);
64     }
65
66 }
67
Popular Tags