This project aims to provide a simple set of POJO beans
with which you can map JCR (document, binary, etc) nodes to POJO (ContentNode
) beans,
and also bind the POJO beans back to JCR (document, binary, etc) nodes.
The POJO beans provided by this project are very friendly to most marshalling/unmarshalling frameworks
such as Jackson (for JSON), JAXB (for XML) or any others (for YAML as an example).
Therefore, you can easily export JCR content through the POJO (ContentNode
) beans after mapping,
and import data through the (unmarshalled) POJO (ContentNode
) beans to JCR content by binding.
As depicted in the diagram above, what this project provides is in the light yellow area in the center. The left and right area are out of scope in this project.
Some pointers are:
ContentNode
POJO beans provided by this project.ContentNode
POJO beans can be used to update JCR nodes back in binding process.ContentNode
is purely lightweight POJO bean without any stateful members
such as javax.jcr.Node
or javax.jcr.Property
,
you can easily marshal the ContentNode
POJO beans to JSON or XML files,
and unmarshal the ContentNode
POJO beans back from the JSON or XML files.
Basically two main POJO beans are provided by this project: ContentNode
and ContentProperty
.
ContentNode
is analogous to javax.jcr.Node
and
ContentProperty
is analogous to javax.jcr.Property
.
ContentNode
may have multiple ContentProperty
items
and multiple child ContentNode
items like JCR.
But they are purely serializable as POJOs.
Also, for simplicity, ContentProperty
stores all the values in string.
It provides type transforming getter methods for convenience though.
For example, ContentProperty#getValue(String name)
returns a string value,
and ContentProperty#getValues(String name)
returns a list of string values.
However, CotnentProperty#getValueAsObject(String name)
returns a transformed object value
(e.g, Long, Double, BigDecimal, Calendar, BinaryValue, etc) from the internal string value,
and CotnentProperty#getValuesAsObject(String name)
returns a list of transformed object values
for convenience.
Please see more detail in JavaDocs.
It is very crucial to handle binary data properly even in a simple mapping/binding library because the data size of a binary value can be big which may make a bad impact on system availability (e.g, OutOfMemoryError).
So, this library handles binary data values carefully with using BinaryValue
unlike other values
(other values are always stringified internally for simplicity).
For example, DefaultJcrContentValueConverter
(the default ContentValueConverter
implementation)
is able to automatically serialize a binary data into an external VFS file
and keep the URL string only in the ContentProperty
instance
if the data size exceeds the configured threshold size.
If the data size is less than the configured threshold size, it simply converts the binary data
into a data:
URL (containing a mimeType optionally as well as BASE64 encoded string).
Please see Release Notes.