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/12 22:06:24 UTC

[cxf] branch master updated: CXF-8344: org.apache.cxf.jaxrs.utils.AnnotationUtils#getNameBindings does not use ClassUnwrapper (#775)

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

reta pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/cxf.git


The following commit(s) were added to refs/heads/master by this push:
     new d812015  CXF-8344: org.apache.cxf.jaxrs.utils.AnnotationUtils#getNameBindings does not use ClassUnwrapper (#775)
d812015 is described below

commit d812015566bb421760b3389b130c08df9d658363
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
---
 .../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 6bc22cd..673243d 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
@@ -1349,8 +1349,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 6eef3f5..1f8e2cf 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
@@ -64,6 +66,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));
     }
 }