cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From r...@apache.org
Subject [16/33] cxf git commit: Adding an option to provide a proxy class directly in the code
Date Mon, 11 Jul 2016 00:14:21 GMT
Adding an option to provide a proxy class directly in the code


Project: http://git-wip-us.apache.org/repos/asf/cxf/repo
Commit: http://git-wip-us.apache.org/repos/asf/cxf/commit/fd9783c5
Tree: http://git-wip-us.apache.org/repos/asf/cxf/tree/fd9783c5
Diff: http://git-wip-us.apache.org/repos/asf/cxf/diff/fd9783c5

Branch: refs/heads/master-jaxrs-2.1
Commit: fd9783c50438e2c0a3b4175d14c5401adfe0e2e6
Parents: faa6552
Author: Sergey Beryozkin <sberyozkin@gmail.com>
Authored: Fri Jul 8 11:32:11 2016 +0100
Committer: Sergey Beryozkin <sberyozkin@gmail.com>
Committed: Fri Jul 8 11:32:11 2016 +0100

----------------------------------------------------------------------
 .../AbstractJaxRsClientConfiguration.java       | 19 ++++-
 .../client/spring/EnableJaxRsProxyClient.java   |  2 +-
 .../client/spring/EnableJaxRsWebClient.java     |  2 +-
 .../JaxRsClientClassesScanConfiguration.java    | 60 ---------------
 .../client/spring/WebClientConfiguration.java   | 79 --------------------
 5 files changed, 20 insertions(+), 142 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cxf/blob/fd9783c5/rt/rs/client/src/main/java/org/apache/cxf/jaxrs/client/spring/AbstractJaxRsClientConfiguration.java
----------------------------------------------------------------------
diff --git a/rt/rs/client/src/main/java/org/apache/cxf/jaxrs/client/spring/AbstractJaxRsClientConfiguration.java
b/rt/rs/client/src/main/java/org/apache/cxf/jaxrs/client/spring/AbstractJaxRsClientConfiguration.java
index 560d45e..4541c72 100644
--- a/rt/rs/client/src/main/java/org/apache/cxf/jaxrs/client/spring/AbstractJaxRsClientConfiguration.java
+++ b/rt/rs/client/src/main/java/org/apache/cxf/jaxrs/client/spring/AbstractJaxRsClientConfiguration.java
@@ -18,9 +18,13 @@
  */
 package org.apache.cxf.jaxrs.client.spring;
 
+import java.util.HashMap;
+import java.util.Map;
+
 import javax.ws.rs.ext.Provider;
 
 import org.apache.cxf.Bus;
+import org.apache.cxf.common.util.StringUtils;
 import org.apache.cxf.jaxrs.client.Client;
 import org.apache.cxf.jaxrs.client.JAXRSClientFactoryBean;
 import org.apache.cxf.jaxrs.spring.JaxRsConfig;
@@ -47,6 +51,10 @@ public abstract class AbstractJaxRsClientConfiguration implements ApplicationCon
     private String address;
     @Value("${cxf.jaxrs.client.thread-safe:false}")
     private Boolean threadSafe;
+    @Value("${cxf.jaxrs.client.headers.accept:''}")
+    private String accept;
+    @Value("${cxf.jaxrs.client.headers.content-type:''}")
+    private String contentType;
     
     
     protected Client createClient() {
@@ -61,7 +69,16 @@ public abstract class AbstractJaxRsClientConfiguration implements ApplicationCon
                 bean.setProvider(context.getBean(beanName));
             } 
         }
-        
+        Map<String, String> extraHeaders = new HashMap<String, String>();
+        if (!StringUtils.isEmpty(accept)) {
+            extraHeaders.put("Accept", accept);
+        }
+        if (!StringUtils.isEmpty(contentType)) {
+            extraHeaders.put("Content-Type", contentType);
+        }
+        if (!extraHeaders.isEmpty()) {
+            bean.setHeaders(extraHeaders);
+        }
         return bean.create();
     }
     

