You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by ni...@apache.org on 2015/04/17 08:20:32 UTC

[1/3] camel git commit: CAMEL-8642 Merged the patch into camel-http4

Repository: camel
Updated Branches:
  refs/heads/master 3b3a6e6e6 -> 763bf1712


CAMEL-8642 Merged the patch into camel-http4


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

Branch: refs/heads/master
Commit: cbeabcc70381c052cdbd6d298c27db533b607e64
Parents: 8bb4ad5
Author: Willem Jiang <wi...@gmail.com>
Authored: Fri Apr 17 10:55:28 2015 +0800
Committer: Willem Jiang <wi...@gmail.com>
Committed: Fri Apr 17 14:16:53 2015 +0800

----------------------------------------------------------------------
 .../component/http4/helper/HttpHelper.java      | 20 +++++++++++++++++++-
 1 file changed, 19 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/camel/blob/cbeabcc7/components/camel-http4/src/main/java/org/apache/camel/component/http4/helper/HttpHelper.java
----------------------------------------------------------------------
diff --git a/components/camel-http4/src/main/java/org/apache/camel/component/http4/helper/HttpHelper.java b/components/camel-http4/src/main/java/org/apache/camel/component/http4/helper/HttpHelper.java
index 5610d6a..448e64a 100644
--- a/components/camel-http4/src/main/java/org/apache/camel/component/http4/helper/HttpHelper.java
+++ b/components/camel-http4/src/main/java/org/apache/camel/component/http4/helper/HttpHelper.java
@@ -26,9 +26,11 @@ import java.net.URISyntaxException;
 import java.util.ArrayList;
 import java.util.List;
 import java.util.Map;
+
 import javax.servlet.ServletResponse;
 import javax.servlet.http.HttpServletRequest;
 
+import org.apache.camel.CamelContext;
 import org.apache.camel.Exchange;
 import org.apache.camel.Producer;
 import org.apache.camel.RuntimeExchangeException;
@@ -39,6 +41,7 @@ import org.apache.camel.component.http4.HttpMessage;
 import org.apache.camel.component.http4.HttpMethods;
 import org.apache.camel.component.http4.HttpServletUrlRewrite;
 import org.apache.camel.converter.stream.CachedOutputStream;
+import org.apache.camel.util.CamelObjectInputStream;
 import org.apache.camel.util.IOHelper;
 import org.apache.camel.util.ObjectHelper;
 import org.apache.camel.util.URISupport;
