All Downloads are FREE. Search and download functionalities are using the official Maven repository.

net.guerlab.spring.commons.autoconfigure.EndpointResponseAdvisorPropertiesAutoconfigure Maven / Gradle / Ivy

There is a newer version: 2.1.5
Show newest version
package net.guerlab.spring.commons.autoconfigure;

import java.util.ArrayList;
import java.util.List;

import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.actuate.autoconfigure.endpoint.web.WebEndpointProperties;
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
import org.springframework.context.annotation.Configuration;

import net.guerlab.spring.commons.properties.ResponseAdvisorProperties;

/**
 * @author guer
 *
 */
@Configuration
@ConditionalOnClass(WebEndpointProperties.class)
public class EndpointResponseAdvisorPropertiesAutoconfigure {

    @Autowired
    public void advisor(WebEndpointProperties webEndpointProperties,
            ResponseAdvisorProperties responseAdvisorProperties) {
        String basePath = webEndpointProperties.getBasePath();

        if (StringUtils.isBlank(basePath)) {
            return;
        }

        List excluded = responseAdvisorProperties.getExcluded();

        List list = excluded == null ? new ArrayList<>() : new ArrayList<>(excluded);
        list.add(basePath);

        responseAdvisorProperties.setExcluded(list);
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy