Skip to content

Commit 899f353

Browse files
authored
[AMQ-9769] Add name property to connector interface and MBean. (#1493)
* [AMQ-9769] Add name property to connector interface and MBean. * [AMQ-9769] Use connector name property in web console. * Add getConnectionId() to ConnectionViewMBeanAdd.
1 parent 9949dce commit 899f353

9 files changed

Lines changed: 34 additions & 21 deletions

File tree

activemq-broker/src/main/java/org/apache/activemq/broker/Connector.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,4 +111,8 @@ public interface Connector extends Service {
111111

112112
public int getConnectionCount();
113113

114+
/**
115+
* @return connector name
116+
*/
117+
public String getName();
114118
}

activemq-broker/src/main/java/org/apache/activemq/broker/jmx/ConnectionView.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,7 @@ public String getClientId() {
105105
return connection.getConnectionId();
106106
}
107107

108+
@Override
108109
public String getConnectionId() {
109110
return connection.getConnectionId();
110111
}

activemq-broker/src/main/java/org/apache/activemq/broker/jmx/ConnectionViewMBean.java

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,14 @@ public interface ConnectionViewMBean extends Service {
6868
@MBeanInfo("client id for this connection")
6969
String getClientId();
7070

71+
/**
72+
* Returns the identifier for this connection
73+
*
74+
* @return the identifier for this connection
75+
*/
76+
@MBeanInfo("ID for this connection")
77+
String getConnectionId();
78+
7179
/**
7280
* Returns the number of messages to be dispatched to this connection
7381
* @return the number of messages pending dispatch

activemq-broker/src/main/java/org/apache/activemq/broker/jmx/ConnectorView.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -230,4 +230,8 @@ public int getConnectionCount() {
230230
return this.connector.connectionCount();
231231
}
232232

233+
@Override
234+
public String getName() {
235+
return this.connector.getName();
236+
}
233237
}

activemq-broker/src/main/java/org/apache/activemq/broker/jmx/ConnectorViewMBean.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -145,4 +145,7 @@ public interface ConnectorViewMBean extends Service {
145145

146146
@MBeanInfo("Connection count")
147147
public int getConnectionCount();
148+
149+
@MBeanInfo("Connector name")
150+
String getName();
148151
}

activemq-web-console/src/main/webapp/WEB-INF/tags/jms/forEachConnection.tag

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,8 @@
2323
<%
2424
Iterator it = broker.getConnections(connectorName).iterator();
2525
while (it.hasNext()) {
26-
String conName = (String) it.next();
27-
ConnectionViewMBean con = broker.getConnection(conName);
28-
request.setAttribute(connectionName, conName);
26+
ConnectionViewMBean con = (ConnectionViewMBean) it.next();
27+
request.setAttribute(connectionName, con.getClientId());
2928
request.setAttribute(connection, con);
3029
%>
3130
<jsp:doBody/>

activemq-web-console/src/main/webapp/connections.jsp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,8 @@
2828

2929
<h2>Connections</h2>
3030

31-
<c:forEach items="${requestContext.brokerQuery.connectors}" var="connectorName">
32-
<h3>Connector <c:out value="${connectorName}" /></h3>
31+
<c:forEach items="${requestContext.brokerQuery.connectors}" var="connector">
32+
<h3>Connector <c:out value="${connector.name}" /></h3>
3333

3434
<table id="connections" class="sortable autostripe">
3535
<thead>
@@ -41,7 +41,7 @@
4141
</tr>
4242
</thead>
4343
<tbody>
44-
<jms:forEachConnection broker="${requestContext.brokerQuery}" connectorName="${connectorName}"
44+
<jms:forEachConnection broker="${requestContext.brokerQuery}" connectorName="${connector.name}"
4545
connection="con" connectionName="conName">
4646
<tr>
4747

activemq-web/src/main/java/org/apache/activemq/web/BrokerFacade.java

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -134,12 +134,12 @@ Collection<DurableSubscriptionViewMBean> getInactiveDurableTopicSubscribers()
134134
throws Exception;
135135

136136
/**
137-
* The names of all transport connectors of the broker (f.e. openwire, ssl)
137+
* All transport connectors of the broker (f.e. openwire, ssl)
138138
*
139139
* @return not <code>null</code>
140140
* @throws Exception
141141
*/
142-
Collection<String> getConnectors() throws Exception;
142+
Collection<ConnectorViewMBean> getConnectors() throws Exception;
143143

144144
/**
145145
* A transport connectors.
@@ -160,16 +160,15 @@ Collection<DurableSubscriptionViewMBean> getInactiveDurableTopicSubscribers()
160160
Collection<ConnectionViewMBean> getConnections() throws Exception;
161161

162162
/**
163-
* The names of all connections to a specific transport connectors of the
164-
* broker.
163+
* All connections to a specific transport connectors of the broker.
165164
*
166165
* @see #getConnection(String)
167166
* @param connectorName
168167
* not <code>null</code>
169168
* @return not <code>null</code>
170169
* @throws Exception
171170
*/
172-
Collection<String> getConnections(String connectorName) throws Exception;
171+
Collection<ConnectionViewMBean> getConnections(String connectorName) throws Exception;
173172

174173
/**
175174
* A specific connection to the broker.

activemq-web/src/main/java/org/apache/activemq/web/BrokerFacadeSupport.java

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -169,18 +169,14 @@ public Collection<ConnectionViewMBean> getConnections() throws Exception {
169169

170170
@Override
171171
@SuppressWarnings("unchecked")
172-
public Collection<String> getConnections(String connectorName) throws Exception {
172+
public Collection<ConnectionViewMBean> getConnections(String connectorName) throws Exception {
173173
String brokerName = getBrokerName();
174174
connectorName = JMXSupport.encodeObjectNamePart(connectorName);
175175
ObjectName query = new ObjectName("org.apache.activemq:type=Broker,brokerName=" + brokerName
176176
+ ",connector=clientConnectors,connectorName=" + connectorName + ",connectionViewType=clientId,connectionName=*");
177177
Set<ObjectName> queryResult = queryNames(query, null);
178-
Collection<ConnectionViewMBean> connections = getManagedObjects(queryResult.toArray(new ObjectName[queryResult.size()]),
178+
return getManagedObjects(queryResult.toArray(new ObjectName[queryResult.size()]),
179179
ConnectionViewMBean.class);
180-
Collection<String> result = new ArrayList<String>(queryResult.size());
181-
for (ConnectionViewMBean connection : connections)
182-
result.add(connection.getClientId());
183-
return result;
184180
}
185181

186182
@Override
@@ -200,14 +196,13 @@ public ConnectionViewMBean getConnection(String connectionName) throws Exception
200196

201197
@Override
202198
@SuppressWarnings("unchecked")
203-
public Collection<String> getConnectors() throws Exception {
199+
public Collection<ConnectorViewMBean> getConnectors() throws Exception {
204200
String brokerName = getBrokerName();
205201
ObjectName query = new ObjectName("org.apache.activemq:type=Broker,brokerName=" + brokerName + ",connector=clientConnectors,connectorName=*");
206202
Set<ObjectName> queryResult = queryNames(query, null);
207203
Collection<String> result = new ArrayList<String>(queryResult.size());
208-
for (ObjectName on : queryResult)
209-
result.add(on.getKeyProperty("connectorName"));
210-
return result;
204+
return getManagedObjects(queryResult.toArray(new ObjectName[queryResult.size()]),
205+
ConnectorViewMBean.class);
211206
}
212207

213208
@Override

0 commit comments

Comments
 (0)