cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From serg...@apache.org
Subject svn commit: r1469335 - in /cxf/branches/2.7.x-fixes: ./ rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/client/
Date Thu, 18 Apr 2013 14:09:13 GMT
Author: sergeyb
Date: Thu Apr 18 14:09:13 2013
New Revision: 1469335

URL: http://svn.apache.org/r1469335
Log:
Merged revisions 1469306 via svnmerge from 
https://svn.apache.org/repos/asf/cxf/trunk

........
  r1469306 | sergeyb | 2013-04-18 14:14:52 +0100 (Thu, 18 Apr 2013) | 1 line
  
  [CXF-4953] Adding a frontend Client adapter to get JAX-RS client used in interfaces where
the frontend Client is expected
........

Added:
    cxf/branches/2.7.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/client/FrontendClientAdapter.java
  (with props)
Modified:
    cxf/branches/2.7.x-fixes/   (props changed)
    cxf/branches/2.7.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/client/JAXRSClientFactoryBean.java
    cxf/branches/2.7.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/client/WebClient.java

Propchange: cxf/branches/2.7.x-fixes/
------------------------------------------------------------------------------
  Merged /cxf/trunk:r1469306

Propchange: cxf/branches/2.7.x-fixes/
------------------------------------------------------------------------------
Binary property 'svnmerge-integrated' - no diff available.

Added: cxf/branches/2.7.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/client/FrontendClientAdapter.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.7.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/client/FrontendClientAdapter.java?rev=1469335&view=auto
==============================================================================
--- cxf/branches/2.7.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/client/FrontendClientAdapter.java
(added)
+++ cxf/branches/2.7.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/client/FrontendClientAdapter.java
Thu Apr 18 14:09:13 2013
@@ -0,0 +1,211 @@
+/**
+ * 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;
+
+import java.util.List;
+import java.util.Map;
+import java.util.concurrent.Executor;
+
+import javax.xml.namespace.QName;
+
+import org.apache.cxf.Bus;
+import org.apache.cxf.endpoint.ClientCallback;
+import org.apache.cxf.endpoint.ConduitSelector;
+import org.apache.cxf.endpoint.Endpoint;
+import org.apache.cxf.interceptor.Interceptor;
+import org.apache.cxf.message.Exchange;
+import org.apache.cxf.message.Message;
+import org.apache.cxf.service.model.BindingOperationInfo;
+import org.apache.cxf.transport.Conduit;
+
+/**
+ * The adapter between JAX-RS and CXF Frontend Client, can be used in cases
+ * when org.apache.cxf.endpoint.Client is expected by the runtime, example when
+ * bus level features have to applied to a given JAX-RS client instance, etc  
+ */
+class FrontendClientAdapter implements org.apache.cxf.endpoint.Client {
+    private ClientConfiguration config;
+    
+    FrontendClientAdapter(ClientConfiguration config) {
+        this.config = config;
+    }
+    
+    @Override
+    public List<Interceptor<? extends Message>> getInInterceptors() {
+        return config.getInInterceptors();
+    }
+
+    @Override
+    public List<Interceptor<? extends Message>> getOutInterceptors() {
+        return config.getOutInterceptors();
+    }
+
+    @Override
+    public List<Interceptor<? extends Message>> getInFaultInterceptors() {
+        return config.getInFaultInterceptors();
+    }
+
+    @Override
+    public List<Interceptor<? extends Message>> getOutFaultInterceptors() {
+        return config.getOutFaultInterceptors();
+    }
+
+    @Override
+    public Conduit getConduit() {
+        return config.getConduit();
+    }
+
+    @Override
+    public ConduitSelector getConduitSelector() {
+        return config.getConduitSelector();
+    }
+
+    @Override
+    public void setConduitSelector(ConduitSelector selector) {
+        config.setConduitSelector(selector);
+    }
+
+    @Override
+    public Bus getBus() {
+        return config.getBus();
+    }
+    
+    @Override
+    public Endpoint getEndpoint() {
+        throw new UnsupportedOperationException();
+    }
+    
+    @Override
+    public void destroy() {
+        throw new UnsupportedOperationException();
+    }
+    
+    @Override
+    public void onMessage(Message message) {
+        throw new UnsupportedOperationException();
+    }
+
+    @Override
+    public Object[] invoke(String operationName, Object... params) throws Exception {
+        throw new UnsupportedOperationException();
+    }
+
+    @Override
+    public Object[] invoke(QName operationName, Object... params) throws Exception {
+        throw new UnsupportedOperationException();
+    }
+
+    @Override
+    public Object[] invokeWrapped(String operationName, Object... params) throws Exception
{
+        throw new UnsupportedOperationException();
+    }
+
+    @Override
+    public Object[] invokeWrapped(QName operationName, Object... params) throws Exception
{
+        throw new UnsupportedOperationException();
+    }
+
+    @Override
+    public Object[] invoke(BindingOperationInfo oi, Object... params) throws Exception {
+        throw new UnsupportedOperationException();
+    }
+
+    @Override
+    public Object[] invoke(BindingOperationInfo oi, Object[] params, Map<String, Object>
context)
+        throws Exception {
+        throw new UnsupportedOperationException();
+    }
+
+    @Override
+    public Object[] invoke(BindingOperationInfo oi, Object[] params, Map<String, Object>
context,
+                           Exchange exchange) throws Exception {
+        throw new UnsupportedOperationException();
+    }
+
+    @Override
+    public void invoke(ClientCallback callback, String operationName, Object... params) throws
Exception {
+        throw new UnsupportedOperationException();
+    }
+
+    @Override
+    public void invoke(ClientCallback callback, QName operationName, Object... params) throws
Exception {
+        throw new UnsupportedOperationException();
+        
+    }
+
+    @Override
+    public void invokeWrapped(ClientCallback callback, String operationName, Object... params)
+        throws Exception {
+        throw new UnsupportedOperationException();
+    }
+
+    @Override
+    public void invokeWrapped(ClientCallback callback, QName operationName, Object... params)
+        throws Exception {
+        throw new UnsupportedOperationException();
+    }
+
+    @Override
+    public void invoke(ClientCallback callback, BindingOperationInfo oi, Object... params)
throws Exception {
+        throw new UnsupportedOperationException();
+    }
+
+    @Override
+    public void invoke(ClientCallback callback, BindingOperationInfo oi, Object[] params,
+                       Map<String, Object> context) throws Exception {
+        throw new UnsupportedOperationException();
+    }
+
+    @Override
+    public void invoke(ClientCallback callback, BindingOperationInfo oi, Object[] params,
Exchange exchange)
+        throws Exception {
+        throw new UnsupportedOperationException();
+    }
+
+    @Override
+    public void invoke(ClientCallback callback, BindingOperationInfo oi, Object[] params,
+                       Map<String, Object> context, Exchange exchange) throws Exception
{
+        throw new UnsupportedOperationException();
+    }
+
+    @Override
+    public Map<String, Object> getRequestContext() {
+        throw new UnsupportedOperationException();
+    }
+
+    @Override
+    public Map<String, Object> getResponseContext() {
+        throw new UnsupportedOperationException();
+    }
+
+    @Override
+    public void setThreadLocalRequestContext(boolean b) {
+        throw new UnsupportedOperationException();
+    }
+
+    @Override
+    public boolean isThreadLocalRequestContext() {
+        throw new UnsupportedOperationException();
+    }
+
+    @Override
+    public void setExecutor(Executor executor) {
+        throw new UnsupportedOperationException();
+    }
+}

