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/13 01:20:23 UTC

[cxf] branch 3.3.x-fixes updated (c8a64bb -> 6394c3e)

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 c8a64bb  Recording .gitmergeinfo Changes
     new 97ea294  CXF-8344: org.apache.cxf.jaxrs.utils.AnnotationUtils#getNameBindings does not use ClassUnwrapper (#775)
     new 6394c3e  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                                      |  1 +
 .../apache/cxf/jaxrs/JAXRSServerFactoryBean.java   |  5 +--
 .../apache/cxf/jaxrs/model/ClassResourceInfo.java  |  2 +-
 .../apache/cxf/jaxrs/provider/ProviderFactory.java |  3 +-
 .../apache/cxf/jaxrs/utils/AnnotationUtils.java    | 13 ++++++
 .../systests/cdi/base/AbstractCdiMultiAppTest.java | 23 +++++++++++
 .../apache/cxf/systests/cdi/base/BookStore.java    |  3 ++
 ...kStoreByIds.java => CustomScopedBookStore.java} | 43 ++++++++++++++------
 ...StoreByIds.java => RequestScopedBookStore.java} | 43 ++++++++++++++------
 .../cxf/systests/cdi/base/bindings/Logged.java}    |  6 +--
 .../systests/cdi/base/bindings/LoggingFilter.java} | 17 ++++----
 .../cxf/systests/cdi/base/scope/CustomContext.java | 46 ++++++++++++----------
 .../cdi/base/scope/CustomScopeExtension.java       | 18 +++++----
 .../cxf/systests/cdi/base/scope/CustomScoped.java  | 25 ++++++------
 .../services/javax.enterprise.inject.spi.Extension |  1 +
 .../systest/jaxrs/BookStoreCustomApplication.java  |  7 +++-
 .../systest/jaxrs/BookStoreCustomApplication.java  | 10 ++++-
 17 files changed, 176 insertions(+), 90 deletions(-)
 copy systests/cdi/base/src/main/java/org/apache/cxf/systests/cdi/base/{BookStoreByIds.java => CustomScopedBookStore.java} (58%)
 copy systests/cdi/base/src/main/java/org/apache/cxf/systests/cdi/base/{BookStoreByIds.java => RequestScopedBookStore.java} (58%)
 copy systests/{jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/GlobalNameBinding.java => cdi/base/src/main/java/org/apache/cxf/systests/cdi/base/bindings/Logged.java} (93%)
 copy systests/{jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/BookContinuationFilter.java => cdi/base/src/main/java/org/apache/cxf/systests/cdi/base/bindings/LoggingFilter.java} (70%)
 copy integration/cdi/src/main/java/org/apache/cxf/cdi/Lifecycle.java => systests/cdi/base/src/main/java/org/apache/cxf/systests/cdi/base/scope/CustomContext.java (56%)
 copy core/src/main/java/org/apache/cxf/common/CXFPermissions.java => systests/cdi/base/src/main/java/org/apache/cxf/systests/cdi/base/scope/CustomScopeExtension.java (60%)
 copy core/src/main/java/org/apache/cxf/management/annotation/ManagedNotification.java => systests/cdi/base/src/main/java/org/apache/cxf/systests/cdi/base/scope/CustomScoped.java (70%)
 create mode 100644 systests/cdi/base/src/main/resources/META-INF/services/javax.enterprise.inject.spi.Extension

[cxf] 01/02: CXF-8344: org.apache.cxf.jaxrs.utils.AnnotationUtils#getNameBindings does not use ClassUnwrapper (#775)

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 97ea294bb8479626675c3828bcf7babc79ee29e3
Author: Andriy Redko <dr...@gmail.com>
AuthorDate: Mon Apr 12 18:05:17 2021 -0400

    CXF-8344: org.apache.cxf.jaxrs.utils.AnnotationUtils#getNameBindings does not use ClassUnwrapper (#775)
    
    * CXF-8344: org.apache.cxf.jaxrs.utils.AnnotationUtils#getNameBindings does not use ClassUnwrapper
    
    * CXF-8344: org.apache.cxf.jaxrs.utils.AnnotationUtils#getNameBindings does not use ClassUnwrapper. Adding more test cases
    
    (cherry picked from commit d812015566bb421760b3389b130c08df9d658363)
    (cherry picked from commit a2a43df528bc0e8fb16f20bf936810ca60c7d2ab)
