cxf-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Sergey Beryozkin <sberyoz...@gmail.com>
Subject Re: Is it possible to add root resource classes to JAXRSServerFactoryBean after its server is created?
Date Wed, 14 Mar 2012 10:24:29 GMT
Hi Rice
On 14/03/12 05:58, Rice Yeh wrote:
> Hi,
>    Is it possible to add root resource classes to JAXRSServerFactoryBean
> after its server is created? I am running on OSGi and use blueprint. My
> requirement comes from a bundle b1 with resource classes wanting to share
> the same destination address as the main bundle b0. I don't want to enlist
> the resource classes in b1 into the b0's jaxrs:serviceBeans definition
> because b0 has to import b1 and there are so many unpredictable b1s. The
> following is an illustration of my problem:
>
> <<jaxrs:server address="/hr" id="b0">
> ...
>    <jaxrs:serviceBeans>
>      ... resource classes in b0 ...
>      .... I DO NOT WANT resource classes in b1 IS PUT HERE ...
>    </jaxrs:serviceBeans>
> </jaxrs:server>

I recall we were chatting about something like this before...
What do you think of the following:
- Have a 'master' root resource, listening on "/hr/master" (just an 
example). This root resource does nothing but manages the actual 
handlers, example:

@Path("master")
public class MasterRootResource {

    Map<String, Handler> realHandlers = new HashMap<String, Handler>();


    @POST
    @Path("id")
    void post(@PathParam("id") String id, Book book) {
        Handler handler = realHandlers.get(id);
        if (handler == null) {
            throw new WebApplicationException(400);
        }
        handler.post(book);
    }
}

where "id" represents a new 'resource' added dynamically to the 
realHandlers ?

Would that work for you ?

Cheers, Sergey

>
>
> Rice
>



Mime
View raw message