This commit is contained in:
gtully 2014-08-08 14:09:17 +01:00
parent ec2a3c750b
commit 7c2735d0f4
3 changed files with 33 additions and 3 deletions

View File

@ -2493,7 +2493,6 @@ public class BrokerService implements Service {
List<TransportConnector> al = new ArrayList<TransportConnector>();
for (Iterator<TransportConnector> iter = getTransportConnectors().iterator(); iter.hasNext();) {
TransportConnector connector = iter.next();
connector.setBrokerService(this);
al.add(startTransportConnector(connector));
}
if (al.size() > 0) {
@ -2570,7 +2569,8 @@ public class BrokerService implements Service {
}
}
protected TransportConnector startTransportConnector(TransportConnector connector) throws Exception {
public TransportConnector startTransportConnector(TransportConnector connector) throws Exception {
connector.setBrokerService(this);
connector.setTaskRunnerFactory(getTaskRunnerFactory());
MessageAuthorizationPolicy policy = getMessageAuthorizationPolicy();
if (policy != null) {

View File

@ -355,7 +355,7 @@ public class BrokerView implements BrokerViewMBean {
if (connector == null) {
throw new NoSuchElementException("Not connector matched the given name: " + discoveryAddress);
}
connector.start();
brokerService.startTransportConnector(connector);
return connector.getName();
}

View File

@ -1362,6 +1362,36 @@ public class MBeanTest extends EmbeddedBrokerTestSupport {
session.close();
}
public void testAddRemoveConnectorBrokerView() throws Exception {
ObjectName brokerName = assertRegisteredObjectName(domain + ":type=Broker,brokerName=localhost");
BrokerViewMBean brokerView = MBeanServerInvocationHandler.newProxyInstance(mbeanServer, brokerName, BrokerViewMBean.class, true);
Map connectors = brokerView.getTransportConnectors();
LOG.info("Connectors: " + connectors);
assertEquals("one connector", 1, connectors.size());
ConnectorViewMBean connector = getProxyToConnectionView("tcp");
assertNotNull(connector);
String name = connectors.keySet().iterator().next().toString();
brokerView.removeConnector(name);
connectors = brokerView.getTransportConnectors();
assertEquals("empty", 0, connectors.size());
name = brokerView.addConnector("tcp://0.0.0.0:0");
connector = getProxyToConnectionView("tcp");
assertNotNull(connector);
connectors = brokerView.getTransportConnectors();
LOG.info("Connectors: " + connectors);
assertEquals("one connector", 1, connectors.size());
assertTrue("name is in map: " + connectors.keySet(), connectors.keySet().contains(name));
}
public void testConnectorView() throws Exception {
ConnectorViewMBean connector = getProxyToConnectionView("tcp");
assertNotNull(connector);