Example usage for org.springframework.vault.core.util PropertyTransformer andThen

List of usage examples for org.springframework.vault.core.util PropertyTransformer andThen

Introduction

In this page you can find the example usage for org.springframework.vault.core.util PropertyTransformer andThen.

Prototype

default PropertyTransformer andThen(PropertyTransformer after) 

Source Link

Document

Return a composed transformer function that first applies this filter, and then applies the after transformer.

Usage

From source file:org.springframework.vault.core.env.LeaseAwareVaultPropertySource.java

/**
 * Create a new {@link LeaseAwareVaultPropertySource} given a {@code name},
 * {@link SecretLeaseContainer} and {@link RequestedSecret}. This property source
 * requests the secret upon initialization and receives secrets once they are emitted
 * through events published by {@link SecretLeaseContainer}.
 *
 * @param name name of the property source, must not be {@literal null}.
 * @param secretLeaseContainer must not be {@literal null}.
 * @param requestedSecret must not be {@literal null}.
 * @param propertyTransformer object to transform properties.
 * @see PropertyTransformers//from   w  w  w .  j  av  a2s . co m
 */
public LeaseAwareVaultPropertySource(String name, SecretLeaseContainer secretLeaseContainer,
        RequestedSecret requestedSecret, PropertyTransformer propertyTransformer) {

    super(name);

    Assert.notNull(secretLeaseContainer, "Path name must contain at least one character");
    Assert.notNull(requestedSecret, "SecretLeaseContainer must not be null");
    Assert.notNull(propertyTransformer, "PropertyTransformer must not be null");

    this.secretLeaseContainer = secretLeaseContainer;
    this.requestedSecret = requestedSecret;
    this.propertyTransformer = propertyTransformer.andThen(PropertyTransformers.removeNullProperties());
    this.leaseListener = new LeaseListenerAdapter() {
        @Override
        public void onLeaseEvent(SecretLeaseEvent leaseEvent) {
            handleLeaseEvent(leaseEvent, LeaseAwareVaultPropertySource.this.properties);
        }
    };

    loadProperties();
}