git-svn-id: https://svn.apache.org/repos/asf/activemq/trunk@582086 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Robert Davies 2007-10-05 06:02:46 +00:00
parent f3d633c2a9
commit e2ef8b8165
3 changed files with 52 additions and 0 deletions

View File

@ -782,6 +782,15 @@ public class BrokerService implements Service {
this.managementContext = managementContext;
}
public NetworkConnector getNetworkConnectorByName(String connectorName) {
for(NetworkConnector connector : networkConnectors) {
if(connector.getName().equals(connectorName)) {
return connector;
}
}
return null;
}
public String[] getNetworkConnectorURIs() {
return networkConnectorURIs;
}
@ -790,6 +799,15 @@ public class BrokerService implements Service {
this.networkConnectorURIs = networkConnectorURIs;
}
public TransportConnector getConnectorByName(String connectorName) {
for(TransportConnector connector : transportConnectors) {
if(connector.getName().equals(connectorName)) {
return connector;
}
}
return null;
}
public String[] getTransportConnectorURIs() {
return transportConnectorURIs;
}

View File

@ -24,12 +24,14 @@ import javax.management.ObjectName;
import org.apache.activemq.broker.Broker;
import org.apache.activemq.broker.BrokerService;
import org.apache.activemq.broker.ConnectionContext;
import org.apache.activemq.broker.TransportConnector;
import org.apache.activemq.broker.region.Subscription;
import org.apache.activemq.command.ActiveMQQueue;
import org.apache.activemq.command.ActiveMQTopic;
import org.apache.activemq.command.ConsumerId;
import org.apache.activemq.command.ConsumerInfo;
import org.apache.activemq.command.RemoveSubscriptionInfo;
import org.apache.activemq.network.NetworkConnector;
//import org.apache.log4j.LogManager;
//import org.apache.log4j.PropertyConfigurator;
@ -156,6 +158,30 @@ public class BrokerView implements BrokerViewMBean {
return broker.getInactiveDurableTopicSubscribers();
}
public String addConnector(String discoveryAddress) throws Exception {
TransportConnector connector = brokerService.addConnector(discoveryAddress);
connector.start();
return connector.getName();
}
public String addNetworkConnector(String discoveryAddress) throws Exception {
NetworkConnector connector = brokerService.addNetworkConnector(discoveryAddress);
connector.start();
return connector.getName();
}
public boolean removeConnector(String connectorName) throws Exception {
TransportConnector connector = brokerService.getConnectorByName(connectorName);
connector.stop();
return brokerService.removeConnector(connector);
}
public boolean removeNetworkConnector(String connectorName) throws Exception {
NetworkConnector connector = brokerService.getNetworkConnectorByName(connectorName);
connector.stop();
return brokerService.removeNetworkConnector(connector);
}
public void addTopic(String name) throws Exception {
broker.addDestination(getConnectionContext(broker.getContextBroker()), new ActiveMQTopic(name));
}

View File

@ -90,6 +90,14 @@ public interface BrokerViewMBean extends Service {
ObjectName[] getTemporaryQueueSubscribers();
String addConnector(String discoveryAddress) throws Exception;
String addNetworkConnector(String discoveryAddress) throws Exception;
boolean removeConnector(String connectorName) throws Exception;
boolean removeNetworkConnector(String connectorName) throws Exception;
/**
* Adds a Topic destination to the broker.
*