I've been playing around with a dynamic service/plugin model that I could
register with CXF that would not require any annotations (based on some of
the docs I read here:
http://cxf.apache.org/docs/jax-rs-advanced-features.html).

I started by defining a Generic Service that had a method per HTTP
operation.

public class GenericService
{
    Response get();
    Response put(Object content);
    Response post(Object content);
    Response delete();
}

Then, I was hoping I could define a list of resources in the model file,
and map each operation within each resource to one of the methods in the
generic service.

<model xmlns="http://cxf.apache.org/jaxrs";>
    <resource name="com.example.GenericService" path="bookstore">
        <operation name="get" verb="GET" path="/books"
produces="application/xml"/>
        <operation name="get" verb="GET" path="/books/{id}">
            <param name="id" type="PATH"/>
        </operation>
    </resource>
    <resource name="com.example.GenericService" path="bank">
        <operation name="get" verb="GET" path="/money"/>
        <operation name="put" verb="PUT" path="/money"
consumes="application/xml">
            <param name="content" type="REQUEST_BODY"/>
        </operation>
    </resource>
</model>

However, I ran into a couple of problems.

Based on the example above, in the bookstore resource, only the second GET
operation is registered; the first one returns 404. Also, if I try to
define another resource with a different path but using the same generic
service, the bookstore example above would return 404, and only the bank
endpoint would be available.

I'm guessing the resources are store in some sort of map, and they must be
using the same key (the resource name rather than the path).

Is there any way for me to define a generic resource/service class to
process more than one path?

Thanks,

Fitz

Reply via email to