guice

Python Dependency Injection Framework

Is there a framework equivalent to Guice (http://code.google.com/p/google-guice) for Python? ...

Are you using Google Guice in a production system?

Have you found Guice useful to manage DI in you applications or run stress tests or even brought an application using Guice to a production phase in your company? If you have, have you run into any issues with it? ...

Projects with browsable source using dependency injection w/ guice?

I often read about dependency injection and I did research on google and I understand in theory what it can do and how it works, but I'd like to see an actual code base using it (Java/guice would be preferred). Can anyone point me to an open source project, where I can see, how it's really used? I think browsing the code and seeing the...

Which Java Web Framework fits best with Google Guice?

I'm planning to start on a new project and am looking at the current state-of-the-art Java web frameworks. I decided to build my application around Guice, and am likely to use a very lightweight ORM like Squill/JEQUEL/JaQu or similar, but I can't decide on the web framework. Which one would fit best in such a lightweight environment? And...

Overriding Binding in Guice

I've just started playing with Guice, and a use-case I can think of is that in a test I just want to override a single binding. I think I'd like to use the rest of the production level bindings to ensure everything is setup correctly and to avoid duplication. So imagine I have the following Module public class ProductionModule impleme...

Is there ever a case for 'new' when using dependency injection?

Does dependency injection mean that you don't ever need the 'new' keyword? Or is it reasonable to directly create simple leaf classes such as collections? In the example below I inject the comparator, query and dao, but the SortedSet is directly instantiated: public Iterable<Employee> getRecentHires() { SortedSet<Employee> entries ...

Injector.getInstance(..) returns a new instance for a singleton

My Module: bind( Translator.class ).to( TranslatorImpl.class ).in( Scopes.SINGLETON ); Now I expect to get the same instance everytime when I do Injector injector = ...; injector.getInstance( Translator.class ); But if I do injector.getInstance( TranslatorImpl.class ); I get a new instance everytime. Is this a bug or expected b...

Can Guice initialize beans?

I've used Spring before (and like it), but thought I'd take a look at Guice. Is there a way to initialize something like maps or lists into beans using Guice? For instance, I've done the following before in Spring to inject a list of items I want to process into some bean. <property name="FilesToProcess"> <list> <value>file1....

Wicket Dependency Injection

I've got a page with a form in Wicket where the form requires a collaborator to get its job done. The collaborator is injected (for which I'm using Guice) and looks something like: public class RegistrationPage extends WebPage { @Inject public RegistrationPage(RegistrationService service) { this.service = service; ...

Java error: Found interface ... but class was expected

I am getting a strange runtime error from my code: "Found interface [SomeInterface] but class was expected" How can this happen? How can an interface get instantiated? Update: (In response to some answers) I am compiling and running against the same set of libraries, but I am using Guice to inject a Provider for this particular Inter...

Inject an array of Objects in Guice

Hi, I would like to achieve something similar to the following in Guice: public MyClass { private final InjectedObject[] injectedObjects; @Inject public MyClass(InjectedObject[] injectedObjects) { this.injectedObjects=injectedObjects; } } ie I would like to be able to create a certain number of instances of ...

Why there's no configuration file at all for dependency injection with Google Guice?

I am checking out Google Guice as DI framework but I am a bit puzzled: why there's no configuration file at all? I found a partial explanation on this question but it is still not clear how I would be able to set my component roles (or any other thing I need to use a switch) without a config file. Any help appreciated! ...

Post-injection initialisation (JSF 1.2 + Guice)

I'm trying to integrate Guice into a JSF 1.2 (Sun RI) application, and I want to be able to do the following to my managed-beans: Inject dependencies using the Guice @Inject annotation, then Perform initialisation using the @PostConstruct annotation My problem is that the @PostConstruct method is always invoked before the @Inject ann...

In what maven2 repository Google Guice 2.0 can be found?

As far as I understand Google Guice 2.0 is out not so long ago. But I see that central repo still has outdated 1.0 version. Please, tell where can I find maven2 repository with Google Guice 2.0. ...

Has anyone used ServiceLoader together with Guice?

I keep wanting to try this on a larger scale with our app + build system, but higher priorities keep pushing it to the back burner. It seems like a nice way to load Guice modules and avoids the common complaint about "hard coded configuration". Individual configuration properties rarely change on their own, but you will almost always hav...

Migrating application to use Guice - how to inject transactions into existing objects?

I'm new to Guice, and I'm working it in to an application with a large amount of legacy code. It has several classes that look like this: public final class DataAccessClass { private Transaction txn; @Inject //This was just added public DataAccessClass(/* injectable parameters */, Transaction txn) { this.txn = tx...

Managing complexity in a dependency-injected app with a large number of beans

I'm working on an Spring application which has a large number of beans - in the hundreds - and it's getting quite cumbersome to use and document. I'm interested in any experience you have with DI-enabled apps with a large number of beans which would aid maintainability, documentation and general usage. Although the application is Sprin...

How to use Google Guice to create objects that require parameters?

Maybe I am just blind, but I do not see how to use Guice (just starting with it) to replace the new call in this method: public boolean myMethod(String anInputValue) { Processor proc = new ProcessorImpl(anInputValue); return proc.isEnabled(); } For testing there might be a different implementation of the Processor, so I'd like...

What's aopalliance all about? And why is guice using it?

I'm using guice for dependency injection with aop from aopalliance. I can't quite figure out what's aopalliance all about and who implemented the version (dated from 2004) that's on their sourceforge page. Why is guice using this version instead of a more known package such as AspectJ? Also, do you know of any tutorials on the aopallian...

Dependency Injection with Guice: Something that isn't covered by any tutorial...

Hi Everyone! i just tinkered around with Google Guice for Dependency Injection and started integrating it into my existing application. So far, so good. I have many classes which need, beside their dependencies, Strings, DataSources, et cetera. I know there are NamedBindings, but i really do not want to create an annotation for every si...