Skip to content

2 Project Structure

Rolf Thunbo edited this page Mar 10, 2015 · 7 revisions

The project is a combined AngularJS and Spring MVC application.

The project is structured as a Maven project, and can be built by Maven command line.

AngularJS

The AngularJS web site files (js, html, css, etc.) is located at src/main/webapp.

bower.json defines all JavaScript dependencies for the JavaScript application code and the dependencies added to this file will automatically be reflected in index.html (in src/main/webapp) and karma.conf.js in the bower:js and bower:css sections if you are using Eclipse or executing mvn copy-resources.

Gruntfile.js is the Grunt build file.

karma.conf.js and karma.ci.conf.js is JavaScript unittest configuration files (karma.ci.conf.js is for the CI server only).

package.json defines all JavaScript dependencies needed to build the JavaScript application code.

The application is based on a single page AngularJS web site consisting of a number of views each using a number of components.

The views are located at src/main/webapp/views and the components are located at src/main/webapp/components.

The main page is located at src/main/webapp/index.html.

Java / Spring MVC

Code

The Java code is located at src/main/java (the Java test code is located at src/test/java).

eea.eprtr.controller

This Java package contains all the Spring MVC controllers hosting the REST services. Each controller must be annotated with @RestController and the serving methods must be annotated with @RequestMapping annotations. If the controller depends on a repository (fancy name for DAO), then the dependencies are injected using @Autowired annotations.

eea.eprtr.dao

This Java package contains all the DAO related classes. Repository classes are annotated with the @Repository annotation to be injectable into to another managed class. Filter classes are meant as reusable components for the different search services.

eea.eprtr.model

The Java package contains all the entity classes.

Configuration

The configuration files is located at src/main/resources and src/main/webapp/WEB-INF (the test configuration files is located at src/test/resources).

Spring configuration

The Spring configuration file is located at src/main/webapp/WEB-INF/spring-mvc-config.xml.

The following is configured:

  1. Enable static file serving (such as js, css and html).
  2. Enable component scan for the eea.eprtr.controllerand eea.eprtr.dao packages so that classes annotated with @Component and descendants (@RestController, @Repository, etc.) will be auto-discovered and be part of the configuration.
  3. Enable JPA with Hibernate as the persistence provider
  4. Initializing the jdbc datasource from jndi using the name jdbc/datasource (which requires that a data source has been configured in the server.xml or context.xml for the tomcat server instance).
JPA configuration

The JPA configuration file is located at src/main/resources/META-INF/persistence.xml.

The following is configured:

  1. exclude-unlisted-classes is set to false meaning that all entity classes will be auto-discovered using annotations.
  2. Second level cache has been enabled with EhCache as the provider.
  3. All other configuration parameters is done using annotations on the entity classes.

The database-mapping.xml configuration file (located at src/main/resources/META-INF) defines the schema etc. to use when generating native queries (from JPA queries).

The persistence-test.xml configuration file (located at src/main/resources/META-INF) is used for the unit tests and should not be moved (the reason being that JPA requires that the persistence configuration file located in the same jar file as the persistence classes).