users@jersey.java.net

Re: [Jersey] Passing my own non-static objects into jersey resources and providers ?

From: Morten <mortench2004_at_yahoo.dk>
Date: Mon, 3 May 2010 12:18:14 +0000 (GMT)

--- Den man 3/5/10 skrev Paul Sandoz <Paul.Sandoz@Sun.COM>: >You can add singleton instances to the Application. Thanks, I tried it and this works for singletons. I was not aware of this (all constructors and examples I could find only used classes). >You can register your own injectables by implementing: >  https://jersey.dev.java.net/nonav/apidocs/latest/jersey/com/sun/jersey/spi/inject/InjectableProvider.html The problem is then moved to how to pass the state to the InjectableProvider but I guess if it is a singleton then the above trick with adding singletons to applications will work. >Is that the one i fixed related to class hierarchies? Yes! (The one that was so complicated to verify last week as we found out I could not bundle a new version of jersey with my app in glassfish). As I wrote to you I have come to realize that the Jersey integration with dependency managers and glassfish is too cutting edge. Once your bugfix is in a released version of jersey and a new glassfish version is there with the new jersey version and all customers has upgraded I am sure it will work but until then I will either have to live with the problem or try a workaround. And the workaround I am trying is a simpler setup. >You can also define your own component provider factory. Yea, been there earlier with my own dependency manager but I am trying to live a simpler life now :-) Thanks for the help. I think I am going with the Application singletons approach. Cheers, Morten