public Endpoint resolveEndpoint(String uri, String ref) { Endpoint endpoint = null; if (uri != null) { endpoint = resolveEndpoint(uri); if (endpoint == null) { throw new NoSuchEndpointException(uri); } } if (ref != null) { endpoint = lookup(ref, Endpoint.class); if (endpoint == null) { throw new NoSuchEndpointException("ref:" + ref, "check your camel registry with id " + ref); } // Check the endpoint has the right CamelContext if (!this.getCamelContext().equals(endpoint.getCamelContext())) { throw new NoSuchEndpointException( "ref:" + ref, "make sure the endpoint has the same camel context as the route does."); } try { // need add the endpoint into service getCamelContext().addService(endpoint); } catch (Exception ex) { throw new RuntimeCamelException(ex); } } if (endpoint == null) { throw new IllegalArgumentException("Either 'uri' or 'ref' must be specified on: " + this); } else { return endpoint; } }
public DefaultExchange(Endpoint fromEndpoint, ExchangePattern pattern) { this(fromEndpoint.getCamelContext(), pattern); this.fromEndpoint = fromEndpoint; }