[jira] [Commented] (CXF-7571) Revamp of the CXF injection implementation
[ https://issues.apache.org/jira/browse/CXF-7571?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16351840#comment-16351840 ] John D. Ament commented on CXF-7571: [~dkulp] K, fixed. > Revamp of the CXF injection implementation > --- > > Key: CXF-7571 > URL: https://issues.apache.org/jira/browse/CXF-7571 > Project: CXF > Issue Type: Improvement > Components: JAX-RS >Reporter: Andriy Redko >Assignee: John D. Ament >Priority: Major > Fix For: 3.2.2 > > > 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 (v7.6.3#76005)
[jira] [Commented] (CXF-7571) Revamp of the CXF injection implementation
[ https://issues.apache.org/jira/browse/CXF-7571?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16350773#comment-16350773 ] Daniel Kulp commented on CXF-7571: -- I don't know... It was still marked open for 3.2.2 and since I'm building 3.2.2, I needed to move it out. If it IS complete, please resolve it. > 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 >Priority: Major > > 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 (v7.6.3#76005)
[jira] [Commented] (CXF-7571) Revamp of the CXF injection implementation
[ https://issues.apache.org/jira/browse/CXF-7571?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16350769#comment-16350769 ] John D. Ament commented on CXF-7571: [~dkulp] whats left to do on this? > 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 >Priority: Major > > 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 (v7.6.3#76005)
[jira] [Commented] (CXF-7571) Revamp of the CXF injection implementation
[ https://issues.apache.org/jira/browse/CXF-7571?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16325633#comment-16325633 ] ASF GitHub Bot commented on CXF-7571: - johnament closed pull request #351: [CXF-7571] Adding support for CDI injection of @Context objects. URL: https://github.com/apache/cxf/pull/351 This is a PR merged from a forked repository. As GitHub hides the original diff on merge, it is displayed below for the sake of provenance: As this is a foreign pull request (from a fork), the diff is supplied below (as it won't show otherwise due to GitHub magic): diff --git a/integration/cdi/src/main/java/org/apache/cxf/cdi/AbstractCXFBean.java b/integration/cdi/src/main/java/org/apache/cxf/cdi/AbstractCXFBean.java index dea25bfa354..687f3a8c864 100644 --- a/integration/cdi/src/main/java/org/apache/cxf/cdi/AbstractCXFBean.java +++ b/integration/cdi/src/main/java/org/apache/cxf/cdi/AbstractCXFBean.java @@ -25,21 +25,21 @@ import java.util.Set; import javax.enterprise.context.ApplicationScoped; +import javax.enterprise.context.spi.CreationalContext; import javax.enterprise.inject.Any; import javax.enterprise.inject.Default; import javax.enterprise.inject.spi.Bean; +import javax.enterprise.inject.spi.InjectionPoint; import javax.enterprise.util.AnnotationLiteral; abstract class AbstractCXFBean implements Bean { +static final Any ANY = new AnyLiteral(); +static final Default DEFAULT = new DefaultLiteral(); @Override public Set getQualifiers() { Set qualifiers = new HashSet<>(); -qualifiers.add(new AnnotationLiteral() { -private static final long serialVersionUID = 1L; -}); -qualifiers.add(new AnnotationLiteral() { -private static final long serialVersionUID = 1L; -}); +qualifiers.add(ANY); +qualifiers.add(DEFAULT); return qualifiers; } @@ -65,8 +65,27 @@ public boolean isNullable() { return false; } +@Override +public Set getInjectionPoints() { +return Collections.emptySet(); +} + + +@Override +public void destroy(T instance, CreationalContext creationalContext) { +creationalContext.release(); +} + @Override public Set< Class< ? extends Annotation > > getStereotypes() { return Collections.emptySet(); } + +private static class DefaultLiteral extends AnnotationLiteral implements Default { +private static final long serialVersionUID = 1L; +} + +private static class AnyLiteral extends AnnotationLiteral implements Any { +private static final long serialVersionUID = 1L; +} } diff --git a/integration/cdi/src/main/java/org/apache/cxf/cdi/ContextProducerBean.java b/integration/cdi/src/main/java/org/apache/cxf/cdi/ContextProducerBean.java new file mode 100644 index 000..7fab97782d7 --- /dev/null +++ b/integration/cdi/src/main/java/org/apache/cxf/cdi/ContextProducerBean.java @@ -0,0 +1,100 @@ +/** + * 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.ParameterizedType; +import java.lang.reflect.Type; +import java.util.HashSet; +import java.util.Set; + +import javax.enterprise.context.RequestScoped; +import javax.enterprise.context.spi.CreationalContext; +import javax.enterprise.inject.spi.PassivationCapable; + +import org.apache.cxf.jaxrs.utils.JAXRSUtils; +import org.apache.cxf.message.Message; +import org.apache.cxf.phase.PhaseInterceptorChain; + +public class ContextProducerBean extends AbstractCXFBean implements PassivationCapable { +private final Type type; + +ContextProducerBean(Type type) { +this.type = type; +} + +@Override +public Set getQualifiers() { +Set qualifiers = new HashSet<>(2); +qualifiers.add(ContextResolved.LITERAL); +qualifiers.add(DEFAULT); +return qualifiers; +} + +@Override +public Class getScope() { +return RequestScoped.class; +} + +@Override +public Class getBeanClass() { +return (Class)type; +} + +@Override +
[jira] [Commented] (CXF-7571) Revamp of the CXF injection implementation
[ https://issues.apache.org/jira/browse/CXF-7571?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16325632#comment-16325632 ] ASF GitHub Bot commented on CXF-7571: - johnament commented on issue #351: [CXF-7571] Adding support for CDI injection of @Context objects. URL: https://github.com/apache/cxf/pull/351#issuecomment-357519951 I'll address any remaining issues in a separate PR. I'm still curious about removing the current logic for providers, but can address that later. 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: us...@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)
[jira] [Commented] (CXF-7571) Revamp of the CXF injection implementation
[ https://issues.apache.org/jira/browse/CXF-7571?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16325580#comment-16325580 ] ASF GitHub Bot commented on CXF-7571: - johnament commented on issue #351: [CXF-7571] Adding support for CDI injection of @Context objects. URL: https://github.com/apache/cxf/pull/351#issuecomment-357511714 @reta originally I wasn't going to do that, since its just a CDI feature. But I updated the existing resources to demonstrate both constructor and field injection. 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: us...@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)
[jira] [Commented] (CXF-7571) Revamp of the CXF injection implementation
[ https://issues.apache.org/jira/browse/CXF-7571?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16325414#comment-16325414 ] ASF GitHub Bot commented on CXF-7571: - reta commented on issue #351: [CXF-7571] Adding support for CDI injection of @Context objects. URL: https://github.com/apache/cxf/pull/351#issuecomment-357481029 One specific use case which I was not able to find the clean way to implement is using constructor-based injection for `@Context` instances (in this case the `Message` instance is not available). Are you planning to include the support for that? 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: us...@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)
[jira] [Commented] (CXF-7571) Revamp of the CXF injection implementation
[ https://issues.apache.org/jira/browse/CXF-7571?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16325407#comment-16325407 ] ASF GitHub Bot commented on CXF-7571: - reta commented on issue #351: [CXF-7571] Adding support for CDI injection of @Context objects. URL: https://github.com/apache/cxf/pull/351#issuecomment-357480755 @johnament I think it is acceptable to not test each module (the service loader). You have a test case for that in the CDI test suite, it should work just fine I think. 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: us...@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)
[jira] [Commented] (CXF-7571) Revamp of the CXF injection implementation
[ https://issues.apache.org/jira/browse/CXF-7571?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16325295#comment-16325295 ] 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_r161379748 ## File path: rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/utils/InjectionUtils.java ## @@ -1526,4 +1529,13 @@ public static Type processGenericTypeIfNeeded(Class serviceCls, Class para public static Object getEntity(Object o) { return o instanceof GenericEntity ? ((GenericEntity)o).getEntity() : o; } + +public static SetgetCustomContextClasses() { Review comment: Sure, but just to confirm the actual interface `ContextClassProvider` stays in frontend/jax-rs since multiple modules will use it (and shouldn't rely on CDI) 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: us...@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)
[jira] [Commented] (CXF-7571) Revamp of the CXF injection implementation
[ https://issues.apache.org/jira/browse/CXF-7571?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16325294#comment-16325294 ] ASF GitHub Bot commented on CXF-7571: - reta 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_r161379679 ## File path: rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/utils/InjectionUtils.java ## @@ -1526,4 +1529,13 @@ public static Type processGenericTypeIfNeeded(Class serviceCls, Class para public static Object getEntity(Object o) { return o instanceof GenericEntity ? ((GenericEntity)o).getEntity() : o; } + +public static SetgetCustomContextClasses() { Review comment: Moving to CDI module would be better I believe, so it would be clear where this flow belongs to 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: us...@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)
[jira] [Commented] (CXF-7571) Revamp of the CXF injection implementation
[ https://issues.apache.org/jira/browse/CXF-7571?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16325235#comment-16325235 ] ASF GitHub Bot commented on CXF-7571: - johnament commented on issue #351: [CXF-7571] Adding support for CDI injection of @Context objects. URL: https://github.com/apache/cxf/pull/351#issuecomment-357452426 BTW, I'm assuming that there was some code added already that handled `@Context` for CDI objects. I should probably pull that out in this change, but I'm not sure where that's happening. 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: us...@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)
[jira] [Commented] (CXF-7571) Revamp of the CXF injection implementation
[ https://issues.apache.org/jira/browse/CXF-7571?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16325215#comment-16325215 ] 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_r161376606 ## File path: rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/utils/InjectionUtils.java ## @@ -1526,4 +1529,13 @@ public static Type processGenericTypeIfNeeded(Class serviceCls, Class para public static Object getEntity(Object o) { return o instanceof GenericEntity ? ((GenericEntity)o).getEntity() : o; } + +public static SetgetCustomContextClasses() { Review comment: Is this utility OK to include here? Or should I move it into the CDI module? 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: us...@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)
[jira] [Commented] (CXF-7571) Revamp of the CXF injection implementation
[ https://issues.apache.org/jira/browse/CXF-7571?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16325214#comment-16325214 ] 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_r161376582 ## 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 SetreplacedFields; + +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: This is now working fine. With the service loader approach, we can `@Inject` any context object we want now. 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: us...@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)
[jira] [Commented] (CXF-7571) Revamp of the CXF injection implementation
[ https://issues.apache.org/jira/browse/CXF-7571?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16325212#comment-16325212 ] ASF GitHub Bot commented on CXF-7571: - johnament commented on issue #351: [CXF-7571] Adding support for CDI injection of @Context objects. URL: https://github.com/apache/cxf/pull/351#issuecomment-357449893 Ok, so I had a logic issue (and sorry for the delay in getting this done, I've been a bit more offline the past week and a half) in the new context object that I created (`message.getId()` is always null for rest messages). So this is all working well, I'm going to plan to add the service loader to the identified modules but I don't see a lot of value in testing them. What do you think @reta @sberyozkin ? 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: us...@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)
[jira] [Commented] (CXF-7571) Revamp of the CXF injection implementation
[ https://issues.apache.org/jira/browse/CXF-7571?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16307029#comment-16307029 ] ASF GitHub Bot commented on CXF-7571: - reta 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_r159132277 ## File path: systests/cdi/base/src/main/java/org/apache/cxf/systests/cdi/base/BookStoreVersion.java ## @@ -22,20 +22,25 @@ import javax.enterprise.context.RequestScoped; import javax.inject.Inject; import javax.ws.rs.GET; -import javax.ws.rs.core.Context; import javax.ws.rs.core.HttpHeaders; import javax.ws.rs.core.MediaType; import javax.ws.rs.core.Response; +import org.apache.cxf.systests.cdi.base.context.CustomContext; + @RequestScoped public class BookStoreVersion { @Inject private String version; -@Context +@Inject private HttpHeaders httpHeaders; +@Inject Review comment: @johnament I conducted a short debug session, it looks like it is working as expected / described, I see `DelegateContextAnnotatedType`, `ContextProducerBean` and finally `CustomContextImpl` being invoked in case when `CustomContext` is annotated with `@Context` annotation. Interesting, what is happening in your case ... 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: us...@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)
[jira] [Commented] (CXF-7571) Revamp of the CXF injection implementation
[ https://issues.apache.org/jira/browse/CXF-7571?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16306856#comment-16306856 ] 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_r159124524 ## File path: systests/cdi/base/src/main/java/org/apache/cxf/systests/cdi/base/BookStoreVersion.java ## @@ -22,20 +22,25 @@ import javax.enterprise.context.RequestScoped; import javax.inject.Inject; import javax.ws.rs.GET; -import javax.ws.rs.core.Context; import javax.ws.rs.core.HttpHeaders; import javax.ws.rs.core.MediaType; import javax.ws.rs.core.Response; +import org.apache.cxf.systests.cdi.base.context.CustomContext; + @RequestScoped public class BookStoreVersion { @Inject private String version; -@Context +@Inject private HttpHeaders httpHeaders; +@Inject Review comment: @reta yes, that's what I'm expecting to happen, however I'm never seeing the bean invoked for this context object. 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: us...@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)
[jira] [Commented] (CXF-7571) Revamp of the CXF injection implementation
[ https://issues.apache.org/jira/browse/CXF-7571?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16306434#comment-16306434 ] ASF GitHub Bot commented on CXF-7571: - reta 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_r159089178 ## File path: systests/cdi/base/src/main/java/org/apache/cxf/systests/cdi/base/BookStoreVersion.java ## @@ -22,20 +22,25 @@ import javax.enterprise.context.RequestScoped; import javax.inject.Inject; import javax.ws.rs.GET; -import javax.ws.rs.core.Context; import javax.ws.rs.core.HttpHeaders; import javax.ws.rs.core.MediaType; import javax.ws.rs.core.Response; +import org.apache.cxf.systests.cdi.base.context.CustomContext; + @RequestScoped public class BookStoreVersion { @Inject private String version; -@Context +@Inject private HttpHeaders httpHeaders; +@Inject Review comment: @johnament Not sure I understood the exact nature of the problem, but with `@Context` annotation the `CustomContext` is being processed by `DelegateContextAnnotatedType` which injects into it the proxy value (CDI managed one), and later on the instance is created by `ContextProducerBean` on first invocation. Is it something along this lines or absolutely different flow? 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: us...@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)
[jira] [Commented] (CXF-7571) Revamp of the CXF injection implementation
[ https://issues.apache.org/jira/browse/CXF-7571?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16305937#comment-16305937 ] 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_r159021453 ## File path: systests/cdi/base/src/main/java/org/apache/cxf/systests/cdi/base/BookStoreVersion.java ## @@ -22,20 +22,25 @@ import javax.enterprise.context.RequestScoped; import javax.inject.Inject; import javax.ws.rs.GET; -import javax.ws.rs.core.Context; import javax.ws.rs.core.HttpHeaders; import javax.ws.rs.core.MediaType; import javax.ws.rs.core.Response; +import org.apache.cxf.systests.cdi.base.context.CustomContext; + @RequestScoped public class BookStoreVersion { @Inject private String version; -@Context +@Inject private HttpHeaders httpHeaders; +@Inject Review comment: @sberyozkin @reta I'm a bit stumped at this point. Even when I annotate the field with `@Context`, I don't see it being processed using my `ContextProvider` yet somehow there is a value set.. 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: us...@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)
[jira] [Commented] (CXF-7571) Revamp of the CXF injection implementation
[ https://issues.apache.org/jira/browse/CXF-7571?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16301682#comment-16301682 ] ASF GitHub Bot commented on CXF-7571: - reta 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_r158527866 ## File path: systests/cdi/base/src/main/java/org/apache/cxf/systests/cdi/base/OpenTracingProducer.java ## @@ -0,0 +1,32 @@ +/** + * 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.ApplicationScoped; +import javax.enterprise.inject.Produces; +import org.apache.cxf.tracing.opentracing.jaxrs.OpenTracingFeature; + +@ApplicationScoped +public class OpenTracingProducer { Review comment: Adding `bean.xml` to `opentracing` module fixed the issue right away, the `OpenTracingFeature` has been discovered. As a side note, could you please move these testcases to `systest-tracing` project, it would be good to keep the CDI tests clean from external integration. Thank you. 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: us...@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)
[jira] [Commented] (CXF-7571) Revamp of the CXF injection implementation
[ https://issues.apache.org/jira/browse/CXF-7571?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16301609#comment-16301609 ] ASF GitHub Bot commented on CXF-7571: - reta 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_r158518372 ## File path: systests/cdi/base/src/main/java/org/apache/cxf/systests/cdi/base/OpenTracingProducer.java ## @@ -0,0 +1,32 @@ +/** + * 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.ApplicationScoped; +import javax.enterprise.inject.Produces; +import org.apache.cxf.tracing.opentracing.jaxrs.OpenTracingFeature; + +@ApplicationScoped +public class OpenTracingProducer { Review comment: I will take a look, should be working (in general but we haven't tested with CDI) 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: us...@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)
[jira] [Commented] (CXF-7571) Revamp of the CXF injection implementation
[ https://issues.apache.org/jira/browse/CXF-7571?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16301517#comment-16301517 ] 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_r158503924 ## File path: integration/tracing/tracing-opentracing/src/main/java/org/apache/cxf/tracing/opentracing/jaxrs/OpenTracingTracerContextClassProvider.java ## @@ -0,0 +1,29 @@ +/** + * 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.tracing.opentracing.jaxrs; + +import org.apache.cxf.jaxrs.ext.ContextClassProvider; +import org.apache.cxf.tracing.TracerContext; + +public class OpenTracingTracerContextClassProvider implements ContextClassProvider { Review comment: I just tested it, using a static method won't work. I'm assuming that the class is loaded too late to register via the CDI extension. Are there any concerns with a service loader based approach? 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: us...@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)
[jira] [Commented] (CXF-7571) Revamp of the CXF injection implementation
[ https://issues.apache.org/jira/browse/CXF-7571?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16301507#comment-16301507 ] 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_r158501464 ## File path: systests/cdi/base/src/main/java/org/apache/cxf/systests/cdi/base/OpenTracingProducer.java ## @@ -0,0 +1,32 @@ +/** + * 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.ApplicationScoped; +import javax.enterprise.inject.Produces; +import org.apache.cxf.tracing.opentracing.jaxrs.OpenTracingFeature; + +@ApplicationScoped +public class OpenTracingProducer { Review comment: I couldn't get automatic registration to work. Not sure why, but I went with the hint from Sergey and added an explicit producer to make sure it was a CDI bean. 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: us...@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)
[jira] [Commented] (CXF-7571) Revamp of the CXF injection implementation
[ https://issues.apache.org/jira/browse/CXF-7571?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16301506#comment-16301506 ] 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_r158501296 ## File path: integration/tracing/tracing-opentracing/src/main/java/org/apache/cxf/tracing/opentracing/jaxrs/OpenTracingTracerContextClassProvider.java ## @@ -0,0 +1,29 @@ +/** + * 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.tracing.opentracing.jaxrs; + +import org.apache.cxf.jaxrs.ext.ContextClassProvider; +import org.apache.cxf.tracing.TracerContext; + +public class OpenTracingTracerContextClassProvider implements ContextClassProvider { Review comment: This is one approach. Now that I know what to do to fix the registration, I'm going to try with the explicit class addition via static method, see if that works. But this would be the alternative via service loader. 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: us...@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)
[jira] [Commented] (CXF-7571) Revamp of the CXF injection implementation
[ https://issues.apache.org/jira/browse/CXF-7571?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16301302#comment-16301302 ] ASF GitHub Bot commented on CXF-7571: - sberyozkin commented on issue #351: [CXF-7571] Adding support for CDI injection of @Context objects. URL: https://github.com/apache/cxf/pull/351#issuecomment-353583573 Yeah, that OAuthContext has never been injectable :-), I did it awhile back and the idea was that may be the RS code might want to get the current access token properties like messageContext,getContent(OAuthContext.class), but indeed, it would need to be converted to the interface for it to be accessed as Context... 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: us...@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)
[jira] [Commented] (CXF-7571) Revamp of the CXF injection implementation
[ https://issues.apache.org/jira/browse/CXF-7571?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16300716#comment-16300716 ] ASF GitHub Bot commented on CXF-7571: - johnament commented on issue #351: [CXF-7571] Adding support for CDI injection of @Context objects. URL: https://github.com/apache/cxf/pull/351#issuecomment-353482392 Ok, that makes me feel better. there is one that doesn't have an interface, so it will be an issue: `OAuthContext`. But we could just skip it for now. Here's something that is a possible issue. `UserInfoContext` extends `IdTokenContext`, so you could end up with ambiguous dependencies (but may not if i only register one type). So I probably wasn't too far off, just off by 1. 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: us...@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)
[jira] [Commented] (CXF-7571) Revamp of the CXF injection implementation
[ https://issues.apache.org/jira/browse/CXF-7571?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16300530#comment-16300530 ] ASF GitHub Bot commented on CXF-7571: - sberyozkin commented on issue #351: [CXF-7571] Adding support for CDI injection of @Context objects. URL: https://github.com/apache/cxf/pull/351#issuecomment-353449573 IdTokenContext is an interface: https://github.com/apache/cxf/blob/master/rt/rs/security/sso/oidc/src/main/java/org/apache/cxf/rs/security/oidc/rp/IdTokenContext.java 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: us...@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)
[jira] [Commented] (CXF-7571) Revamp of the CXF injection implementation
[ https://issues.apache.org/jira/browse/CXF-7571?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16300498#comment-16300498 ] ASF GitHub Bot commented on CXF-7571: - reta commented on issue #351: [CXF-7571] Adding support for CDI injection of @Context objects. URL: https://github.com/apache/cxf/pull/351#issuecomment-353442636 `@Context TracerContext` only, the provider is specific to tracing framework, but interface is same for everyone 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: us...@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)
[jira] [Commented] (CXF-7571) Revamp of the CXF injection implementation
[ https://issues.apache.org/jira/browse/CXF-7571?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16300354#comment-16300354 ] ASF GitHub Bot commented on CXF-7571: - johnament commented on issue #351: [CXF-7571] Adding support for CDI injection of @Context objects. URL: https://github.com/apache/cxf/pull/351#issuecomment-353413392 @reta so should a user be doing `@Context OpenTracingContext` or `@Context TracerContext` to get the injection? CDI can support the latter, but the former isn't a valid bean. I also think the OIDC context objects fail in this area as well. 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: us...@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)
[jira] [Commented] (CXF-7571) Revamp of the CXF injection implementation
[ https://issues.apache.org/jira/browse/CXF-7571?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16300350#comment-16300350 ] ASF GitHub Bot commented on CXF-7571: - reta commented on issue #351: [CXF-7571] Adding support for CDI injection of @Context objects. URL: https://github.com/apache/cxf/pull/351#issuecomment-353412834 @johnament Hm ... most context objects do have interfaces, if we look on STANDARD_CONTEXT_CLASSES. Custom contexts also do have them, f.e. `TracerContext` is the interface. Or you mean different API objects? 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: us...@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)
[jira] [Commented] (CXF-7571) Revamp of the CXF injection implementation
[ https://issues.apache.org/jira/browse/CXF-7571?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16300345#comment-16300345 ] ASF GitHub Bot commented on CXF-7571: - reta 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_r158336534 ## 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 SetreplacedFields; + +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: I expected the roadblocks here, `@Context` it be ... 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: us...@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)
[jira] [Commented] (CXF-7571) Revamp of the CXF injection implementation
[ https://issues.apache.org/jira/browse/CXF-7571?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16300253#comment-16300253 ] ASF GitHub Bot commented on CXF-7571: - sberyozkin commented on issue #351: [CXF-7571] Adding support for CDI injection of @Context objects. URL: https://github.com/apache/cxf/pull/351#issuecomment-353397838 "My thinking is to replace the current API objects that are concrete with interfaces" - what do you mean ? 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: us...@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)
[jira] [Commented] (CXF-7571) Revamp of the CXF injection implementation
[ https://issues.apache.org/jira/browse/CXF-7571?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16300240#comment-16300240 ] ASF GitHub Bot commented on CXF-7571: - johnament commented on issue #351: [CXF-7571] Adding support for CDI injection of @Context objects. URL: https://github.com/apache/cxf/pull/351#issuecomment-353395855 I had a thought at the end of the day yesterday on this. The problem around proxying is because most of the context objects don't have interfaces. If we use an interface, the impl doesn't need to be proxyable (its weird, counterintuitive, but it works). My thinking is to replace the current API objects that are concrete with interfaces, and encourage users to use that if they want CDI injection. Does that make sense @reta @sberyozkin ? 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: us...@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)
[jira] [Commented] (CXF-7571) Revamp of the CXF injection implementation
[ https://issues.apache.org/jira/browse/CXF-7571?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=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 SetreplacedFields; + +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: us...@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)
[jira] [Commented] (CXF-7571) Revamp of the CXF injection implementation
[ https://issues.apache.org/jira/browse/CXF-7571?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16297415#comment-16297415 ] 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_r157872871 ## 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 SetreplacedFields; + +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: I would still recommend keeping `@ContextResolved` just to allow multiple beans to be registered (avoiding close tie in). I'll work on getting the additional field processed and update this PR. 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: us...@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)
[jira] [Commented] (CXF-7571) Revamp of the CXF injection implementation
[ https://issues.apache.org/jira/browse/CXF-7571?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16294967#comment-16294967 ] ASF GitHub Bot commented on CXF-7571: - reta 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_r157485092 ## 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 SetreplacedFields; + +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: Right, forgot about that, this is what you was referring to as manual registration. Ok, here is my suggestion, let us start from this simple solution (either using `InjectionUtils.STANDARD_CONTEXT_CLASSES`, or in safer with another collection, f.e. `InjectionUtils.NON_STANDARD_CONTEXT_CLASSES`), and revisit it later when the PR would be more or less feature complete. I suspect we are going to have quite a few challenges ahead, so we may use absolutely different approach at the end :-) At least we could get rid of `@ContextResolved` for now and move on. Sounds good? 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: us...@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)
[jira] [Commented] (CXF-7571) Revamp of the CXF injection implementation
[ https://issues.apache.org/jira/browse/CXF-7571?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16294429#comment-16294429 ] 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_r157387990 ## 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 SetreplacedFields; + +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: @reta just want to clarify my point a bit more. The simplest solution I can think of is to add this snippet to `BraveContextProvider` ```java static { InjectionUtils.STANDARD_CONTEXT_CLASSES.add(BraveTracerContext.class.getName()); } ``` Or do something like require a service loader to give the class name. Then you wouldn't need to do things like make the providers CDI component classes (which doesn't sound right). FWIW, I'm almost inclined to add `` to modules that shouldn't have CDI beans within them, to avoid excessive classloadering. But another day. 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: us...@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)
[jira] [Commented] (CXF-7571) Revamp of the CXF injection implementation
[ https://issues.apache.org/jira/browse/CXF-7571?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16294424#comment-16294424 ] ASF GitHub Bot commented on CXF-7571: - reta 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_r157386997 ## 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 SetreplacedFields; + +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: Sorry for keeping silence, haven't had time to get back to the issue. Spent some time playing with the context providers, my personal option (purely from user perspective), using `@Inject @ContextResolved SomeContext context` is not very intuitive. Getting back to the initial problem: `@Inject TracerContext` and `@Context TracerContext`. Besides the solution you have with `@ContextResolved`, we could also introduce 1) a marker interface for context objects 2) or an annotation (similar to `@ContextResolved`) for context objects 3) require context providers to be placed into CDI archives (than at least we could discover the possible context objects while processing annotated types) There are certainly more options available, but I think the 3rd one is as best as we could do without introducing too much of confusion. That would certainly impose some constraints (as you mentioned before) but may be it is not as bad as it sounds? What do you think? 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: us...@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)
[jira] [Commented] (CXF-7571) Revamp of the CXF injection implementation
[ https://issues.apache.org/jira/browse/CXF-7571?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16285437#comment-16285437 ] 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_r155968867 ## 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 SetreplacedFields; + +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: We could, however it seems that the registration of the `ContextProvider` is done within CXF, which would be too late for CDI. In addition, I don't want to require/expect that all `ContextProvider` impls are CDI beans. 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: us...@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)
[jira] [Commented] (CXF-7571) Revamp of the CXF injection implementation
[ https://issues.apache.org/jira/browse/CXF-7571?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16277736#comment-16277736 ] ASF GitHub Bot commented on CXF-7571: - reta 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_r154805454 ## 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 SetreplacedFields; + +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: I think we could only manually register the context providers which come from CXF, but not the user ones. May be we could deduct the context providers by introspecting the providers / resources / features during the `collect`? We have interface to check for, `ContextProvider`, this should for all cases. What do you think? 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: us...@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)
[jira] [Commented] (CXF-7571) Revamp of the CXF injection implementation
[ https://issues.apache.org/jira/browse/CXF-7571?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16277735#comment-16277735 ] ASF GitHub Bot commented on CXF-7571: - reta 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_r154805454 ## 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 SetreplacedFields; + +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: I think we could only manually register the context providers which come from CXF, but not the user ones. May be could deduct the context providers by introspecting the providers / resources / features during the `collect`? We have interface to check for, `ContextProvider`, this should for all cases. What do you think? 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: us...@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)
[jira] [Commented] (CXF-7571) Revamp of the CXF injection implementation
[ https://issues.apache.org/jira/browse/CXF-7571?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16277511#comment-16277511 ] 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_r154777036 ## 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 SetreplacedFields; + +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: So what do you think about adding support for registering the context type, manually? 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: us...@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)
[jira] [Commented] (CXF-7571) Revamp of the CXF injection implementation
[ https://issues.apache.org/jira/browse/CXF-7571?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16276129#comment-16276129 ] ASF GitHub Bot commented on CXF-7571: - reta 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_r154538914 ## 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 SetreplacedFields; + +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: Aha, thanks for explanation @johnament, the role of `@ContextResolved` becomes clear now. That's actually an interesting challenge to solve ... We definitely know all of them at the moment `JAXRSServerFactoryBean` is being constructed but it is too late with respect to CDI lifecycle (and what can we do at this point). 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: us...@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)
[jira] [Commented] (CXF-7571) Revamp of the CXF injection implementation
[ https://issues.apache.org/jira/browse/CXF-7571?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16275948#comment-16275948 ] 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_r154524699 ## 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 SetreplacedFields; + +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: It would be for anything that isn't in the `STANDARD_CONTEXT` map, but is explicitly annotated and provided as a `Context` object. Could be anything with a custom `ContextProvider` implemented that isn't injected using `@Context` but has the qualifier. 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: us...@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)
[jira] [Commented] (CXF-7571) Revamp of the CXF injection implementation
[ https://issues.apache.org/jira/browse/CXF-7571?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16275946#comment-16275946 ] John D. Ament commented on CXF-7571: If it makes sense, we can create separate tickets for CDI/Spring injection. But IMHO it won't be done until we stop processing {{@Context}} injection for those runtimes. To do that, we'll need handle methods as well (which this doesn't do). > 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)
[jira] [Commented] (CXF-7571) Revamp of the CXF injection implementation
[ https://issues.apache.org/jira/browse/CXF-7571?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16275773#comment-16275773 ] 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_r154509313 ## File path: rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/impl/ResourceContextImpl.java ## @@ -30,13 +32,15 @@ public class ResourceContextImpl implements ResourceContext { private static final String CONTEXT_PROVIDER_PROP = "org.apache.cxf.jaxrs.resource.context.provider"; -private ClassResourceInfo cri; -private Class subClass; -private Message m; -public ResourceContextImpl(Message m, OperationResourceInfo ori) { +private final ClassUnwrapper classUnwrapper; +private final ClassResourceInfo cri; +private final Class subClass; +private final Message m; +public ResourceContextImpl(Message m, OperationResourceInfo ori, Bus bus) { Review comment: I need to revert this change. 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: us...@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: Andriy Redko > > 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)
[jira] [Commented] (CXF-7571) Revamp of the CXF injection implementation
[ https://issues.apache.org/jira/browse/CXF-7571?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16275774#comment-16275774 ] 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_r154509322 ## File path: systests/cdi/base/src/main/java/org/apache/cxf/systests/cdi/base/BookStore.java ## @@ -38,13 +39,11 @@ @Path("/bookstore/") public class BookStore { @Inject private BookStoreService service; -@Inject private String version; +@Inject private BookStoreVersion bookStoreVersion; -@GET @Path("/version") -@Produces(MediaType.TEXT_PLAIN) -public String getVersion() { -return version; +public BookStoreVersion getVersion(@Context ResourceContext resourceContext) { Review comment: I need to remove this. 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: us...@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: Andriy Redko > > 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)
[jira] [Commented] (CXF-7571) Revamp of the CXF injection implementation
[ https://issues.apache.org/jira/browse/CXF-7571?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16275772#comment-16275772 ] ASF GitHub Bot commented on CXF-7571: - johnament opened a new pull request #351: [CXF-7571] Adding support for CDI injection of @Context objects. URL: https://github.com/apache/cxf/pull/351 This is a WIP right now (needs more testing). But it does the gist of what I was aiming to do, which is to make it so that CDI takes over injection. I figure there's areas of the code that have to be removed now. If you guys have some pointers about where they might be, would be great. 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: us...@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: Andriy Redko > > 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)
[jira] [Commented] (CXF-7571) Revamp of the CXF injection implementation
[ https://issues.apache.org/jira/browse/CXF-7571?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16275336#comment-16275336 ] John D. Ament commented on CXF-7571: [~reta] this is assigned to you, but if you need help I'm happy to start on the work. I ran into a similar issue, https://lists.apache.org/thread.html/40c3438b7299d53063b5ae98f6a6d674ea8b1c954f9af160033c05f8@%3Cdev.cxf.apache.org%3E , where {{@Context}} doesn't work for sub-resources. I started to add support, but it doesn't make sense if we're going to make the contexts all CDI aware. > 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: Andriy Redko > > 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)
[jira] [Commented] (CXF-7571) Revamp of the CXF injection implementation
[ https://issues.apache.org/jira/browse/CXF-7571?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16267068#comment-16267068 ] Andriy Redko commented on CXF-7571: --- Yep, sounds like a great plan to move it forward, thanks [~johndament], [~sergey_beryozkin] > 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: Andriy Redko > > 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)
[jira] [Commented] (CXF-7571) Revamp of the CXF injection implementation
[ https://issues.apache.org/jira/browse/CXF-7571?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16266857#comment-16266857 ] Sergey Beryozkin commented on CXF-7571: --- That sounds good, if a fix like that at the CXF CDI level would enable the support of @Inject for the JAX-RS contexts (which works for Jersey, RestEasy) then it would be massive. Lets start from this enhancement first :-) > 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: Andriy Redko > > 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)
[jira] [Commented] (CXF-7571) Revamp of the CXF injection implementation
[ https://issues.apache.org/jira/browse/CXF-7571?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16266850#comment-16266850 ] John D. Ament commented on CXF-7571: Sergey, no, that's not what I am suggesting. In the CDI extension, find any managed bean that declares a {{@Context}}, and update the underlying {{Annotated}} object to add {{@Inject}} to the annotations. CDI exposes {{AnnotatedField}}, {{AnnotatedMethod}}, {{AnnotatedParameter}} for these use cases. For instance, if a method param is annotated {{@Context}} you'll need to add {{@Inject}} to the method. What will be curious is how to handle {{@Context}} in a service method. I did something like that recently for a custom event model I was implementing. This would allow CDI to take over the injection of the field, since it'll have the JSR-330 annotation. I think Andriy has my point. It makes it so that CXF doesn't have to do anything (other than register additional beans). > 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: Andriy Redko > > 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)
[jira] [Commented] (CXF-7571) Revamp of the CXF injection implementation
[ https://issues.apache.org/jira/browse/CXF-7571?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16266842#comment-16266842 ] Andriy Redko commented on CXF-7571: --- I think this is what we aim to as well, so the CXF won't be doing the work framework should be doing (and we get rid of any issues caused f.e. by bean proxies, etc). But there are also cases when DI framework is not in place, so the injection still has to work as expected. > 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: Andriy Redko > > 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)
[jira] [Commented] (CXF-7571) Revamp of the CXF injection implementation
[ https://issues.apache.org/jira/browse/CXF-7571?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16266837#comment-16266837 ] Sergey Beryozkin commented on CXF-7571: --- John, are you suggesting to update the code which checks '@Context' to also check '@Inject' ? That may work in the short term I guess, there used to be the code checking @Conext and @Resource... > 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: Andriy Redko > > 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)
[jira] [Commented] (CXF-7571) Revamp of the CXF injection implementation
[ https://issues.apache.org/jira/browse/CXF-7571?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16266816#comment-16266816 ] John D. Ament commented on CXF-7571: yeah, but you have to weigh what the spec is asking for vs what may make sense to do in a future JAX-RS impl. Its pretty simple IMHO to loop through the annotated fields and add {{@Inject}} to each {{@Context}} field. Personally, I think having support for {{@Inject}} for the built in {{@Context}} objects makes sense. But to solve that, I think it makes the most sense to just register them as beans and then satisfy what I just described. You get the added benefit that any CDI bean could inject a {{UriInfo}} for instance. > 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: Andriy Redko > > 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)
[jira] [Commented] (CXF-7571) Revamp of the CXF injection implementation
[ https://issues.apache.org/jira/browse/CXF-7571?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16266644#comment-16266644 ] Sergey Beryozkin commented on CXF-7571: --- Indeed, if we keep patching to support CDI-specific cases where @Context does not work then it will only keep us further away from achieving "@Inject UriInfo ui", etc. IMHO all the existing injection code has to be moved to a default strategy first, without worrying about CDI/etc. Once it's done and the confidence is there it does work, then a CDI specific strategy will cleanly replace the default strategy when needed. > 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: Andriy Redko > > 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)
[jira] [Commented] (CXF-7571) Revamp of the CXF injection implementation
[ https://issues.apache.org/jira/browse/CXF-7571?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16266031#comment-16266031 ] Andriy Redko commented on CXF-7571: --- I wish it would be as simple as that :-) There are two major issues: - proxified beans (in this case InjectionUtils inject proxies into bean's proxy, not into the backing bean) - the more generic design issue: the injections implementation is blurred between CXF and whatever DI framework it may integrate with (CDI f.e) As of now, the injection works in most cases (except field-based injection into proxified beans which could be workarounded). But this split of responsibilities makes it very hard to cover all possible cases. > 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: Andriy Redko > > 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)