tomee-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rmannibu...@apache.org
Subject svn commit: r1458224 - in /tomee/tomee/trunk/server: openejb-axis/src/main/java/org/apache/openejb/server/axis/ openejb-cxf-rs/src/main/java/org/apache/openejb/server/cxf/rs/ openejb-cxf/src/main/java/org/apache/openejb/server/cxf/ openejb-cxf/src/main...
Date Tue, 19 Mar 2013 11:17:37 GMT
Author: rmannibucau
Date: Tue Mar 19 11:17:37 2013
New Revision: 1458224

URL: http://svn.apache.org/r1458224
Log:
using app classloader instead of class classloader for cxf webservices to be sure to get the
right initial context - in embedded mode class classloader is often appclassloader

Modified:
    tomee/tomee/trunk/server/openejb-axis/src/main/java/org/apache/openejb/server/axis/AxisService.java
    tomee/tomee/trunk/server/openejb-cxf-rs/src/main/java/org/apache/openejb/server/cxf/rs/CxfRsHttpListener.java
    tomee/tomee/trunk/server/openejb-cxf-rs/src/main/java/org/apache/openejb/server/cxf/rs/OpenEJBPerRequestPojoResourceProvider.java
    tomee/tomee/trunk/server/openejb-cxf/src/main/java/org/apache/openejb/server/cxf/CxfService.java
    tomee/tomee/trunk/server/openejb-cxf/src/main/java/org/apache/openejb/server/cxf/pojo/PojoEndpoint.java
    tomee/tomee/trunk/server/openejb-cxf/src/main/java/org/apache/openejb/server/cxf/pojo/PojoWsContainer.java
    tomee/tomee/trunk/server/openejb-rest/src/main/java/org/apache/openejb/server/rest/RESTService.java
    tomee/tomee/trunk/server/openejb-rest/src/main/java/org/apache/openejb/server/rest/RsHttpListener.java
    tomee/tomee/trunk/server/openejb-webservices/src/main/java/org/apache/openejb/server/webservices/WsService.java

Modified: tomee/tomee/trunk/server/openejb-axis/src/main/java/org/apache/openejb/server/axis/AxisService.java
URL: http://svn.apache.org/viewvc/tomee/tomee/trunk/server/openejb-axis/src/main/java/org/apache/openejb/server/axis/AxisService.java?rev=1458224&r1=1458223&r2=1458224&view=diff
==============================================================================
--- tomee/tomee/trunk/server/openejb-axis/src/main/java/org/apache/openejb/server/axis/AxisService.java
(original)
+++ tomee/tomee/trunk/server/openejb-axis/src/main/java/org/apache/openejb/server/axis/AxisService.java
Tue Mar 19 11:17:37 2013
@@ -102,7 +102,7 @@ public class AxisService extends WsServi
         }
     }
 
