use of org.neo4j.graphdb.config.ScopeAwareSetting in project neo4j by neo4j.
the class Settings method advertisedAddress.
public static BaseSetting<AdvertisedSocketAddress> advertisedAddress(String name, Setting<ListenSocketAddress> listenAddressSetting) {
return new ScopeAwareSetting<AdvertisedSocketAddress>() {
@Override
protected String provideName() {
return name;
}
@Override
public String getDefaultValue() {
return default_advertised_address.getDefaultValue() + ":" + LISTEN_SOCKET_ADDRESS.apply(listenAddressSetting.getDefaultValue()).socketAddress().getPort();
}
@Override
public AdvertisedSocketAddress from(Configuration config) {
return config.get(this);
}
@Override
public AdvertisedSocketAddress apply(Function<String, String> config) {
ListenSocketAddress listenSocketAddress = listenAddressSetting.apply(config);
String hostname = default_advertised_address.apply(config);
int port = listenSocketAddress.socketAddress().getPort();
String name = name();
String value = config.apply(name);
return SocketAddressFormat.socketAddress(name, value, hostname, port, AdvertisedSocketAddress::new);
}
@Override
public void withScope(Function<String, String> scopingRule) {
super.withScope(scopingRule);
listenAddressSetting.withScope(scopingRule);
}
@Override
public String valueDescription() {
return ADVERTISED_SOCKET_ADDRESS.toString();
}
};
}
use of org.neo4j.graphdb.config.ScopeAwareSetting in project neo4j by neo4j.
the class Settings method pathSetting.
public static Setting<File> pathSetting(String name, String defaultValue) {
return new ScopeAwareSetting<File>() {
@Override
protected String provideName() {
return name;
}
@Override
public String getDefaultValue() {
return defaultValue;
}
@Override
public File from(Configuration config) {
return config.get(this);
}
@Override
public File apply(Function<String, String> config) {
String value = config.apply(name());
if (value == null) {
value = defaultValue;
}
if (value == null) {
return null;
}
String setting = fixSeparatorsInPath(value);
File settingFile = new File(setting);
if (settingFile.isAbsolute()) {
return settingFile;
} else {
return new File(GraphDatabaseSettings.neo4j_home.apply(config), setting);
}
}
@Override
public String valueDescription() {
return "A filesystem path; relative paths are resolved against the installation root, _<neo4j-home>_";
}
};
}
Aggregations