-
Notifications
You must be signed in to change notification settings - Fork 168
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add basic support for Spring 5 WebFlux reactive in Spring Boot 2 (#333)
1 parent
d74b2db
commit 4773093
Showing
32 changed files
with
622 additions
and
560 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
64 changes: 64 additions & 0 deletions
64
...g/pebble-spring-boot-starter/src/test/java/com/mitchellbosecke/pebble/boot/AppConfig.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
package com.mitchellbosecke.pebble.boot; | ||
|
||
import com.mitchellbosecke.pebble.extension.AbstractExtension; | ||
import com.mitchellbosecke.pebble.extension.Extension; | ||
import com.mitchellbosecke.pebble.extension.Function; | ||
import com.mitchellbosecke.pebble.template.EvaluationContext; | ||
import com.mitchellbosecke.pebble.template.PebbleTemplate; | ||
|
||
import org.springframework.context.MessageSource; | ||
import org.springframework.context.annotation.Bean; | ||
import org.springframework.context.annotation.Configuration; | ||
import org.springframework.context.support.ResourceBundleMessageSource; | ||
import org.springframework.web.servlet.LocaleResolver; | ||
import org.springframework.web.servlet.i18n.AcceptHeaderLocaleResolver; | ||
|
||
import java.util.Collections; | ||
import java.util.HashMap; | ||
import java.util.List; | ||
import java.util.Map; | ||
|
||
@Configuration(proxyBeanMethods = false) | ||
public class AppConfig { | ||
@Bean | ||
public MessageSource messageSource() { | ||
ResourceBundleMessageSource messageSource = new ResourceBundleMessageSource(); | ||
messageSource.setBasename("messages"); | ||
messageSource.setFallbackToSystemLocale(false); | ||
return messageSource; | ||
} | ||
|
||
@Bean | ||
public LocaleResolver localeResolver() { | ||
return new AcceptHeaderLocaleResolver(); | ||
} | ||
|
||
@Bean | ||
public Extension testExtension() { | ||
return new TestExtension(); | ||
} | ||
|
||
public static class TestExtension extends AbstractExtension { | ||
|
||
@Override | ||
public Map<String, Function> getFunctions() { | ||
Map<String, Function> functions = new HashMap<String, Function>(); | ||
functions.put("testFunction", new TestFunction()); | ||
return functions; | ||
} | ||
|
||
public static class TestFunction implements Function { | ||
|
||
@Override | ||
public List<String> getArgumentNames() { | ||
return Collections.emptyList(); | ||
} | ||
|
||
@Override | ||
public Object execute(Map<String, Object> args, PebbleTemplate self, | ||
EvaluationContext context, int lineNumber) { | ||
return "Tested!"; | ||
} | ||
} | ||
} | ||
} |
50 changes: 0 additions & 50 deletions
50
...pebble-spring-boot-starter/src/test/java/com/mitchellbosecke/pebble/boot/Application.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,62 +1,12 @@ | ||
package com.mitchellbosecke.pebble.boot; | ||
|
||
import com.mitchellbosecke.pebble.extension.AbstractExtension; | ||
import com.mitchellbosecke.pebble.extension.Extension; | ||
import com.mitchellbosecke.pebble.extension.Function; | ||
import com.mitchellbosecke.pebble.template.EvaluationContext; | ||
import com.mitchellbosecke.pebble.template.PebbleTemplate; | ||
import java.util.Collections; | ||
import java.util.HashMap; | ||
import java.util.List; | ||
import java.util.Map; | ||
import org.springframework.boot.SpringApplication; | ||
import org.springframework.boot.autoconfigure.SpringBootApplication; | ||
import org.springframework.context.MessageSource; | ||
import org.springframework.context.annotation.Bean; | ||
import org.springframework.context.support.ResourceBundleMessageSource; | ||
import org.springframework.web.servlet.LocaleResolver; | ||
import org.springframework.web.servlet.i18n.AcceptHeaderLocaleResolver; | ||
|
||
@SpringBootApplication | ||
@ServletComponentScan | ||
public class Application { | ||
|
||
public static void main(String[] args) { | ||
SpringApplication.run(Application.class, args); | ||
} | ||
|
||
@Bean | ||
public LocaleResolver localeResolver() { | ||
return new AcceptHeaderLocaleResolver(); | ||
} | ||
|
||
@Bean | ||
public Extension testExtension() { | ||
return new TestExtension(); | ||
} | ||
|
||
public static class TestExtension extends AbstractExtension { | ||
|
||
@Override | ||
public Map<String, Function> getFunctions() { | ||
Map<String, Function> functions = new HashMap<String, Function>(); | ||
functions.put("testFunction", new TestFunction()); | ||
return functions; | ||
} | ||
|
||
public static class TestFunction implements Function { | ||
|
||
@Override | ||
public List<String> getArgumentNames() { | ||
return Collections.emptyList(); | ||
} | ||
|
||
@Override | ||
public Object execute(Map<String, Object> args, PebbleTemplate self, | ||
EvaluationContext context, int lineNumber) { | ||
return "Tested!"; | ||
} | ||
} | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
16 changes: 16 additions & 0 deletions
16
...pring-boot-starter/src/test/java/com/mitchellbosecke/pebble/boot/ReactiveApplication.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
package com.mitchellbosecke.pebble.boot; | ||
|
||
import org.springframework.boot.SpringApplication; | ||
import org.springframework.boot.autoconfigure.SpringBootApplication; | ||
|
||
import static org.springframework.boot.WebApplicationType.REACTIVE; | ||
|
||
@SpringBootApplication | ||
public class ReactiveApplication { | ||
|
||
public static void main(String[] args) { | ||
SpringApplication application = new SpringApplication(Application.class); | ||
application.setWebApplicationType(REACTIVE); | ||
application.run(args); | ||
} | ||
} |
Oops, something went wrong.