In a earlier write up we saw how we can setup basic spring security. In this one we will see how to make a custom UserDetailsService instead of using the credentials in the configuration file. We will use MongoDB as a datasource.
We will use the project from the Spring Security project we created earlier and add the MongoDB config details and user service to provide the capability. See my previous blog for setting up MongoDB Spring Data.
Add the following to the mongo-config.xml file in the location WEB-INF/mongo/
Add the Spring Data dependencies in the pom.xml file
Add the mongo-config.xml file to the contextConfigLocation on web.xml. The context param will look like this
We will now create a CustomUserDetailsService class that implements UserDetailsService. We will add the implementation of loadUserByUsername method. The CustomUserDetailsService is as follows. The getUserDetail method queries to get the user object from MongoDB (it is…
View original post 101 more words
Over the last few weeks I got in touch with the fascinating field of data visualisation which offers great ways to play around with the perception of information.
In a more formal approach data visualisation denotes “The representation and presentation of data that exploits our visual perception abilities in order to amplify cognition”
Nowadays there is a huge flood of information that hit’s us everyday. Enormous amounts of data collected from various sources are freely available on the internet. One of these data gargoyles is Twitter producing around 400 million (400 000 000!) tweets per day!
View original post 415 more words
You have picked up Mockito and you are interested in some good practices to avoid hangovers.
Don’t mix with Spring Integration Test
Mixing spring integration test and mockito can produce strange border effects like : singleton replaced by mocks,…
and will also lose the main benefit of mockito tests : speed !
Avoid abstract testcases
When something breaks it simply takes too long to diagnose.. An alternative is to create custom assertion and factory methods that can be reused.
-> prefer composition over inheritance.
Don’t mock your model
Prefer simply using your model
Over mocking it
Easier to read and you will may be add convenient contructor/factory methods to your production or test codebase… remember to put the code where it belongs.
Don’t abuse mocks
Mockito isn’t a Panacea. If all you have is a hammer, everything looks like a nail…
For example testing an xstream converter
View original post 351 more words
Earlier this week, Josh Constine wrote an epic piece on Facebook, Google and Apple’s impending messaging war. As Constine explains, we have most likely reached “peak SMS,” that is, text messaging is on the decline and another form of messaging will take its place.
But as the major empires wage total war for glorious messaging spoils, there are far smaller, distant tribes that will make their own windfall of riches from the battle. Man, I miss playing Age of Empires.
As these tech giants extend their reach even further, it is quite possible that users will seek to regain control over their information and embrace applications that quickly erase or encrypt their messages and pictures. Especially if the companies’ battle reduces their respect for users’ privacy—like Facebook’s aggressive email change last month.
The real gold mine for these impermanent apps is that they aren’t in the war. None of them…
View original post 500 more words
This is another tutorial of the category ‘quick start for absolute beginners’. This time the topic is on Play 2.0, Heroku and Scala. The reason for this tutorial is that recentannouncements indicate that the three topics will have a bright future together. A really nice overview of all three topics can be found in this presentation on slideshare (simply skip the Akka part. Or even better, read it as well!).
As the time of writing Play 2.0 is still in beta status and according to the official homepage, APIs are likely to change a bit in the future. Nevertheless, I guess it is time to have a quick look into the new features of the framework and create a simple application.
As we would like to access all latest features, we are going to build Play from the source code ourselves. Therefore…
View original post 982 more words
Update: Heroku now does support Java.
does not officially support Java applications yet (yes, it does). However, the most recently launched stack comes with support for Clojure. Well, if Heroku does run Clojure code, it is certainly running a JVM. Then why can we not deploy regular Java code on top of it?
I was playing with it today and found a way to do that. I admit, so far it is just a hack, but it is working fine. The best (?) part is that it should allow any maven-based Java Web Application to be deployed fairly easy. So, if your project can be built with maven, i.e.
mvn package generates a WAR package for you, then you are ready to run on the fantastic Heroku Platform as a Service.
Wait. There is more. In these polyglot times, we all know that being able to run Java…
View original post 807 more words