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 java.util.List;
020import java.util.concurrent.CopyOnWriteArrayList;
021
022import org.apache.activemq.network.NetworkBridge;
023
024public class NetworkBridgeView implements NetworkBridgeViewMBean {
025
026    private final NetworkBridge bridge;
027    private boolean createByDuplex = false;
028    private List<NetworkDestinationView> networkDestinationViewList = new CopyOnWriteArrayList<NetworkDestinationView>();
029
030    public NetworkBridgeView(NetworkBridge bridge) {
031        this.bridge = bridge;
032    }
033
034    public void start() throws Exception {
035        bridge.start();
036    }
037
038    public void stop() throws Exception {
039        bridge.stop();
040    }
041
042    public String getLocalAddress() {
043        return bridge.getLocalAddress();
044    }
045
046    public String getRemoteAddress() {
047        return bridge.getRemoteAddress();
048    }
049
050    public String getRemoteBrokerName() {
051        return bridge.getRemoteBrokerName();
052    }
053
054
055    public String getRemoteBrokerId() {
056        return bridge.getRemoteBrokerId();
057    }
058
059    public String getLocalBrokerName() {
060        return bridge.getLocalBrokerName();
061    }
062
063    public long getEnqueueCounter() {
064        return bridge.getEnqueueCounter();
065    }
066
067    public long getDequeueCounter() {
068        return bridge.getDequeueCounter();
069    }
070
071    public boolean isCreatedByDuplex() {
072        return createByDuplex;
073    }
074
075    public void setCreateByDuplex(boolean createByDuplex) {
076        this.createByDuplex = createByDuplex;
077    }
078
079    public void resetStats(){
080        bridge.resetStats();
081        for (NetworkDestinationView networkDestinationView:networkDestinationViewList){
082            networkDestinationView.resetStats();
083        }
084    }
085
086    public void addNetworkDestinationView(NetworkDestinationView networkDestinationView){
087        networkDestinationViewList.add(networkDestinationView);
088    }
089
090    public void removeNetworkDestinationView(NetworkDestinationView networkDestinationView){
091        networkDestinationViewList.remove(networkDestinationView);
092    }
093}