cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From serg...@apache.org
Subject cxf git commit: [CXF-6115] Introducing ClassUnwrapper and updating Classhelpers to delegate to it if it is available
Date Fri, 21 Nov 2014 18:08:58 GMT
Repository: cxf
Updated Branches:
  refs/heads/master bbbe2c56b -> 24ac267d6


[CXF-6115] Introducing ClassUnwrapper and updating Classhelpers to delegate to it if it is
available


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

Branch: refs/heads/master
Commit: 24ac267d6ac755ac536348a8bf1a7f221cc09df8
Parents: bbbe2c5
Author: Sergey Beryozkin <sberyozkin@talend.com>
Authored: Fri Nov 21 18:08:32 2014 +0000
Committer: Sergey Beryozkin <sberyozkin@talend.com>
Committed: Fri Nov 21 18:08:32 2014 +0000

----------------------------------------------------------------------
 .../org/apache/cxf/common/util/ClassHelper.java | 16 ++++++++++---
 .../apache/cxf/common/util/ClassUnwrapper.java  | 25 ++++++++++++++++++++
 .../java/org/apache/cxf/jaxrs/JAXRSInvoker.java |  2 +-
 .../cxf/jaxrs/JAXRSServiceFactoryBean.java      |  2 +-
 .../cxf/jaxrs/provider/ProviderFactory.java     |  4 ++--
 .../jaxrs/provider/ServerProviderFactory.java   |  2 +-
 .../java/org/apache/cxf/jaxws/EndpointImpl.java |  2 +-
 ...xWsWebServicePublisherBeanPostProcessor.java |  2 +-
 .../apache/cxf/frontend/ServerFactoryBean.java  |  6 ++---
 .../cxf/jaxrs/client/ClientProviderFactory.java |  2 +-
 .../cxf/systest/jaxrs/CustomJAXRSInvoker.java   |  2 +-
 11 files changed, 50 insertions(+), 15 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cxf/blob/24ac267d/core/src/main/java/org/apache/cxf/common/util/ClassHelper.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/cxf/common/util/ClassHelper.java b/core/src/main/java/org/apache/cxf/common/util/ClassHelper.java
index 645f780..98c249b 100644
--- a/core/src/main/java/org/apache/cxf/common/util/ClassHelper.java
+++ b/core/src/main/java/org/apache/cxf/common/util/ClassHelper.java
@@ -19,6 +19,9 @@
 
 package org.apache.cxf.common.util;
 
+import org.apache.cxf.Bus;
+import org.apache.cxf.BusFactory;
+
 /**
  * 
  */
@@ -49,10 +52,8 @@ public class ClassHelper {
         return o;
     }
     
-    
-    
     public static Class<?> getRealClass(Object o) {
-        return HELPER.getRealClassInternal(o);
+        return getRealClass(null, o);
     }
     
     public static Class<?> getRealClassFromClass(Class<?> cls) {
@@ -63,5 +64,14 @@ public class ClassHelper {
         return HELPER.getRealObjectInternal(o);
     }
 
+    public static Class<?> getRealClass(Bus bus, Object o) {
+        bus = bus == null ? BusFactory.getThreadDefaultBus() : bus;
+        if (bus != null && bus.getProperty(ClassUnwrapper.class.getName()) != null)
{
+            ClassUnwrapper unwrapper = (ClassUnwrapper)bus.getProperty(ClassUnwrapper.class.getName());
+            return unwrapper.getRealClass(o);
+        } else {
+            return HELPER.getRealClassInternal(o);
+        }
+    }
     
 }

