Return-Path: X-Original-To: archive-asf-public-internal@cust-asf2.ponee.io Delivered-To: archive-asf-public-internal@cust-asf2.ponee.io Received: from cust-asf.ponee.io (cust-asf.ponee.io [163.172.22.183]) by cust-asf2.ponee.io (Postfix) with ESMTP id DC491200D71 for ; Thu, 21 Dec 2017 03:55:06 +0100 (CET) Received: by cust-asf.ponee.io (Postfix) id DACF9160C2B; Thu, 21 Dec 2017 02:55:06 +0000 (UTC) Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by cust-asf.ponee.io (Postfix) with SMTP id 2C06B160C15 for ; Thu, 21 Dec 2017 03:55:06 +0100 (CET) Received: (qmail 21018 invoked by uid 500); 21 Dec 2017 02:55:05 -0000 Mailing-List: contact issues-help@cxf.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@cxf.apache.org Delivered-To: mailing list issues@cxf.apache.org Received: (qmail 21007 invoked by uid 99); 21 Dec 2017 02:55:04 -0000 Received: from pnap-us-west-generic-nat.apache.org (HELO spamd1-us-west.apache.org) (209.188.14.142) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 21 Dec 2017 02:55:04 +0000 Received: from localhost (localhost [127.0.0.1]) by spamd1-us-west.apache.org (ASF Mail Server at spamd1-us-west.apache.org) with ESMTP id 67A64C4E5F for ; Thu, 21 Dec 2017 02:55:04 +0000 (UTC) X-Virus-Scanned: Debian amavisd-new at spamd1-us-west.apache.org X-Spam-Flag: NO X-Spam-Score: -99.211 X-Spam-Level: X-Spam-Status: No, score=-99.211 tagged_above=-999 required=6.31 tests=[KAM_ASCII_DIVIDERS=0.8, RCVD_IN_DNSWL_NONE=-0.0001, SPF_PASS=-0.001, T_RP_MATCHES_RCVD=-0.01, USER_IN_WHITELIST=-100] autolearn=disabled Received: from mx1-lw-eu.apache.org ([10.40.0.8]) by localhost (spamd1-us-west.apache.org [10.40.0.7]) (amavisd-new, port 10024) with ESMTP id e7nEO4cDwmvy for ; Thu, 21 Dec 2017 02:55:03 +0000 (UTC) Received: from mailrelay1-us-west.apache.org (mailrelay1-us-west.apache.org [209.188.14.139]) by mx1-lw-eu.apache.org (ASF Mail Server at mx1-lw-eu.apache.org) with ESMTP id 95CAE5F1D5 for ; Thu, 21 Dec 2017 02:55:02 +0000 (UTC) Received: from jira-lw-us.apache.org (unknown [207.244.88.139]) by mailrelay1-us-west.apache.org (ASF Mail Server at mailrelay1-us-west.apache.org) with ESMTP id ADC0EE0959 for ; Thu, 21 Dec 2017 02:55:01 +0000 (UTC) Received: from jira-lw-us.apache.org (localhost [127.0.0.1]) by jira-lw-us.apache.org (ASF Mail Server at jira-lw-us.apache.org) with ESMTP id 02DCC240DE for ; Thu, 21 Dec 2017 02:55:01 +0000 (UTC) Date: Thu, 21 Dec 2017 02:55:01 +0000 (UTC) From: "ASF GitHub Bot (JIRA)" To: issues@cxf.apache.org Message-ID: In-Reply-To: References: Subject: [jira] [Commented] (CXF-7571) Revamp of the CXF injection implementation MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-JIRA-FingerPrint: 30527f35849b9dde25b450d4833f0394 archived-at: Thu, 21 Dec 2017 02:55:07 -0000 [ https://issues.apache.org/jira/browse/CXF-7571?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16299459#comment-16299459 ] ASF GitHub Bot commented on CXF-7571: ------------------------------------- johnament commented on a change in pull request #351: [CXF-7571] Adding support for CDI injection of @Context objects. URL: https://github.com/apache/cxf/pull/351#discussion_r158187709 ########## File path: integration/cdi/src/main/java/org/apache/cxf/cdi/DelegateContextAnnotatedType.java ########## @@ -0,0 +1,182 @@ +/** + * 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.cdi; + +import java.lang.annotation.Annotation; +import java.lang.reflect.Field; +import java.lang.reflect.Type; +import java.util.Collections; +import java.util.LinkedHashSet; +import java.util.Set; +import static java.util.stream.Collectors.toSet; +import javax.enterprise.inject.spi.AnnotatedConstructor; +import javax.enterprise.inject.spi.AnnotatedField; +import javax.enterprise.inject.spi.AnnotatedMethod; +import javax.enterprise.inject.spi.AnnotatedType; +import javax.enterprise.util.AnnotationLiteral; +import javax.inject.Inject; +import javax.ws.rs.core.Context; + +final class DelegateContextAnnotatedType implements AnnotatedType { + private static final Inject INJECT = new InjectLiteral(); + private static final ContextResolved CONTEXT_RESOLVED = ContextResolved.LITERAL; + private final AnnotatedType original; + private final Set> replacedFields; + + DelegateContextAnnotatedType(AnnotatedType original) { + this.original = original; + this.replacedFields = replaceFields(original); + } + + private Set> replaceFields(AnnotatedType delegate) { + return delegate.getFields().stream().map(this::wrap).collect(toSet()); + } + + Set getContextFieldTypes() { + return replacedFields.stream() + .filter(f -> f.isAnnotationPresent(Context.class) || f.isAnnotationPresent(ContextResolved.class)) Review comment: Alright, so I've done some digging around and have bad news :-( For the custom created context objects, pretty much everything fails CDI use cases. In order to get the scoping correct, the context objects must be request scoped. However, all of the custom context objects CXF has fail CDI requirements, they don't have default constructors. As a result they can't be request scoped beans. So each of those would need to remain as `@Context` objects for injection purposes. ---------------------------------------------------------------- This is an automated message from the Apache Git Service. To respond to the message, please log on GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: users@infra.apache.org > Revamp of the CXF injection implementation > ------------------------------------------- > > Key: CXF-7571 > URL: https://issues.apache.org/jira/browse/CXF-7571 > Project: CXF > Issue Type: Improvement > Reporter: Andriy Redko > Assignee: John D. Ament > > As more deep integration with CDI revealed, there are complexities in bringing together {{@Context}}- and {{@Inject}}-based injections. Encapsulating CXF injection implementation and than delegating the hard work to appropriate strategy (CDI, Spring, ...) would be the right solution to address the problem at its roots. -- This message was sent by Atlassian JIRA (v6.4.14#64029)