From: Jakub N. <jmn...@gm...> - 2013-09-03 20:58:37
|
Hi, I was actually curiouse if there is a similar functionality in RESTeasy to the Jersey InjectableProvider? The interface basically allows to define provider for custom object injection. Thanks in advance, Jakub Narloch |
From: Weinan Li <l.w...@gm...> - 2013-09-04 05:48:24
|
-- Weinan Li On Wednesday, September 4, 2013 at 4:58 AM, Jakub Narloch wrote: > Hi, > > I was actually curiouse if there is a similar functionality in RESTeasy > to the Jersey InjectableProvider? If I didn't make any mistake, seems RESTEasy doesn't have similar functions. RESTEasy's @Context let you inject: javax.ws.rs.core.HttpHeaders, javax.ws.rs.core.UriInfo, javax.ws.rs.core.Request, javax.servlet.HttpServletRequest, javax.servlet.HttpServletResponse, javax.servlet.ServletConfig, javax.servlet.ServletContext, and javax.ws.rs.core.SecurityContext objects. If you want to use something like: public String uppercase(@Context Locale locale) { return "this is lowercase".toUppercase(locale); } and: @Provider public class LocaleProvider extends AbstractHttpContextInjectable<Locale> implements InjectableProvider<Context, Type> { @Override public Injectable<E> getInjectable(ComponentContext ic, Context a, Type c) { if (c.equals(Locale.class)) { return this; } return null; } @Override public ComponentScope getScope() { return ComponentScope.PerRequest; } @Override public Locale getValue(HttpContext c) { final Locales locales = c.getRequest().getAcceptableLanguages(); if (locales.isEmpty()) { return Locale.US; } return locales.get(0); } } in Jersey. I don't know how to do this in RESTEasy(I wonder if there is a way). Please blame me if there *is* a way to do this in RESTEasy and I don't know how because of my lack of knowledge :-) > The interface basically allows to > define provider for custom object injection. > > Thanks in advance, > Jakub Narloch > > ------------------------------------------------------------------------------ > Learn the latest--Visual Studio 2012, SharePoint 2013, SQL 2012, more! > Discover the easy way to master current and previous Microsoft technologies > and advance your career. Get an incredible 1,500+ hours of step-by-step > tutorial videos with LearnDevNow. Subscribe today and save! > http://pubads.g.doubleclick.net/gampad/clk?id=58040911&iu=/4140/ostg.clktrk > _______________________________________________ > Resteasy-users mailing list > Res...@li... (mailto:Res...@li...) > https://lists.sourceforge.net/lists/listinfo/resteasy-users |
From: Bill B. <bb...@re...> - 2013-09-04 12:09:51
|
Resteasy has an injection API internally, but we never exposed it. Nobody ever really asked us to. If you have a glaring need, I could add it for the next release. Bill On 9/3/2013 4:58 PM, Jakub Narloch wrote: > Hi, > > I was actually curiouse if there is a similar functionality in RESTeasy > to the Jersey InjectableProvider? The interface basically allows to > define provider for custom object injection. > > Thanks in advance, > Jakub Narloch > > ------------------------------------------------------------------------------ > Learn the latest--Visual Studio 2012, SharePoint 2013, SQL 2012, more! > Discover the easy way to master current and previous Microsoft technologies > and advance your career. Get an incredible 1,500+ hours of step-by-step > tutorial videos with LearnDevNow. Subscribe today and save! > http://pubads.g.doubleclick.net/gampad/clk?id=58040911&iu=/4140/ostg.clktrk > _______________________________________________ > Resteasy-users mailing list > Res...@li... > https://lists.sourceforge.net/lists/listinfo/resteasy-users > -- Bill Burke JBoss, a division of Red Hat http://bill.burkecentral.com |