You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by GitBox <gi...@apache.org> on 2020/04/22 15:58:23 UTC
[GitHub] [camel-k] ctron opened a new issue #1422: @PropertyInject does not work in @BindToRegistry methods
ctron opened a new issue #1422:
URL: https://github.com/apache/camel-k/issues/1422
Having the following code:
~~~java
import org.apache.camel.BindToRegistry;
import org.apache.camel.PropertyInject;
public class MyBuilder extends org.apache.camel.builder.RouteBuilder {
@PropertyInject("foo")
String foo;
@BindToRegistry
public Object someBean() {
System.out.println("someBean: " + foo);
return foo;
}
@Override
public void configure() throws Exception {
System.out.println("configure: " + foo);
}
}
~~~
And running that with:
~~~
kamel run --dev -p foo=bar MyBuilder.java
~~~
Will give you:
~~~
…
[3] someBean: null
[3] configure: bar
…
~~~
I would expect properties to be available already when binding objects.
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [camel-k] davsclaus commented on issue #1422: @PropertyInject does not work in @BindToRegistry methods
Posted by GitBox <gi...@apache.org>.
davsclaus commented on issue #1422:
URL: https://github.com/apache/camel-k/issues/1422#issuecomment-617952519
Ah yeah both examples should ideally work, the latter requires Camel 3.2. But for the 1st we need to ensure that camel-k creates an instance of the `MyBuilder` via Camel's `Injector` that will do the dependency injection, and thus discover the field with the @PropertyInject and so on.
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [camel-k] davsclaus commented on issue #1422: @PropertyInject does not work in @BindToRegistry methods
Posted by GitBox <gi...@apache.org>.
davsclaus commented on issue #1422:
URL: https://github.com/apache/camel-k/issues/1422#issuecomment-617969460
Ah yeah @lburgazzoli its an ordering, bind to registry is taking precedence. But you could argue that field injections should come before?
Its all in this class
https://github.com/apache/camel/blob/master/core/camel-base/src/main/java/org/apache/camel/impl/engine/DefaultCamelBeanPostProcessor.java
I cant remember on top of my head why bind to registry was injected before fields et all.
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [camel-k] lburgazzoli commented on issue #1422: @PropertyInject does not work in @BindToRegistry methods
Posted by GitBox <gi...@apache.org>.
lburgazzoli commented on issue #1422:
URL: https://github.com/apache/camel-k/issues/1422#issuecomment-617972080
definitely not an easy task unless we want to re-implement cdi/spring :)
so I think binding properties using the parameters is a slightly better option to reduce issue due to ordering
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [camel-k] davsclaus commented on issue #1422: @PropertyInject does not work in @BindToRegistry methods
Posted by GitBox <gi...@apache.org>.
davsclaus commented on issue #1422:
URL: https://github.com/apache/camel-k/issues/1422#issuecomment-618246148
Created a ticket
https://issues.apache.org/jira/browse/CAMEL-14955
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [camel-k] davsclaus commented on issue #1422: @PropertyInject does not work in @BindToRegistry methods
Posted by GitBox <gi...@apache.org>.
davsclaus commented on issue #1422:
URL: https://github.com/apache/camel-k/issues/1422#issuecomment-617974332
Yeah surely as that was how BindToRegistry was intended/designed to be liked a spring @Bean that creates an output that are stored in the registry. And as input you have the parameters of the method. So yeah I see your point and think its the correct approach.
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [camel-k] davsclaus commented on issue #1422: @PropertyInject does not work in @BindToRegistry methods
Posted by GitBox <gi...@apache.org>.
davsclaus commented on issue #1422:
URL: https://github.com/apache/camel-k/issues/1422#issuecomment-618252275
Okay fixed/improved this for Camel 3.3, which camel-k will pickup later.
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [camel-k] davsclaus commented on issue #1422: @PropertyInject does not work in @BindToRegistry methods
Posted by GitBox <gi...@apache.org>.
davsclaus commented on issue #1422:
URL: https://github.com/apache/camel-k/issues/1422#issuecomment-618242115
Okay I am working on doing 2 passes where we first do primitive / simple types so we can do the String field injection first, before doing the bean
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [camel-k] lburgazzoli commented on issue #1422: @PropertyInject does not work in @BindToRegistry methods
Posted by GitBox <gi...@apache.org>.
lburgazzoli commented on issue #1422:
URL: https://github.com/apache/camel-k/issues/1422#issuecomment-617959068
I’m trying to look at if it is possible but as the class is compiled at runtime it may be tricky, however the route is subject to the bean post processor so I think it could be an ordering issue
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [camel-k] lburgazzoli commented on issue #1422: @PropertyInject does not work in @BindToRegistry methods
Posted by GitBox <gi...@apache.org>.
lburgazzoli commented on issue #1422:
URL: https://github.com/apache/camel-k/issues/1422#issuecomment-617871836
You probably need to use `@PropertyInject` as:
```java
@BindToRegistry
public Object someBean(@PropertyInject("foo" String foo) ) {
System.out.println("someBean: " + foo);
return foo;
}
```
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org