Questions tagged [guice-3]

Google Guice 3.0 Release

Guice 3 is version of Google Guice. Link to guice tag.

New Features are supported in Guice release 3.

  • JSR 330 Support
  • New Persist Extension
  • ToConstructor Bindings

and many such more features are introduced.

Reference

103 questions
2
votes
1 answer

Guice, Injecting TypeLiteral when using @AssistedInject

This works: public static class SomeGenericType { private TypeLiteral type; @Inject public SomeGenericType(TypeLiteral type) { this.type = type; } public Class getType() { return…
aidanok
  • 859
  • 1
  • 7
  • 11
1
vote
1 answer

Module Initialization And Destruction handlers in Guice?

The following link describes how to handle module initialization and destruction in Guice using a Service interface with a start() and stop() method: https://github.com/google/guice/wiki/ModulesShouldBeFastAndSideEffectFree The documentation…
Basil Musa
  • 8,198
  • 6
  • 64
  • 63
1
vote
1 answer

Passing variable parameters to Guice @Provides method

I have a Guice module that has a @Provides method that takes 2 parameters and returns one of the two implementations of an interface public class ClientModule extends AbstractModule{ @Override protected void configure(){ } …
1
vote
1 answer

Binding a guava supplier using guice

I want do a binding like this, bind(Supplier).toProvider(Provider>).in(Singleton.class); The provider is returned by an external function so, inside the toProvider(), I call that function and it returns…
1
vote
1 answer

How to get Guice injector for a class with parameterised constructor

I have following class and test code write now and it is working fine. public class AppleRegistry { private final ImmutableMap appRegistry; AppleRegistry(Apple... apple) { this.appRegistry = createRegistry(apple); } …
Tushar
  • 129
  • 1
  • 2
  • 10
1
vote
1 answer

How to inject a list with different implementations of the same interface in a nested module scenario via Guice?

There is an interface DCE, which is implemented by a class DCEImpl which has a dependency, say, string S, which it gets via its constructor. The universe of S is limited, say S can only take values {'A','B','C'}. There is an already existing Guice…
1
vote
1 answer

Is there any annotation equivalent for Guice's bindEagerSingleton()?

I did something like this bindEagerSingleton(MyClass.class); Can I do something like this @SomeAnnotation public class MyClass {} Thank you!
ddreian
  • 1,766
  • 5
  • 21
  • 29
1
vote
0 answers

Error in Extending the GuiceApplicationLoader : No implementation for play.Application was bound. while locating play.Application

I am trying to Extend the GuiceApplicationLoader in play java project as shown here in official play documentation. (https://www.playframework.com/documentation/2.6.x/JavaDependencyInjection) I am getting below error: play.api.UnexpectedException:…
Bharat
  • 311
  • 3
  • 11
1
vote
0 answers

Continuation of request scope after request has been completed

I am having trouble finding a definitive approach to achieving the following objective. We have a nice implementation for request scoped operation invocation from client. These operations are expected to be fast and nimble i.e. <10 ms and any heavy…
Gautam
  • 1,030
  • 13
  • 37
1
vote
1 answer

ExceptionHandler equivalent in Guice

I'm having Controller which can throw my Custom Exception. public Response fetch(final String id) throws MyException { return Response.ok().entity(custonService.fetch(id)).build(); } I want to handle that exception and set response status as…
Krishna
  • 1,865
  • 4
  • 18
  • 26
1
vote
0 answers

Guice Novice Error in Using AemLogin of Bobcat through my Java main

I am new to Bobcat(automated framework for AEM).I am trying to write a sample Java class that could use the AemLogin API through a inject.But I am getting errors. I am unable to clearly understand how to use the Module to bind since there is only…
1
vote
3 answers

How can i combine Guice and Mapstruct?

I'm using jersey and Guice DI and I want to use Mapstruct interfaces with @Inject annotation. So is there some way to force Guice to autowire Mapstruct interface implementations ?
Taras K
  • 85
  • 2
  • 9
1
vote
2 answers

Guice @annotations approach similar to Guice MapBinder approach

I am new to Guice DI. And I would like to get my scenario clarified. To put it simple, Is there any replacement of MapBinder through Guice @annotations? My Scenario: Interface A{} Class A1 implements A{} Class A2 implements A{} I would like to…
Viswa
  • 1,357
  • 3
  • 18
  • 30
1
vote
0 answers

Is there any way to seed custom binding to already created injector in Guice?

I have created Injector instance using Guice.create(modules). After creating an injector I want to add some bindings dynamically, so is it possible?
vsbehere
  • 666
  • 1
  • 7
  • 23
1
vote
1 answer

In Guice, How to create a Map Binder singleton binding which has a different scope dependency?

The following map binder binding gives me a com.google.inject.OutOfScopeException: Not in MyScope: mapbinder.addBinding("ferrari").to(Ferrari.class).in(Singleton.class); I am guessing this is probably because the constructor of Ferrari has…
Crusaderpyro
  • 2,163
  • 5
  • 29
  • 53