---
 .../apache/cxf/jaxrs/JAXRSServerFactoryBean.java   |  5 +-
 .../apache/cxf/jaxrs/model/ClassResourceInfo.java  |  2 +-
 .../apache/cxf/jaxrs/provider/ProviderFactory.java |  3 +-
 .../apache/cxf/jaxrs/utils/AnnotationUtils.java    | 13 +++++
 .../systests/cdi/base/AbstractCdiMultiAppTest.java | 23 ++++++++
 .../apache/cxf/systests/cdi/base/BookStore.java    |  3 ++
 .../systests/cdi/base/CustomScopedBookStore.java   | 61 ++++++++++++++++++++++
 .../systests/cdi/base/RequestScopedBookStore.java  | 61 ++++++++++++++++++++++
 .../cxf/systests/cdi/base/bindings/Logged.java     | 33 ++++++++++++
 .../systests/cdi/base/bindings/LoggingFilter.java  | 35 +++++++++++++
 .../cxf/systests/cdi/base/scope/CustomContext.java | 55 +++++++++++++++++++
 .../cdi/base/scope/CustomScopeExtension.java       | 33 ++++++++++++
 .../cxf/systests/cdi/base/scope/CustomScoped.java  | 39 ++++++++++++++
 .../services/javax.enterprise.inject.spi.Extension |  1 +
 .../systest/jaxrs/BookStoreCustomApplication.java  |  7 ++-
 .../systest/jaxrs/BookStoreCustomApplication.java  | 10 +++-
 16 files changed, 375 insertions(+), 9 deletions(-)

