A kind of method and device docked with business system based on js
Technical field
The present invention relates to system docking field, it is based on js particularly to a kind of(javascript)Carry out with business system
The method and device of docking.
Background technology
SOA(Service-Oriented Architecture, Services Oriented Achitecture)It is a component model,
It is by the different function units of application program(Referred to as service)By defining good interface and contract connection between these services
System gets up.Interface is to be defined by the way of neutral, and it is independent of hardware platform, operating system and the volume of service of realizing
Cheng Yuyan.This make build the service in various systems can by using a kind of unification and general in the way of handed over
Mutually.
SOA is a kind of coarseness, loose coupling service architecture, is communicated by simple, explication interface between service,
It is not related to programming on bottom layer interface and Communication Model.SOA can be regarded as B/S(Browser/Server, browser/server)Mould
Type, XML/Web Service(Extensible markup language/Web service)Natural extension after technology.
There is problems with itself in SOA technology:(1)SOA can be described as the extension of Web Service technology, data transfer
Frequently with soap protocol(xml), xml, in data transmission procedure, wastes substantial amounts of bandwidth than json data form, do not have
Json data form simplifies practicality;(2)Mobile Internet HTML5 application cannot parse the message content of xml, need to introduce other solutions
Analysis module could support that xml parses well, applies primary support to the parsing HTML5 of json data;(3)Access control in the past
Only need to log in and verify;And in SOA environment, because the assembly of an application software is easy to and not same area field, no
The other assemblies of homologous ray engage in the dialogue, it is ensured that the safety between far different and interconnective system will become
Especially difficult;(4)Define the business implication of affairs data, the thorny problem that always IT management personnel face.Semantic pass
System is the key element designing good SOA framework.For now, which technology or software product is not had can really to solve
Matter of semantics.
Content of the invention
The technical problem to be solved in the present invention is, for the above-mentioned waste bandwidth of prior art, cannot be in analytic message
Hold, safety there is no guarantee that, can not solve the defect of matter of semantics, provide a kind of take less bandwidth, can analytic message content,
Safety is guaranteed, can solve the method and device docked based on js of matter of semantics with business system.
The technical solution adopted for the present invention to solve the technical problems is:Construction is a kind of to be carried out with business system based on js
The method of docking, comprises the steps:
A)Client passes through http agreement json(JavaScript Object Notation, a kind of data of lightweight
DIF)Data form to jsse (JavaScript Service Engine, js service-Engine) send request and to institute
State request to be processed;Described jsse includes adapter assembly and capability component, and described adapter assembly and capability component have
Api interface;
B)Call described adapter assembly or the api interface of capability component to dock with described business system, to realize to enterprise
The conversion of industry system interface data form.
In the method docked with business system based on js of the present invention, described jsse also includes main core
Framework and js engine.
In the method docked with business system based on js of the present invention, described step A)Wrap further
Include:
A1)Client sends request according to the data form of the json meeting http agreement to described main core frame;
A2)Described main core frame parses to described request, and obtains the data carrying in described request;
A3)Described js engine is loaded in described jsse described main core frame;
A4)Specified js logical file content is loaded into by described main core frame according to the data carrying in described request
In described jsse;
A5)Described main core frame is parsed by described js engine and executes the content of described js logical file;
A6)Judge in the content of js logical file of execution with the presence or absence of the script loading adapter assembly or capability component
Code, in this way, execution step A7);Otherwise, do not execute any operation;
A7)Specified adapter assembly or capability component are loaded in described jsse described main core frame.
In the method docked with business system based on js of the present invention, described step B)Wrap further
Include:
B1)The adapter assembly specified or the api interface of capability component is called to be docked with described business system;
B2)Call result is returned to described main core frame;
B3)Described call result is returned to by described main core frame according to the data form of the json meeting http agreement
Described client.
In the method docked with business system based on js of the present invention, executing described js logic literary composition
The content of part, responded described request after or receive legitimacy and the visitor of client request client unconfirmed in described jsse
Before the integrity of family end data, described js engine enters or in a dormant state.
The invention still further relates to a kind of device realizing the above-mentioned method docked based on js with business system, including:
Request transmitting unit:Data form for making client pass through http agreement json sends request and to described request to jsse
Processed;Described jsse includes adapter assembly and capability component, and described adapter assembly and capability component have API and connect
Mouthful;
Interface interchange converting unit:For calling the api interface of described adapter assembly or capability component and described enterprise
System docking, to realize the conversion to business system interface data format.
In the device realizing the above-mentioned method docked based on js with business system of the present invention, described
Jsse also includes main core frame and js engine.
In the device realizing the above-mentioned method docked based on js with business system of the present invention, described please
Transmitting element is asked to further include:
Formatted request sending module:For making client according to the data form of the json meeting http agreement to described master
Core frame sends request;
Parsing module:For making described main core frame that described request is parsed, and obtain described request in carry
Data;
Engine load-on module:For making described main core frame that described js engine to be loaded in described jsse;
Logical file loading module:For making the described main core frame will be specified according to the data that carries in described request
Js logical file content is loaded in described jsse;
Parsing performing module:For making described main core frame parse by described js engine and executing described js logic literary composition
The content of part;
Load judge module:For judge execution js logical file content in the presence or absence of load adapter assembly or
The scripted code of capability component;
Specified load-on module:For making described main core frame that specified adapter assembly or capability component are loaded into institute
State in jsse.
In the device realizing the above-mentioned method docked based on js with business system of the present invention, described connect
Mouth calls converting unit to further include:
Call to connection module:For calling api interface and the system of described enterprise of the adapter assembly specified or capability component
System is docked;
Call result returns module:For call result is returned to described main core frame;
Call result form returns module:For making described main core frame according to the data of the json meeting http agreement
Described call result is returned to described client by form.
In the device realizing the above-mentioned method docked based on js with business system of the present invention, in execution
The content of complete described js logical file, responded described request after or receive client request client unconfirmed in described jsse
Before the integrity of the legitimacy at end and client data, described js engine enters or in a dormant state.
Implement the method and device docked with business system based on js of the present invention, have the advantages that:
Because client is processed to jsse transmission request and to request by the data form of http agreement json;Jsse includes fitting
Orchestration assembly and capability component, adapter assembly and capability component have api interface;By calling adapter assembly or ability group
The api interface of part is docked with described business system, to realize the conversion to business system interface data format, using json data
Form simplifies practicality, so taking less bandwidth, mobile Internet HTML5 can parse to json data;Adapter assembly
With capability component, there is unified api interface it is easy to realize the docking of each interface, so safety is guaranteed, based on standard
Javascript development language, simply write the javascript file with logic, just can achieve complicated service logic,
Without too many consideration matter of semantics, so matter of semantics can be solved.
Brief description
In order to be illustrated more clearly that the embodiment of the present invention or technical scheme of the prior art, below will be to embodiment or existing
Have technology description in required use accompanying drawing be briefly described it should be apparent that, drawings in the following description be only this
Some embodiments of invention, for those of ordinary skill in the art, without having to pay creative labor, also may be used
So that other accompanying drawings are obtained according to these accompanying drawings.
Fig. 1 is to dock enterprise with business system in one embodiment of method and device that the present invention is docked based on js
The structural representation of system;
Fig. 2 is the flow chart of method in described embodiment;
Fig. 3 is that in described embodiment, client sends request and to please by the data form of http agreement json to jsse
Seek the particular flow sheet being processed;
Fig. 4 is to call adapter assembly or the api interface of capability component to dock with business system in described embodiment, comes real
The now particular flow sheet to the conversion of business system interface data format;
Fig. 5 is the sequential chart realizing in described embodiment docking with business system;
Fig. 6 is the structural representation of device in described embodiment.
Specific embodiment
Below in conjunction with the accompanying drawing in the embodiment of the present invention, the technical scheme in the embodiment of the present invention is carried out clear, complete
Site preparation description is it is clear that described embodiment is only a part of embodiment of the present invention, rather than whole embodiments.It is based on
Embodiment in the present invention, it is every other that those of ordinary skill in the art are obtained under the premise of not making creative work
Embodiment, broadly falls into the scope of protection of the invention.
In the method and device embodiment that the present invention is docked with business system based on js, it docks business system
Structural representation as shown in Figure 1.In Fig. 1, by writing javascript script, call API(Existing or self-defined)Ability, just
The docking to business system can be completed, thus realizing new business systemic-function.In the present embodiment, jsse include adapter assembly and
Capability component, adapter assembly and capability component have api interface, and adapter assembly comprises multiple adapters, and capability component has
Multiple.Jsse also includes main core frame and js engine.The data form request by http agreement json for the new operation system
Jsse, jsse pass through adapter assembly or capability component is docked with existing business system, to realize completing to existing enterprise
The conversion of system interface data form, thus realize predefined function.Using js language can quick left-hand seat, learning cost is low, carries
Support, measured javascript development language, by simply writing the javscript with logic for powerful API
File, just can achieve complicated service logic.
In the present embodiment, the flow chart of the above-mentioned method docked with business system based on js is as shown in Figure 2.Fig. 2
In, the method comprises the steps:
Step S01 client by the data form of http agreement json to jsse send request and to request at
Reason:In this step, client(Requesting party, also corresponds to the new business system in Fig. 1)By the data lattice of http agreement json
Formula sends to jsse to be asked and request is processed, it is emphasized that jsse agreement request is the number of http protocol transmission
It is json according to form.
Step S02 calls adapter assembly or the api interface of capability component to dock with business system, to realize to system of enterprise
The conversion of system interface data format:In this step, call api interface and the business system pair of adapter assembly or capability component
Connect, to realize the conversion to business system interface data format.Simplify practicality using json data form, so taking less band
Width, mobile Internet HTML5 can parse to json data;Adapter assembly and capability component have unified api interface,
It is easily achieved the docking of each interface, so safety is guaranteed, measured javascript development language, simply write
There is the javscript file of logic, just can achieve complicated service logic, without too many consideration matter of semantics, so energy
Solve matter of semantics.
In prior art, SOA, by so-called coarse granularity services interface and classification, really improves efficiency, realizes procedure
After, also really simplify development difficulty.But if this flow process is not suitable for the practical situation of enterprise it is desired nonetheless to personalization
Exploitation.In the present embodiment, the exploitation standard of adapter assembly and capability component is provided, can customize and be more targetedly adapted to
Can freely assemble between device or capability component, and each adapter, capability component, be not relying on, can be very good to solve now
There is the problem in technology.
For the present embodiment, above-mentioned steps S01 also can refine further, and the flow chart after its refinement is as shown in Figure 3.
In Fig. 3, above-mentioned steps S01 further include:
Step S11 client sends request according to the data form of the json meeting http agreement to main core frame:This
In step, client sends request according to the data form of the json meeting http agreement to main core frame.
The main core frame of step S12 parses to request, and obtains the data carrying in request:In this step, main core
Heart framework parses to request, and obtains the data carrying in request.
Js engine is loaded in jsse step S13 main core frame:In this step, main core frame loads js engine,
And js engine is loaded in jsse.
Specified js logical file content is loaded into jsse according to the data carrying in request by the main core frame of step S14
In:In this step, the js logical file content that main core frame is specified according to the data loading carrying in request, and will be specified
Js logical file content is loaded in jsse.
The main core frame of step S15 is parsed by js engine and executes the content of js logical file:In this step, main core
Framework is parsed by js engine and executes the content of js logical file.
Step S16 judges in the content of js logical file of execution with the presence or absence of loading adapter assembly or capability component
Scripted code:In this step, judge in the content of js logical file of execution with the presence or absence of loading adapter assembly or ability group
The scripted code of part, if it is determined that result be yes, then execution step S18;Otherwise, execution step S17.
Step S17 does not execute any operation:If the judged result of above-mentioned steps S16 is no, execute this step.This step
In rapid, do not execute any operation.
Specified adapter assembly or capability component are loaded in jsse the main core frame of step S18:If above-mentioned step
The judged result of rapid S16 is yes, then execute this step.In this step, main core frame is by specified adapter assembly or ability
Assembly is loaded in jsse.
For the present embodiment, above-mentioned steps S02 also can refine further, and the flow chart after its refinement is as shown in Figure 4.
In Fig. 4, above-mentioned steps S02 further include:
Step S21 calls the adapter assembly specified or the api interface of capability component to be docked with business system:This step
In rapid, the adapter assembly specified or the api interface of capability component is called to be docked with business system.
Call result is returned to main core frame by step S22:In this step, call result is returned to main core frame
Frame.
Call result is returned to client according to the data form of the json meeting http agreement by the main core frame of step S23
End:In this step, call result is returned to client according to the data form of the json meeting http agreement by main core frame.
Based on standard js grammer, complete and the interacting of existing business system, realize system docking, and return according to client(Request
Side)The data form requiring and data.This completes the conversion to existing business system interface data format, thus real
Now predefine function.
Four assemblies such as above-mentioned main core frame, js engine, adapter assembly and capability component are described below.Main core frame
The major function responsibility of frame has:Receive, decompose the request of client, and obtain the data carrying in request;Load js engine extremely
In jsse;According to request data, load the content specifying js logical file;Parsed by js engine and execute js logical file
Content.If there is the scripted code loading adapter or capability component, main core frame in the javascript script of execution
The adapter specified in js logical file or capability component are loaded onto in js engine.
Js engine is javascript parsing and execution kernel, and in the present embodiment, js engine adopts silent in Java jdk1.7
Recognize the Mozilla Rhino supporting to carry.Mozilla Rhino is a js engine of increasing income write using java language completely
Realize, be mainly used in executing js program in java environment, provide scripting ability for end user.
Js engine runs in tense in whole jsse has several states, respectively resting state, original state and operation
State.Program initial start-up, will realize the js engine instance of part dormant state, and jsse has executed the content of js logical file,
Respond client(Requesting party)Request after, js engine will reenter dormant state.Jsse is doing the docking of system service
When, when jsse receives the request of requesting party, before the legitimacy of requesting party unconfirmed and the integrity of requesting party's data, in order to
Not the wasting of safeguards system resource, js engine will not be loaded and is ready to carry out, and now js engine will be in dormant state.
In original state, after jsse confirms the integrity of the legitimacy of requesting party and data, js will be loaded and draw
Hold up, and realize some initial loadings and be ready to carry out preparation work.In running status, when jsse carries out real system pair
When connecing, js engine will load and execution js logical file, and parse the predefined logic of js logical file, call each adaptation
Device or capability component carry out relevant treatment.
In the present embodiment, adapter assembly and capability component are mainly used in existing enterprise's system being adapted to and is docked
Work.Adapter assembly comprises multiple adapters, such as SQLAdapter(Database adapter), HTTPAdapter(Http protocol
Adapter)And EmailAdapte(Email adaptor)Etc.;Wherein, SQLAdapter is mainly used in data base is docked
(Oracle, Sqlserver, DB2, Mysql ...), HttpAdapter be mainly used in dock http protocol relevant interface
(WebService, Http+Json, list submission etc.), EmailAdapter support standard pop3 and smtp agreement carry out postal
The transmitting-receiving of part, is mainly used in mailing system is docked.Capability component has multiple, such as FILEEnabler(File ability group
Part)、DOCUMENTEnable(Document capability component)、CODECEnabler(Code capability component)And ZipEnabler(Compression
Capability component)Etc., wherein, FileEnabler is used for the support to file protocol, supports file system is operated,
DocumentEnabler is used for office, pdf document being carried out process the operation of conversion, and ZipEnabler is used for compressing, decompresses
The operation of contracting is processed.In addition except the above-mentioned adapter listed and capability component, also substantial amounts of adapter and capability component
In the present embodiment with regard to not listed one by one.
The present embodiment further relates to a kind of device realizing the above-mentioned method docked based on js with business system, its knot
Structure schematic diagram is as shown in Figure 6.In Fig. 6, this device includes request transmitting unit 1 and interface interchange converting unit 2;Wherein, ask
Transmitting element 1 is used for making client carry out to jsse transmission request and to described request by the data form of http agreement json
Process;Jsse includes adapter assembly and capability component, and adapter assembly and capability component have api interface;Interface interchange turns
Change unit 2 for calling adapter assembly or the api interface of capability component to dock with business system, to realize business system is connect
The conversion of mouth data form.In the present embodiment, jsse also includes main core frame and js engine.Simplified using json data form
Practicality, so taking less bandwidth, mobile Internet HTML5 can parse to json data;Adapter assembly and ability group
Part has unified api interface it is easy to realize the docking of each interface, so safety is guaranteed, measured
Javascript development language, simply writes the javscript file with logic, just can achieve complicated service logic, no
With too many consideration matter of semantics, so matter of semantics can be solved.
In the present embodiment, request transmitting unit 1 further includes formatted request sending module 11, parsing module 12, engine
Load-on module 13, logical file loading module 14, parsing performing module 15, loading judge module 16 and specified load-on module 17;
Wherein, formatted request sending module 11 is used for making client according to the data form of the json meeting http agreement to main core frame
Frame sends request;Parsing module 12 is used for making main core frame that request is parsed, and obtains the data carrying in request;Draw
Hold up load-on module 13 to be used for making main core frame that js engine to be loaded in jsse;Logical file loading module 14 is used for making main core
Heart framework according to the data carrying in request, specified js logical file content is loaded in jsse;Parsing performing module 15 is used
In making main core frame parse by js engine and execute the content of js logical file;Load judge module 16 to be used for judging execution
The content of js logical file in the presence or absence of the scripted code loading adapter assembly or capability component;Specified load-on module 17
For making main core frame that specified adapter assembly or capability component to be loaded in jsse.
In the present embodiment, interface interchange converting unit 2 further includes to call and returns module to connection module 21, call result
22 and call result form return module 23;Wherein, call and connection module 21 is used for calling the adapter assembly specified or ability
The api interface of assembly is docked with business system;Call result returns module 22 and is used for for call result returning to main core
Framework;Call result form returns module 23 and is used for making main core frame incite somebody to action according to the data form of the json meeting http agreement
Call result returns to client.
In the present embodiment, receive after the content having executed js logical file, the request having responded client or in jsse
Before the integrity of the legitimacy of client request client unconfirmed and client data, js engine enters or is in dormancy
State.So can be with save resources.
In a word, in the present embodiment, jsse itself can support the existing most interface protocol of docking, and jsse is also
Exploitation custom adapter and the API of capability component, so just can do more personalized customization for existing enterprise's system, have
Preferably expansion.Because using js language, its local exchange just possesses cross-platform characteristic, support multiple common platforms.Jsse system
Flexible configuration changeable, after system deployment success, the configuration item of system configuration file itself and business procedure all can be with jsse system
System separation management.System deployment is simple, superior performance, and system can distributed multimachine deployment.System supports heat deployment, configuration file
Soon come into force after modification, configuration file and system relationship, but be not relying on.Additionally, system supports various modes (development mode
And deployment mode) it is easy to exploitation debugging and formal dispose, have independent log system, with module, system is dividing for daily record.
Using js language, it programs object-oriented, can reduce code redundancy well, its rate of code reuse is higher, more conducively team
The developer's effectively division of labor and management code, improves work efficiency.Js Engine objects pond has automatic telescopic characteristic, can achieve
The caching of system, realizes the Automatic dispatching management to connection resource according to system busy situation.Meanwhile, object pool provides link shape
State automatic detection and reconnect mechanism.
The foregoing is only presently preferred embodiments of the present invention, not in order to limit the present invention, all essences in the present invention
Within god and principle, any modification, equivalent substitution and improvement made etc., should be included within the scope of the present invention.