Skip to content

Commit

Permalink
Use constructor injection
Browse files Browse the repository at this point in the history
  • Loading branch information
ebussieres committed May 4, 2020
1 parent 61921ed commit a4f12aa
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.context.MessageSource;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Import;
Expand All @@ -33,8 +34,8 @@ public Loader<?> pebbleLoader(PebbleProperties properties) {

@Bean
@ConditionalOnMissingBean
public SpringExtension pebbleSpringExtension() {
return new SpringExtension();
public SpringExtension pebbleSpringExtension(MessageSource messageSource) {
return new SpringExtension(messageSource);
}

@Bean
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
import org.springframework.boot.test.util.TestPropertyValues;
import org.springframework.boot.web.reactive.context.AnnotationConfigReactiveWebApplicationContext;
import org.springframework.boot.web.servlet.context.AnnotationConfigServletWebApplicationContext;
import org.springframework.context.MessageSource;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Import;
Expand Down Expand Up @@ -101,8 +102,8 @@ public PebbleEngine pebbleEngine() {
}

@Bean
public SpringExtension customSpringExtension() {
return new SpringExtension();
public SpringExtension customSpringExtension(MessageSource messageSource) {
return new SpringExtension(messageSource);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
import com.mitchellbosecke.pebble.spring.extension.function.bindingresult.HasGlobalErrorsFunction;
import java.util.HashMap;
import java.util.Map;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.MessageSource;

/**
Expand All @@ -30,8 +29,11 @@
*/
public class SpringExtension extends AbstractExtension {

@Autowired
private MessageSource messageSource;
private final MessageSource messageSource;

public SpringExtension(MessageSource messageSource) {
this.messageSource = messageSource;
}

@Override
public Map<String, Function> getFunctions() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
import com.mitchellbosecke.pebble.spring.bean.SomeBean;
import com.mitchellbosecke.pebble.spring.extension.SpringExtension;
import com.mitchellbosecke.pebble.spring.servlet.PebbleViewResolver;

import org.springframework.context.MessageSource;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
Expand Down Expand Up @@ -51,8 +50,8 @@ public PebbleEngine pebbleEngine(SpringExtension springExtension,
}

@Bean
public SpringExtension springExtension() {
return new SpringExtension();
public SpringExtension springExtension(MessageSource messageSource) {
return new SpringExtension(messageSource);
}

@Bean
Expand Down

0 comments on commit a4f12aa

Please sign in to comment.