diff --git a/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/JAXRSServerFactoryBean.java b/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/JAXRSServerFactoryBean.java
index f3b47a6..7871226 100644
--- a/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/JAXRSServerFactoryBean.java
+++ b/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/JAXRSServerFactoryBean.java
@@ -100,11 +100,10 @@ public class JAXRSServerFactoryBean extends AbstractJAXRSFactoryBean {
 
     public void setApplicationInfo(ApplicationInfo provider) {
         appProvider = provider;
-        Set<String> appNameBindings = AnnotationUtils.getNameBindings(provider.getProvider()
-                                                                      .getClass().getAnnotations());
+        Set<String> appNameBindings = AnnotationUtils.getNameBindings(bus, provider.getProvider().getClass());
         for (ClassResourceInfo cri : getServiceFactory().getClassResourceInfo()) {
             Set<String> clsNameBindings = new LinkedHashSet<>(appNameBindings);
-            clsNameBindings.addAll(AnnotationUtils.getNameBindings(cri.getServiceClass().getAnnotations()));
+            clsNameBindings.addAll(AnnotationUtils.getNameBindings(bus, cri.getServiceClass()));
             cri.setNameBindings(clsNameBindings);
         }
     }
diff --git a/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/model/ClassResourceInfo.java b/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/model/ClassResourceInfo.java
index 0314b9c..a69cac1 100644
--- a/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/model/ClassResourceInfo.java
+++ b/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/model/ClassResourceInfo.java
@@ -89,7 +89,7 @@ public class ClassResourceInfo extends BeanResourceInfo {
         super(theResourceClass, theServiceClass, theRoot, theRoot || enableStatic, bus);
         this.enableStatic = enableStatic;
         if (resourceClass != null) {
-            nameBindings = AnnotationUtils.getNameBindings(serviceClass.getAnnotations());
+            nameBindings = AnnotationUtils.getNameBindings(bus, serviceClass);
         }
     }
     //CHECKSTYLE:OFF
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 bf7f2b5..f3d23b4 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
@@ -1354,8 +1354,7 @@ public abstract class ProviderFactory {
 
     }
     protected static Set<String> getFilterNameBindings(Bus bus, Object provider) {
-        Class<?> pClass = ClassHelper.getRealClass(bus, provider);
-        Set<String> names = AnnotationUtils.getNameBindings(pClass.getAnnotations());
+        Set<String> names = AnnotationUtils.getInstanceNameBindings(bus, provider);
         if (names.isEmpty()) {
             names = Collections.singleton(DEFAULT_FILTER_NAME_BINDING);
         }
diff --git a/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/utils/AnnotationUtils.java b/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/utils/AnnotationUtils.java
index 67d2a3c..8d49e2d 100644
--- a/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/utils/AnnotationUtils.java
+++ b/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/utils/AnnotationUtils.java
@@ -44,7 +44,9 @@ import javax.ws.rs.Produces;
 import javax.ws.rs.QueryParam;
 import javax.ws.rs.core.Context;
 
+import org.apache.cxf.Bus;
 import org.apache.cxf.common.logging.LogUtils;
+import org.apache.cxf.common.util.ClassHelper;
 
 public final class AnnotationUtils {
     private static final Logger LOG = LogUtils.getL7dLogger(AnnotationUtils.class);
@@ -115,6 +117,17 @@ public final class AnnotationUtils {
             return Priorities.USER;
         }
     }
+    
+    public static Set<String> getInstanceNameBindings(Bus bus, Object obj) {
+        final Class<?> realClazz = ClassHelper.getRealClass(bus, obj);
+        return getNameBindings(realClazz.getAnnotations());
+    }
+    
+    public static Set<String> getNameBindings(Bus bus, Class<?> clazz) {
+        final Class<?> realClazz = ClassHelper.getRealClassFromClass(bus, clazz);
+        return getNameBindings(realClazz.getAnnotations());
+    }
+    
     public static Set<String> getNameBindings(Annotation[] targetAnns) {
         if (targetAnns.length == 0) {
             return Collections.emptySet();
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 f923878..68df06e 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
@@ -34,6 +34,7 @@ import org.junit.Test;
 
 import static org.hamcrest.CoreMatchers.equalTo;
 import static org.hamcrest.CoreMatchers.not;
+import static org.hamcrest.CoreMatchers.nullValue;
 import static org.hamcrest.CoreMatchers.startsWith;
 import static org.hamcrest.MatcherAssert.assertThat;
 import static org.junit.Assert.assertEquals;
@@ -47,6 +48,7 @@ public abstract class AbstractCdiMultiAppTest extends AbstractCdiSingleAppTest {
                 new Form()
                         .param("id", id));
         assertEquals(Response.Status.BAD_REQUEST.getStatusCode(), r.getStatus());
+        assertThat(r.getHeaderString("X-Logged"), nullValue());
     }
 
     @Test
@@ -62,6 +64,27 @@ public abstract class AbstractCdiMultiAppTest extends AbstractCdiSingleAppTest {
         assertThat(r2.readEntity(String.class), not(equalTo(r1.readEntity(String.class))));
     }
 
+    @Test
+    public void testResponseHasBeenReceivedWhenQueringRequestScopedBookstore() {
+        Response r = createWebClient("/rest/v2/bookstore/request/books").get();
+        assertEquals(Response.Status.OK.getStatusCode(), r.getStatus());
+        assertThat(r.getHeaderString("X-Logged"), equalTo("true"));
+    }
+    
+    @Test
+    public void testResponseHasBeenReceivedWhenQueringCustomScopedBookstore() {
+        Response r = createWebClient("/rest/v2/bookstore/custom/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());
+        assertThat(r.getHeaderString("X-Logged"), equalTo("true"));
+    }
+    
     protected WebClient createWebClient(final String url) {
         return createWebClient(url, MediaType.APPLICATION_JSON);
     }
diff --git a/systests/cdi/base/src/main/java/org/apache/cxf/systests/cdi/base/BookStore.java b/systests/cdi/base/src/main/java/org/apache/cxf/systests/cdi/base/BookStore.java
index 63cbc3a..ee5f508 100644
--- a/systests/cdi/base/src/main/java/org/apache/cxf/systests/cdi/base/BookStore.java
+++ b/systests/cdi/base/src/main/java/org/apache/cxf/systests/cdi/base/BookStore.java
@@ -34,6 +34,8 @@ import javax.ws.rs.core.MediaType;
 import javax.ws.rs.core.Response;
 import javax.ws.rs.core.UriInfo;
 
+import org.apache.cxf.systests.cdi.base.bindings.Logged;
+
 @Path("/bookstore/")
 public class BookStore {
     private BookStoreService service;
@@ -76,6 +78,7 @@ public class BookStore {
     @Path("/books")
     @NotNull @Valid
     @Produces(MediaType.APPLICATION_JSON)
+    @Logged
     public Collection< Book > getBooks() {
         return service.all();
     }
diff --git a/systests/cdi/base/src/main/java/org/apache/cxf/systests/cdi/base/CustomScopedBookStore.java b/systests/cdi/base/src/main/java/org/apache/cxf/systests/cdi/base/CustomScopedBookStore.java
new file mode 100644
index 0000000..ebaa1c9
--- /dev/null
+++ b/systests/cdi/base/src/main/java/org/apache/cxf/systests/cdi/base/CustomScopedBookStore.java
@@ -0,0 +1,61 @@
+/**
+ * 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;
+
+import javax.inject.Inject;
+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;
+import javax.ws.rs.core.UriInfo;
+
+import org.apache.cxf.systests.cdi.base.bindings.Logged;
+import org.apache.cxf.systests.cdi.base.scope.CustomScoped;
+
+@Path("/bookstore/custom")
+@CustomScoped
+@Logged
+public class CustomScopedBookStore {
+    private BookStoreService service;
+    private UriInfo uriInfo;
+
+    public CustomScopedBookStore() {
+    }
+
+    @Inject
+    public CustomScopedBookStore(BookStoreService service, UriInfo uriInfo) {
+        this.service = service;
+        this.uriInfo = uriInfo;
+    }
+
+    @GET
+    @Path("/books")
+    @NotNull @Valid
+    @Produces(MediaType.APPLICATION_JSON)
+    public Response getBooks() {
+        return Response
+          .ok()
+          .entity(service.all())
+          .contentLocation(uriInfo.getAbsolutePath())
+          .build();
+    }
+}
diff --git a/systests/cdi/base/src/main/java/org/apache/cxf/systests/cdi/base/RequestScopedBookStore.java b/systests/cdi/base/src/main/java/org/apache/cxf/systests/cdi/base/RequestScopedBookStore.java
new file mode 100644
index 0000000..e5559a2
--- /dev/null
+++ b/systests/cdi/base/src/main/java/org/apache/cxf/systests/cdi/base/RequestScopedBookStore.java
@@ -0,0 +1,61 @@
+/**
+ * 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;
+
+import javax.enterprise.context.RequestScoped;
+import javax.inject.Inject;
+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;
+import javax.ws.rs.core.UriInfo;
+
+import org.apache.cxf.systests.cdi.base.bindings.Logged;
+
+@Path("/bookstore/request")
+@RequestScoped
+@Logged
+public class RequestScopedBookStore {
+    private BookStoreService service;
+    private UriInfo uriInfo;
+
+    public RequestScopedBookStore() {
+    }
+
+    @Inject
+    public RequestScopedBookStore(BookStoreService service, UriInfo uriInfo) {
+        this.service = service;
+        this.uriInfo = uriInfo;
+    }
+
+    @GET
+    @Path("/books")
+    @NotNull @Valid
+    @Produces(MediaType.APPLICATION_JSON)
+    public Response getBooks() {
+        return Response
+          .ok()
+          .entity(service.all())
+          .contentLocation(uriInfo.getAbsolutePath())
+          .build();
+    }
+}
diff --git a/systests/cdi/base/src/main/java/org/apache/cxf/systests/cdi/base/bindings/Logged.java b/systests/cdi/base/src/main/java/org/apache/cxf/systests/cdi/base/bindings/Logged.java
new file mode 100644
index 0000000..235ffbd
--- /dev/null
+++ b/systests/cdi/base/src/main/java/org/apache/cxf/systests/cdi/base/bindings/Logged.java
@@ -0,0 +1,33 @@
+/**
+ * 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.bindings;
+
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+import javax.ws.rs.NameBinding;
+
+@Target({ ElementType.TYPE, ElementType.METHOD })
+@Retention(value = RetentionPolicy.RUNTIME)
+@NameBinding
+public @interface Logged {
+}
diff --git a/systests/cdi/base/src/main/java/org/apache/cxf/systests/cdi/base/bindings/LoggingFilter.java b/systests/cdi/base/src/main/java/org/apache/cxf/systests/cdi/base/bindings/LoggingFilter.java
new file mode 100644
index 0000000..0444e76
--- /dev/null
+++ b/systests/cdi/base/src/main/java/org/apache/cxf/systests/cdi/base/bindings/LoggingFilter.java
@@ -0,0 +1,35 @@
+/**
+ * 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.bindings;
+
+import java.io.IOException;
+
+import javax.ws.rs.container.ContainerRequestContext;
+import javax.ws.rs.container.ContainerResponseContext;
+import javax.ws.rs.container.ContainerResponseFilter;
+
+@Logged
+public class LoggingFilter implements ContainerResponseFilter {
+    @Override
+    public void filter(ContainerRequestContext requestContext, 
+            ContainerResponseContext responseContext) throws IOException {
+        responseContext.getHeaders().putSingle("X-Logged", true);
+    }
+}
diff --git a/systests/cdi/base/src/main/java/org/apache/cxf/systests/cdi/base/scope/CustomContext.java b/systests/cdi/base/src/main/java/org/apache/cxf/systests/cdi/base/scope/CustomContext.java
new file mode 100644
index 0000000..916d7bd
--- /dev/null
+++ b/systests/cdi/base/src/main/java/org/apache/cxf/systests/cdi/base/scope/CustomContext.java
@@ -0,0 +1,55 @@
+/**
+ * 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.scope;
+
+import java.lang.annotation.Annotation;
+
+import javax.enterprise.context.spi.Context;
+import javax.enterprise.context.spi.Contextual;
+import javax.enterprise.context.spi.CreationalContext;
+import javax.enterprise.inject.spi.BeanManager;
+
+public class CustomContext implements Context {
+    private final BeanManager beanManager;
+    
+    public CustomContext(BeanManager beanManager) {
+        this.beanManager = beanManager;
+    }
+    
+    @Override
+    public Class<? extends Annotation> getScope() {
+        return CustomScoped.class;
+    }
+
+    @Override
+    public <T> T get(Contextual<T> contextual, CreationalContext<T> creationalContext) {
+        return contextual.create(creationalContext);
+    }
+
+    @Override
+    public <T> T get(Contextual<T> contextual) {
+        return contextual.create(beanManager.createCreationalContext(contextual));
+    }
+
+    @Override
+    public boolean isActive() {
+        return true;
+    }
+}
diff --git a/systests/cdi/base/src/main/java/org/apache/cxf/systests/cdi/base/scope/CustomScopeExtension.java b/systests/cdi/base/src/main/java/org/apache/cxf/systests/cdi/base/scope/CustomScopeExtension.java
new file mode 100644
index 0000000..99e02a7
--- /dev/null
+++ b/systests/cdi/base/src/main/java/org/apache/cxf/systests/cdi/base/scope/CustomScopeExtension.java
@@ -0,0 +1,33 @@
+/**
+ * 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.scope;
+
+import javax.enterprise.context.spi.Context;
+import javax.enterprise.event.Observes;
+import javax.enterprise.inject.spi.AfterBeanDiscovery;
+import javax.enterprise.inject.spi.BeanManager;
+import javax.enterprise.inject.spi.Extension;
+
+public class CustomScopeExtension implements Extension {
+    public void afterBeanDiscovery(@Observes AfterBeanDiscovery event, BeanManager manager) {
+        final Context context = new CustomContext(manager);
+        event.addContext(context);
+    }
+}
diff --git a/systests/cdi/base/src/main/java/org/apache/cxf/systests/cdi/base/scope/CustomScoped.java b/systests/cdi/base/src/main/java/org/apache/cxf/systests/cdi/base/scope/CustomScoped.java
new file mode 100644
index 0000000..ee4084e
--- /dev/null
+++ b/systests/cdi/base/src/main/java/org/apache/cxf/systests/cdi/base/scope/CustomScoped.java
@@ -0,0 +1,39 @@
+/**
+ * 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.scope;
+
+import java.lang.annotation.Inherited;
+import java.lang.annotation.Retention;
+import java.lang.annotation.Target;
+
+import javax.inject.Scope;
+
+import static java.lang.annotation.ElementType.FIELD;
+import static java.lang.annotation.ElementType.METHOD;
+import static java.lang.annotation.ElementType.TYPE;
+import static java.lang.annotation.RetentionPolicy.RUNTIME;
+
+@Target({ METHOD, TYPE, FIELD })
+@Retention(RUNTIME)
+@Scope
+@Inherited
+public @interface CustomScoped {
+
+}
diff --git a/systests/cdi/base/src/main/resources/META-INF/services/javax.enterprise.inject.spi.Extension b/systests/cdi/base/src/main/resources/META-INF/services/javax.enterprise.inject.spi.Extension
new file mode 100644
index 0000000..062c1b9
--- /dev/null
+++ b/systests/cdi/base/src/main/resources/META-INF/services/javax.enterprise.inject.spi.Extension
@@ -0,0 +1 @@
+org.apache.cxf.systests.cdi.base.scope.CustomScopeExtension
\ No newline at end of file
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 64a6405..aeb3083 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
@@ -32,6 +32,9 @@ import org.apache.cxf.jaxrs.validation.JAXRSBeanValidationFeature;
 import org.apache.cxf.jaxrs.validation.ValidationExceptionMapper;
 import org.apache.cxf.systests.cdi.base.BookStore;
 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;
 
 @ApplicationPath("/v2")
 public class BookStoreCustomApplication extends Application {
@@ -41,11 +44,13 @@ public class BookStoreCustomApplication extends Application {
         singletons.add(new JacksonJsonProvider());
         singletons.add(new ValidationExceptionMapper());
         singletons.add(new JAXRSBeanValidationFeature());
+        singletons.add(new LoggingFilter());
         return singletons;
     }
 
     @Override
     public Set<Class<?>> getClasses() {
-        return new LinkedHashSet<>(Arrays.asList(BookStore.class, BookStoreByIds.class));
+        return new LinkedHashSet<>(Arrays.asList(BookStore.class, BookStoreByIds.class, 
+             CustomScopedBookStore.class, RequestScopedBookStore.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 4438aaf..b6d82f2 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
@@ -18,8 +18,9 @@
  */
 package org.apache.cxf.systest.jaxrs;
 
-import java.util.Collections;
+import java.util.Arrays;
 import java.util.HashSet;
+import java.util.LinkedHashSet;
 import java.util.Set;
 
 import javax.ws.rs.ApplicationPath;
@@ -30,6 +31,9 @@ import com.fasterxml.jackson.jaxrs.json.JacksonJsonProvider;
 import org.apache.cxf.jaxrs.validation.JAXRSBeanValidationFeature;
 import org.apache.cxf.jaxrs.validation.ValidationExceptionMapper;
 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;
 
 @ApplicationPath("/v2")
 public class BookStoreCustomApplication extends Application {
@@ -39,11 +43,13 @@ public class BookStoreCustomApplication extends Application {
         singletons.add(new JacksonJsonProvider());
         singletons.add(new ValidationExceptionMapper());
         singletons.add(new JAXRSBeanValidationFeature());
+        singletons.add(new LoggingFilter());
         return singletons;
     }
 
     @Override
     public Set<Class<?>> getClasses() {
-        return Collections.<Class<?>>singleton(BookStore.class);
+        return new LinkedHashSet<>(Arrays.asList(BookStore.class, RequestScopedBookStore.class, 
+            CustomScopedBookStore.class));
     }
 }

[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 6394c3e9394dd43f027cbf694c0a32a459cdf93e
Author: reta <dr...@gmail.com>
AuthorDate: Mon Apr 12 21:11:54 2021 -0400

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

diff --git a/.gitmergeinfo b/.gitmergeinfo
index 6b86f3e..25c5e98 100644
--- a/.gitmergeinfo
+++ b/.gitmergeinfo
@@ -853,6 +853,7 @@ M c1b52e9ed11541a74d1c7d48e880052c1d38049f
 M c1b729ea9f0c43e6560099dbc427751fe33ee088
 M c2244fa94cd86e1bd1068f36d9fe2f88269f2a74
 M c673affb1cc40a38953dd9ce6b567705fa6eef46
+M cafe51572ed0a0c1452ea0685b1c750fb0df6755
 M cbc0fde7f85d01e379e40a7f27fe5cea20169ddf
 M cbeb9a21ba4a46f1861851f5bc56ee90d89a2225
 M ccb743e48e9ed99e240ae05f373b6ff799085049