-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
use SpringData Aerospike beans directly instead of duplicating them
- Loading branch information
Showing
16 changed files
with
365 additions
and
503 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
78 changes: 78 additions & 0 deletions
78
...n/java/org/springframework/boot/autoconfigure/aerospike/AerospikeClientConfiguration.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
/* | ||
* Copyright 2019 the original author or 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 org.springframework.boot.autoconfigure.aerospike; | ||
|
||
import com.aerospike.client.AerospikeClient; | ||
import com.aerospike.client.Host; | ||
import com.aerospike.client.IAerospikeClient; | ||
import com.aerospike.client.async.EventLoops; | ||
import com.aerospike.client.policy.ClientPolicy; | ||
import com.aerospike.client.reactor.AerospikeReactorClient; | ||
import com.aerospike.client.reactor.IAerospikeReactorClient; | ||
import lombok.extern.slf4j.Slf4j; | ||
import org.springframework.boot.autoconfigure.AutoConfiguration; | ||
import org.springframework.boot.autoconfigure.AutoConfigureAfter; | ||
import org.springframework.boot.autoconfigure.utils.NoNamespaceProperty; | ||
import org.springframework.boot.autoconfigure.EnableAutoConfiguration; | ||
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass; | ||
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean; | ||
import org.springframework.context.annotation.Bean; | ||
import org.springframework.context.annotation.Conditional; | ||
import reactor.core.publisher.Flux; | ||
|
||
import java.util.Optional; | ||
|
||
import static org.springframework.boot.autoconfigure.utils.AerospikeConfigurationUtils.getClientPolicyConfig; | ||
|
||
/** | ||
* {@link EnableAutoConfiguration Auto-configuration} for Aerospike client. | ||
* Loaded only when no namespace property is given. | ||
* | ||
* @author Anastasiia Smirnova | ||
*/ | ||
@AutoConfiguration | ||
@Conditional(NoNamespaceProperty.class) | ||
@AutoConfigureAfter({AerospikeAutoConfiguration.class}) | ||
@Slf4j | ||
public class AerospikeClientConfiguration { | ||
|
||
@Bean(name = "aerospikeClient", destroyMethod = "close") | ||
@ConditionalOnMissingBean(IAerospikeClient.class) | ||
public IAerospikeClient aerospikeClient(AerospikeProperties properties, | ||
ClientPolicy aerospikeClientPolicy) { | ||
log.info("Initializing only Aerospike Java client due to no namespace property given"); | ||
Host[] hosts = Host.parseHosts(properties.getHosts(), properties.getDefaultPort()); | ||
return new AerospikeClient(aerospikeClientPolicy, hosts); | ||
} | ||
|
||
|
||
@ConditionalOnClass({IAerospikeReactorClient.class, Flux.class}) | ||
public static class AerospikeReactiveAutoConfiguration { | ||
|
||
@Bean(name = "aerospikeReactorClient", destroyMethod = "") | ||
@ConditionalOnMissingBean | ||
// disable destroy method, because we do not want AerospikeReactorClient to close AerospikeClient | ||
public IAerospikeReactorClient aerospikeReactorClient(IAerospikeClient aerospikeClient) { | ||
return new AerospikeReactorClient(aerospikeClient); | ||
} | ||
} | ||
|
||
@ConditionalOnMissingBean | ||
public ClientPolicy aerospikeClientPolicy(AerospikeProperties properties) { | ||
return getClientPolicyConfig(new ClientPolicy(), properties); | ||
} | ||
} |
150 changes: 0 additions & 150 deletions
150
...g/springframework/boot/autoconfigure/data/aerospike/AerospikeCommonDataConfiguration.java
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.