Details
-
Improvement
-
Status: Resolved
-
Major
-
Resolution: Fixed
-
None
-
None
-
Unknown
Description
In such a configuration class
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. } }
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
@BindToRegistry
public AmazonS3 myAmazon(ClientConfiguration config)