cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From serg...@apache.org
Subject [1/2] cxf git commit: Updatimg RequestDispatcherProvider to be able to map to interfaces
Date Fri, 26 Jun 2015 16:48:00 GMT
Repository: cxf
Updated Branches:
  refs/heads/3.0.x-fixes d54ca8cb1 -> 6e91725ff


Updatimg RequestDispatcherProvider to be able to map to interfaces


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

Branch: refs/heads/3.0.x-fixes
Commit: 5f3f85f9a40bc73ed4dc08528e3ae617c5520c65
Parents: d54ca8c
Author: Sergey Beryozkin <sberyozkin@talend.com>
Authored: Fri Jun 26 17:28:04 2015 +0100
Committer: Sergey Beryozkin <sberyozkin@talend.com>
Committed: Fri Jun 26 17:45:03 2015 +0100

----------------------------------------------------------------------
 .../big_query/src/main/webapp/forms/login.jsp   | 29 ------------
 .../big_query/src/main/webapp/simpleLogin.jsp   | 29 ++++++++++++
 .../provider/RequestDispatcherProvider.java     | 47 +++++++++++++++-----
 3 files changed, 65 insertions(+), 40 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cxf/blob/5f3f85f9/distribution/src/main/release/samples/jax_rs/big_query/src/main/webapp/forms/login.jsp
----------------------------------------------------------------------
diff --git a/distribution/src/main/release/samples/jax_rs/big_query/src/main/webapp/forms/login.jsp
b/distribution/src/main/release/samples/jax_rs/big_query/src/main/webapp/forms/login.jsp
deleted file mode 100644
index d829e42..0000000
--- a/distribution/src/main/release/samples/jax_rs/big_query/src/main/webapp/forms/login.jsp
+++ /dev/null
@@ -1,29 +0,0 @@
-<html xmlns="http://www.w3.org/1999/xhtml">
-<head>
-    <title>Shakespeare Text Search Service Login</title>
-    <STYLE TYPE="text/css">
-	<!--
-	  input {font-family:verdana, arial, helvetica, sans-serif;font-size:20px;line-height:40px;}
-	  div.padded {  
-         padding-left: 15em;  
-      } 
-	-->
-</STYLE>
-</head>
-<body>
-<div class="padded">
-<h1>Shakespeare Text Search Service Login</h1>
-<em></em>
-<p>
- <table>
-     <form action="https://localhost:8080/bigquery/service/oidc/rp" method="POST">
-        <tr>
-            <td colspan="2">
-                <input type="submit" value=" Login with Google "/>
-            </td>
-        </tr>
-  </form>
- </table> 
-</div> 
-</body>
-</html>

http://git-wip-us.apache.org/repos/asf/cxf/blob/5f3f85f9/distribution/src/main/release/samples/jax_rs/big_query/src/main/webapp/simpleLogin.jsp
----------------------------------------------------------------------
diff --git a/distribution/src/main/release/samples/jax_rs/big_query/src/main/webapp/simpleLogin.jsp
b/distribution/src/main/release/samples/jax_rs/big_query/src/main/webapp/simpleLogin.jsp
new file mode 100644
index 0000000..d829e42
--- /dev/null
+++ b/distribution/src/main/release/samples/jax_rs/big_query/src/main/webapp/simpleLogin.jsp
@@ -0,0 +1,29 @@
+<html xmlns="http://www.w3.org/1999/xhtml">
+<head>
+    <title>Shakespeare Text Search Service Login</title>
+    <STYLE TYPE="text/css">
+	<!--
+	  input {font-family:verdana, arial, helvetica, sans-serif;font-size:20px;line-height:40px;}
+	  div.padded {  
+         padding-left: 15em;  
+      } 
+	-->
+</STYLE>
+</head>
+<body>
+<div class="padded">
+<h1>Shakespeare Text Search Service Login</h1>
+<em></em>
+<p>
+ <table>
+     <form action="https://localhost:8080/bigquery/service/oidc/rp" method="POST">
+        <tr>
+            <td colspan="2">
+                <input type="submit" value=" Login with Google "/>
+            </td>
+        </tr>
+  </form>
+ </table> 
+</div> 
+</body>
+</html>

