use of org.apache.camel.Endpoint in project camel by apache.
the class AbstractHttpSpanDecoratorTest method testGetHttpURLFromEndpointUriWithAdditionalScheme.
@Test
public void testGetHttpURLFromEndpointUriWithAdditionalScheme() {
Endpoint endpoint = Mockito.mock(Endpoint.class);
Exchange exchange = Mockito.mock(Exchange.class);
Message message = Mockito.mock(Message.class);
Mockito.when(endpoint.getEndpointUri()).thenReturn("netty-http:" + TEST_URI);
Mockito.when(exchange.getIn()).thenReturn(message);
AbstractHttpSpanDecorator decorator = new AbstractHttpSpanDecorator() {
@Override
public String getComponent() {
return null;
}
};
assertEquals(TEST_URI, decorator.getHttpURL(exchange, endpoint));
}
use of org.apache.camel.Endpoint in project camel by apache.
the class AbstractMessagingSpanDecoratorTest method testOperationName.
@Test
public void testOperationName() {
Endpoint endpoint = Mockito.mock(Endpoint.class);
Mockito.when(endpoint.getEndpointUri()).thenReturn("jms://MyQueue?hello=world");
SpanDecorator decorator = new AbstractMessagingSpanDecorator() {
@Override
public String getComponent() {
return null;
}
};
assertEquals("MyQueue", decorator.getOperationName(null, endpoint));
}
use of org.apache.camel.Endpoint in project camel by apache.
the class AbstractMessagingSpanDecoratorTest method testPreMessageBusDestination.
@Test
public void testPreMessageBusDestination() {
Endpoint endpoint = Mockito.mock(Endpoint.class);
Mockito.when(endpoint.getEndpointUri()).thenReturn("jms://MyQueue?hello=world");
SpanDecorator decorator = new AbstractMessagingSpanDecorator() {
@Override
public String getComponent() {
return null;
}
};
MockTracer tracer = new MockTracer();
MockSpan span = (MockSpan) tracer.buildSpan("TestSpan").start();
decorator.pre(span, null, endpoint);
assertEquals("MyQueue", span.tags().get(Tags.MESSAGE_BUS_DESTINATION.getKey()));
}
use of org.apache.camel.Endpoint in project camel by apache.
the class CamelJob method lookupQuartzEndpoint.
private QuartzEndpoint lookupQuartzEndpoint(CamelContext camelContext, String endpointUri, Trigger trigger) throws JobExecutionException {
String targetTriggerName = trigger.getName();
String targetTriggerGroup = trigger.getGroup();
LOG.debug("Looking up existing QuartzEndpoint with trigger {}.{}", targetTriggerName, targetTriggerGroup);
try {
// as we prefer to use the existing endpoint from the routes
for (Route route : camelContext.getRoutes()) {
Endpoint endpoint = route.getEndpoint();
if (endpoint instanceof DelegateEndpoint) {
endpoint = ((DelegateEndpoint) endpoint).getEndpoint();
}
if (endpoint instanceof QuartzEndpoint) {
QuartzEndpoint quartzEndpoint = (QuartzEndpoint) endpoint;
String triggerName = quartzEndpoint.getTrigger().getName();
String triggerGroup = quartzEndpoint.getTrigger().getGroup();
LOG.trace("Checking route trigger {}.{}", triggerName, triggerGroup);
if (triggerName.equals(targetTriggerName) && triggerGroup.equals(targetTriggerGroup)) {
return (QuartzEndpoint) endpoint;
}
}
}
} catch (Exception e) {
throw new JobExecutionException("Error lookup up existing QuartzEndpoint with trigger: " + trigger, e);
}
// fallback and lookup existing from registry (eg maybe a @Consume POJO with a quartz endpoint, and thus not from a route)
if (camelContext.hasEndpoint(endpointUri) != null) {
return camelContext.getEndpoint(endpointUri, QuartzEndpoint.class);
} else {
LOG.warn("Cannot find existing QuartzEndpoint with uri: {}. Creating new endpoint instance.", endpointUri);
return camelContext.getEndpoint(endpointUri, QuartzEndpoint.class);
}
}
use of org.apache.camel.Endpoint in project camel by apache.
the class TradeExecutorComponent method createEndpoint.
@Override
protected Endpoint createEndpoint(String uri, String remaining, Map<String, Object> parameters) throws Exception {
synchronized (endpoints) {
Endpoint endpoint = endpoints.get(uri);
if (endpoint == null) {
endpoint = new TradeExecutorEndpoint(uri, new TradeExecutor());
endpoints.put(uri, (TradeExecutorEndpoint) endpoint);
LOG.info("Created trade executor: " + uri);
}
return endpoint;
}
}
Aggregations