On Mar 24, 2009, at 5:04 PM, Mats Henricson wrote:
> Unfortunately, that was WAY above my knowledge level.
>
I kind of hoped the Overview document would help increase your
knowledge level :-)
> But lets see, what you are saying is that it is NOT possible to hand-
> wire my resources together with its exception mappers, and then
> send it to Grizzly or some other container so that I can test it over
> HTTP?
>
You can create the following:
public class MyApplication extends Application {
public Set<Class<?>> getClasses() {
Set<Class<?>> s = new HashSet<Class<?>>();
s.add(MyResourceClass.class);
s.add(MyExceptionMapper.class);
return s;
}
}
And then register the class with the init params:
sa.addInitParameter( "javax.ws.rs.Application",
MyApplicaton.class.getName());
It is possible to get more even programmatic if you use the lower
level grizzly layer of:
https://jersey.dev.java.net/source/browse/*checkout*/jersey/tags/jersey-1.0.2/api/jersey/com/sun/jersey/api/container/grizzly/GrizzlyServerFactory.html
Paul.
> Mats
> ________________________________________
> From: Paul.Sandoz_at_Sun.COM [Paul.Sandoz_at_Sun.COM]
> Sent: Tuesday, March 24, 2009 16:55
> To: users_at_jersey.dev.java.net
> Subject: Re: [Jersey] Is there a way to programmatically attach my
> excewption mappers?
>
> On Mar 24, 2009, at 4:26 PM, Mats Henricson wrote:
>
>> Hi!
>>
>> I've seen and used the @Provider annotation, but is there any way I
>> can wire
>> up my resource and these mappers programatically (not using
>> annotations)?
>>
>> This could help me get my unit tests through, by subclassing
>> Application.
>>
>
> You still need to use the annotations but you can change the
> registration strategy by subclassing Application. See:
>
> http://wikis.sun.com/display/Jersey/Overview+of+JAX-RS+1.0+Features#OverviewofJAX-RS1.0Features-DeployingaRESTfulWebservice
>
> Paul.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe_at_jersey.dev.java.net
> For additional commands, e-mail: users-help_at_jersey.dev.java.net
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe_at_jersey.dev.java.net
> For additional commands, e-mail: users-help_at_jersey.dev.java.net
>