On Mon, Jul 22, 2013 at 4:36 PM, Sergey Beryozkin <[email protected]>wrote:

> Hi
>
> JAX-RS 2.0 ResourceContext is supported from CXF 2.7.2, which version do
> you use ?
> FYI, I'd not use ResourceContext myself unless there's a good reason a
> subresource instance can not get required contexts propagated to it from a
> parent resource - it makes things more complex IMHO :-)
>
> Cheers, Sergey
>
> On 22/07/13 19:07, Nick Khamis wrote:
>
>> Hello Everyone,
>>
>> I have the following resource running on tomcat:
>>
>> @Context
>>      ResourceContext rc;
>>
>>      Map<String, Bean> bc;
>>
>>      @POST
>>      public void init() {
>>          this.bc = new ConcurrentHashMap<String, Bean>();
>>      }
>>
>>      @GET
>>      public Collection<Bean> allBeans() {
>>          return bc.values();
>>      }
>>
>>      @GET
>>      @Path("{id}")
>>      public Bean bean(@PathParam("id") String id) {
>>          return bc.get(id);
>>      }
>>
>>      @POST
>>      public Response add(Bean bean) {
>>          if (bean != null) {
>>              bc.put(bean.getName(), bean);
>>          }
>>          final URI id = URI.create(bean.getName());
>>          return Response.created(id).build();
>>      }
>>
>>      @DELETE
>>      @Path("{id}")
>>      public void remove(@PathParam("id") String id) {
>>          bc.remove(id);
>>      }
>>
>>      @Path("/roaster/{id}")
>>      public RoasterResource roaster(){
>>          return this.rc.initResource(new RoasterResource());
>>      }
>>
>> For now I am trying to invoke the different resource using curl. Now, I am
>> trying to run:
>>
>> @Path("/roaster/{id}")
>>      public RoasterResource roaster(){
>>          return this.rc.initResource(new RoasterResource());
>>      }
>>
>> to initialize a new instance of RoasterResource however, not able to do
>> so.
>> Can someone please help me in invoking this service without getting hit
>> with "null pointer exception" please!
>>
>> Kind Regards,
>>
>> Nick.
>>
>>
>
> --
> Sergey Beryozkin
>
> Talend Community Coders
> http://coders.talend.com/
>
> Blog: http://sberyozkin.blogspot.com
>


To be honest, please don't shoot me! I am just experimenting using JAX-RS
2.0 (Jersey).
I used CXF in the past for RS, and this is why I am sending the message to
this mailing list.

I can see how ResourceContext adds cognitive complexity however, it's a
nice feature and if
I can only figure out how to get it working for me.

I am running the following example:

http://www.oracle.com/technetwork/articles/java/jaxrs20-1929352.html

If you guys don't *freak out*, and tell me to forward my message to Jersey
mailing list. I also want
to talk about Async, Filters, and Interceptors. And how we can get them
working for our services.

It's been a while, and I am trying to get back into restful service mindset.

Kind Regards,

Nick.

Reply via email to