KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > activemq > console > util > AmqMessagesUtil


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.console.util;
19
20 import org.apache.activemq.console.filter.QueryFilter;
21 import org.apache.activemq.console.filter.WildcardToMsgSelectorTransformFilter;
22 import org.apache.activemq.console.filter.PropertiesViewFilter;
23 import org.apache.activemq.console.filter.StubQueryFilter;
24 import org.apache.activemq.console.filter.MapTransformFilter;
25 import org.apache.activemq.console.filter.GroupPropertiesViewFilter;
26 import org.apache.activemq.console.filter.AmqMessagesQueryFilter;
27
28 import javax.jms.Destination JavaDoc;
29 import java.net.URI JavaDoc;
30 import java.util.List JavaDoc;
31 import java.util.Set JavaDoc;
32
33 public class AmqMessagesUtil {
34     public static final String JavaDoc JMS_MESSAGE_HEADER_PREFIX = "JMS_HEADER_FIELD:";
35     public static final String JavaDoc JMS_MESSAGE_CUSTOM_PREFIX = "JMS_CUSTOM_FIELD:";
36     public static final String JavaDoc JMS_MESSAGE_BODY_PREFIX = "JMS_BODY_FIELD:";
37
38     public static List JavaDoc getAllMessages(URI JavaDoc brokerUrl, Destination JavaDoc dest) throws Exception JavaDoc {
39        return getMessages(brokerUrl, dest, "");
40     }
41
42     public static List JavaDoc getMessages(URI JavaDoc brokerUrl, Destination JavaDoc dest, String JavaDoc selector) throws Exception JavaDoc {
43         return createMessageQueryFilter(brokerUrl, dest).query(selector);
44     }
45
46     public static List JavaDoc getMessages(URI JavaDoc brokerUrl, Destination JavaDoc dest, List JavaDoc selectors) throws Exception JavaDoc {
47         return createMessageQueryFilter(brokerUrl, dest).query(selectors);
48     }
49
50     public static List JavaDoc filterMessagesView(List JavaDoc messages, Set JavaDoc groupViews, Set JavaDoc attributeViews) throws Exception JavaDoc {
51         return (new PropertiesViewFilter(attributeViews,
52             new GroupPropertiesViewFilter(groupViews,
53                 new MapTransformFilter(
54                     new StubQueryFilter(messages)
55                 )
56             )
57         )).query("");
58     }
59
60     public static QueryFilter createMessageQueryFilter(URI JavaDoc brokerUrl, Destination JavaDoc dest) {
61         return new WildcardToMsgSelectorTransformFilter(
62             new AmqMessagesQueryFilter(brokerUrl, dest)
63         );
64     }
65 }
66
Popular Tags