You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@camel.apache.org by "Claus Ibsen (JIRA)" <ji...@apache.org> on 2019/05/27 10:53:00 UTC
[jira] [Resolved] (CAMEL-13582) Camel main - Configuration class
should support automatic autowire by type
[ https://issues.apache.org/jira/browse/CAMEL-13582?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Claus Ibsen resolved CAMEL-13582.
---------------------------------
Resolution: Fixed
> Camel main - Configuration class should support automatic autowire by type
> --------------------------------------------------------------------------
>
> Key: CAMEL-13582
> URL: https://issues.apache.org/jira/browse/CAMEL-13582
> Project: Camel
> Issue Type: Improvement
> Components: camel-core
> Reporter: Claus Ibsen
> Assignee: Claus Ibsen
> Priority: Major
> Fix For: 3.0.0, 3.0.0-M3
>
>
> In such a configuration class
> {code}
> public class MyConfiguration {
> @BindToRegistry
> public ClientConfiguration myClientConfig() {
> ClientConfiguration cc = new ClientConfiguration();
> cc.setMaxConnections(5);
> return cc;
> }
> @BindToRegistry
> public MyBean myBean(@PropertyInject("hi") String hi, @PropertyInject("bye") String bye) {
> // this will create an instance of this bean with the name of the method (eg myBean)
> return new MyBean(hi, bye);
> }
> @BindToRegistry
> public AmazonS3 myAmazon(@BeanInject("myClientConfig") ClientConfiguration config) {
> return AmazonS3Client.builder().withRegion("US-EAST-1").withClientConfiguration(config).build();
> }
> public void configure() {
> // this method is optional and can be removed if no additional configuration is needed.
> }
> }
> {code}
> We could detect that the myAmazon method has a parameter of type ClientConfiguration which we can attempt to lookup as singleton bean. Then you can do
> {code}
> @BindToRegistry
> public AmazonS3 myAmazon(ClientConfiguration config)
> {code}
--
This message was sent by Atlassian JIRA
(v7.6.3#76005)