Notice: This Wiki is now read only and edits are no longer possible. Please see: https://gitlab.eclipse.org/eclipsefdn/helpdesk/-/wikis/Wiki-shutdown-plan for the plan.
EclipseLink/Development/DBWS/RestfulComponent/Design
DBRS Design
The DBRS utility starts by reading some initial configuration information:
(if command-line arg -builderFile not present, default to look in current working directory)
prompt > DBRSBuilder running, connected to port 8884 ... Press <Return> to finish
dbrsbuilder.properties:
# builder properties
builder.port=8884
#builder.mode=production
builder.mode=test
builder.test.port=8885
# project properties
project.name=myproject
project.entities=employee, other entities ...
# database properties
db.driver=com.mysql.jdbc.Driver
db.url=jdbc:mysql://localhost:3306/db
db.user=user
db.pwd=password
db.platform=org.eclipse.persistence.platform.database.MySQLPlatform
logging.level=info
If the table name does not match the entity name, the user may specify an alias:
alias.employee.tablename=EMP
The DBRS utility will login in to the database using the given database credentials and 'scrape' the meta-data for the employee table: column names and datatypes, PKs, foreign-key relationships, etc. If the built-in pluralization does not generate acceptible URIs, the user can add an alias for that as well - e.g. if the entity is person, the plural should be people, not persons:
alias.person.plural=people
The DBRS utility operates at two levels:
- it builds RESTful applications (see RESTful Design Principles for more details); and
- it is itself a RESTful application that listens for messages that manipulate 'meta-resources', the in-memory representation of the meta-data for all entities in the project . This in-memory model is based on EclipseLink JAXB's OXM meta-data and EclipseLink JPA's ORM meta-data (
javax.persistence.metamodel
API):
DBRS URI Design
Of primary importance is the design of the URIs for each resource (entity):
URI | Operation | Result | ||||||||
---|---|---|---|---|---|---|---|---|---|---|
/myproject/entities/employees/ |
|
| ||||||||
/myproject/entities/employees/count | GET with search modifier | retrieve a count of the list of employees (200 OK) | ||||||||
/myproject/entities/employees/?pgNum=0&pgSize=40 | GET with query parameters | retrieve the first group of 40 employees (200 OK) Message body should include the following additional information:
| ||||||||
/myproject/entities/employee/{id} |
|
|
DBRS meta-resources URI Design
In addition, the URIs for an entity's meta-resources:
Note: all properties in dbrsbuilder.properties
can be accessed
URI | Operation | Result |
---|---|---|
/dbrsbuilder/project/name | GET | retrieve the name of the current project (200 OK) |
/dbrsbuilder/db/user | PUT | update the db.user property (201 Created) |
/dbrsbuilder/alias/employee/plural | PUT | update the alias.employee.plural property (201 Created) |
/dbrsbuilder/meta/model | GET | retrieve the meta-model for the current project (200 OK) |