http://git-wip-us.apache.org/repos/asf/cxf/blob/fd9783c5/rt/rs/client/src/main/java/org/apache/cxf/jaxrs/client/spring/EnableJaxRsProxyClient.java
----------------------------------------------------------------------
diff --git a/rt/rs/client/src/main/java/org/apache/cxf/jaxrs/client/spring/EnableJaxRsProxyClient.java
b/rt/rs/client/src/main/java/org/apache/cxf/jaxrs/client/spring/EnableJaxRsProxyClient.java
index 3bc1512..ed8afee 100644
--- a/rt/rs/client/src/main/java/org/apache/cxf/jaxrs/client/spring/EnableJaxRsProxyClient.java
+++ b/rt/rs/client/src/main/java/org/apache/cxf/jaxrs/client/spring/EnableJaxRsProxyClient.java
@@ -27,7 +27,7 @@ import org.springframework.context.annotation.Import;
 
 @Retention(RetentionPolicy.RUNTIME)
 @Target(ElementType.TYPE)
-@Import(JaxRsClientClassesScanConfiguration.class)
+@Import(JaxRsProxyClientConfiguration.class)
 public @interface EnableJaxRsProxyClient {
 
 }

http://git-wip-us.apache.org/repos/asf/cxf/blob/fd9783c5/rt/rs/client/src/main/java/org/apache/cxf/jaxrs/client/spring/EnableJaxRsWebClient.java
----------------------------------------------------------------------
diff --git a/rt/rs/client/src/main/java/org/apache/cxf/jaxrs/client/spring/EnableJaxRsWebClient.java
b/rt/rs/client/src/main/java/org/apache/cxf/jaxrs/client/spring/EnableJaxRsWebClient.java
index 53c0521..be5a47f 100644
--- a/rt/rs/client/src/main/java/org/apache/cxf/jaxrs/client/spring/EnableJaxRsWebClient.java
+++ b/rt/rs/client/src/main/java/org/apache/cxf/jaxrs/client/spring/EnableJaxRsWebClient.java
@@ -27,7 +27,7 @@ import org.springframework.context.annotation.Import;
 
 @Retention(RetentionPolicy.RUNTIME)
 @Target(ElementType.TYPE)
-@Import(WebClientConfiguration.class)
+@Import(JaxRsWebClientConfiguration.class)
 public @interface EnableJaxRsWebClient {
 
 }

