From commits-return-72920-archive-asf-public=cust-asf.ponee.io@camel.apache.org Wed May 29 09:36:50 2019 Return-Path: X-Original-To: archive-asf-public@cust-asf.ponee.io Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [207.244.88.153]) by mx-eu-01.ponee.io (Postfix) with SMTP id E213018067E for ; Wed, 29 May 2019 11:36:49 +0200 (CEST) Received: (qmail 2627 invoked by uid 500); 29 May 2019 09:36:49 -0000 Mailing-List: contact commits-help@camel.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@camel.apache.org Delivered-To: mailing list commits@camel.apache.org Received: (qmail 2529 invoked by uid 99); 29 May 2019 09:36:49 -0000 Received: from ec2-52-202-80-70.compute-1.amazonaws.com (HELO gitbox.apache.org) (52.202.80.70) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 29 May 2019 09:36:49 +0000 Received: by gitbox.apache.org (ASF Mail Server at gitbox.apache.org, from userid 33) id 0AC488A311; Wed, 29 May 2019 09:36:49 +0000 (UTC) Date: Wed, 29 May 2019 09:36:50 +0000 To: "commits@camel.apache.org" Subject: [camel] 02/10: CAMEL-10324 - Camel-CBOR MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit From: acosentino@apache.org In-Reply-To: <155912260826.15097.11322657782825546453@gitbox.apache.org> References: <155912260826.15097.11322657782825546453@gitbox.apache.org> X-Git-Host: gitbox.apache.org X-Git-Repo: camel X-Git-Refname: refs/heads/master X-Git-Reftype: branch X-Git-Rev: 42f854843d71e3796f9be46ccdab0a19bdb7e0e7 X-Git-NotificationType: diff X-Git-Multimail-Version: 1.5.dev Auto-Submitted: auto-generated Message-Id: <20190529093649.0AC488A311@gitbox.apache.org> This is an automated email from the ASF dual-hosted git repository. acosentino pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/camel.git commit 42f854843d71e3796f9be46ccdab0a19bdb7e0e7 Author: Andrea Cosentino AuthorDate: Wed May 29 09:13:30 2019 +0200 CAMEL-10324 - Camel-CBOR --- apache-camel/pom.xml | 5 + apache-camel/src/main/descriptors/common-bin.xml | 2 + bom/camel-bom/pom.xml | 10 ++ components/pom.xml | 1 + .../camel/model/dataformat/CBORDataFormat.java | 126 +++++++++++++++++++++ 5 files changed, 144 insertions(+) diff --git a/apache-camel/pom.xml b/apache-camel/pom.xml index c1ec489..432ef61 100644 --- a/apache-camel/pom.xml +++ b/apache-camel/pom.xml @@ -338,6 +338,11 @@ org.apache.camel + camel-cbor + ${project.version} + + + org.apache.camel camel-cdi ${project.version} diff --git a/apache-camel/src/main/descriptors/common-bin.xml b/apache-camel/src/main/descriptors/common-bin.xml index 9e43763..d2edfd0 100644 --- a/apache-camel/src/main/descriptors/common-bin.xml +++ b/apache-camel/src/main/descriptors/common-bin.xml @@ -89,6 +89,7 @@ org.apache.camel:camel-browse org.apache.camel:camel-caffeine org.apache.camel:camel-cassandraql + org.apache.camel:camel-cbor org.apache.camel:camel-cdi org.apache.camel:camel-chatscript org.apache.camel:camel-chunk @@ -427,6 +428,7 @@ org.apache.camel:camel-browse-starter org.apache.camel:camel-caffeine-starter org.apache.camel:camel-cassandraql-starter + org.apache.camel:camel-cbor-starter org.apache.camel:camel-chatscript-starter org.apache.camel:camel-chunk-starter org.apache.camel:camel-cm-sms-starter diff --git a/bom/camel-bom/pom.xml b/bom/camel-bom/pom.xml index 0eaf5ef..4a1ed0b 100644 --- a/bom/camel-bom/pom.xml +++ b/bom/camel-bom/pom.xml @@ -538,6 +538,16 @@ org.apache.camel + camel-cbor + ${project.version} + + + org.apache.camel + camel-cbor-starter + ${project.version} + + + org.apache.camel camel-cdi ${project.version} diff --git a/components/pom.xml b/components/pom.xml index 61f2e74..d49c9b3 100644 --- a/components/pom.xml +++ b/components/pom.xml @@ -130,6 +130,7 @@ camel-braintree camel-caffeine camel-cassandraql + camel-cbor camel-cdi camel-chatscript camel-chunk diff --git a/core/camel-core/src/main/java/org/apache/camel/model/dataformat/CBORDataFormat.java b/core/camel-core/src/main/java/org/apache/camel/model/dataformat/CBORDataFormat.java new file mode 100644 index 0000000..01c1405 --- /dev/null +++ b/core/camel-core/src/main/java/org/apache/camel/model/dataformat/CBORDataFormat.java @@ -0,0 +1,126 @@ +/* + * 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.model.dataformat; + +import javax.xml.bind.annotation.XmlAccessType; +import javax.xml.bind.annotation.XmlAccessorType; +import javax.xml.bind.annotation.XmlAttribute; +import javax.xml.bind.annotation.XmlRootElement; +import javax.xml.bind.annotation.XmlTransient; + +import org.apache.camel.model.DataFormatDefinition; +import org.apache.camel.spi.Metadata; + +/** + * CBOR data format is used for unmarshal a CBOR payload to POJO or to marshal + * POJO back to CBOR payload. + */ +@Metadata(firstVersion = "3.0.0",label = "dataformat,transformation,json", title = "CBOR") +@XmlRootElement(name = "cbor") +@XmlAccessorType(XmlAccessType.FIELD) +public class CBORDataFormat extends DataFormatDefinition { + @XmlAttribute + private String objectMapper; + @XmlAttribute + @Metadata(defaultValue = "true") + private Boolean useDefaultObjectMapper; + @XmlTransient + private Class unmarshalType; + @XmlTransient + private Class collectionType; + @XmlAttribute + private Boolean useList; + @XmlAttribute + private Boolean allowUnmarshallType; + + public CBORDataFormat() { + super("cbor"); + } + + public String getObjectMapper() { + return objectMapper; + } + + /** + * Lookup and use the existing CBOR ObjectMapper with the given id when using + * Jackson. + */ + public void setObjectMapper(String objectMapper) { + this.objectMapper = objectMapper; + } + + public Boolean getUseDefaultObjectMapper() { + return useDefaultObjectMapper; + } + + /** + * Whether to lookup and use default Jackson CBOR ObjectMapper from the registry. + */ + public void setUseDefaultObjectMapper(Boolean useDefaultObjectMapper) { + this.useDefaultObjectMapper = useDefaultObjectMapper; + } + + public Class getUnmarshalType() { + return unmarshalType; + } + + /** + * Class of the java type to use when unarmshalling + */ + public void setUnmarshalType(Class unmarshalType) { + this.unmarshalType = unmarshalType; + } + + public Class getCollectionType() { + return collectionType; + } + + public void setCollectionType(Class collectionType) { + this.collectionType = collectionType; + } + + public Boolean getUseList() { + return useList; + } + + /** + * To unarmshal to a List of Map or a List of Pojo. + */ + public void setUseList(Boolean useList) { + this.useList = useList; + } + + public Boolean getAllowUnmarshallType() { + return allowUnmarshallType; + } + + /** + * If enabled then Jackson is allowed to attempt to use the + * CamelJacksonUnmarshalType header during the unmarshalling. + *

+ * This should only be enabled when desired to be used. + */ + public void setAllowUnmarshallType(Boolean allowUnmarshallType) { + this.allowUnmarshallType = allowUnmarshallType; + } + + @Override + public String getDataFormatName() { + return "cbor"; + } + +}