endpoint = CamelContextHelper.getMandatoryEndpoint(camelCtx, endpointUri);
/** * Returns the to endpoint, lazily resolving it if need be */ protected Endpoint getToEndpoint(CamelContext camelContext) { if (toEndpoint == null) { if (to != null) { toEndpoint = CamelContextHelper.getMandatoryEndpoint(camelContext, to); } } return toEndpoint; }
public void afterPropertiesSet() throws Exception { // lets bind the URI to a pojo notNull(uri, "uri"); // Always resolve the camel context by using the camelContextID if (ObjectHelper.isNotEmpty(camelContextId)) { camelContext = CamelContextResolverHelper.getCamelContextWithId(applicationContext, camelContextId); } notNull(camelContext, "camelContext"); if (serviceRef != null && getService() == null && applicationContext != null) { setService(applicationContext.getBean(serviceRef)); } Endpoint endpoint = CamelContextHelper.getMandatoryEndpoint(camelContext, uri); notNull(getService(), "service"); Object proxy = getProxyForService(); try { // need to start endpoint before we create consumer ServiceHelper.startService(endpoint); consumer = endpoint.createConsumer(new BeanProcessor(proxy, camelContext)); // add and start consumer camelContext.addService(consumer, true, true); } catch (Exception e) { throw new FailedToCreateConsumerException(endpoint, e); } }
/** * Creates a new {@link Enricher}. * * @param aggregationStrategy * aggregation strategy to combine input data and additional * data. * @param resourceUri * URI of resource endpoint for obtaining additional data. * @return an enricher. * @throws Exception * if a producer cannot be created for the endpoint represented * by <code>resourceUri</code>. */ public Enricher enricher(AggregationStrategy aggregationStrategy, String resourceUri) throws Exception { Endpoint endpoint = CamelContextHelper.getMandatoryEndpoint(routeBuilder.getContext(), resourceUri); return new Enricher(aggregationStrategy, endpoint.createProducer()); }
/** * Creates a {@link Validation} process object. * * @param validatorUri * URI of the endpoint that validates an exchange. * @return a validation process object. * @throws Exception * if a producer cannot be created for the endpoint represented * by <code>validatorUri</code>. */ public Validation validation(String validatorUri) throws Exception { Endpoint endpoint = CamelContextHelper.getMandatoryEndpoint(routeBuilder.getContext(), validatorUri); return new Validation(endpoint.createProducer()); }
protected Endpoint resolveEndpoint(String targetId) { Endpoint result = getContext().getRegistry().lookup(targetId, Endpoint.class); if (result == null) { result = CamelContextHelper.getMandatoryEndpoint(getContext(), targetId); } return result; }
@Override public T create(CreationalContext<T> creationalContext) { try { CamelContext context = isNotEmpty(exporter.getCamelContextId()) ? getReferenceByName(manager, exporter.getCamelContextId(), CamelContext.class).get() : getReference(manager, CamelContext.class, this.context); Bean<?> bean = manager.resolve(manager.getBeans(exporter.getServiceRef())); if (bean == null) { throw new UnsatisfiedResolutionException("No bean with name [" + exporter.getServiceRef() + "] is deployed!"); } @SuppressWarnings("unchecked") T service = (T) manager.getReference(bean, type, manager.createCreationalContext(bean)); Endpoint endpoint = getMandatoryEndpoint(context, exporter.getUri()); try { // need to start endpoint before we create consumer startService(endpoint); Consumer consumer = endpoint.createConsumer(new BeanProcessor(service, context)); // add and start consumer context.addService(consumer, true, true); } catch (Exception cause) { throw new FailedToCreateConsumerException(endpoint, cause); } return service; } catch (Exception cause) { throw new CreationException("Error while creating instance for " + this, cause); } }
/** * Creates a new {@link Enricher} using an {@link AggregatorAdapter} that * adapts an {@link Aggregator} Spring bean identified by name * <code>aggregatorBeanName</code>. The adapter is configured to obtain * the enrichment data from the resource's response-message's body (i.e. * from the out-message's body of the exchange used to communicate with the * resource). * * @param aggregatorBeanName * name of the {@link Aggregator} bean. * @param resourceUri * URI of resource endpoint for obtaining additional data. * @return an enricher. * @throws Exception * if a producer cannot be created for the endpoint represented * by <code>resourceUri</code>. */ public Enricher enricher(String aggregatorBeanName, String resourceUri) throws Exception { Endpoint endpoint = CamelContextHelper.getMandatoryEndpoint(routeBuilder.getContext(), resourceUri); return new Enricher(aggregationStrategy(aggregatorBeanName).aggregationInput(routeBuilder.body()), endpoint.createProducer()); }