@@ -102,14 +105,29 @@ public final class HttpHelper {
      * @return the java object, or <tt>null</tt> if input stream was <tt>null</tt>
      * @throws ClassNotFoundException is thrown if class not found
      * @throws IOException can be thrown
+     * @deprecated Camel 3.0 
+     * Please use the one which has the parameter of camel context
      */
     public static Object deserializeJavaObjectFromStream(InputStream is) throws ClassNotFoundException, IOException {
+        return deserializeJavaObjectFromStream(is, null);
+    }
+    
+    /**
+     * Deserializes the input stream to a Java object
+     *
+     * @param is input stream for the Java object
+     * @param context the camel context which could help us to apply the customer classloader
+     * @return the java object, or <tt>null</tt> if input stream was <tt>null</tt>
+     * @throws ClassNotFoundException is thrown if class not found
+     * @throws IOException can be thrown
+     */
+    public static Object deserializeJavaObjectFromStream(InputStream is, CamelContext context) throws ClassNotFoundException, IOException {
         if (is == null) {
             return null;
         }
 
         Object answer = null;
-        ObjectInputStream ois = new ObjectInputStream(is);
+        ObjectInputStream ois = new CamelObjectInputStream(is, context);
         try {
             answer = ois.readObject();
         } finally {


[2/3] camel git commit: CAMEL-8642 Supports to use custom classloader when deserializeJavaObjectFromStream in HttpHelper

Posted by ni...@apache.org.
CAMEL-8642 Supports to use custom classloader when deserializeJavaObjectFromStream in HttpHelper


Project: http://git-wip-us.apache.org/repos/asf/camel/repo
Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/8bb4ad50
Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/8bb4ad50
Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/8bb4ad50

Branch: refs/heads/master
Commit: 8bb4ad505f3688e13369b37890ce372f7d0b4ae5
Parents: 3b3a6e6
Author: Willem Jiang <wi...@gmail.com>
Authored: Fri Apr 17 10:52:14 2015 +0800
Committer: Willem Jiang <wi...@gmail.com>
Committed: Fri Apr 17 14:16:53 2015 +0800

----------------------------------------------------------------------
 .../camel/util/CamelObjectInputStream.java      | 46 ++++++++++++++++++++
 .../component/http/DefaultHttpBinding.java      |  2 +-
 .../camel/component/http/HttpProducer.java      |  2 +-
 .../camel/component/http/helper/HttpHelper.java | 20 ++++++++-
 .../jetty/DefaultJettyHttpBinding.java          |  2 +-
 5 files changed, 68 insertions(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/camel/blob/8bb4ad50/camel-core/src/main/java/org/apache/camel/util/CamelObjectInputStream.java
----------------------------------------------------------------------
diff --git a/camel-core/src/main/java/org/apache/camel/util/CamelObjectInputStream.java b/camel-core/src/main/java/org/apache/camel/util/CamelObjectInputStream.java
new file mode 100644
index 0000000..a5cc591
--- /dev/null
+++ b/camel-core/src/main/java/org/apache/camel/util/CamelObjectInputStream.java
@@ -0,0 +1,46 @@
+/**
+ * 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.util;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.ObjectInputStream;
+import java.io.ObjectStreamClass;
+
+import org.apache.camel.CamelContext;
+
+public class CamelObjectInputStream extends ObjectInputStream {
+    private final ClassLoader classLoader;
+    
+    public CamelObjectInputStream(InputStream in, CamelContext context) throws IOException {
+        super(in);
+        if (context != null) {
+            this.classLoader = context.getApplicationContextClassLoader();
+        } else {
+            this.classLoader = null;
+        }
+    }
+    
+    protected Class<?> resolveClass(ObjectStreamClass desc) throws ClassNotFoundException, IOException {
+        if (classLoader != null) {
+            return Class.forName(desc.getName(), false, classLoader);
+        } else {
+            // If the application classloader is not set we just fallback to use old behaivor
+            return super.resolveClass(desc);
+        }
+    }
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/camel/blob/8bb4ad50/components/camel-http/src/main/java/org/apache/camel/component/http/DefaultHttpBinding.java
----------------------------------------------------------------------
diff --git a/components/camel-http/src/main/java/org/apache/camel/component/http/DefaultHttpBinding.java b/components/camel-http/src/main/java/org/apache/camel/component/http/DefaultHttpBinding.java
index 651c2ac..e1fa34e 100644
--- a/components/camel-http/src/main/java/org/apache/camel/component/http/DefaultHttpBinding.java
+++ b/components/camel-http/src/main/java/org/apache/camel/component/http/DefaultHttpBinding.java
@@ -138,7 +138,7 @@ public class DefaultHttpBinding implements HttpBinding {
         if (request.getContentType() != null && HttpConstants.CONTENT_TYPE_JAVA_SERIALIZED_OBJECT.equals(request.getContentType())) {
             try {
                 InputStream is = endpoint.getCamelContext().getTypeConverter().mandatoryConvertTo(InputStream.class, body);
-                Object object = HttpHelper.deserializeJavaObjectFromStream(is);
+                Object object = HttpHelper.deserializeJavaObjectFromStream(is, message.getExchange().getContext());
                 if (object != null) {
                     message.setBody(object);
                 }

http://git-wip-us.apache.org/repos/asf/camel/blob/8bb4ad50/components/camel-http/src/main/java/org/apache/camel/component/http/HttpProducer.java
----------------------------------------------------------------------
diff --git a/components/camel-http/src/main/java/org/apache/camel/component/http/HttpProducer.java b/components/camel-http/src/main/java/org/apache/camel/component/http/HttpProducer.java
index 9774118..0269ee4 100644
--- a/components/camel-http/src/main/java/org/apache/camel/component/http/HttpProducer.java
+++ b/components/camel-http/src/main/java/org/apache/camel/component/http/HttpProducer.java
@@ -294,7 +294,7 @@ public class HttpProducer extends DefaultProducer {
         InputStream response = doExtractResponseBodyAsStream(is, exchange);
         // if content type is a serialized java object then de-serialize it back to a Java object
         if (contentType != null && contentType.equals(HttpConstants.CONTENT_TYPE_JAVA_SERIALIZED_OBJECT)) {
-            return HttpHelper.deserializeJavaObjectFromStream(response);
+            return HttpHelper.deserializeJavaObjectFromStream(response, exchange.getContext());
         } else {
             return response;
         }

http://git-wip-us.apache.org/repos/asf/camel/blob/8bb4ad50/components/camel-http/src/main/java/org/apache/camel/component/http/helper/HttpHelper.java
----------------------------------------------------------------------
diff --git a/components/camel-http/src/main/java/org/apache/camel/component/http/helper/HttpHelper.java b/components/camel-http/src/main/java/org/apache/camel/component/http/helper/HttpHelper.java
index dade973..36374a2 100644
--- a/components/camel-http/src/main/java/org/apache/camel/component/http/helper/HttpHelper.java
+++ b/components/camel-http/src/main/java/org/apache/camel/component/http/helper/HttpHelper.java
@@ -26,9 +26,11 @@ import java.net.URISyntaxException;
 import java.util.ArrayList;
 import java.util.List;
 import java.util.Map;
+
 import javax.servlet.ServletResponse;
 import javax.servlet.http.HttpServletRequest;
 
+import org.apache.camel.CamelContext;
 import org.apache.camel.Exchange;
 import org.apache.camel.Producer;
 import org.apache.camel.RuntimeExchangeException;
@@ -40,6 +42,7 @@ import org.apache.camel.component.http.HttpMethods;
 import org.apache.camel.component.http.HttpServletUrlRewrite;
 import org.apache.camel.converter.IOConverter;
 import org.apache.camel.converter.stream.CachedOutputStream;
+import org.apache.camel.util.CamelObjectInputStream;
 import org.apache.camel.util.IOHelper;
 import org.apache.camel.util.ObjectHelper;
 import org.apache.camel.util.URISupport;
@@ -118,14 +121,29 @@ public final class HttpHelper {
      * @return the java object, or <tt>null</tt> if input stream was <tt>null</tt>
      * @throws ClassNotFoundException is thrown if class not found
      * @throws IOException can be thrown
+     * @deprecated Camel 3.0 
+     * Please use the one which has the parameter of camel context
      */
     public static Object deserializeJavaObjectFromStream(InputStream is) throws ClassNotFoundException, IOException {
+        return deserializeJavaObjectFromStream(is, null);
+    }
+    
+    /**
+     * Deserializes the input stream to a Java object
+     *
+     * @param is input stream for the Java object
+     * @param context the camel context which could help us to apply the customer classloader
+     * @return the java object, or <tt>null</tt> if input stream was <tt>null</tt>
+     * @throws ClassNotFoundException is thrown if class not found
+     * @throws IOException can be thrown
+     */
+    public static Object deserializeJavaObjectFromStream(InputStream is, CamelContext context) throws ClassNotFoundException, IOException {
         if (is == null) {
             return null;
         }
 
         Object answer = null;
-        ObjectInputStream ois = new ObjectInputStream(is);
+        ObjectInputStream ois = new CamelObjectInputStream(is, context);
         try {
             answer = ois.readObject();
         } finally {

http://git-wip-us.apache.org/repos/asf/camel/blob/8bb4ad50/components/camel-jetty-common/src/main/java/org/apache/camel/component/jetty/DefaultJettyHttpBinding.java
----------------------------------------------------------------------
diff --git a/components/camel-jetty-common/src/main/java/org/apache/camel/component/jetty/DefaultJettyHttpBinding.java b/components/camel-jetty-common/src/main/java/org/apache/camel/component/jetty/DefaultJettyHttpBinding.java
index 8c55d3e..dabafd5 100644
--- a/components/camel-jetty-common/src/main/java/org/apache/camel/component/jetty/DefaultJettyHttpBinding.java
+++ b/components/camel-jetty-common/src/main/java/org/apache/camel/component/jetty/DefaultJettyHttpBinding.java
@@ -172,7 +172,7 @@ public class DefaultJettyHttpBinding implements JettyHttpBinding {
         if (contentType != null && HttpConstants.CONTENT_TYPE_JAVA_SERIALIZED_OBJECT.equals(contentType)) {
             try {
                 InputStream is = exchange.getContext().getTypeConverter().mandatoryConvertTo(InputStream.class, httpExchange.getResponseContentBytes());
-                return HttpHelper.deserializeJavaObjectFromStream(is);
+                return HttpHelper.deserializeJavaObjectFromStream(is, exchange.getContext());
             } catch (Exception e) {
                 throw new RuntimeCamelException("Cannot deserialize body to Java object", e);
             }


[3/3] camel git commit: CAMEL-8614 Added olingo2 and linkedin artifacts into the kit

Posted by ni...@apache.org.
CAMEL-8614 Added olingo2 and linkedin artifacts into the kit


Project: http://git-wip-us.apache.org/repos/asf/camel/repo
Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/763bf171
Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/763bf171
Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/763bf171

Branch: refs/heads/master
Commit: 763bf1712552a6ff0eb1efa8b4eae2095330bfcd
Parents: cbeabcc
Author: Willem Jiang <wi...@gmail.com>
Authored: Fri Apr 17 14:16:05 2015 +0800
Committer: Willem Jiang <wi...@gmail.com>
Committed: Fri Apr 17 14:19:35 2015 +0800

----------------------------------------------------------------------
 apache-camel/src/main/descriptors/common-bin.xml | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/camel/blob/763bf171/apache-camel/src/main/descriptors/common-bin.xml
----------------------------------------------------------------------
diff --git a/apache-camel/src/main/descriptors/common-bin.xml b/apache-camel/src/main/descriptors/common-bin.xml
index add72b8..a4776da 100644
--- a/apache-camel/src/main/descriptors/common-bin.xml
+++ b/apache-camel/src/main/descriptors/common-bin.xml
@@ -127,8 +127,8 @@
         <include>org.apache.camel:camel-kura</include>
         <include>org.apache.camel:camel-ldap</include>
         <include>org.apache.camel:camel-leveldb</include>
-        <include>org.apache.camel.camel-linkedin-api</include>
-        <include>org.apache.camel.camel-linkedin</include>
+        <include>org.apache.camel:camel-linkedin-api</include>
+        <include>org.apache.camel:camel-linkedin</include>
         <include>org.apache.camel:camel-lucene</include>
         <include>org.apache.camel:camel-metrics</include>
         <include>org.apache.camel:camel-mail</include>
@@ -146,8 +146,8 @@
         <include>org.apache.camel:camel-netty-http</include>
         <include>org.apache.camel:camel-netty4-http</include>
         <include>org.apache.camel:camel-ognl</include>
-        <include>org.apache.camel.camel-olingo2-api</include>
-        <include>org.apache.camel.camel-olingo2</include>
+        <include>org.apache.camel:camel-olingo2-api</include>
+        <include>org.apache.camel:camel-olingo2</include>
         <include>org.apache.camel:camel-openshift</include>
         <include>org.apache.camel:camel-optaplanner</include>
         <include>org.apache.camel:camel-paho</include>