use of org.apache.camel.Consumer in project camel by apache.
the class FtpEndpointURISanitizedTest method testFtpConsumerUriSanitized.
@Test
public void testFtpConsumerUriSanitized() throws Exception {
Endpoint endpoint = context.getEndpoint(getFtpUrl());
Consumer consumer = endpoint.createConsumer(null);
assertFalse(consumer.toString().contains(password));
}
use of org.apache.camel.Consumer in project camel by apache.
the class RestApiEndpoint method createConsumer.
@Override
public Consumer createConsumer(Processor processor) throws Exception {
RestApiConsumerFactory factory = null;
String cname = null;
// the API then uses the api component (eg usually camel-swagger-java) to build the API
if (getComponentName() != null) {
Object comp = getCamelContext().getRegistry().lookupByName(getComponentName());
if (comp != null && comp instanceof RestApiConsumerFactory) {
factory = (RestApiConsumerFactory) comp;
} else {
comp = getCamelContext().getComponent(getComponentName());
if (comp != null && comp instanceof RestApiConsumerFactory) {
factory = (RestApiConsumerFactory) comp;
}
}
if (factory == null) {
if (comp != null) {
throw new IllegalArgumentException("Component " + getComponentName() + " is not a RestApiConsumerFactory");
} else {
throw new NoSuchBeanException(getComponentName(), RestApiConsumerFactory.class.getName());
}
}
cname = getComponentName();
}
// try all components
if (factory == null) {
for (String name : getCamelContext().getComponentNames()) {
Component comp = getCamelContext().getComponent(name);
if (comp != null && comp instanceof RestApiConsumerFactory) {
factory = (RestApiConsumerFactory) comp;
cname = name;
break;
}
}
}
// lookup in registry
if (factory == null) {
Set<RestApiConsumerFactory> factories = getCamelContext().getRegistry().findByType(RestApiConsumerFactory.class);
if (factories != null && factories.size() == 1) {
factory = factories.iterator().next();
}
}
if (factory != null) {
// calculate the url to the rest API service
RestConfiguration config = getCamelContext().getRestConfiguration(cname, true);
// calculate the url to the rest API service
String path = getPath();
if (path != null && !path.startsWith("/")) {
path = "/" + path;
}
Consumer consumer = factory.createApiConsumer(getCamelContext(), processor, path, config, getParameters());
configureConsumer(consumer);
return consumer;
} else {
throw new IllegalStateException("Cannot find RestApiConsumerFactory in Registry or as a Component to use");
}
}
use of org.apache.camel.Consumer in project camel by apache.
the class BrowseEndpoint method createConsumer.
public Consumer createConsumer(Processor processor) throws Exception {
Consumer answer = new LoadBalancerConsumer(this, processor, loadBalancer);
configureConsumer(answer);
return answer;
}
use of org.apache.camel.Consumer in project camel by apache.
the class DataSetEndpoint method createConsumer.
@Override
public Consumer createConsumer(Processor processor) throws Exception {
Consumer answer = new DataSetConsumer(this, processor);
configureConsumer(answer);
return answer;
}
use of org.apache.camel.Consumer in project camel by apache.
the class DirectVmEndpoint method createConsumer.
@Override
public Consumer createConsumer(Processor processor) throws Exception {
Consumer answer = new DirectVmConsumer(this, new DirectVmProcessor(processor, this));
configureConsumer(answer);
return answer;
}
Aggregations