http://git-wip-us.apache.org/repos/asf/cxf/blob/5f3f85f9/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/RequestDispatcherProvider.java
----------------------------------------------------------------------
diff --git a/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/RequestDispatcherProvider.java
b/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/RequestDispatcherProvider.java
index c7b33e6..09a673b 100644
--- a/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/RequestDispatcherProvider.java
+++ b/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/RequestDispatcherProvider.java
@@ -45,6 +45,7 @@ import javax.ws.rs.ext.Provider;
 
 import org.apache.cxf.common.i18n.BundleUtils;
 import org.apache.cxf.common.logging.LogUtils;
+import org.apache.cxf.common.util.StringUtils;
 import org.apache.cxf.jaxrs.ext.MessageContext;
 import org.apache.cxf.jaxrs.utils.ExceptionUtils;
 import org.apache.cxf.jaxrs.utils.ResourceUtils;
@@ -113,23 +114,34 @@ public class RequestDispatcherProvider extends AbstractConfigurableProvider
     }
 
     private String getClassResourceName(Class<?> type) {
-        String simpleName = type.getSimpleName();
-        StringBuilder sb = new StringBuilder();
-        sb.append(Character.toLowerCase(simpleName.charAt(0)));
-        if (simpleName.length() > 1) {
-            sb.append(simpleName.substring(1));
+        String resourceName = doGetClassResourceName(type);
+        if (resourceName == null) {
+            for (Class<?> in : type.getInterfaces()) {
+                resourceName = doGetClassResourceName(in);
+                if (resourceName != null) {
+                    break;
+                }
+            }
         }
+        return resourceName;
+    }
+    private String doGetClassResourceName(Class<?> type) {
+        String simpleName = StringUtils.uncapitalize(type.getSimpleName());
         String thePrefix = locationPrefix == null ? DEFAULT_LOCATION_PREFIX : locationPrefix;
         String theExtension = resourceExtension == null ? DEFAULT_RESOURCE_EXTENSION : resourceExtension;
-        return thePrefix + sb.toString() + theExtension;  
+        String resourceName = thePrefix + simpleName + theExtension;
+        if (ResourceUtils.getClasspathResourceURL(resourceName,
+                                                  RequestDispatcherProvider.class,
+                                                  getBus()) != null) {
+            return resourceName;
+        } else {
+            return null;
+        }
     }
     
     public boolean isWriteable(Class<?> type, Type genericType, Annotation[] annotations,
MediaType mt) {
         
-        if (useClassNames 
-            && ResourceUtils.getClasspathResourceURL(getClassResourceName(type),
-                                                     RequestDispatcherProvider.class,
-                                                     getBus()) != null) {
+        if (useClassNames && getClassResourceName(type) != null) {
             return true;
         }
         if (resourcePath != null || classResourceSupported(type)) {
@@ -339,7 +351,20 @@ public class RequestDispatcherProvider extends AbstractConfigurableProvider
             return beanName;
         }
         String name = beanNames.get(bean.getClass().getName());
-        return name != null ? name : bean.getClass().getSimpleName().toLowerCase();
+        if (name != null) {
+            return null;
+        } 
+        Class<?> resourceClass = bean.getClass();
+        if (useClassNames && doGetClassResourceName(resourceClass) == null) {
+            for (Class<?> cls : bean.getClass().getInterfaces()) {
+                if (doGetClassResourceName(cls) != null) {
+                    resourceClass = cls;
+                    break;
+                }
+            }
+        }
+        
+        return resourceClass.getSimpleName().toLowerCase();
     }
 
     protected void setRequestParameters(HttpServletRequestFilter request) {


Mime
View raw message