We're looking at technologies for an up and coming project here and I really want to use Guice as our dependency injection framework, I also want to use Hessian for client/server comms, but it doesn't seem to be compatible with Guice.
public class WebMobule extends ServletModule {
@Override
protected void configureServlets() {
ser...
Hi all,
I am using Guice 2.0 and its struts plugin 'guice-struts2-plugin-2.0' in my application. The struts version is 'Struts2-core-2.1.8.1 and application server is Jboss 4.2.2.
when deploying application getting problem
java.lang.NullPointerException : at com.google.inject.struts2.GuiceObjectFactory
$ProvidedInterceptor.destroy(Gu...
I have a class, being injected by guice and this class constructor invokes super, with resource loaded by class.getResource(..)
@SuppressWarnings("serial")
public class CleanAction extends AbstractAction {
private final JTable table;
private final PowderTableModel tableModel;
@Inject
public CleanAction(@Named("data") J...
I have a Java main application with somewhat complex command line arguments. These arguments are currently processed by a CommandLineArgumentProcessor class. Here's what my code current looks like:
public static void main(String[] args) {
Injector injector = Guice.createInjector(new ConfigModule(), new WorkModule(), new ReportModul...
I am trying to inject a Map into a class using Guice where the map has the form Map<MyInterface, Integer>.
I want to use the MapBinder extention to accomplish this, but it seems that MapBinder requires an instantiated object for the key. I would like to have Guice inject instantiations of the key, since they are complex objects that re...
I have an interface Producer<T> and a concrete FooProducer that implements Producer<Foo>. Binding this in guice looks ugly as sin:
bind(new TypeLiteral<Producer<Foo>>() {}).to(FooProducer.class);
I have lots of these such bindings. I have tried the following:
static <T> TypeLiteral<Producer<T>> producer() {
return new TypeLiteral...
The following code is an example of a factory that produces a Bar<T> given a Foo<T>. The factory doesn't care what T is: for any type T, it can make a Bar<T> from a Foo<T>.
import com.google.inject.*;
import com.google.inject.assistedinject.*;
class Foo<T> {
public void flip(T x) { System.out.println("flip: " + x); }
}
interface Ba...
Just thinking of implementing Guice in scala
Any sample code ?
...
Hi,
I have simple private module:
public class SomePrivateModule extends PrivateModule {
@Override
protected void configure() {
bind(SomeInterface.class).
annotatedWith(SomeAnotation.class).
to(SomeClass.class);
expose(SomeInterface.class).annotatedWith(SomeAnotation.class);
bind(S...
Hi,
I'm creating a library that will be included as a jar, so it won't contain a main method. I'm wondering what is the best practice for bootstrapping Guice in this case. I have one top level singleton.
public class TestManager
{
private TestManager()
{
}
public static TestManager getInstance()
{
// cons...
I created a class that uses the the Java Executor API to create/manage a pool with fixed number of threads.
Each thread needs a new instance of a particular object, and I would like to inject this object with Guice.
For the moment I'm using a Provider which provides new instances of the object through its get() method.
But now this clas...
We have two singleton objects (declared via in(Scopes.SINGLETON)) in Guice that each uses the other in its constructor. Guice's way to implement this is with proxies - it initializes the object at first with a proxy to the other object, and only when that object is needed it is resolved.
When running this code from several threads, we g...
Hi,
I have a class that extends AbstractGinModule
like:
public class ClientModule extends AbstractGinModule {
public ClientModule() { }
@Override
protected void configure() {
...
...
bind(...class).annotatedWith(...).to(...class).in(Singleton.class);
...
}
}
The idea that I have is to bind one class with ano...
I trying to expose some groovy service with jersey and girzzly. but i got a wierd error when i'm launching my servlet container.
Here is the snippet which lauch it:
ServletAdapter adapter = new ServletAdapter();
Injector injector = Guice.createInjector(new GmediaModule());
GuiceContainer container = new GuiceContainer(injector);
adapte...
I have Quartz scheduler in my web application with Guice. I followed code found here. Everything works fine, but I can't figure out how to shutdown scheduler. My context listener looks like this:
public class MyAppContextListener extends GuiceServletContextListener{
@Override
protected Injector getInjector() {
return Gu...
Hello :-)
My question is the following:
I got one application running with GWT.
At the startup of the application, one GWTClientModule which extends AbstractGinModule or another GWTClientModule is loaded.
Based on that switch I would like to set the local.
Is there a way to set the local not directly in .html by doing as follow:
<me...
I have the following problem:
Given a Guice type literal TypeLiteral<T> template and a class Class c implementing or extending T, construct a type Type t which is equivalent to c with all type variables instantiated so as to be compatible with template.
If c has no type variables, it's easy; c is the type in question. However, if ...
There's something I just don't get about guice: According to what I've read so far, I'm supposed to use the Injector only in my bootstrapping class (in a standalone application this would typically be in the main() method), like in the example below (taken from the guice documentation):
public static void main(String[] args) {
/*
...
I downloaded the guice 2.0 source from http://code.google.com/p/google-guice/downloads/list but when I looked at the pom I saw the version was was marked as 1.0-RC2 and the target jar that was build by maven was named guice-1.0-RC2.jar. On the central maven repository under com.google.inject there is a jar named guice-2.0.jar. Under com....
Is it possible to wrap generic injections in some way?
Given the interface:
interface IFoo<T>
In my guice module:
bind((Key<IFoo<SomeType>) Key.get(Types.newParameterizedType(IFoo.class, SomeType.class))).to(Foo.class);
But before I return the Foo instance I want to wrap it with this:
class FooWrapper<T> implements IFoo<T> { public...