You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cxf.apache.org by Maleldil <ge...@gmail.com> on 2008/10/22 21:57:47 UTC

Configuration of multiple jaxrs:server elements

I am attempting to create a RESTful web service using CXF.  I have everything
set up as far as Spring goes, and have no problem when using a single
<jaxrs:server> element.  The following example works fine:

<jaxrs:server id="tripMgmtServiceRest" address="/">
    <jaxrs:serviceBeans>
        <ref bean="tripManagementService"/>
    </jaxrs:serviceBeans>
    <jaxrs:providers>
        <ref bean="jsonProvider"/>
    </jaxrs:providers>
</jaxrs:server>

But if I do the following:

<jaxrs:server id="tripMgmtServiceRest" address="/">
    <jaxrs:serviceBeans>
        <ref bean="tripManagementService"/>
        <ref bean="pointOfInterestService"/>
    </jaxrs:serviceBeans>
    <jaxrs:providers>
        <ref bean="jsonProvider"/>
    </jaxrs:providers>
</jaxrs:server>

Then only the tripManagementService actually works, and the
pointOfInterestService does not.  If I put the pointOfInterestService above
the tripManagementService then it will work.  Is this not supported?  I
don't want to have to put all of my REST methods in one class.
-- 
View this message in context: http://www.nabble.com/Configuration-of-multiple-jaxrs%3Aserver-elements-tp20118540p20118540.html
Sent from the cxf-user mailing list archive at Nabble.com.


RE: Configuration of multiple jaxrs:server elements

Posted by Maleldil <ge...@gmail.com>.


