Migrating from Spring framework to Play framework (Scala)

John Mullins

I have always used Spring framework (3.x) in my projects, using such features as:

  • security: Spring security API
  • persistence: Hibernate (auto-generate/update database scheme)
  • full text search: Hibernate Search (based on Apache Lucene)
  • IOC: Spring dependency injections

I want to migrate some of my previous projects to Play framework. Recently I've started studying Scala language along with Play framework 2.x. And I want to use the same features as before. For database I'm going to use Slick library.

Could you advise me what to use for security and full text search?

Esko

Migration to new technology is always a bumpy road, so don't expect the first thing you try to work for you - might be you need to implement something yourself. I'll get to this with a specific example in a bit.

First, Scala means scalable, not integratable. That is, if you choose to code anything in Scala, keep in mind that frameworks meant for automating things in Java mostly do not work on the Scala side. ORM is a very good example of this since Scala methods are not always exactly Java methods, so the metadata will end up in incorrect places and you'll end up having corrupt data. So the general pointer is that if you go with Scala, you really can't look into the Java ecosystem for helpers unless the helpers are completely isolated from language semantics.


Security

Assuming you took full advantage of Spring Security, you were using role-based access control. If you go with Java, you actually should be able to use Spring Security which definitely helps you with the migration and saves time writing more code. All you really need is a Spring container in your Play app and thankfully others have already solved that: Integrating Play framework 2.0 and Spring framework

On Scala side RBAC seems to be a civilized fight about semantics betwen RBAC and ACL with no clear winner. This is problematic since it seems like no one's actually working on one which means you may have to roll your own.

Persistence

With Java you should be able to use Hibernate/any JPA solution since it's not tied to a web container. Play also comes with EBeans but from what I've observed it can't be used for the most exotic use cases. Might be you'll never hit those though so it's worth trying out since it's already there.

On Scala side, as you already thought, Slick should be alright.

Full text search

Search is a really complex thing so I'd actually setup standalone Solr/ElasticSearch and integrate to its APIs instead of embed it to the app itself, no matter what language or framework is being used.

IOC

Latest Play just about supports Guice, Scala itself tries to enforce the cake pattern. Spring should be possible with the container integration linked earlier.

I hope someone else actually has good insights to comment on this because the way Play is built, especially on the Java side seems to be very IOC hostile.

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

Play Framework: Problems migrating from version 2.3.x to 2.4.1

From Dev

Calling into Play framework app from the Scala console

From Dev

Play framework in Scala deployment

From Dev

Play Framework Scala Template

From Dev

Database tuning performance from play framework in play scala project

From Dev

Use Scala templates from Play! framework in scala.js

From Dev

Use Scala templates from Play! framework in scala.js

From Dev

Use of @Singleton in Scala play framework

From Dev

Depedency injection framework of Play and Scala?

From Dev

Firebase and Play Framework (Scala) is it possible?

From Dev

Scala Play Framework - Dynamic Forms

From Dev

Scala parameter to Java (Play Framework)

From Dev

Scala backticks in Play Framework Routes

From Dev

Nested requests with Scala and play Framework

From Dev

Firebase and Play Framework (Scala) is it possible?

From Dev

Scala Dependency Injection in Play Framework

From Dev

Play! Framework Scala Form Submitbutton

From Dev

scala play framework json conversion

From Dev

Play Framework [2.2-scala]: creating Enumerator from a slow InputStream

From Dev

Add <script> to the <head> from scala template tags in Play Framework 2

From Dev

Serving static page from custom scala action in Play Framework

From Dev

Play Framework trouble importing scala template from different package

From Dev

Play Framework [2.2-scala]: creating Enumerator from a slow InputStream

From Dev

Play FrameWork / scala - return a streamed response from an Array[Byte]

From Dev

Unit Test controllers in Play 2 framework with Scala

From Dev

Composing `Future` result in Play Framework with Scala

From Dev

Scala Play framework beginner - 'Action Not Found'

From Dev

Loading an arbitrary file in the Play Framework 2 (Scala)

From Dev

Read JSON Tree structure in Scala Play Framework

Related Related

  1. 1

    Play Framework: Problems migrating from version 2.3.x to 2.4.1

  2. 2

    Calling into Play framework app from the Scala console

  3. 3

    Play framework in Scala deployment

  4. 4

    Play Framework Scala Template

  5. 5

    Database tuning performance from play framework in play scala project

  6. 6

    Use Scala templates from Play! framework in scala.js

  7. 7

    Use Scala templates from Play! framework in scala.js

  8. 8

    Use of @Singleton in Scala play framework

  9. 9

    Depedency injection framework of Play and Scala?

  10. 10

    Firebase and Play Framework (Scala) is it possible?

  11. 11

    Scala Play Framework - Dynamic Forms

  12. 12

    Scala parameter to Java (Play Framework)

  13. 13

    Scala backticks in Play Framework Routes

  14. 14

    Nested requests with Scala and play Framework

  15. 15

    Firebase and Play Framework (Scala) is it possible?

  16. 16

    Scala Dependency Injection in Play Framework

  17. 17

    Play! Framework Scala Form Submitbutton

  18. 18

    scala play framework json conversion

  19. 19

    Play Framework [2.2-scala]: creating Enumerator from a slow InputStream

  20. 20

    Add <script> to the <head> from scala template tags in Play Framework 2

  21. 21

    Serving static page from custom scala action in Play Framework

  22. 22

    Play Framework trouble importing scala template from different package

  23. 23

    Play Framework [2.2-scala]: creating Enumerator from a slow InputStream

  24. 24

    Play FrameWork / scala - return a streamed response from an Array[Byte]

  25. 25

    Unit Test controllers in Play 2 framework with Scala

  26. 26

    Composing `Future` result in Play Framework with Scala

  27. 27

    Scala Play framework beginner - 'Action Not Found'

  28. 28

    Loading an arbitrary file in the Play Framework 2 (Scala)

  29. 29

    Read JSON Tree structure in Scala Play Framework

HotTag

Archive