I am using the built in cache in a scala playframework 2.4 application.
During development, I would like to be able to deactivate the whole cache temporarily.
How would I do that?
If you're using play's default cache implementation, which is EhCache, you can run your play application with net.sf.ehcache.disabled=true in order to turn off the cache. Of course this is not so desirable for automated testing and only applicable to EhCache implementation.
Related
We are using using spring-core 4.1.X module and spring-batch-core 3.0.X versions for a spring boot application. We are using SimpleAsyncTaskExecutor for async working of threads. I need to copy MDC information from parent to child thread. I have seen using ThreadDecorators as best way to achieve this. But, i these are not available in version of spring we are using. Any suggestions on equivalent approaches with the spring versions we are using. If we cannot achieve using TaskDecorators, any suggestions on what is the other best way ??
I think you are referring to the usage of TaskDecorator that was added in Spring 4.3 as a means to create a custom MDC decorator and register it in a TaskExecutor, a process that is nicely described in this article.
Actually this is a great idea especially since SimpleAsyncTaskExecutor has also been upgraded in Spring 4.3 to support TaskDecorators.
If you cannot upgrade (which is the recommended approach) I don't think it's especially hard to extend SimpleAsyncTaskExecutor to offer a similar hook if you see what is actually happening under the hood.
Here's the original commit on version 4.3 for SimpleAsyncTaskExecutor to support TaskDecorator's
I have to build a component that runs in a jvm, uses MongoDB as database and doesn't need a UI. It will be integrated into other products. I'm planning to build this using scala and related tools.
My first thoughts are to just let it expose REST API and let other products integrate using the API. While this is acceptable for some products, it isn't for others due to performance reasons. So I have to enable other components to communicate to this using either http or ipc or message queues. How can achieve this without much duplication of business logic.
Would Play framework be the right choice for this even though there is no UI involved and there is a need to accept messages via http or ipc or message queues?
Using Play for that is ok but there are frameworks better fit for what you are planning to do, as you already said, play has a lot of support for frontend features you don't need.
It will not so much affect the runtime speed as the time you will need for programming, compiling, building and deployment.
There are some framworks that might fit you needs better:
Scalatra Nice, easy to use, integrates good with JavaEE-Stack http://www.scalatra.org/
Finatra Cool if you have the twitter stack running. Metrics and other stuff almost for free http://finatra.info/
Skinny Framework : Looks nice, never tried myself
Spray : Cool features to come, a little elitist
Is there a way to hook into Play evolutions framework such that when it succeeds migrating from n.sql to n+1.sql to n+2.sql ..., it calls some post-success hook in the Play app (something like postSchemaMigration(n: Int)?
Can I manually check and apply evolutions one by one in the global object somewhere before the server bootstraps?
As it stands, Play has no in-built mechanism to allow you to control the evolution process. Either it succeeds completely, or it fails. If your application runs, then all evolutions have been applied
Depending on your use case, you have a few options. The most flexible is simply to not use Play's evolution framework, and apply your database evolutions with custom code in the global object, using plain-ol' JDBC. On roughly the same lines, you could implement a custom Play plugin that applies your evolutions.
Or you could modify the existing evolution framework. Play is open source, after all, and if your code solves a common problem, it may even make sense to submit it for inclusion in the standard Play distribution.
Hey I love Play Framework Scala and I also am falling in love with Firebase. I was wondering though, I'm planning on building an app using AngularFire and I'm going to need to do some server-side logic/computation and make some server-side queries to Firebase. Is this possible to do with a Play Framework Scala setup? If so what is the recommended approach? If not, is it coming? If so when? I think it's so cool that the Firebase guys used Scala to build Firebase, but I'm bummed there is no Scala API to work with (that I can see). Maybe I could use the Java API somehow, but write still write the app in Scala? Any help would be great. Thanks!
Scala is highly interoperable with Java (compiles to the same bytecode) so you should be able to use the Java API straight-up without any issues.
While some libraries add Scala-specific wrappers to make an API more idiomatic and pleasant for a functional programming style and to smooth some rough edges, it's often not strictly necessary.
If for some reason you didn't want to use the Java client libs, you could also interface with the Firebase REST API via Play 2's very convenience and succinct web services library.
Should be no problem with either their Java SDK (when using Firebase on the backend) or the JavaScript SDK (when using it on the client). But you won't have native support for Scala or Play, especially no support for Iteratee/Enumeratee in Play.
The Java API looks quite good and seems to be event driven. So it should be no problem to integrate it in Play in a scalable way.
We are getting the new requirement for a web based application which uses RESTful Web services. we are planning to use Play with Netty. Where to find the best documents and video materials to start the application from scratch.
Any tools are available to generate the skeleton of the project like maven archetype.
Play comes bundled with netty already. You can learn more about it at
http://www.playframework.org/documentation/2.0.1/Home
Don't go into mavenizing a Play application unless you have a good Maven level.
Paly! comes with all the stuff needed by the developpers.