com.sap.cloud.yaas.servicesdk.springboot.jersey.PingFeatureAutoConfiguration Maven / Gradle / Ivy
/*
* © 2017 SAP SE or an SAP affiliate company.
* All rights reserved.
* Please see http://www.sap.com/corporate-en/legal/copyright/index.epx for additional trademark information and
* notices.
*/
package com.sap.cloud.yaas.servicesdk.springboot.jersey;
import javax.ws.rs.core.Feature;
import com.sap.cloud.yaas.servicesdk.ping.PingFeature;
import org.glassfish.jersey.server.ResourceConfig;
import org.springframework.boot.autoconfigure.AutoConfigureAfter;
import org.springframework.boot.autoconfigure.AutoConfigureBefore;
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.boot.autoconfigure.condition.ConditionalOnWebApplication;
import org.springframework.boot.autoconfigure.jersey.JerseyAutoConfiguration;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
/**
* Configures ping endpoint (the simplest possible diagnostics).
*/
@Configuration
@ConditionalOnWebApplication
@ConditionalOnClass(ResourceConfig.class)
@ConditionalOnMissingBean(ResourceConfig.class)
@AutoConfigureAfter(JsonFeatureAutoConfiguration.class)
@AutoConfigureBefore(JerseyAutoConfiguration.class)
public class PingFeatureAutoConfiguration
{
/**
* Registers the Jersey {@link PingFeature}.
*
* @return the Jersey {@link PingFeature}
*/
@Bean
@ConditionalOnClass(PingFeature.class)
@ConditionalOnMissingBean(PingFeature.class)
@ConditionalOnProperty(prefix = "yaas.service.jersey", name = "enable-ping-resource", matchIfMissing = true)
public Feature pingFeature()
{
return new PingFeature();
}
}