Repository navigation
REST API
In order for client requests to be sent over HTTP and read by the application, there must be a serialization policy that dictates how the Java objects and read from and written to JSON. The technology employed to handle this work is Jackson. Jackson is a reflection based tool that can serialize and deserialize JSON to POJOs (plain old java objects). Due to the close relationship of the object structure and the JSON it produces, it is important to have these objects be used strictly for data. There should be no business logic on them.
There are two classes which reference the Jackson library, com.atypon.wayf.request.RequestReader and com.atypon.wayf.request.RequestWriter. The Jackson instance used by WAYF is actually managed by Vert.x. On server initialization and startup, the server will automatically detect which types require serialization. They classes will then be reflected upon to look for standard Jackson annotations. These annotations can provide customizations of the serialization policy such as name changes, field suppression, and object factories for polymorphic types.
In a more mature solution, the Jackson ObjectMapper should be managed on its own and not as a part of the Vert.x library. This may then be accessed in a static manner. This pattern would ensure that each call to Jackson receives the same policy and removes the possibility of transformation errors.
In the current implementation, the API types are used in the business logic. This means that the Publisher type messaged in by an end-user will be the same Java type operated on by the core business logic. Considering how tightly the structure of the types are coupled with the serialized representations, this is not ideal. For example, renaming or restructuring a field for changes in business logic would cause a breaking API change. At some point there should be a translation layer that can map the versioned API types to versionless domain objects.