KickJava   Java API By Example, From Geeks To Geeks.

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


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.management.openmbean.CompositeData JavaDoc;
21 import javax.management.openmbean.OpenDataException JavaDoc;
22
23 import org.apache.activemq.broker.ConnectionContext;
24 import org.apache.activemq.broker.region.Queue;
25 import org.apache.activemq.command.ActiveMQDestination;
26 import org.apache.activemq.command.Message;
27
28 /**
29  * Provides a JMX Management view of a Queue.
30  */

31 public class QueueView extends DestinationView implements QueueViewMBean{
32     public QueueView(ManagedRegionBroker broker, Queue destination){
33         super(broker, destination);
34     }
35
36     public CompositeData JavaDoc getMessage(String JavaDoc messageId) throws OpenDataException JavaDoc{
37         Message rc=((Queue) destination).getMessage(messageId);
38         if(rc==null)
39             return null;
40         return OpenTypeSupport.convert(rc);
41     }
42
43     public void purge() throws Exception JavaDoc{
44         ((Queue) destination).purge();
45     }
46
47     public boolean removeMessage(String JavaDoc messageId) throws Exception JavaDoc{
48         return ((Queue) destination).removeMessage(messageId);
49     }
50
51     public int removeMatchingMessages(String JavaDoc selector) throws Exception JavaDoc {
52         return ((Queue) destination).removeMatchingMessages(selector);
53     }
54     
55     public int removeMatchingMessages(String JavaDoc selector, int maximumMessages) throws Exception JavaDoc {
56         return ((Queue) destination).removeMatchingMessages(selector, maximumMessages);
57     }
58     
59     public boolean copyMessageTo(String JavaDoc messageId, String JavaDoc destinationName) throws Exception JavaDoc {
60         ConnectionContext context = BrokerView.getConnectionContext(broker.getContextBroker());
61         ActiveMQDestination toDestination = ActiveMQDestination.createDestination(destinationName, ActiveMQDestination.QUEUE_TYPE);
62         return ((Queue) destination).copyMessageTo(context, messageId, toDestination);
63     }
64
65     public int copyMatchingMessagesTo(String JavaDoc selector, String JavaDoc destinationName) throws Exception JavaDoc {
66         ConnectionContext context = BrokerView.getConnectionContext(broker.getContextBroker());
67         ActiveMQDestination toDestination = ActiveMQDestination.createDestination(destinationName, ActiveMQDestination.QUEUE_TYPE);
68         return ((Queue) destination).copyMatchingMessagesTo(context, selector, toDestination);
69     }
70     
71     public int copyMatchingMessagesTo(String JavaDoc selector, String JavaDoc destinationName, int maximumMessages) throws Exception JavaDoc {
72         ConnectionContext context = BrokerView.getConnectionContext(broker.getContextBroker());
73         ActiveMQDestination toDestination = ActiveMQDestination.createDestination(destinationName, ActiveMQDestination.QUEUE_TYPE);
74         return ((Queue) destination).copyMatchingMessagesTo(context, selector, toDestination, maximumMessages);
75     }
76     
77     public boolean moveMessageTo(String JavaDoc messageId, String JavaDoc destinationName) throws Exception JavaDoc {
78         ConnectionContext context = BrokerView.getConnectionContext(broker.getContextBroker());
79         ActiveMQDestination toDestination = ActiveMQDestination.createDestination(destinationName, ActiveMQDestination.QUEUE_TYPE);
80         return ((Queue) destination).moveMessageTo(context, messageId, toDestination);
81     }
82     
83     public int moveMatchingMessagesTo(String JavaDoc selector, String JavaDoc destinationName) throws Exception JavaDoc {
84         ConnectionContext context = BrokerView.getConnectionContext(broker.getContextBroker());
85         ActiveMQDestination toDestination = ActiveMQDestination.createDestination(destinationName, ActiveMQDestination.QUEUE_TYPE);
86         return ((Queue) destination).moveMatchingMessagesTo(context, selector, toDestination);
87     }
88     
89     public int moveMatchingMessagesTo(String JavaDoc selector, String JavaDoc destinationName, int maximumMessages) throws Exception JavaDoc {
90         ConnectionContext context = BrokerView.getConnectionContext(broker.getContextBroker());
91         ActiveMQDestination toDestination = ActiveMQDestination.createDestination(destinationName, ActiveMQDestination.QUEUE_TYPE);
92         return ((Queue) destination).moveMatchingMessagesTo(context, selector, toDestination, maximumMessages);
93     }
94
95 }
96
Popular Tags