Service Generation

This section explains the structure of the service generation file orm.generation.xml.

This file will contain the specification and the structure of the service layer for the ORM generation. This layer organizes the incoming data from the DB in a service logic fashion and specifies the DAOs.

List of tags in the file

model tag

This is the root tag for the generation file.

  • SubTags
    • service

    Example:

        <model></model>
    

service tag

This tag defines the service and the contributions of DAOs or services that can exist for a given service.

  • SubTags
    • uses
  • Parameters
    • name - it defines the name of the service that will be created

Example:

    <service name="ServiceName"></service>

uses tag

This tag specifies a contribution for the service. Each contribution must either be a service or a DAO.

  • Parameters
    • dao - defines the name of the dao that will be used
    • service - defines the name of the service that will be used

Example:

    <uses dao="DAOname"/>
    <uses service="ServiceName"/>

Complete example

Here's an example of an orm.generation.xml file as well as the file output from the plugin.

The example depicts a set of three services that define several DAOs. There's service hierarchy, being Services the top-level service. Another service, Programs is used by the top-level service, and uses a Messages service. Each service defines a set of DAOs for itself.

<model>
    <service name="Messages">
        <uses dao="Messages"/>
        <uses dao="Messagetranslations"/>
        <uses dao="Languages"/>
    </service>
    <service name="Programs">
        <uses dao="Programs"/>
        <uses dao="Programsapplications"/>
        <uses dao="Providers"/>
        <uses dao="Medias"/>
        <uses dao="Applications"/>
        <uses dao="Applicationsmedias"/>
        <uses service="Messages"/>
   </service>
   <service name="Services">
        <uses dao="Services"/>
        <uses dao="Serviceconfigurations"/>
        <uses dao="Stages"/>
        <uses dao="Stagemessages"/>
        <uses service="Messages"/>
        <uses service="Programs"/>
   </service>
</model>

In this case the service generation will generate five service files :

  • ServicesService.java - Service for the "Services" table group.
  • ProgramsService.java - Service for the "Programs" table group.
  • MessagesService.java - Service for the "Messages" table group.
  • DIFModelModule.java - IoC Binder Module for the above services.
  • module.properties - IoC contribution locator for the "DIFModelModule.java"

All DAO and Data classes will also be generated.

Getters for each DAO and each service link will be created on each service.