-    protected HttpListener createPojoWsContainer(URL moduleBaseUrl, PortData port, String
serviceId, Class target, Context context, String contextRoot, Map<String, Object> bdgs,
ServiceConfiguration serviceInfos) throws Exception {
+    protected HttpListener createPojoWsContainer(ClassLoader loader, URL moduleBaseUrl, PortData
port, String serviceId, Class target, Context context, String contextRoot, Map<String,
Object> bdgs, ServiceConfiguration serviceInfos) throws Exception {
         ClassLoader classLoader = target.getClassLoader();
 
         // todo build JaxRpcServiceInfo in assembler

Modified: tomee/tomee/trunk/server/openejb-cxf-rs/src/main/java/org/apache/openejb/server/cxf/rs/CxfRsHttpListener.java
URL: http://svn.apache.org/viewvc/tomee/tomee/trunk/server/openejb-cxf-rs/src/main/java/org/apache/openejb/server/cxf/rs/CxfRsHttpListener.java?rev=1458224&r1=1458223&r2=1458224&view=diff
==============================================================================
--- tomee/tomee/trunk/server/openejb-cxf-rs/src/main/java/org/apache/openejb/server/cxf/rs/CxfRsHttpListener.java
(original)
+++ tomee/tomee/trunk/server/openejb-cxf-rs/src/main/java/org/apache/openejb/server/cxf/rs/CxfRsHttpListener.java
Tue Mar 19 11:17:37 2013
@@ -197,9 +197,9 @@ public class CxfRsHttpListener implement
     }
 
     @Override
-    public void deployPojo(String contextRoot, String fullContext, Class<?> loadedClazz,
Application app, Collection<Injection> injections,
+    public void deployPojo(ClassLoader loader, String contextRoot, String fullContext, Class<?>
loadedClazz, Application app, Collection<Injection> injections,
                            Context context, WebBeansContext owbCtx, Collection<Object>
additionalProviders, ServiceConfiguration configuration) {
-        deploy(contextRoot, loadedClazz, fullContext, new OpenEJBPerRequestPojoResourceProvider(loadedClazz,
injections, context, owbCtx),
+        deploy(contextRoot, loadedClazz, fullContext, new OpenEJBPerRequestPojoResourceProvider(loader,
loadedClazz, injections, context, owbCtx),
                             null, app, null, additionalProviders, configuration);
     }
 
@@ -325,7 +325,7 @@ public class CxfRsHttpListener implement
                     final Object proxy = ProxyEJB.subclassProxy(bc);
                     factory.setResourceProvider(clazz, new NoopResourceProvider(bc.getBeanClass(),
proxy));
                 } else {
-                    factory.setResourceProvider(clazz, new OpenEJBPerRequestPojoResourceProvider(clazz,
injections, context, owbCtx));
+                    factory.setResourceProvider(clazz, new OpenEJBPerRequestPojoResourceProvider(classLoader,
clazz, injections, context, owbCtx));
                 }
             }
 

Modified: tomee/tomee/trunk/server/openejb-cxf-rs/src/main/java/org/apache/openejb/server/cxf/rs/OpenEJBPerRequestPojoResourceProvider.java
URL: http://svn.apache.org/viewvc/tomee/tomee/trunk/server/openejb-cxf-rs/src/main/java/org/apache/openejb/server/cxf/rs/OpenEJBPerRequestPojoResourceProvider.java?rev=1458224&r1=1458223&r2=1458224&view=diff
==============================================================================
--- tomee/tomee/trunk/server/openejb-cxf-rs/src/main/java/org/apache/openejb/server/cxf/rs/OpenEJBPerRequestPojoResourceProvider.java
(original)
+++ tomee/tomee/trunk/server/openejb-cxf-rs/src/main/java/org/apache/openejb/server/cxf/rs/OpenEJBPerRequestPojoResourceProvider.java
Tue Mar 19 11:17:37 2013
@@ -65,10 +65,10 @@ public class OpenEJBPerRequestPojoResour
     private BeanCreator creator;
     private final Collection<Class<?>> contextTypes = new HashSet<Class<?>>();
 
-    public OpenEJBPerRequestPojoResourceProvider(final Class<?> clazz, final Collection<Injection>
injectionCollection, final Context initialContext, final WebBeansContext owbCtx) {
+    public OpenEJBPerRequestPojoResourceProvider(final ClassLoader loader, final Class<?>
clazz, final Collection<Injection> injectionCollection, final Context initialContext,
final WebBeansContext owbCtx) {
         injections = injectionCollection;
         webbeansContext = owbCtx;
-        classLoader = clazz.getClassLoader();
+        classLoader = loader;
         context = (Context) Proxy.newProxyInstance(classLoader, new Class<?>[]{Context.class},
new InitialContextWrapper(initialContext));
 
         constructor = ResourceUtils.findResourceConstructor(clazz, true);

Modified: tomee/tomee/trunk/server/openejb-cxf/src/main/java/org/apache/openejb/server/cxf/CxfService.java
URL: http://svn.apache.org/viewvc/tomee/tomee/trunk/server/openejb-cxf/src/main/java/org/apache/openejb/server/cxf/CxfService.java?rev=1458224&r1=1458223&r2=1458224&view=diff
==============================================================================
--- tomee/tomee/trunk/server/openejb-cxf/src/main/java/org/apache/openejb/server/cxf/CxfService.java
(original)
+++ tomee/tomee/trunk/server/openejb-cxf/src/main/java/org/apache/openejb/server/cxf/CxfService.java
Tue Mar 19 11:17:37 2013
@@ -68,7 +68,7 @@ public class CxfService extends WsServic
         }
     }
 
-    protected HttpListener createPojoWsContainer(URL moduleBaseUrl, PortData port, String
serviceId, Class target, Context context, String contextRoot, Map<String, Object> bdgs,
ServiceConfiguration services) {
+    protected HttpListener createPojoWsContainer(ClassLoader loader, URL moduleBaseUrl, PortData
port, String serviceId, Class target, Context context, String contextRoot, Map<String,
Object> bdgs, ServiceConfiguration services) {
         Bus bus = CxfUtil.getBus();
 
         final ClassLoader oldLoader = Thread.currentThread().getContextClassLoader();
@@ -76,7 +76,7 @@ public class CxfService extends WsServic
         try {
             CxfCatalogUtils.loadOASISCatalog(bus, moduleBaseUrl, "META-INF/jax-ws-catalog.xml");
 
-            PojoWsContainer container = new PojoWsContainer(bus, port, context, target, bdgs,
services);
+            PojoWsContainer container = new PojoWsContainer(loader, bus, port, context, target,
bdgs, services);
             container.start();
             wsContainers.put(serviceId, container);
             return container;

Modified: tomee/tomee/trunk/server/openejb-cxf/src/main/java/org/apache/openejb/server/cxf/pojo/PojoEndpoint.java
URL: http://svn.apache.org/viewvc/tomee/tomee/trunk/server/openejb-cxf/src/main/java/org/apache/openejb/server/cxf/pojo/PojoEndpoint.java?rev=1458224&r1=1458223&r2=1458224&view=diff
==============================================================================
--- tomee/tomee/trunk/server/openejb-cxf/src/main/java/org/apache/openejb/server/cxf/pojo/PojoEndpoint.java
(original)
+++ tomee/tomee/trunk/server/openejb-cxf/src/main/java/org/apache/openejb/server/cxf/pojo/PojoEndpoint.java
Tue Mar 19 11:17:37 2013
@@ -44,7 +44,7 @@ import static org.apache.openejb.Injecti
 public class PojoEndpoint extends CxfEndpoint {
     private InjectionProcessor<Object> injectionProcessor;
 
-    public PojoEndpoint(Bus bus, PortData port, Context context, Class<?> instance,
+    public PojoEndpoint(ClassLoader loader, Bus bus, PortData port, Context context, Class<?>
instance,
                         HTTPTransportFactory httpTransportFactory,
                         Map<String, Object> bindings, ServiceConfiguration config)
{
     	super(bus, port, context, instance, httpTransportFactory, config);
@@ -65,7 +65,9 @@ public class PojoEndpoint extends CxfEnd
 
         service = serviceFactory.create();
 
-        // instantiate and inject resources into service
+        // instantiate and inject resources into service using the app classloader to be
sure to get the right InitialContext
+        final ClassLoader old = Thread.currentThread().getContextClassLoader();
+        Thread.currentThread().setContextClassLoader(loader);
         try {
             injectionProcessor = new InjectionProcessor<Object>(instance, port.getInjections(),
null, null, unwrap(context), bindings);
             injectionProcessor.createInstance();
@@ -74,6 +76,8 @@ public class PojoEndpoint extends CxfEnd
             injectCxfResources(implementor);
         } catch (Exception e) {
             throw new WebServiceException("Service resource injection failed", e);
+        } finally {
+            Thread.currentThread().setContextClassLoader(old);
         }
 
         service.setInvoker(new JAXWSMethodInvoker(implementor));

Modified: tomee/tomee/trunk/server/openejb-cxf/src/main/java/org/apache/openejb/server/cxf/pojo/PojoWsContainer.java
URL: http://svn.apache.org/viewvc/tomee/tomee/trunk/server/openejb-cxf/src/main/java/org/apache/openejb/server/cxf/pojo/PojoWsContainer.java?rev=1458224&r1=1458223&r2=1458224&view=diff
==============================================================================
--- tomee/tomee/trunk/server/openejb-cxf/src/main/java/org/apache/openejb/server/cxf/pojo/PojoWsContainer.java
(original)
+++ tomee/tomee/trunk/server/openejb-cxf/src/main/java/org/apache/openejb/server/cxf/pojo/PojoWsContainer.java
Tue Mar 19 11:17:37 2013
@@ -29,17 +29,19 @@ public class PojoWsContainer extends Cxf
     private final Context context;
     private final Class target;
     private final Map<String, Object> bindings;
+    private final ClassLoader loader;
 
-    public PojoWsContainer(Bus bus, PortData port, Context context, Class target,
+    public PojoWsContainer(ClassLoader loader, Bus bus, PortData port, Context context, Class
target,
                            Map<String, Object> bdgs, ServiceConfiguration configuration)
{
         super(bus, port, configuration);
         if (target == null) throw new NullPointerException("target is null");
         this.context = context;
         this.target = target;
         this.bindings = bdgs;
+        this.loader = loader;
     }
 
     protected PojoEndpoint createEndpoint() {
-        return new PojoEndpoint(bus, port, context, target, httpTransportFactory, bindings,
serviceConfiguration);
+        return new PojoEndpoint(loader, bus, port, context, target, httpTransportFactory,
bindings, serviceConfiguration);
     }
 }

Modified: tomee/tomee/trunk/server/openejb-rest/src/main/java/org/apache/openejb/server/rest/RESTService.java
URL: http://svn.apache.org/viewvc/tomee/tomee/trunk/server/openejb-rest/src/main/java/org/apache/openejb/server/rest/RESTService.java?rev=1458224&r1=1458223&r2=1458224&view=diff
==============================================================================
--- tomee/tomee/trunk/server/openejb-rest/src/main/java/org/apache/openejb/server/rest/RESTService.java
(original)
+++ tomee/tomee/trunk/server/openejb-rest/src/main/java/org/apache/openejb/server/rest/RESTService.java
Tue Mar 19 11:17:37 2013
@@ -678,7 +678,7 @@ public abstract class RESTService implem
         final RsRegistry.AddressInfo address = rsRegistry.createRsHttpListener(web, listener,
classLoader, nopath.substring(NOPATH_PREFIX.length() - 1), virtualHost);
 
         services.add(new DeployedService(address.complete, contextRoot, loadedClazz.getName()));
-        listener.deployPojo(contextRoot, getFullContext(address.base, contextRoot), loadedClazz,
app, injections, context, owbCtx,
+        listener.deployPojo(classLoader, contextRoot, getFullContext(address.base, contextRoot),
loadedClazz, app, injections, context, owbCtx,
                 additionalProviders, config);
 
         LOGGER.info("REST Service: " + address.complete + "  -> Pojo " + loadedClazz.getName());

Modified: tomee/tomee/trunk/server/openejb-rest/src/main/java/org/apache/openejb/server/rest/RsHttpListener.java
URL: http://svn.apache.org/viewvc/tomee/tomee/trunk/server/openejb-rest/src/main/java/org/apache/openejb/server/rest/RsHttpListener.java?rev=1458224&r1=1458223&r2=1458224&view=diff
==============================================================================
--- tomee/tomee/trunk/server/openejb-rest/src/main/java/org/apache/openejb/server/rest/RsHttpListener.java
(original)
+++ tomee/tomee/trunk/server/openejb-rest/src/main/java/org/apache/openejb/server/rest/RsHttpListener.java
Tue Mar 19 11:17:37 2013
@@ -32,8 +32,9 @@ public interface RsHttpListener extends 
     void deploySingleton(String webContext, String fullContext, Object o, Application appInstance,
                          Collection<Object> additionalProviders, ServiceConfiguration
serviceInfos);
 
-    void deployPojo(String webContext, String fullContext, Class<?> loadedClazz, Application
app, Collection<Injection> injections,
-                    Context context, WebBeansContext owbCtx, Collection<Object> additionalProviders,
ServiceConfiguration serviceInfos);
+    void deployPojo(ClassLoader classloader, String webContext, String fullContext, Class<?>
loadedClazz, Application app,
+                    Collection<Injection> injections, Context context, WebBeansContext
owbCtx,
+                    Collection<Object> additionalProviders, ServiceConfiguration serviceInfos);
 
     void deployEJB(String webContext, String fullContext, BeanContext beanContext, Collection<Object>
additionalProviders, ServiceConfiguration serviceInfos);
 

Modified: tomee/tomee/trunk/server/openejb-webservices/src/main/java/org/apache/openejb/server/webservices/WsService.java
URL: http://svn.apache.org/viewvc/tomee/tomee/trunk/server/openejb-webservices/src/main/java/org/apache/openejb/server/webservices/WsService.java?rev=1458224&r1=1458223&r2=1458224&view=diff
==============================================================================
--- tomee/tomee/trunk/server/openejb-webservices/src/main/java/org/apache/openejb/server/webservices/WsService.java
(original)
+++ tomee/tomee/trunk/server/openejb-webservices/src/main/java/org/apache/openejb/server/webservices/WsService.java
Tue Mar 19 11:17:37 2013
@@ -207,7 +207,9 @@ public abstract class WsService implemen
 
     protected abstract void destroyEjbWsContainer(String deploymentId);
 
-    protected abstract HttpListener createPojoWsContainer(URL moduleBaseUrl, PortData port,
String serviceId, Class target, Context context, String contextRoot, Map<String, Object>
bindings, ServiceConfiguration configuration) throws Exception;
+    protected abstract HttpListener createPojoWsContainer(ClassLoader loader, URL moduleBaseUrl,
PortData port, String serviceId,
+                                                          Class target, Context context,
String contextRoot,
+                                                          Map<String, Object> bindings,
ServiceConfiguration configuration) throws Exception;
 
     protected abstract void destroyPojoWsContainer(String serviceId);
 
@@ -370,7 +372,7 @@ public abstract class WsService implemen
 
                 pojoConfiguration = PojoUtil.findPojoConfig(pojoConfiguration, appInfo, webApp);
 
-                final HttpListener container = createPojoWsContainer(moduleBaseUrl, port,
portInfo.serviceLink,
+                final HttpListener container = createPojoWsContainer(classLoader, moduleBaseUrl,
port, portInfo.serviceLink,
                                                                      target, context, webApp.contextRoot,
bindings,
                                                                      new ServiceConfiguration(PojoUtil.findConfiguration(pojoConfiguration,
target.getName()), appInfo.services));
 



Mime
View raw message