A detailed documentation with interactive examples you find at elasticobjects.org.
This website is an example by itself. Its build by one generic spring boot endpoint and
EO template calls.
EO - Elastic Objects
Elastic Objects is a java framework using typed JSON for looseless communication with composed objects by one generic endpoint.
Functionality is provided by special call objects with a generic execution method using a source path as input and a target path for output.
Compared with todays RPC concepts its more a "Remote Object Call" (ROC) architecture. One can easily create new calls for almost anything. A client can create a typed JSON message addressing call objects in any combination.
There are some predefined generic calls e.g. for files, csv, Excel, database or templates. The calls implemented are used in the two applications:
- the documentation on http://elasticobjects.org/" in module example-springboot
- the builder for generation java code and configurations.
Elastic Objects
Elastic Objects is a generic object wrapper skin with typed path methods to an java object skeleton. Typed objects are embedded in an untyped map structure.
Some code examples you will find in http://elasticobjects.org/eo/EO.html.
Model Configurations
For the access to the embedded java objects EO is provided by preloaded model configurations in JSON.Call Types
A special Call bean with a generic execution method offers functionality. Its has the following important fields:
- ≡sourcePath for the location of the input
- ≡targetPath for storing the output
- ≡condition
Pseudo JSON Example
The following pseudo code would call the execute method in the ACall instance, which uses the AnObject object provided in input path and store the result in target path.
{
"(AnObject)input":{...},
"(ACall)target:{"sourcePath":"input"}
}
A CSV Example
This example is executable on elasticobjects.org.
{
"data": {
"(CsvSimpleReadCall)csv":{
"configKey"="AnObject.csv"
},
"(TemplateResourceCall)abc":{
"configKey":"table.tpl",
"sourcePath":"/data/csv",
"targetPath":"/_asTemplate"
}
},
"asTemplate":true
}
Elements
- CsvSimpleReadCall reads AnObject.csv and store it under the path "/data/csv"
- TemplateResourceCall use /data/csv as input table.tpl and store it under the path "_asTemplate"
Sending Template
The following example is executable on elasticobjects.org
<h1>An Example Template</h1>
<h2>CSV</h2>
==>{CsvSimpleReadCall->AnObject.csv, data/csv}.
==>{TemplateResourceCall->table.tpl, data/csv}.
<h2>Excel</h2>
==>{XlsxReadCall->AnObject.xlsx:test, data/xlsx}.
==>{TemplateResourceCall->table.tpl, data/xlsx}.
<h2>DB</h2>
==>{DbSqlReadCall->h2:mem:basic, h2:mem:basic:AnObject, data/db}.
==>{TemplateResourceCall->table.tpl, data/db}.
Short Form
In the template a short form of one call JSON is used:
==>{CsvSimpleReadCall->AnObject.csv, data/csv}.
is equivalent to
===>{"(CsvSimpleReadCall)":{
"fileConfigKey":"AnObject.csv",
"targetPath":"data/csv"
}}.
and
==>{TemplateResourceCall->table.tpl, data/csv}.
is equivalent to
===>{"(TemplateResourceCall)":{
"fileConfigKey"="table.tpl",
"sourcePath": "data/csv"
}}.
Elements
On elasticobjects.org a second endpoint is defined for receiving templates via WebEo.java.
- CsvSimpleReadCall with AnObject.csv
- XlsxReadCall with AnObject.xlsx:test
- DbQueryCall with DbSqlConfig.json
After each read call the AnObject example data a TemplateResourceCall will render this data with table.tpl again.
Other Examples
Service Examples
Under http://elasticobjects.org/examples/ExamplesStart.html you find further working editable service examples:
Direct Java Usage
Under the http://elasticobjects.org/eo/EO.html you find examples to use EO in a java code context.
Conclusion
The project has now version 0.8.1 and it's good enough for a proof of concept. For the hyped microservice architectures it would offer an incredible flexibility compared with RPC API solutions.
Modules
Actually three modules are deployed to Maven Central.
elastic-objects
The core has actually no dependencies beside Log4j
and is rather small with a jar size of approximately 270 KB. It already includes the template calls.
<dependency>
<groupId>org.fluentcodes.projects.elasticobjects</groupId>
<artifactId>elastic-objects</artifactId>
<version>0.8.0</version>
</dependency>
elastic-objects-test
The objectives elastic-objects-test is providing all tests for elastic-object module together with a main package providing test helper and test objects to other modules.
examples-springboot
examples-springboot are the sources for the spring boot web example on http://www.elasticobjects.org.
eo-csv
eo-csv offers calls and configurations for reading and writing csv files using OpenCsv.
<dependency>
<groupId>org.fluentcodes.projects.elasticobjects</groupId>
<artifactId>eo-csv</artifactId>
<version>0.8.0</version>
</dependency>
<div align="right" style="font-size:10px">
eo-db
eo-db is provide the execution of some sql configurations as list or as query.
eo-xlsx
eo-xlsx offers calls and configurations for reading and writing xlsx files using Apache POI.
<dependency>
<groupId>org.fluentcodes.projects.elasticobjects</groupId>
<artifactId>eo-xlsx</artifactId>
<version>0.8.0</version>
</dependency>
builder
builder offers calls and configurations
for generating sources like java classes or json configuration by a simple Excel file.
Links
- https://tech.signavio.com/2017/json-type-information
- https://www.json.org/json-en.html
- https://de.wikipedia.org/wiki/JSON-LD
- http://restcookbook.com/Mediatypes/json/
- https://gkulshrestha.wordpress.com/2013/11/16/embedding-type-information-in-json-posted-to-web-api/
- https://www.newtonsoft.com/json/help/html/T_Newtonsoft_Json_TypeNameHandling.htm
- https://de.wikipedia.org/wiki/JavaScript_Object_Notation
- http://jsonp.eu/
- https://github.com/json-path/JsonPath