Review
In the previous section, we have discussed the View layer along with Thymeleaf. In this section, we will focus on the Domain, Repository, Service, and Controller classes.Table of Contents
Click on a link to jump to that section:
- Functional Specs
- Generate OAuth keys
- Spring Social configuration
- Spring Security configuration
- JavaConfig
- ApplicationInitializer.java
- ApplicationContext.java
- DataConfig.java
- ThymeleafConfig.java
- spring.properties
- View with Thymeleaf
- Layers
- Domain
- Repository
- Service
- Controller
- Running the application
- Clone from GitHub
- Create the Database
- Run with Maven and Tomcat 7
- Run with Maven and Jetty 8
- Import to Eclipse
- Validate with W3C
Layers
Domain
Our domain layer consists of two simple classes: User.java and Role.java. By annotating these classes with @Entity we're declaring these classes as JPA entities and consequently will be persisted to a database.
The User class contains the following properties: first name, last name, username, role, and password. For the Role class, we only have two values: an admin and a regular user.
Although this is not part of the domain layer, we've included the UserDto here. This DTO is used for transferring user information to the view layer.
Controller
We have five controllers:
- AccessController is responsible for managing login and signup requests
- FacebookController is responsible for handling Facebook requests
- TwitterController is responsible for handling Twitter requests
- UserController is responsible for handling User CRUD operations
- MediatorController simply handles call to the root page
AccessController.java
FacebookController.java
MediatorController.java
TwitterController.java
UserController.java
Repository
We have a simple repository. There's nothing much to explain here.
UserRepository.java
Service
We have two services:
- UserService is used for handling user-related CRUD operations
- RepositoryBasedUserDetailsService is used for retrieving user details for authentication purposes
UserService.java
RepositoryBasedUserDetailsService.java
0 komentar:
Post a Comment