users@jersey.java.net

Re: [Jersey] Newbie question: How do I inject objects into resources

From: Imran M Yousuf <imran_at_smartitengineering.com>
Date: Tue, 24 Mar 2009 14:41:50 +0600

On Tue, Mar 24, 2009 at 2:34 PM, Mats Henricson <Mats.Henricson_at_paf.com> wrote:
> From: Craig.McClanahan_at_Sun.COM [Craig.McClanahan_at_Sun.COM]
>>> Why is this so much more complicated with Jersey?
>> Because Jersey does not pretend to play in the IoC framework space.  It would much rather integrate with IoC
>> frameworks, so you don't have to choose one approach for your REST resource classes and some other
>> approach for your back end services.
>

I totally agree with the comment made, especially seeing how the
Spring Framework integration works, I am pretty darn pleased to be
honest :).

> This explanation would make more sense if your example (of how to get a
> Database Connection object inserted) was not an example of how Jersey
> "integrates with IoC frameworks" but instead an example for how to manually
> do the integration.
>
> Which is something completely different, of course.
>
> Me myself is struggling with writing JUnit tests of Jersey components over
> HTTP, but I can't find a single example out there. There are lots of examples
> for how to autowire Jersey code into execution environments like GlassFish,
> but none for JUnit. Am I the only TDD enthusiast using Jersey?
>
> It seems like I have to write my own subclass of PackagesResourceConfig,
> since my Resource class needs injection of other objects. Right?
>

What kind of integration are you looking for? Did you have a look at
the Jersey's jersey-tests module? And I also (at least try to) follow
TDD and I have worked on a sample that uses Jersey, Spring, GlassFish
(Embedded), Hibernate (through another custom lib - Smart DAO), Derby
(as RDBMS). You can also have a look at them as an example -

http://repo.or.cz/w/smart-bookstore.git

I hope that helps, if not please let us know we will surely try to get
something for you thats useful :).

- Imran

> Mats
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe_at_jersey.dev.java.net
> For additional commands, e-mail: users-help_at_jersey.dev.java.net
>
>



-- 
Imran M Yousuf
Entrepreneur & Software Engineer
Smart IT Engineering
Dhaka, Bangladesh
Email: imran_at_smartitengineering.com
Blog: http://imyousuf-tech.blogs.smartitengineering.com/
Mobile: +880-1711402557