Ressor is a framework which ease the development of resource-based Java services. It translates your static or dynamic resources (files, http endpoints, git repositories, etc) into a complete Java service instance, implicitly reloading it when the source data is changing.
See the Basic Concepts page for the more details.
Ressor generates a special proxy class at runtime, which inherits the class/interface of your service. It delegates the calls to an actual instance of your service, which is created and stored inside this proxy, filled with the resource data.
As a result, you generate a single instance once and use it everywhere for the whole application lifetime. When the source data changes, it reloads the service and just swap to the new instance under the hood.
Ressor is currently at its early stages, so the feature set can be not complete and some bugs occur.
Feel free to participate in Ressor development in any form via contributions, issues, feature requests, etc.
Let's suppose you have a service which provides book titles by the ISBN:
public class BookRepository {
private final Map<String, String> data = new HashMap<>();
public BookRepository(List<Book> node) {
node.forEach(b -> data.put(b.getIsbn(), b.getTitle()));
}
public String getTitle(String isbn) {
return data.get(isbn);
}
}
Also, there is a /etc/books.json
file with all the data. Now we can simply tell Ressor to create a service instance, based on that file and use JSON format:
var ressor = Ressor.create();
var bookService = ressor.service(BookRepository.class)
.fileSource("/etc/books.json")
.translator(jsonList(Book.class))
.build();
Now we can just use it:
var title = bookService.getTitle("0679760806"); // The Master and Margarita
What will happen if the books.json
file will be changed? In case of file on local File System you can just subscribe for the changes:
ressor.listen(bookService);
That's all, you can continue using bookService
instance, which will be always up-to-date with the books.json
file contents.
See our Project Website.
Javadoc is here.
Releases are available via Maven Central.
implementation 'xyz.ressor:ressor-core:1.3.0'
implementation 'xyz.ressor:ressor-git-source:1.3.0'
implementation 'xyz.ressor:ressor-http-source:1.3.0'
implementation 'xyz.ressor:ressor-s3-source:1.3.0'
implementation 'xyz.ressor:ressor-core-jdk8:1.3.0'
implementation 'xyz.ressor:ressor-git-source-jdk8:1.3.0'
implementation 'xyz.ressor:ressor-http-source-jdk8:1.3.0'
implementation 'xyz.ressor:ressor-s3-source-jdk8:1.3.0'
We use SemVer for versioning. For the versions available, see the releases on this repository.
This project is licensed under the Apache License 2.0 - see the LICENSE file for details.