Sinobu

kiss

Lifestyle<M>

Lifestyle manages the instance in the specific context. Sinobu provides two commonly used lifestyles (I#prototype(Class) and Singleton.

There are two ways to specify Lifestyle for the class.

The one is Managed annotation. This way is useful if the target class is under your control. If the lifestyle is not specified, Sinobu uses I#prototype(Class) lifestyle as default. The following is example.

@Managed(lifestyle = Singleton.class)
 public class TargetClass {
 }

The other is defining custom Lifestyle. Sinobu recognizes it automatically if your custom lifestyle class is loaded or unloaded by I#load(Class) and Disposable#dispose()methods. The following is example.

public class CustomLifestyle implements Lifestyle<ClassNotUnderYourControl> {
 
     public ClassNotUnderYourControl call() {
         return new ClassNotUnderYourControl();
     }
 }