use of org.neo4j.graphdb.config.BaseSetting in project neo4j by neo4j.
the class BoltConnectorValidator method getSettingFor.
@Override
@Nonnull
protected Optional<Setting<Object>> getSettingFor(@Nonnull String settingName, @Nonnull Map<String, String> params) {
// owns has already verified that 'type' is correct and that this split is possible
String[] parts = settingName.split("\\.");
final String name = parts[2];
final String subsetting = parts[3];
BaseSetting setting;
switch(subsetting) {
case "enabled":
setting = setting(settingName, BOOLEAN, "false");
setting.setDescription("Enable this connector.");
break;
case "type":
setting = setting(settingName, options(Connector.ConnectorType.class), NO_DEFAULT);
setting.setDeprecated(true);
setting.setDescription("Connector type. This setting is deprecated and its value will instead be " + "inferred from the name of the connector.");
break;
case "tls_level":
setting = setting(settingName, options(BoltConnector.EncryptionLevel.class), OPTIONAL.name());
setting.setDescription("Encryption level to require this connector to use.");
break;
case "address":
setting = listenAddress(settingName, 7687);
setting.setDeprecated(true);
setting.setReplacement("dbms.connector." + name + ".listen_address");
setting.setDescription("Address the connector should bind to. Deprecated and replaced by " + setting.replacement().get() + ".");
break;
case "listen_address":
setting = listenAddress(settingName, 7687);
setting.setDescription("Address the connector should bind to.");
break;
case "advertised_address":
setting = advertisedAddress(settingName, listenAddress(settingName, 7687));
setting.setDescription("Advertised address for this connector.");
break;
default:
return Optional.empty();
}
// If not deprecated for other reasons
if (isDeprecatedConnectorName(name) && !setting.deprecated()) {
setting.setDeprecated(true);
setting.setReplacement(format("%s.%s.%s.%s", parts[0], parts[1], "bolt", subsetting));
}
return Optional.of(setting);
}
use of org.neo4j.graphdb.config.BaseSetting in project neo4j by neo4j.
the class HttpConnectorValidator method getSettingFor.
@Override
@Nonnull
protected Optional<Setting<Object>> getSettingFor(@Nonnull String settingName, @Nonnull Map<String, String> params) {
// owns has already verified that 'type' is correct and that this split is possible
String[] parts = settingName.split("\\.");
final String name = parts[2];
final String subsetting = parts[3];
final boolean encrypted = encryptionSetting(name).apply(params::get).equals(Encryption.TLS);
BaseSetting setting;
switch(subsetting) {
case "enabled":
setting = setting(settingName, BOOLEAN, "false");
setting.setDescription("Enable this connector.");
break;
case "type":
setting = setting(settingName, options(Connector.ConnectorType.class), NO_DEFAULT);
setting.setDeprecated(true);
setting.setDescription("Connector type. This setting is deprecated and its value will instead be " + "inferred from the name of the connector.");
break;
case "encryption":
setting = encryptionSetting(name);
setting.setDescription("Enable TLS for this connector.");
break;
case "address":
setting = listenAddress(settingName, defaultPort(name, params));
setting.setDeprecated(true);
setting.setReplacement("dbms.connector." + name + ".listen_address");
setting.setDescription("Address the connector should bind to. Deprecated and replaced by " + setting.replacement().get() + ".");
break;
case "listen_address":
setting = listenAddress(settingName, defaultPort(name, params));
setting.setDescription("Address the connector should bind to.");
break;
case "advertised_address":
setting = advertisedAddress(settingName, listenAddress(settingName, defaultPort(name, params)));
setting.setDescription("Advertised address for this connector.");
break;
default:
return Optional.empty();
}
// If not deprecated for other reasons
if (isDeprecatedConnectorName(name) && !setting.deprecated()) {
setting.setDeprecated(true);
setting.setReplacement(format("%s.%s.%s.%s", parts[0], parts[1], encrypted ? "https" : "http", subsetting));
}
return Optional.of(setting);
}
use of org.neo4j.graphdb.config.BaseSetting in project neo4j by neo4j.
the class LoadableConfig method getConfigOptions.
/**
* Collects settings from implementors which may or may not have descriptions attached to them.
*
* @return a list of the implementing class's ConfigOptions
*/
default default List<ConfigOptions> getConfigOptions() {
ArrayList<ConfigOptions> configOptions = new ArrayList<>();
for (Field f : getClass().getDeclaredFields()) {
try {
Object publicSetting = f.get(this);
if (publicSetting instanceof BaseSetting) {
BaseSetting setting = (BaseSetting) publicSetting;
final Description documentation = f.getAnnotation(Description.class);
if (documentation != null) {
setting.setDescription(documentation.value());
}
final DocumentedDefaultValue defValue = f.getAnnotation(DocumentedDefaultValue.class);
if (defValue != null) {
setting.setDocumentedDefaultValue(defValue.value());
}
final Deprecated deprecatedAnnotation = f.getAnnotation(Deprecated.class);
setting.setDeprecated(deprecatedAnnotation != null);
final ReplacedBy replacedByAnnotation = f.getAnnotation(ReplacedBy.class);
if (replacedByAnnotation != null) {
setting.setReplacement(replacedByAnnotation.value());
}
final Internal internalAnnotation = f.getAnnotation(Internal.class);
setting.setInternal(internalAnnotation != null);
}
if (publicSetting instanceof SettingGroup) {
SettingGroup setting = (SettingGroup) publicSetting;
configOptions.add(new ConfigOptions(setting));
}
} catch (IllegalAccessException ignored) {
// Field is private, ignore it
continue;
}
}
return configOptions;
}
Aggregations