001    /**
002     * Licensed to the Apache Software Foundation (ASF) under one or more
003     * contributor license agreements.  See the NOTICE file distributed with
004     * this work for additional information regarding copyright ownership.
005     * The ASF licenses this file to You under the Apache License, Version 2.0
006     * (the "License"); you may not use this file except in compliance with
007     * the License.  You may obtain a copy of the License at
008     *
009     *      http://www.apache.org/licenses/LICENSE-2.0
010     *
011     * Unless required by applicable law or agreed to in writing, software
012     * distributed under the License is distributed on an "AS IS" BASIS,
013     * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
014     * See the License for the specific language governing permissions and
015     * limitations under the License.
016     */
017    package org.apache.activemq.broker.jmx;
018    
019    import org.apache.activemq.broker.Connector;
020    import org.apache.activemq.command.BrokerInfo;
021    
022    public class ConnectorView implements ConnectorViewMBean {
023    
024        private final Connector connector;
025    
026        public ConnectorView(Connector connector) {
027            this.connector = connector;
028        }
029    
030        public void start() throws Exception {
031            connector.start();
032        }
033    
034        public String getBrokerName() {
035            return getBrokerInfo().getBrokerName();
036        }
037    
038        public void stop() throws Exception {
039            connector.stop();
040        }
041    
042        public String getBrokerURL() {
043            return getBrokerInfo().getBrokerURL();
044        }
045    
046        public BrokerInfo getBrokerInfo() {
047            return connector.getBrokerInfo();
048        }
049    
050        /**
051         * Resets the statistics
052         */
053        public void resetStatistics() {
054            connector.getStatistics().reset();
055        }
056    
057        /**
058         * enable statistics gathering
059         */
060        public void enableStatistics() {
061            connector.getStatistics().setEnabled(true);
062        }
063    
064        /**
065         * disable statistics gathering
066         */
067        public void disableStatistics() {
068            connector.getStatistics().setEnabled(false);
069        }
070    
071        /**
072         * Returns true if statistics is enabled
073         * 
074         * @return true if statistics is enabled
075         */
076        public boolean isStatisticsEnabled() {
077            return connector.getStatistics().isEnabled();
078        }
079    
080        /**
081         * Returns the number of current connections
082         */
083        public int connectionCount() {
084            return connector.connectionCount();
085        }
086    
087    }