[ https://issues.apache.org/jira/browse/CAMEL-10394?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15630165#comment-15630165 ]
ASF GitHub Bot commented on CAMEL-10394: ---------------------------------------- GitHub user hqstevenson opened a pull request: https://github.com/apache/camel/pull/1246 CAMEL-10394: Resolve components from Camel Context Check the camel context for a component registered under the given name before creating a service reference. You can merge this pull request into a Git repository by running: $ git pull https://github.com/hqstevenson/camel CAMEL-10394 Alternatively you can review and apply these changes as the patch at: https://github.com/apache/camel/pull/1246.patch To close this pull request, make a commit to your master/trunk branch with (at least) the following in the commit message: This closes #1246 ---- commit 03528e3dd1bfdd9a3ef52003e2fa73301f1a3fbd Author: Quinn Stevenson <qu...@pronoia-solutions.com> Date: 2016-11-02T19:30:20Z CAMEL-10394: Resolve components from Camel Context before creating service reference ---- > BlueprintCamelContext cannot find components created in > RouteBuilder.configure method > ------------------------------------------------------------------------------------- > > Key: CAMEL-10394 > URL: https://issues.apache.org/jira/browse/CAMEL-10394 > Project: Camel > Issue Type: Bug > Components: camel-blueprint > Affects Versions: 2.18.0 > Reporter: Quinn Stevenson > Priority: Minor > > When a simple java RouteBuilder that creates a component and adds it to the > context in the configure method is used in a blueprint, the context cannot > find the component. > Example Builder: > public class TimerRouteBuilder extends RouteBuilder { > @Override > public void configure() throws Exception { > TimerComponent timerComponent = new TimerComponent(); > getContext().addComponent("my-timer", timerComponent); > from( "my-timer://test-timer") > .log("Timer Fired") > .to("mock://result"); > } > } > Example Blueprint: > <?xml version="1.0" encoding="UTF-8"?> > <blueprint xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0" > xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" > xsi:schemaLocation=" > http://www.osgi.org/xmlns/blueprint/v1.0.0 > https://www.osgi.org/xmlns/blueprint/v1.0.0/blueprint.xsd > http://camel.apache.org/schema/blueprint > http://camel.apache.org/schema/blueprint/camel-blueprint.xsd"> > <bean id="timer-route-builder" > class="com.pronoia.camel.builder.TimerRouteBuilder"/> > <camelContext id="blueprint-context" > xmlns="http://camel.apache.org/schema/blueprint"> > <routeBuilder ref="timer-route-builder"/> > </camelContext> > </blueprint> > This test fails: > public class BlueprintTest extends CamelBlueprintTestSupport { > @EndpointInject(uri = "mock://result") > MockEndpoint result; > @Override > protected String getBlueprintDescriptor() { > return "/OSGI-INF/blueprint/blueprint.xml"; > } > @Test > public void testRoute() throws Exception { > result.expectedMessageCount(5); > assertMockEndpointsSatisfied(10, TimeUnit.SECONDS); > } > } > But this test passes > public class CamelTest extends CamelTestSupport { > @EndpointInject(uri = "mock://result") > MockEndpoint result; > @Override > protected RoutesBuilder createRouteBuilder() throws Exception { > return new TimerRouteBuilder(); > } > @Test > public void testRoute() throws Exception { > result.expectedMessageCount(5); > assertMockEndpointsSatisfied(10, TimeUnit.SECONDS); > } > } -- This message was sent by Atlassian JIRA (v6.3.4#6332)