We recently decided to test a new persistence solution: Java Content Repository and especially the ModeShape implementation. Java Content Repository are designed to store content and metadata about this content. It looks like they are a good solution to persist application data, especially if you are manipulating lot of files and binary data.
The tree structure of a Java Content Repository allow a pretty simple mapping of graphs of Java objects. Mapping can be done either manually or using an object mapping framework. It looks like that one of the most used JCR mapping framework is JCROM. JCROM is described as a lightweight framework for mapping Java objects to/from a Java Content Repository (JCR).
JCROM was initially designed to handle most basic Java types but it was in 2008 when JavaFX did not exist! So we forked this excellent project and tried to extend it to support JavaFX properties...and it turned out to be pretty easy, even for JavaFX collections.
So we are pleased to announce that you can use JCROMfx to map your Java objects with JavaFX properties directly to/from a JCR repository! Just annotate your JavaFX properties and you are ready to persist them. This include all basic JavaFX properties (StringProperty, IntegerProperty,...), collections (ListProperty, MapProperty) and object properties of enum or of other objects (using @JcrChildNode)
Just to give you an overview of how a bean looks like with JCROM annotation & JavaFX properties :
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class Contact extends AbstractJcrEntity { | |
@JcrProperty | |
private StringProperty name = new SimpleStringProperty(); | |
@JcrProperty | |
private DoubleProperty height = new SimpleDoubleProperty(); | |
@JcrProperty | |
private ObjectProperty<Date> birthday = new SimpleObjectProperty<Date>(); | |
@JcrChildNode(createContainerNode = false) | |
private ObjectProperty<Address> address = new SimpleObjectProperty(); | |
@JcrProperty | |
private ObjectProperty<Role> role = new SimpleObjectProperty<Role>(); | |
@JcrProperty | |
private ListProperty<String> hobbies = new SimpleListProperty<String>(FXCollections.<String>observableArrayList()); | |
} |
Aucun commentaire:
Enregistrer un commentaire