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 */
017package org.apache.activemq.broker.jmx;
018
019import org.apache.activemq.broker.Connector;
020import org.apache.activemq.command.BrokerInfo;
021
022public class ConnectorView implements ConnectorViewMBean {
023
024    private final Connector connector;
025
026    public ConnectorView(Connector connector) {
027        this.connector = connector;
028    }
029
030    @Override
031    public void start() throws Exception {
032        connector.start();
033    }
034
035    public String getBrokerName() {
036        return getBrokerInfo().getBrokerName();
037    }
038
039    @Override
040    public void stop() throws Exception {
041        connector.stop();
042    }
043
044    public String getBrokerURL() {
045        return getBrokerInfo().getBrokerURL();
046    }
047
048    public BrokerInfo getBrokerInfo() {
049        return connector.getBrokerInfo();
050    }
051
052    /**
053     * Resets the statistics
054     */
055    @Override
056    public void resetStatistics() {
057        connector.getStatistics().reset();
058    }
059
060    /**
061     * enable statistics gathering
062     */
063    @Override
064    public void enableStatistics() {
065        connector.getStatistics().setEnabled(true);
066    }
067
068    /**
069     * disable statistics gathering
070     */
071    @Override
072    public void disableStatistics() {
073        connector.getStatistics().setEnabled(false);
074    }
075
076    /**
077     * Returns true if statistics is enabled
078     *
079     * @return true if statistics is enabled
080     */
081    @Override
082    public boolean isStatisticsEnabled() {
083        return connector.getStatistics().isEnabled();
084    }
085
086    /**
087     * Returns the number of current connections
088     */
089    @Override
090    public int connectionCount() {
091        return connector.connectionCount();
092    }
093
094    /**
095     * Returns true if updating cluster client URL is enabled
096     *
097     * @return true if update cluster client URL is enabled
098     */
099    @Override
100    public boolean isUpdateClusterClients() {
101        return this.connector.isUpdateClusterClientsOnRemove();
102    }
103
104    /**
105     * Returns true if rebalancing cluster clients is enabled
106     *
107     * @return true if rebalance cluster clients is enabled
108     */
109    @Override
110    public boolean isRebalanceClusterClients() {
111        return this.connector.isRebalanceClusterClients();
112    }
113
114    /**
115     * Returns true if updating cluster client URL when brokers are removed is
116     * enabled
117     *
118     * @return true if update cluster client URL when brokers are removed is
119     *         enabled
120     */
121    @Override
122    public boolean isUpdateClusterClientsOnRemove() {
123        return this.connector.isUpdateClusterClientsOnRemove();
124    }
125
126    /**
127     * @return The comma separated string of regex patterns to match broker
128     *         names for cluster client updates
129     */
130    @Override
131    public String getUpdateClusterFilter() {
132        return this.connector.getUpdateClusterFilter();
133    }
134
135    @Override
136    public boolean isAllowLinkStealingEnabled() {
137        return this.connector.isAllowLinkStealing();
138    }
139}