当前位置:网站首页>< 2021SC@SDUSC > Application and practice of software engineering in Shandong University jpress code analysis (I)
< 2021SC@SDUSC > Application and practice of software engineering in Shandong University jpress code analysis (I)
2022-04-21 20:21:00 【indaeyo】
2021SC@SDUSC
This article focuses on the page code module module-page Introduction and analysis , Make it clear module-page Module architecture and purpose of each sub module , Then analyze the first sub module in detail module-page-model.
Catalog
One 、module-page The module overview
1.2 module-page Corresponding functions
Two 、module-page Module architecture
2.4 module-page-service-provider
3、 ... and 、module-page-model Module analysis
One 、module-page The module overview
1.1 JPress framework

JPress Is powerful , Including articles 、 page 、 product 、 Functions of each module related to users . It can be seen from the architecture diagram that , Page module code module-page by JPress An important part of ,module-page And jpress-template Combination of modules , Allows us to quickly develop templates , Create a personal technology blog 、 Marketing Interface 、 The company's official website, etc .
1.2 module-page Corresponding functions

The function corresponding to the page module code is page management 、 newly build 、 Comment on 、 Set up functions .
- Page management : Provides access to published 、 draft 、 Batch operation of dustbin interface .

- newly build : Based on the existing template , Be able to write the content simply , Form a perfect interface , You can set SEO And so on .

- Comment on : Provide batch management of all comments on published articles .

- Set up : Provide the setting of comment function 、 Relevant settings of comment notice .

Two 、module-page Module architecture
module-page It contains four sub modules :
<modules>
<module>module-page-model</module>
<module>module-page-web</module>
<module>module-page-service</module>
<module>module-page-service-provider</module>
</modules>
2.1 module-page-model
- module-page-model Is the entity class module of the page , Defined the page 、 Related variables of comments and their get and set Method .
2.2 module-page-web
- Realize the interactive interface and function realization .
2.3 module-page-service
- Define database operations model Related interfaces , For example, delete according to the page primary key Model、 Add or update Model Data etc. .
2.4 module-page-service-provider
- The underlying the JFinal、Jboot Related technology , Operation on Database Model Implementation of related interfaces .
- Define thread implementation Runnable Interface , use JFinal Number of visits to technology update pages .
3、 ... and 、module-page-model Module analysis
Contains abstract classes BaseSinglePage、 His subclass SinglePage, And abstract classes BaseSinglePageComment、 His subclass SinglePageComment.

3.1 Add dependency
The main dependencies of this module are Jboot, And Jboot Based on JFinal complete MVC + ORM Supported development , Therefore, both are the main framework of development . The second is the need jpress-commons Tool class 、jpress-core The functional core class consists of two modules .
<dependencies>
<dependency>
<groupId>io.jboot</groupId>
<artifactId>jboot</artifactId>
</dependency>
<dependency>
<groupId>io.jpress</groupId>
<artifactId>jpress-commons</artifactId>
</dependency>
<dependency>
<groupId>io.jpress</groupId>
<artifactId>jpress-core</artifactId>
</dependency>
</dependencies>
3.2 BaseSinglePage
Inherit JbootModel, and JbootModel Inherited from jfinal.plugin.activerecord.Model, Realization IBean Interface .
- Defines the basic properties of a page and its properties get and set Method .
- Model yes ActiveRecord One of the most important components in , It acts as MVC In the pattern Model part .
- One Model Corresponding to a piece of data in the database .
- BaseSinglePage By inheritance Model, There are many convenient ways to operate the database . be based on ActiveRecord Of Model There is no need to define properties , There is no need to define getter、setter Method , There is no need to XML To configure , There is no need to Annotation To configure , Greatly reduces the amount of code .
- stay BaseSinglePage in , Defines the corresponding attributes in the database table set and get Method . The code example is as follows :
/**
* Primary key ID
*/
public void setId(java.lang.Long id) {
set("id", id);
}
/**
* Primary key ID
*/
public java.lang.Long getId() {
return getLong("id");
}
BaseSinglePageComment And BaseSinglePage The implementation side of is the same , Just different functions , Defines the basic attributes of a comment and its get and set Method .
3.3 SinglePage
Inherit BaseSinglePage<M extends BaseSinglePage<M>>.
- Use @Table annotation , Specify the corresponding database table name as single_page, And its parent class BaseSinglePage Medium set and get Method is used as the relevant data in the operation table . Table is defined as follows :

