[SPARK-1477]: Add the lifecycle interface 

Java code can actually extend Scala traits as well. Do you have other concerns?