cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From serg...@apache.org
Subject svn commit: r1504203 - in /cxf/trunk: rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/impl/ rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/utils/ rt/rs/client/src/main/java/org/apache/cxf/jaxrs/client/ rt/rs/client/src/main/java/org/apache/c...
Date Wed, 17 Jul 2013 17:03:37 GMT
Author: sergeyb
Date: Wed Jul 17 17:03:36 2013
New Revision: 1504203

URL: http://svn.apache.org/r1504203
Log:
[CXF-5135] Prototyping the code to get 2.0 fluent API supported, more to follow

Added:
    cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/impl/ConfigurationImpl.java
  (with props)
    cxf/trunk/rt/rs/client/src/main/java/org/apache/cxf/jaxrs/client/spec/ClientBuilderImpl.java
  (with props)
    cxf/trunk/rt/rs/client/src/main/java/org/apache/cxf/jaxrs/client/spec/ClientImpl.java
  (with props)
    cxf/trunk/rt/rs/client/src/main/java/org/apache/cxf/jaxrs/client/spec/ConfigurableImpl.java
  (with props)
    cxf/trunk/rt/rs/client/src/main/java/org/apache/cxf/jaxrs/client/spec/InvocationBuilderImpl.java
  (with props)
    cxf/trunk/rt/rs/client/src/main/java/org/apache/cxf/jaxrs/client/spec/TLSConfiguration.java
  (with props)
    cxf/trunk/rt/rs/client/src/main/resources/META-INF/services/
    cxf/trunk/rt/rs/client/src/main/resources/META-INF/services/javax.ws.rs.client.ClientBuilder
Modified:
    cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/utils/HttpUtils.java
    cxf/trunk/rt/rs/client/src/main/java/org/apache/cxf/jaxrs/client/WebClient.java
    cxf/trunk/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/JAXRS20ClientServerBookTest.java