http://git-wip-us.apache.org/repos/asf/cxf/blob/fd9783c5/rt/rs/client/src/main/java/org/apache/cxf/jaxrs/client/spring/JaxRsClientClassesScanConfiguration.java
----------------------------------------------------------------------
diff --git a/rt/rs/client/src/main/java/org/apache/cxf/jaxrs/client/spring/JaxRsClientClassesScanConfiguration.java
b/rt/rs/client/src/main/java/org/apache/cxf/jaxrs/client/spring/JaxRsClientClassesScanConfiguration.java
deleted file mode 100644
index 45a7cef..0000000
--- a/rt/rs/client/src/main/java/org/apache/cxf/jaxrs/client/spring/JaxRsClientClassesScanConfiguration.java
+++ /dev/null
@@ -1,60 +0,0 @@
-/**
- * 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.jaxrs.client.spring;
-
-import java.lang.annotation.Annotation;
-import java.util.Collection;
-import java.util.Map;
-
-import javax.ws.rs.Path;
-import javax.ws.rs.ext.Provider;
-
-import org.apache.cxf.common.util.ClasspathScanner;
-import org.apache.cxf.jaxrs.client.Client;
-import org.apache.cxf.jaxrs.client.JAXRSClientFactoryBean;
-import org.apache.cxf.service.factory.ServiceConstructionException;
-import org.springframework.beans.factory.annotation.Value;
-import org.springframework.context.annotation.Bean;
-
-public class JaxRsClientClassesScanConfiguration extends AbstractJaxRsClientConfiguration
{
-    @Value("${cxf.jaxrs.client.classes-scan-packages}")
-    private String scanPackages;
-    
-    @Bean
-    protected Client jaxRsProxyClient() {
-        return super.createClient();
-    }
-    
-    protected void setJaxrsResources(JAXRSClientFactoryBean factory) {
-        try {
-            final Map< Class< ? extends Annotation >, Collection< Class< ?
> > > classes = 
-                ClasspathScanner.findClasses(scanPackages, Path.class, Provider.class);
-            
-            factory.setServiceClass(
-                JAXRSClientFactoryBeanDefinitionParser.getServiceClass(classes.get(Path.class)));
-            factory.setProviders(
-                JAXRSClientFactoryBeanDefinitionParser.getProviders(context, classes.get(Provider.class)));
-        } catch (Exception ex) {
-            throw new ServiceConstructionException(ex);    
-        }
-        
-    }
-
-    
-}

http://git-wip-us.apache.org/repos/asf/cxf/blob/fd9783c5/rt/rs/client/src/main/java/org/apache/cxf/jaxrs/client/spring/WebClientConfiguration.java
----------------------------------------------------------------------
diff --git a/rt/rs/client/src/main/java/org/apache/cxf/jaxrs/client/spring/WebClientConfiguration.java
b/rt/rs/client/src/main/java/org/apache/cxf/jaxrs/client/spring/WebClientConfiguration.java
deleted file mode 100644
index ccac861..0000000
--- a/rt/rs/client/src/main/java/org/apache/cxf/jaxrs/client/spring/WebClientConfiguration.java
+++ /dev/null
@@ -1,79 +0,0 @@
-/**
- * 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.jaxrs.client.spring;
-
-import java.lang.annotation.Annotation;
-import java.util.Collection;
-import java.util.HashMap;
-import java.util.Map;
-
-import javax.ws.rs.ext.Provider;
-
-import org.apache.cxf.common.util.ClasspathScanner;
-import org.apache.cxf.common.util.StringUtils;
-import org.apache.cxf.jaxrs.client.Client;
-import org.apache.cxf.jaxrs.client.JAXRSClientFactoryBean;
-import org.apache.cxf.jaxrs.client.WebClient;
-import org.apache.cxf.service.factory.ServiceConstructionException;
-import org.springframework.beans.factory.annotation.Value;
-import org.springframework.context.annotation.Bean;
-
-public class WebClientConfiguration extends AbstractJaxRsClientConfiguration {
-
-    @Value("${cxf.jaxrs.client.classes-scan-packages:''}")
-    private String scanPackages;
-    @Value("${cxf.jaxrs.client.headers.accept:''}")
-    private String accept;
-    @Value("${cxf.jaxrs.client.headers.content-type:''}")
-    private String contentType;
-    
-    @Bean
-    protected Client jaxRsWebClient() {
-        return super.createClient();
-    }
-    
-    @Override
-    protected void setJaxrsResources(JAXRSClientFactoryBean factory) {
-        factory.setServiceClass(WebClient.class);
-        
-        if (!StringUtils.isEmpty(scanPackages)) {
-            try {
-                final Map< Class< ? extends Annotation >, Collection< Class<
? > > > classes = 
-                    ClasspathScanner.findClasses(scanPackages, Provider.class);
-                
-                factory.setProviders(
-                    JAXRSClientFactoryBeanDefinitionParser.getProviders(context, classes.get(Provider.class)));
-            } catch (Exception ex) {
-                throw new ServiceConstructionException(ex);
-            }
-        }
-        Map<String, String> extraHeaders = new HashMap<String, String>();
-        if (!StringUtils.isEmpty(accept)) {
-            extraHeaders.put("Accept", accept);
-        }
-        if (!StringUtils.isEmpty(contentType)) {
-            extraHeaders.put("Content-Type", contentType);
-        }
-        if (!extraHeaders.isEmpty()) {
-            factory.setHeaders(extraHeaders);
-        }
-    }
-
-    
-}


Mime
View raw message