mirror of https://github.com/apache/activemq.git
Allow configuration of the included and exluded destinations in the network connector.
git-svn-id: https://svn.apache.org/repos/asf/incubator/activemq/trunk@379540 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
66dd4364ea
commit
e2b83bd133
|
@ -20,6 +20,9 @@ import javax.jms.JMSException;
|
|||
import javax.jms.Queue;
|
||||
|
||||
/**
|
||||
*
|
||||
* @org.apache.xbean.XBean element="queue" description="An ActiveMQ Queue Destination"
|
||||
*
|
||||
* @openwire:marshaller code="100"
|
||||
* @version $Revision: 1.5 $
|
||||
*/
|
||||
|
|
|
@ -20,6 +20,9 @@ import javax.jms.JMSException;
|
|||
import javax.jms.Topic;
|
||||
|
||||
/**
|
||||
*
|
||||
* @org.apache.xbean.XBean element="topic" description="An ActiveMQ Topic Destination"
|
||||
*
|
||||
* @openwire:marshaller code="101"
|
||||
* @version $Revision: 1.5 $
|
||||
*/
|
||||
|
|
|
@ -20,10 +20,10 @@ import java.io.IOException;
|
|||
import java.net.URI;
|
||||
import java.net.URISyntaxException;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
import org.apache.activemq.Service;
|
||||
import org.apache.activemq.broker.BrokerService;
|
||||
import org.apache.activemq.command.ActiveMQDestination;
|
||||
import org.apache.activemq.command.DiscoveryEvent;
|
||||
import org.apache.activemq.transport.Transport;
|
||||
|
@ -36,6 +36,7 @@ import org.apache.commons.logging.Log;
|
|||
import org.apache.commons.logging.LogFactory;
|
||||
|
||||
import edu.emory.mathcs.backport.java.util.concurrent.ConcurrentHashMap;
|
||||
import edu.emory.mathcs.backport.java.util.concurrent.CopyOnWriteArrayList;
|
||||
|
||||
/**
|
||||
* @org.apache.xbean.XBean
|
||||
|
@ -52,9 +53,9 @@ public class NetworkConnector implements Service, DiscoveryListener {
|
|||
private ConcurrentHashMap bridges = new ConcurrentHashMap();
|
||||
private Set durableDestinations;
|
||||
private boolean failover=true;
|
||||
private ActiveMQDestination[] excludedDestinations;
|
||||
private ActiveMQDestination[] dynamicallyIncludedDestinations;
|
||||
private ActiveMQDestination[] staticallyIncludedDestinations;
|
||||
private List excludedDestinations = new CopyOnWriteArrayList();
|
||||
private List dynamicallyIncludedDestinations = new CopyOnWriteArrayList();
|
||||
private List staticallyIncludedDestinations = new CopyOnWriteArrayList();
|
||||
private boolean dynamicOnly = false;
|
||||
private boolean conduitSubscriptions = true;
|
||||
private boolean decreaseNetworkConsumerPriority;
|
||||
|
@ -239,21 +240,6 @@ public class NetworkConnector implements Service, DiscoveryListener {
|
|||
}
|
||||
|
||||
|
||||
/**
|
||||
* @return Returns the dynamicallyIncludedDestinations.
|
||||
*/
|
||||
public ActiveMQDestination[] getDynamicallyIncludedDestinations(){
|
||||
return dynamicallyIncludedDestinations;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param dynamicallyIncludedDestinations The dynamicallyIncludedDestinations to set.
|
||||
*/
|
||||
public void setDynamicallyIncludedDestinations(ActiveMQDestination[] dynamicallyIncludedDestinations){
|
||||
this.dynamicallyIncludedDestinations=dynamicallyIncludedDestinations;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @return Returns the dynamicOnly.
|
||||
|
@ -317,35 +303,52 @@ public class NetworkConnector implements Service, DiscoveryListener {
|
|||
/**
|
||||
* @return Returns the excludedDestinations.
|
||||
*/
|
||||
public ActiveMQDestination[] getExcludedDestinations(){
|
||||
public List getExcludedDestinations(){
|
||||
return excludedDestinations;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param excludedDestinations The excludedDestinations to set.
|
||||
*/
|
||||
public void setExcludedDestinations(ActiveMQDestination[] exludedDestinations){
|
||||
public void setExcludedDestinations(List exludedDestinations){
|
||||
this.excludedDestinations=exludedDestinations;
|
||||
}
|
||||
public void addExcludedDestination(ActiveMQDestination destiantion) {
|
||||
this.excludedDestinations.add(destiantion);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @return Returns the staticallyIncludedDestinations.
|
||||
*/
|
||||
public ActiveMQDestination[] getStaticallyIncludedDestinations(){
|
||||
public List getStaticallyIncludedDestinations(){
|
||||
return staticallyIncludedDestinations;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param staticallyIncludedDestinations The staticallyIncludedDestinations to set.
|
||||
*/
|
||||
public void setStaticallyIncludedDestinations(ActiveMQDestination[] staticallyIncludedDestinations){
|
||||
public void setStaticallyIncludedDestinations(List staticallyIncludedDestinations){
|
||||
this.staticallyIncludedDestinations=staticallyIncludedDestinations;
|
||||
}
|
||||
public void addStaticallyIncludedDestination(ActiveMQDestination destiantion) {
|
||||
this.staticallyIncludedDestinations.add(destiantion);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @return Returns the dynamicallyIncludedDestinations.
|
||||
*/
|
||||
public List getDynamicallyIncludedDestinations(){
|
||||
return dynamicallyIncludedDestinations;
|
||||
}
|
||||
/**
|
||||
* @param dynamicallyIncludedDestinations The dynamicallyIncludedDestinations to set.
|
||||
*/
|
||||
public void setDynamicallyIncludedDestinations(List dynamicallyIncludedDestinations){
|
||||
this.dynamicallyIncludedDestinations = dynamicallyIncludedDestinations;
|
||||
}
|
||||
public void addDynamicallyIncludedDestination(ActiveMQDestination destiantion) {
|
||||
this.dynamicallyIncludedDestinations.add(destiantion);
|
||||
}
|
||||
|
||||
|
||||
// Implementation methods
|
||||
|
@ -391,9 +394,19 @@ public class NetworkConnector implements Service, DiscoveryListener {
|
|||
result.setLocalBrokerName(brokerName);
|
||||
result.setNetworkTTL(getNetworkTTL());
|
||||
result.setDecreaseNetworkConsumerPriority(isDecreaseNetworkConsumerPriority());
|
||||
result.setDynamicallyIncludedDestinations(getDynamicallyIncludedDestinations());
|
||||
result.setExcludedDestinations(getExcludedDestinations());
|
||||
result.setStaticallyIncludedDestinations(getStaticallyIncludedDestinations());
|
||||
|
||||
List destsList = getDynamicallyIncludedDestinations();
|
||||
ActiveMQDestination dests[] = (ActiveMQDestination[]) destsList.toArray(new ActiveMQDestination[destsList.size()]);
|
||||
result.setDynamicallyIncludedDestinations(dests);
|
||||
|
||||
destsList = getExcludedDestinations();
|
||||
dests = (ActiveMQDestination[]) destsList.toArray(new ActiveMQDestination[destsList.size()]);
|
||||
result.setExcludedDestinations(dests);
|
||||
|
||||
destsList = getStaticallyIncludedDestinations();
|
||||
dests = (ActiveMQDestination[]) destsList.toArray(new ActiveMQDestination[destsList.size()]);
|
||||
result.setStaticallyIncludedDestinations(dests);
|
||||
|
||||
if (durableDestinations != null){
|
||||
ActiveMQDestination[] dest = new ActiveMQDestination[durableDestinations.size()];
|
||||
dest = (ActiveMQDestination[]) durableDestinations.toArray(dest);
|
||||
|
|
|
@ -17,12 +17,16 @@
|
|||
package org.apache.activemq.xbean;
|
||||
|
||||
import java.net.URI;
|
||||
import java.util.List;
|
||||
|
||||
import junit.framework.TestCase;
|
||||
|
||||
import org.apache.activemq.broker.BrokerFactory;
|
||||
import org.apache.activemq.broker.BrokerService;
|
||||
import org.apache.activemq.broker.TransportConnector;
|
||||
import org.apache.activemq.command.ActiveMQQueue;
|
||||
import org.apache.activemq.command.ActiveMQTopic;
|
||||
import org.apache.activemq.network.NetworkConnector;
|
||||
|
||||
/**
|
||||
*
|
||||
|
@ -38,6 +42,17 @@ public class ConnectorXBeanConfigTest extends TestCase {
|
|||
|
||||
assertEquals( new URI("tcp://localhost:61636"), connector.getUri() );
|
||||
assertTrue( connector.getTaskRunnerFactory() == brokerService.getTaskRunnerFactory() );
|
||||
|
||||
|
||||
NetworkConnector netConnector = (NetworkConnector) brokerService.getNetworkConnectors().get(0);
|
||||
List excludedDestinations = netConnector.getExcludedDestinations();
|
||||
assertEquals(new ActiveMQQueue("exclude.test.foo"), excludedDestinations.get(0));
|
||||
assertEquals(new ActiveMQTopic("exclude.test.bar"), excludedDestinations.get(1));
|
||||
|
||||
List dynamicallyIncludedDestinations = netConnector.getDynamicallyIncludedDestinations();
|
||||
assertEquals(new ActiveMQQueue("include.test.foo"), dynamicallyIncludedDestinations.get(0));
|
||||
assertEquals(new ActiveMQTopic("include.test.bar"), dynamicallyIncludedDestinations.get(1));
|
||||
|
||||
}
|
||||
|
||||
protected void setUp() throws Exception {
|
||||
|
|
|
@ -25,6 +25,20 @@
|
|||
<transportConnector uri="tcp://localhost:61636" />
|
||||
</transportConnectors>
|
||||
|
||||
<networkConnectors>
|
||||
<networkConnector uri="static://(tcp://localhost:61616)">
|
||||
<excludedDestinations>
|
||||
<queue physicalName="exclude.test.foo"/>
|
||||
<topic physicalName="exclude.test.bar"/>
|
||||
</excludedDestinations>
|
||||
<dynamicallyIncludedDestinations>
|
||||
<queue physicalName="include.test.foo"/>
|
||||
<topic physicalName="include.test.bar"/>
|
||||
</dynamicallyIncludedDestinations>
|
||||
</networkConnector>
|
||||
</networkConnectors>
|
||||
|
||||
|
||||
</broker>
|
||||
|
||||
</beans>
|
||||
|
|
Loading…
Reference in New Issue