[GitHub] [cxf] andymc12 opened a new pull request #680: [CXF-8299][CXF-8304] QueryParamStyles and CDI-managed providers for MP Rest Client 2.0

classic Classic list List threaded Threaded
7 messages Options
Reply | Threaded
Open this post in threaded view
|

[GitHub] [cxf] andymc12 opened a new pull request #680: [CXF-8299][CXF-8304] QueryParamStyles and CDI-managed providers for MP Rest Client 2.0

GitBox

andymc12 opened a new pull request #680:
URL: https://github.com/apache/cxf/pull/680


   This PR fixes [CXF-8299](https://issues.apache.org/jira/browse/CXF-8299) (QueryParamStyles) and [CXF-8304](https://issues.apache.org/jira/browse/CXF-8304) (CDI-managed providers), and supersedes PR #678.
   
   For 8299, this allows the client to specify how collections should be handle when using query parameters - i.e. expanded, expanded with array syntax (required for PHP servers), or with a single key but comma-separated values.
   
   For 8304, this changes the way providers are instantiated. If CDI is managing an instance of the provider class, then the client implementation should use that instance rather than creating a new instance.  This should only apply in cases where the interface registers the provider _class_, and not cases where it registers an _instance_ of the provider.
   


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
[hidden email]


Reply | Threaded
Open this post in threaded view
|

[GitHub] [cxf] reta commented on a change in pull request #680: [CXF-8299][CXF-8304] QueryParamStyles and CDI-managed providers for MP Rest Client 2.0

GitBox

reta commented on a change in pull request #680:
URL: https://github.com/apache/cxf/pull/680#discussion_r441243634



##########
File path: rt/rs/microprofile-client/src/main/java/org/apache/cxf/microprofile/client/cdi/CDIInstantiator.java
##########
@@ -0,0 +1,61 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.cxf.microprofile.client.cdi;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import org.apache.cxf.jaxrs.impl.ConfigurableImpl.Instantiator;
+
+
+public final class CDIInstantiator implements Instantiator {
+
+    static final CDIInstantiator INSTANCE = new CDIInstantiator();
+
+    private final Map<Object, Instance<?>> cdiInstances = new HashMap<>();

Review comment:
       Won't `IdentityHashMap` be a bit more appropriate here since we track references essentially?




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
[hidden email]


Reply | Threaded
Open this post in threaded view
|

[GitHub] [cxf] reta commented on a change in pull request #680: [CXF-8299][CXF-8304] QueryParamStyles and CDI-managed providers for MP Rest Client 2.0

GitBox
In reply to this post by GitBox

reta commented on a change in pull request #680:
URL: https://github.com/apache/cxf/pull/680#discussion_r441245517



##########
File path: rt/rs/microprofile-client/src/main/java/org/apache/cxf/microprofile/client/MicroProfileClientConfigurableImpl.java
##########
@@ -42,6 +43,8 @@
         MessageBodyWriter.class, MessageBodyReader.class, ResponseExceptionMapper.class};
     private static final String CONFIG_KEY_DISABLE_MAPPER = "microprofile.rest.client.disable.default.mapper";
 
+    private Instantiator instantiator = CDIFacade.getInstantiator().orElse(super.getInstantiator());

Review comment:
       Minor, probably should be `final`




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
[hidden email]


Reply | Threaded
Open this post in threaded view
|

[GitHub] [cxf] andymc12 commented on a change in pull request #680: [CXF-8299][CXF-8304] QueryParamStyles and CDI-managed providers for MP Rest Client 2.0

GitBox
In reply to this post by GitBox

andymc12 commented on a change in pull request #680:
URL: https://github.com/apache/cxf/pull/680#discussion_r441754631



##########
File path: rt/rs/microprofile-client/src/main/java/org/apache/cxf/microprofile/client/cdi/CDIInstantiator.java
##########
@@ -0,0 +1,61 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.cxf.microprofile.client.cdi;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import org.apache.cxf.jaxrs.impl.ConfigurableImpl.Instantiator;
+
+
+public final class CDIInstantiator implements Instantiator {
+
+    static final CDIInstantiator INSTANCE = new CDIInstantiator();
+
+    private final Map<Object, Instance<?>> cdiInstances = new HashMap<>();

Review comment:
       Agreed - good catch.

##########
File path: rt/rs/microprofile-client/src/main/java/org/apache/cxf/microprofile/client/MicroProfileClientConfigurableImpl.java
##########
@@ -42,6 +43,8 @@
         MessageBodyWriter.class, MessageBodyReader.class, ResponseExceptionMapper.class};
     private static final String CONFIG_KEY_DISABLE_MAPPER = "microprofile.rest.client.disable.default.mapper";
 
+    private Instantiator instantiator = CDIFacade.getInstantiator().orElse(super.getInstantiator());

Review comment:
       Agreed.




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
[hidden email]


Reply | Threaded
Open this post in threaded view
|

[GitHub] [cxf] andymc12 commented on a change in pull request #680: [CXF-8299][CXF-8304] QueryParamStyles and CDI-managed providers for MP Rest Client 2.0

GitBox
In reply to this post by GitBox

andymc12 commented on a change in pull request #680:
URL: https://github.com/apache/cxf/pull/680#discussion_r441840909



##########
File path: rt/rs/microprofile-client/src/main/java/org/apache/cxf/microprofile/client/MicroProfileClientConfigurableImpl.java
##########
@@ -42,6 +43,8 @@
         MessageBodyWriter.class, MessageBodyReader.class, ResponseExceptionMapper.class};
     private static final String CONFIG_KEY_DISABLE_MAPPER = "microprofile.rest.client.disable.default.mapper";
 
+    private Instantiator instantiator = CDIFacade.getInstantiator().orElse(super.getInstantiator());

Review comment:
       I think it is a good idea, but when I tried it out, I realized that it breaks one of the TCK test cases - it fails when a new client is built using the `RestClientBuilder` from within a CDI-managed bean - specifically,[ this test](https://github.com/eclipse/microprofile-rest-client/blob/24096f2df248938fc00185a587bc812d969b5845/tck/src/main/java/org/eclipse/microprofile/rest/client/tck/cditests/CDIManagedProviderTest.java#L91).




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
[hidden email]


Reply | Threaded
Open this post in threaded view
|

[GitHub] [cxf] reta commented on a change in pull request #680: [CXF-8299][CXF-8304] QueryParamStyles and CDI-managed providers for MP Rest Client 2.0

GitBox
In reply to this post by GitBox

reta commented on a change in pull request #680:
URL: https://github.com/apache/cxf/pull/680#discussion_r441854285



##########
File path: rt/rs/microprofile-client/src/main/java/org/apache/cxf/microprofile/client/MicroProfileClientConfigurableImpl.java
##########
@@ -42,6 +43,8 @@
         MessageBodyWriter.class, MessageBodyReader.class, ResponseExceptionMapper.class};
     private static final String CONFIG_KEY_DISABLE_MAPPER = "microprofile.rest.client.disable.default.mapper";
 
+    private Instantiator instantiator = CDIFacade.getInstantiator().orElse(super.getInstantiator());

Review comment:
       Gotcha, thanks !




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
[hidden email]


Reply | Threaded
Open this post in threaded view
|

[GitHub] [cxf] andymc12 merged pull request #680: [CXF-8299][CXF-8304] QueryParamStyles and CDI-managed providers for MP Rest Client 2.0

GitBox
In reply to this post by GitBox

andymc12 merged pull request #680:
URL: https://github.com/apache/cxf/pull/680


   


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
[hidden email]