http://git-wip-us.apache.org/repos/asf/cxf/blob/24ac267d/core/src/main/java/org/apache/cxf/common/util/ClassUnwrapper.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/cxf/common/util/ClassUnwrapper.java b/core/src/main/java/org/apache/cxf/common/util/ClassUnwrapper.java
new file mode 100644
index 0000000..c3f8361
--- /dev/null
+++ b/core/src/main/java/org/apache/cxf/common/util/ClassUnwrapper.java
@@ -0,0 +1,25 @@
+/**
+ * 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.common.util;
+
+public interface ClassUnwrapper {
+
+    Class<?> getRealClass(Object o);
+
+}

http://git-wip-us.apache.org/repos/asf/cxf/blob/24ac267d/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/JAXRSInvoker.java
----------------------------------------------------------------------
diff --git a/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/JAXRSInvoker.java b/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/JAXRSInvoker.java
index 135ac8d..9cba371 100644
--- a/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/JAXRSInvoker.java
+++ b/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/JAXRSInvoker.java
@@ -235,7 +235,7 @@ public class JAXRSInvoker extends AbstractInvoker {
                 result = checkResultObject(result, subResourcePath);
 
                 subCri = cri.getSubResource(methodToInvoke.getReturnType(),
-                    ClassHelper.getRealClass(result), result);
+                    ClassHelper.getRealClass(exchange.getBus(), result), result);
                 if (subCri == null) {
                     org.apache.cxf.common.i18n.Message errorM =
                         new org.apache.cxf.common.i18n.Message("NO_SUBRESOURCE_FOUND",

http://git-wip-us.apache.org/repos/asf/cxf/blob/24ac267d/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/JAXRSServiceFactoryBean.java
----------------------------------------------------------------------
diff --git a/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/JAXRSServiceFactoryBean.java
b/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/JAXRSServiceFactoryBean.java
index b9da2727..b615bc3 100644
--- a/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/JAXRSServiceFactoryBean.java
+++ b/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/JAXRSServiceFactoryBean.java
@@ -215,7 +215,7 @@ public class JAXRSServiceFactoryBean extends AbstractServiceFactoryBean
{
     public void setResourceClassesFromBeans(List<Object> beans) {
         for (Object bean : beans) {
             
-            Class<?> realClass = ClassHelper.getRealClass(bean);
+            Class<?> realClass = ClassHelper.getRealClass(getBus(), bean);
             
             ClassResourceInfo cri = getCreatedFromModel(realClass);
             if (cri != null) {

http://git-wip-us.apache.org/repos/asf/cxf/blob/24ac267d/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/ProviderFactory.java
----------------------------------------------------------------------
diff --git a/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/ProviderFactory.java
b/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/ProviderFactory.java
index e38bdb4..1fb8abf 100644
--- a/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/ProviderFactory.java
+++ b/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/ProviderFactory.java
@@ -272,7 +272,7 @@ public abstract class ProviderFactory {
                                      Class<?> providerClass,
                                      boolean injectContext) {
         
-        Class<?> mapperClass = ClassHelper.getRealClass(em.getProvider());
+        Class<?> mapperClass = ClassHelper.getRealClass(bus, em.getProvider());
         Type[] types = null;
         if (m != null && MessageUtils.isTrue(m.getContextualProperty(IGNORE_TYPE_VARIABLES)))
{
             types = new Type[]{mapperClass};
@@ -495,7 +495,7 @@ public abstract class ProviderFactory {
         List<ProviderInfo<WriterInterceptor>> writeInts = 
             new LinkedList<ProviderInfo<WriterInterceptor>>();
         for (ProviderInfo<? extends Object> provider : theProviders) {
-            Class<?> providerCls = ClassHelper.getRealClass(provider.getProvider());
+            Class<?> providerCls = ClassHelper.getRealClass(bus, provider.getProvider());
             
             if (MessageBodyReader.class.isAssignableFrom(providerCls)) {
                 addProviderToList(messageReaders, provider);

http://git-wip-us.apache.org/repos/asf/cxf/blob/24ac267d/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/ServerProviderFactory.java
----------------------------------------------------------------------
diff --git a/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/ServerProviderFactory.java
b/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/ServerProviderFactory.java
index 9418224..0094ace 100644
--- a/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/ServerProviderFactory.java
+++ b/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/ServerProviderFactory.java
@@ -220,7 +220,7 @@ public final class ServerProviderFactory extends ProviderFactory {
             prepareProviders((Object[])providers, application);
         super.setCommonProviders(theProviders);
         for (ProviderInfo<? extends Object> provider : theProviders) {
-            Class<?> providerCls = ClassHelper.getRealClass(provider.getProvider());
+            Class<?> providerCls = ClassHelper.getRealClass(getBus(), provider.getProvider());
             
             if (filterContractSupported(provider, providerCls, ContainerRequestFilter.class))
{
                 addContainerRequestFilter(postMatchRequestFilters, 

http://git-wip-us.apache.org/repos/asf/cxf/blob/24ac267d/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/EndpointImpl.java
----------------------------------------------------------------------
diff --git a/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/EndpointImpl.java b/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/EndpointImpl.java
index 9807cae..467751f 100644
--- a/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/EndpointImpl.java
+++ b/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/EndpointImpl.java
@@ -216,7 +216,7 @@ public class EndpointImpl extends javax.xml.ws.Endpoint
      * @return the class of the implementor object
      */
     public Class<?> getImplementorClass() {
-        return implementorClass != null ? implementorClass : ClassHelper.getRealClass(implementor);
+        return implementorClass != null ? implementorClass : ClassHelper.getRealClass(bus,
implementor);
     }
 
     public List<Source> getMetadata() {

http://git-wip-us.apache.org/repos/asf/cxf/blob/24ac267d/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/spring/JaxWsWebServicePublisherBeanPostProcessor.java
----------------------------------------------------------------------
diff --git a/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/spring/JaxWsWebServicePublisherBeanPostProcessor.java
b/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/spring/JaxWsWebServicePublisherBeanPostProcessor.java
index f3294b4..45118a3 100644
--- a/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/spring/JaxWsWebServicePublisherBeanPostProcessor.java
+++ b/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/spring/JaxWsWebServicePublisherBeanPostProcessor.java
@@ -130,7 +130,7 @@ public class JaxWsWebServicePublisherBeanPostProcessor
     }
     
     public Object postProcessAfterInitialization(Object bean, String beanName) throws BeansException
{
-        Class<?> clazz = ClassHelper.getRealClass(bean);
+        Class<?> clazz = ClassHelper.getRealClass(getServletBus(), bean);
 
         if (clazz.isAnnotationPresent(WebService.class)) {
             WebService ws = clazz.getAnnotation(WebService.class);

http://git-wip-us.apache.org/repos/asf/cxf/blob/24ac267d/rt/frontend/simple/src/main/java/org/apache/cxf/frontend/ServerFactoryBean.java
----------------------------------------------------------------------
diff --git a/rt/frontend/simple/src/main/java/org/apache/cxf/frontend/ServerFactoryBean.java
b/rt/frontend/simple/src/main/java/org/apache/cxf/frontend/ServerFactoryBean.java
index 3d82657..46fc155 100644
--- a/rt/frontend/simple/src/main/java/org/apache/cxf/frontend/ServerFactoryBean.java
+++ b/rt/frontend/simple/src/main/java/org/apache/cxf/frontend/ServerFactoryBean.java
@@ -156,7 +156,7 @@ public class ServerFactoryBean extends AbstractWSDLBasedEndpointFactory
{
                     getServiceFactory().getProperties().putAll(getProperties());
                 }
                 if (serviceBean != null && getServiceClass() == null) {
-                    setServiceClass(ClassHelper.getRealClass(serviceBean));
+                    setServiceClass(ClassHelper.getRealClass(bus, serviceBean));
                 }
                 if (invoker != null) {
                     getServiceFactory().setInvoker(invoker);
@@ -173,7 +173,7 @@ public class ServerFactoryBean extends AbstractWSDLBasedEndpointFactory
{
                                                   ? getServiceFactory().getServiceClass()

                                                   : getServiceClass()
                                               : getServiceClass() == null
-                                                  ? ClassHelper.getRealClass(getServiceBean())

+                                                  ? ClassHelper.getRealClass(getBus(), getServiceBean())

                                                   : getServiceClass());
 
                 server = new ServerImpl(getBus(),
@@ -285,7 +285,7 @@ public class ServerFactoryBean extends AbstractWSDLBasedEndpointFactory
{
 
     public Class<?> getServiceBeanClass() {
         if (serviceBean != null) {
-            return ClassHelper.getRealClass(serviceBean);
+            return ClassHelper.getRealClass(getBus(), serviceBean);
         } else {
             return getServiceFactory().getServiceClass();
         }

http://git-wip-us.apache.org/repos/asf/cxf/blob/24ac267d/rt/rs/client/src/main/java/org/apache/cxf/jaxrs/client/ClientProviderFactory.java
----------------------------------------------------------------------
diff --git a/rt/rs/client/src/main/java/org/apache/cxf/jaxrs/client/ClientProviderFactory.java
b/rt/rs/client/src/main/java/org/apache/cxf/jaxrs/client/ClientProviderFactory.java
index 0c2b20b..2764756 100644
--- a/rt/rs/client/src/main/java/org/apache/cxf/jaxrs/client/ClientProviderFactory.java
+++ b/rt/rs/client/src/main/java/org/apache/cxf/jaxrs/client/ClientProviderFactory.java
@@ -88,7 +88,7 @@ public final class ClientProviderFactory extends ProviderFactory {
             prepareProviders((Object[])providers, null);
         super.setCommonProviders(theProviders);
         for (ProviderInfo<? extends Object> provider : theProviders) {
-            Class<?> providerCls = ClassHelper.getRealClass(provider.getProvider());
+            Class<?> providerCls = ClassHelper.getRealClass(getBus(), provider.getProvider());
             if (filterContractSupported(provider, providerCls, ClientRequestFilter.class))
{
                 addProviderToList(clientRequestFilters, provider);
             }

http://git-wip-us.apache.org/repos/asf/cxf/blob/24ac267d/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/CustomJAXRSInvoker.java
----------------------------------------------------------------------
diff --git a/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/CustomJAXRSInvoker.java
b/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/CustomJAXRSInvoker.java
index 2f5a0f2..cce0f04 100644
--- a/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/CustomJAXRSInvoker.java
+++ b/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/CustomJAXRSInvoker.java
@@ -38,7 +38,7 @@ public class CustomJAXRSInvoker extends JAXRSInvoker {
         
         OperationResourceInfo ori = exchange.get(OperationResourceInfo.class);
         Method m = ori.getMethodToInvoke();
-        Class<?> realClass = ClassHelper.getRealClass(resourceObject);
+        Class<?> realClass = ClassHelper.getRealClass(exchange.getBus(), resourceObject);
         
         Principal p = new SecurityContextImpl(exchange.getInMessage()).getUserPrincipal();
         if (realClass == SecureBookStore.class && "getThatBook".equals(m.getName())


Mime
View raw message