#164 Set Dandelion active profile to "prod" when Spring production profile is enabled

This commit is contained in:
Antoine Rey 2016-06-25 15:27:37 +02:00
parent 4da41dbbda
commit 1f42b7615d

View file

@ -19,11 +19,16 @@ package org.springframework.samples.petclinic.config;
import com.github.dandelion.core.web.DandelionFilter;
import com.github.dandelion.core.web.DandelionServlet;
import com.github.dandelion.datatables.core.web.filter.DatatablesFilter;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.context.embedded.FilterRegistrationBean;
import org.springframework.boot.context.embedded.ServletRegistrationBean;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Description;
import org.springframework.context.annotation.Profile;
import org.springframework.core.env.Environment;
import javax.annotation.PostConstruct;
/**
* Java configuration for the Dandelion datatables component.
@ -33,6 +38,16 @@ import org.springframework.context.annotation.Description;
@Configuration
public class DandelionConfig {
@Autowired
private Environment environment;
@PostConstruct
public void init() {
if (environment.acceptsProfiles("production")) {
System.setProperty("dandelion.profile.active", "prod");
}
}
@Bean
@Description("Dandelion filter definition and mapping")
public FilterRegistrationBean filterRegistrationBean() {