[google-gin] Re: Comment on GinFaq in google-gin

39 views
Skip to first unread message

googl...@googlecode.com

unread,
Apr 27, 2010, 11:59:22 AM4/27/10
to googl...@googlegroups.com
Comment by desprez.marine:

How to you use IN with MVP qnd JSON ? please


For more information:
http://code.google.com/p/google-gin/wiki/GinFaq

--
You received this message because you are subscribed to the Google Groups "google-gin" group.
To post to this group, send email to googl...@googlegroups.com.
To unsubscribe from this group, send email to google-gin+...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/google-gin?hl=en.

googl...@googlecode.com

unread,
Apr 28, 2010, 12:16:40 PM4/28/10
to googl...@googlegroups.com
Comment by desprez.marine:

It is possible to use GIN and GUICE with an application with GWT and JSON ?
thanks for your answer.

googl...@googlecode.com

unread,
Apr 28, 2010, 11:30:03 PM4/28/10
to googl...@googlegroups.com
Comment by wanjunfeng:

Currently, in my project, I'm using replace-with to handle some specific
implementations for gecko1_8. But with gin, I haven't found any way to do
it.

The scenario is like, I have RegisterPanel, and its subclasses
RegisterPanelStandard for other browsers and RegisterPanelGecko for firefox.

I have Module.java
public class Module extends AbstractGinModule
{
@Override
protected void configure()
{
bind(RegisterPanel.class).to(RegisterPanelStandard .class);
}
}

and ModuleGecko.java
public class ModuleGecko extends Module
{
@Override
protected void configure()
{
super.configure();
bind(RegisterPanel.class).to(RegisterPanelGecko .class);
}
}

and Injector.java

@GinModules(Module.class)
public interface Injector extends Ginjector
{
RegisterPanel getRegisterPanel();
}

and in myproject.gwt.xml, I added the following,

<replace-with class="com.topcmm.client.ModuleGecko">
<when-type-is class="com.topcmm.client.Module"></when-type-is>
<when-property-is name="user.agent" value="gecko1_8"></when-property-is>
</replace-with>

But I found it doesn't work for me. Anyone can explain it or how can I make
it work?

Appreciate for any comments!

googl...@googlecode.com

unread,
Apr 28, 2010, 11:34:08 PM4/28/10
to googl...@googlegroups.com

googl...@googlecode.com

unread,
May 12, 2010, 3:41:54 PM5/12/10
to googl...@googlegroups.com
Comment by vkubushyn:

Hey everyone,

We are trying to split out our codebase into multiple GWT modules with GIN
for dependency injections. A need arose for different Ginjectors to inherit
from other Ginjectors.

We found that this works:
{{{
@GinModules(ParentModule.class)
public interface ParentInjector extends ChildInjector, Ginjector{
public SomeClass getSomeClass();
}
}}}
and then the ChildInjector is like this:
{{{
@GinModules(ChildModule.class)
public interface ChildInjector extends Ginjector{
public SomeOtherClass getSomeOtherClass();
}
}}}
Now, we can get the SomeOtherClass instance by instantiating the parent
Ginjector:
{{{
ParentInjector injector = GWT.create(ParentInjector.class);
SomeOtherClass socInstance = injector.getSomeOtherClass();
}}}

This works fine, but I'm wondering whether we're overlooking any major
issues this could cause?

Any comments are appreciated!


For more information:
https://code.google.com/p/google-gin/wiki/GinFaq

googl...@googlecode.com

unread,
Jun 17, 2010, 11:09:57 AM6/17/10
to googl...@googlegroups.com
Comment by nat...@gmail.com:

@vkubushyn
i'm having the exact same problem.

googl...@googlecode.com

unread,
Jun 30, 2010, 1:34:00 PM6/30/10
to googl...@googlegroups.com
Comment by arashbi:

How does lazy instantiation works with jin?

googl...@googlecode.com

unread,
Jul 3, 2010, 3:03:56 AM7/3/10
to googl...@googlegroups.com
Comment by arashbi:

Can I inject a parametrized type to a class using jin?
I tried several approaches but I get error

googl...@googlecode.com

unread,
Jul 21, 2010, 10:04:06 AM7/21/10
to googl...@googlegroups.com
Comment by alex.moffat:

Sorry for answering a question in the comments but....

@arashbi Lazy instantiation works fine. You can see this by adding some
sort of message, such as Window.alert("XXX"), to the constructor of a class
created by gin. You will see that the message only appears when the
injector.xxx() method is called. By printing out hashCodes you can also
check that Singleton etc. works as you expect.

For parameterized types use the TypeLiteral class, take a look at the Guice
documentation for this.

googl...@googlecode.com

unread,
Jan 16, 2011, 2:55:21 AM1/16/11
to googl...@googlegroups.com
Comment by ste...@haebler.ch:

While working on a gin module in development mode, I often get
the "Deferred binding result type 'A' should not be abstract" error. After
restarting the development console, it's gone. Just a hint in case you run
into this one as well.

Debian, 2.6.26-2
Firefox 3.6.13
GWT 2.1.1
GIN 1.0

googl...@googlecode.com

unread,
Apr 1, 2011, 5:50:26 PM4/1/11
to googl...@googlegroups.com
Comment by aryzho...@gmail.com:

I have a question to Gin team:

In Guice, I specify the module when I am creating an injector. This is fine
because I can create two injectors with different modules, for testing
purposes.

In Gin, I must specify the module to use in the Injector interface via
@GinModules. So I cannot create two instances of the injector with
different modules. This creates a dependency from an interface to the
implementation and defeats the whole purpose of dependency injection.

Is there a way around it?

googl...@googlecode.com

unread,
Apr 4, 2011, 8:04:07 PM4/4/11
to googl...@googlegroups.com
Comment by aragos:

There are two ways to reuse Ginjectors. The classic way is to subclass
them, i.e. if the ginjector with all your methods is A, then have 2 (n)
ginjectors B and C, each of which extend A but which define different gin
modules.

Another way to easily swap the gin module names is to use GWT properties,
which was recently implemented. Take a look at
http://code.google.com/p/google-gin/source/browse/trunk/src/com/google/gwt/inject/client/GinModules.java
for some more documentation.

googl...@googlecode.com

unread,
Jan 8, 2014, 2:01:14 PM1/8/14
to googl...@googlegroups.com
Reply all
Reply to author
Forward
0 new messages