-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathAtomicAwareNodeBlockingServiceFactoryAutoConfiguration.kt
75 lines (68 loc) · 3.4 KB
/
AtomicAwareNodeBlockingServiceFactoryAutoConfiguration.kt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
package com.wavesenterprise.sdk.spring.autoconfigure.atomic
import com.wavesenterprise.sdk.atomic.AtomicAwareNodeBlockingServiceFactory
import com.wavesenterprise.sdk.atomic.AtomicBroadcaster
import com.wavesenterprise.sdk.atomic.cache.contract.info.ThreadLocalContractInfoCacheManager
import com.wavesenterprise.sdk.atomic.manager.AtomicAwareContextManager
import com.wavesenterprise.sdk.atomic.manager.AtomicAwareContextManagerHook
import com.wavesenterprise.sdk.atomic.manager.ContractInfoCacheContextManagerHook
import com.wavesenterprise.sdk.atomic.manager.ContractInfoCacheManager
import com.wavesenterprise.sdk.atomic.manager.ThreadLocalAtomicAwareContextManagerWithHook
import com.wavesenterprise.sdk.node.client.blocking.node.NodeBlockingServiceFactory
import com.wavesenterprise.sdk.spring.autoconfigure.node.NodeBlockingServiceFactoryAutoConfiguration
import com.wavesenterprise.sdk.spring.autoconfigure.node.service.NodeServicesAutoConfiguration
import com.wavesenterprise.sdk.tx.signer.TxSigner
import org.springframework.boot.autoconfigure.AutoConfigureAfter
import org.springframework.boot.autoconfigure.AutoConfigureBefore
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass
import org.springframework.context.ApplicationContext
import org.springframework.context.annotation.Bean
import org.springframework.context.annotation.Configuration
import org.springframework.context.annotation.EnableAspectJAutoProxy
@Configuration
@ConditionalOnClass(
NodeBlockingServiceFactory::class,
AtomicAwareNodeBlockingServiceFactory::class,
)
@EnableAspectJAutoProxy
@AutoConfigureAfter(NodeBlockingServiceFactoryAutoConfiguration::class)
@AutoConfigureBefore(NodeServicesAutoConfiguration::class)
class AtomicAwareNodeBlockingServiceFactoryAutoConfiguration {
@Bean
fun contractInfoCacheManager(): ContractInfoCacheManager = ThreadLocalContractInfoCacheManager()
@Bean
fun atomicAwareContextManagerHook(
contractInfoCacheManager: ContractInfoCacheManager,
): AtomicAwareContextManagerHook =
ContractInfoCacheContextManagerHook(
contractInfoCacheManager = contractInfoCacheManager,
)
@Bean
fun atomicAwareContextManager(
atomicAwareContextManagerHook: AtomicAwareContextManagerHook,
): AtomicAwareContextManager =
ThreadLocalAtomicAwareContextManagerWithHook(
atomicAwareContextManagerHook = atomicAwareContextManagerHook,
)
@Bean
fun atomicBroadcaster(
atomicAwareContextManager: AtomicAwareContextManager,
txSigner: TxSigner,
atomicAwareNodeBlockingServiceFactory: NodeBlockingServiceFactory,
): AtomicBroadcaster =
AtomicBroadcaster(
atomicAwareContextManager = atomicAwareContextManager,
txSigner = txSigner,
atomicAwareNodeBlockingServiceFactory = atomicAwareNodeBlockingServiceFactory,
)
@Bean
fun atomicAwareNodeBlockingServiceFactoryPostProcessor(
applicationContext: ApplicationContext,
contractInfoCacheManager: ContractInfoCacheManager,
atomicAwareContextManager: AtomicAwareContextManager,
): AtomicAwareNodeBlockingServiceFactoryPostProcessor =
AtomicAwareNodeBlockingServiceFactoryPostProcessor(
applicationContext = applicationContext,
contractInfoCacheManager = contractInfoCacheManager,
atomicAwareContextManager = atomicAwareContextManager,
)
}