Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,14 @@ public class AerospikeConnectionSettings {
// Storing hosts
Host[] hostsArray;

String user;
String password;

public AerospikeConnectionSettings(Environment environment) {
if (environment != null) {
setStringFromConfig(this::setHosts, environment, CONFIG_PREFIX_CONNECTION, "hosts");
setStringFromConfig(this::setUser, environment, CONFIG_PREFIX_CONNECTION, "user");
setStringFromConfig(this::setPassword, environment, CONFIG_PREFIX_CONNECTION, "password");
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.config.BeanDefinition;
import org.springframework.context.EnvironmentAware;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.ClassPathScanningCandidateComponentProvider;
import org.springframework.context.annotation.Configuration;
Expand Down Expand Up @@ -77,12 +78,19 @@
*/
@Slf4j
@Configuration
public abstract class AerospikeDataConfigurationSupport {
public abstract class AerospikeDataConfigurationSupport implements EnvironmentAware {

public static final String CONFIG_PREFIX = "spring";
public static final String CONFIG_PREFIX_DATA = CONFIG_PREFIX + ".data.aerospike";
public static final String CONFIG_PREFIX_CONNECTION = CONFIG_PREFIX + ".aerospike";

protected Environment environment;

@Override
public void setEnvironment(Environment environment) {
this.environment = environment;
}

@Bean(name = "aerospikeQueryContextBuilder")
public QueryContextBuilder queryContextBuilder(IndexesCache indexesCache) {
return new QueryContextBuilder(indexesCache);
Expand Down Expand Up @@ -293,6 +301,10 @@ protected ClientPolicy getClientPolicy() {
clientPolicy.queryPolicyDefault.sendKey = sendKey;
clientPolicy.scanPolicyDefault.sendKey = sendKey;
clientPolicy.eventLoops = eventLoops();

AerospikeConnectionSettings aerospikeConnectionSettings = readAerospikeSettings(this.environment);
clientPolicy.setUser(aerospikeConnectionSettings.getUser());
clientPolicy.setPassword(aerospikeConnectionSettings.getPassword());
return clientPolicy;
}

Expand Down
Loading