CN104267974A - Method and device for calling business interface - Google Patents
- ️Wed Jan 07 2015
Embodiment
The present invention program is understood better in order to make those skilled in the art person, below in conjunction with the accompanying drawing in the embodiment of the present invention, technical scheme in the embodiment of the present invention is clearly and completely described, obviously, described embodiment is only the embodiment of a part of the present invention, instead of whole embodiments.Based on the embodiment in the present invention, those of ordinary skill in the art, not making the every other embodiment obtained under creative work prerequisite, should belong to the scope of protection of the invention.
It should be noted that, term " first ", " second " etc. in instructions of the present invention and claims and above-mentioned accompanying drawing are for distinguishing similar object, and need not be used for describing specific order or precedence.Should be appreciated that the data used like this can be exchanged in the appropriate case, so as embodiments of the invention described herein can with except here diagram or describe those except order implement.In addition, term " comprises " and " having " and their any distortion, intention is to cover not exclusive comprising, such as, contain those steps or unit that the process of series of steps or unit, method, system, product or equipment is not necessarily limited to clearly list, but can comprise clearly do not list or for intrinsic other step of these processes, method, product or equipment or unit.
Embodiment 1
According to the embodiment of the present invention, provide a kind of embodiment of call method of business interface, it should be noted that, can perform in the computer system of such as one group of computer executable instructions in the step shown in the process flow diagram of accompanying drawing, and, although show logical order in flow charts, in some cases, can be different from the step shown or described by order execution herein.
The embodiment of the method that the embodiment of the present application one provides can perform in mobile intelligent terminal, arithmetic unit with the intelligent terminal of touch sensitive screen.To operate on mobile intelligent terminal, Fig. 1 is the process flow diagram of the call method of a kind of business interface of the embodiment of the present invention.As shown in Figure 1, the call method of this business interface can implementation step as follows:
Step S12, sends renewal data request information according to Business Entity configuration information to Business Entity server.
In above-mentioned steps S12, business module, according to the configuration information of Business Entity, sends the information upgrading request of data for obtaining Business Entity to Business Entity server.
Step S14, receives Business Entity server according to the more new data upgrading the Business Entity that data request information returns.
In above-mentioned steps S14, server end is receiving the renewal data request information of Business Entity, according to the content upgrading data request information, sends the content corresponding with the content upgrading data request information.
Step S16, according to Business Entity configuration information, carrying out Data Analysis to the more new data of the Business Entity returned according to Business Entity configuration information, is the data layout that Business Entity can identify by the renewal Data Analysis of the Business Entity returned.
In above-mentioned steps S16, by Business Entity configuration information, according to the content in configuration information, Data Analysis is carried out to the more new data of the Business Entity returned.The renewal data message returned is resolved to the data layout that Business Entity can directly read.
Step S18, will resolve to the renewal data syn-chronization of the Business Entity that Business Entity can identify to Business Entity.
In above-mentioned steps S18, renewal data message is resolved to Business Entity after the information of Direct Recognition, can be synchronized in Business Entity, carry out for Business Entity.
In the embodiment of the present application one, be a kind of automatically according to the method that physical arrangements information (entity configuration) is initiated the data call request that Business Entity upgrades to Business Entity server.The method is resolved by the renewal data message returned server service property server, and the renewal data message parsed is synchronized in corresponding thread, uses for Business Entity.Wherein, Business Entity can have multiple, and these different Business Entities can use identical calling logic, resolution logic and thread synchronization logic.This method is by the whole Business Entity of scanning, and after setting up the corresponding relation of Business Entity and Business Entity server, the data type of the renewal data message returned according to Business Entity server goes to select in physical arrangements information corresponding to this data type.Finally the renewal data message returned is resolved to the example (instance) that can be used for Business Entity freely to use.In this way, eliminate the method for the request of writing of different business entity and parsing when exploitation, avoid code overlapping development, greatly save time and the cost of exploitation.In actual applications, Business Entity server can be independent server, also can be some in multiple corresponding with the Business Entity interface that server provides.
Here, above-mentioned steps can be put into three abstract modules and carry out, three abstract modules comprise: abstract service module, abstract data parsing module and abstract network module.
Wherein, abstract service module, is responsible for the data type of collecting Business Entity, for business transferring physical arrangements information and data type.Heavy business consuming time can be put into asynchronous thread to perform, avoid blocking main thread for a long time.And be responsible for the data transmission of sub-thread and front-end interface thread (UI thread), facilitate other functions to use.The Data Analysis function of the data communication facility of abstract network module and abstract data solution module organically combines and it is encapsulated in the private method of abstract service module by this module, externally only exposes using method, greatly strengthen the extensibility of abstract service.
Wherein, abstract data parsing module, is responsible for resolving the data transmitted between Business Entity and Business Entity server.This module abstracts Data Analysis interface, can resolve various data layout (including but not limited to JSON, XML, binary stream, user-defined format etc.) easily.This module does not rely on abstract network module, does not relate to any business, convenient data message of resolving various different Business Entity.Itself also has nothing to do with the data layout of reality, and takes out expansion interface with the parsing facilitating expansion to support more data form.
Wherein, abstract network module, is responsible for the network call of Business Entity and Business Entity server.This module abstracts goes out network request interface, network request can be based upon completely on the network plan (such as: HTTP, SOCKET) of existing maturation with this.This module does not rely on abstract data parsing module, does not relate to any business yet.Can the very convenient network request setting up different business on this basis.
The application program that the step S12 that the above embodiments of the present application one provide to step S18 can run on mobile intelligent terminal uses, in implementation process, a kind of embodiment of the application program run on mobile intelligent terminal in above-described embodiment one, it can be the news client run on mobile intelligent terminal, below just for this news client, above-described embodiment one is described in detail.
In news client, multiple news column can be there is, such as: hot news plate, financial and economic news column, science and technology news column, sports news column etc.Wherein each news column can regard it as a Business Entity.Each news column has respective configuration mode.When carrying out refresh operation to some news columns, client sends Data Update request according to the configuration information of this news column to the server corresponding with this column or server interface.After server receives update request, return the concrete update content of news client by according to the update request received.After news client receives update content, news client is resolved update content.Update content, according to the configuration information of this news template, is resolved to the data layout that this plate can directly use by news client, and is sent to this plate by after parsing to fresh content, uses for this column.
Preferably, as shown in Figure 2, in the above embodiments of the present application one, before sending in step S12 the step upgrading data request information to Business Entity server according to Business Entity configuration information, following implementation step can also be performed:
Step S10, obtains the physical arrangements information of Business Entity.Wherein, physical arrangements information at least comprises: Business Entity server network address, Business Entity server interface title, the data layout upgrading content data request, upgrade request of data mode, return.
In above-mentioned steps S10, by the reading to Business Entity, scanning, obtain the configuration information of Business Entity.Wherein configuration information at least comprises: Business Entity server network address, Business Entity server interface title, the data layout upgrading content data request, upgrade request of data mode, return.
Wherein, Business Entity server network address, Business Entity server interface title: Business Entity can be determined to obtain the position upgrading data message by Business Entity server network address and Business Entity server interface title, to realize the function obtained from target location for the Business Entity information content.
Wherein, the data layout upgrade content data request, upgrading request of data mode, return: the data layout upgrade content data request, upgrade request of data mode, returning receive with corresponding Business Entity server upgrade content data request, receive the request of data mode that upgrades, the data layout of transmission is corresponding, to realize the function of being resolved the request of transmission and the information that receives by configuration file.
According to the step S10 that the above embodiments of the present application one provide, below just for this news client, the step S10 that above-described embodiment one provides is described in detail.
When news client terminal start-up, each news template in news client is scanned, obtains the NEWS SERVER network address corresponding with each news template, NEWS SERVER interface name, the data layout etc. that upgrades content data request, upgrade request of data mode, return.For convenience of client to the acquisition of each news template configuration information, when developing, allocation list corresponding with it can be set for each news template, in allocation list, can at least comprise above-mentioned configuration information.
Preferably, as shown in Figure 3, in the above embodiments of the present application one, after step S10 obtains the step of physical arrangements parameter of described Business Entity, following implementation step can also be performed:
Step S11, according to the physical arrangements information transmitting data between Business Entity and Business Entity server, creates cache information.Cache information at least comprises: the physical arrangements information between Business Entity and Business Entity server.
According to the step S11 that the above embodiments of the present application one provide, below just for this news client, the step S11 that above-described embodiment one provides is described in detail.
After news client terminal start-up, in order to ensure news client travelling speed, cache information can be created to the configuration information of each news template scanned in this locality.Avoiding news client when upgrading the content of news column, also needing repeatedly repeatedly to scan this news column, causing system burden overweight.
Preferably, as shown in Figure 4, in the above embodiments of the present application one, in step S16 according to Business Entity configuration information, according to Business Entity configuration information, Data Analysis is carried out to the more new data of the Business Entity returned, be in the Business Entity data layout that can identify by the renewal Data Analysis of the Business Entity returned, can also comprise the steps:
Step S161, obtains the more new data of the Business Entity received;
Step S163, searches the physical arrangements information corresponding to the more new data of the Business Entity received in cache information;
Step S165, according to the data layout returned in physical arrangements information, resolves the more new data of Business Entity, resolves to the data layout that Business Entity can identify.
Above-mentioned steps S161 is in step S165, search the physical arrangements information of mating with the renewal data message of the Business Entity received in buffer memory, resolve according to the renewal data message of the data layout returned in physical arrangements information to Business Entity, resolve to the data layout that Business Entity can identify, carry out for Business Entity.
Preferably, in the above embodiments of the present application one, send renewal data request information in step s 12 and at least comprise following a kind of requesting data information: upgrade the table data solicited message of Business Entity, upgrade the content data request information of Business Entity.
According to the above embodiments of the present application one, below just for this news client, above-described embodiment one is described in detail.
In news client, Business Entity is generally divided into two kinds of contents, the list information of news and the text message of news.Wherein, the table data solicited message of above-mentioned renewal Business Entity is exactly the list information for refreshing the news template in news client; The content data request information of above-mentioned renewal Business Entity is exactly the information for refreshing the news content in news client.
Preferably, in the above embodiments of the present application one, sending to Business Entity server the step upgrading data request information according to Business Entity configuration information in step S12 can also comprise:
Step S121, when sending that to upgrade data request information be the table data solicited message for upgrading Business Entity: obtain the list reference position of table data in the table data of Business Entity and upgrade the number of entries of table data, generating and upgrade data request information;
According to the step S121 that the above embodiments of the present application one provide, below just for this news client, the step S121 that above-described embodiment one provides is described in detail.
In news client, each news column, when refreshing news list information, does not need to refresh the news list of whole news at every turn.A kind of mode can be that news client judges with time or label this news template, obtain last refresh time or numbering, be sent to server, the news list of the self-defined quantity after last refresh time or numbering is refreshed.Another mode can be the time that news client obtains refresh operation, refreshes the news list of the self-defined quantity before refresh time.
Step S123, when sending renewal data request information and being the content data request information of renewal Business Entity: obtain the context number corresponding with the content-data of Business Entity, generate and upgrade data request information.
According to the step S123 that the above embodiments of the present application one provide, below just for this news client, the step S123 that above-described embodiment one provides is described in detail.
In news client, each news column is when refreshing news content information, and news client can obtain the news numbering of a certain section news in this column, generates renewal data request information.
Here, composition graphs 5, according to being described the flow process of each abstract module respectively:
Abstract service module: practical business funcall initiates request by abstract service module to the server end business interface of correspondence.After receiving the data that abstract network module returns, call abstract data parsing module, parsing of the data stream is become Business Entity example.After parsing, this Business Entity example will be passed to UI thread and transfer to related service logic process.
Abstract data parsing module: this module scans whole Business Entity collection when application program launching, and obtain type of service by analyzing Business Entity configuration information, arranges a buffer memory, is used for preserving the corresponding relation of Business Entity and server end business interface.After the Data Analysis request receiving abstract service module, obtain Business Entity by type of service, the Data Analysis that abstract network module returns is become related service entity instance, then this entity instance is passed to abstract service module.
Abstract network module: after this module receives the network request of abstract service module, obtain the Business Entity server network address in the update request of Business Entity, Business Entity server interface title, upgrade request of data mode, they are combined into general network request and initiate request to Business Entity server.After receiving server end response, the data stream returned got up and return to abstract service module.
The present invention is by network request, and resolution logic is encapsulated and takes out business interface, eliminates the step repeating to write network request function and Data Analysis function.Under development, developer only needs the exploitation of being correlated with through simply using training just can drop into upper-layer service at once, and does not spend care and how to write the request function mutual with server end and Data Analysis function.We are freed from the duplication of labour of bottom, makes us more be absorbed in the realization of business function, improve production efficiency.
Embodiment 2
Fig. 6 is the schematic diagram of the calling device of business interface according to the embodiment of the present invention two.As shown in Figure 4, this device can comprise: request module 202, receiver module 204, parsing module 206 and synchronization module 208.
Wherein, request module 202, for sending renewal data request information according to Business Entity configuration information to Business Entity server; Receiver module 204, for receiving Business Entity server according to the more new data upgrading the Business Entity that data request information returns; Parsing module 206, for according to Business Entity configuration information, carrying out Data Analysis to the more new data of the Business Entity returned according to Business Entity configuration information, is the data layout that Business Entity can identify by the renewal Data Analysis of the Business Entity returned; Synchronization module 208, for resolving to the renewal data syn-chronization of the Business Entity that Business Entity can identify to Business Entity.
In the above embodiments of the present application two, the request module 202 that the above embodiments of the present application one provide, receiver module 204, parsing module 206 and synchronization module 208 can be included in the application program that mobile intelligent terminal runs, in implementation process, a kind of embodiment of the application program run on mobile intelligent terminal in above-described embodiment two, it can be the news client run on mobile intelligent terminal, below just for this news client, above-described embodiment two is described in detail.
In news client, multiple news column can be there is, such as: hot news plate, financial and economic news column, science and technology news column, sports news column etc.Wherein each news column can regard it as a Business Entity.Each news column has respective configuration mode.When carrying out refresh operation to some news columns, client sends Data Update request according to the configuration information of this news column to the server corresponding with this column or server interface.After server receives update request, return the concrete update content of news client by according to the update request received.After news client receives update content, news client is resolved update content.Update content, according to the configuration information of this news template, is resolved to the data layout that this plate can directly use by news client, and is sent to this plate by after parsing to fresh content, uses for this column.
Preferably, as shown in Figure 7, in the above embodiments of the present application two, said apparatus also comprises: acquisition module 200.
Wherein, acquisition module 200, for obtaining the physical arrangements information of Business Entity, wherein, physical arrangements information at least comprises: Business Entity server network address, Business Entity server interface title, the data layout upgrading content data request, upgrade request of data mode, return.
Wherein, Business Entity server network address, Business Entity server interface title: Business Entity can be determined to obtain the position upgrading data message by Business Entity server network address and Business Entity server interface title, to realize the function obtained from target location for the Business Entity information content.
Wherein, the data layout upgrade content data request, upgrading request of data mode, return: the data layout upgrade content data request, upgrade request of data mode, returning receive with corresponding Business Entity server upgrade content data request, receive the request of data mode that upgrades, the data layout of transmission is corresponding, to realize the function of being resolved the request of transmission and the information that receives by configuration file.
According to the acquisition module 200 that the above embodiments of the present application two provide, below just for this news client, the acquisition module 200 that above-described embodiment one provides is described in detail.
When news client terminal start-up, each news template in news client is scanned, obtains the NEWS SERVER network address corresponding with each news template, NEWS SERVER interface name, the data layout etc. that upgrades content data request, upgrade request of data mode, return.For convenience of client to the acquisition of each news template configuration information, when developing, allocation list corresponding with it can be set for each news template, in allocation list, can at least comprise above-mentioned configuration information.
Preferably, as shown in Figure 8, in the above embodiments of the present application two, said apparatus also comprises: cache module 201.
Wherein, cache module 201, for according to the physical arrangements information transmitting data between Business Entity and Business Entity server, create cache information, cache information at least comprises: the physical arrangements information between Business Entity and Business Entity server.
According to the cache module 201 that the above embodiments of the present application one provide, below just for this news client, the cache module 201 that above-described embodiment one provides is described in detail.
After news client terminal start-up, in order to ensure news client travelling speed, cache module can create cache information to the configuration information of each news template scanned in this locality.Avoiding news client when upgrading the content of news column, also needing repeatedly repeatedly to scan this news column, causing system burden overweight.
Preferably, in the above embodiments of the present application two, for according to Business Entity configuration information, carry out Data Analysis to the more new data of the Business Entity returned according to Business Entity configuration information, the parsing module 206 being the data layout that Business Entity can identify by the renewal Data Analysis of the Business Entity returned comprises: sub-acquisition device 2061, treating apparatus 2063 and resolver 2065.
Wherein, sub-acquisition device 2061, for obtaining the more new data of the Business Entity received;
Treating apparatus 2063, for searching the physical arrangements information corresponding to the more new data of the Business Entity received in cache information;
Resolver 2065, for according to the data layout returned in physical arrangements information, resolves the more new data of Business Entity, resolves to the data layout that Business Entity can identify.
The physical arrangements information of mating with the renewal data message of the Business Entity received in buffer memory searched by above-mentioned treating apparatus 2063 by sub-acquisition device 2061, resolve according to the renewal data message of the data layout returned in physical arrangements information by resolver 2065 pairs of Business Entities, resolve to the data layout that Business Entity can identify, carry out for Business Entity.
Preferably, in the above embodiments of the present application two, when upgrading data request information and at least comprising the table data solicited message upgrading Business Entity, the content data request information upgrading Business Entity, comprise for sending to Business Entity server the request module 202 upgrading data request information according to Business Entity configuration information: the first acquisition module 2021 and the second acquisition module 2023.
Wherein, first acquisition module 2021, for send upgrade data request information be the table data solicited message for upgrading Business Entity time, obtain the list reference position of table data in the table data of Business Entity and upgrade the number of entries of table data, generating and upgrade data request information;
According to the first acquisition module 2021 that the above embodiments of the present application two provide, below just for this news client, the first acquisition module 2021 that above-described embodiment two provides is described in detail.
In news client, each news column, when refreshing news list information, does not need to refresh the news list of whole news at every turn.A kind of mode can be that news client judges with time or label this news template, last refresh time or numbering is obtained by the first acquisition module, be sent to server, the news list of the self-defined quantity after last refresh time or numbering is refreshed.Another mode can be that news client obtains the time of refresh operation by the first acquisition module, refreshes the news list of the self-defined quantity before refresh time.
Second acquisition module 2023, for when sending renewal data request information and being the content data request information of renewal Business Entity, obtains the context number corresponding with the content-data of Business Entity, generates and upgrade data request information.
According to the second acquisition module 2023 that the above embodiments of the present application two provide, below just for this news client, the second acquisition module 2023 that above-described embodiment two provides is described in detail.
In news client, each news column is when refreshing news content information, and news client obtains the news numbering of a certain section news in this column by the second acquisition module, generates renewal data request information.
The invention described above embodiment sequence number, just to describing, does not represent the quality of embodiment.
In the above embodiment of the present invention, the description of each embodiment is all emphasized particularly on different fields, in certain embodiment, there is no the part described in detail, can see the associated description of other embodiments.
In several embodiments that the application provides, should be understood that, disclosed device, the mode by other realizes.Wherein, device embodiment described above is only schematic, the such as division of described unit, be only a kind of logic function to divide, actual can have other dividing mode when realizing, such as multiple unit or assembly can in conjunction with or another system can be integrated into, or some features can be ignored, or do not perform.Another point, shown or discussed coupling each other or direct-coupling or communication connection can be by some interfaces, and the indirect coupling of unit or module or communication connection can be electrical or other form.
The described unit illustrated as separating component or can may not be and physically separates, and the parts as unit display can be or may not be physical location, namely can be positioned at a place, or also can be distributed in multiple network element.Some or all of unit wherein can be selected according to the actual needs to realize the object of the present embodiment scheme.
In addition, each functional unit in each embodiment of the present invention can be integrated in a processing unit, also can be that the independent physics of unit exists, also can two or more unit in a unit integrated.Above-mentioned integrated unit both can adopt the form of hardware to realize, and the form of SFU software functional unit also can be adopted to realize.
If described integrated unit using the form of SFU software functional unit realize and as independently production marketing or use time, can be stored in a computer read/write memory medium.Based on such understanding, the part that technical scheme of the present invention contributes to prior art in essence in other words or all or part of of this technical scheme can embody with the form of software product, this computer software product is stored in a storage medium, comprises all or part of step of some instructions in order to make a computer equipment (can be personal computer, server or the network equipment etc.) perform method described in each embodiment of the present invention.And aforesaid storage medium comprises: USB flash disk, ROM (read-only memory) (ROM, Read-Only Memory), random access memory (RAM, Random Access Memory), portable hard drive, magnetic disc or CD etc. various can be program code stored medium.
The above is only the preferred embodiment of the present invention; it should be pointed out that for those skilled in the art, under the premise without departing from the principles of the invention; can also make some improvements and modifications, these improvements and modifications also should be considered as protection scope of the present invention.