Added: cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/impl/ConfigurationImpl.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/impl/ConfigurationImpl.java?rev=1504203&view=auto
==============================================================================
--- cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/impl/ConfigurationImpl.java
(added)
+++ cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/impl/ConfigurationImpl.java
Wed Jul 17 17:03:36 2013
@@ -0,0 +1,105 @@
+/**
+ * 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.impl;
+
+import java.util.Collection;
+import java.util.Map;
+import java.util.Set;
+
+import javax.ws.rs.RuntimeType;
+import javax.ws.rs.core.Configuration;
+import javax.ws.rs.core.Feature;
+
+public class ConfigurationImpl implements Configuration {
+
+    public ConfigurationImpl() {
+        
+    }
+    
+    public ConfigurationImpl(Configuration parent) {
+        
+    }
+    
+    @Override
+    public Set<Class<?>> getClasses() {
+        // TODO Auto-generated method stub
+        return null;
+    }
+
+    @Override
+    public Map<Class<?>, Integer> getContracts(Class<?> arg0) {
+        // TODO Auto-generated method stub
+        return null;
+    }
+
+    @Override
+    public Set<Object> getInstances() {
+        // TODO Auto-generated method stub
+        return null;
+    }
+
+    @Override
+    public Map<String, Object> getProperties() {
+        // TODO Auto-generated method stub
+        return null;
+    }
+
+    @Override
+    public Object getProperty(String arg0) {
+        // TODO Auto-generated method stub
+        return null;
+    }
+
+    @Override
+    public Collection<String> getPropertyNames() {
+        // TODO Auto-generated method stub
+        return null;
+    }
+
+    @Override
+    public RuntimeType getRuntimeType() {
+        // TODO Auto-generated method stub
+        return null;
+    }
+
+    @Override
+    public boolean isEnabled(Feature arg0) {
+        // TODO Auto-generated method stub
+        return false;
+    }
+
+    @Override
+    public boolean isEnabled(Class<? extends Feature> arg0) {
+        // TODO Auto-generated method stub
+        return false;
+    }
+
+    @Override
+    public boolean isRegistered(Object arg0) {
+        // TODO Auto-generated method stub
+        return false;
+    }
+
+    @Override
+    public boolean isRegistered(Class<?> arg0) {
+        // TODO Auto-generated method stub
+        return false;
+    }
+
+}

Propchange: cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/impl/ConfigurationImpl.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/impl/ConfigurationImpl.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Modified: cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/utils/HttpUtils.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/utils/HttpUtils.java?rev=1504203&r1=1504202&r2=1504203&view=diff
==============================================================================
--- cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/utils/HttpUtils.java (original)
+++ cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/utils/HttpUtils.java Wed
Jul 17 17:03:36 2013
@@ -580,4 +580,8 @@ public final class HttpUtils {
         return relative.resolve(relToCommon);
         
     }
+    
+    public static String toHttpLanguage(Locale locale) {
+        return Headers.toHttpLanguage(locale);
+    }
 }

Modified: cxf/trunk/rt/rs/client/src/main/java/org/apache/cxf/jaxrs/client/WebClient.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/rs/client/src/main/java/org/apache/cxf/jaxrs/client/WebClient.java?rev=1504203&r1=1504202&r2=1504203&view=diff
==============================================================================
--- cxf/trunk/rt/rs/client/src/main/java/org/apache/cxf/jaxrs/client/WebClient.java (original)
+++ cxf/trunk/rt/rs/client/src/main/java/org/apache/cxf/jaxrs/client/WebClient.java Wed Jul
17 17:03:36 2013
@@ -1245,12 +1245,14 @@ public class WebClient extends AbstractC
     }
     
     private void setEntityHeaders(Entity<?> entity) {
-        type(entity.getMediaType());
-        if (entity.getLanguage() != null) {
-            language(entity.getLanguage().toString());
-        }
-        if (entity.getEncoding() != null) {
-            encoding(entity.getEncoding());
+        if (entity != null) {
+            type(entity.getMediaType());
+            if (entity.getLanguage() != null) {
+                language(entity.getLanguage().toString());
+            }
+            if (entity.getEncoding() != null) {
+                encoding(entity.getEncoding());
+            }
         }
     }
     
@@ -1415,22 +1417,29 @@ public class WebClient extends AbstractC
         @Override
         public <T> Future<T> method(String name, Entity<?> entity, Class<T>
responseType) {
             WebClient.this.setEntityHeaders(entity);
-            return doInvokeAsync(name, entity.getEntity(), entity.getEntity().getClass(),
null, 
-                                 responseType, responseType, null);
+            return doInvokeAsync(name, 
+                                 entity == null ? null : entity.getEntity(), 
+                                 entity == null ? null : entity.getEntity().getClass(), 
+                                 null, responseType, responseType, null);
         }
 
         @Override
         public <T> Future<T> method(String name, Entity<?> entity, GenericType<T>
responseType) {
             WebClient.this.setEntityHeaders(entity);
-            return doInvokeAsync(name, entity.getEntity(), entity.getEntity().getClass(),
null, 
-                                 responseType.getRawType(), responseType.getType(), null);
+            return doInvokeAsync(name, 
+                                 entity == null ? null : entity.getEntity(), 
+                                 entity == null ? null : entity.getEntity().getClass(), 
+                                 null, responseType.getRawType(), responseType.getType(),
null);
         }
 
         @Override
         public <T> Future<T> method(String name, Entity<?> entity, InvocationCallback<T>
callback) {
             WebClient.this.setEntityHeaders(entity);
-            return doInvokeAsyncCallback(name, entity.getEntity(), entity.getEntity().getClass(),
null, 
-                callback);
+            return doInvokeAsyncCallback(name, 
+                                         entity.getEntity(), 
+                                         entity.getEntity().getClass(), 
+                                         null, 
+                                         callback);
         }
     }
     
@@ -1556,13 +1565,17 @@ public class WebClient extends AbstractC
         @Override
         public <T> T method(String method, Entity<?> entity, Class<T> cls)
{
             WebClient.this.setEntityHeaders(entity);
-            return invoke(method, entity.getEntity(), cls);
+            return invoke(method, 
+                          entity == null ? null : entity.getEntity(), 
+                          cls);
         }
 
         @Override
         public <T> T method(String method, Entity<?> entity, GenericType<T>
genericType) {
             WebClient.this.setEntityHeaders(entity);
-            return invoke(method, entity.getEntity(), genericType);
+            return invoke(method, 
+                          entity == null ? null : entity.getEntity(), 
+                          genericType);
         }
     }
 }

Added: cxf/trunk/rt/rs/client/src/main/java/org/apache/cxf/jaxrs/client/spec/ClientBuilderImpl.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/rs/client/src/main/java/org/apache/cxf/jaxrs/client/spec/ClientBuilderImpl.java?rev=1504203&view=auto
==============================================================================
--- cxf/trunk/rt/rs/client/src/main/java/org/apache/cxf/jaxrs/client/spec/ClientBuilderImpl.java
(added)
+++ cxf/trunk/rt/rs/client/src/main/java/org/apache/cxf/jaxrs/client/spec/ClientBuilderImpl.java
Wed Jul 17 17:03:36 2013
@@ -0,0 +1,124 @@
+/**
+ * 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.spec;
+
+import java.security.KeyStore;
+import java.util.Map;
+
+import javax.net.ssl.HostnameVerifier;
+import javax.net.ssl.SSLContext;
+import javax.ws.rs.client.Client;
+import javax.ws.rs.client.ClientBuilder;
+import javax.ws.rs.core.Configuration;
+
+public class ClientBuilderImpl extends ClientBuilder {
+
+    private ConfigurableImpl<ClientBuilder> configImpl = new ConfigurableImpl<ClientBuilder>();
+    private TLSConfiguration secConfig = new TLSConfiguration();
+    
+    public ClientBuilderImpl() {
+        System.out.println();    
+    }
+    
+    @Override
+    public Configuration getConfiguration() {
+        return configImpl.getConfiguration();
+    }
+
+    @Override
+    public ClientBuilder property(String name, Object value) {
+        return configImpl.property(name, value);
+    }
+
+    @Override
+    public ClientBuilder register(Class<?> cls) {
+        return configImpl.register(cls);
+    }
+
+    @Override
+    public ClientBuilder register(Object object) {
+        return configImpl.register(object);
+    }
+
+    @Override
+    public ClientBuilder register(Class<?> cls, int index) {
+        return configImpl.register(cls, index);
+    }
+
+    @Override
+    public ClientBuilder register(Class<?> cls, Class<?>... contracts) {
+        return configImpl.register(cls, contracts);
+    }
+
+    @Override
+    public ClientBuilder register(Class<?> cls, Map<Class<?>, Integer>
map) {
+        return configImpl.register(cls, map);
+    }
+
+    @Override
+    public ClientBuilder register(Object object, int index) {
+        return configImpl.register(object, index);
+    }
+
+    @Override
+    public ClientBuilder register(Object object, Class<?>... contracts) {
+        return configImpl.register(object, contracts);
+    }
+
+    @Override
+    public ClientBuilder register(Object object, Map<Class<?>, Integer> map)
{
+        return configImpl.register(object, map);
+    }
+
+    @Override
+    public Client build() {
+        return new ClientImpl(configImpl.getConfiguration(), secConfig);
+    }
+
+    @Override
+    public ClientBuilder hostnameVerifier(HostnameVerifier verifier) {
+        secConfig.setVerifier(verifier);
+        return this;
+    }
+
+    @Override
+    public ClientBuilder sslContext(SSLContext sslContext) {
+        secConfig.setSslContext(sslContext);
+        return this;
+    }
+
+    @Override
+    public ClientBuilder keyStore(KeyStore store, char[] password) {
+        // TODO Auto-generated method stub
+        return null;
+    }
+    
+    @Override
+    public ClientBuilder trustStore(KeyStore store) {
+        secConfig.setTrustStore(store);
+        return this;
+    }
+
+    @Override
+    public ClientBuilder withConfig(Configuration cfg) {
+        configImpl = new ConfigurableImpl<ClientBuilder>(cfg);
+        return this;
+    }
+
+}

Propchange: cxf/trunk/rt/rs/client/src/main/java/org/apache/cxf/jaxrs/client/spec/ClientBuilderImpl.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: cxf/trunk/rt/rs/client/src/main/java/org/apache/cxf/jaxrs/client/spec/ClientBuilderImpl.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Added: cxf/trunk/rt/rs/client/src/main/java/org/apache/cxf/jaxrs/client/spec/ClientImpl.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/rs/client/src/main/java/org/apache/cxf/jaxrs/client/spec/ClientImpl.java?rev=1504203&view=auto
==============================================================================
--- cxf/trunk/rt/rs/client/src/main/java/org/apache/cxf/jaxrs/client/spec/ClientImpl.java
(added)
+++ cxf/trunk/rt/rs/client/src/main/java/org/apache/cxf/jaxrs/client/spec/ClientImpl.java
Wed Jul 17 17:03:36 2013
@@ -0,0 +1,214 @@
+/**
+ * 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.spec;
+
+import java.net.URI;
+import java.util.Map;
+
+import javax.net.ssl.HostnameVerifier;
+import javax.net.ssl.SSLContext;
+import javax.ws.rs.client.Client;
+import javax.ws.rs.client.Invocation.Builder;
+import javax.ws.rs.client.WebTarget;
+import javax.ws.rs.core.Configuration;
+import javax.ws.rs.core.Link;
+import javax.ws.rs.core.MediaType;
+import javax.ws.rs.core.UriBuilder;
+
+import org.apache.cxf.jaxrs.client.JAXRSClientFactoryBean;
+import org.apache.cxf.jaxrs.client.WebClient;
+
+public class ClientImpl extends ConfigurableImpl<Client> implements Client {
+    private TLSConfiguration secConfig;
+    private boolean closed;
+    private WebClient template;
+    public ClientImpl(Configuration config,
+                      TLSConfiguration secConfig) {
+        super(config);
+        this.secConfig = secConfig;
+    }
+    
+    @Override
+    public void close() {
+        if (!closed) {
+            if (template != null) {
+                template.close();
+                template = null;
+            }
+            closed = true;
+        }
+        
+    }
+
+    @Override
+    public Builder invocation(Link link) {
+        checkClosed();
+        return target(link.getUriBuilder()).request();
+    }
+
+    @Override
+    public WebTarget target(UriBuilder builder) {
+        checkClosed();
+        initWebClientTemplateIfNeeded();
+        return new WebTargetImpl(builder, getConfiguration(), template);
+    }
+
+    private void initWebClientTemplateIfNeeded() {
+        // This is done to make the creation of individual targets really easy
+        if (template == null) {
+            JAXRSClientFactoryBean bean = new JAXRSClientFactoryBean();
+            bean.setAddress("http://tempuri");
+            // handle Configuration providers
+            this.template = bean.createWebClient();
+        }
+    }
+    
+    @Override
+    public WebTarget target(String address) {
+        return target(UriBuilder.fromUri(address));
+    }
+    
+    @Override
+    public WebTarget target(Link link) {
+        return target(link.getUriBuilder());
+    }
+
+    @Override
+    public WebTarget target(URI uri) {
+        return target(UriBuilder.fromUri(uri));
+    }
+
+    
+    @Override
+    public HostnameVerifier getHostnameVerifier() {
+        checkClosed();
+        return secConfig.getVerifier();
+    }
+
+    @Override
+    public SSLContext getSslContext() {
+        checkClosed();
+        return secConfig.getSslContext();
+    }
+    
+    private void checkClosed() {
+        if (closed) {
+            throw new IllegalStateException();
+        }
+    }
+    
+    class WebTargetImpl extends ConfigurableImpl<WebTarget> implements WebTarget {
+        private UriBuilder uriBuilder;
+        private WebClient template; 
+        
+        public WebTargetImpl(UriBuilder uriBuilder, 
+                              Configuration config, 
+                              WebClient template) {
+            super(config);
+            this.uriBuilder = uriBuilder.clone();
+            this.template = template;
+        }
+        
+        @Override
+        public Builder request() {
+            checkClosed();
+            WebClient wc = WebClient.fromClient(template).to(uriBuilder.build().toString(),
false);
+            return new InvocationBuilderImpl(wc);
+        }
+
+        @Override
+        public Builder request(String... accept) {
+            return request().accept(accept);
+        }
+
+        @Override
+        public Builder request(MediaType... accept) {
+            return request().accept(accept);
+        }
+
+        @Override
+        public URI getUri() {
+            checkClosed();
+            return uriBuilder.build();
+        }
+
+        @Override
+        public UriBuilder getUriBuilder() {
+            checkClosed();
+            return uriBuilder.clone();
+        }
+
+        @Override
+        public WebTarget matrixParam(String name, Object... values) {
+            return newWebTarget(getUriBuilder().matrixParam(name, values));
+        }
+        
+        @Override
+        public WebTarget path(String path) {
+            return newWebTarget(getUriBuilder().path(path));
+        }
+
+        @Override
+        public WebTarget queryParam(String name, Object... values) {
+            return newWebTarget(getUriBuilder().queryParam(name, values));
+        }
+
+        @Override
+        public WebTarget resolveTemplate(String name, Object value) {
+            return resolveTemplate(name, value, true);
+        }
+
+        @Override
+        public WebTarget resolveTemplate(String name, Object value, boolean encodeSlash)
{
+            return newWebTarget(getUriBuilder().resolveTemplate(name, value, encodeSlash));
+        }
+
+        @Override
+        public WebTarget resolveTemplateFromEncoded(String name, Object value) {
+            return newWebTarget(getUriBuilder().resolveTemplateFromEncoded(name, value));
+        }
+
+        @Override
+        public WebTarget resolveTemplates(Map<String, Object> templatesMap) {
+            return resolveTemplates(templatesMap, true);
+        }
+
+        @Override
+        public WebTarget resolveTemplates(Map<String, Object> templatesMap, boolean
encodeSlash) {
+            checkClosed();
+            if (templatesMap.isEmpty()) {
+                return this;
+            }
+            return newWebTarget(getUriBuilder().resolveTemplates(templatesMap, encodeSlash));
+        }
+
+        @Override
+        public WebTarget resolveTemplatesFromEncoded(Map<String, Object> templatesMap)
{
+            checkClosed();
+            if (templatesMap.isEmpty()) {
+                return this;
+            }
+            return newWebTarget(getUriBuilder().resolveTemplatesFromEncoded(templatesMap));
+        }
+        
+        private WebTarget newWebTarget(UriBuilder newBuilder) {
+            return new WebTargetImpl(newBuilder, getConfiguration(), template);
+        }
+    }
+}

Propchange: cxf/trunk/rt/rs/client/src/main/java/org/apache/cxf/jaxrs/client/spec/ClientImpl.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: cxf/trunk/rt/rs/client/src/main/java/org/apache/cxf/jaxrs/client/spec/ClientImpl.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Added: cxf/trunk/rt/rs/client/src/main/java/org/apache/cxf/jaxrs/client/spec/ConfigurableImpl.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/rs/client/src/main/java/org/apache/cxf/jaxrs/client/spec/ConfigurableImpl.java?rev=1504203&view=auto
==============================================================================
--- cxf/trunk/rt/rs/client/src/main/java/org/apache/cxf/jaxrs/client/spec/ConfigurableImpl.java
(added)
+++ cxf/trunk/rt/rs/client/src/main/java/org/apache/cxf/jaxrs/client/spec/ConfigurableImpl.java
Wed Jul 17 17:03:36 2013
@@ -0,0 +1,98 @@
+/**
+ * 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.spec;
+
+import java.util.Map;
+
+import javax.ws.rs.core.Configurable;
+import javax.ws.rs.core.Configuration;
+
+import org.apache.cxf.jaxrs.impl.ConfigurationImpl;
+
+public class ConfigurableImpl<C extends Configurable<C>> implements Configurable<C>
{
+    private Configuration config;
+    protected ConfigurableImpl() {
+        this(new ConfigurationImpl());
+    }
+    
+    protected ConfigurableImpl(Configuration config) {
+        this.config = config;
+    }
+    
+    @Override
+    public Configuration getConfiguration() {
+        return config;
+    }
+
+    @Override
+    public C property(String arg0, Object arg1) {
+        // TODO Auto-generated method stub
+        return null;
+    }
+
+    @Override
+    public C register(Class<?> arg0) {
+        // TODO Auto-generated method stub
+        return null;
+    }
+
+    @Override
+    public C register(Object arg0) {
+        // TODO Auto-generated method stub
+        return null;
+    }
+
+    @Override
+    public C register(Class<?> arg0, int arg1) {
+        // TODO Auto-generated method stub
+        return null;
+    }
+
+    @Override
+    public C register(Class<?> arg0, Class<?>... arg1) {
+        // TODO Auto-generated method stub
+        return null;
+    }
+
+    @Override
+    public C register(Class<?> arg0, Map<Class<?>, Integer> arg1) {
+        // TODO Auto-generated method stub
+        return null;
+    }
+
+    @Override
+    public C register(Object arg0, int arg1) {
+        // TODO Auto-generated method stub
+        return null;
+    }
+
+    @Override
+    public C register(Object arg0, Class<?>... arg1) {
+        // TODO Auto-generated method stub
+        return null;
+    }
+
+    @Override
+    public C register(Object arg0, Map<Class<?>, Integer> arg1) {
+        // TODO Auto-generated method stub
+        return null;
+    }
+
+}

Propchange: cxf/trunk/rt/rs/client/src/main/java/org/apache/cxf/jaxrs/client/spec/ConfigurableImpl.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: cxf/trunk/rt/rs/client/src/main/java/org/apache/cxf/jaxrs/client/spec/ConfigurableImpl.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Added: cxf/trunk/rt/rs/client/src/main/java/org/apache/cxf/jaxrs/client/spec/InvocationBuilderImpl.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/rs/client/src/main/java/org/apache/cxf/jaxrs/client/spec/InvocationBuilderImpl.java?rev=1504203&view=auto
==============================================================================
--- cxf/trunk/rt/rs/client/src/main/java/org/apache/cxf/jaxrs/client/spec/InvocationBuilderImpl.java
(added)
+++ cxf/trunk/rt/rs/client/src/main/java/org/apache/cxf/jaxrs/client/spec/InvocationBuilderImpl.java
Wed Jul 17 17:03:36 2013
@@ -0,0 +1,353 @@
+/**
+ * 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.spec;
+
+import java.util.HashMap;
+import java.util.Locale;
+import java.util.Map;
+import java.util.concurrent.Future;
+
+import javax.ws.rs.HttpMethod;
+import javax.ws.rs.client.AsyncInvoker;
+import javax.ws.rs.client.Entity;
+import javax.ws.rs.client.Invocation;
+import javax.ws.rs.client.Invocation.Builder;
+import javax.ws.rs.client.InvocationCallback;
+import javax.ws.rs.client.SyncInvoker;
+import javax.ws.rs.core.CacheControl;
+import javax.ws.rs.core.Cookie;
+import javax.ws.rs.core.GenericType;
+import javax.ws.rs.core.HttpHeaders;
+import javax.ws.rs.core.MediaType;
+import javax.ws.rs.core.MultivaluedMap;
+import javax.ws.rs.core.Response;
+
+import org.apache.cxf.helpers.CastUtils;
+import org.apache.cxf.jaxrs.client.WebClient;
+import org.apache.cxf.jaxrs.utils.HttpUtils;
+
+public class InvocationBuilderImpl implements Invocation.Builder {
+    private static final String PROPERTY_KEY = "jaxrs.filter.properties";
+    
+    private WebClient webClient;
+    private SyncInvoker sync;
+    
+    public InvocationBuilderImpl(WebClient webClient) {
+        this.webClient = webClient;
+        this.sync = webClient.sync();
+    }
+    
+    @Override
+    public Response delete() {
+        return sync.delete();
+    }
+
+    @Override
+    public <T> T delete(Class<T> cls) {
+        return sync.delete(cls);
+    }
+
+    @Override
+    public <T> T delete(GenericType<T> type) {
+        return sync.delete(type);
+    }
+
+    @Override
+    public Response get() {
+        return sync.get();
+    }
+
+    @Override
+    public <T> T get(Class<T> cls) {
+        return sync.get(cls);
+    }
+
+    @Override
+    public <T> T get(GenericType<T> type) {
+        return sync.get(type);
+    }
+
+    @Override
+    public Response head() {
+        return sync.head();
+    }
+
+    @Override
+    public Response method(String method) {
+        return sync.method(method);
+    }
+
+    @Override
+    public <T> T method(String method, Class<T> cls) {
+        return sync.method(method, cls);
+    }
+
+    @Override
+    public <T> T method(String method, GenericType<T> type) {
+        return sync.method(method, type);
+    }
+
+    @Override
+    public Response method(String method, Entity<?> entity) {
+        return sync.method(method, entity);
+    }
+
+    @Override
+    public <T> T method(String method, Entity<?> entity, Class<T> cls)
{
+        return sync.method(method, entity, cls);
+    }
+
+    @Override
+    public <T> T method(String method, Entity<?> entity, GenericType<T>
type) {
+        return sync.method(method, entity, type);
+    }
+
+    @Override
+    public Response options() {
+        return sync.options();
+    }
+
+    @Override
+    public <T> T options(Class<T> cls) {
+        return sync.options(cls);
+    }
+
+    @Override
+    public <T> T options(GenericType<T> type) {
+        return sync.options(type);
+    }
+
+    @Override
+    public Response post(Entity<?> entity) {
+        return sync.post(entity);
+    }
+
+    @Override
+    public <T> T post(Entity<?> entity, Class<T> cls) {
+        return sync.post(entity, cls);
+    }
+
+    @Override
+    public <T> T post(Entity<?> entity, GenericType<T> type) {
+        return sync.post(entity, type);
+    }
+
+    @Override
+    public Response put(Entity<?> entity) {
+        return sync.put(entity);
+    }
+
+    @Override
+    public <T> T put(Entity<?> entity, Class<T> cls) {
+        return sync.put(entity, cls);
+    }
+
+    @Override
+    public <T> T put(Entity<?> entity, GenericType<T> type) {
+        return sync.put(entity, type);
+    }
+
+    @Override
+    public Response trace() {
+        return sync.trace();
+    }
+
+    @Override
+    public <T> T trace(Class<T> cls) {
+        return sync.trace(cls);
+    }
+
+    @Override
+    public <T> T trace(GenericType<T> type) {
+        return sync.trace(type);
+    }
+
+    @Override
+    public Builder accept(String... types) {
+        webClient.accept(types);
+        return this;
+    }
+
+    @Override
+    public Builder accept(MediaType... types) {
+        webClient.accept(types);
+        return this;
+    }
+
+    @Override
+    public Builder acceptEncoding(String... enc) {
+        webClient.acceptEncoding(enc);
+        return this;
+        
+    }
+
+    @Override
+    public Builder acceptLanguage(Locale... lang) {
+        for (Locale l : lang) {
+            webClient.acceptLanguage(HttpUtils.toHttpLanguage(l));
+        }
+        return this;
+    }
+
+    @Override
+    public Builder acceptLanguage(String... lang) {
+        webClient.acceptLanguage(lang);
+        return this;
+    }
+
+    @Override
+    public Builder cacheControl(CacheControl control) {
+        webClient.header(HttpHeaders.CACHE_CONTROL, control.toString());
+        return this;
+    }
+
+    @Override
+    public Builder cookie(Cookie cookie) {
+        webClient.cookie(cookie);
+        return this;
+    }
+
+    @Override
+    public Builder cookie(String name, String value) {
+        webClient.header(HttpHeaders.COOKIE, name + "=" + value);
+        return this;
+    }
+
+    @Override
+    public Builder header(String name, Object value) {
+        webClient.header(name, value);
+        return this;
+    }
+
+    @Override
+    public Builder headers(MultivaluedMap<String, Object> headers) {
+        
+        return this;
+    }
+
+    @Override
+    public Builder property(String name, Object value) {
+        Map<String, Object> contextProps = WebClient.getConfig(webClient).getRequestContext();
+        Map<String, Object> filterProps = CastUtils.cast((Map<?, ?>)contextProps.get(PROPERTY_KEY));
+        if (filterProps == null) {
+            filterProps = new HashMap<String, Object>();
+            contextProps.put(PROPERTY_KEY, filterProps);
+        }
+        if (value == null) {
+            filterProps.remove(name);
+        } else {
+            filterProps.put(name, value);
+        }
+        return this;
+    }
+    
+    @Override
+    public AsyncInvoker async() {
+        return webClient.async();
+    }
+
+    @Override
+    public Invocation build(String method) {
+        return new InvocationImpl(method);
+    }
+
+    @Override
+    public Invocation build(String method, Entity<?> entity) {
+        return new InvocationImpl(method, entity);
+    }
+
+    @Override
+    public Invocation buildDelete() {
+        return build(HttpMethod.DELETE);
+    }
+
+    @Override
+    public Invocation buildGet() {
+        return build(HttpMethod.GET);
+    }
+
+    @Override
+    public Invocation buildPost(Entity<?> entity) {
+        return build(HttpMethod.POST, entity);
+    }
+
+    @Override
+    public Invocation buildPut(Entity<?> entity) {
+        return build(HttpMethod.PUT, entity);
+    }
+    
+    private class InvocationImpl implements Invocation {
+
+        private Invocation.Builder invBuilder;
+        private String httpMethod;
+        private Entity<?> entity;
+        
+        public InvocationImpl(String httpMethod) {
+            this(httpMethod, null);
+        }
+        
+        public InvocationImpl(String httpMethod, Entity<?> entity) {
+            this.invBuilder = InvocationBuilderImpl.this;
+            this.httpMethod = httpMethod;
+            this.entity = entity;
+        }
+        
+        @Override
+        public Response invoke() {
+            return invBuilder.method(httpMethod, entity);
+        }
+
+        @Override
+        public <T> T invoke(Class<T> cls) {
+            return invBuilder.method(httpMethod, entity, cls);
+        }
+
+        @Override
+        public <T> T invoke(GenericType<T> type) {
+            return invBuilder.method(httpMethod, entity, type);
+        }
+
+        @Override
+        public Invocation property(String name, Object value) {
+            invBuilder.property(name, value);
+            return this;
+        }
+
+        @Override
+        public Future<Response> submit() {
+            return invBuilder.async().method(httpMethod, entity);
+        }
+
+        @Override
+        public <T> Future<T> submit(Class<T> cls) {
+            return invBuilder.async().method(httpMethod, entity, cls);
+        }
+
+        @Override
+        public <T> Future<T> submit(GenericType<T> type) {
+            return invBuilder.async().method(httpMethod, entity, type);
+        }
+
+        @Override
+        public <T> Future<T> submit(InvocationCallback<T> callback) {
+            return invBuilder.async().method(httpMethod, entity, callback);
+        }
+
+    }
+}

Propchange: cxf/trunk/rt/rs/client/src/main/java/org/apache/cxf/jaxrs/client/spec/InvocationBuilderImpl.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: cxf/trunk/rt/rs/client/src/main/java/org/apache/cxf/jaxrs/client/spec/InvocationBuilderImpl.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Added: cxf/trunk/rt/rs/client/src/main/java/org/apache/cxf/jaxrs/client/spec/TLSConfiguration.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/rs/client/src/main/java/org/apache/cxf/jaxrs/client/spec/TLSConfiguration.java?rev=1504203&view=auto
==============================================================================
--- cxf/trunk/rt/rs/client/src/main/java/org/apache/cxf/jaxrs/client/spec/TLSConfiguration.java
(added)
+++ cxf/trunk/rt/rs/client/src/main/java/org/apache/cxf/jaxrs/client/spec/TLSConfiguration.java
Wed Jul 17 17:03:36 2013
@@ -0,0 +1,49 @@
+/**
+ * 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.spec;
+
+import java.security.KeyStore;
+
+import javax.net.ssl.HostnameVerifier;
+import javax.net.ssl.SSLContext;
+
+
+public class TLSConfiguration {
+    private SSLContext sslContext;
+    private HostnameVerifier verifier;
+    private KeyStore trustStore;
+    public SSLContext getSslContext() {
+        return sslContext;
+    }
+    public void setSslContext(SSLContext sslContext) {
+        this.sslContext = sslContext;
+    }
+    public HostnameVerifier getVerifier() {
+        return verifier;
+    }
+    public void setVerifier(HostnameVerifier verifier) {
+        this.verifier = verifier;
+    }
+    public KeyStore getTrustStore() {
+        return trustStore;
+    }
+    public void setTrustStore(KeyStore trustStore) {
+        this.trustStore = trustStore;
+    }
+}

Propchange: cxf/trunk/rt/rs/client/src/main/java/org/apache/cxf/jaxrs/client/spec/TLSConfiguration.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: cxf/trunk/rt/rs/client/src/main/java/org/apache/cxf/jaxrs/client/spec/TLSConfiguration.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Added: cxf/trunk/rt/rs/client/src/main/resources/META-INF/services/javax.ws.rs.client.ClientBuilder
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/rs/client/src/main/resources/META-INF/services/javax.ws.rs.client.ClientBuilder?rev=1504203&view=auto
==============================================================================
--- cxf/trunk/rt/rs/client/src/main/resources/META-INF/services/javax.ws.rs.client.ClientBuilder
(added)
+++ cxf/trunk/rt/rs/client/src/main/resources/META-INF/services/javax.ws.rs.client.ClientBuilder
Wed Jul 17 17:03:36 2013
@@ -0,0 +1 @@
+org.apache.cxf.jaxrs.client.spec.ClientBuilderImpl
\ No newline at end of file

Modified: cxf/trunk/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/JAXRS20ClientServerBookTest.java
URL: http://svn.apache.org/viewvc/cxf/trunk/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/JAXRS20ClientServerBookTest.java?rev=1504203&r1=1504202&r2=1504203&view=diff
==============================================================================
--- cxf/trunk/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/JAXRS20ClientServerBookTest.java
(original)
+++ cxf/trunk/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/JAXRS20ClientServerBookTest.java
Wed Jul 17 17:03:36 2013
@@ -27,6 +27,7 @@ import java.util.concurrent.ExecutionExc
 import java.util.concurrent.Future;
 
 import javax.ws.rs.WebApplicationException;
+import javax.ws.rs.client.ClientBuilder;
 import javax.ws.rs.client.ClientRequestContext;
 import javax.ws.rs.client.ClientRequestFilter;
 import javax.ws.rs.client.ClientResponseContext;
@@ -103,6 +104,14 @@ public class JAXRS20ClientServerBookTest
     }
     
     @Test
+    public void testGetBookSpec() {
+        String address = "http://localhost:" + PORT + "/bookstore/bookheaders/simple";
+        Book book = ClientBuilder.newClient().target(address)
+            .request("application/xml").get(Book.class);
+        assertEquals(124L, book.getId());
+    }
+    
+    @Test
     public void testGetBookSyncWithAsync() {
         String address = "http://localhost:" + PORT + "/bookstore/bookheaders/simple";
         doTestGetBook(address, true);



Mime
View raw message