Backend API. Server-side code: this runs in a Codename One backend, not in the app on the device.

@Retention(CLASS) @Target({TYPE, METHOD})

public @interface Lazy

Constructs this bean the first time something calls it, instead of at start-up.

The build injects a generated subclass that constructs the real bean on the first call and delegates to it. The class must therefore be possible to subclass: not final, with a constructor taking no arguments that the subclass can call.

That constructor runs once at start-up, for the stand-in itself, because a subclass cannot be built without it. So keep it cheap, and put the expensive set-up in a @PostConstruct method: that runs only on the real instance, on first use.

Methods

public abstract boolean value() default trueWhether the bean is lazy; false undoes a class-level annotation.

Method details

value

public abstract boolean value() default true
Whether the bean is lazy; false undoes a class-level annotation.