You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@cxf.apache.org by "Angelo (JIRA)" <ji...@apache.org> on 2012/06/05 15:57:22 UTC
[jira] [Created] (CXF-4359)
ParameterizedType#getActualTypeArguments() classes not added to th
eJAXBContext for the providers
Angelo created CXF-4359:
---------------------------
Summary: ParameterizedType#getActualTypeArguments() classes not added to th eJAXBContext for the providers
Key: CXF-4359
URL: https://issues.apache.org/jira/browse/CXF-4359
Project: CXF
Issue Type: New Feature
Components: JAX-RS
Affects Versions: 2.6.1
Reporter: Angelo
Take a parameterized class like PageResult<T> :
--------------------------------------------------------
@XmlRootElement
@XmlAccessorType(XmlAccessType.FIELD)
public class ResultPage<T> {
private List<T> content;
public List<T> getContent() {
return content;
}
public void setContent(List<T> content) {
this.content = content;
}
}
--------------------------------------------------------
And take a service which uses this parameterized class :
--------------------------------------------------------
public interface UserService {
@GET
public PageResult<User> findUsers();
@GET
public PageResult<Role> findRoles();
}
--------------------------------------------------------
When provider create JAXBContext (eg: JSONProvider) for this interface, only PageResult class is added to the JAXBContext and we need declare the 2 classes
-------------------------------------------------------------
<bean id="jsonProvider" class="org.apache.cxf.jaxrs.provider.JSONProvider">
<property name="singleJaxbContext" value="true" />
<property name="extraClass">
<list>
<value>User</value>
<value>Role</value>
</list>
</property>
</bean>
-------------------------------------------------------------
This mean can be boring, because as soon as you add new domain class, you must modify too this declaration.
In my case I cannot use XmlSeeAlso because PageResult belongs to another Java Project (Spring Data) and it can be used with any domain classes.
To fix this problem, the JAX-RS CXF provider should populate the JAXBContext with PageResult, A and B instead of just with PageResult.
The attached patch manage this case.
--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira
[jira] [Updated] (CXF-4359)
ParameterizedType#getActualTypeArguments() classes not added to the
JAXBContext for JAX-RS providers
Posted by "Angelo (JIRA)" <ji...@apache.org>.
[ https://issues.apache.org/jira/browse/CXF-4359?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Angelo updated CXF-4359:
------------------------
Summary: ParameterizedType#getActualTypeArguments() classes not added to the JAXBContext for JAX-RS providers (was: ParameterizedType#getActualTypeArguments() classes not added to th eJAXBContext for the providers)
> ParameterizedType#getActualTypeArguments() classes not added to the JAXBContext for JAX-RS providers
> ----------------------------------------------------------------------------------------------------
>
> Key: CXF-4359
> URL: https://issues.apache.org/jira/browse/CXF-4359
> Project: CXF
> Issue Type: New Feature
> Components: JAX-RS
> Affects Versions: 2.6.1
> Reporter: Angelo
>
> Take a parameterized class like PageResult<T> :
> --------------------------------------------------------
> @XmlRootElement
> @XmlAccessorType(XmlAccessType.FIELD)
> public class ResultPage<T> {
> private List<T> content;
> public List<T> getContent() {
> return content;
> }
>
> public void setContent(List<T> content) {
> this.content = content;
> }
> }
> --------------------------------------------------------
> And take a service which uses this parameterized class :
> --------------------------------------------------------
> public interface UserService {
> @GET
> public PageResult<User> findUsers();
> @GET
> public PageResult<Role> findRoles();
> }
> --------------------------------------------------------
> When provider create JAXBContext (eg: JSONProvider) for this interface, only PageResult class is added to the JAXBContext and we need declare the 2 classes
> -------------------------------------------------------------
> <bean id="jsonProvider" class="org.apache.cxf.jaxrs.provider.JSONProvider">
> <property name="singleJaxbContext" value="true" />
> <property name="extraClass">
> <list>
> <value>User</value>
> <value>Role</value>
> </list>
> </property>
> </bean>
> -------------------------------------------------------------
> This mean can be boring, because as soon as you add new domain class, you must modify too this declaration.
> In my case I cannot use XmlSeeAlso because PageResult belongs to another Java Project (Spring Data) and it can be used with any domain classes.
> To fix this problem, the JAX-RS CXF provider should populate the JAXBContext with PageResult, A and B instead of just with PageResult.
> The attached patch manage this case.
--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira
[jira] [Commented] (CXF-4359)
ParameterizedType#getActualTypeArguments() classes not added to the
JAXBContext for JAX-RS providers
Posted by "Angelo (JIRA)" <ji...@apache.org>.
[ https://issues.apache.org/jira/browse/CXF-4359?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13395464#comment-13395464 ]
Angelo commented on CXF-4359:
-----------------------------
Hi Sergey,
I'm happy that this patch seems to please to you.
> I'm concerned of introducing some instability by having a fairly rare use case supported (where JAXBContext is re-created dynamically)
I understand. I find it' sham ethat's it not possible to add some classes to JAXBContext.
> why only do it for parameterized types, should we simply have a single context for all the classes, etc.
perhaps. This patch that I have developped manages my need, but I think it could be improved and perhepas this logic can be used too for JAX-WS?
> his property still has to be set
I understand your choice. We must experiment this patch and in the future if it works like a sharm, singleJaxbContext could be activated by default.
> but at least you won't have to specify the list of extra classes
Yes, for our project, it will help us a lot:)
> ParameterizedType#getActualTypeArguments() classes not added to the JAXBContext for JAX-RS providers
> ----------------------------------------------------------------------------------------------------
>
> Key: CXF-4359
> URL: https://issues.apache.org/jira/browse/CXF-4359
> Project: CXF
> Issue Type: New Feature
> Components: JAX-RS
> Affects Versions: 2.6.1
> Reporter: Angelo
> Assignee: Sergey Beryozkin
> Attachments: cxf-patch.txt, src.zip
>
>
> Take a parameterized class like PageResult<T> :
> --------------------------------------------------------
> @XmlRootElement
> @XmlAccessorType(XmlAccessType.FIELD)
> public class ResultPage<T> {
> private List<T> content;
> public List<T> getContent() {
> return content;
> }
>
> public void setContent(List<T> content) {
> this.content = content;
> }
> }
> --------------------------------------------------------
> And take a service which uses this parameterized class :
> --------------------------------------------------------
> public interface UserService {
> @GET
> public PageResult<User> findUsers();
> @GET
> public PageResult<Role> findRoles();
> }
> --------------------------------------------------------
> When provider create JAXBContext (eg: JSONProvider) for this interface, only PageResult class is added to the JAXBContext and we need declare the 2 classes
> -------------------------------------------------------------
> <bean id="jsonProvider" class="org.apache.cxf.jaxrs.provider.JSONProvider">
> <property name="singleJaxbContext" value="true" />
> <property name="extraClass">
> <list>
> <value>User</value>
> <value>Role</value>
> </list>
> </property>
> </bean>
> -------------------------------------------------------------
> This mean can be boring, because as soon as you add new domain class, you must modify too this declaration.
> In my case I cannot use XmlSeeAlso because PageResult belongs to another Java Project (Spring Data) and it can be used with any domain classes.
> To fix this problem, the JAX-RS CXF provider should populate the JAXBContext with PageResult, A and B instead of just with PageResult.
> The attached patch manage this case.
--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira
[jira] [Assigned] (CXF-4359)
ParameterizedType#getActualTypeArguments() classes not added to the
JAXBContext for JAX-RS providers
Posted by "Sergey Beryozkin (JIRA)" <ji...@apache.org>.
[ https://issues.apache.org/jira/browse/CXF-4359?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Sergey Beryozkin reassigned CXF-4359:
-------------------------------------
Assignee: Sergey Beryozkin
> ParameterizedType#getActualTypeArguments() classes not added to the JAXBContext for JAX-RS providers
> ----------------------------------------------------------------------------------------------------
>
> Key: CXF-4359
> URL: https://issues.apache.org/jira/browse/CXF-4359
> Project: CXF
> Issue Type: New Feature
> Components: JAX-RS
> Affects Versions: 2.6.1
> Reporter: Angelo
> Assignee: Sergey Beryozkin
> Attachments: cxf-patch.txt, src.zip
>
>
> Take a parameterized class like PageResult<T> :
> --------------------------------------------------------
> @XmlRootElement
> @XmlAccessorType(XmlAccessType.FIELD)
> public class ResultPage<T> {
> private List<T> content;
> public List<T> getContent() {
> return content;
> }
>
> public void setContent(List<T> content) {
> this.content = content;
> }
> }
> --------------------------------------------------------
> And take a service which uses this parameterized class :
> --------------------------------------------------------
> public interface UserService {
> @GET
> public PageResult<User> findUsers();
> @GET
> public PageResult<Role> findRoles();
> }
> --------------------------------------------------------
> When provider create JAXBContext (eg: JSONProvider) for this interface, only PageResult class is added to the JAXBContext and we need declare the 2 classes
> -------------------------------------------------------------
> <bean id="jsonProvider" class="org.apache.cxf.jaxrs.provider.JSONProvider">
> <property name="singleJaxbContext" value="true" />
> <property name="extraClass">
> <list>
> <value>User</value>
> <value>Role</value>
> </list>
> </property>
> </bean>
> -------------------------------------------------------------
> This mean can be boring, because as soon as you add new domain class, you must modify too this declaration.
> In my case I cannot use XmlSeeAlso because PageResult belongs to another Java Project (Spring Data) and it can be used with any domain classes.
> To fix this problem, the JAX-RS CXF provider should populate the JAXBContext with PageResult, A and B instead of just with PageResult.
> The attached patch manage this case.
--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira
[jira] [Updated] (CXF-4359)
ParameterizedType#getActualTypeArguments() classes not added to the
JAXBContext for JAX-RS providers
Posted by "Angelo (JIRA)" <ji...@apache.org>.
[ https://issues.apache.org/jira/browse/CXF-4359?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Angelo updated CXF-4359:
------------------------
Description:
Take a parameterized class like PageResult<T> :
--------------------------------------------------------
@XmlRootElement
@XmlAccessorType(XmlAccessType.FIELD)
public class ResultPage<T> {
private List<T> content;
public List<T> getContent() {
return content;
}
public void setContent(List<T> content) {
this.content = content;
}
}
--------------------------------------------------------
And take a service which uses this parameterized class :
--------------------------------------------------------
public interface UserService {
@GET
public PageResult<User> findUsers();
@GET
public PageResult<Role> findRoles();
}
--------------------------------------------------------
When provider create JAXBContext (eg: JSONProvider) for this interface, only PageResult class is added to the JAXBContext and we need declare the 2 classes
-------------------------------------------------------------
<bean id="jsonProvider" class="org.apache.cxf.jaxrs.provider.JSONProvider">
<property name="singleJaxbContext" value="true" />
<property name="extraClass">
<list>
<value>User</value>
<value>Role</value>
</list>
</property>
</bean>
-------------------------------------------------------------
This mean can be boring, because as soon as you add new domain class, you must modify too this declaration.
In my case I cannot use XmlSeeAlso because PageResult belongs to another Java Project (Spring Data) and it can be used with any domain classes.
To fix this problem, the JAX-RS CXF provider should populate the JAXBContext with PageResult, A and B instead of just with PageResult.
The attached patch manage this case.
was:
Take a parameterized class like PageResult<T> :
--------------------------------------------------------
@XmlRootElement
@XmlAccessorType(XmlAccessType.FIELD)
public class ResultPage<T> {
private List<T> content;
public List<T> getContent() {
return content;
}
public void setContent(List<T> content) {
this.content = content;
}
}
--------------------------------------------------------
And take a service which uses this parameterized class :
--------------------------------------------------------
public interface UserService {
@GET
public PageResult<User> findUsers();
@GET
public PageResult<Role> findRoles();
}
--------------------------------------------------------
When provider create JAXBContext (eg: JSONProvider) for this interface, only PageResult class is added to the JAXBContext and we need declare the 2 classes
-------------------------------------------------------------
<bean id="jsonProvider" class="org.apache.cxf.jaxrs.provider.JSONProvider">
<property name="singleJaxbContext" value="true" />
<property name="extraClass">
<list>
<value>User</value>
<value>Role</value>
</list>
</property>
</bean>
-------------------------------------------------------------
This mean can be boring, because as soon as you add new domain class, you must modify too this declaration.
In my case I cannot use XmlSeeAlso because PageResult belongs to another Java Project (Spring Data) and it can be used with any domain classes.
To fix this problem, the JAX-RS CXF provider should populate the JAXBContext with PageResult, A and B instead of just with PageResult.
The attached patch manage this case.
> ParameterizedType#getActualTypeArguments() classes not added to the JAXBContext for JAX-RS providers
> ----------------------------------------------------------------------------------------------------
>
> Key: CXF-4359
> URL: https://issues.apache.org/jira/browse/CXF-4359
> Project: CXF
> Issue Type: New Feature
> Components: JAX-RS
> Affects Versions: 2.6.1
> Reporter: Angelo
>
> Take a parameterized class like PageResult<T> :
> --------------------------------------------------------
> @XmlRootElement
> @XmlAccessorType(XmlAccessType.FIELD)
> public class ResultPage<T> {
> private List<T> content;
> public List<T> getContent() {
> return content;
> }
>
> public void setContent(List<T> content) {
> this.content = content;
> }
> }
> --------------------------------------------------------
> And take a service which uses this parameterized class :
> --------------------------------------------------------
> public interface UserService {
> @GET
> public PageResult<User> findUsers();
> @GET
> public PageResult<Role> findRoles();
> }
> --------------------------------------------------------
> When provider create JAXBContext (eg: JSONProvider) for this interface, only PageResult class is added to the JAXBContext and we need declare the 2 classes
> -------------------------------------------------------------
> <bean id="jsonProvider" class="org.apache.cxf.jaxrs.provider.JSONProvider">
> <property name="singleJaxbContext" value="true" />
> <property name="extraClass">
> <list>
> <value>User</value>
> <value>Role</value>
> </list>
> </property>
> </bean>
> -------------------------------------------------------------
> This mean can be boring, because as soon as you add new domain class, you must modify too this declaration.
> In my case I cannot use XmlSeeAlso because PageResult belongs to another Java Project (Spring Data) and it can be used with any domain classes.
> To fix this problem, the JAX-RS CXF provider should populate the JAXBContext with PageResult, A and B instead of just with PageResult.
> The attached patch manage this case.
--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira
[jira] [Commented] (CXF-4359)
ParameterizedType#getActualTypeArguments() classes not added to the
JAXBContext for JAX-RS providers
Posted by "Sergey Beryozkin (JIRA)" <ji...@apache.org>.
[ https://issues.apache.org/jira/browse/CXF-4359?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13393572#comment-13393572 ]
Sergey Beryozkin commented on CXF-4359:
---------------------------------------
Hi Angelo, I have a code ready to be committed. I'm coming to the conclusion that at the moment it will be simpler to support this feature only if a 'singleJaxbContext' property is set. The patch is technically very good but I'm concerned of introducing some instability by having a fairly rare use case supported (where JAXBContext is re-created dynamically): the question then is, why only do it for parameterized types, should we simply have a single context for all the classes, etc.
Right now, the 'protection' of 'singleJaxbContext' will let us experiment a bit with adding the types derived from Parameterized types to a single JAXB context. That can be expanded in the future. This property still has to be set :-), but at least you won't have to specify the list of extra classes
> ParameterizedType#getActualTypeArguments() classes not added to the JAXBContext for JAX-RS providers
> ----------------------------------------------------------------------------------------------------
>
> Key: CXF-4359
> URL: https://issues.apache.org/jira/browse/CXF-4359
> Project: CXF
> Issue Type: New Feature
> Components: JAX-RS
> Affects Versions: 2.6.1
> Reporter: Angelo
> Assignee: Sergey Beryozkin
> Attachments: cxf-patch.txt, src.zip
>
>
> Take a parameterized class like PageResult<T> :
> --------------------------------------------------------
> @XmlRootElement
> @XmlAccessorType(XmlAccessType.FIELD)
> public class ResultPage<T> {
> private List<T> content;
> public List<T> getContent() {
> return content;
> }
>
> public void setContent(List<T> content) {
> this.content = content;
> }
> }
> --------------------------------------------------------
> And take a service which uses this parameterized class :
> --------------------------------------------------------
> public interface UserService {
> @GET
> public PageResult<User> findUsers();
> @GET
> public PageResult<Role> findRoles();
> }
> --------------------------------------------------------
> When provider create JAXBContext (eg: JSONProvider) for this interface, only PageResult class is added to the JAXBContext and we need declare the 2 classes
> -------------------------------------------------------------
> <bean id="jsonProvider" class="org.apache.cxf.jaxrs.provider.JSONProvider">
> <property name="singleJaxbContext" value="true" />
> <property name="extraClass">
> <list>
> <value>User</value>
> <value>Role</value>
> </list>
> </property>
> </bean>
> -------------------------------------------------------------
> This mean can be boring, because as soon as you add new domain class, you must modify too this declaration.
> In my case I cannot use XmlSeeAlso because PageResult belongs to another Java Project (Spring Data) and it can be used with any domain classes.
> To fix this problem, the JAX-RS CXF provider should populate the JAXBContext with PageResult, A and B instead of just with PageResult.
> The attached patch manage this case.
--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira
[jira] [Resolved] (CXF-4359)
ParameterizedType#getActualTypeArguments() classes not added to the
JAXBContext for JAX-RS providers
Posted by "Sergey Beryozkin (JIRA)" <ji...@apache.org>.
[ https://issues.apache.org/jira/browse/CXF-4359?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Sergey Beryozkin resolved CXF-4359.
-----------------------------------
Resolution: Fixed
Fix Version/s: 2.7.0
2.6.2
2.5.5
> ParameterizedType#getActualTypeArguments() classes not added to the JAXBContext for JAX-RS providers
> ----------------------------------------------------------------------------------------------------
>
> Key: CXF-4359
> URL: https://issues.apache.org/jira/browse/CXF-4359
> Project: CXF
> Issue Type: New Feature
> Components: JAX-RS
> Affects Versions: 2.6.1
> Reporter: Angelo
> Assignee: Sergey Beryozkin
> Fix For: 2.5.5, 2.6.2, 2.7.0
>
> Attachments: cxf-patch.txt, src.zip
>
>
> Take a parameterized class like PageResult<T> :
> --------------------------------------------------------
> @XmlRootElement
> @XmlAccessorType(XmlAccessType.FIELD)
> public class ResultPage<T> {
> private List<T> content;
> public List<T> getContent() {
> return content;
> }
>
> public void setContent(List<T> content) {
> this.content = content;
> }
> }
> --------------------------------------------------------
> And take a service which uses this parameterized class :
> --------------------------------------------------------
> public interface UserService {
> @GET
> public PageResult<User> findUsers();
> @GET
> public PageResult<Role> findRoles();
> }
> --------------------------------------------------------
> When provider create JAXBContext (eg: JSONProvider) for this interface, only PageResult class is added to the JAXBContext and we need declare the 2 classes
> -------------------------------------------------------------
> <bean id="jsonProvider" class="org.apache.cxf.jaxrs.provider.JSONProvider">
> <property name="singleJaxbContext" value="true" />
> <property name="extraClass">
> <list>
> <value>User</value>
> <value>Role</value>
> </list>
> </property>
> </bean>
> -------------------------------------------------------------
> This mean can be boring, because as soon as you add new domain class, you must modify too this declaration.
> In my case I cannot use XmlSeeAlso because PageResult belongs to another Java Project (Spring Data) and it can be used with any domain classes.
> To fix this problem, the JAX-RS CXF provider should populate the JAXBContext with PageResult, A and B instead of just with PageResult.
> The attached patch manage this case.
--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira
[jira] [Updated] (CXF-4359)
ParameterizedType#getActualTypeArguments() classes not added to the
JAXBContext for JAX-RS providers
Posted by "Angelo (JIRA)" <ji...@apache.org>.
[ https://issues.apache.org/jira/browse/CXF-4359?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Angelo updated CXF-4359:
------------------------
Attachment: cxf-patch.txt
Here a SVN Patch to manage parameterized classes. Every code is commented but if you have question don't hesitate to tell me.
> ParameterizedType#getActualTypeArguments() classes not added to the JAXBContext for JAX-RS providers
> ----------------------------------------------------------------------------------------------------
>
> Key: CXF-4359
> URL: https://issues.apache.org/jira/browse/CXF-4359
> Project: CXF
> Issue Type: New Feature
> Components: JAX-RS
> Affects Versions: 2.6.1
> Reporter: Angelo
> Attachments: cxf-patch.txt
>
>
> Take a parameterized class like PageResult<T> :
> --------------------------------------------------------
> @XmlRootElement
> @XmlAccessorType(XmlAccessType.FIELD)
> public class ResultPage<T> {
> private List<T> content;
> public List<T> getContent() {
> return content;
> }
>
> public void setContent(List<T> content) {
> this.content = content;
> }
> }
> --------------------------------------------------------
> And take a service which uses this parameterized class :
> --------------------------------------------------------
> public interface UserService {
> @GET
> public PageResult<User> findUsers();
> @GET
> public PageResult<Role> findRoles();
> }
> --------------------------------------------------------
> When provider create JAXBContext (eg: JSONProvider) for this interface, only PageResult class is added to the JAXBContext and we need declare the 2 classes
> -------------------------------------------------------------
> <bean id="jsonProvider" class="org.apache.cxf.jaxrs.provider.JSONProvider">
> <property name="singleJaxbContext" value="true" />
> <property name="extraClass">
> <list>
> <value>User</value>
> <value>Role</value>
> </list>
> </property>
> </bean>
> -------------------------------------------------------------
> This mean can be boring, because as soon as you add new domain class, you must modify too this declaration.
> In my case I cannot use XmlSeeAlso because PageResult belongs to another Java Project (Spring Data) and it can be used with any domain classes.
> To fix this problem, the JAX-RS CXF provider should populate the JAXBContext with PageResult, A and B instead of just with PageResult.
> The attached patch manage this case.
--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira
[jira] [Updated] (CXF-4359)
ParameterizedType#getActualTypeArguments() classes not added to the
JAXBContext for JAX-RS providers
Posted by "Angelo (JIRA)" <ji...@apache.org>.
[ https://issues.apache.org/jira/browse/CXF-4359?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Angelo updated CXF-4359:
------------------------
Attachment: src.zip
JUnit with JSONProvider to test case with Parameterized class PageResult<User>, PageResult<Role> which populate JAXBContext with User, Role and PageResult (instead of just PageResult).
> ParameterizedType#getActualTypeArguments() classes not added to the JAXBContext for JAX-RS providers
> ----------------------------------------------------------------------------------------------------
>
> Key: CXF-4359
> URL: https://issues.apache.org/jira/browse/CXF-4359
> Project: CXF
> Issue Type: New Feature
> Components: JAX-RS
> Affects Versions: 2.6.1
> Reporter: Angelo
> Attachments: cxf-patch.txt, src.zip
>
>
> Take a parameterized class like PageResult<T> :
> --------------------------------------------------------
> @XmlRootElement
> @XmlAccessorType(XmlAccessType.FIELD)
> public class ResultPage<T> {
> private List<T> content;
> public List<T> getContent() {
> return content;
> }
>
> public void setContent(List<T> content) {
> this.content = content;
> }
> }
> --------------------------------------------------------
> And take a service which uses this parameterized class :
> --------------------------------------------------------
> public interface UserService {
> @GET
> public PageResult<User> findUsers();
> @GET
> public PageResult<Role> findRoles();
> }
> --------------------------------------------------------
> When provider create JAXBContext (eg: JSONProvider) for this interface, only PageResult class is added to the JAXBContext and we need declare the 2 classes
> -------------------------------------------------------------
> <bean id="jsonProvider" class="org.apache.cxf.jaxrs.provider.JSONProvider">
> <property name="singleJaxbContext" value="true" />
> <property name="extraClass">
> <list>
> <value>User</value>
> <value>Role</value>
> </list>
> </property>
> </bean>
> -------------------------------------------------------------
> This mean can be boring, because as soon as you add new domain class, you must modify too this declaration.
> In my case I cannot use XmlSeeAlso because PageResult belongs to another Java Project (Spring Data) and it can be used with any domain classes.
> To fix this problem, the JAX-RS CXF provider should populate the JAXBContext with PageResult, A and B instead of just with PageResult.
> The attached patch manage this case.
--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira