Annotation-driven lazy-loading for people too bone idle to write it themselves
Got a bunch of data you want to load in to your class just once, but don't want to write all those tedious ifs yourself? Don't worry, boneidle has got you covered with these three easy steps:
- Write a method to do the loading
- Annotate the lazy-loaded getters with
@LazyLoadWith
(or any other method you want to trigger the loader). Annotate the class to make all methods lazily-loaded by default. - Create your lazy-loading proxy with
LazyFactory.proxy()
For more information see boneidle.io.
Maven Central. You can add a dependency to your project like this:
<dependency>
<groupId>io.boneidle</groupId>
<artifactId>boneidle-core</artifactId>
<version>1.0.0</version>
</dependency>
There are two artifacts to be aware of:
- boneidle-annotations which contains only the annotation classes, for use with marking up a class for lazy loading
- boneidle-core which includes boneidle-annotations plus the classes needing for generating lazy-loading proxies.
If you're not sure which you want, use boneidle-core; boneidle-annotations is intended for use with library modules/projects that define lazily loaded classes, but don't actually make use of them.
Version numbers follow the Semantic Versioning (semver.org) convention.
Ways in which boneidle could be even better include:
- Smarter / configurable strategies for deciding when data needs to be loaded. For example:
- If the
@LazyLoadWith
loader has been invoked once - If any loader specified (by a new annotation?) has been invoked
- If the field backing the bean getter is not null (for bean getters only, obviously)
- Extend support for
@LazyLoadWith
on the class: - Perhaps add different inclusion filters (e.g. all methods, only public methods, only getter methods)
- Build on Travis (or similar)