Spring MVC Architecture Pattern Identification

I work through the spring mvc video series and love it!

I would like to know more about the specifics of the exact architecture used, and it is difficult for me to determine the correct name so that I can read further.

For example, I understand that the level of presentation is MVC, but I’m not quite sure how you more specifically describe the template for accounting for the use of service objects and resources - as opposed to choosing to use services, DAO and Domain objects.

Any tips to help me better focus my search on understanding the layout below?

application core models/entities services rest controllers resources resource_assemblers 

Edit: A comment by Nathan Hughes clarified my confusion in the nomenclature, and SirKometa connected architectural points that I missed. Thank you, guys.

+5
source share
3 answers

As far as I can tell you what you mentioned represents an application that communicates with the world through REST services.

Please let me know if this is the answer you were looking for.

+4
source

This question may interest you, and this is an explanation .

Basically you are talking about the same things, Spring just uses annotations, so when it scans them, it knows what type of object you are creating or creating.

Basically, all requests are sent through a controller annotated using @Controller . Each method processes the request and (if necessary) calls a specific class of service for processing business logic. These classes are annotated using @Service . The controller can create these classes by auto-updating them in @Autowire or storing them with @Resource.

 @Controller @RequestMapping("/") public class MyController { @Resource private MyServiceLayer myServiceLayer; @RequestMapping("/retrieveMain") public String retrieveMain() { String listOfSomething = myServiceLayer.getListOfSomethings(); return listOfSomething; } } 

Service classes then execute their business logic and, if necessary, retrieve data from the repository class annotated with @Repository . The service layer creates these classes the same way, either by auto-arranging them in @Autowire or their resource @ Resource .

 @Service public class MyServiceLayer implements MyServiceLayerService { @Resource private MyDaoLayer myDaoLayer; public String getListOfSomethings() { List<String> listOfSomething = myDaoLayer.getListOfSomethings(); // Business Logic return listOfSomething; } } 

Repository classes make up the DAO, Spring uses the @Repository annotation. Objects are individual class objects obtained by the @Repository level.

 @Repository public class MyDaoLayer implements MyDaoLayerInterface { @Resource private JdbcTemplate jdbcTemplate; public List<String> getListOfSomethings() { // retrieve list from database, process with row mapper, object mapper, etc. return listOfSomething; } } 

@Repository, @Service and @Controller are concrete instances of @Component . All of these layers can be annotated using @Component, it’s just better to call it what it really is.

So, to answer your question, they mean the same thing, they are simply annotated so that Spring knows what type of object it creates and / or how to include another class.

+2
source

I assume that the architectural pattern you are looking for is Representative State Transfer (REST). You can read here:

http://en.wikipedia.org/wiki/Representational_state_transfer

In the framework of REST, the transmitted data is called resources:

Resource Identification : Individual resources are identified in requests, for example, using URIs in REST web systems. The resources themselves are conceptually separated from the views that are returned to the client. For example, a server can send data from its database in the form of HTML, XML or JSON, none of which is an internal representation of the server, and this is the same resource independently.

0
source

All Articles