guice

Guice child injector override binding

Hi All I am trying to to override a binding in a child injector that was already configured in a base injector. like that : public class PersistenceModule extends Abstract{ @Override protected void configure() { bind(IProductPersistenceHelper.class).to(ProductPersistenceHelper.class); } } then : Injector inje...

Using GWT RPC from a GWTTestCase using Guice

I've configured my GWT app with Guice as documented here. With this setup the app works fine. However what I'd like to do now is get a GWTTestCase to call a service using GWT RPC. To this end I've done this, Updated my <app>JUnit.gwt.rpc so that the service URL maps to GuiceRemoteServiceServlet Added an init() method to GuiceRemoteSer...

How do I subtract a binding using a Guice module override?

So according to my testing, If you have something like: Module modA = new AbstractModule() { public void configure() { bind(A.class).to(AImpl.class); bind(C.class).to(ACImpl.class); bind(E.class).to(EImpl.class); } } Module modB = New AbstractModule() { public void configure() { bind(A.class)...

How to @Inject into existing object hierarchy using Guice?

I have an existing object hierarchy where some objects have fields that need to be injected. Also there are some other objects that are constructed using Google Guice and need to be injected with references to some objects from previously described object hierarchy. How do I do such kind of injection with Guice? The problem is that obje...

Google Guice on Google Appengine: mapping with working _ah

I have a Google Appengine/Guice/Wicket Application. My problem is that due to the mapping I can't access the /_ah/admin Page anymore. My Servlet Module says: serve( "/*" ).with( WicketServlet.class, getWicketServletParams() ); so far it is more or less expected that accessing /_ah/admin gives a 404. I problem is that I don't find a ...

How to test Guice Singleton?

Guice Singletons are weird for me First I thought that IService ser = Guice.createInjector().getInstance(IService.class); System.out.println("ser=" + ser); ser = Guice.createInjector().getInstance(IService.class); System.out.println("ser=" + ser); will work as singleton, but it returns ser=Service2@1975b59 ser=Service2@1f934ad its...

Hierarchy of modules in guice

Hi, I'd like to run a unit test where a constant is slightly different than in the standard version. That is, in my default module, the following is bindConstant().annotatedWith(Names.named("number of players")).to(4); but in testing, I'd like to try this line instead: bindConstant().annotatedWith(Names.named("number of players"))...

Confused about this factory, as it doesn't look like an Abstract Factory nor Factory Method

I'm looking into Guice and I've been reading its documentation recently. Reading the motivation section I don't understand the factories part, why they name it that way. To me that factory is just a wrapper for the implementing class they want it to return after calling getInstance(). public class CreditCardProcessorFactory { privat...

Guice , afterPropertiesSet

Hi Someone knows some way that how can I achieve the same functionality in Guice as the 'afterPropertiesSet' interface in spring ? ( its a post construction hook ) ...

Auto injecting logger with guice

With reference to Guice's custom injections article, its TypeListener performs a check for InjectLogger.class annotation - which can be optional. Removing that check will inject to all Logger.class types. class Log4JTypeListener implements TypeListener { public <T> void hear(TypeLiteral<T> typeLiteral, TypeEncounter<T> typeEncounter...

Is dependency injection only for service type objects and singletons? (and NOT for gui?)

I'm currently experimenting with the Google's guice inversion of control container. I previously had singletons for just about any service (database, active directory) my application used. Now I refactored the code: all the dependencies are given as parameters to constructors. So far, so good. Now the hardest part is with the graphical u...

How to integrate Guice 2 into Wicket?

I want to use Guice 2 with Wicket 1.4. There is a "wicket-guice" package, which uses Guice 1. Can someone give me an example how to configure Wicket to use Guice 2 for injection (with Maven). As you can see blow, I've found a solution, but I wonder, if it would be better to use Guice Servlets and register the whole Wicket Application as...

JSR-330 support in Guice

The SVN version of Guice supports JSR-330 annotations ("JSR-330 Integration - This documents an experimental, unreleased feature available in Guice SVN only"). Google gives the advise: "For now, stick with Guice's annotations and Provider interface." Guice 2 is a year old now and I wonder if there will be JSR-330 support in the near futu...

Dependency injection: Scoping by region (Guice, Spring, Whatever)

Here's a simplified version of my needs. I have a program where every B object has its own C and D object, injected through Guice. In addition an A object is injected into every C and D objects. What I want: that for each B object, its C and D objects will be injected with the same A object. [Edit-Start] (1) Guice supports "singlet...

Warp Persist alternative

Has anybody run into an alternative to warp-persist? http://code.google.com/p/warp-persist/ It seems like there is no longer development on warp-persist. ...

Is there an equivalent in CDI(WELD) to build definitions (as done in Guice modules) and then create an Injector ?

I like the way Guice makes it fairly straight forward to manually create your own modules each with their own bindings done in code. CDI on the other hand seems to rely more on magic rather than programmatic access to sest bindings. Am i wrong or how can one achieve the same effect with WELD. Any code sample would be appreciated... CLA...

Guice and properties files

Does anybody have an example of how to use Google Guice to inject properties from a .properties file. I was told Guice was able to validate that all needed properties exist when the injector starts up. At this time I cannot find anything on the guice wiki about this. ...

Best approach to mutate(add/remove bindings) a Guice injector while maintaining state.

I am hoping to redefine or update some bindings within a Module which is in turn used by an Injector. I realise that Modules are immutable and once a binding is sucked and injected its definition cannot change for all practical purposes. I would like to add/change/remove bindings while keeping singletons already living in an Injector. ...

Guice Injection Across Modules for Sharing

I have three Modules in Guice: ReflectionsModule, for providing Metadata (via Reflections) PersistenceModule, for Data Access Objects and Others WebModule, for Web Stuff Simply put, both PersistenceModule and WebModule will fetch a object which is made from Reflections Module. I can not find a very friendly way to do this in guice. ...

Logging with Guice

Does anybody know if there is a way to make Guice log errors before throwing them? We are using Tomcat and any exceptions thrown at deploy-time keep getting swallowed. If we could make guice log the exception before tomcat has the opportunity to throw it away we would have a much better chance of solving our current issue. ...