You'd need to use QueueServiceModule when you create an injector, too. The @Provides method will give you the binding you need.
On Tue, Oct 25, 2011 at 11:42 AM, sbutalia <[email protected]> wrote: > Hello, > > Coming into this question as a beginner so apologies if this is a > trivial.. > > I have the following services.. > > @Inject > public AmazonQueueService(AmazonSQSClient sqs, Logger logger){ > this.sqs = sqs; > this.logger = logger; > } > @Inject > public ViDepositService(Logger logger, AmazonQueueService asqs){ > this.logger = logger; > this.asqs = asqs; > } > > Following Guice Module Configurations... > public class QueueServiceModule extends AbstractModule{ > protected void configure() { > > bind(QueueServiceInterface.class).to(AmazonQueueService.class); > } > > @Provides > AmazonSQSClient provideAmazonSQSClient() { //Returns an instance of > AmazonSQSClient by picking up the credentials from a local > resource.. } > > > > public class DepositModule extends AbstractModule{ > @Override > protected void configure() { > > bind(DepositServiceInterface.class).to(ViDepositService.class); > > > I'm set up a test.. > Injector injector = Guice.createInjector(new > DepositModule()); > ViDepositService vds = > injector.getInstance(ViDepositService.class); > vds.deposit(); > > > Getting this error.. > com.google.inject.CreationException: Guice creation errors: > > 1) Could not find a suitable constructor in > com.amazonaws.services.sqs.AmazonSQSClient. Classes must have either > one (and only one) constructor annotated with @Inject or a zero- > argument constructor that is not private. > at > com.amazonaws.services.sqs.AmazonSQSClient.class(AmazonSQSClient.java: > 99) > while locating com.amazonaws.services.sqs.AmazonSQSClient > > I cannot change the com.amazonaws.services.sqs.AmazonSQSClient class > since its provided by Amazon. Thoughts on how I can get this working? > Do I need another provider in the DepositModule? > > Thanks > > > -- > You received this message because you are subscribed to the Google Groups > "google-guice" group. > To post to this group, send email to [email protected]. > To unsubscribe from this group, send email to > [email protected]. > For more options, visit this group at > http://groups.google.com/group/google-guice?hl=en. > > -- You received this message because you are subscribed to the Google Groups "google-guice" group. To post to this group, send email to [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/google-guice?hl=en.
