Yes. Much simpler indeed. Would you believe I didn't even know you could
have static instances attached to interfaces... I'm still relatively new to
Java. :)

Cheers and thanks again.

On Sun, Mar 21, 2010 at 2:02 PM, Gal Dolber <gal.dol...@gmail.com> wrote:

> You don't need to do that, you can just put a static instance of the
> Injector on the injector interface.
>
> 2010/3/21 PhilBeaudoin <philippe.beaud...@gmail.com>
>
>> One last update:
>> I don't think its a good idea to GWT.create() the ginjector multiple
>> times. I got rid of this by creating it once in a static field in my
>> entry point class, and then accessing that field within my generated
>> class. This brings me to another question:
>>
>> To find the name of the entry point class, I had to create a
>> configuration property. Is there a way, within a generator, to access
>> the entry point class defined in the module:
>> <entry-point class='com.puzzlebazar.client.Puzzlebazar' />
>>
>>
>> On Mar 21, 1:01 am, PhilBeaudoin <philippe.beaud...@gmail.com> wrote:
>> > Yeah, well... Method injection didn't work either, the method just
>> > never got called (as expected...)
>> >
>> > I finally was able to make it work using the technique you proposed by
>> > initializing the generated classes after the injector is created.
>> >
>> > Just to give a bit more details to anybody else interested in this...
>> >
>> > Here is how you define a configuration property in your
>> > project.gwt.xml:
>> >       <define-configuration-property name="gin.injector" is-multi-
>> > valued="false" />
>> >       <set-configuration-property name="gin.injector"
>> > value="com.project.client.gin.MyGinjector" />
>> >
>> > Here is how you access this property in your generator:
>> >       String ginjectorClassName =
>> >
>> ctx.getPropertyOracle().getConfigurationProperty("gin.injector").getValues(
>> ).get(0);
>> >
>> > Now if you want an injector in the source code you generate you do:
>> >       writer.println( ginjectorClassName + " injector = GWT.create(" +
>> > ginjectorClassName + ".class);"  );
>> >
>> > Thanks again Gal. This is a neat trick!
>> >
>> >    Philippe
>>
>> >
>> > On Mar 20, 8:34 pm, PhilBeaudoin <philippe.beaud...@gmail.com> wrote:
>> >
>> >
>> >
>> > > Thanks Gal, it really helped!
>> >
>> > > I'm not quite sure I know how to "include a folder in my lookup
>> > > entries". Is this something I can do in Eclipse debugger?
>> >
>> > > The idea of using the injector directly didn't quite work, because I
>> > > need my generated class to be instanciated .asEagerSingleton(). If I
>> > > try calling GWT.create( MyGingector ) within the generated class I get
>> > > infinite recursion. If I instead try to assign the MyGingector
>> > > instance to some static variable, it doesn't work either because the
>> > > variable isn't initialized yet.
>> >
>> > > However, I've decided to rework my generated class to use method
>> > > injection instead of constructor injection and it seems to work very
>> > > well!
>> >
>> > > Cheers,
>> >
>> > >     Philippe
>> >
>> > > On Mar 20, 7:31 pm, Gal Dolber <gal.dol...@gmail.com> wrote:
>> >
>> > > > Ok,
>> >
>> > > > To view the generated class compile with "-gen /somepathonyourdisk",
>> another
>> > > > tip to debug a generated class: include in your lookup entries the
>> folder
>> > > > where the generated classes are and you will be able to step through
>> the
>> > > > generated code.
>> >
>> > > > And to use gin into your generated class I didn't found a great
>> solution,
>> > > > because you can inject an interface that is generated but gin just
>> make a
>> > > > GWT.create(theinterface.class); and it wont inject into the
>> generated class.
>> >
>> > > > This is what I did:
>> > > > Add an set-configuration-property into your module (define it first)
>> and
>> > > > specify on it the location of your injector, then use directly the
>> injector
>> > > > into your generated code. Like this:
>> >
>> > > > <add-configuration-property name="gin.injector"
>> > > > value="com.some.gin.MyGinInjector" />
>> >
>> > > > Regards
>> >
>> > > > 2010/3/20 PhilBeaudoin <philippe.beaud...@gmail.com>
>> >
>> > > > > I'm trying to write my first GWT generator... I've gotten pretty
>> far,
>> > > > > but I have the following questions:
>> > > > > 1) Is there any way to see the generated class for debugging
>> purposes?
>> > > > > For example, can I force GWT to produce the .java file for my
>> > > > > generated class (it did it once when I had an error, but I can't
>> force
>> > > > > it to produce it every time.) Any other hints as to how to debug a
>> > > > > generated class?
>> > > > > 2) I'd like to use GIN to inject objects in the constructor of the
>> > > > > generated class. I'm not quite sure if this works or how to make
>> it
>> > > > > work. Any hints would be great!
>> >
>> > > > > Thanks!
>> >
>> > > > > --
>> > > > > You received this message because you are subscribed to the Google
>> Groups
>> > > > > "Google Web Toolkit" group.
>> > > > > To post to this group, send email to
>> google-web-tool...@googlegroups.com.
>> > > > > To unsubscribe from this group, send email to
>> > > > > google-web-toolkit+unsubscr...@googlegroups.com<google-web-toolkit%2bunsubscr...@googlegroups.com><google-web-toolkit%2Bunsubs
>> cr...@googlegroups.com>
>> > > > > .
>> > > > > For more options, visit this group at
>> > > > >http://groups.google.com/group/google-web-toolkit?hl=en.
>>
>> --
>> You received this message because you are subscribed to the Google Groups
>> "Google Web Toolkit" group.
>> To post to this group, send email to google-web-tool...@googlegroups.com.
>> To unsubscribe from this group, send email to
>> google-web-toolkit+unsubscr...@googlegroups.com<google-web-toolkit%2bunsubscr...@googlegroups.com>
>> .
>> For more options, visit this group at
>> http://groups.google.com/group/google-web-toolkit?hl=en.
>>
>>
>  --
> You received this message because you are subscribed to the Google Groups
> "Google Web Toolkit" group.
> To post to this group, send email to google-web-tool...@googlegroups.com.
> To unsubscribe from this group, send email to
> google-web-toolkit+unsubscr...@googlegroups.com<google-web-toolkit%2bunsubscr...@googlegroups.com>
> .
> For more options, visit this group at
> http://groups.google.com/group/google-web-toolkit?hl=en.
>

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

Reply via email to