- The above fields are the settings of relevant parameters of a page . Page html The code is based on text The form is stored in content in .
- Define page state : Release ( normal )、 draft 、 dustbin .
- Override some methods of the parent class , Define the variables and acquisition methods of the new page .
public String getHtmlView() {
return StrUtil.isBlank(getStyle()) ? "page.html" : "page_" + getStyle().trim() + ".html";
}
public String getUrl() {
return UrlUtils.getUrl("/", StrUtil.isNotBlank(getSlug()) ? getSlug() : getId());
}
public String getUrlWithPageNumber(int pageNumber) {
if (pageNumber <= 1) {
return getUrl();
}
SinglePageComment And SinglePage Is implemented in the same way , Just different functions , It also rewrites some methods of the parent class , Variables that define the status of new comments , And how to change the comment status .
Four 、 summary
This article mainly analyzes module-page The architecture and of module-page-model Module code analysis , It is found that... Is used in this project jboot, Encapsulates the Jfinal, Adopted JFinal As the core ,JPress It's also benefited from JFinal Flexible architecture . So in the later code analysis , Yes JFinal Mastering is a necessary way to analyze code .
版权声明
本文为[indaeyo]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/04/202204212013209153.html
边栏推荐
- How to check the slow response of the system with high CPU?
- CUDA02 - 访存优化和Unified Memory
- 如何利用 xUnit 框架对测试用例进行维护?
- Android Development Internship interview questions, Android development interview basis
- 华融融达期货这家公司怎么样?期货开户办理安全吗?
- How to solve the thread safety problem without locking
- The difference between PE P / E ratios
- 如何在不加锁的情况下解决线程安全问题
- JS monitor mobile phone screen rotation (horizontal screen or vertical screen)
- Share the advantages of Intranet instant messaging software
猜你喜欢
![[gradle] problem analysis + download and installation + environment configuration + installation verification](/img/a6/d6ea65127fbbed259f5f22faf23839.png)
[gradle] problem analysis + download and installation + environment configuration + installation verification

Three implementation methods of quick sorting

<2021SC@SDUSC>山东大学软件工程应用与实践JPress代码分析(一)

getchar,putchar,EOF

Meaning of stripe in image

3D 沙盒游戏之人物的点击行走移动

Jmeter关联参数

Data preprocessing for data analysis

Jmeter如何设置参数化
C# Mandelbrot和Julia分形图像生成程序更新到2010-9-14版 支持多线程计算 多核处理器
随机推荐
Mandelbrot集的最新变化形态一览——MandelBox,Mandelbulb,Burning Ship,NebulaBrot
[turn] Chinese technology of FC (red and white machine) game files
Gbase 8A set group_ concat_ max_ Solution to error reporting after len parameter
Efficient C language memory copy Test result Rand, loop, operator =% in x86-64 SUSE
MFC CCombobox usage example
Source insight configuration and problem summary
解决composer报错:Could not find a version of package xxx/yyy
Discussion on the hot and cold issues of open source license grounding gas
Three implementation methods of quick sorting
The difference and relationship between glew, glee and GL Glu glut GLX glext
warning: LF will be replaced by CRLF in composer.json.
php UEditor上传文件(图片视频)到OSS
Lenovo announced the new progress of ESG: it promised that 100% of all computer products would contain recycled plastics by 2025
After three years of graduation, he achieved nothing and was forced to go back to his hometown. He made a decision to change his life.
如何在不加锁的情况下解决线程安全问题
glew, glee与 gl glu glut glx glext的区别和关系
Solution of "unable to load and save data" in Eldon law ring
【原】通俗说法所谓数码相机的“动态像素”和“静态像素”背后的故事
After learning this tutorial of capturing packages by Charles, I unloaded Fiddler directly
Multi factor strategy