Class BlockchainAutoConfiguration
This class is the single assembly point for all blockchain Spring beans,
mirroring the non-Spring assembly model in BlockchainConfig but
adapting it to dependency injection (FR-CFG-01, FR-CFG-03).
Activation
Active by default. Disable completely with:
blockchain:
enabled: false
Zero-configuration start (AC-10)
No blockchain.* properties required. Defaults:
ProofOfWorkEngine (difficulty 4) + InMemoryStorage.
Override points (T-072)
Every bean is guarded by @ConditionalOnMissingBean. Provide any
of the following in your @Configuration to replace the default:
BlockchainNode— replaces the entire nodeConsensusEngine— replacesProofOfWorkEngineBlockchainStorage— replacesInMemoryStorageBlockchainHealthIndicator— replaces the status bean
Multiple validators and listeners
All TransactionValidator and BlockchainEventListener beans
are discovered and registered automatically in declaration order.
Node lifecycle
The BlockchainNode bean uses initMethod = "start" and
destroyMethod = "stop". Spring calls start() after all beans
are wired and stop() on context close.
Actuator integration
BlockchainHealthIndicator is a plain status-provider bean with no
compile-time dependency on spring-boot-actuator. To wire it into the
Actuator health endpoint, add this to your @Configuration:
@Bean
HealthIndicator blockchainHealth(BlockchainHealthIndicator indicator) {
return () -> indicator.isUp()
? Health.up().withDetails(indicator.getDetails()).build()
: Health.down().withDetails(indicator.getDetails()).build();
}
- Since:
- 1.0.0
- See Also:
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionCreates theBlockchainHealthIndicatorstatus bean.blockchainNode(BlockchainProperties properties, org.springframework.beans.factory.ObjectProvider<ConsensusEngine> engineProvider, org.springframework.beans.factory.ObjectProvider<BlockchainStorage> storageProvider, org.springframework.beans.factory.ObjectProvider<TransactionValidator> validatorProvider, org.springframework.beans.factory.ObjectProvider<BlockchainEventListener> listenerProvider) Creates and wires theBlockchainNodebean from bound properties and any user-provided override beans (T-070, T-072).
-
Constructor Details
-
BlockchainAutoConfiguration
public BlockchainAutoConfiguration()
-
-
Method Details
-
blockchainNode
@Bean(initMethod="start", destroyMethod="stop") @ConditionalOnMissingBean public BlockchainNode blockchainNode(BlockchainProperties properties, org.springframework.beans.factory.ObjectProvider<ConsensusEngine> engineProvider, org.springframework.beans.factory.ObjectProvider<BlockchainStorage> storageProvider, org.springframework.beans.factory.ObjectProvider<TransactionValidator> validatorProvider, org.springframework.beans.factory.ObjectProvider<BlockchainEventListener> listenerProvider) Creates and wires theBlockchainNodebean from bound properties and any user-provided override beans (T-070, T-072).Dependency resolution order
ConsensusEngine— user bean if present; elseProofOfWorkEnginewith configured difficulty.BlockchainStorage— user bean if present; elseInMemoryStorage(ephemeral, for dev/demo).TransactionValidator— all beans, chained in order (FR-TX-03).BlockchainEventListener— all beans, registered in order (FR-EVENT-02).
The node is not started here. Spring calls
start()viainitMethodafter all beans are fully wired.- Parameters:
properties- boundblockchain.*propertiesengineProvider- optionalConsensusEngineoverridestorageProvider- optionalBlockchainStorageoverridevalidatorProvider- zero or moreTransactionValidatorbeanslistenerProvider- zero or moreBlockchainEventListenerbeans- Returns:
- configured, not-yet-started
BlockchainNode
-
blockchainHealthIndicator
@Bean @ConditionalOnMissingBean public BlockchainHealthIndicator blockchainHealthIndicator(BlockchainNode node) Creates theBlockchainHealthIndicatorstatus bean.This is a plain POJO — it does not implement
spring-boot-actuator'sHealthIndicatorinterface, keeping this module free of a mandatory Actuator dependency. SeeBlockchainHealthIndicatorfor instructions on bridging it to Actuator's health endpoint (T-070).Guarded by
@ConditionalOnMissingBeanso applications can replace it without touching library sources (T-072).- Parameters:
node- the autoconfigured or user-providedBlockchainNode- Returns:
- status provider for the running node
-