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/04/15 12:18:10 UTC

[cxf] branch 3.4.x-fixes updated (0c182f5 -> f5a5855)

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

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


    from 0c182f5  Update to Project Reactor 3.3.16.RELEASE
     new 63d01f5  CXF-7921: JAXRS CDI extension ignores interfaces annotations (#777)
     new f5a5855  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                                      |  3 +++
 .../apache/cxf/cdi/JAXRSCdiResourceExtension.java  | 30 +++++++++++++++++++---
 .../cxf/cdi/JAXRSCdiResourceExtensionTest.java     |  4 +--
 .../systests/cdi/base/AbstractCdiMultiAppTest.java |  7 +++++
 .../cxf/systests/cdi/base/contract}/BookStore.java | 17 ++++++------
 .../BookStoreImpl.java}                            | 23 +++++------------
 .../systest/jaxrs/BookStoreCustomApplication.java  |  3 ++-
 .../systest/jaxrs/BookStoreCustomApplication.java  |  3 ++-
 8 files changed, 57 insertions(+), 33 deletions(-)
 copy systests/{rs-http-sci/src/test/java/org/apache/demo/resources => cdi/base/src/main/java/org/apache/cxf/systests/cdi/base/contract}/BookStore.java (77%)
 copy systests/cdi/base/src/main/java/org/apache/cxf/systests/cdi/base/{RequestScopedBookStore.java => contract/BookStoreImpl.java} (69%)

