Basic support for Cake pattern based configuration.#17
Basic support for Cake pattern based configuration.#17hekonsek wants to merge 1 commit intospring-attic:masterfrom hekonsek:cake_support
Conversation
|
Hey Henryk, Once again, thanks for making another contribution to Spring Scala. It's hard for me to keep up with them all :) I have a couple of questions/remarks:
So overall, I am not entirely convinced we need this feature. I am just not sure who the target audience for this new feature is, who we're trying to appeal to. As I wrote above, Cake users will probably stick with Cake, and Spring users will feel more comfortable with functional configurations. But I could be wrong, of course. Feel free to correct me :). Also, I'm interesting in hearing the opinion of other contributors: @nurkiewicz and @eugener? |
|
Hi Arjen,
Cake is not about a type safeness itself, rather about the compiler verifying that necessary dependencies have been provided. When you compose the cake from components and compile it, the compiler will tell you what dependencies you need to provide. With
In my humble opinion "No frameworks" Scala people won't use Spring Scala anyway. I wouldn't even think about targeting them :) .
I'd like to target people like me :)
Cheers. :) |
|
I see, your points are valid. Especially the compile-time check, I didn't consider that before. WIth that, I need to take another look at the code. I'll keep you informed. Thanks! |
|
Sure, take your time. If you more information from me, just drop me a line. :) |
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.
ServiceandDao.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
Twe specify them as() => T.Then we wire the dependencies into the global application context.
We can use the
CakeObjectas regular Scala cake:Under the hood, our cake hides regular Spring (functional) application context:
The magic here is the
singletonmethod from theCakeSupporttrait 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 :) .