CN110471651A - A kind of method and server-side for realizing control reversion based on C++ - Google Patents

A kind of method and server-side for realizing control reversion based on C++ Download PDF

Info

Publication number
CN110471651A
CN110471651A CN201910703365.3A CN201910703365A CN110471651A CN 110471651 A CN110471651 A CN 110471651A CN 201910703365 A CN201910703365 A CN 201910703365A CN 110471651 A CN110471651 A CN 110471651A
Authority
CN
China
Prior art keywords
service
access request
server
work
dynamic base
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Pending
Application number
CN201910703365.3A
Other languages
Chinese (zh)
Inventor
黄凯
张翔
谭梦迪
华龙宇
徐鑫
刘爱娣
张巍
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
BEIJING SUTONG TECHNOLOGY Co Ltd
Original Assignee
BEIJING SUTONG TECHNOLOGY Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by BEIJING SUTONG TECHNOLOGY Co Ltd filed Critical BEIJING SUTONG TECHNOLOGY Co Ltd
Priority to CN201910703365.3A priority Critical patent/CN110471651A/en
Publication of CN110471651A publication Critical patent/CN110471651A/en
Pending legal-status Critical Current

Links

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F8/00Arrangements for software engineering
    • G06F8/30Creation or generation of source code
    • G06F8/31Programming languages or programming paradigms
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F8/00Arrangements for software engineering
    • G06F8/40Transformation of program code
    • G06F8/41Compilation

Abstract

The application discloses a kind of method and server-side that control reversion is realized based on C++, is related to field of computer technology, the control inverting method includes that service logic is split as different submodules according to different function by C++;Each submodule is encapsulated as mutually independent dynamic base;When receiving the access request of client transmission, the service after instantiation is returned to client using the service in access request parameters instantiation dynamic base by the platform framework realized by C++, is realized and is relied on injection control reversion.The server-side includes master control management level, communication management layer and work disposal layer.Using the skeleton of the application, post-service can be made to change without relying on compiling platform, so that being independent of each other between platform, it is flexibly controllable that load can not only be made, and greatly reduce the coupling of platform and service, improve the scalability of platform.

Description

