[AMQ-7060] Remove deprecated features from camel ActiveMQComponent

This commit is contained in:
Guillaume Nodet 2018-09-22 17:58:40 +02:00
parent cdbddcafa2
commit 8cbc2080a7
2 changed files with 6 additions and 71 deletions

View File

@ -17,18 +17,17 @@
package org.apache.activemq.camel.component; package org.apache.activemq.camel.component;
import java.net.URISyntaxException; import java.net.URISyntaxException;
import java.util.*; import java.util.Map;
import java.util.concurrent.CopyOnWriteArrayList; import java.util.concurrent.CopyOnWriteArrayList;
import javax.jms.Connection;
import org.apache.activemq.EnhancedConnection; import org.apache.activemq.EnhancedConnection;
import org.apache.activemq.Service; import org.apache.activemq.Service;
import org.apache.activemq.advisory.DestinationSource; import org.apache.activemq.advisory.DestinationSource;
import org.apache.activemq.command.ActiveMQDestination;
import org.apache.camel.CamelContext; import org.apache.camel.CamelContext;
import org.apache.camel.ComponentConfiguration;
import org.apache.camel.component.jms.JmsComponent; import org.apache.camel.component.jms.JmsComponent;
import org.apache.camel.component.jms.JmsConfiguration; import org.apache.camel.component.jms.JmsConfiguration;
import org.apache.camel.spi.EndpointCompleter;
import org.apache.camel.util.IntrospectionSupport; import org.apache.camel.util.IntrospectionSupport;
import org.apache.camel.util.ObjectHelper; import org.apache.camel.util.ObjectHelper;
import org.apache.camel.util.URISupport; import org.apache.camel.util.URISupport;
@ -37,23 +36,20 @@ import org.slf4j.LoggerFactory;
import org.springframework.jms.connection.SingleConnectionFactory; import org.springframework.jms.connection.SingleConnectionFactory;
import org.springframework.jms.core.JmsTemplate; import org.springframework.jms.core.JmsTemplate;
import javax.jms.Connection;
/** /**
* The <a href="http://activemq.apache.org/camel/activemq.html">ActiveMQ Component</a> * The <a href="http://activemq.apache.org/camel/activemq.html">ActiveMQ Component</a>
*/ */
public class ActiveMQComponent extends JmsComponent implements EndpointCompleter { public class ActiveMQComponent extends JmsComponent {
private final CopyOnWriteArrayList<SingleConnectionFactory> singleConnectionFactoryList = private final CopyOnWriteArrayList<SingleConnectionFactory> singleConnectionFactoryList =
new CopyOnWriteArrayList<SingleConnectionFactory>(); new CopyOnWriteArrayList<SingleConnectionFactory>();
private final CopyOnWriteArrayList<Service> pooledConnectionFactoryServiceList = private final CopyOnWriteArrayList<Service> pooledConnectionFactoryServiceList =
new CopyOnWriteArrayList<Service>(); new CopyOnWriteArrayList<Service>();
private static final transient Logger LOG = LoggerFactory.getLogger(ActiveMQComponent.class); private static final transient Logger LOG = LoggerFactory.getLogger(ActiveMQComponent.class);
private boolean exposeAllQueues; private boolean exposeAllQueues;
private CamelEndpointLoader endpointLoader; private CamelEndpointLoader endpointLoader;
private EnhancedConnection connection; private EnhancedConnection connection;
DestinationSource source; DestinationSource source;
boolean sourceInitialized = false;
/** /**
* Creates an <a href="http://camel.apache.org/activemq.html">ActiveMQ Component</a> * Creates an <a href="http://camel.apache.org/activemq.html">ActiveMQ Component</a>
@ -103,14 +99,6 @@ public class ActiveMQComponent extends JmsComponent implements EndpointCompleter
} }
} }
/**
* @deprecated - use JmsComponent#setUsername(String)
* @see JmsComponent#setUsername(String)
*/
public void setUserName(String userName) {
setUsername(userName);
}
public void setTrustAllPackages(boolean trustAllPackages) { public void setTrustAllPackages(boolean trustAllPackages) {
if (getConfiguration() instanceof ActiveMQConfiguration) { if (getConfiguration() instanceof ActiveMQConfiguration) {
((ActiveMQConfiguration)getConfiguration()).setTrustAllPackages(trustAllPackages); ((ActiveMQConfiguration)getConfiguration()).setTrustAllPackages(trustAllPackages);
@ -258,34 +246,4 @@ public class ActiveMQComponent extends JmsComponent implements EndpointCompleter
return answer; return answer;
} }
@Override
public List<String> completeEndpointPath(ComponentConfiguration componentConfiguration, String completionText) {
// try to initialize destination source only the first time
if (!sourceInitialized) {
createDestinationSource();
sourceInitialized = true;
}
ArrayList<String> answer = new ArrayList<String>();
if (source != null) {
Set candidates = source.getQueues();
String destinationName = completionText;
if (completionText.startsWith("topic:")) {
candidates = source.getTopics();
destinationName = completionText.substring(6);
} else if (completionText.startsWith("queue:")) {
destinationName = completionText.substring(6);
}
Iterator it = candidates.iterator();
while (it.hasNext()) {
ActiveMQDestination destination = (ActiveMQDestination) it.next();
if (destination.getPhysicalName().startsWith(destinationName)) {
answer.add(destination.getPhysicalName());
}
}
}
return answer;
}
} }

View File

@ -66,29 +66,6 @@ public class AutoExposeQueuesInCamelTest extends EmbeddedBrokerTestSupport {
assertEquals("Should have found an endpoint: "+ endpoints, 2, endpoints.size()); assertEquals("Should have found an endpoint: "+ endpoints, 2, endpoints.size());
} }
public void testCompleter() throws Exception {
Thread.sleep(1000);
List<String> result = component.completeEndpointPath(null, "foo");
assertThat(result, is(Arrays.asList("foo.bar")));
result = component.completeEndpointPath(null, "queue:foo");
assertThat(result, is(Arrays.asList("foo.bar")));
result = component.completeEndpointPath(null, "topic:ch");
assertThat(result, is(Arrays.asList("cheese")));
result = component.completeEndpointPath(null, "ch");
assertTrue(result.isEmpty());
result = component.completeEndpointPath(null, "queue:ch");
assertTrue(result.isEmpty());
result = component.completeEndpointPath(null, "topic:foo");
assertTrue(result.isEmpty());
broker.getAdminView().addQueue("runtime");
Thread.sleep(1000);
result = component.completeEndpointPath(null, "run");
assertThat(result, is(Arrays.asList("runtime")));
}
public <T> List<T> getEndpoints(CamelContext camelContext, Class<T> type) { public <T> List<T> getEndpoints(CamelContext camelContext, Class<T> type) {
List<T> answer = new ArrayList<T>(); List<T> answer = new ArrayList<T>();
Collection<Endpoint> endpoints = camelContext.getEndpoints(); Collection<Endpoint> endpoints = camelContext.getEndpoints();