KickJava   Java API By Example, From Geeks To Geeks.

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


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.Connector;
21 import org.apache.activemq.command.BrokerInfo;
22
23 public class ConnectorView implements ConnectorViewMBean {
24
25     private final Connector connector;
26
27     public ConnectorView(Connector connector) {
28         this.connector = connector;
29     }
30
31     public void start() throws Exception JavaDoc {
32         connector.start();
33     }
34
35     public String JavaDoc getBrokerName() {
36         return getBrokerInfo().getBrokerName();
37     }
38
39     public void stop() throws Exception JavaDoc {
40         connector.stop();
41     }
42
43     public String JavaDoc getBrokerURL() {
44         return getBrokerInfo().getBrokerURL();
45     }
46
47     public BrokerInfo getBrokerInfo() {
48         return connector.getBrokerInfo();
49     }
50     
51     /**
52      * Resets the statistics
53      */

54     public void resetStatistics() {
55         connector.getStatistics().reset();
56     }
57     
58     
59     /**
60      * enable statistics gathering
61      */

62     public void enableStatistics() {
63         connector.getStatistics().setEnabled(true);
64     }
65     
66     /**
67      * disable statistics gathering
68      */

69     public void disableStatistics() {
70         connector.getStatistics().setEnabled(false);
71     }
72     
73     /**
74      * Returns true if statistics is enabled
75      *
76      * @return true if statistics is enabled
77      */

78     public boolean isStatisticsEnabled() {
79         return connector.getStatistics().isEnabled();
80     }
81
82     /**
83      * Returns the number of messages enqueued on this connector
84      *
85      * @return the number of messages enqueued on this connector
86      */

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

97     public long getDequeueCount() {
98         return connector.getStatistics().getDequeues().getCount();
99     }
100
101 }
102
Popular Tags