You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cxf.apache.org by crmuchin <cm...@initiatesystems.com> on 2009/03/31 04:39:53 UTC

[JAX-RS] Nested parameter injection into a bean

I would like to leverage the CXF extension for parameter injection into a
bean, however my bean structure is more than 1 level deep. Take the
following example:

class Name
{
    String first;
    String last;
}

class Address
{
    String city;
    String state;
}

class Person
{
    Name legalName;
    Address homeAddr;
    String race;
    String sex;
    Date birthDate;
}

class MyService
{
    @GET
    @Path("/getPerson")
    Person getPerson(@QueryParam("") Person person);
}

I would like to be able to pass something like:

/getPerson?sex=M&legalName.first=John&legalName.last=Doe&homeAddr.city=Reno&homeAddr.state=NV

This example is simplified somewhat, in a real world scenario there would be
many more fields and subfields, making it impractical to cover all
combinations with path or named parameters. Does this capability already
exist and I'm just not finding it, or would this be a useful feature that
the product might benefit from?

Any suggestions or feedback would be greatly appreciated.

Thanks,
Craig M.
-- 
View this message in context: http://www.nabble.com/-JAX-RS--Nested-parameter-injection-into-a-bean-tp22797243p22797243.html
Sent from the cxf-user mailing list archive at Nabble.com.


Re: [JAX-RS] Nested parameter injection into a bean

Posted by crmuchin <cm...@initiatesystems.com>.
For those interested, I have opened a JIRA issue with a patch 
https://issues.apache.org/jira/browse/CXF-2153
https://issues.apache.org/jira/browse/CXF-2153 

Thanks,
Craig M.


Sergey Beryozkin-2 wrote:
> 
> Hi
> 
> I think it's an interesting idea, bean properties have no '.' thus using a
> '.' as an indicator should work. The procedure in charge 
> of handling this extension will become more complicated, possibly
> recursive, but it looks like it's quite realistic to make it 
> support queries with nested parameters...
> I'm not sure though when exactly I will be able to look into it - the
> immediate priorities at the moment are to fix the reported 
> bugs, support constructor-based injection and do TCK, but I might be able
> to do this enhancement sooner rather than later. A patch 
> would be welcome too...
> 
> cheers, Sergey
> 
>> I would like to leverage the CXF extension for parameter injection into a
>> bean, however my bean structure is more than 1 level deep. Take the
>> following example:
>>
>> class Name
>> {
>>    String first;
>>    String last;
>> }
>>
>> class Address
>> {
>>    String city;
>>    String state;
>> }
>>
>> class Person
>> {
>>    Name legalName;
>>    Address homeAddr;
>>    String race;
>>    String sex;
>>    Date birthDate;
>> }
>>
>> class MyService
>> {
>>    @GET
>>    @Path("/getPerson")
>>    Person getPerson(@QueryParam("") Person person);
>> }
>>
>> I would like to be able to pass something like:
>>
>> /getPerson?sex=M&legalName.first=John&legalName.last=Doe&homeAddr.city=Reno&homeAddr.state=NV
>>
>> This example is simplified somewhat, in a real world scenario there would
>> be
>> many more fields and subfields, making it impractical to cover all
>> combinations with path or named parameters. Does this capability already
>> exist and I'm just not finding it, or would this be a useful feature that
>> the product might benefit from?
>>
>> Any suggestions or feedback would be greatly appreciated.
>>
>> Thanks,
>> Craig M.
>> -- 
>> View this message in context:
>> http://www.nabble.com/-JAX-RS--Nested-parameter-injection-into-a-bean-tp22797243p22797243.html
>> Sent from the cxf-user mailing list archive at Nabble.com.
>> 
> 
> 
> 

-- 
View this message in context: http://www.nabble.com/-JAX-RS--Nested-parameter-injection-into-a-bean-tp22797243p22873366.html
Sent from the cxf-user mailing list archive at Nabble.com.


Re: [JAX-RS] Nested parameter injection into a bean

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

I think it's an interesting idea, bean properties have no '.' thus using a '.' as an indicator should work. The procedure in charge 
of handling this extension will become more complicated, possibly recursive, but it looks like it's quite realistic to make it 
support queries with nested parameters...
I'm not sure though when exactly I will be able to look into it - the immediate priorities at the moment are to fix the reported 
bugs, support constructor-based injection and do TCK, but I might be able to do this enhancement sooner rather than later. A patch 
would be welcome too...

cheers, Sergey

> I would like to leverage the CXF extension for parameter injection into a
> bean, however my bean structure is more than 1 level deep. Take the
> following example:
>
> class Name
> {
>    String first;
>    String last;
> }
>
> class Address
> {
>    String city;
>    String state;
> }
>
> class Person
> {
>    Name legalName;
>    Address homeAddr;
>    String race;
>    String sex;
>    Date birthDate;
> }
>
> class MyService
> {
>    @GET
>    @Path("/getPerson")
>    Person getPerson(@QueryParam("") Person person);
> }
>
> I would like to be able to pass something like:
>
> /getPerson?sex=M&legalName.first=John&legalName.last=Doe&homeAddr.city=Reno&homeAddr.state=NV
>
> This example is simplified somewhat, in a real world scenario there would be
> many more fields and subfields, making it impractical to cover all
> combinations with path or named parameters. Does this capability already
> exist and I'm just not finding it, or would this be a useful feature that
> the product might benefit from?
>
> Any suggestions or feedback would be greatly appreciated.
>
> Thanks,
> Craig M.
> -- 
> View this message in context: http://www.nabble.com/-JAX-RS--Nested-parameter-injection-into-a-bean-tp22797243p22797243.html
> Sent from the cxf-user mailing list archive at Nabble.com.
>