[ 
https://issues.apache.org/jira/browse/CAMEL-11097?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15949321#comment-15949321
 ] 

Bernard Ligny edited comment on CAMEL-11097 at 3/30/17 7:12 PM:
----------------------------------------------------------------

Use case: Camel CDI with *multiple* contexts

{code:java}

public class ContextFactory {
                
   @Produces
   @ApplicationScoped
   @ContextName("ctx-1")
    public CamelContext createCamelContext1() { 
       // ...
    }
        
    @Produces
    @ApplicationScoped
    @ContextName("ctx-2")
    public CamelContext createCamelContext2() { 
       // ...
    }   
    
---

@ContextName("ctx-2")
public class MyRouteBuilder extends RouteBuilder {
        
        @PropertyInject(context="ctx-2", value="...")  // <= why having to set 
"context" (again) ?
        private String myProperty; 
}
{code} 

It would be nice to have a "smart" resolution in case no context is specified, 
even if there is more than one camel context producer.
Ambiguity could be solved with a default resolution : using the same context as 
the "outer" bean (eg the RouteBuilder in my example)..




was (Author: bligny):
Use case: Camel CDI with *multiple* contexts

{code:java}

public class ContextFactory {
                
   @Produces
   @ApplicationScoped
   @ContextName("ctx-1")
    public CamelContext createCamelContext1() { 
       // ...
    }
        
    @Produces
    @ApplicationScoped
    @ContextName("ctx-2")
    public CamelContext createCamelContext2() { 
       // ...
    }   
    
---

@ContextName("ctx-2")
public class MyRouteBuilder extends RouteBuilder {
        
        @PropertyInject(context="ctx-2", value="...")  // <= why having to set 
"context" (again) ?
        private String myProperty; 
}
{code} 

Would be nice to have a "smart" resolution in case no context is specified even 
there is more than one camel context.
Ambiguity can be resolved by using the same context of the "outer" bean (eg the 
RouteBuilder in my case)..



> Injection of CamelContext inside a CamelContextAware bean
> ---------------------------------------------------------
>
>                 Key: CAMEL-11097
>                 URL: https://issues.apache.org/jira/browse/CAMEL-11097
>             Project: Camel
>          Issue Type: Improvement
>          Components: camel-cdi
>    Affects Versions: 2.18.3
>            Reporter: Bernard Ligny
>            Priority: Minor
>
> See this thread on Camel Users forum:
> http://camel.465427.n5.nabble.com/Why-do-we-have-to-specify-a-context-for-PropertyInject-td5796699.html



--
This message was sent by Atlassian JIRA
(v6.3.15#6346)

Reply via email to