Lembas-backend

Lembas core object library for serialization and object description generator

License

License

GroupId

GroupId

com.happyblueduck.lembas
ArtifactId

ArtifactId

lembas-backend
Last Version

Last Version

2.2
Release Date

Release Date

Type

Type

jar
Description

Description

Lembas-backend
Lembas core object library for serialization and object description generator
Project URL

Project URL

http://maven.apache.org
Source Code Management

Source Code Management

https://github.com/anlcan/Lembas-core

Download lembas-backend

How to add to project

<!-- https://jarcasting.com/artifacts/com.happyblueduck.lembas/lembas-backend/ -->
<dependency>
    <groupId>com.happyblueduck.lembas</groupId>
    <artifactId>lembas-backend</artifactId>
    <version>2.2</version>
</dependency>
// https://jarcasting.com/artifacts/com.happyblueduck.lembas/lembas-backend/
implementation 'com.happyblueduck.lembas:lembas-backend:2.2'
// https://jarcasting.com/artifacts/com.happyblueduck.lembas/lembas-backend/
implementation ("com.happyblueduck.lembas:lembas-backend:2.2")
'com.happyblueduck.lembas:lembas-backend:jar:2.2'
<dependency org="com.happyblueduck.lembas" name="lembas-backend" rev="2.2">
  <artifact name="lembas-backend" type="jar" />
</dependency>
@Grapes(
@Grab(group='com.happyblueduck.lembas', module='lembas-backend', version='2.2')
)
libraryDependencies += "com.happyblueduck.lembas" % "lembas-backend" % "2.2"
[com.happyblueduck.lembas/lembas-backend "2.2"]

Dependencies

compile (6)

Group / Artifact Type Version
log4j : log4j jar 1.2.17
com.happyblueduck.lembas : lembas-core jar 2.1
com.google.collections : google-collections jar 1.0
com.googlecode.json-simple : json-simple jar 1.1.1
jstl : jstl jar 1.2
org.eclipse.birt.runtime.3_7_1 : org.apache.commons.codec jar 1.3.0

provided (1)

Group / Artifact Type Version
javax.servlet : servlet-api jar 2.5

Project Modules

There are no modules declared in this project.

Lembas-core

Build Status

Java object serialization and description library

This is a simple and flexible object serialization library built on top of simple.json library. At the time of serialization, object inject its class(type) into serialized data, so it can be deserailized as the correct type.

package com.matrix;
public class User extends LembasObject{
    public String name;
    public String value;
    public int loginCount;
    public Date registerDate;
}

An instance of User class will be serialized to json as follows.

{
    "_type":"User",
    "registerDate":{"_type":"LembasDate",
                        "time":"16:58:05",
                        "date":"25\/08\/2014",
                        "zone":"+0300"},
    "name":"Keanu",
    "value":"The One",
    "loginCount":1337
}

We can than proceed to restore the instance with LembasUtil

 Config.addArtifact("com.matrix"); // setting the target package, for once
 User neo = LembasUtil.deserialize(json);

Also, we can ask the instance to describe itself according to HandsomeProtocol:

JSONObject object = neo.discoDescription();
System.out.println(object.toJSONString());

will print:

{
	"_type" : "MObjectDef",
	"ofType" : "BASE_OBJECT",
	"name" : "User",
	"properties" : [
		{
			"_type" : "MPropertyDef",
			"propType" : "MSTRING",
			"propExtData" : "String",
			"propName" : "value"
		},
		{
			"_type" : "MPropertyDef",
			"propType" : "MSTRING",
			"propExtData" : "String",
			"propName" : "objectKey"
		},
		{
			"_type" : "MPropertyDef",
			"propType" : "MSTRING",
			"propExtData" : "String",
			"propName" : "createDate"
		},
		{
			"_type" : "MPropertyDef",
			"propType" : "MSTRING",
			"propExtData" : "String",
			"propName" : "name"
		},
		{
			"_type" : "MPropertyDef",
			"propType" : "MINT",
			"propExtData" : "int",
			"propName" : "loginCount"
		},
		{
			"_type" : "MPropertyDef",
			"propType" : "MSTRING",
			"propExtData" : "String",
			"propName" : "updateDate"
		},
		{
			"_type" : "MPropertyDef",
			"propType" : "MDATE",
			"propExtData" : "Date",
			"propName" : "registerDate"
		}
	]
}

Roadmap

I have been coding, debugging, tweaking, messing with this library over 2 year. It has been a tremendous learning opportunity for me but as a framework, it has many shortcomings. These are things that I am planning to implement in the near feature.

  • Replace simple.json with codehaus.jackson
  • Change date with an ISO Format

Versions

Version
2.2
2.1