cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From serg...@apache.org
Subject svn commit: r1052544 - in /cxf/branches/2.3.x-fixes: ./ rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/ systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/ systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/sdo/ systests/jaxrs/src/t...
Date Fri, 24 Dec 2010 18:00:14 GMT
Author: sergeyb
Date: Fri Dec 24 18:00:13 2010
New Revision: 1052544

URL: http://svn.apache.org/viewvc?rev=1052544&view=rev
Log:
Merged revisions 1052541 via svnmerge from 
https://svn.apache.org/repos/asf/cxf/trunk

........
  r1052541 | sergeyb | 2010-12-24 17:54:32 +0000 (Fri, 24 Dec 2010) | 1 line
  
  [CXF-3217] Initial support for DataBinding annotation in the JAX-RS frontend
........

Added:
    cxf/branches/2.3.x-fixes/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/sdo/SDOResource2.java
      - copied unchanged from r1052541, cxf/trunk/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/sdo/SDOResource2.java
Modified:
    cxf/branches/2.3.x-fixes/   (props changed)
    cxf/branches/2.3.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/AbstractJAXRSFactoryBean.java
    cxf/branches/2.3.x-fixes/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSDataBindingTest.java
    cxf/branches/2.3.x-fixes/systests/jaxrs/src/test/resources/jaxrs_databinding/WEB-INF/beans.xml

Propchange: cxf/branches/2.3.x-fixes/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Fri Dec 24 18:00:13 2010
@@ -1 +1 @@
-/cxf/trunk:1041183,1041790,1041993,1042346,1042571,1042724,1042805,1042821,1043225,1043229,1043902,1043907,1043954,1044085,1044238-1044305,1045024,1048915,1048919,1048930,1049078,1049426,1049937,1050005,1050021,1050095,1050102,1050113,1050156,1050165,1050280,1051115,1051613,1051790,1051792,1052338,1052516
+/cxf/trunk:1041183,1041790,1041993,1042346,1042571,1042724,1042805,1042821,1043225,1043229,1043902,1043907,1043954,1044085,1044238-1044305,1045024,1048915,1048919,1048930,1049078,1049426,1049937,1050005,1050021,1050095,1050102,1050113,1050156,1050165,1050280,1051115,1051613,1051790,1051792,1052338,1052516,1052541

Propchange: cxf/branches/2.3.x-fixes/
------------------------------------------------------------------------------
Binary property 'svnmerge-integrated' - no diff available.

Modified: cxf/branches/2.3.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/AbstractJAXRSFactoryBean.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.3.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/AbstractJAXRSFactoryBean.java?rev=1052544&r1=1052543&r2=1052544&view=diff
==============================================================================
--- cxf/branches/2.3.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/AbstractJAXRSFactoryBean.java
(original)
+++ cxf/branches/2.3.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/AbstractJAXRSFactoryBean.java
Fri Dec 24 18:00:13 2010
@@ -276,9 +276,8 @@ public class AbstractJAXRSFactoryBean ex
         if (entityProviders != null) {
             factory.setUserProviders(entityProviders); 
         }