[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.4.x-fixes
in repository https://gitbox.apache.org/repos/asf/cxf.git

commit f5a5855e44703ae98281c240888a129711d69284
Author: reta <dr...@gmail.com>
AuthorDate: Wed Apr 14 20:42:21 2021 -0400

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

diff --git a/.gitmergeinfo b/.gitmergeinfo
index 5db4d23..c723f13 100644
--- a/.gitmergeinfo
+++ b/.gitmergeinfo
@@ -77,6 +77,7 @@ M 0f30442f3acb82e9936d4b486e07f5c341c142d2
 M 12a70c867e88379c520c64882ca2b261b9e9559d
 M 15185954d24578b3a848afe5bf258d9774ff03b6
 M 1820f1a94b08ba840c3868ac3e1f3b7751540a08
+M 1c7c39771adb05f1fa8678e20b97f1c735f2601c
 M 299d6a844b99a69555355b2f9baca3e6ec13a918
 M 2c7b64383d81db5e7bd14abc90fbbbf0597044af
 M 2f844e251362ab62923cfc6b7061591375a1cb44
@@ -101,8 +102,10 @@ M 8b3d74cb9bdf0be862f3180ff2f101fb3d9c888b
 M 8b67b6f672d25f1128924e8aac58a6f395fe3511
 M 8c4f04855a5d8623daff2aa8a8856367879c624b
 M 954085421900efbf89643b5ab8f187a237e42eb4
+M 975fc9e2fe226ddb8dfa845bd9565839c7391e2a
 M 9980b0472524e1010aaf7a4a3fe5ff072270efe3
 M 9bb8e487235d728bb80a90e7e2f4a9433b5ef033
+M 9c1106db2f4b21c5918c5e9ada23d715dc15103e
 M 9c17f2fb90a9929d0dc8e4f090da78547a4e7a02
 M 9df9b22a4032b19ea953600ebdfa84e8c15d2370
 M 9f939eefbd41ee5c0e88b41c2e177fdbc5cbdd26

[cxf] 01/02: CXF-7921: JAXRS CDI extension ignores interfaces annotations (#777)

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

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

commit 63d01f5b8487c7b4596a50e430394eb3a36d1529
Author: Andriy Redko <dr...@gmail.com>
AuthorDate: Wed Apr 14 20:22:03 2021 -0400

    CXF-7921: JAXRS CDI extension ignores interfaces annotations (#777)
    
    (cherry picked from commit e173fd47157bad61631a2e87415732d524e05c74)
---
 .../apache/cxf/cdi/JAXRSCdiResourceExtension.java  | 30 +++++++++++--
 .../cxf/cdi/JAXRSCdiResourceExtensionTest.java     |  4 +-
 .../systests/cdi/base/AbstractCdiMultiAppTest.java |  7 +++
 .../cxf/systests/cdi/base/contract/BookStore.java  | 36 ++++++++++++++++
 .../systests/cdi/base/contract/BookStoreImpl.java  | 50 ++++++++++++++++++++++
 .../systest/jaxrs/BookStoreCustomApplication.java  |  3 +-
 .../systest/jaxrs/BookStoreCustomApplication.java  |  3 +-
 7 files changed, 125 insertions(+), 8 deletions(-)

diff --git a/integration/cdi/src/main/java/org/apache/cxf/cdi/JAXRSCdiResourceExtension.java b/integration/cdi/src/main/java/org/apache/cxf/cdi/JAXRSCdiResourceExtension.java
index b5d72c4..02263d3 100644
--- a/integration/cdi/src/main/java/org/apache/cxf/cdi/JAXRSCdiResourceExtension.java
+++ b/integration/cdi/src/main/java/org/apache/cxf/cdi/JAXRSCdiResourceExtension.java
@@ -18,6 +18,7 @@
  */
 package org.apache.cxf.cdi;
 
+import java.lang.annotation.Annotation;
 import java.lang.reflect.Type;
 import java.util.ArrayList;
 import java.util.Collection;
@@ -28,12 +29,14 @@ import java.util.List;
 import java.util.Objects;
 import java.util.ServiceLoader;
 import java.util.Set;
+import java.util.stream.Stream;
 
 import javax.enterprise.context.Dependent;
 import javax.enterprise.context.spi.CreationalContext;
 import javax.enterprise.event.Observes;
 import javax.enterprise.inject.spi.AfterBeanDiscovery;
 import javax.enterprise.inject.spi.AfterDeploymentValidation;
+import javax.enterprise.inject.spi.Annotated;
 import javax.enterprise.inject.spi.AnnotatedType;
 import javax.enterprise.inject.spi.Bean;
 import javax.enterprise.inject.spi.BeanManager;
@@ -188,12 +191,13 @@ public class JAXRSCdiResourceExtension implements Extension {
     }
 
     @SuppressWarnings("unchecked")
-    public <T> void collect(@Observes final ProcessBean< T > event) {
-        if (event.getAnnotated().isAnnotationPresent(ApplicationPath.class)) {
+    public <T> void collect(@Observes final ProcessBean< T > event, final BeanManager beanManager) {
+        final Annotated annotated = event.getAnnotated();
+        if (isAnnotationPresent(beanManager, annotated, ApplicationPath.class)) {
             applicationBeans.add(event.getBean());
-        } else if (event.getAnnotated().isAnnotationPresent(Path.class)) {
+        } else if (isAnnotationPresent(beanManager, annotated, Path.class)) {
             serviceBeans.add(event.getBean());
-        } else if (event.getAnnotated().isAnnotationPresent(Provider.class)) {
+        } else if (isAnnotationPresent(beanManager, annotated, Provider.class)) {
             providerBeans.add(event.getBean());
         } else if (event.getBean().getTypes().contains(javax.ws.rs.core.Feature.class)) {
             providerBeans.add(event.getBean());
@@ -574,4 +578,22 @@ public class JAXRSCdiResourceExtension implements Extension {
         }
         return Collections.unmodifiableSet(customContextClasses);
     }
+    
+    @SuppressWarnings("unchecked")
+    private static boolean isAnnotationPresent(final BeanManager beanManager, final Annotated annotated, 
+            final Class<? extends Annotation> annotationType) {
+
+        if (annotated.isAnnotationPresent(annotationType)) {
+            return true;
+        }
+        
+        final Stream<AnnotatedType<?>> annotatedTypes = annotated
+            .getTypeClosure()
+            .stream()
+            .filter(Class.class::isInstance)
+            .map(Class.class::cast)
+            .map(cls -> (AnnotatedType<?>)beanManager.createAnnotatedType(cls));
+        
+        return annotatedTypes.anyMatch(at -> at.isAnnotationPresent(annotationType));
+    }
 }
diff --git a/integration/cdi/src/test/java/org/apache/cxf/cdi/JAXRSCdiResourceExtensionTest.java b/integration/cdi/src/test/java/org/apache/cxf/cdi/JAXRSCdiResourceExtensionTest.java
index d7517c5..28b3ce2 100644
--- a/integration/cdi/src/test/java/org/apache/cxf/cdi/JAXRSCdiResourceExtensionTest.java
+++ b/integration/cdi/src/test/java/org/apache/cxf/cdi/JAXRSCdiResourceExtensionTest.java
@@ -67,7 +67,7 @@ public class JAXRSCdiResourceExtensionTest {
         Class cls = Bus.class;
         when(busBean.getBeanClass()).thenReturn(cls);
         when(busBean.getName()).thenReturn(CdiBusBean.CXF);
-        extension.collect(processBean);
+        extension.collect(processBean, beanManager);
 
         extension.injectBus(event, beanManager);
 
@@ -79,7 +79,7 @@ public class JAXRSCdiResourceExtensionTest {
         when(processBean.getBean()).thenReturn(busBean);
         when(processBean.getAnnotated()).thenReturn(annotated);
         when(annotated.isAnnotationPresent(Path.class)).thenReturn(true);
-        extension.collect(processBean);
+        extension.collect(processBean, beanManager);
 
         extension.injectBus(event, beanManager);
 
diff --git a/systests/cdi/base/src/main/java/org/apache/cxf/systests/cdi/base/AbstractCdiMultiAppTest.java b/systests/cdi/base/src/main/java/org/apache/cxf/systests/cdi/base/AbstractCdiMultiAppTest.java
index 1f8e2cf..d79ef9c 100644
--- a/systests/cdi/base/src/main/java/org/apache/cxf/systests/cdi/base/AbstractCdiMultiAppTest.java
+++ b/systests/cdi/base/src/main/java/org/apache/cxf/systests/cdi/base/AbstractCdiMultiAppTest.java
@@ -81,6 +81,13 @@ public abstract class AbstractCdiMultiAppTest extends AbstractCdiSingleAppTest {
     }
     
     @Test
+    public void testResponseHasBeenReceivedWhenQueringContractBookstore() {
+        Response r = createWebClient("/rest/v2/bookstore/contract/books").get();
+        assertEquals(Response.Status.OK.getStatusCode(), r.getStatus());
+        assertThat(r.getHeaderString("X-Logged"), equalTo("true"));
+    }
+    
+    @Test
     public void testResponseHasBeenReceivedWhenQueringMethodWithNameBinding() {
         Response r = createWebClient("/rest/v2/bookstore/books").get();
         assertEquals(Response.Status.OK.getStatusCode(), r.getStatus());
diff --git a/systests/cdi/base/src/main/java/org/apache/cxf/systests/cdi/base/contract/BookStore.java b/systests/cdi/base/src/main/java/org/apache/cxf/systests/cdi/base/contract/BookStore.java
new file mode 100644
index 0000000..17daab4
--- /dev/null
+++ b/systests/cdi/base/src/main/java/org/apache/cxf/systests/cdi/base/contract/BookStore.java
@@ -0,0 +1,36 @@
+/**
+ * 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.systests.cdi.base.contract;
+
+import javax.validation.Valid;
+import javax.validation.constraints.NotNull;
+import javax.ws.rs.GET;
+import javax.ws.rs.Path;
+import javax.ws.rs.Produces;
+import javax.ws.rs.core.MediaType;
+import javax.ws.rs.core.Response;
+
+@Path("/bookstore/contract")
+public interface BookStore {
+    @GET
+    @Path("/books")
+    @NotNull @Valid
+    @Produces(MediaType.APPLICATION_JSON)
+    Response getBooks();
+}
diff --git a/systests/cdi/base/src/main/java/org/apache/cxf/systests/cdi/base/contract/BookStoreImpl.java b/systests/cdi/base/src/main/java/org/apache/cxf/systests/cdi/base/contract/BookStoreImpl.java
new file mode 100644
index 0000000..6700416
--- /dev/null
+++ b/systests/cdi/base/src/main/java/org/apache/cxf/systests/cdi/base/contract/BookStoreImpl.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.systests.cdi.base.contract;
+
+import javax.inject.Inject;
+import javax.ws.rs.core.Response;
+import javax.ws.rs.core.UriInfo;
+
+import org.apache.cxf.systests.cdi.base.BookStoreService;
+import org.apache.cxf.systests.cdi.base.bindings.Logged;
+
+@Logged
+public class BookStoreImpl implements BookStore {
+    private BookStoreService service;
+    private UriInfo uriInfo;
+
+    public BookStoreImpl() {
+    }
+
+    @Inject
+    public BookStoreImpl(BookStoreService service, UriInfo uriInfo) {
+        this.service = service;
+        this.uriInfo = uriInfo;
+    }
+
+    @Override
+    public Response getBooks() {
+        return Response
+          .ok()
+          .entity(service.all())
+          .contentLocation(uriInfo.getAbsolutePath())
+          .build();
+    }
+}
diff --git a/systests/cdi/cdi-owb/cdi-multiple-apps-owb/src/test/java/org/apache/cxf/systest/jaxrs/BookStoreCustomApplication.java b/systests/cdi/cdi-owb/cdi-multiple-apps-owb/src/test/java/org/apache/cxf/systest/jaxrs/BookStoreCustomApplication.java
index aeb3083..49c7534 100644
--- a/systests/cdi/cdi-owb/cdi-multiple-apps-owb/src/test/java/org/apache/cxf/systest/jaxrs/BookStoreCustomApplication.java
+++ b/systests/cdi/cdi-owb/cdi-multiple-apps-owb/src/test/java/org/apache/cxf/systest/jaxrs/BookStoreCustomApplication.java
@@ -35,6 +35,7 @@ import org.apache.cxf.systests.cdi.base.BookStoreByIds;
 import org.apache.cxf.systests.cdi.base.CustomScopedBookStore;
 import org.apache.cxf.systests.cdi.base.RequestScopedBookStore;
 import org.apache.cxf.systests.cdi.base.bindings.LoggingFilter;
+import org.apache.cxf.systests.cdi.base.contract.BookStoreImpl;
 
 @ApplicationPath("/v2")
 public class BookStoreCustomApplication extends Application {
@@ -51,6 +52,6 @@ public class BookStoreCustomApplication extends Application {
     @Override
     public Set<Class<?>> getClasses() {
         return new LinkedHashSet<>(Arrays.asList(BookStore.class, BookStoreByIds.class, 
-             CustomScopedBookStore.class, RequestScopedBookStore.class));
+             CustomScopedBookStore.class, RequestScopedBookStore.class, BookStoreImpl.class));
     }
 }
diff --git a/systests/cdi/cdi-weld/cdi-multiple-apps-weld/src/test/java/org/apache/cxf/systest/jaxrs/BookStoreCustomApplication.java b/systests/cdi/cdi-weld/cdi-multiple-apps-weld/src/test/java/org/apache/cxf/systest/jaxrs/BookStoreCustomApplication.java
index b6d82f2..4c1f529 100644
--- a/systests/cdi/cdi-weld/cdi-multiple-apps-weld/src/test/java/org/apache/cxf/systest/jaxrs/BookStoreCustomApplication.java
+++ b/systests/cdi/cdi-weld/cdi-multiple-apps-weld/src/test/java/org/apache/cxf/systest/jaxrs/BookStoreCustomApplication.java
@@ -34,6 +34,7 @@ import org.apache.cxf.systests.cdi.base.BookStore;
 import org.apache.cxf.systests.cdi.base.CustomScopedBookStore;
 import org.apache.cxf.systests.cdi.base.RequestScopedBookStore;
 import org.apache.cxf.systests.cdi.base.bindings.LoggingFilter;
+import org.apache.cxf.systests.cdi.base.contract.BookStoreImpl;
 
 @ApplicationPath("/v2")
 public class BookStoreCustomApplication extends Application {
@@ -50,6 +51,6 @@ public class BookStoreCustomApplication extends Application {
     @Override
     public Set<Class<?>> getClasses() {
         return new LinkedHashSet<>(Arrays.asList(BookStore.class, RequestScopedBookStore.class, 
-            CustomScopedBookStore.class));
+            CustomScopedBookStore.class, BookStoreImpl.class));
     }
 }