Creating a new Project

Project structure

Maven-based wizards are available to help in the creation of new projects. More on this will follow at the end of this section.

Here's the file and folder of a simple project created by one of these wizards:

.
|-- pom.xml
`-- src
    |-- main
    |   |-- java
    |   |   `-- pt
    |   |       `-- digitalis
    |   |           |-- entities
    |   |           |   |-- applications
    |   |           |   |   `-- SampleApplication.java
    |   |           |   |-- providers
    |   |           |   |   `-- SampleProvider.java
    |   |           |   |-- services
    |   |           |   |   `-- SampleService.java
    |   |           |   `-- stages
    |   |           |       `-- SampleStage.java
    |   |           `-- ioc
    |   |               |-- AppModule.java
    |   |               `-- EntityRegistrator.java
    |   |-- resources
    |   |   `-- modules.properties
    |   `-- webapp
    |       |-- WEB-INF
    |       |   `-- web.xml
    |       `-- sample.jsp
    `-- test
        `-- java
            `-- pt
                `-- digitalis
                    `-- SomeTest.java

We can identify the following parts:

  • pom.xml: This file is the Project Object Model, or the project definition file. It is a Maven requirement, only necessary if it is used (which is highly advised!).
    More information on POM files can be found here.
  • src/main/java: This is the folder were all the java classes should be placed. All non-java files will be ignored in packaging-time.
  • src/main/resources: All non-java files should be placed here. XML, properties and other files that will be packaged in the JAR file or other format for this module.
  • src/main/webapp: WAR resources like javascript, image, css or plain HTML files go in here. You can see in the sample above the provided web.xml and a sample JSP.
  • src/test/java: Here is where unit test classes should be placed. Maven will run the tests automatically for the appropriate goals and will generate it's output only if the tests succeed.

Other folders can exist as well, but that's beyond the scope of this section. More information about this subject can be found on the Maven documentation (see here).

Some special files

modules.properties

This is the IoC modules descriptor. Read more about it here.

Entity classes registration

By default the project must define an IEntityRegistration implementation.
This class will tell DiF what packages to search for DEM entity classes.

Here's an example of such a file:

public class EntityRegistrator implements IEntityRegistration {

    public void registerEntitys(IDEMRegistrator registrator) {
        registrator.registerMetaModelPackage("pt.digitalis.someapp.entities");
    }
}

By adding these two files, the modules.properties and this Java class, DiF will search the "pt.digitalis.someapp.entities" package and all it's sub-packages for entity classes. Which is to say java classes annotated with the Entity definition annotations. More information on this subject can be found here

The main project files

The rest of the project files should be organized as follows:

  • src/main/java/pt/digitalis/someapp/entities/...: All java classes that are entities (Providers, Applications, Services, Stages)
  • src/main/resources/messages/...: All message files. More on this here
  • src/main/webapp/...: All views files. More on this here

Walkthrough: creating a simple project

A tutorial describing the creation of a simple project is available here.

Back to User Guide index