A kind of method and server-side for realizing control reversion based on C++
Technical field
This application involves field of computer technology more particularly to a kind of methods and service that control reversion is realized based on C++ End.
Background technique
With apps servers various in network gradually increase and the continuous promotion of performance, service and system Design it is also more and more numerous and more jumbled.Traditional apps server realize service needed for service logic when, be all mostly by Two or more classes are reached by cooperation each other.This makes each object require to obtain pair that it is relied on The reference of elephant certainly will so lead to being highly coupled for code, so that service module is difficult to work independently, and then influence follow-up business Extension and maintenance.
In addition, IoC/DI container can be relied in existing Java/.Net, instantiated by the class name in configuration file It carries out relying on injection control reversion, but the server platform frame realized currently based on C++, also not useful dependence injection is to realize Control reversion, to achieve the purpose that reduce system module coupling.
Summary of the invention
This application provides a kind of methods for realizing control reversion based on C++, include the following steps:
Service logic is split as different submodules according to different function by C++;
Each submodule is encapsulated as mutually independent dynamic base;
When receiving the access request of client transmission, access request parameters are used by the platform framework that C++ is realized The service in dynamic base is instantiated, the service after instantiation is returned into client, realizes and relies on injection control reversion.
The method that control reversion is realized based on C++ as described above, wherein each submodule is encapsulated as mutually independent dynamic State library specifically includes following sub-step;
Precompile is carried out to the source code file of each submodule;
The file that each submodule precompile is completed is compiled, corresponding assembly code file is generated;
Assembly code file is linked into an executable command, and generates dynamic link library and static state under engineering catalogue Library.
The method that control reversion is realized based on C++ as described above, wherein each submodule is packaged into independent dynamic Further include distributing unique index for each dynamic base behind library, presets according to the external device access request ginseng received Number can determine unique dynamic base, can find corresponding unique business.
The method that control reversion is realized based on C++ as described above, wherein using access by the platform framework that C++ is realized Required parameter instantiates the service in dynamic base, specially searches corresponding dynamic base according to the parameter of access request, will dynamic Service instantiation in library.
The application also provides a kind of server-side, including master control management level, communication management layer and work disposal layer;
Telecommunication media of the communication management layer as server-side and client, be responsible for client access request access/pick out;
Master control management level monitor interprocess communication and work for managing the communication management layer and work disposal layer being attached thereto Process existing state;
Work disposal layer executes the above-mentioned method for realizing control reversion based on C++, by processing result Returning communication management level.
Server-side as described above, wherein master control management level monitoring interprocess communication and progress of work existing state, work as communication When there is the unexpected process hung and in process or the progress of work, the process is restarted.
Server-side as described above, wherein master control management level are also used to the starting of monitoring service, visit when receiving client When asking request, master control management level are responsible for monitoring the handling duration of service corresponding with the access request, and according to the spy of the service Determine service type and default timeout threshold, the processing method after determining time-out.
Server-side as described above, wherein communication management layer when receiving client access request, establish server-side and The communication connection of client parses access request using multithreading based on I/O multiplexing, according to access request In type of service distribute to the process processing of corresponding responsibility, thread-safe is guaranteed by message queue mechanism and thread lock, so Message, parallel processing access request between thread are transmitted by shared drive afterwards, and access request is forwarded to work disposal layer.
Server-side as described above wherein includes multiple independent progresses of work in work disposal layer, each work The access request that process is used to be forwarded according to communication management layer calls the corresponding with service in dynamic base, when work disposal layer receives After the access request of communication management layer, dynamic base is called according to the type of service in access request, by corresponding in dynamic base Processing result is back to communication management layer after being disposed by service processing related service logic.
Server-side as described above, wherein further including database, the database is connect with work disposal layer, is used for work The business datum for dealing with layer carries out persistence processing, i.e., the instantaneous traffic lasting data in memory is turned to the lasting of database Data carry out long-term preservation.
What the application realized has the beneficial effect that: using the skeleton of the application, post-service can be made to change nothing Compiling platform need to be relied on, so that being independent of each other between platform, it is flexibly controllable that load can not only be made, and greatly reduce platform With the coupling of service, the scalability of platform is improved.
Detailed description of the invention
In order to more clearly explain the embodiment of the invention or the technical proposal in the existing technology, to embodiment or will show below There is attached drawing needed in technical description to be briefly described, it should be apparent that, the accompanying drawings in the following description is only this The some embodiments recorded in invention can also be obtained according to these attached drawings other for those of ordinary skill in the art Attached drawing.
Fig. 1 is the server-side schematic diagram that the embodiment of the present application one provides;
Fig. 2 is existing server-side application program service operation schematic diagram;
Fig. 3 is server-side application program service operation schematic diagram provided by the present application;
Fig. 4 is the method flow diagram for the control reversion that the embodiment of the present application two provides.
Specific embodiment
With reference to the attached drawing in the embodiment of the present invention, technical solution in the embodiment of the present invention carries out clear, complete Ground description, it is clear that described embodiments are some of the embodiments of the present invention, instead of all the embodiments.Based on the present invention In embodiment, those skilled in the art's every other embodiment obtained without making creative work, all Belong to the scope of protection of the invention.
Embodiment one
In order to which the server platform framework for enabling C++ to realize controls reversion, to reach the mesh of service and system loose coupling , while can be realized the flexibility of process distribution, this application provides a kind of architecture systems based on C/S, including client It (Client) and server-side (Server), include realizing that platform framework and each functional module encapsulate with C++ in server-side Dynamic base;
As shown in Figure 1, the server-side includes master control management level, communication management layer, work disposal layer and database;Its In, master control management level connecting communication management level and work disposal layer, communication management layer are connect with work disposal layer, work disposal layer It is connect with database.
Specifically, master control management level are for manage the communication management layer and work disposal layer being attached thereto, monitor communicate into Journey and progress of work existing state, when there is the unexpected process hung and in interprocess communication or the progress of work, restarting should be into Journey, it is ensured that the stability and safety of platform;
In addition, master control management level are also used to the starting of monitoring service, when receive client (architecture system based on C/S, Including server-side and client) access request when, master control management level are responsible for monitoring the processing of service corresponding with the access request Duration, and according to the particular type of service of the service and default timeout threshold, the processing method after determining time-out, reduces service Waiting time improves the response speed of service.
Telecommunication media of the communication management layer as server-side and client, be responsible for client access request access/pick out, When receiving client access request, it is successfully established the communication connection of server-side and client, is based on I/O multiplexing technique (I/O refers to network I/O, and multichannel refers to multiple TCP connections, and multiplexing refers to that one or several threads of multiplexing, I/O multiplexing technique are One or a set of multiple TCP connections of thread process it is small to reduce overhead, it is not necessary to create excessive process/thread, need not also tie up Protect these process/threads), communication management layer parses access using multithreading, according to the business in access request Type distributes to the process processing of corresponding responsibility, guarantees thread-safe by message queue mechanism and thread lock, then by altogether Memory transmitting message, parallel processing access request between thread are enjoyed, and access request is forwarded to work disposal layer;
In the embodiment of the present application, communication management layer can be closed using the access request that multithreading processing client is sent Reason efficiently utilizes server multicore advantage and server resource, significantly lifting system processing capacity;In addition, communication management layer Time limit alleviation system processing pressure can be accessed on peak using message queue and thread lock mechanism, avoided because of processing capacity deficiency And cause to service the appearance of situations such as unavailable;
Preferably, the application uses interaction bridge of the shared drive as communication management layer and work disposal layer, for communication Management level are interacted with the communication of work disposal layer provides the highest Inter-Process Communication technology of efficiency, so that all interactive operations are all Safety is completed in memory, and can customized memory according to actual needs distribution;Communication management layer uses this process as a result, Distribution mechanisms enhance the specificity and specific aim of processing capacity, improve treatment effeciency, further increase the stability of system.
It include multiple independent progresses of work in the work disposal layer, each progress of work is used for according to communication pipe The corresponding with service in the access request calling dynamic base of layer forwarding is managed, when the access that work disposal layer receives communication management layer is asked After asking, dynamic base is called according to the type of service in access request, is patrolled by service processing related service corresponding in dynamic base Volume, processing result is back to communication management layer after being disposed;
As shown in Fig. 2, when needing, in entity X, (entity abstract representation is any in the application program service of existing server-side The hardware or software process of information can be sent or received) it is middle using entity Z, then pair of entity Z can be created directly in entity X As external resource Z required for actively being obtained that is, in entity X;However using existing mode entity X need to obtain it institute according to The object reference of bad entity Z, therefore the code needs of entity X and entity Z are highly coupled;
As shown in figure 3, the application is in work disposal layer in order to reduce the coupling of currently existing scheme entity X Yu entity Z The loose coupling that entity X and entity Z are realized using the method for inverse injection control reversion, specially when entity X is needed using entity Z When, the object of entity Z is no longer actively created, but passively waited, it is obtained by the platform framework that C++ is realized based on container technique Then the example of entity Z is reversely injected into entity X by the example for taking an entity Z, realize that the control for relying on injection is anti-with this Turn, reduce the degree of coupling of entity X and entity Z, guarantees the loose coupling of platform and service.
In addition, the database in the server-side is connect with work disposal layer, for by the business datum of work disposal layer Persistence processing is carried out, i.e., the persistant data that the instantaneous traffic lasting data in memory turns to database is subjected to long-term preservation.
Embodiment two
The embodiment of the present application two provides a kind of method of control reversion, as shown in figure 4, including the following steps:
Service logic is split as different submodules according to different function by C++ by step 410;
Specifically, the business in server-side is split according to business function, for example, server-side business includes but unlimited In management business, more new business, payment transaction etc., server-side business is split as to different submodules, that is, is split as management Module, update submodule, payment submodule etc..
Each submodule is encapsulated as mutually independent dynamic base by step 420;
In the present embodiment, each submodule is encapsulated as mutually independent dynamic base and specifically includes following sub-step:
Step 421 carries out precompile to the source code file of each submodule;
Wherein precompile is specially and pre-processes to source code file, what processing was started in source code file with " # " Precompile instruction, such as macro expansion, treatment conditions compiling instruction, processing #include instruction etc.;
The file that each submodule precompile is completed is compiled by step 422, generates corresponding assembly code file;
Specifically, the assembly code in the file of precompile completion is converted into binary file.
Assembly code file is linked into an executable command, and generates dynamic link under engineering catalogue by step 423 Library and static library;
Specifically, there are two files, i.e. LIB file (static library) and dll file (dynamic base) for dynamic link library needs, preceding Person uses when being compiling, and the latter uses when being operation.
In the present embodiment, after each submodule is packaged into independent dynamic base, unique rope is distributed for each dynamic base Draw, presets and unique dynamic base can determine according to the external device access required parameter received, can find Corresponding unique business.
Step 430, when receive client transmission access request when, by C++ realize platform framework using access Required parameter instantiates the service in dynamic base, and the service after instantiation is returned to client, realizes that dependence injection control is anti- Turn.
Specifically, after receiving the access request of client transmission, server-side is according to the lookup pair of the parameter of access request Then the example of service in dynamic base is returned to client, thus by the service instantiation in dynamic base by the dynamic base answered The Service Instance for creating the server-side to be accessed in advance in the client is not needed, it is directly that the Service Instance in dynamic base is reversed The data interaction of client and server-side can be realized in injection client, and can be realized the loose coupling of platform framework and service.
Following technical effect is reached using the technical solution of the application:
(1) skeleton for using the application can be such that post-service changes without relying on compiling platform, so that platform Between be independent of each other, load can not only be made flexibly controllable, and greatly reduce the coupling of platform and service, improve platform Scalability;
(2) technical solution of the application can accomplish very careful change without influencing other business moulds in later maintenance The purpose of block;
(3) it is all main that the dependence injection control inverting method that the application uses, which breaks existing application to obtain external resource, The dynamic conventional thought launched an attack, realizes the loose coupling of principal and subordinate's transposition, so that calling program overall structure is become very flexible, and this changes Into being not available for existing C++ frame.
Although the preferred embodiment of the application has been described, it is created once a person skilled in the art knows basic Property concept, then additional changes and modifications may be made to these embodiments.So it includes excellent that the following claims are intended to be interpreted as It selects embodiment and falls into all change and modification of the application range.Obviously, those skilled in the art can be to the application Various modification and variations are carried out without departing from spirit and scope.If in this way, these modifications and variations of the application Belong within the scope of the claim of this application and its equivalent technologies, then the application is also intended to encompass these modification and variations and exists It is interior.

