camel-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ningji...@apache.org
Subject svn commit: r1360716 - in /camel/branches/camel-2.9.x: ./ components/camel-cxf/src/main/java/org/apache/camel/component/cxf/jaxrs/ components/camel-cxf/src/test/java/org/apache/camel/component/cxf/ components/camel-cxf/src/test/java/org/apache/camel/co...
Date Thu, 12 Jul 2012 15:13:45 GMT
Author: ningjiang
Date: Thu Jul 12 15:13:45 2012
New Revision: 1360716

URL: http://svn.apache.org/viewvc?rev=1360716&view=rev
Log:
Merged revisions 1360663 via svnmerge from 
https://svn.apache.org/repos/asf/camel/branches/camel-2.10.x

................
  r1360663 | ningjiang | 2012-07-12 21:17:59 +0800 (Thu, 12 Jul 2012) | 9 lines
  
  Merged revisions 1360583 via svnmerge from 
  https://svn.apache.org/repos/asf/camel/trunk
  
  ........
    r1360583 | ningjiang | 2012-07-12 16:50:19 +0800 (Thu, 12 Jul 2012) | 1 line
    
    Fixed the CS errors of camel-cxf components
  ........
................

Added:
    camel/branches/camel-2.9.x/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/jaxrs/CamelResourceProvider.java
    camel/branches/camel-2.9.x/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/jaxrs/SubResourceClassInvocationHandler.java
Modified:
    camel/branches/camel-2.9.x/   (props changed)
    camel/branches/camel-2.9.x/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/jaxrs/CxfRsEndpoint.java
    camel/branches/camel-2.9.x/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/CxfPayLoadBareSoapTest.java
    camel/branches/camel-2.9.x/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/jaxrs/testbean/CustomerServiceResource.java

Propchange: camel/branches/camel-2.9.x/
------------------------------------------------------------------------------
  Merged /camel/trunk:r1360583
  Merged /camel/branches/camel-2.10.x:r1360663

Propchange: camel/branches/camel-2.9.x/
------------------------------------------------------------------------------
Binary property 'svnmerge-integrated' - no diff available.

