01: /**
02: * Licensed to the Apache Software Foundation (ASF) under one or more
03: * contributor license agreements. See the NOTICE file distributed with
04: * this work for additional information regarding copyright ownership.
05: * The ASF licenses this file to You under the Apache License, Version 2.0
06: * (the "License"); you may not use this file except in compliance with
07: * the License. You may obtain a copy of the License at
08: *
09: * http://www.apache.org/licenses/LICENSE-2.0
10: *
11: * Unless required by applicable law or agreed to in writing, software
12: * distributed under the License is distributed on an "AS IS" BASIS,
13: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14: * See the License for the specific language governing permissions and
15: * limitations under the License.
16: */package org.apache.geronimo.console.jmsmanager.server;
17:
18: import org.apache.geronimo.console.BasePortlet;
19: import org.apache.geronimo.console.util.PortletManager;
20: import org.apache.geronimo.gbean.AbstractName;
21: import org.apache.geronimo.management.geronimo.JMSBroker;
22: import org.apache.geronimo.management.geronimo.JMSManager;
23:
24: import javax.portlet.PortletException;
25: import javax.portlet.RenderRequest;
26:
27: import java.util.ArrayList;
28: import java.util.List;
29:
30: /**
31: * Common methods for JMS portlets
32: *
33: * @version $Rev: 476061 $ $Date: 2006-11-16 22:36:50 -0800 (Thu, 16 Nov 2006) $
34: */
35: public class BaseJMSPortlet extends BasePortlet {
36: /**
37: * Gets a Map relating broker name to JMSBroker instance
38: */
39: protected static List getBrokerList(RenderRequest renderRequest,
40: JMSManager manager) throws PortletException {
41:
42: JMSBroker[] brokers = (JMSBroker[]) manager.getContainers();
43: List beans = new ArrayList();
44: try {
45: for (int i = 0; i < brokers.length; i++) {
46: AbstractName abstractName = PortletManager.getNameFor(
47: renderRequest, brokers[i]);
48: String displayName = abstractName.getName().get("name")
49: .toString();
50: beans.add(new BrokerWrapper(displayName, abstractName
51: .toString(), brokers[i]));
52: }
53: } catch (Exception e) {
54: throw new PortletException(e);
55: }
56: return beans;
57: }
58:
59: public static class BrokerWrapper {
60: private String brokerName;
61: private String brokerURI;
62: private JMSBroker broker;
63:
64: public BrokerWrapper(String brokerName, String brokerURI,
65: JMSBroker broker) {
66: this .brokerName = brokerName;
67: this .brokerURI = brokerURI;
68: this .broker = broker;
69: }
70:
71: public String getBrokerName() {
72: return brokerName;
73: }
74:
75: public JMSBroker getBroker() {
76: return broker;
77: }
78:
79: public String getBrokerURI() {
80: return brokerURI;
81: }
82: }
83: }
|