Re: injecting jsp tags and EJBs

2010-04-27 Thread Kartik Kumar
For Guice and EJB, take a look at this article. http://musingsofaprogrammingaddict.blogspot.com/2009/03/guice-tutorial-part-3-integrating-guice.html. Guiceyfruit also provides lifecycle support for JSR 250 annotations. They might be worth a look. Kartik On Tue, Apr 27, 2010 at 3:36 AM, senny w

Re: Suggested way of injecting static dependencies

2010-04-27 Thread Patrick Bergner
Thanks, Sam. Now I got your first explanation as well. Great people around here! :-) -- You received this message because you are subscribed to the Google Groups "google-guice" group. To post to this group, send email to google-gu...@googlegroups.com. To unsubscribe from this group, send email

Re: Suggested way of injecting static dependencies

2010-04-27 Thread Sam Berlin
It looks like you're angling to tell Guice, "I only want a single instance of SettingsXmlReader." That's what the Singleton annotation/scope is for. You can either add @Singleton to the SettingsXmlReader implementation class or you can explicitly bind it as a singleton (see my above example that b

Re: Suggested way of injecting static dependencies

2010-04-27 Thread Christian Edward Gruber
Please don't do this - you're using a single static logger behind an instance variable, and using Logger quite differently than it's intended. And what happens if someone doens't force the constructor... log is not initialized. Or what if there are multiple injectors in the VM - now you h

Re: Suggested way of injecting static dependencies

2010-04-27 Thread Patrick Bergner
Thanks for your reply, Sam. With (a) you're absolutely right. However, I'm not sure if I understood (b) correctly. From the way I understood it the answer would be that that's not what I need. Let my try to explain SettingsXmlReader a bit better: (i) SettingsXmlReader has dependencies in its const

Re: Suggested way of injecting static dependencies

2010-04-27 Thread Sam Berlin
Let me repeat the problem to see if I understand it. You a) Have some kind of SettingsXmlReader class that reads an XML file and requires dependencies from Guice passed to its constructor (or parameter methods). b) Need to also tell Guice to bind the result of some of SettingsXmlReader's methods

Re: Suggested way of injecting static dependencies

2010-04-27 Thread Patrick Bergner
Thanks for your replies. They give me some idea of the "Guice way". I'll make the utilities non-static and let Guice create the instance for me. Now, if you don't mind, give me a hint on this one: I have a Settings object that is a wrapper for a settings.xml file. I instantiate it using Guice. As

Re: Suggested way of injecting static dependencies

2010-04-27 Thread Jonathan Abourbih
I'm also a bit new to Guice, but I'll give it a shot. One way to avoid the static injection would be to use an instance of the Utils class: @Singleton public class Utils { private static Logger log; @Inject private TestStatic(Foo myFoo) { TestStatic.myFoo = myFoo; } public

Re: Suggested way of injecting static dependencies

2010-04-27 Thread Christian Edward Gruber
Yes, I would make your methods non-static, make the class instantiatable - if you MUST, make a singleton static factory method, but in your Guice-ified code, don't use the factory method - just inject it where you need it, and in its constructor, ask for the logger. If you use it outside of

injecting jsp tags and EJBs

2010-04-27 Thread senny
Hey Guicers I just picked up Guice and am eagerly learning and integrating it into our project. There are some questions I could not answer with the Documentation or the existing Group Discussions. 1.) Is it possible to inject JSP Tags with Guice? And if not, is there a workaround for it? 2.) Is

Re: Suggested way of injecting static dependencies

2010-04-27 Thread Stuart McCulloch
On 27 April 2010 17:44, Patrick Bergner wrote: > Hi, I'm new to Guice and lack experience in using it the suggested > (intended) way. I already figured out most of what I need to use Guice > in a relatively simple application and like it very much but one thing > is missing: injecting static depe

Re: Suggested way of injecting static dependencies

2010-04-27 Thread Willi Schönborn
Patrick Bergner wrote: Hi, I'm new to Guice and lack experience in using it the suggested (intended) way. I already figured out most of what I need to use Guice in a relatively simple application and like it very much but one thing is missing: injecting static dependencies. I need this in classe

Suggested way of injecting static dependencies

2010-04-27 Thread Patrick Bergner
Hi, I'm new to Guice and lack experience in using it the suggested (intended) way. I already figured out most of what I need to use Guice in a relatively simple application and like it very much but one thing is missing: injecting static dependencies. I need this in classes that contain only stati