<commit_before>/**
 * Copyright (c) 2016 Red Hat
 *
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v1.0
 * which accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/epl-v10.html
 *
 * Contributors:
 *    <NAME> - initial creation
 */

package org.eclipse.hono.adapter;

import io.vertx.core.Vertx;
import org.eclipse.hono.config.HonoClientConfigProperties;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.annotation.Bean;

/**
 * Minimum configuration for protocol adapters
 */
public abstract class AdapterConfig {

    private final Vertx vertx = Vertx.vertx();

    @Bean
    public Vertx getVertx() {
        return vertx;
    }

    @ConfigurationProperties(prefix = "hono.client")
    @Bean
    public HonoClientConfigProperties honoClientConfig() {
        return new HonoClientConfigProperties();
    }
}
<commit_msg>Provide means to programmatically customize client config.<commit_after>/**
 * Copyright (c) 2016 Red Hat
 *
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v1.0
 * which accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/epl-v10.html
 *
 * Contributors:
 *    <NAME> - initial creation
 */

package org.eclipse.hono.adapter;

import org.eclipse.hono.config.HonoClientConfigProperties;
import org.eclipse.hono.connection.ConnectionFactory;
import org.eclipse.hono.connection.ConnectionFactoryImpl;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.annotation.Bean;

import io.vertx.core.Vertx;

/**
 * Minimum configuration for protocol adapters
 */
public abstract class AdapterConfig {

    private final Vertx vertx = Vertx.vertx();

    /**
     * Exposes a Vert.x instance as a Spring bean.
     * 
     * @return The Vert.x instance.
     */
    @Bean
    public Vertx getVertx() {
        return vertx;
    }

    /**
     * Exposes client configuration properties as a Spring bean.
     * 
     * @return The properties.
     */
    @ConfigurationProperties(prefix = "hono.client")
    @Bean
    public HonoClientConfigProperties honoClientConfig() {
        HonoClientConfigProperties config = new HonoClientConfigProperties();
        customizeClientConfigProperties(config);
        return config;
    }

    /**
     * Further customizes the client properties provided by the {@link #honoClientConfig()}
     * method.
     * <p>
     * This method does nothing by default. Subclasses may override this method to set additional
     * properties programmatically.
     * 
     * @param config The client configuration to customize.
     */
    protected void customizeClientConfigProperties(final HonoClientConfigProperties config) {
        // empty by default
    }

    /**
     * Exposes a factory for connections to the Hono server
     * as a Spring bean.
     * 
     * @return The connection factory.
     */
    @Bean
    public ConnectionFactory honoConnectionFactory() {
        return new ConnectionFactoryImpl();
    }
}

{'fraction_non_alphanumeric': 0.0856259659969088, 'fraction_numerical': 0.004945904173106646, 'mean_word_length': 3.2635046113306982, 'pattern_counts': {'":': 0, '<': 6, '<?xml version=': 0, '>': 6, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2767836', 'n_tokens_mistral': 877, 'n_tokens_neox': 842, 'n_words': 262}