KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > activemq > broker > jmx > ConnectionView


1 /**
2  *
3  * Licensed to the Apache Software Foundation (ASF) under one or more
4  * contributor license agreements. See the NOTICE file distributed with
5  * this work for additional information regarding copyright ownership.
6  * The ASF licenses this file to You under the Apache License, Version 2.0
7  * (the "License"); you may not use this file except in compliance with
8  * the License. You may obtain a copy of the License at
9  *
10  * http://www.apache.org/licenses/LICENSE-2.0
11  *
12  * Unless required by applicable law or agreed to in writing, software
13  * distributed under the License is distributed on an "AS IS" BASIS,
14  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15  * See the License for the specific language governing permissions and
16  * limitations under the License.
17  */

18 package org.apache.activemq.broker.jmx;
19
20 import org.apache.activemq.broker.Connection;
21
22 public class ConnectionView implements ConnectionViewMBean {
23
24     private final Connection connection;
25
26     public ConnectionView(Connection connection) {
27         this.connection = connection;
28     }
29
30     public void start() throws Exception JavaDoc {
31         connection.start();
32     }
33
34     public void stop() throws Exception JavaDoc {
35         connection.stop();
36     }
37     
38     /**
39      * @return true if the Connection is slow
40      */

41     public boolean isSlow() {
42         return connection.isSlow();
43     }
44     
45     /**
46      * @return if after being marked, the Connection is still writing
47      */

48     public boolean isBlocked() {
49         return connection.isBlocked();
50     }
51     
52     
53     /**
54      * @return true if the Connection is connected
55      */

56     public boolean isConnected() {
57         return connection.isConnected();
58     }
59     
60     /**
61      * @return true if the Connection is active
62      */

63     public boolean isActive() {
64         return connection.isActive();
65     }
66     
67
68     /**
69      * Returns the number of messages to be dispatched to this connection
70      */

71     public int getDispatchQueueSize() {
72         return connection.getDispatchQueueSize();
73     }
74     
75     /**
76      * Resets the statistics
77      */

78     public void resetStatistics() {
79         connection.getStatistics().reset();
80     }
81
82     /**
83      * Returns the number of messages enqueued on this connection
84      *
85      * @return the number of messages enqueued on this connection
86      */

87     public long getEnqueueCount() {
88         return connection.getStatistics().getEnqueues().getCount();
89     
90     }
91
92     /**
93      * Returns the number of messages dequeued on this connection
94      *
95      * @return the number of messages dequeued on this connection
96      */

97     public long getDequeueCount() {
98         return connection.getStatistics().getDequeues().getCount();
99     }
100
101     public String JavaDoc getRemoteAddress() {
102         return connection.getRemoteAddress();
103     }
104
105     public String JavaDoc getConnectionId() {
106         return connection.getConnectionId();
107     }
108
109 }
110
Popular Tags