001/*
002 * (C) Copyright 2006-2018 Nuxeo (http://nuxeo.com/) and others.
003 *
004 * Licensed under the Apache License, Version 2.0 (the "License");
005 * you may not use this file except in compliance with the License.
006 * You may obtain a copy of the License at
007 *
008 *     http://www.apache.org/licenses/LICENSE-2.0
009 *
010 * Unless required by applicable law or agreed to in writing, software
011 * distributed under the License is distributed on an "AS IS" BASIS,
012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
013 * See the License for the specific language governing permissions and
014 * limitations under the License.
015 *
016 *
017 * Contributors:
018 *     anechaev
019 */
020package org.nuxeo.runtime.kafka;
021
022import java.util.Properties;
023
024import org.nuxeo.common.xmap.annotation.XNode;
025import org.nuxeo.common.xmap.annotation.XNodeMap;
026import org.nuxeo.common.xmap.annotation.XObject;
027import org.nuxeo.runtime.model.Descriptor;
028
029@XObject("kafkaConfig")
030public class KafkaConfigDescriptor implements Descriptor {
031
032    @XObject("consumer")
033    public static class ConsumerProperties {
034        @XNodeMap(value = "property", key = "@name", type = Properties.class, componentType = String.class)
035        protected Properties properties = new Properties();
036    }
037
038    @XObject("producer")
039    public static class ProducerProperties {
040        @XNodeMap(value = "property", key = "@name", type = Properties.class, componentType = String.class)
041        protected Properties properties = new Properties();
042    }
043
044    // @since 11.1
045    @XObject("admin")
046    public static class AdminProperties {
047        @XNodeMap(value = "property", key = "@name", type = Properties.class, componentType = String.class)
048        protected Properties properties = new Properties();
049    }
050
051    @XNode("@name")
052    public String name;
053
054    @XNode("@zkServers")
055    public String zkServers;
056
057    @XNode("@topicPrefix")
058    public String topicPrefix;
059
060    @XNode("@randomPrefix")
061    public Boolean randomPrefix = Boolean.FALSE;
062
063    @XNode("producer")
064    public ProducerProperties producerProperties = new ProducerProperties();
065
066    @XNode("consumer")
067    public ConsumerProperties consumerProperties = new ConsumerProperties();
068
069    // @since 11.1
070    @XNode("admin")
071    public AdminProperties adminProperties = new AdminProperties();
072
073    @Override
074    public String getId() {
075        return name;
076    }
077
078}