Added: camel/branches/camel-2.9.x/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/jaxrs/CamelResourceProvider.java
URL: http://svn.apache.org/viewvc/camel/branches/camel-2.9.x/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/jaxrs/CamelResourceProvider.java?rev=1360716&view=auto
==============================================================================
--- camel/branches/camel-2.9.x/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/jaxrs/CamelResourceProvider.java
(added)
+++ camel/branches/camel-2.9.x/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/jaxrs/CamelResourceProvider.java
Thu Jul 12 15:13:45 2012
@@ -0,0 +1,71 @@
+/**
+ * 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.camel.component.cxf.jaxrs;
+
+import java.lang.reflect.Proxy;
+
+import org.apache.cxf.jaxrs.lifecycle.PerRequestResourceProvider;
+import org.apache.cxf.jaxrs.lifecycle.ResourceProvider;
+import org.apache.cxf.message.Message;
+
+public class CamelResourceProvider implements ResourceProvider {
+    // Using the dynamical proxy to provide the instance of client to invoke
+    private Class<?> clazz;
+    private ResourceProvider provider;
+    
+    public CamelResourceProvider(Class<?> clazz) {
+        this.clazz = clazz;
+        if (!clazz.isInterface()) {
+            provider = new PerRequestResourceProvider(clazz);
+        }
+    }
+
+    @Override
+    public Object getInstance(Message m) {
+        Object result = null;
+        if (provider != null) {
+            result = provider.getInstance(m);
+        } else {
+            // create the instance with the invoker
+            result = Proxy.newProxyInstance(clazz.getClassLoader(), new Class[] {clazz},
+                                            new SubResourceClassInvocationHandler());
+        }
+        return result;
+    }
+
+    @Override
+    public void releaseInstance(Message m, Object o) {
+        if (provider != null) {
+            provider.releaseInstance(m, o);
+        }
+    }
+
+    @Override
+    public Class<?> getResourceClass() {
+        if (provider != null) {
+            return provider.getResourceClass();
+        } else {
+            return clazz;
+        }
+    }
+
+    @Override
+    public boolean isSingleton() {
+        return false;
+    }
+
+}

Modified: camel/branches/camel-2.9.x/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/jaxrs/CxfRsEndpoint.java
URL: http://svn.apache.org/viewvc/camel/branches/camel-2.9.x/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/jaxrs/CxfRsEndpoint.java?rev=1360716&r1=1360715&r2=1360716&view=diff
==============================================================================
--- camel/branches/camel-2.9.x/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/jaxrs/CxfRsEndpoint.java
(original)
+++ camel/branches/camel-2.9.x/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/jaxrs/CxfRsEndpoint.java
Thu Jul 12 15:13:45 2012
@@ -141,8 +141,8 @@ public class CxfRsEndpoint extends Defau
         if (getResourceClasses() != null) {
             List<Class<?>> res = CastUtils.cast(getResourceClasses());
             // setup the resource providers
-            for(Class<?>clazz : res) {
-            	sfb.setResourceProvider(clazz, new CamelResourceProvider(clazz));
+            for (Class<?> clazz : res) {
+                sfb.setResourceProvider(clazz, new CamelResourceProvider(clazz));
             }
             sfb.setResourceClasses(res);
         }

Added: camel/branches/camel-2.9.x/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/jaxrs/SubResourceClassInvocationHandler.java
URL: http://svn.apache.org/viewvc/camel/branches/camel-2.9.x/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/jaxrs/SubResourceClassInvocationHandler.java?rev=1360716&view=auto
==============================================================================
--- camel/branches/camel-2.9.x/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/jaxrs/SubResourceClassInvocationHandler.java
(added)
+++ camel/branches/camel-2.9.x/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/jaxrs/SubResourceClassInvocationHandler.java
Thu Jul 12 15:13:45 2012
@@ -0,0 +1,48 @@
+/**
+ * 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.camel.component.cxf.jaxrs;
+
+import java.lang.reflect.Constructor;
+import java.lang.reflect.InvocationHandler;
+import java.lang.reflect.Method;
+import java.lang.reflect.Proxy;
+
+import org.apache.cxf.jaxrs.utils.ResourceUtils;
+// This class only return the sub class instance
+public class SubResourceClassInvocationHandler implements InvocationHandler {
+
+    @Override
+    public Object invoke(Object proxy, Method method, Object[] parameters) throws Throwable
{
+        Object result = null;
+        Class<?> returnType = method.getReturnType();
+        System.out.println("returnType class " + returnType);
+        if (!returnType.isAssignableFrom(Void.class)) {
+            // create a instance to return
+            if (returnType.isInterface()) {
+                // create a new proxy for it
+                result = Proxy.newProxyInstance(returnType.getClassLoader(), new Class[]
{returnType},
+                                                new SubResourceClassInvocationHandler());
+            } else {
+                // get the constructor and create a new instance
+                Constructor<?> c = ResourceUtils.findResourceConstructor(returnType,
true);
+                result = c.newInstance(new Object[] {});
+            }
+        }
+        return result;
+    }
+
+}

Modified: camel/branches/camel-2.9.x/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/CxfPayLoadBareSoapTest.java
URL: http://svn.apache.org/viewvc/camel/branches/camel-2.9.x/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/CxfPayLoadBareSoapTest.java?rev=1360716&r1=1360715&r2=1360716&view=diff
==============================================================================
--- camel/branches/camel-2.9.x/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/CxfPayLoadBareSoapTest.java
(original)
+++ camel/branches/camel-2.9.x/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/CxfPayLoadBareSoapTest.java
Thu Jul 12 15:13:45 2012
@@ -76,7 +76,7 @@ public class CxfPayLoadBareSoapTest exte
 
     @WebService
     @SOAPBinding(parameterStyle = SOAPBinding.ParameterStyle.BARE)
-    public static interface BareSoapService {
+    public interface BareSoapService {
 
         public void doSomething();
 

Modified: camel/branches/camel-2.9.x/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/jaxrs/testbean/CustomerServiceResource.java
URL: http://svn.apache.org/viewvc/camel/branches/camel-2.9.x/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/jaxrs/testbean/CustomerServiceResource.java?rev=1360716&r1=1360715&r2=1360716&view=diff
==============================================================================
--- camel/branches/camel-2.9.x/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/jaxrs/testbean/CustomerServiceResource.java
(original)
+++ camel/branches/camel-2.9.x/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/jaxrs/testbean/CustomerServiceResource.java
Thu Jul 12 15:13:45 2012
@@ -29,10 +29,10 @@ public interface CustomerServiceResource
 
     @GET
     @Path("/customers/{id}/")
-    public Customer getCustomer(@PathParam("id") String id);
+    Customer getCustomer(@PathParam("id") String id);
 
     @PUT
     @Path("/customers/")
-    public Response updateCustomer(Customer customer);
+    Response updateCustomer(Customer customer);
 }
 // END SNIPPET: example



Mime
View raw message