Claims (10)

1. a kind of method for realizing control reversion based on C++, which comprises the steps of:
Service logic is split as different submodules according to different function by C++;
Each submodule is encapsulated as mutually independent dynamic base;
When receiving the access request of client transmission, access request parameters example is used by the platform framework that C++ is realized Change the service in dynamic base, the service after instantiation is returned into client, realizes and rely on injection control reversion.
2. the method for realizing control reversion based on C++ as described in claim 1, which is characterized in that each submodule to be encapsulated as Mutually independent dynamic base specifically includes following sub-step;
Precompile is carried out to the source code file of each submodule;
The file that each submodule precompile is completed is compiled, corresponding assembly code file is generated;
Assembly code file is linked into an executable command, and generates dynamic link library and static library under engineering catalogue.
3. the method for realizing control reversion based on C++ as claimed in claim 1 or 2, which is characterized in that seal each submodule After dressing up independent dynamic base, further includes distributing unique index for each dynamic base, preset according to the outside received Equipment access request parameters can determine unique dynamic base, can find corresponding unique business.
4. the method for realizing control reversion based on C++ as claimed in claim 3, which is characterized in that the platform realized by C++ Frame is specially searched according to the parameter of access request corresponding dynamic using the service in access request parameters instantiation dynamic base State library, by the service instantiation in dynamic base.
5. a kind of server-side, which is characterized in that including master control management level, communication management layer and work disposal layer;
Telecommunication media of the communication management layer as server-side and client, be responsible for client access request access/pick out;
Master control management level monitor interprocess communication and the progress of work for managing the communication management layer and work disposal layer being attached thereto Existing state;
Work disposal layer executes the method for realizing control reversion based on C++ as described in any one of claim 1-4, will locate Manage result Returning communication management level.
6. server-side as claimed in claim 5, which is characterized in that master control management level monitor interprocess communication and progress of work survival State restarts the process when there is the unexpected process hung and in interprocess communication or the progress of work.
7. server-side as claimed in claim 5, which is characterized in that master control management level are also used to the starting of monitoring service, when connecing When receiving client access request, master control management level are responsible for monitoring the handling duration of service corresponding with the access request, and root Processing method according to the particular type of service and default timeout threshold of the service, after determining time-out.
8. server-side as claimed in claim 5, which is characterized in that communication management layer when receiving client access request, The communication connection for establishing server-side and client parses access request using multithreading based on I/O multiplexing, The process processing that corresponding responsibility is distributed to according to the type of service in access request, is guaranteed by message queue mechanism and thread lock Then thread-safe transmits message, parallel processing access request between thread by shared drive, and access request is forwarded to Work disposal layer.
9. server-side as claimed in claim 5, which is characterized in that include in work disposal layer it is multiple it is independent work into Journey, the access request that each progress of work is used to be forwarded according to communication management layer call the corresponding with service in dynamic base, work as work After dealing with the access request that layer receives communication management layer, dynamic base is called according to the type of service in access request, is passed through Corresponding service processing related service logic, is back to communication management layer for processing result after being disposed in dynamic base.
10. server-side as claimed in claim 5, which is characterized in that it further include database, the database and work disposal layer Connection, for the business datum of work disposal layer to be carried out persistence processing, i.e., by the instantaneous traffic data persistence in memory Long-term preservation is carried out for the persistant data of database.
CN201910703365.3A 2019-07-31 2019-07-31 A kind of method and server-side for realizing control reversion based on C++ Pending CN110471651A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201910703365.3A CN110471651A (en) 2019-07-31 2019-07-31 A kind of method and server-side for realizing control reversion based on C++

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201910703365.3A CN110471651A (en) 2019-07-31 2019-07-31 A kind of method and server-side for realizing control reversion based on C++

