Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements. See the NOTICE file distributed with this work for additional information regarding copyright ownership. The ASF licenses this file to You under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
 
 package org.apache.activemq.web;
 
 import java.util.List;
 
 
A useful base class for an implementation of BrokerFacade

Version:
$Revision: 569067 $
 
 public abstract class BrokerFacadeSupport implements BrokerFacade {
     public abstract ManagementContext getManagementContext();
 
     public Collection<ObjectgetQueues() throws Exception {
         BrokerViewMBean broker = getBrokerAdmin();
         if (broker == null) {
             return .;
         }
         ObjectName[] queues = broker.getQueues();
         return getManagedObjects(queuesQueueViewMBean.class);
     }
 
     public Collection<ObjectgetTopics() throws Exception {
         BrokerViewMBean broker = getBrokerAdmin();
         if (broker == null) {
             return .;
         }
         ObjectName[] queues = broker.getTopics();
         return getManagedObjects(queuesTopicViewMBean.class);
     }
 
     public Collection<ObjectgetDurableTopicSubscribers() throws Exception {
         BrokerViewMBean broker = getBrokerAdmin();
         if (broker == null) {
             return .;
         }
         ObjectName[] queues = broker.getDurableTopicSubscribers();
         return getManagedObjects(queuesDurableSubscriptionViewMBean.class);
     }
 
     public QueueViewMBean getQueue(String namethrows Exception {
         return (QueueViewMBeangetDestinationByName(getQueues(), name);
     }
 
     public TopicViewMBean getTopic(String namethrows Exception {
         return (TopicViewMBeangetDestinationByName(getTopics(), name);
     }
 
     protected DestinationViewMBean getDestinationByName(Collection<ObjectcollectionString name) {
         Iterator<Objectiter = collection.iterator();
         while (iter.hasNext()) {
             DestinationViewMBean destinationViewMBean = (DestinationViewMBeaniter.next();
             if (name.equals(destinationViewMBean.getName())) {
                 return destinationViewMBean;
             }
         }
         return null;
     }
 
     protected Collection<ObjectgetManagedObjects(ObjectName[] namesClass type) {
         List<Objectanswer = new ArrayList<Object>();
         MBeanServer mbeanServer = getManagementContext().getMBeanServer();
         if (mbeanServer != null) {
             for (int i = 0; i < names.lengthi++) {
                 ObjectName name = names[i];
                 Object value = MBeanServerInvocationHandler.newProxyInstance(mbeanServernametypetrue);
                 if (value != null) {
                     answer.add(value);
                 }
            }
        }
        return answer;
    }
New to GrepCode? Check out our FAQ X