-
Notifications
You must be signed in to change notification settings - Fork 0
Home
#Atem - the meta API
The Atem API is designed to be used for data centric tasks instead of the standard reflection API. It provides access to class information via the interface EntityType
. An EntityType
provides access to its attributes which are analoguos to a java class's fields or java bean properties. The advantages of the Atem API over standard reflection or java beans introspection are as follows:
- access to the parmeter type of collections and maps
The parameter types of a field of typejava.util.Collection
is not available at runtime. Most libraries that need this kind of information use annotations to add the information (JPA). The Atem API uses existing annotations or provides its own annotations. - access to the known subtypes
The subtypes of class are not accessible at runtime. Since java can dynamically load new classes and a lot of libraries generate subclasses at runtime, this information is only ever valid for the moment. It is of great use though and the information can be retrieved under certain conditions. JPA handles a certain set of classes that does not change during runtime. Within this set of classes the subclasses of a class can be determined (Ignoring proxy classes). - declare new primitive types
A Date is not a java primitive type. From a data centric point it just represents a single value and can be treated as a primitive. It is more expressive to have an attribute of the primitive type „date“ than an attribute whose EntityType has one attribute of the primitive type string or long. - Incoming associations
In Atem it is possible to find all attributes that are referencing a type. It is even possible to find all entities that are referencing a certain object. For the latter certain service interfaces need to be implemented. - add meta data to objects, types or attributes.
In java you can annotate a class with annotations to add meta data. Sometimes meta data is only available at runtime or is stored in a database. The Atem API makes it possible to attach meta data to any object (e.g. object, Attribute or type). - adapt the api to dynamic types (json, xml, jdbc resultsets, ..)
It is possible to create new dynamic types at runtime. This can be used as an alternative to using a classical mapping library to convert a non java format (xml, json) into java objects. The main advantage is that you have a common reflective access to objects of very different origin.
Imagine you want to compare two objects. Here are some requirements that come to mind:
- Not all properties/fields in the objects should be compared. If I compare two objects from two different databases and I know that the primary keys are different but otherwise the object represent the same entity, then I want to exclude the id from the comparison.
- I want the comparison to tell me what exactly the differences are, so I want the comparison to include the properties of associated objects. E.g. an account has an address property and the streetnumber has changed, then the comparison of the two accounts should tell me that the value of "address.streetnumber" has changed.
In order to fullfill these requirement you want to define a comparison based on paths that specify which attributes are included and which not. At start-up time the comparison is defined and the paths should be validated. This is where normal reflection fails, because it does not provide for path resolution across multiple associations like sets and lists. The type of the associated objects needs to be provided via annotations or other metadata (just like in JPA). Also you need to know subtypes of associated objects to fully validate the paths. This information can be accessed via Atem in a standardized way.
To get started follow the instructions [here] (/stemey/atem.api.github.com/wiki/getting-started)
- Maven site.
- Utilities based on the API for cloning, comparing and transforming entites.
- Implementations of the API for pojos, JSON and dynamic entities. Also explains how to configure the repositories.
- Hibernate implementation.