Publications (1)

Publication Number Publication Date
CN110471651A true CN110471651A (en) 2019-11-19

Family

ID=68509606

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201910703365.3A Pending CN110471651A (en) 2019-07-31 2019-07-31 A kind of method and server-side for realizing control reversion based on C++

Country Status (1)

Country Link
CN (1) CN110471651A (en)

Cited By (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN111522535A (en) * 2020-03-26 2020-08-11 杭州数跑科技有限公司 Data source aggregation method and device, storage medium and computer equipment
CN111857675A (en) * 2020-08-03 2020-10-30 北京思特奇信息技术股份有限公司 Method and system for realizing RESTFUL service based on C + +
CN112051988A (en) * 2020-09-15 2020-12-08 北京达佳互联信息技术有限公司 Module processing method and device and server
CN112130863A (en) * 2020-08-18 2020-12-25 许继集团有限公司 Protection method for preventing disassembly of client program

Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
KR20070112755A (en) * 2007-11-07 2007-11-27 정안모 A method for software development and operation based on component reuse and dependency injection
US20080276231A1 (en) * 2007-05-03 2008-11-06 Yunwu Huang Method and apparatus for dependency injection by static code generation
US20120233591A1 (en) * 2011-03-11 2012-09-13 Sivakumar Melapannai Thyagarajan Type-safe Dependency Injection of Services into Enterprise Components
US20160092246A1 (en) * 2014-09-26 2016-03-31 Oracle International Corporation Reverse dependency injection in a system with dynamic code loading
CN109213605A (en) * 2018-09-17 2019-01-15 上海高顿教育培训有限公司 A kind of server I suitable for high concurrent scene/O implementation method

Patent Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20080276231A1 (en) * 2007-05-03 2008-11-06 Yunwu Huang Method and apparatus for dependency injection by static code generation
KR20070112755A (en) * 2007-11-07 2007-11-27 정안모 A method for software development and operation based on component reuse and dependency injection
US20120233591A1 (en) * 2011-03-11 2012-09-13 Sivakumar Melapannai Thyagarajan Type-safe Dependency Injection of Services into Enterprise Components
US20160092246A1 (en) * 2014-09-26 2016-03-31 Oracle International Corporation Reverse dependency injection in a system with dynamic code loading
CN109213605A (en) * 2018-09-17 2019-01-15 上海高顿教育培训有限公司 A kind of server I suitable for high concurrent scene/O implementation method

Non-Patent Citations (1)

* Cited by examiner, † Cited by third party
Title
龚箭: "依赖注入机制在电能质量智能信息系统的应用", 《中国优秀硕士学位论文全文数据库 工程科技Ⅱ辑》 *

Cited By (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN111522535A (en) * 2020-03-26 2020-08-11 杭州数跑科技有限公司 Data source aggregation method and device, storage medium and computer equipment
CN111857675A (en) * 2020-08-03 2020-10-30 北京思特奇信息技术股份有限公司 Method and system for realizing RESTFUL service based on C + +
CN111857675B (en) * 2020-08-03 2023-07-11 北京思特奇信息技术股份有限公司 Method and system for realizing RESTFUL service based on C++
CN112130863A (en) * 2020-08-18 2020-12-25 许继集团有限公司 Protection method for preventing disassembly of client program
CN112130863B (en) * 2020-08-18 2023-10-20 许继集团有限公司 Protection method for preventing disassembly of client program
CN112051988A (en) * 2020-09-15 2020-12-08 北京达佳互联信息技术有限公司 Module processing method and device and server

Similar Documents

Publication Publication Date Title
CN110471651A (en) A kind of method and server-side for realizing control reversion based on C++
CN107005567B (en) Implementing communication events
US7415522B2 (en) Extensible framework for transferring session state
CN100527086C (en) Modular event-driven processing
US20190340033A1 (en) Systems and methods for cloud computing data procesing
US6317773B1 (en) System and method for creating an object oriented transaction service that interoperates with procedural transaction coordinators
CN111352653B (en) System development method based on PaaS cloud platform server and server
CN107835181A (en) Right management method, device, medium and the electronic equipment of server cluster
CN112596931A (en) Cross-process communication method and device, electronic equipment and storage medium
CN110062041B (en) Method and device for changing IOT (input/output) equipment based on block chain
CN109343970A (en) Operating method, device, electronic equipment and computer media based on application program
CN112529711B (en) Transaction processing method and device based on block chain virtual machine multiplexing
US20190278639A1 (en) Service for enabling legacy mainframe applications to invoke java classes in a service address space
KR20210040322A (en) Scheduling method and apparatus, device and storage medium
US20030055965A1 (en) User-defined units of context in a distributed computer environment
CN112395570A (en) Alliance chain intelligent contract calling authority control method, system and storage medium
CN104717249A (en) Method for issuing remote operation application, proxy server and system
US11816204B2 (en) Multi-tenant actor systems with web assembly
CN109522111A (en) Call method, device, electronic equipment and the storage medium of the isomery ecosystem
CN109683875A (en) The application framework and its method of MVC pattern under distributed environment
CN112256408A (en) Micro-service global context control method and system
CN112187570A (en) Risk detection method and device, electronic equipment and readable storage medium
CN114006913A (en) Distributed lock processing method and device
CN107479903A (en) The method of flexible control service module based on Dubbo frameworks
CN116909779B (en) Message processing method and device and related equipment

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination