You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cxf.apache.org by re...@apache.org on 2021/06/02 00:34:56 UTC

[cxf] branch 3.3.x-fixes updated (3fd2172 -> 59201ec)

This is an automated email from the ASF dual-hosted git repository.

reta pushed a change to branch 3.3.x-fixes
in repository https://gitbox.apache.org/repos/asf/cxf.git.


    from 3fd2172  [CXF-8546]introduce a property so that we can configure writeOptionalTypeParameters
     new 6328f90  CXF-8532: @Priority support for ParamConverterProvider (#807)
     new 59201ec  Recording .gitmergeinfo Changes

The 2 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 .gitmergeinfo                                      |  4 ++
 .../apache/cxf/jaxrs/provider/ProviderFactory.java | 33 +++++++++++++++-
 ....java => PriorityCustomerParameterHandler.java} |  5 ++-
 .../cxf/jaxrs/provider/ProviderFactoryTest.java    | 45 ++++++++++++++++++++++
 .../jaxrs/client/ClientProviderFactoryTest.java    | 40 +++++++++----------
 .../java/org/apache/cxf/jaxrs/client/Customer.java |  9 +++--
 .../jaxrs/client}/CustomerParameterHandler.java    |  2 +-
 .../client/PriorityCustomerParameterHandler.java}  |  7 +++-
 8 files changed, 116 insertions(+), 29 deletions(-)
 copy rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/{CustomerParameterHandler.java => PriorityCustomerParameterHandler.java} (88%)
 copy distribution/src/main/release/samples/jaxws_graalvm_dynamic/client/src/main/java/demo/jaxws/client/ClientCapture.java => rt/rs/client/src/test/java/org/apache/cxf/jaxrs/client/ClientProviderFactoryTest.java (51%)
 copy distribution/src/main/release/samples/aegis_standalone/src/main/java/org/apache/cxf/demo/aegis/types/Animal.java => rt/rs/client/src/test/java/org/apache/cxf/jaxrs/client/Customer.java (93%)
 copy rt/{frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs => rs/client/src/test/java/org/apache/cxf/jaxrs/client}/CustomerParameterHandler.java (97%)
 copy rt/{frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/CustomerParameterHandler.java => rs/client/src/test/java/org/apache/cxf/jaxrs/client/PriorityCustomerParameterHandler.java} (86%)

[cxf] 01/02: CXF-8532: @Priority support for ParamConverterProvider (#807)

Posted by re...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

reta pushed a commit to branch 3.3.x-fixes
in repository https://gitbox.apache.org/repos/asf/cxf.git

commit 6328f906357ed7f0d8e20e4538c91fd4b34338b9
Author: Andriy Redko <dr...@gmail.com>
AuthorDate: Tue Jun 1 17:42:34 2021 -0400

    CXF-8532: @Priority support for ParamConverterProvider (#807)
    
    (cherry picked from commit 33478ad5cfcbab35404680bfb40cb481be760a03)
    (cherry picked from commit cc9efac873f7dd69753ef5674adf1127e60ce06d)
---
 .../apache/cxf/jaxrs/provider/ProviderFactory.java | 33 +++++++++++++-
 .../jaxrs/PriorityCustomerParameterHandler.java    | 53 ++++++++++++++++++++++
 .../cxf/jaxrs/provider/ProviderFactoryTest.java    | 45 ++++++++++++++++++
 .../jaxrs/client/ClientProviderFactoryTest.java    | 51 +++++++++++++++++++++
 .../java/org/apache/cxf/jaxrs/client/Customer.java | 32 +++++++++++++
 .../cxf/jaxrs/client/CustomerParameterHandler.java | 50 ++++++++++++++++++++
 .../client/PriorityCustomerParameterHandler.java   | 53 ++++++++++++++++++++++
 7 files changed, 316 insertions(+), 1 deletion(-)

diff --git a/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/ProviderFactory.java b/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/ProviderFactory.java
index f3d23b4..3c62ebc 100644
--- a/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/ProviderFactory.java
+++ b/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/ProviderFactory.java
@@ -662,6 +662,7 @@ public abstract class ProviderFactory {
         sortReaders();
         sortWriters();
         sortContextResolvers();
+        sortParamConverterProviders();
 
         mapInterceptorFilters(readerInterceptors, readInts, ReaderInterceptor.class, true);
         mapInterceptorFilters(writerInterceptors, writeInts, WriterInterceptor.class, true);
@@ -742,6 +743,14 @@ public abstract class ProviderFactory {
             doCustomSort(messageWriters);
         }
     }
+    
+    private <T> void sortParamConverterProviders() {
+        if (!customComparatorAvailable(ParamConverterProvider.class)) {
+            paramConverters.sort(new ParamConverterProviderComparator(bus));
+        } else {
+            doCustomSort(paramConverters);
+        }
+    }
 
     private boolean customComparatorAvailable(Class<?> providerClass) {
         if (providerComparator != null) {
@@ -912,6 +921,27 @@ public abstract class ProviderFactory {
         }
     }
 
+    private static class ParamConverterProviderComparator implements Comparator<ProviderInfo<ParamConverterProvider>> {
+        private final Bus bus;
+        
+        ParamConverterProviderComparator(Bus bus) {
+            this.bus = bus;
+        }
+        
+        @Override
+        public int compare(ProviderInfo<ParamConverterProvider> p1, ProviderInfo<ParamConverterProvider> p2) {
+            final int result = compareCustomStatus(p1, p2);
+            if (result != 0) {
+                return result;
+            }
+
+            final Class<?> cl1 = ClassHelper.getRealClass(bus, p1.getProvider());
+            final Class<?> cl2 = ClassHelper.getRealClass(bus, p2.getProvider());
+
+            return comparePriorityStatus(cl1, cl2);
+        }
+    }
+
     protected static int compareCustomStatus(ProviderInfo<?> p1, ProviderInfo<?> p2) {
         Boolean custom1 = p1.isCustom();
         Boolean custom2 = p2.isCustom();
@@ -1480,7 +1510,8 @@ public abstract class ProviderFactory {
 
         sortReaders();
         sortWriters();
-
+        sortParamConverterProviders();
+        
         NameKeyMap<ProviderInfo<ReaderInterceptor>> sortedReaderInterceptors =
             new NameKeyMap<>(
                 (Comparator<ProviderInfo<?>>) providerComparator, true);
diff --git a/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/PriorityCustomerParameterHandler.java b/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/PriorityCustomerParameterHandler.java
new file mode 100644
index 0000000..d5fe732
--- /dev/null
+++ b/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/PriorityCustomerParameterHandler.java
@@ -0,0 +1,53 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.cxf.jaxrs;
+
+import java.lang.annotation.Annotation;
+import java.lang.reflect.Type;
+
+import javax.annotation.Priority;
+import javax.ws.rs.Priorities;
+import javax.ws.rs.ext.ParamConverter;
+import javax.ws.rs.ext.ParamConverterProvider;
+
+
+@Priority(Priorities.USER - 1)
+public class PriorityCustomerParameterHandler implements ParamConverterProvider, ParamConverter<Customer> {
+
+    @SuppressWarnings("unchecked")
+    @Override
+    public <T> ParamConverter<T> getConverter(Class<T> cls, Type arg1, Annotation[] arg2) {
+        if (Customer.class == cls) {
+            return (ParamConverter<T>)this;
+        }
+        return null;
+    }
+
+    public Customer fromString(String s) throws IllegalArgumentException {
+        Customer c = new Customer();
+        c.setName(s);
+        return c;
+    }
+
+    @Override
+    public String toString(Customer arg0) throws IllegalArgumentException {
+        return null;
+    }
+}
diff --git a/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/provider/ProviderFactoryTest.java b/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/provider/ProviderFactoryTest.java
index cb0435a..21a07af 100644
--- a/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/provider/ProviderFactoryTest.java
+++ b/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/provider/ProviderFactoryTest.java
@@ -67,6 +67,7 @@ import org.apache.cxf.jaxrs.Customer;
 import org.apache.cxf.jaxrs.CustomerParameterHandler;
 import org.apache.cxf.jaxrs.JAXBContextProvider;
 import org.apache.cxf.jaxrs.JAXBContextProvider2;
+import org.apache.cxf.jaxrs.PriorityCustomerParameterHandler;
 import org.apache.cxf.jaxrs.impl.MetadataMap;
 import org.apache.cxf.jaxrs.impl.WebApplicationExceptionMapper;
 import org.apache.cxf.jaxrs.model.AbstractResourceInfo;
@@ -669,8 +670,52 @@ public class ProviderFactoryTest {
                                                                 new MessageImpl());
         assertSame(h2, h);
     }
+    
+    @Test
+    public void testParameterHandlerProviderWithPriority() throws Exception {
+        ProviderFactory pf = ServerProviderFactory.getInstance();
+        ParamConverterProvider h = new CustomerParameterHandler();
+        ParamConverterProvider hp = new PriorityCustomerParameterHandler();
+        pf.registerUserProvider(h);
+        pf.registerUserProvider(hp);
+        ParamConverter<Customer> h2 = pf.createParameterHandler(Customer.class, Customer.class, null,
+                                                                new MessageImpl());
+        assertSame(h2, hp);
+    }
 
     @Test
+    public void testCustomProviderSortingParamConverterProvider() {
+        ParamConverterProvider h = new CustomerParameterHandler();
+        ParamConverterProvider hp = new PriorityCustomerParameterHandler();
+        
+        ProviderFactory pf = ServerProviderFactory.getInstance();
+        pf.setUserProviders(Arrays.asList(h, hp));
+
+        Comparator<ProviderInfo<ParamConverterProvider>> comp =
+            new Comparator<ProviderInfo<ParamConverterProvider>>() {
+
+                @Override
+                public int compare(
+                    ProviderInfo<ParamConverterProvider> o1,
+                    ProviderInfo<ParamConverterProvider> o2) {
+
+                    ParamConverterProvider provider1 = o1.getProvider();
+                    ParamConverterProvider provider2 = o2.getProvider();
+
+                    return provider1.getClass().getName().compareTo(
+                        provider2.getClass().getName());
+                }
+
+            };
+
+        pf.setProviderComparator(comp);
+
+        ParamConverter<Customer> h2 = pf.createParameterHandler(Customer.class, Customer.class, null,
+                new MessageImpl());
+        assertSame(h2, h);
+    }
+    
+    @Test
     public void testGetStringProvider() throws Exception {
         verifyProvider(String.class, StringTextProvider.class, "text/plain");
     }
diff --git a/rt/rs/client/src/test/java/org/apache/cxf/jaxrs/client/ClientProviderFactoryTest.java b/rt/rs/client/src/test/java/org/apache/cxf/jaxrs/client/ClientProviderFactoryTest.java
new file mode 100644
index 0000000..2d4815a
--- /dev/null
+++ b/rt/rs/client/src/test/java/org/apache/cxf/jaxrs/client/ClientProviderFactoryTest.java
@@ -0,0 +1,51 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.cxf.jaxrs.client;
+
+import javax.ws.rs.ext.ParamConverter;
+import javax.ws.rs.ext.ParamConverterProvider;
+
+import org.apache.cxf.Bus;
+import org.apache.cxf.bus.extension.ExtensionManagerBus;
+import org.apache.cxf.jaxrs.provider.ProviderFactory;
+import org.apache.cxf.message.MessageImpl;
+
+import org.junit.Test;
+
+import static org.junit.Assert.assertSame;
+
+
+public class ClientProviderFactoryTest {
+
+    @Test
+    public void testParameterHandlerProviderWithPriority() throws Exception {
+        final Bus bus = new ExtensionManagerBus();
+        final ProviderFactory pf = ClientProviderFactory.createInstance(bus);
+        
+        ParamConverterProvider h = new CustomerParameterHandler();
+        ParamConverterProvider hp = new PriorityCustomerParameterHandler();
+        pf.registerUserProvider(h);
+        pf.registerUserProvider(hp);
+        ParamConverter<Customer> h2 = pf.createParameterHandler(Customer.class, Customer.class, null,
+                                                                new MessageImpl());
+        assertSame(h2, hp);
+    }
+
+}
diff --git a/rt/rs/client/src/test/java/org/apache/cxf/jaxrs/client/Customer.java b/rt/rs/client/src/test/java/org/apache/cxf/jaxrs/client/Customer.java
new file mode 100644
index 0000000..f7506e0
--- /dev/null
+++ b/rt/rs/client/src/test/java/org/apache/cxf/jaxrs/client/Customer.java
@@ -0,0 +1,32 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.cxf.jaxrs.client;
+
+public class Customer {
+    private String name;
+    
+    public String getName() {
+        return name;
+    }
+    
+    public void setName(String name) {
+        this.name = name;
+    }
+}
diff --git a/rt/rs/client/src/test/java/org/apache/cxf/jaxrs/client/CustomerParameterHandler.java b/rt/rs/client/src/test/java/org/apache/cxf/jaxrs/client/CustomerParameterHandler.java
new file mode 100644
index 0000000..b04294e
--- /dev/null
+++ b/rt/rs/client/src/test/java/org/apache/cxf/jaxrs/client/CustomerParameterHandler.java
@@ -0,0 +1,50 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.cxf.jaxrs.client;
+
+import java.lang.annotation.Annotation;
+import java.lang.reflect.Type;
+
+import javax.ws.rs.ext.ParamConverter;
+import javax.ws.rs.ext.ParamConverterProvider;
+
+
+public class CustomerParameterHandler implements ParamConverterProvider, ParamConverter<Customer> {
+
+    @SuppressWarnings("unchecked")
+    @Override
+    public <T> ParamConverter<T> getConverter(Class<T> cls, Type arg1, Annotation[] arg2) {
+        if (Customer.class == cls) {
+            return (ParamConverter<T>)this;
+        }
+        return null;
+    }
+
+    public Customer fromString(String s) throws IllegalArgumentException {
+        Customer c = new Customer();
+        c.setName(s);
+        return c;
+    }
+
+    @Override
+    public String toString(Customer arg0) throws IllegalArgumentException {
+        return null;
+    }
+}
diff --git a/rt/rs/client/src/test/java/org/apache/cxf/jaxrs/client/PriorityCustomerParameterHandler.java b/rt/rs/client/src/test/java/org/apache/cxf/jaxrs/client/PriorityCustomerParameterHandler.java
new file mode 100644
index 0000000..f84eeef
--- /dev/null
+++ b/rt/rs/client/src/test/java/org/apache/cxf/jaxrs/client/PriorityCustomerParameterHandler.java
@@ -0,0 +1,53 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.cxf.jaxrs.client;
+
+import java.lang.annotation.Annotation;
+import java.lang.reflect.Type;
+
+import javax.annotation.Priority;
+import javax.ws.rs.Priorities;
+import javax.ws.rs.ext.ParamConverter;
+import javax.ws.rs.ext.ParamConverterProvider;
+
+
+@Priority(Priorities.USER - 1)
+public class PriorityCustomerParameterHandler implements ParamConverterProvider, ParamConverter<Customer> {
+
+    @SuppressWarnings("unchecked")
+    @Override
+    public <T> ParamConverter<T> getConverter(Class<T> cls, Type arg1, Annotation[] arg2) {
+        if (Customer.class == cls) {
+            return (ParamConverter<T>)this;
+        }
+        return null;
+    }
+
+    public Customer fromString(String s) throws IllegalArgumentException {
+        Customer c = new Customer();
+        c.setName(s);
+        return c;
+    }
+
+    @Override
+    public String toString(Customer arg0) throws IllegalArgumentException {
+        return null;
+    }
+}

[cxf] 02/02: Recording .gitmergeinfo Changes

Posted by re...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

reta pushed a commit to branch 3.3.x-fixes
in repository https://gitbox.apache.org/repos/asf/cxf.git

commit 59201ec26382ff46887a0b636f1cd3cec1fd67a0
Author: Andriy Redko <dr...@gmail.com>
AuthorDate: Tue Jun 1 20:28:06 2021 -0400

    Recording .gitmergeinfo Changes
---
 .gitmergeinfo | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/.gitmergeinfo b/.gitmergeinfo
index 80881bd..057a2b4 100644
--- a/.gitmergeinfo
+++ b/.gitmergeinfo
@@ -671,6 +671,7 @@ B fdcccee816a8639a4b253d12d44beb4cb285789b
 B ff2b7c87de12d16cd71a62e7a1f0a0be3901b39e
 B ff683953b2ed253aac150c4758e8993ba220a5bb
 B ff7b028eeea39fedeb06207753fe6dcb9b0d8cca
+M 004948b568233ebfa250bd3d4cde761bb9a6b145
 M 00adb9d87b59e3ba73cfe323c5975eed75780ee3
 M 00c77f3e98985d339b4bb3488a7ea8799eefcdec
 M 01eb99f3912adfb191428b5ee2fde2e7650815ff
@@ -734,6 +735,7 @@ M 2e9ffb54bcc26530556c60b0c5bacc380f2a3cf3
 M 2eab747e67a2172614b5d63fa7f7557029e48c42
 M 2f392a68ed59b0a73ffdc3ff114bba1041ae3f63
 M 2f844e251362ab62923cfc6b7061591375a1cb44
+M 3218d06ce8867b8449e34e140899ec9a166a203d
 M 325ed0436bc9cfa9150b3504a54b5911b47e3266
 M 330f0f9d83c5e689a8db3c107b3d27a294161bbb
 M 336d49d4e88641a6ffaf757185ff0ff93473322c
@@ -812,6 +814,7 @@ M 79466c55a2a1191df9c28a02568b82a8c3d08fbd
 M 7971b506283502c26aafb97c0f6e50633f126cdd
 M 79f68ec4acb91c754e1b7d118f844d787a5ce888
 M 7a05e4fb0b67a89b86ed6eee68b9416005d6f631
+M 7a188f96fee4923b40e59529dd0bd177983bf24c
 M 7a655b49fd6d432127a55b38f15c1212f7064196
 M 7aa6e0a402b8ce7dfff8a931a507b884d7152cea
 M 7b50181ebc445bb84d3463b284643432399bc0f8
@@ -906,6 +909,7 @@ M c673affb1cc40a38953dd9ce6b567705fa6eef46
 M cafe51572ed0a0c1452ea0685b1c750fb0df6755
 M cbc0fde7f85d01e379e40a7f27fe5cea20169ddf
 M cbeb9a21ba4a46f1861851f5bc56ee90d89a2225
+M cc9efac873f7dd69753ef5674adf1127e60ce06d
 M ccb743e48e9ed99e240ae05f373b6ff799085049
 M ccfa0a686e19f2d4b9ef9f35cec88f3ec710ee89
 M ce504146b81a2ffb2e8cda36d8bdf8486730e485