johnament commented on a change in pull request #359: Adding an implementation 
of the MicroProfile Rest Client v1.0
URL: https://github.com/apache/cxf/pull/359#discussion_r157662779
 
 

 ##########
 File path: 
rt/rs/microprofile-client/src/main/java/org/apache/cxf/microprofile/client/cdi/RestClientBean.java
 ##########
 @@ -0,0 +1,162 @@
+/**
+ * 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.lang.annotation.Annotation;
+import java.lang.reflect.Type;
+import java.net.MalformedURLException;
+import java.net.URL;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Set;
+import javax.enterprise.context.Dependent;
+import javax.enterprise.context.spi.CreationalContext;
+import javax.enterprise.inject.Default;
+import javax.enterprise.inject.spi.Bean;
+import javax.enterprise.inject.spi.BeanManager;
+import javax.enterprise.inject.spi.InjectionPoint;
+import javax.enterprise.inject.spi.PassivationCapable;
+import javax.enterprise.util.AnnotationLiteral;
+import org.apache.cxf.microprofile.client.CxfTypeSafeClientBuilder;
+import org.eclipse.microprofile.config.Config;
+import org.eclipse.microprofile.config.ConfigProvider;
+import org.eclipse.microprofile.rest.client.inject.RestClient;
+
+public class RestClientBean implements Bean<Object>, PassivationCapable {
+    public static final String REST_URL_FORMAT = "%s/mp-rest/url";
+    public static final String REST_SCOPE_FORMAT = "%s/mp-rest/scope";
+    private static final Default DEFAULT_LITERAL = new DefaultLiteral();
+    private final Class<?> clientInterface;
+    private final Class<? extends Annotation> scope;
+    private final BeanManager beanManager;
+    private final Config config;
+
+    RestClientBean(Class<?> clientInterface, BeanManager beanManager) {
+        this.clientInterface = clientInterface;
+        this.beanManager = beanManager;
+        this.config = ConfigProvider.getConfig();
+        this.scope = this.readScope();
+    }
+    @Override
+    public String getId() {
+        return clientInterface.getName();
+    }
+
+    @Override
+    public Class<?> getBeanClass() {
+        return clientInterface;
+    }
+
+    @Override
+    public Set<InjectionPoint> getInjectionPoints() {
+        return Collections.emptySet();
+    }
+
+    @Override
+    public boolean isNullable() {
+        return false;
+    }
+
+    @Override
+    public Object create(CreationalContext<Object> creationalContext) {
+        CxfTypeSafeClientBuilder builder = new CxfTypeSafeClientBuilder();
+        String baseUrl = getBaseUrl();
+        try {
+            return builder.baseUrl(new URL(baseUrl)).build(clientInterface);
 
 Review comment:
   @andymc12 I just realized when reading this, we are missing TCK tests for 
the configurable CDI properties outside of URL.

----------------------------------------------------------------
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


With regards,
Apache Git Services

Reply via email to