Java Backend Server Analytics

Source: Internet
Author: User

First look at the structure diagram:

Previously did not write server-side code, the project has a separate service side, read the code, feel well written, feel that the original author should have seen some open source code, framework and design-at least not before the design of the server-side code structure.

Summarize the main design:

1. The server must need a servers, where the serversocket of the Java network is used as the basis for the service side

2. The server includes two aspects: (1) configuration classes and configuration files for the true service-side service

(2) The service side itself

3. From the 2nd can be known, when the service starts, it is necessary to pre-load the configuration, will first execute the Mainserver init method, that is, load the configuration, where a configuration Entry class config is used, and the main configuration file is passed in

3.1 After the server boot to config, the main configuration file can be loaded, as shown in the figure, there is more than one configuration file, which is related to the framework, business

3.2 The main configuration file contains the configuration file path for each specific category, such as log,server,spring ... This is followed by an object-oriented embodiment, similar to the other frameworks, where each configuration file corresponds to its respective context and config (and ServletContext and ServletConfig types)

3.3 Specific to parse the configuration file, the actual configuration set to the respective Config, config is generally static, and its method is generally static, the life cycle is very long, convenient, but attention not to load multiple times

The 3.4init method executes, and the server obtains the required config, which can be used later

4. Server-Side code startup

4.1, and the above configuration file types, each different business corresponding to their own separate server, they have inherited the baseserver, dealing with common problems, this and actionsupport similar

4.2 Start the respective server (server is a thread, has its own port), start, you can use the 3rd step in the initialization of the config, and the config is inserted as required, at the same time, each server has its own thread pool to handle this type of request;

4.3 Each server corresponds to a processing class handler, in handler, has obtained the request socket, and the server is similar, handler can also inherit from a parent class handler, processing the continuity problem, of course, can also be personalized implementation, The main method of this process is the process class

4.4 At this point, the request has basically been read, according to the object-oriented thinking (and HTTP request similar), should be encapsulated into object--request, response response can be encapsulated in the following (? ), note here, still for continuity, a generic parent message is defined for the request, and the specific request expands

4.5 Follow-up will continue to invoke the specific service, defined by the parent class interface, implementation of the respective subclasses, different sub-classes

Java Backend Server Analytics

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.