You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@druid.apache.org by GitBox <gi...@apache.org> on 2018/11/16 17:37:02 UTC

[GitHub] QubitPi opened a new issue #6634: Dependency Injection in DruidModule extension

QubitPi opened a new issue #6634: Dependency Injection in DruidModule extension
URL: https://github.com/apache/incubator-druid/issues/6634
 
 
   We are writing a custom registered lookup module. We have an object like this
   
   ```java
   public class Foo {
   
       @Inject // Guice inject
       Foo(@PayPal CreditCardProcessor processor) {
           ...
       }
   }
   ```
   
   We are using binding annotation to bind `CreditCardProcessor` type to `PayPalCreditCardProcessor`. But our `CreditCardProcessor` is created via Jackson binding
   
   ```java
   public class PayPalCreditCardProcessor implements CreditCardProcessor {
   
       @JsonCreator
       PayPalCreditCardProcessor(@JsonProperty("cardNumber") String cardNumber) {
           ...
       }
   }
   ```
   
   How do we make this dependency graph happen?
   
   Looks like for Guice to traverse dependency graph down to `PayPalCreditCardProcessor`, I had to bind it with Guice annotation like this
   
   ```java
       @Inject // Guice inject
       @JsonCreator
       PayPalCreditCardProcessor(@JsonProperty("cardNumber") String cardNumber) {
           ...
       }
   ```
   
   But when I did that, it asked for a instance binding for `cardNumber` which seems to be impossible via Jackson binding. Am I wrong? How do I make dependency injection start with Guice binding and have a terminal injection via Jackson?

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on 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


With regards,
Apache Git Services

---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@druid.apache.org
For additional commands, e-mail: commits-help@druid.apache.org