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
Next
In the next section, we will study how to build and run our application. We will use Maven, Tomcat, and Jetty to run the app. We'll also study how to import the project in Eclipse. Click here to proceed.
Share the joy:
|
Subscribe by reader Subscribe by email Share
This is a great tutorial! I've learnt a lot from it.
ReplyDeleteMark, can you explain why you used the @JsonManagedReference annotation in your JPA entities?
Also, maybe you would like to continue your tutorial by explaining what happens on the client-side of your application (e.g. how does the client browser create, process, and send JSON? I see some of the UserController methods producing JSON). This would be awesome!
And finally: What about having a demo running somewhere online so that users can play with it?
Cheers!
Can you explain what if someone wants to sign up to your page using facebook?
ReplyDeletegenerate OAuth keys for Facebook and Twitter (Online Java Training) Generate OAuth keys Java Training in Chennai Consumer key and Consumer secret values: J2EE Training in Chennai
ReplyDeleteYour blogging is really more than wonderful and we hope for more creativity because you really are capable of that creative
ReplyDeleteالعاب سباق سيارات 2018
العاب سباق
Good Post! Thank you so much for sharing this pretty post, it was so good to read and useful to improve my knowledge as updated one, keep blogging.
ReplyDeletecore java training in Electronic City
Hibernate Training in electronic city
spring training in electronic city
java j2ee training in electronic city
I enjoyed your blog Thanks for sharing such an informative post. We are also providing the best services click on below links to visit our website.
ReplyDeletedigital marketing company in nagercoil
digital marketing services in nagercoil
digital marketing agency in nagercoil
best marketing services in nagercoil
SEO company in nagercoil
SEO services in nagercoil
social media marketing in nagercoil
social media company in nagercoil
PPC services in nagercoil
digital marketing company in velachery
digital marketing company in velachery
digital marketing services in velachery
digital marketing agency in velachery
SEO company in velachery
SEO services in velachery
social media marketing in velachery
social media company in velachery
PPC services in velachery
online advertisement services in velachery
online advertisement services in nagercoil
web design company in nagercoil
web development company in nagercoil
website design company in nagercoil
website development company in nagercoil
web designing company in nagercoil
website designing company in nagercoil
best web design company in nagercoil
web design company in velachery
web development company in velachery
website design company in velachery
website development company in velachery
web designing company in velachery
website designing company in velachery
best web design company in velachery
Thanks for Sharing - ( Groarz branding solutions )
Including various techniques of gambling, both disadvantages and disadvantages. Various techniques that the gambler should know nunchaku-tech
ReplyDeleteWOW! I Love it...
ReplyDeleteand i thing thats good for you >>
GOOD HOW TO Thank you!
This is my blog. Click here.
ReplyDeleteวิธีเล่นบาคาร่าให้ได้เงิน 8 เทคนิคนี้ช่วยได้"
Thanks for sharing a useful knowledge-sharing blog
ReplyDeletewordpress
blogspot
youtube
Game ស្លត់អនឡាញ