/playaway

Demo app for migrating Java Play app to Spring MVC app with some legacy components around

Primary LanguageJava

What is this?

This is a demo application that serves as an executable guideline for migrating a large-ish service written in "Play for Java" framework to a traditional servlet-based Spring MVC service.

Components

Domain

Non-Functional

Un-Spring way

Would we write an app like this had we started with Spring MVC straight away? No. But we have a bunch of existing components and we need to mitigate the risks of this migration as much as we can. Therefore we're carrying over some styles/components that are not typically seen in Spring MVC applications:

  • Guardians instead of Controller Advices
    • manual aspects guarding path variables and query parameters
  • Preconditions instead of Controller Advices and/or auto-binding
    • @ModelAttribute-like advices are substituted with PreconditionsAction
  • Manual validation instead of @Valid
    • @Valid and custom validators are possible (and possibly preferred for the future usages), but this demo also supports manual payload preconditions and JSON request to POJO binding

Play-only concepts and their replacements

  • Actions @With(FooAction.class) are replaced with Controller Advices, see ErrorHandler for example
  • application.conf is replaced with application.yml
  • ctx() (hidden behind HttpContext) are replaced by Spring-first binding (@RequestHeader, @RequestParam etc.) or adapted using RequestContextHolder (for storing request-only data)