YOP is an ORM tool.
And since I am such a nice guy, a REST stack is built on top of it.
Modules :
Yop modules are available on Maven central :
<dependency>
<groupId>org.y-op</groupId>
<artifactId>reflection</artifactId>
<version>0.9.0</version>
</dependency>
<dependency>
<groupId>org.y-op</groupId>
<artifactId>ioc</artifactId>
<version>0.9.0</version>
</dependency>
<dependency>
<groupId>org.y-op</groupId>
<artifactId>orm</artifactId>
<version>0.9.0</version>
</dependency>
<dependency>
<groupId>org.y-op</groupId>
<artifactId>rest</artifactId>
<version>0.9.0</version>
</dependency>
<dependency>
<groupId>org.y-op</groupId>
<artifactId>swaggerui</artifactId>
<version>0.9.0</version>
</dependency>
Yop is an ORM tool with a conventional REST webservice Servlet. Webservices are described using OpenAPI specifications
The ORM module brings a set of query builders with an SQL like syntax :
Select
.from(Library.class)
.join(Library::getAuthors, Author::getBooks, Book::getChapters)
.join(Library::getEmployees)
.execute(connection);
The REST module brings a set of annotations to directly expose the data objects as REST resources :
@Rest(
path="book",
summary = "Rest resource for books !",
description = "A collection of sheets of paper bound together to hinge at one edge."
)
@Table(name="book")
public class Book implements Yopable {}
A REST servlet can expose the data objects as REST resources :
Wrapper wrapper = Tomcat.addServlet(context, YopRestServlet.class.getSimpleName(), new YopRestServlet());
// The data objects packages exposed as REST resources
wrapper.addInitParameter(YopRestServlet.PACKAGE_INIT_PARAM, "org.yop");
// The datasource JNDI name (or you can override the 'getConnection' method)
wrapper.addInitParameter(YopRestServlet.DATASOURCE_JNDI_INIT_PARAM, "datasource");
// The exposition path for the data objects REST resources
context.addServletMappingDecoded("/yop/rest/*", YopRestServletWithConnection.class.getSimpleName());
The OpenAPI description of data objects can be generated and exposed using a Servlet :
Wrapper wrapper = Tomcat.addServlet(context, OpenAPIServlet.class.getSimpleName(), new OpenAPIServlet());
// The data objects packages exposed as REST resources
wrapper.addInitParameter(OpenAPIServlet.PACKAGE_INIT_PARAM, "org.yop");
// The exposition path for the data objects REST resources
wrapper.addInitParameter(OpenAPIServlet.EXPOSITION_PATH_PARAM, "/yop/rest");
// The exposition path for the generated OpenAPI description of the data objects REST resources
context.addServletMappingDecoded("/yop/openapi", OpenAPIServlet.class.getSimpleName());
- Data objects describe their REST and/or ORM features.
- CRUD behavior in REST services is conventional.
- Data objects carry any extra CRUD behavior (i.e beyond conventional) to be exposed in REST services.
- Explicit CRUD can be achieved using the orm module in an SQL like syntax.
- DAO pattern sucks.
- DTO pattern sucks.
- YOP naively aims at being a straightforward Model-Driven ORM/REST stack.