This repository has been archived by the owner on Apr 14, 2022. It is now read-only.
Basic support for Cake pattern based configuration. #17
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Hi,
Some people complain that using type-scafe Scala with type-unsafe Spring dependency injection makes no sense. I personally disgaree with such statements, although I think that we could add some optional type-safe checking to the project to laverage the pros of Scala. I therefore created the Cake support for Spring Scala.
Cake support for Spring Scala allows to create type-safe cake view over the entire-, or part of the-, functional application context.
I would like to elaborate a little bit on some concrete example. Imagine the part of the typical Spring application .i.e.
Service
andDao
.We want to wire these two guys into Spring application context. On the same time we want to take the advantage of the cake pattern in order to:
a) get global access to the application components
b) verify at the compile time that we have provided all necessary dependencies
For this purpose we create typical cake components, but instead of specifying dependencies as
T
we specify them as() => T
.Then we wire the dependencies into the global application context.
We can use the
CakeObject
as regular Scala cake:Under the hood, our cake hides regular Spring (functional) application context:
The magic here is the
singleton
method from theCakeSupport
trait which registers the function defined as Cake dependency in the application context.The nice thing in cake for Spring Scala is that you don't have to cover all your Spring dependencies with "caked" components.
Using this approach you can combine the best of both worlds - type-safe cake dependencies and dynamic Spring configuration.
What do you think?
PS Scaladoc available on demand, as usually :) .