Monday 28 October 2013

ExpectedException JUnit 4.9

The ExpectedException Rule allows in-test specification of expected exception types and messages: Example here: http://junit.org/javadoc/4.9/org/junit/rules/ExpectedException.html

Sunday 27 October 2013

Optional in guava

Optional is a way of replacing a nullable T reference with a non-null value. An Optional may either contain a non-null T reference (in which case we say the reference is "present"), or it may contain nothing (in which case we say the reference is "absent"). It is never said to "contain null."

Same concept Optional class is going to be added to the core java.util library in jdk8

More detalails here: https://code.google.com/p/guava-libraries/wiki/UsingAndAvoidingNullExplained

Monday 21 October 2013

JSR 303 Beans Validation - Groups

With JSR 303 we can validate depending on the context by using groups.
Read whole story here: http://www.jroller.com/eyallupu/entry/jsr_303_beans_validation_using

Friday 18 October 2013

RestX - the lightweight Java REST framework

Pros:
  • Fast (It is build using annotation processors, so it is not using reflection but generated code during compilation)
  • Has very simple and neat console for testing rests
  • Has wizard for generating project from scratch
  • Can be used in the current project with simple configuration http://restx.io/docs/manual-app-bootstrap.html
  • Has well constructed DI
  • Very nice usage of Rest Specifications notated in yuml
  • Examples of mongo and couchbase integrations
  • Integrations with tomcat, jetty, simpleframework

For me it's worth trying!

Read more here: http://restx.io

Monday 14 October 2013

How to connect Java Mission Control to your application with Flight Recorder enabled?

You have to:
  • Run application with java version1.7.0_40 or higher
  • Start application with flags -XX:+UnlockCommertialFeatures -XX:+FlightRecorder

Worth watching: http://www.youtube.com/watch?v=WMEpRUgp9Y4

Saturday 5 October 2013

Spring core started to have cglib dependency by default

Due to: https://jira.springsource.org/browse/SPR-9669
Spring Core is going to be have by default cglib library dependancy, as it is commited into the 3.2 branch.

The efect of this change is eliminating the need to manually add CGLIB to the application classpath, what is needed for using Java-based configuration functionality and proxy-target-class and method injection. Those things will work out of box.

All of this will work from the next released version.

Tuesday 1 October 2013

How to set a thread, that it will not stop program from exiting?

Just set him as a deamon:
  thread.setDaemon(true);