QueryJ has built-in capabilities to perform actions (focused on generating code) based on the relational model it sees.
In particular, QueryJ 0.7 provides the following criteria:
- Code to generate for each table of the model.
- Code to generate for the whole repository.
- Code to generate for each custom query.
- Code to generate for each custom result.
In any case, the required steps to extend QueryJ to generate sources based on new templates are:
- Identify which entity the sources are associated to (see above).
- Create a Template class extending, respectively,
- BasePerTableTemplate
- BasePerRepositoryTemplate
- BasePerCustomSqlTemplate
- BasePerCustomResultTemplate
- Create a TemplateGenerator implementing the associated !BasePerXXXTemplateGenerator. This class is responsible of writing the template output to disk.
- Create a TemplateBuildHandler and TemplateWritingHandler, extending from BasePerXXXTemplateBuildHandler and BasePerXXXTemplateWritingHandler. This two classes participate in QueryJ's Chain of Responsibility. The former takes the input the templates require from the available Command and builds the template instances, whereas the latter asks the decorator to write them.
- Create a TemplateHandlerBundle using any of the already-existing ones as a model. It's just a composite handler to group the build and writing handlers together.
- Include the bundle into QueryJ's flow. Extend ''QueryJTask as needed.
