Updated Branches: refs/heads/master 9843f2a36 -> 97de5839c
fixed compiler error Project: http://git-wip-us.apache.org/repos/asf/camel/repo Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/97de5839 Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/97de5839 Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/97de5839 Branch: refs/heads/master Commit: 97de5839c89a87b4d768f46b9719778d0898d53b Parents: 9843f2a Author: cmueller <cmuel...@apache.org> Authored: Sun Oct 6 22:12:21 2013 +0200 Committer: cmueller <cmuel...@apache.org> Committed: Sun Oct 6 22:12:21 2013 +0200 ---------------------------------------------------------------------- .../org/apache/camel/jsonpath/JSonPath.java | 40 ----------- .../apache/camel/jsonpath/JSonPathEngine.java | 70 -------------------- .../org/apache/camel/jsonpath/JsonPath.java | 40 +++++++++++ .../apache/camel/jsonpath/JsonPathEngine.java | 70 ++++++++++++++++++++ 4 files changed, 110 insertions(+), 110 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/camel/blob/97de5839/components/camel-jsonpath/src/main/java/org/apache/camel/jsonpath/JSonPath.java ---------------------------------------------------------------------- diff --git a/components/camel-jsonpath/src/main/java/org/apache/camel/jsonpath/JSonPath.java b/components/camel-jsonpath/src/main/java/org/apache/camel/jsonpath/JSonPath.java deleted file mode 100644 index 354875c..0000000 --- a/components/camel-jsonpath/src/main/java/org/apache/camel/jsonpath/JSonPath.java +++ /dev/null @@ -1,40 +0,0 @@ -/** - * 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.jsonpath; - -import java.lang.annotation.Documented; -import java.lang.annotation.ElementType; -import java.lang.annotation.Retention; -import java.lang.annotation.RetentionPolicy; -import java.lang.annotation.Target; - -import org.apache.camel.language.LanguageAnnotation; - -/** - * An annotation used to inject a <a href="http://commons.apache.org/jsonpath/">JSon Path</a> - * expression into a method parameter when using - * <a href="http://camel.apache.org/bean-integration.html">Bean Integration</a> - * - * @version - */ -@Retention(RetentionPolicy.RUNTIME) -@Documented -@Target({ElementType.FIELD, ElementType.METHOD, ElementType.PARAMETER }) -@LanguageAnnotation(language = "jsonpath") -public @interface JsonPath { - String value(); -} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/camel/blob/97de5839/components/camel-jsonpath/src/main/java/org/apache/camel/jsonpath/JSonPathEngine.java ---------------------------------------------------------------------- diff --git a/components/camel-jsonpath/src/main/java/org/apache/camel/jsonpath/JSonPathEngine.java b/components/camel-jsonpath/src/main/java/org/apache/camel/jsonpath/JSonPathEngine.java deleted file mode 100644 index 4724199..0000000 --- a/components/camel-jsonpath/src/main/java/org/apache/camel/jsonpath/JSonPathEngine.java +++ /dev/null @@ -1,70 +0,0 @@ -/** - * 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.jsonpath; - -import java.io.File; -import java.io.IOException; -import java.io.InputStream; -import java.net.URL; - -import com.jayway.jsonpath.Configuration; -import com.jayway.jsonpath.JsonPath; -import org.apache.camel.Exchange; -import org.apache.camel.InvalidPayloadException; -import org.apache.camel.WrappedFile; - -public class JsonPathEngine { - - private final String expression; - private final JsonPath path; - private final Configuration configuration; - - public JsonPathEngine(String expression) { - this.expression = expression; - this.configuration = Configuration.defaultConfiguration(); - this.path = JsonPath.compile(expression); - } - - public Object read(Exchange exchange) throws IOException, InvalidPayloadException { - Object json = exchange.getIn().getBody(); - - if (json instanceof WrappedFile) { - json = ((WrappedFile) json).getFile(); - } - - // the message body type should use the suitable read method - if (configuration.getProvider().isContainer(json)) { - return path.read(json); - } else if (json instanceof String) { - String str = (String) json; - return path.read(str); - } else if (json instanceof InputStream) { - InputStream is = (InputStream) json; - return path.read(is); - } else if (json instanceof File) { - File file = (File) json; - return path.read(file); - } else if (json instanceof URL) { - URL url = (URL) json; - return path.read(url); - } - - // fallback as input stream - InputStream is = exchange.getIn().getMandatoryBody(InputStream.class); - return path.read(is); - } -} http://git-wip-us.apache.org/repos/asf/camel/blob/97de5839/components/camel-jsonpath/src/main/java/org/apache/camel/jsonpath/JsonPath.java ---------------------------------------------------------------------- diff --git a/components/camel-jsonpath/src/main/java/org/apache/camel/jsonpath/JsonPath.java b/components/camel-jsonpath/src/main/java/org/apache/camel/jsonpath/JsonPath.java new file mode 100644 index 0000000..354875c --- /dev/null +++ b/components/camel-jsonpath/src/main/java/org/apache/camel/jsonpath/JsonPath.java @@ -0,0 +1,40 @@ +/** + * 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.jsonpath; + +import java.lang.annotation.Documented; +import java.lang.annotation.ElementType; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; + +import org.apache.camel.language.LanguageAnnotation; + +/** + * An annotation used to inject a <a href="http://commons.apache.org/jsonpath/">JSon Path</a> + * expression into a method parameter when using + * <a href="http://camel.apache.org/bean-integration.html">Bean Integration</a> + * + * @version + */ +@Retention(RetentionPolicy.RUNTIME) +@Documented +@Target({ElementType.FIELD, ElementType.METHOD, ElementType.PARAMETER }) +@LanguageAnnotation(language = "jsonpath") +public @interface JsonPath { + String value(); +} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/camel/blob/97de5839/components/camel-jsonpath/src/main/java/org/apache/camel/jsonpath/JsonPathEngine.java ---------------------------------------------------------------------- diff --git a/components/camel-jsonpath/src/main/java/org/apache/camel/jsonpath/JsonPathEngine.java b/components/camel-jsonpath/src/main/java/org/apache/camel/jsonpath/JsonPathEngine.java new file mode 100644 index 0000000..4724199 --- /dev/null +++ b/components/camel-jsonpath/src/main/java/org/apache/camel/jsonpath/JsonPathEngine.java @@ -0,0 +1,70 @@ +/** + * 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.jsonpath; + +import java.io.File; +import java.io.IOException; +import java.io.InputStream; +import java.net.URL; + +import com.jayway.jsonpath.Configuration; +import com.jayway.jsonpath.JsonPath; +import org.apache.camel.Exchange; +import org.apache.camel.InvalidPayloadException; +import org.apache.camel.WrappedFile; + +public class JsonPathEngine { + + private final String expression; + private final JsonPath path; + private final Configuration configuration; + + public JsonPathEngine(String expression) { + this.expression = expression; + this.configuration = Configuration.defaultConfiguration(); + this.path = JsonPath.compile(expression); + } + + public Object read(Exchange exchange) throws IOException, InvalidPayloadException { + Object json = exchange.getIn().getBody(); + + if (json instanceof WrappedFile) { + json = ((WrappedFile) json).getFile(); + } + + // the message body type should use the suitable read method + if (configuration.getProvider().isContainer(json)) { + return path.read(json); + } else if (json instanceof String) { + String str = (String) json; + return path.read(str); + } else if (json instanceof InputStream) { + InputStream is = (InputStream) json; + return path.read(is); + } else if (json instanceof File) { + File file = (File) json; + return path.read(file); + } else if (json instanceof URL) { + URL url = (URL) json; + return path.read(url); + } + + // fallback as input stream + InputStream is = exchange.getIn().getMandatoryBody(InputStream.class); + return path.read(is); + } +}