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
96
votes
1 answer

How to use Guice's AssistedInject?

I've read https://github.com/google/guice/wiki/AssistedInject, but it doesn't say how to pass in the values of the AssistedInject arguments. What would the injector.getInstance() call look like?
Noel Yap
  • 18,822
  • 21
  • 92
  • 144
16
votes
3 answers

Play Framework: Dependency Inject Action Builder

since Play Framework 2.4 there is the possibility to use dependency injection (with Guice). Before I used objects (for example AuthenticationService) in my ActionBuilders: object AuthenticatedAction extends ActionBuilder[AuthenticatedRequest] { …
Tim Joseph
  • 847
  • 2
  • 14
  • 28
13
votes
1 answer

Problem with generic return type in guice assisted inject factory

So far, I successfully used google guice 2. While migrating to guice 3.0, I had troubles with assisted inject factories. Assume the following code public interface Currency {} public class SwissFrancs implements Currency {} public interface…
kraftan
  • 6,272
  • 2
  • 22
  • 24
13
votes
1 answer

guice injection in static variable

I Have doubt about guice injection. Is it possible to inject a @named variable value to a static variable? I have tried @Provides @Named("emp.id") public Integer getEmpId() { return 2; } and tried to inject this value to static variable such…
Robin
  • 533
  • 2
  • 5
  • 16
12
votes
1 answer

How to use Guice's Injector?

I'm in process of learning Guice and I don't clearly understand how to use Injector instance. It's better to create Injector instance once on application bootstrap, and make it public singleton? And is it true that we always must use…
WelcomeTo
  • 19,843
  • 53
  • 170
  • 286
10
votes
2 answers

How can I validate a Guice scope's usage in tests?

I have some tests that I would like to have fail if certain Guice scopes are used incorrectly. For example, a @Singleton should not have any @RequestScoped or @TestScoped dependencies (Provider<>s are okay, of course). In production, this is…
Tavian Barnes
  • 12,477
  • 4
  • 45
  • 118
8
votes
2 answers

Integrating Google Guice in AWS Lambda

I'm trying to integrate Google Guice in AWS Lambda but for some reasons, injection is not working well. It give me null whenever i try to call Handler Code: public class FirstLamdba implements RequestHandler{ private…
user1030128
  • 411
  • 9
  • 23
7
votes
2 answers

Guice 3.0 - ArrayIndexOutOfBoundsException on startup?

Why Guice 3.0 throws this exception instead of a formatted message for wrong configurated components (@Inject is missing for example)? Exception in thread "main" com.google.inject.internal.util.$ComputationException:…
Daniel Hári
  • 7,254
  • 5
  • 39
  • 54
4
votes
6 answers

Java Generics : Is any meta information about the generic type preserved at runtime as well?

Background My understanding of Java generics is it being completely a compile time feature (mainly focusing on type safety checks). The type information for any generic class is lost at runtime (type erasure). Still, i see many frameworks seem to…
Harshit
  • 1,174
  • 1
  • 9
  • 24
4
votes
1 answer

Why is a lambda expression breaking guice error handling when i try to start jetty?

I face the following problem where i try to start jetty, i get the following exeption: Execution default-test of goal org.apache.maven.plugins:maven-surefire-plugin:2.17:test failed: There was an error in the forked process [ERROR]…
Charles
  • 570
  • 11
  • 29
4
votes
4 answers

How to unit test Jersey + Guice: ServiceLocator?

By using HK2's guice-bridge I managed to integrate Jersey 2.x with Guice 3.x. public class MyApp extends ResourceConfig { @Inject public MyApp(ServiceLocator serviceLocator) { packages("com.mycompany"); ... …
stephanos
  • 3,319
  • 7
  • 33
  • 47
4
votes
2 answers

Difference between @Inject and @AssistedInjected?

The page regarding assisted injection explains how assisted injection can be done by annotating some parameters in the constructor with @Assisted but it does not explain what the @AssistedInject annotation is for and how it differs from @Inject. Is…
rgrinberg
  • 9,638
  • 7
  • 27
  • 44
4
votes
1 answer

Custom dynamic error 404 page - guice / tomcat

I'm creating a web application using guice 3.0 on a tomcat 7 server. I managed to use a static file to customize my error 404 page but now I need to customize the error 404 page using a servlet. So, in my web.xml I add those lines:
Manu
  • 493
  • 6
  • 17
3
votes
1 answer

Guice bound provider not being used for dependency fulfillment

I'm trying to use provider injection to inject a pre-configured object into a factory: public class CacheBuilderProvider implements Provider> { public CacheBuilder get () { //Log the…
Matt Mills
  • 8,692
  • 6
  • 40
  • 64
3
votes
1 answer

Guice bind().toInstance() injects already injected members?

I have multiple injectors in a multi module project, and want to pass an already injected instance from module A to another Guice module B: //module B bind(DeleteEmployeeUseCaseFactory.class).toInstance(useCaseFactories); //usecaseFactories…
Daniel Hári
  • 7,254
  • 5
  • 39
  • 54
1
2 3 4 5 6 7