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.Connection;
020    
021    public class ConnectionView implements ConnectionViewMBean {
022    
023        private final Connection connection;
024    
025        public ConnectionView(Connection connection) {
026            this.connection = connection;
027        }
028    
029        public void start() throws Exception {
030            connection.start();
031        }
032    
033        public void stop() throws Exception {
034            connection.stop();
035        }
036    
037        /**
038         * @return true if the Connection is slow
039         */
040        public boolean isSlow() {
041            return connection.isSlow();
042        }
043    
044        /**
045         * @return if after being marked, the Connection is still writing
046         */
047        public boolean isBlocked() {
048            return connection.isBlocked();
049        }
050    
051        /**
052         * @return true if the Connection is connected
053         */
054        public boolean isConnected() {
055            return connection.isConnected();
056        }
057    
058        /**
059         * @return true if the Connection is active
060         */
061        public boolean isActive() {
062            return connection.isActive();
063        }
064    
065        /**
066         * Resets the statistics
067         */
068        public void resetStatistics() {
069            connection.getStatistics().reset();
070        }
071    
072        public String getRemoteAddress() {
073            return connection.getRemoteAddress();
074        }
075    
076        public String getConnectionId() {
077            return connection.getConnectionId();
078        }
079    
080    }