Return-Path: X-Original-To: archive-asf-public@cust-asf.ponee.io 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 319A81609E9 for ; Fri, 27 Oct 2017 18:27:57 +0200 (CEST) Received: (qmail 60608 invoked by uid 500); 27 Oct 2017 16:27:56 -0000 Mailing-List: contact dev-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 dev@cxf.apache.org Received: (qmail 60597 invoked by uid 99); 27 Oct 2017 16:27:56 -0000 Received: from ec2-52-202-80-70.compute-1.amazonaws.com (HELO gitbox.apache.org) (52.202.80.70) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 27 Oct 2017 16:27:56 +0000 From: GitBox To: dev@cxf.apache.org Subject: [GitHub] rmannibucau commented on a change in pull request #329: CXF-7501: Cannot inject field in ContainerRequestFilter (and generally, into any providers registered using FeatureContext) Message-ID: <150912167566.27246.7510301699849543629.gitbox@gitbox.apache.org> archived-at: Fri, 27 Oct 2017 16:27:57 -0000 rmannibucau commented on a change in pull request #329: CXF-7501: Cannot inject field in ContainerRequestFilter (and generally, into any providers registered using FeatureContext) URL: https://github.com/apache/cxf/pull/329#discussion_r147456626 ########## File path: integration/cdi/src/main/java/org/apache/cxf/cdi/CdiServerConfigurableFactory.java ########## @@ -0,0 +1,85 @@ +/** + * 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 javax.enterprise.context.spi.CreationalContext; +import javax.enterprise.inject.spi.AnnotatedType; +import javax.enterprise.inject.spi.Bean; +import javax.enterprise.inject.spi.BeanAttributes; +import javax.enterprise.inject.spi.BeanManager; +import javax.enterprise.inject.spi.InjectionTargetFactory; +import javax.ws.rs.RuntimeType; +import javax.ws.rs.core.Configurable; +import javax.ws.rs.core.FeatureContext; + +import org.apache.cxf.jaxrs.impl.ConfigurableImpl; +import org.apache.cxf.jaxrs.impl.ConfigurableImpl.Instantiator; +import org.apache.cxf.jaxrs.provider.ServerConfigurableFactory; + +/** + * Creates the instance of Configurable suitable for CDI-managed runtime. + */ +public class CdiServerConfigurableFactory implements ServerConfigurableFactory { + private final BeanManager beanManager; + + CdiServerConfigurableFactory(final BeanManager beanManager) { + this.beanManager = beanManager; + } + + @Override + public Configurable create(FeatureContext context) { + return new CdiServerFeatureContextConfigurable(context, beanManager); + } + + /** + * Instantiates the instance of the provider using CDI/BeanManager + */ + private static class CdiInstantiator implements Instantiator { + private final BeanManager beanManager; + + CdiInstantiator(final BeanManager beanManager) { + this.beanManager = beanManager; + } + + @Override + public Object create(Class cls) { Review comment: the client has close() so we can - worse case - use that. Also if the beanManager.isNormalScope(bean.getScope()) is true we don't need to call context.release() ---------------------------------------------------------------- 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 With regards, Apache Git Services