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/03/26 09:44:53 UTC
[09/11] camel git commit: CAMEL-8547 Polish the code to avoid
breaking the API
CAMEL-8547 Polish the code to avoid breaking the API
Project: http://git-wip-us.apache.org/repos/asf/camel/repo
Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/35a87e6b
Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/35a87e6b
Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/35a87e6b
Branch: refs/heads/camel-2.14.x
Commit: 35a87e6b31797019d242d10ac8a996e213e59219
Parents: 611781c
Author: Willem Jiang <wi...@gmail.com>
Authored: Thu Mar 26 16:41:06 2015 +0800
Committer: Willem Jiang <wi...@gmail.com>
Committed: Thu Mar 26 16:43:52 2015 +0800
----------------------------------------------------------------------
.../converter/xmlbeans/XmlBeansConverter.java | 84 +++++++++++++++++---
1 file changed, 72 insertions(+), 12 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/camel/blob/35a87e6b/components/camel-xmlbeans/src/main/java/org/apache/camel/converter/xmlbeans/XmlBeansConverter.java
----------------------------------------------------------------------
diff --git a/components/camel-xmlbeans/src/main/java/org/apache/camel/converter/xmlbeans/XmlBeansConverter.java b/components/camel-xmlbeans/src/main/java/org/apache/camel/converter/xmlbeans/XmlBeansConverter.java
index 5b1b011..4239c09 100644
--- a/components/camel-xmlbeans/src/main/java/org/apache/camel/converter/xmlbeans/XmlBeansConverter.java
+++ b/components/camel-xmlbeans/src/main/java/org/apache/camel/converter/xmlbeans/XmlBeansConverter.java
@@ -44,12 +44,62 @@ public final class XmlBeansConverter {
private XmlBeansConverter() {
}
+ @Deprecated
+ // It will be removed in Camel 2.16.0, please use the one with Exchange parameter
+ public static XmlObject toXmlObject(File value) throws IOException, XmlException {
+ return toXmlObject(value, null);
+ }
+
+ @Deprecated
+ // It will be removed in Camel 2.16.0, please use the one with Exchange parameter
+ public static XmlObject toXmlObject(Reader value) throws IOException, XmlException {
+ return toXmlObject(value, null);
+ }
+
+ @Deprecated
+ // It will be removed in Camel 2.16.0, please use the one with Exchange parameter
+ public static XmlObject toXmlObject(Node value) throws IOException, XmlException {
+ return toXmlObject(value, null);
+ }
+
+ @Deprecated
+ // It will be removed in Camel 2.16.0, please use the one with Exchange parameter
+ public static XmlObject toXmlObject(InputStream value) throws IOException, XmlException {
+ return toXmlObject(value, null);
+ }
+
+ @Deprecated
+ // It will be removed in Camel 2.16.0, please use the one with Exchange parameter
+ public static XmlObject toXmlObject(String value) throws IOException, XmlException {
+ return toXmlObject(value, null);
+ }
+
+ @Deprecated
+ // It will be removed in Camel 2.16.0, please use the one with Exchange parameter
+ public static XmlObject toXmlObject(byte[] value) throws IOException, XmlException {
+ return toXmlObject(value, null);
+ }
+
+ @Deprecated
+ // It will be removed in Camel 2.16.0, please use the one with Exchange parameter
+ public static XmlObject toXmlObject(ByteBuffer value) throws IOException, XmlException {
+ return toXmlObject(value, null);
+ }
+
+ @Deprecated
+ // It will be removed in Camel 2.16.0, please use the one with Exchange parameter
+ public static XmlObject toXmlObject(XMLStreamReader value) throws IOException, XmlException {
+ return toXmlObject(value, null);
+ }
+
@Converter
public static XmlObject toXmlObject(File value, Exchange exchange) throws IOException, XmlException {
ClassLoader tccl = Thread.currentThread().getContextClassLoader();
-
try {
- ClassLoader apcl = exchange.getContext().getApplicationContextClassLoader();
+ ClassLoader apcl = null;
+ if (exchange != null && exchange.getContext() != null) {
+ apcl = exchange.getContext().getApplicationContextClassLoader();
+ }
if (apcl != null) {
Thread.currentThread().setContextClassLoader(apcl);
}
@@ -64,9 +114,11 @@ public final class XmlBeansConverter {
@Converter
public static XmlObject toXmlObject(Reader value, Exchange exchange) throws IOException, XmlException {
ClassLoader tccl = Thread.currentThread().getContextClassLoader();
-
try {
- ClassLoader apcl = exchange.getContext().getApplicationContextClassLoader();
+ ClassLoader apcl = null;
+ if (exchange != null && exchange.getContext() != null) {
+ apcl = exchange.getContext().getApplicationContextClassLoader();
+ }
if (apcl != null) {
Thread.currentThread().setContextClassLoader(apcl);
}
@@ -81,9 +133,11 @@ public final class XmlBeansConverter {
@Converter
public static XmlObject toXmlObject(Node value, Exchange exchange) throws IOException, XmlException {
ClassLoader tccl = Thread.currentThread().getContextClassLoader();
-
try {
- ClassLoader apcl = exchange.getContext().getApplicationContextClassLoader();
+ ClassLoader apcl = null;
+ if (exchange != null && exchange.getContext() != null) {
+ apcl = exchange.getContext().getApplicationContextClassLoader();
+ }
if (apcl != null) {
Thread.currentThread().setContextClassLoader(apcl);
}
@@ -98,9 +152,11 @@ public final class XmlBeansConverter {
@Converter
public static XmlObject toXmlObject(InputStream value, Exchange exchange) throws IOException, XmlException {
ClassLoader tccl = Thread.currentThread().getContextClassLoader();
-
try {
- ClassLoader apcl = exchange.getContext().getApplicationContextClassLoader();
+ ClassLoader apcl = null;
+ if (exchange != null && exchange.getContext() != null) {
+ apcl = exchange.getContext().getApplicationContextClassLoader();
+ }
if (apcl != null) {
Thread.currentThread().setContextClassLoader(apcl);
}
@@ -130,9 +186,11 @@ public final class XmlBeansConverter {
@Converter
public static XmlObject toXmlObject(XMLStreamReader value, Exchange exchange) throws IOException, XmlException {
ClassLoader tccl = Thread.currentThread().getContextClassLoader();
-
try {
- ClassLoader apcl = exchange.getContext().getApplicationContextClassLoader();
+ ClassLoader apcl = null;
+ if (exchange != null && exchange.getContext() != null) {
+ apcl = exchange.getContext().getApplicationContextClassLoader();
+ }
if (apcl != null) {
Thread.currentThread().setContextClassLoader(apcl);
}
@@ -148,9 +206,11 @@ public final class XmlBeansConverter {
public static XmlObject toXmlObject(Source value, Exchange exchange) throws IOException, XmlException, NoTypeConversionAvailableException {
Reader reader = exchange.getContext().getTypeConverter().mandatoryConvertTo(Reader.class, value);
ClassLoader tccl = Thread.currentThread().getContextClassLoader();
-
try {
- ClassLoader apcl = exchange.getContext().getApplicationContextClassLoader();
+ ClassLoader apcl = null;
+ if (exchange != null && exchange.getContext() != null) {
+ apcl = exchange.getContext().getApplicationContextClassLoader();
+ }
if (apcl != null) {
Thread.currentThread().setContextClassLoader(apcl);
}