Embodiment
In order to more clearly understand above-mentioned purpose of the present invention, feature and advantage, below in conjunction with the drawings and specific embodiments, the present invention is further described in detail.It should be noted that, when not conflicting, the feature in the embodiment of the application and embodiment can combine mutually.
Set forth a lot of detail in the following description so that fully understand the present invention, but the present invention can also adopt other to be different from other modes described here and implement, and therefore, the present invention is not limited to the restriction of following public specific embodiment.
Fig. 1 shows the schematic block diagram of the automatically generating device of web system according to an embodiment of the invention.
As shown in Figure 1, the automatically generating device of web system according to an embodiment of the invention, comprising: view layer generation unit, for generating the form interface of the view layer of described web system; Model layer generation unit, comprise: Database subelement, for building database, in described database, store the database table corresponding with described form interface, the attribute information one_to_one corresponding of each form controls in the field in described database table and described form interface; Class creates subelement, creates the business processing class being used for operating described database, to complete the generation of the model layer of described web system; Key-course generation unit, comprising: functional configuration subelement, for carrying out functional configuration according to the configuration file preset; Strategy sets up subelement, for setting up control strategy, to complete the generation of the key-course of described web system.
In this technical scheme, obtained by the attribute of the form interface to view layer, and set up corresponding database, make the incidence relation automatically set up between view layer and model layer, and need not completely manually carry out associated configuration by user, improve the automaticity of system development, contribute to increasing work efficiency.Meanwhile, also by providing the business processing class automatically generated, completing the concrete operations of key-course to the database of model layer, achieving view layer, tight association between model layer and key-course, contributing to reducing artificial intervention degree.
In technique scheme, preferably, described view layer generation unit comprises: chooser unit, for the selection instruction according to the user received, selects form controls and view type; List generates subelement, for according to the key entry information obtained, for each form controls adds corresponding attribute information and method information, to generate the form interface of described view layer.
In this technical scheme, for without the need to performing writing specific code, only needing to select view type and the visual control model set up in advance, can automatically generate corresponding code by backstage, contribute to increasing work efficiency.By keying in attribute information and method information, then for the system architecture by the control model-composing preset, for each concrete control arranges corresponding practical function and logical relation, but these operations are all without the need to manually writing code by user, only need to pay close attention to concrete service logic, improve automaticity, contribute to increasing work efficiency.
In above-mentioned arbitrary technical scheme, preferably, described Database subelement is used for: the JavaBean assembly creating the attribute information of each form controls comprised in described form interface; According to the attributive character of required database, generate database table, all properties information one_to_one corresponding in the field in described database table and described JavaBean assembly; Described database table is stored to database.
In this technical scheme, utilize dynamic proxy technology, by JavaBean, the attribute of the form controls of view layer is obtained, and set up corresponding database table, thus be automatically associated between view layer and model layer, and at view layer, be automatically associated between model layer with database, manually arrange without the need to user, contribute to the automaticity of elevator system, improve the work efficiency of user.
In above-mentioned arbitrary technical scheme, preferably, the foundation class for operating described database inherited by described JavaBean assembly; And described business processing class comprises Agent components and described JavaBean assembly, wherein, described Agent components, by calling described JavaBean assembly, realizes the operation to described database.
In this technical scheme, by inheriting foundation class by JavaBean assembly, realize the concrete operations to database, and realized responding concrete request during system cloud gray model by Agent components, thus the clearly division realized multiple function, contribute to concrete debugging and control.
In above-mentioned arbitrary technical scheme, preferably, described model layer generation unit also comprises: template generation subelement, for generating and storing the SQL templates statement be associated with described business processing class; Wherein, the information parsed from the operation requests received is added into described SQL templates statement by described business processing class, to generate SQL perform statement, and by described SQL perform statement, realizes the operation to described database.
In this technical scheme, by generating SQL templates statement, then when responding the request of user, without the need to all again writing SQL query statement at every turn, and the relevant position directly mark (ID etc. as concrete database table) of the data of desired operation is added in SQL templates statement, directly can realize the operation to database, contribute to shortening the response time, improve operational efficiency.
In above-mentioned arbitrary technical scheme, preferably, described key-course generation unit also comprises: file generated subelement, and for the operational motion by detecting user, determination operation object and mode of operation, to generate described default configuration file.
In this technical scheme, in the generative process of key-course, in initialization procedure and concrete functional configuration process, need to use the configuration file generated in advance.The generative process of configuration file is without the need to user's manual programming, only need by user's execution as the operation such as establishment, the selection of object, the selection of mode of operation in path, system just can generate corresponding configuration file automatically, make the generative process robotization more of configuration file, contribute to increasing work efficiency.
In above-mentioned arbitrary technical scheme, preferably, described strategy set up subelement for: according to user select framework type, read the predetermined control strategy that described framework type is corresponding; Or according to the user's configuration-direct received, set up the control strategy of configuration in real time.
In this technical scheme, user can select the framework type pre-set, then can directly read corresponding to control strategy corresponding to selected framework, to raise the efficiency; User also according to actual conditions, can configure new control strategy, to be applicable to different actual conditions.
Fig. 2 shows the schematic flow sheet of the automatic generation method of web system according to an embodiment of the invention.
As shown in Figure 2, the automatic generation method of web system according to an embodiment of the invention, comprising: the form interface generating the view layer of described web system; Building database, stores the database table corresponding with described form interface in described database, the attribute information one_to_one corresponding of each form controls in the field in described database table and described form interface; Create the business processing class being used for operating described database, to complete the generation of the model layer of described web system; Configuration file according to presetting carries out functional configuration, and sets up control strategy, to complete the generation of the key-course of described web system.
In this technical scheme, obtained by the attribute of the form interface to view layer, and set up corresponding database, make the incidence relation automatically set up between view layer and model layer, and need not completely manually carry out associated configuration by user, improve the automaticity of system development, contribute to increasing work efficiency.Meanwhile, also by providing the business processing class automatically generated, completing the concrete operations of key-course to the database of model layer, achieving view layer, tight association between model layer and key-course, contributing to reducing artificial intervention degree.
In technique scheme, preferably, the process generating described form interface comprises: according to the selection instruction of the user received, select form controls and view type, and according to the key entry information obtained, for each form controls adds corresponding attribute information and method information, to generate the form interface of described view layer.
In this technical scheme, for without the need to performing writing specific code, only needing to select view type and the visual control model set up in advance, can automatically generate corresponding code by backstage, contribute to increasing work efficiency.By keying in attribute information and method information, then for the system architecture by the control model-composing preset, for each concrete control arranges corresponding practical function and logical relation, but these operations are all without the need to manually writing code by user, only need to pay close attention to concrete service logic, improve automaticity, contribute to increasing work efficiency.
In above-mentioned arbitrary technical scheme, preferably, the process setting up described database comprises: the JavaBean assembly creating the attribute information of each form controls comprised in described form interface; According to the attributive character of required database, generate database table, all properties information one_to_one corresponding in the field in described database table and described JavaBean assembly; Described database table is stored to database.
In this technical scheme, utilize dynamic proxy technology, by JavaBean, the attribute of the form controls of view layer is obtained, and set up corresponding database table, thus be automatically associated between view layer and model layer, and at view layer, be automatically associated between model layer with database, manually arrange without the need to user, contribute to the automaticity of elevator system, improve the work efficiency of user.
In above-mentioned arbitrary technical scheme, preferably, also comprise: the foundation class for operating described database inherited by described JavaBean assembly; And described business processing class comprises Agent components and described JavaBean assembly, wherein, described Agent components, by calling described JavaBean assembly, realizes the operation to described database.
In this technical scheme, by inheriting foundation class by JavaBean assembly, realize the concrete operations to database, and realized responding concrete request during system cloud gray model by Agent components, thus the clearly division realized multiple function, contribute to concrete debugging and control.
In above-mentioned arbitrary technical scheme, preferably, also comprise: generate and store the SQL templates statement be associated with described business processing class; The information parsed from the operation requests received is added into described SQL templates statement by described business processing class, to generate SQL perform statement, and by described SQL perform statement, realizes the operation to described database.
In this technical scheme, by generating SQL templates statement, then when responding the request of user, without the need to all again writing SQL query statement at every turn, and the relevant position directly mark (ID etc. as concrete database table) of the data of desired operation is added in SQL templates statement, directly can realize the operation to database, contribute to shortening the response time, improve operational efficiency.
In above-mentioned arbitrary technical scheme, preferably, also comprise: by detecting the operational motion of user, determination operation object and mode of operation, to generate described default configuration file.
In this technical scheme, in the generative process of key-course, in initialization procedure and concrete functional configuration process, need to use the configuration file generated in advance.The generative process of configuration file is without the need to user's manual programming, only need by user's execution as the operation such as establishment, the selection of object, the selection of mode of operation in path, system just can generate corresponding configuration file automatically, make the generative process robotization more of configuration file, contribute to increasing work efficiency.
In above-mentioned arbitrary technical scheme, preferably, the process setting up control strategy comprises: the framework type selected according to user, reads the predetermined control strategy that described framework type is corresponding; Or according to the user's configuration-direct received, set up the control strategy of configuration in real time.
In this technical scheme, user can select the framework type pre-set, then can directly read corresponding to control strategy corresponding to selected framework, to raise the efficiency; User also according to actual conditions, can configure new control strategy, to be applicable to different actual conditions.
Fig. 3 shows the principle schematic that robotization according to an embodiment of the invention generates web system.
Below in conjunction with Fig. 3, the principle of work robotization based on embodiments of the invention being generated to web system is described in detail.
Assuming that in web system development platform of the present invention, comprise basis plateform system 302, also comprise for other concrete functions as view layer platform 302A, model layer platform 302B, key-course platform 302C etc., to realize the exploitation of concrete web system.
When needs perform web system exploitation, the setting being carried out in advance by plateform system 302 couples of users and complete or configuration is needed to read, to realize initialization and the functional configuration of system.
One, the automatic generation of view layer
In the present embodiment, the robotization generation of view layer is realized primarily of view layer platform 302A.Particularly, interactive process can be realized by the mode of browser, and user only needs to pull the mode with keyboard operation by mouse, can realize the generation of the page.
1, view type
User according to demand, the view type needed for selection, such as HTML, jsp, freemarker etc.
2, design drawing
Particularly, need to provide visual view control by view layer platform 302A, then user according to the demand of self, can use mouse to select and drags view control, can form corresponding design drawing.Such as, view control wherein can adopt W3C(World Wide WebConsortium, World Wide Web Consortium) control inside standard, only need the related specifications understanding W3C, do not need to spend again any time and energy goes to learn new control and API.
3, list
Design drawing on the view type that view layer platform 302A selects according to user and design platform, can generate corresponding list automatically.
Wherein, the association between the view control on list, with mutual, can adopt JavaScript and DOM technology to realize.Such as, some basic DOM can be provided in view layer platform 302A to operate (method), select for programmer; Meanwhile, programmer also can self-defined DOM method, and is associated to concrete view control.List and backstage then can adopt as ajax mode alternately, or generate the mode of interim form label submission.
4, the embodiment of " login interface "
Assuming that user needs the web system of design one " login interface ", then the generative process for view layer comprises:
1) select on interface at the control of view design platform 302A, pull a user name input frame (input-text label) and a Password Input frame (input-password label), and pull two buttons: " login " (input-button label), " replacement " (input-button label).
2) form types (as JSP, HTML etc.) needing to generate is selected: jsp; Input list ID(uniquely indicates): login.jsp.
3) attribute of each view control is edited.Such as double-click user name input frame edit properties, input ID:userName; Double-click Password Input frame edit properties, input ID:userPassword; Double-click login button edit properties, URL:login.do is submitted in input ID:loginButton, input to; Input needs the form ID:loginForm submitted to; Double-click reset button edit properties, input ID:resetButton; Input needs the form ID:loginForm reset.
4) view layer platform 302A can be that each view control generates javaScript method automatically.Such as submit to loginButton: producing interim form, an ID is: loginForm, content contain all on the page can input object (Password Input frame, Password Input frame); Action is: login.do; Last form.submit ().
Certainly, log in if user needs oneself to write javaScript method, the event attribute of login button can be edited, and change self-defining method into.
5) automation equipment generates corresponding form interface on backstage according to a series of design procedure above.
Two, the automatic generation of model layer
1、JavaBean
Model layer platform 302B uses dynamic proxy technology, using the class name (for each list generate a corresponding JavaBean) of form ID as JavaBean, html all on list can correspond to the attribute of JavaBean by input label, the JavaBean corresponding to automatically generating.
2, database
Obtain the information comprised in the JavaBean generated, the attribute information of the view control namely in view layer in corresponding list, and according to the type of database of the information of JavaBean and selected use, version and framework, automatically produce corresponding database script.
By the database script of above-mentioned generation, the database table of automatic generation corresponding with JavaBean (ID of ID and the JavaBean of such as database table, the ID of corresponding list are identical), field inside database table and the attribute one_to_one corresponding inside Javabean, thus complete the establishment to database.
Meanwhile, each JavaBean inherits a foundation class, and JavaBean mainly associates with database manipulation by this foundation class, can realize the operation to database, as increased, deleting, change, look into.
3、Action
In fact, by the request of the direct response limiting layer of JavaBean, can perform the operation to database, but in order to distinguish difference in functionality, be convenient to debugging and the division of labor of system, native system also by creating Action, thus shares the request to key-course.
Action is business processing class, and be the class of operation that of generating according to the attribute of JavaBean and method has basic database operations (additions and deletions change look into), this Action can carry out operating database by calling JavaBean.
4, SQL statement template
While generation Action, model layer platform 302B also can produce a SQL configuration file corresponding with this Action, with auxiliary support Action to the operation of database.Particularly, this SQL configuration file comprises the SQL statement template to database manipulation, then without the need to regenerating SQL statement at every turn, as long as and according to the request of key-course, the Data Identification (ID etc. as database table) of association is added into corresponding position in SQL statement template, contributes to increasing work efficiency.
Certainly, programmer can modify to Action according to actual conditions, also can modify to SQL configuration file; And the amendment of operating function for database, also can automatic synchronization in Action and SQL configuration file.
In technique scheme, by the parsing to view layer forms pages, using the various input controls of list as attribute, and generate corresponding function (method), thus obtain JavaBean.The view page on foreground can well associate with the concrete business logic processing class of background model layer by above-mentioned dynamic proxy technology, programmer is allowed only to need to be concerned about the process of concrete service logic, need not go to consider the associating of foreground and backstage, communication again, thus lifting work efficiency.
5, the embodiment of " login interface "
1) according to the list generated, create a class on backstage, its title is according to form ID (being associated): Login_jsp.java, and each attribute is consistent with the input control of list: username, usePassword; Corresponding method: getUserName (), setUserName (), getUserPassword (), setUserPassword ().
2) SQL script is generated.Specific code can be:
3) formation base class.Specific code can be:
4) Action class is generated.Specific code can be:
Three, the automatic generation of key-course
1, user's configuration
After the configuration of key-course platform 302C initialization system, enter key-course administration interface 304, and according to the configuration of user, automatically generate key-course.
User needs to generate corresponding configuration file in advance, for the functional configuration in the initial configuration of key-course and control procedure.User, without the need to writing the function code of configuration file particularly, only needs, to needing the object, mode etc. operated select or create, can automatically generate corresponding code by backstage, such as the appointment in path, only needs directly to create this path; For the appointment of operand, only need directly to choose this object.
2, processing logic
Except above-mentioned configuration, also need to arrange concrete processing logic.
1) key-course platform 302C provides the multiple framework pre-set, and user can directly select it, then processing logic corresponding for selected framework can directly be applied in current web system by key-course platform 302C.Particularly, by the configuration file of the types such as above-mentioned processing logic write web, xml is realized.
2) programmer also can not select predefined framework, but redefines processing logic according to actual conditions.Particularly, such as key-course platform 302C can generate the request URL that blocker class carrys out certain specific format ending that hook procedure person configures automatically.
More specifically, as: programmer is configured with system URL suffix at key-course administration interface 304 and is called .do, so automatic formation controller of plateform system 302 meeting, to tackle the request that all .do are suffix name, and according to the path configured during Design view layer and ID, send to blocker as request URL.Blocker is resolved the URL that obtains and is distributed to corresponding Action(business processing class).
3, the embodiment of " login interface "
1) login interface (list) is set to be submitted to login.do on view layer design platform 302A.
2) on controller management interface 304, the request that all .do tackled by blocker is configured.
3) correlation parameter of configuration is write in the web.xml file of the system that robotization generates.
4) when clicking login button, parameter can be sent to login.do, this request (request) intercepted by blocker inside web.xml, is just sent in loginAction by this request analysis, then carries out processing the processing procedure such as database manipulation particularly by loginAction.
More than be described with reference to the accompanying drawings technical scheme of the present invention, the invention provides a kind of automatically generating device of web system and a kind of automatic generation method of web system, the automation process in web system performance history can be improved, reduce manual intervention, simplify performance history.
Those skilled in the art should understand, embodiments of the invention can be provided as method, system or computer program.Therefore, the present invention can adopt the form of complete hardware embodiment, completely software implementation or the embodiment in conjunction with software and hardware aspect.And the present invention can adopt in one or more form wherein including the upper computer program implemented of computer-usable storage medium (including but not limited to magnetic disk memory, CD-ROM, optical memory etc.) of computer usable program code.
The present invention describes with reference to according to the process flow diagram of the method for the embodiment of the present invention, equipment (system) and computer program and/or block scheme.Should understand can by the combination of the flow process in each flow process in computer program instructions realization flow figure and/or block scheme and/or square frame and process flow diagram and/or block scheme and/or square frame.These computer program instructions can being provided to the processor of multi-purpose computer, special purpose computer, Embedded Processor or other programmable data processing device to produce a machine, making the instruction performed by the processor of computing machine or other programmable data processing device produce device for realizing the function of specifying in process flow diagram flow process or multiple flow process and/or block scheme square frame or multiple square frame.
These computer program instructions also can be stored in can in the computer-readable memory that works in a specific way of vectoring computer or other programmable data processing device, the instruction making to be stored in this computer-readable memory produces the manufacture comprising command device, and this command device realizes the function of specifying in process flow diagram flow process or multiple flow process and/or block scheme square frame or multiple square frame.
These computer program instructions also can be loaded in computing machine or other programmable data processing device, make on computing machine or other programmable devices, to perform sequence of operations step to produce computer implemented process, thus the instruction performed on computing machine or other programmable devices is provided for the step realizing the function of specifying in process flow diagram flow process or multiple flow process and/or block scheme square frame or multiple square frame.
The foregoing is only the preferred embodiments of the present invention, be not limited to the present invention, for a person skilled in the art, the present invention can have various modifications and variations.Within the spirit and principles in the present invention all, any amendment done, equivalent replacement, improvement etc., all should be included within protection scope of the present invention.