From d42548457059e61dda94db9cb214db7e5463d371 Mon Sep 17 00:00:00 2001 From: DOHA Date: Mon, 30 Mar 2015 13:30:00 +0200 Subject: [PATCH] fix boot configurations --- .../src/main/java/org/baeldung/spring/SecSecurityConfig.java | 2 ++ .../src/main/java/org/baeldung/web/metric/MetricFilter.java | 5 +++++ 2 files changed, 7 insertions(+) diff --git a/spring-security-rest-full/src/main/java/org/baeldung/spring/SecSecurityConfig.java b/spring-security-rest-full/src/main/java/org/baeldung/spring/SecSecurityConfig.java index 4da114c78b..acf5ff6be5 100644 --- a/spring-security-rest-full/src/main/java/org/baeldung/spring/SecSecurityConfig.java +++ b/spring-security-rest-full/src/main/java/org/baeldung/spring/SecSecurityConfig.java @@ -1,9 +1,11 @@ package org.baeldung.spring; +import org.springframework.boot.autoconfigure.EnableAutoConfiguration; import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.ImportResource; @Configuration +@EnableAutoConfiguration @ImportResource({ "classpath:webSecurityConfig.xml" }) public class SecSecurityConfig { diff --git a/spring-security-rest-full/src/main/java/org/baeldung/web/metric/MetricFilter.java b/spring-security-rest-full/src/main/java/org/baeldung/web/metric/MetricFilter.java index f892aa4ffe..06665f820b 100644 --- a/spring-security-rest-full/src/main/java/org/baeldung/web/metric/MetricFilter.java +++ b/spring-security-rest-full/src/main/java/org/baeldung/web/metric/MetricFilter.java @@ -11,6 +11,7 @@ import javax.servlet.http.HttpServletResponse; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; +import org.springframework.web.context.support.WebApplicationContextUtils; @Component public class MetricFilter implements Filter { @@ -23,6 +24,10 @@ public class MetricFilter implements Filter { @Override public void init(final FilterConfig config) throws ServletException { + if (metricService == null || actMetricService == null) { + metricService = (IMetricService) WebApplicationContextUtils.getRequiredWebApplicationContext(config.getServletContext()).getBean("metricService"); + actMetricService = (IActuatorMetricService) WebApplicationContextUtils.getRequiredWebApplicationContext(config.getServletContext()).getBean("actuatorMetricService"); + } } @Override