Claus Ibsen created CAMEL-13582:
-----------------------------------

             Summary: 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
             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)

Reply via email to