This is the 25th day of my participation in the November Gwen Challenge. Check out the event details: The last Gwen Challenge 2021

In a previous article, we reviewed the package of PageHeler com. Making. Pagehelper and subpackage com. Making. Pagehelper) class and structure of the cache, And through the cache package Class writing method to understand the factory mode and Java in another kind of loading and creating object method: class.forname, and through GuavaCache and SimpleCache familiar with xxxBuilder to create objects.

Reading source code is like reading articles

Today we are going to learn another child package: com. Making. Pagehelper) page. (according to the letter size should speak com. Making. Pagehelper. Package the dialect, the dialect is more complex, however, let’s put it, to understand the other part in turn to see it again.)

Page package

There are four files in the Page package with the following basic comments:

Pageautodialect.java: Basic dialect information.

PageBoundSqlInterceptors. Java.

Pagemethod. Java: Basic paging method.

Pageparams. Java: parameter information

Let’s go through them all.

PageParams

PageParams, parameter information, including attributes including: (pageNum), rowBoundsWithCount (Boolean), pageSizeZero (Boolean), reasonable (Boolean) Paging rationalization), Support MethodSa guments (Boolean value, whether or not you support interface parameters to pass paging parameters), countColumn (string, default 0). Methods have two other methods in addition to the basic setter/getter:

Page getPage(Object parameterObject, RowBounds rowBounds)

And the method of initializing objects through configuration:

void setProperties(Properties properties)

SetProperties makes extensive use of the methods of the java.util.Properties class. Let’s take a look at this Generic Java utility.

Java.util.properties implements the interfaces Map,Serializable, Clonable, and the class is thread-safe, meaning that multiple threads can share a single Properties object without external synchronization. The two main methods are: getProperty value getProperty(String key) and setProperty value setProperty(String key, String value).

Other common methods include loading from a file: Load (InputStream), writing configuration to a file store(OutStream, String Comments), etc.

PageBoundSqlInterceptors

This class includes an interface parameter values BoundSqlInterceptor. Chain and getter methods, as well as another way to void setProperties (Properties Properties).

By reading the code, we can see that setProperties is actually a setter method on the Chain: By configuring multiple Class names on the boundSqlInterceptors parameter and creating its object entities through class.forname (xx).newinstance (), Then call the constructor of BoundSqlInterceptorChain (an implementation of the Chain interface) to create a Chain entity object.

In other words, thus the SQL interceptor according to certain order is saved in the PageBoundSqlInterceptors. In the chain.