cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From serg...@apache.org
Subject svn commit: r1343298 - /cxf/dosgi/trunk/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/handlers/JaxRSPojoConfigurationTypeHandler.java
Date Mon, 28 May 2012 15:46:15 GMT
Author: sergeyb
Date: Mon May 28 15:46:15 2012
New Revision: 1343298

URL: http://svn.apache.org/viewvc?rev=1343298&view=rev
Log:
[DOSGI-18] Retrying a jaxrs proxy creation with ProxyClassLoader

Modified:
    cxf/dosgi/trunk/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/handlers/JaxRSPojoConfigurationTypeHandler.java

Modified: cxf/dosgi/trunk/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/handlers/JaxRSPojoConfigurationTypeHandler.java
URL: http://svn.apache.org/viewvc/cxf/dosgi/trunk/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/handlers/JaxRSPojoConfigurationTypeHandler.java?rev=1343298&r1=1343297&r2=1343298&view=diff
==============================================================================
--- cxf/dosgi/trunk/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/handlers/JaxRSPojoConfigurationTypeHandler.java
(original)
+++ cxf/dosgi/trunk/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/handlers/JaxRSPojoConfigurationTypeHandler.java
Mon May 28 15:46:15 2012
@@ -31,7 +31,9 @@ import org.apache.cxf.dosgi.dsw.OsgiUtil
 import org.apache.cxf.dosgi.dsw.service.ExportRegistrationImpl;
 import org.apache.cxf.endpoint.Server;
 import org.apache.cxf.jaxrs.JAXRSServerFactoryBean;
+import org.apache.cxf.jaxrs.client.Client;
 import org.apache.cxf.jaxrs.client.JAXRSClientFactoryBean;
+import org.apache.cxf.jaxrs.client.ProxyClassLoader;
 import org.apache.cxf.jaxrs.lifecycle.SingletonResourceProvider;
 import org.apache.cxf.jaxrs.model.UserResource;
 import org.osgi.framework.BundleContext;
@@ -62,33 +64,53 @@ public class JaxRSPojoConfigurationTypeH
 
         ClassLoader oldClassLoader = Thread.currentThread().getContextClassLoader();
         try {
-            JAXRSClientFactoryBean bean = new JAXRSClientFactoryBean();
-            bean.setAddress(address);
-
-            addRsInterceptorsFeaturesProps(bean, callingContext, sd.getProperties());
-            
-            List<UserResource> resources = JaxRSUtils.getModel(callingContext, iClass);
-            if (resources != null) {
-                bean.setModelBeansWithServiceClass(resources, iClass);
-            } else {
-                bean.setServiceClass(iClass);
-            }
-            List<Object> providers = JaxRSUtils.getProviders(callingContext, dswContext,
sd.getProperties());
-            if (providers != null && providers.size() > 0) {
-                bean.setProviders(providers);
-            }
-            Thread.currentThread().setContextClassLoader(JAXRSClientFactoryBean.class.getClassLoader());
-            Object proxy = getProxy(bean.create(), iClass);
-            return proxy;
-        } catch (Exception e) {
-            LOG.log(Level.WARNING, "proxy creation failed", e);
-        } finally {
+            return createJaxrsProxy(address, callingContext, dswContext, iClass, null, sd);
+        } catch (Throwable e) {
             Thread.currentThread().setContextClassLoader(oldClassLoader);
         }
+        
+        try {
+        	ProxyClassLoader cl = new ProxyClassLoader();
+        	cl.addLoader(iClass.getClassLoader());
+        	cl.addLoader(Client.class.getClassLoader());
+            return createJaxrsProxy(address, callingContext, dswContext, iClass, cl, sd);
+        } catch (Throwable e) {
+            LOG.log(Level.WARNING, "proxy creation failed", e);
+        }
+        
         return null;
 
     }
 
+    protected Object createJaxrsProxy(String address, 
+    		                          BundleContext dswContext,
+                                      BundleContext callingContext,
+                                      Class<?> iClass,
+                                      ClassLoader loader,
+                                      EndpointDescription sd) {
+    	JAXRSClientFactoryBean bean = new JAXRSClientFactoryBean();
+        bean.setAddress(address);
+        if (loader != null) {
+        	bean.setClassLoader(loader);
+        }
+        
+        addRsInterceptorsFeaturesProps(bean, callingContext, sd.getProperties());
+        
+        List<UserResource> resources = JaxRSUtils.getModel(callingContext, iClass);
+        if (resources != null) {
+            bean.setModelBeansWithServiceClass(resources, iClass);
+        } else {
+            bean.setServiceClass(iClass);
+        }
+        List<Object> providers = JaxRSUtils.getProviders(callingContext, dswContext,
sd.getProperties());
+        if (providers != null && providers.size() > 0) {
+            bean.setProviders(providers);
+        }
+        Thread.currentThread().setContextClassLoader(JAXRSClientFactoryBean.class.getClassLoader());
+        Object proxy = getProxy(bean.create(), iClass);
+        return proxy;
+    }
+    
     @Override
     public void createServer(ExportRegistrationImpl exportRegistration, BundleContext dswContext,
                              BundleContext callingContext, Map sd, Class<?> iClass,
Object serviceBean)



Mime
View raw message