Sergey Beryozkin-2 wrote:
> 
> Hi
> 
> Lets assume tripManagementService bean refers to
> 
> @Path("/")
> class TripManagementService {}
> 
> while pointOfInterestService bean refers to
> 
> @Path("/")
> class PointOfInterestService {}
> 
> As you can see if both classes have the same root Path value then
> there's no way for the JAX-RS runtime to decide upfront which class will
> further handle the request. 
> First, the root resource class is selected, next that and only that
> class is
> checked further.
> 
> If you do something like  
> 
> @Path("/trip")
> class TripManagementService {
> 
> }
> 
> @Path("/trip/")
> class PointOfInterestService {
> }
> 
> then all request URIs ending with /trip will get delivered to
> TripManagementService, and all ending with /trip/ or trip/* - to
> PointOfInterestService.
> 
> Or you can do
> 
> @Path("/trip/manage")
> class TripManagementService {
> 
> }
> 
> @Path("/trip/interest")
> class PointOfInterestService {
> } 
> 
> In principle we may try to handle the case with all the root resource
> classes having the same Path like ("/"). If we don't find a match on the
> first selected class then we can try the next class. It won't be JAX-RS
> compatible AFAIK but we can try to do it anyway (provided, say, if a
> user explicitly allowed for it through some new jaxrs:server attribute).
> I'll keep it in mind.
> 
> For now, root Path expressions should be unique...
> 
> Hope it helps
> Sergey
> 
> -----Original Message-----
> From: Maleldil [mailto:geoff.sallee@gmail.com] 
> Sent: 22 October 2008 20:58
> To: users@cxf.apache.org
> Subject: Configuration of multiple jaxrs:server elements
> 
> 
> I am attempting to create a RESTful web service using CXF.  I have
> everything
> set up as far as Spring goes, and have no problem when using a single
> <jaxrs:server> element.  The following example works fine:
> 
> <jaxrs:server id="tripMgmtServiceRest" address="/">
>     <jaxrs:serviceBeans>
>         <ref bean="tripManagementService"/>
>     </jaxrs:serviceBeans>
>     <jaxrs:providers>
>         <ref bean="jsonProvider"/>
>     </jaxrs:providers>
> </jaxrs:server>
> 
> But if I do the following:
> 
> <jaxrs:server id="tripMgmtServiceRest" address="/">
>     <jaxrs:serviceBeans>
>         <ref bean="tripManagementService "/>
>         <ref bean="pointOfInterestService"/>
>     </jaxrs:serviceBeans>
>     <jaxrs:providers>
>         <ref bean="jsonProvider"/>
>     </jaxrs:providers>
> </jaxrs:server>
> 
> Then only the tripManagementService actually works, and the
> pointOfInterestService does not.  If I put the pointOfInterestService
> above
> the tripManagementService then it will work.  Is this not supported?  I
> don't want to have to put all of my REST methods in one class.
> -- 
> View this message in context:
> http://www.nabble.com/Configuration-of-multiple-jaxrs%3Aserver-elements-
> tp20118540p20118540.html
> Sent from the cxf-user mailing list archive at Nabble.com.
> 
> 
> 


I think I understand.  Thank you for that clarification.
-- 
View this message in context: http://www.nabble.com/Configuration-of-multiple-jaxrs%3Aserver-elements-tp20118540p20120179.html
Sent from the cxf-user mailing list archive at Nabble.com.


RE: Configuration of multiple jaxrs:server elements

Posted by Sergey Beryozkin <sb...@progress.com>.
Hi

Lets assume tripManagementService bean refers to

@Path("/")
class TripManagementService {}

while pointOfInterestService bean refers to

@Path("/")
class PointOfInterestService {}

As you can see if both classes have the same root Path value then
there's no way for the JAX-RS runtime to decide upfront which class will
further handle the request. 
First, the root resource class is selected, next that and only that
class is
checked further.

If you do something like  

@Path("/trip")
class TripManagementService {

}

@Path("/trip/")
class PointOfInterestService {
}

then all request URIs ending with /trip will get delivered to
TripManagementService, and all ending with /trip/ or trip/* - to
PointOfInterestService.

Or you can do

@Path("/trip/manage")
class TripManagementService {

}

@Path("/trip/interest")
class PointOfInterestService {
} 

In principle we may try to handle the case with all the root resource
classes having the same Path like ("/"). If we don't find a match on the
first selected class then we can try the next class. It won't be JAX-RS
compatible AFAIK but we can try to do it anyway (provided, say, if a
user explicitly allowed for it through some new jaxrs:server attribute).
I'll keep it in mind.

For now, root Path expressions should be unique...

Hope it helps
Sergey

-----Original Message-----
From: Maleldil [mailto:geoff.sallee@gmail.com] 
Sent: 22 October 2008 20:58
To: users@cxf.apache.org
Subject: Configuration of multiple jaxrs:server elements


I am attempting to create a RESTful web service using CXF.  I have
everything
set up as far as Spring goes, and have no problem when using a single
<jaxrs:server> element.  The following example works fine:

<jaxrs:server id="tripMgmtServiceRest" address="/">
    <jaxrs:serviceBeans>
        <ref bean="tripManagementService"/>
    </jaxrs:serviceBeans>
    <jaxrs:providers>
        <ref bean="jsonProvider"/>
    </jaxrs:providers>
</jaxrs:server>

But if I do the following:

<jaxrs:server id="tripMgmtServiceRest" address="/">
    <jaxrs:serviceBeans>
        <ref bean="tripManagementService "/>
        <ref bean="pointOfInterestService"/>
    </jaxrs:serviceBeans>
    <jaxrs:providers>
        <ref bean="jsonProvider"/>
    </jaxrs:providers>
</jaxrs:server>

Then only the tripManagementService actually works, and the
pointOfInterestService does not.  If I put the pointOfInterestService
above
the tripManagementService then it will work.  Is this not supported?  I
don't want to have to put all of my REST methods in one class.
-- 
View this message in context:
http://www.nabble.com/Configuration-of-multiple-jaxrs%3Aserver-elements-
tp20118540p20118540.html
Sent from the cxf-user mailing list archive at Nabble.com.