/*
 * Copyright 2017-2020 original authors
 *
 * Licensed 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
 *
 * https://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 io.micronaut.discovery.config;

import io.micronaut.core.util.Toggleable;

import java.util.Optional;

Abstract class for common configuration discovery settings.
Author:graemerocher
Since:1.0
/** * Abstract class for common configuration discovery settings. * * @author graemerocher * @since 1.0 */
public abstract class ConfigDiscoveryConfiguration implements Toggleable {
The prefix to use for all Consul client config settings.
/** * The prefix to use for all Consul client config settings. */
public static final String PREFIX = "config";
The default path.
/** * The default path. */
public static final String DEFAULT_PATH = PREFIX + "/";
The default enable value.
/** * The default enable value. */
@SuppressWarnings("WeakerAccess") public static final boolean DEFAULT_ENABLED = true; private boolean enabled = DEFAULT_ENABLED; private String path; private Format format = Format.NATIVE;
Returns:Is distributed configuration enabled. True if it is.
/** * @return Is distributed configuration enabled. True if it is. */
@Override public boolean isEnabled() { return enabled; }
Default value (true).
Params:
  • enabled – Enable the distributed configuration
/** * Default value ({@value #DEFAULT_ENABLED}). * @param enabled Enable the distributed configuration */
public void setEnabled(boolean enabled) { this.enabled = enabled; }
Returns:The path where the configuration is stored
/** * @return The path where the configuration is stored */
public Optional<String> getPath() { return Optional.ofNullable(path); }
Params:
  • path – The path to store the configuration
/** * @param path The path to store the configuration */
public void setPath(String path) { this.path = path; }
Returns:The configuration format
/** * @return The configuration format */
public Format getFormat() { return format; }
Params:
  • format – The configuration format
/** * @param format The configuration format */
public void setFormat(Format format) { if (format != null) { this.format = format; } }
The format the configuration is stored in.
/** * The format the configuration is stored in. */
public enum Format {
Stored in YAML format.
/** * Stored in YAML format. */
YAML,
Stored in JSON format.
/** * Stored in JSON format. */
JSON,
Stored in Java properties file format.
/** * Stored in Java properties file format. */
PROPERTIES,
Stored in the native format provided by the configuration server.
/** * Stored in the native format provided by the configuration server. */
NATIVE,
Each value in the configuration server represents the name of a file and the contents of the file. Useful when using solutions such as git2consul.
/** * Each value in the configuration server represents the name of a file and the contents of the file. * Useful when using solutions such as git2consul. */
FILE } }