guice

Why my @singleton doesn't work?

Hi, I met a problem when trying @Singleton of Guice: import com.google.inject.Singleton; @Singleton public class ConfigManager { private String data; public void setData(String data) { this.data = data; } public String getData(){ return this.data; } public static void main(String[] args){ Confi...

Is Guice needed in unit test?

I was told the Guice is aim to produce testable code, and not needed in the unit test. But how can I test a Singleton(@Singleton) without use Guice? ...

Using Guice with OSGi

I have a project that I am trying to convert to OSGi. However, this project has been built with Guice as its dependency injection manager. It's a large project with Guice interwoven all throughout. Guice has been giving me many fits with the conversion process. Specifically, it has been given me a NoClassDefFoundError for com.google.inje...

Lifetime management with Google Guice

Is there a recommended pattern for shutting down / closing objects created with Guice? The lifecycle I'm aiming for is: Prepare a Guice Module Create an injector Use the injector through your code to obtain objects (injector.getInstance(Foo.class)) ... Close any resources held by said objects (file handles, TCP connections, etc...). I...

How to vary Constants based on deployment instance

I've been building a GWT 1.7 + GAE application using the eclipse plugin. The system constants are loaded into a MyConstants.properties file that is loaded by the singleton MyConstants class extending the ...gwt.i18n.client.Constants class. I would like for MyConstants to load one of several files containing settings like MyConstants-l...

Guice best practices and anti-patterns

I'm not sure if there is merit to this question or not, but are there any best practices and anti-patterns specific to Google Guice? Please direct any generic DI patterns to this question. ...

Spring's IOC with annotations is confusing for a Guice guy. Help to enlighten me

I came into IOC via Google Guice. And now I've been forced to use Spring 2.5.6 at work & I am lost because Spring is quite complicated. Here are some questions after reading bits of the spring docs: What is the difference between @Service, @Controller and @Component ? If I just want to auto wire my objects like Guice, do I need to be ...

Guice Creation Exception

Hi Everyone, I am trying to get Guice working with Struts, Hibernate and Quartz scheduler. When I deploy my application under Tomcat, I get the following error - Nov 19, 2009 2:11:26 PM com.google.inject.struts2.GuiceObjectFactory buildBean INFO: Creating injector... com.google.inject.CreationException: Guice configuration erro...

Alternative to dozer for bean mapping?

I am trying to figure out an easy way to map DTOs to entities without the boiler-plate code. While I was thinking of using dozer it appears to require a lot of xml configuration. Has anybody seen a dozer alternative that uses a DSL to configure the bean mapping in pure Java? Ideally I am hoping to find a bean mapper that is inspired b...

A Guice-ready security framework?

Has anybody seen a framework which is either written to work with Guice or a library that integrates an existing security system (ie: Acegi) with Guice? I have found the following thus far... http://code.google.com/p/warp-security/ (I think this abandonware) http://code.google.com/p/warp-security/ (no documentation) ...

AtUnit vs 'Junit,JMock and GUICE' by hand - ?

How does AtUnit fare with respect to unit testing using DI and guice ?. Please share your experiences. ...

How to manage security with google guice ?

Is there a way to handle security with google guice (like with Spring Security) ? ...

Guice, bind different database provider based on yaml config

I have an application config file that looks something like this: database: type: [db-type] username: [name] password: [pw] server: [ip] database: [db-name] db-type can be any of the following: {postgresql, mysql, mssql, file}. I wanted to configure the binding, such that (it's hibernate based) the app loads a special Provid...

How to inject with Guice when there are two different constructors?

Total Guice noob here, have read a few articles and seen the intro video, that's about it. Here's my simplified old code that I'm trying to "guicifiy". Can't quite figure out how to, since (as far as I understand), I can only @inject-annotate one of the two constructors? How can a calling class create the one or the other instance? Or w...

JSR 330 and Guice interoperability

Does anybody have experience with JSR 330 vs Guice? From what I gather Guice is not an implementation of JSR 330 but if it is anything like Hibernate and JPA the implementation supports a bunch of additional functionality no in the API. Since I am already using GWT-Dispatch, Warp-persist guice-serlvet, etc would there be anything gaine...

How does the Built-in Bindings of Google Guice work?

Hello, I tried Google Guice the first time and find it very nice. But, when I reached the part of Built-in Bindings I do not understand the examples. For me it looks like I can use it for logging like an interceptor, but I don't know how. Could someone of you explain this type of Binding and how I can use it? And maybe (if it's possib...

Guice and JSF 2

I'm trying to use Guice to inject properties of a JSF managed bean. This is all running on Google App Engine (which may or may not be important) I've followed the instructions here: http://code.google.com/docreader/#p=google-guice&s=google-guice&t=GoogleAppEngine One problem is in the first step. I can't subclass the Servlet...

Google Guice vs. PicoContainer for Dependency Injection

My team is researching dependency injection frameworks and is trying to decide between using Google-Guice and PicoContainer. We are looking for several things in our framework: A small code footprint - What I mean by a small code footprint is we don't want to have dependency injection code litter everywhere in our code base. If we ne...

What is the best way to use Guice and JMock together?

I have started using Guice to do some dependency injection on a project, primarily because I need to inject mocks (using JMock currently) a layer away from the unit test, which makes manual injection very awkward. My question is what is the best approach for introducing a mock? What I currently have is to make a new module in the unit t...

Adhering to logging standard while using Google Guice?

The Java docs for Logger indicate that the logger name should be based on the class name. Google Guice handles this in BinderImpl.java where it does the following: return member == null ? Logger.getAnonymousLogger() : Logger.getLogger(member.getDeclaringClass().getName()); However, since it's getting a new logger for each...