Propchange: cxf/branches/2.7.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/client/FrontendClientAdapter.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: cxf/branches/2.7.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/client/FrontendClientAdapter.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Modified: cxf/branches/2.7.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/client/JAXRSClientFactoryBean.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.7.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/client/JAXRSClientFactoryBean.java?rev=1469335&r1=1469334&r2=1469335&view=diff
==============================================================================
--- cxf/branches/2.7.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/client/JAXRSClientFactoryBean.java
(original)
+++ cxf/branches/2.7.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/client/JAXRSClientFactoryBean.java
Thu Apr 18 14:09:13 2013
@@ -28,6 +28,7 @@ import javax.ws.rs.core.MultivaluedMap;
 import org.apache.cxf.common.logging.LogUtils;
 import org.apache.cxf.common.util.ProxyHelper;
 import org.apache.cxf.configuration.security.AuthorizationPolicy;
+import org.apache.cxf.endpoint.ClientLifeCycleManager;
 import org.apache.cxf.endpoint.ConduitSelector;
 import org.apache.cxf.endpoint.Endpoint;
 import org.apache.cxf.endpoint.UpfrontConduitSelector;
@@ -209,6 +210,7 @@ public class JAXRSClientFactoryBean exte
                 : new WebClient(actualState);
             initClient(client, ep, actualState == null);
     
+            notifyLifecycleManager(client); 
             this.getServiceFactory().sendEvent(FactoryBeanListener.Event.CLIENT_CREATED,
client, ep);
             
             return client;
@@ -219,6 +221,12 @@ public class JAXRSClientFactoryBean exte
     }
 
     
+    private void notifyLifecycleManager(Object client) {
+        ClientLifeCycleManager mgr = bus.getExtension(ClientLifeCycleManager.class);
+        if (null != mgr) {
+            mgr.clientCreated(new FrontendClientAdapter(WebClient.getConfig(client)));
+        }
+    }  
     
     private ClientState getActualState() {
         if (threadSafe) {
@@ -311,6 +319,8 @@ public class JAXRSClientFactoryBean exte
                                                                 InvocationHandlerAware.class},

                                      proxyImpl);
             }
+
+            notifyLifecycleManager(actualClient);
             this.getServiceFactory().sendEvent(FactoryBeanListener.Event.CLIENT_CREATED,
actualClient, ep);
             return actualClient;
         } catch (IllegalArgumentException ex) {

Modified: cxf/branches/2.7.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/client/WebClient.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.7.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/client/WebClient.java?rev=1469335&r1=1469334&r2=1469335&view=diff
==============================================================================
--- cxf/branches/2.7.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/client/WebClient.java
(original)
+++ cxf/branches/2.7.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/client/WebClient.java
Thu Apr 18 14:09:13 2013
@@ -236,13 +236,13 @@ public class WebClient extends AbstractC
     }
     
     /**
-     * Converts proxy to Client
-     * @param proxy the proxy
-     * @return proxy as a Client 
-     */
-    public static Client client(Object proxy) {
-        if (proxy instanceof Client) {
-            return (Client)proxy;
+     * Converts object to Client
+     * @param object the object
+     * @return Client object converted to Client 
+     */
+    public static Client client(Object object) {
+        if (object instanceof Client) {
+            return (Client)object;
         }
         return null;
     }



Mime
View raw message