-        if (getDataBinding() != null) {
-            setDataBindingProvider(factory, ep.getService());
-        }
+        setDataBindingProvider(factory, ep.getService());
+        
         factory.setBus(getBus());
         if (schemaLocations != null) {
             factory.setSchemaLocations(schemaLocations);
@@ -288,10 +287,25 @@ public class AbstractJAXRSFactoryBean ex
     }
 
     protected void setDataBindingProvider(ProviderFactory factory, Service s) {
+        
+        List<ClassResourceInfo> cris = serviceFactory.getRealClassResourceInfo();
+        if (getDataBinding() == null && cris.size() > 0) {
+            org.apache.cxf.annotations.DataBinding ann = 
+                cris.get(0).getServiceClass().getAnnotation(org.apache.cxf.annotations.DataBinding.class);
+            if (ann != null) {
+                try {
+                    setDataBinding(ann.value().newInstance());
+                } catch (Exception ex) {
+                    LOG.warning("DataBinding " + ann.value() + " can not be loaded");
+                }
+            }
+        }
         DataBinding db = getDataBinding();
+        if (db == null) {
+            return;
+        }
         if (db instanceof PropertiesAwareDataBinding) {
-            Map<Class<?>, Type> allClasses = ResourceUtils.getAllRequestResponseTypes(
-                                                 serviceFactory.getRealClassResourceInfo(),
false);
+            Map<Class<?>, Type> allClasses = ResourceUtils.getAllRequestResponseTypes(cris,
false);
             Map<String, Object> props = new HashMap<String, Object>();
             props.put(PropertiesAwareDataBinding.TYPES_PROPERTY, allClasses);
             ((PropertiesAwareDataBinding)db).initialize(props);

Modified: cxf/branches/2.3.x-fixes/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSDataBindingTest.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.3.x-fixes/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSDataBindingTest.java?rev=1052544&r1=1052543&r2=1052544&view=diff
==============================================================================
--- cxf/branches/2.3.x-fixes/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSDataBindingTest.java
(original)
+++ cxf/branches/2.3.x-fixes/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSDataBindingTest.java
Fri Dec 24 18:00:13 2010
@@ -71,9 +71,18 @@ public class JAXRSDataBindingTest extend
     
     @Test
     public void testSDOStructure() throws Exception {
+        doTestSDOStructure("http://localhost:" + PORT + "/databinding/sdo");
+    }
+    
+    @Test
+    public void testSDOStructureWithAnnotation() throws Exception {
+        doTestSDOStructure("http://localhost:" + PORT + "/databinding/sdo2");
+    }
+    
+    private void doTestSDOStructure(String address) throws Exception {
         JAXRSClientFactoryBean bean = new JAXRSClientFactoryBean();
         bean.setDataBinding(new SDODataBinding());
-        bean.setAddress("http://localhost:" + PORT + "/databinding/sdo");
+        bean.setAddress(address);
         bean.setResourceClass(SDOResource.class);
         SDOResource client = bean.create(SDOResource.class);
         Structure struct = client.getStructure();

Modified: cxf/branches/2.3.x-fixes/systests/jaxrs/src/test/resources/jaxrs_databinding/WEB-INF/beans.xml
URL: http://svn.apache.org/viewvc/cxf/branches/2.3.x-fixes/systests/jaxrs/src/test/resources/jaxrs_databinding/WEB-INF/beans.xml?rev=1052544&r1=1052543&r2=1052544&view=diff
==============================================================================
--- cxf/branches/2.3.x-fixes/systests/jaxrs/src/test/resources/jaxrs_databinding/WEB-INF/beans.xml
(original)
+++ cxf/branches/2.3.x-fixes/systests/jaxrs/src/test/resources/jaxrs_databinding/WEB-INF/beans.xml
Fri Dec 24 18:00:13 2010
@@ -46,6 +46,7 @@ http://cxf.apache.org/schemas/core.xsd">
   <bean class="org.apache.cxf.systest.jaxrs.BookStoreSpring" id="serviceBean"/>
   
   <bean class="org.apache.cxf.systest.jaxrs.sdo.SDOResource" id="sdoBean"/>
+  <bean class="org.apache.cxf.systest.jaxrs.sdo.SDOResource2" id="sdoBean2"/>
   
   <jaxrs:server id="jaxbbook" address="/jaxb">
     <jaxrs:serviceBeans>
@@ -83,6 +84,12 @@ http://cxf.apache.org/schemas/core.xsd">
     </jaxrs:providers>
   </jaxrs:server>
 
+  <jaxrs:server id="sdo2" address="/sdo2">
+    <jaxrs:serviceBeans>
+      <ref bean="sdoBean2" />
+    </jaxrs:serviceBeans>		   
+  </jaxrs:server>
+
   <bean id="sdoDatabinding" class="org.apache.cxf.sdo.SDODataBinding"/>
   <bean id="jsonSdoBean" class="org.apache.cxf.jaxrs.provider.DataBindingJSONProvider">
       <property name="dataBinding" ref="sdoDatabinding"/>



Mime
View raw message