Realize the system and the method thereof of the service of object ensured sustained development
Technical field
The present invention relates to the service of object ensured sustained development, particularly the realization of object ensured sustained development service.
Background technology
Along with arrival of information age, the application of network has been deep into the every aspect in people's the life.The rapid increase of data volume proposes more and more higher requirement to the management of network data on the network.
Current, the exploitation network management software adopts the three-layer architecture of Client mostly, comprises client, server end and relational database (Relational DataBase is called for short RDB).On the one hand, server end links to each other with client by communication platform; On the other hand, handle RDB by database middleware.The task model that server end faces is an object oriented programming model, and it accepts standard C ++ object returns corresponding standard C++ object as a result of as the input of task after the processing of finishing the work.But the server end data model that needs to handle in the process of executing the task is a relational model, and its maneuverability pattern is the procedure-oriented formula.
Because the difference between the object oriented programming model of task and the relational model of database must be finished in the code of the task of writing in the application data is changed.In database interface (DataBase Interface is called for short DBI) function, use-pattern is the procedure-oriented formula, has occurred many closely similar functions in the code.The affairs that will finish with our task of calling of data model conversion and customary database manipulation to reality do not have direct relation, but appearance repeatedly in a large number, its result who causes is exactly:
The first, code redundancy increases greatly, and the code of significant proportion is used for the data model conversion, has increased development workload greatly.
The second, the developer is in exploitation during a task, and except the affairs logic that will know this task clearly, both its task models of GPRS is grasped the memory model of relational database again, goes back the model conversion of GPRS between them, increased development difficulty greatly.
The 3rd, under existing development mode, the data model conversion, the manipulation of database is explicit carrying out fully, in the DBI function, be flooded with the hard coded that relational database is handled in a large number, the relation schema of relational database (comprise table name, row name) and code logic close-coupled make that system's later maintenance is extremely difficult together.And for high-end webmaster program, because the variation of user's request is often relatively more frequent, system maintainability is particularly important.
Generally speaking, in most of network management system, often handle relational model, and task model is object-oriented (Object-Oriented is called for short an OO) model in the mode of procedure-oriented formula; Difference between these two kinds of models makes can only carry out model conversion by explicitly in processor-oriented coding, show ground manipulation relational database, and this is the basic place of causing above-mentioned variety of problems.Problem hereto generally has two kinds of solutions at present:
A kind of method is suitably separated semantic expressiveness with customary algorithm as shown in Figure 1.This solution comprises two levels, and ensured sustained development object object-oriented modeling and object model are to the mapping of relational database.The user at first sets up suitable ensured sustained development object model according to service logic, each concrete ensured sustained development object is explicit sets up " knowledge base " object one to one, the ensured sustained development object is finished necessary semantical definition, accordingly " knowledge base " object then explicitly finish the actual manipulation to the RDB of lower floor (as operations such as insertion, renewal, deletion, selections) by data base tool (Database Tools, be called for short DBTools).
Another kind method has had a plurality of third-party products to adopt this solution as shown in Figure 2 at present.The starting point of this scheme is that all are from object modeling, the user adopts Object Defination Language (ObjectDefine Language, abbreviation ODL) sets up OODB Object Oriented Data Base (Object-OrientedDataBase, abbreviation OODB) data model, call corresponding compiler compiling then, produce the stake code of C++ persistence object, and set up database script.Here so-called stake code is meant that the ODL compiler becomes the C++ code to the file translation that we write with ODL, and we are translated into C++ class with the class that ODL writes, and the statement of this class, code are corresponding C ++ the stake code.As framework, add suitable service logic with this code, become the sustainableization object in the system, thereby handle relational database; Management to relational database then is responsible for by special Object Manager.System is at run time call ensured sustained development object, and object storage oneself is finished by the ensured sustained development object, and the developer only can see this one deck of sustainableization object downwards when system development like this, realizes the Object oriented encapsulation of relation schema fully.
In actual applications, there is following problem in such scheme: for prior art scheme one, actual code compiling amount does not reduce, and the code redundancy phenomenon still exists, and the situation that system is difficult to safeguard, be difficult to expand does not improve.
For prior art scheme two, too huge with the workload of ODL OODB again, and development difficulty is big, for most of middle-size and small-size software enterprises, want oneself exploitation and realize unrealistic.
Cause the main cause of this situation to be, cause the in-problem in actual applications reason of prior art scheme one to be, to the database manipulation of reality what call employing is explicit modeling and explicit mapping, this must simplified code.The maintainability of system, the realization of extensibility also suffer restraints.
Cause the in-problem in actual applications reason of prior art scheme two to be, this scheme requires to set up ODL, and realization ODL compiler, be used for interface definitional language (Interface DefinationLanguage, be called for short " IDL ") translate into corresponding C++ code and relational database script, be based upon the Object Manager on the relational database.It is very huge that the writing of these codes said so from workload, can't allow most of middle-size and small-size software enterprises accept.
Summary of the invention
In view of this, fundamental purpose of the present invention is to provide a kind of system and method thereof that realizes the service of object ensured sustained development, makes that the realization of object ensured sustained development service is more simple, significantly reduces the development amount.
For achieving the above object, the invention provides a kind of system that realizes the service of object ensured sustained development, comprise database manipulation module, sustainableization object basic module and a plurality of sustainableization objects services module, wherein,
Described database manipulation module is used for realizing unified database manipulation routine by general type algorithm;
Described sustainableization object basic module is used to receive and register the semanteme that described sustainableization objects services module reports, finish concrete data base manipulation statement tissue according to calling of described database manipulation module, finish the attribute of described sustainableization objects services module and the exchanges data between the described database table field related with it;
Described sustainableization objects services module is used for reading for described database manipulation module according to described sustainableization object basic module definition self attributes and this attribute and database table field correlating method.
Wherein, described database manipulation routine comprises that inquiry, increase, change, deletion, piece to described database read and piece a kind of or its combination in any in writing.
Described sustainableization object basic module also comprises acts on behalf of submodule and field recon module, wherein,
The described submodule of acting on behalf of is used to receive and register the semanteme that described sustainableization objects services module reports;
Described field recon module is used to finish concrete query sentence of database tissue, finishes the attribute of described sustainableization objects services module and the exchanges data between the described database table field related with it.
Described system can be applicable to the network management of communication system.
The present invention also provides a kind of realization object ensured sustained development service method, comprises following steps:
Definition self attributes and this attribute and database table field correlating method in sustainableization objects services module, and be reported to sustainableization object basic module;
Described sustainableization object basic module receives and registers the semanteme that described sustainableization objects services module reports;
When carrying out database manipulation, the associated databases procedure routine that the database manipulation module invokes realizes by general type algorithm, and use the semanteme of registering in the described sustainableization object basic module to finish concrete data base manipulation statement;
Carry out described concrete data base manipulation statement, finish the exchanges data between the attribute of described sustainableization objects services module and the described database table field related with it.
Wherein, described database manipulation routine comprises that inquiry, increase, change, deletion, piece to described database read and piece a kind of or its combination in any in writing.
Described method can be applicable to the network management of communication system.
Described method also comprises following steps:
Structure and the corresponding database table structure of sustainableization objects services module.
This technical scheme has comparatively significantly beneficial effect, and technical scheme promptly of the present invention has been introduced the notion of persistence layer, thereby can unify the customary manipulation process of process database, has made things convenient for the development and maintenance of code; And solved mission mode, the unmatched problem of procedure schema, utilized the POS module that the database manipulation towards process type has been carried out Object oriented encapsulation, allowed the programmer set up corresponding sustainableization object model easily according to task model.
A whole set of POS system of Shi Xianing like this, make common object is added that a few lang justice registration code just become sustainableization object, the ODL compiler that complete unnecessary realization is extremely complicated, make that the programmer only needs these Object Operations are got final product, thereby do not need directly to greatly reduce code redundancy, reduced development workload and intensity in the face of relational database.
In practice, technical scheme of the present invention is that middle-size and small-size software enterprise is when developing in network management system, the mode with the procedure-oriented formula that faces handles relational model and task model is that the contradiction of task model provides the solution that is easy to realize with object oriented programming model, helps the business development of medium and small sized enterprises aspect network management.
Description of drawings
Fig. 1 is the structural representation of prior art scheme one;
Fig. 2 is the structural representation of prior art scheme two;
Fig. 3 is the design cycle synoptic diagram of the system of realization object ensured sustained development service according to an embodiment of the invention;
Fig. 4 is the architectural schematic of persistence objects services according to an embodiment of the invention;
Fig. 5 is that POS according to an embodiment of the invention realizes simplified diagram.
Embodiment
For making the purpose, technical solutions and advantages of the present invention clearer, the present invention is described in further detail below in conjunction with accompanying drawing.
Basic ideas of the present invention are to reduce general one by one algorithm such as customary manipulation process such as the database that inserts, upgrades, deletes, selects, reads, and these algorithms propose certain semantic requirements to the ensured sustained development object of being handled.So only need the semanteme of definition ensured sustained development object, carry out structured modeling, just can constitute OODB.The algorithm that defines as possible makes and sets up enough facilities of OODB model by hand, is a key of this programme.
Therefore technical scheme of the present invention provides an independent POS layer, the commercial product that the starting point of this method and industry have had, and as Power Tier, versant etc. are essentially different.These existing commodity are to rely on the ODL compiler that the programmer is translated into the C++ code with the object model that ODL sets up, and final goal code and manual hard coded do not have essential distinction, and only compiler generates automatically.And method of the present invention is the system of a whole set of realization of design POS, makes common object only need be added that several langs justice registration code just can become sustainableization object, the ODL compiler that complete unnecessary realization is extremely complicated.
After introducing the POS layer, system is divided into four levels: operation layer, OODB (its presentation is the object tree of sustainableization, and each node is the ensured sustained development object in the tree), POS layer, object storage layer (being RDB here).Owing to will realize that OODB must realize following technical matters.One, sustainableization object structure modeling, prevailing mode are that to set up one be the object tree of root node with the root object that does not have concrete affairs implication, and the modeling here is when being explicit modeling.Two, adjust database design, make the tissue of relation table on structure, merge mutually with sustainableization object model.Three, set up OODB, external access interface, interface mode is when the class factory of imitating in the Design Mode, and each class all is the class factory of its subclass.Four, set up POS, in order to realize the mapping of OODB to relational database.Yet first three bar all is the basis that is embodied as with the 4th, and therefore as seen, the key of technical scheme of the present invention does not lie in sets up OODB, but is to set up the facility that OODB is set up in perfect relatively being used to of a cover, and the core of this facility is exactly POS.
Below in conjunction with Fig. 3, the design cycle of the present invention program's a embodiment is further described.Use is before this flow process, at first will be at an original webmastering software ensured sustained development object model of exploitation and general ensured sustained development service layer, and adjust Structured Query Language (SQL) (Structured Query Language is called for short SQL), make data base tool support the manipulation of ensured sustained development service.
At first execution in step 100, set up the ensured sustained development object according to the requirement and the ensured sustained development object model of service logic, then enter step 110.Need to prove that the object ensured sustained development is a programmatics, is called the object ensured sustained development again, it realizes the ensured sustained development feature of object, promptly this object is saved in permanent place such as file, database, can not lose because process withdraws from.
Execution in step 110 then, utilize newly-established ensured sustained development object manipulation POS, enter step 120 then.Need to prove that the general ensured sustained development service layer that the service of POS is finished by previous exploitation provides.
Then execution in step 120 is handled original data base tool by the ensured sustained development objects services, and next execution in step 130, utilizes data base tool to finish operation to relational database.These data base tools are handled by POS, on to the operation of relational database and general data base tool and indistinction.
It is to be noted, the core concept of technical scheme of the present invention has designed a whole set of POS system exactly, the architecture of this system as shown in Figure 4, the ensured sustained development object is proposed suitable, implicit semantic requirements, a parent of unified Definition (CPersistentObject), comprise some in this parent such as object sequence number (Object Identity, be called for short OID) etc. general semanteme, and the concrete semanteme of secondary definition oneself again in each concrete class (CConcretPerObject), such as querying condition, sub-SQL of nested query or the like.(CPerObjWraper) semanteme is unified to explain that parent, subclass can be determined the SQL framework of certain flexibility ratio like this by one " parcel person "; Simultaneously three subclass CSelectPerObjWraper, the CUpdatePerObjWraper of class CPerObjWraper and CDeletePerObjWraper have further done expansion to it respectively, and function has been done refinement.The ensured sustained development object provides interface in addition, so that fill the parameter of SQL in the time of running.By above three levels, guaranteed the unification of dirigibility and ease for use, thereby reached the complexity of simplified model definition.
The ensured sustained development work of sustainableization object is finished by three objects are collaborative, and CAlgorithms provides the customary manipulation process of relational database, and ensured sustained development object CConcretPerObject comprises self necessary semanteme, and this meaning of one's words provides by object-oriented way.CPerObjWraper wraps one deck in ensured sustained development object CConcretPerObject outside, and it is understood ensured sustained development object semanteme and reports the semanteme of data base-oriented operation to CAlgorithms.
After having introduced the POS layer, system is divided into four levels: operation layer, OODB (its presentation is the object tree of sustainableization, and each node is the ensured sustained development object in the tree), POS layer, object storage layer (being RDB here).Owing to will realize that OODB must realize following technical matters.One, sustainableization object structure modeling, prevailing mode are that to set up one be the object tree of root node with the root object that does not have concrete affairs implication, and the modeling here is when being explicit modeling.Two, adjust database design, make the tissue of relation table on structure, merge mutually with sustainableization object model.Three, set up OODB, external access interface, interface mode is when the class factory of imitating in the Design Mode, and each class all is the class factory of its subclass.Four, set up POS, in order to realize the mapping of OODB to relational database.Yet first three bar all is the basis that is embodied as with the 4th, and therefore, the key of technical scheme of the present invention does not lie in sets up OODB, but is to set up the facility that OODB is set up in perfect relatively being used to of a cover, and the core of this facility is exactly POS.
As shown in Figure 5, the POS system inner structure mainly is made up of three parts: database manipulation module, sustainableization object basic module and a plurality of sustainableization objects services module.In an enforcement of the present invention, the database manipulation module is mainly realized by general type algorithm, sustainableization object basic module is the object that is called the base class generation of CperBase by, sustainableization objects services module is concrete POS object, and the concrete POS class that generates these POS objects is inherited from CPerBase.General type algorithm is handled concrete POS class, and concrete POS class is inherited from CPerBase, and CPerBase understands the semantic of the concrete POS class of storage and reports these semantemes to general type algorithm.
General type algorithm detaches outside particular type and specific data structure, makes it adapt to and vague generalization type as much as possible, and algorithm itself does not just go to be disturbed by the realization details by various data structures for its logic that need express essence of implementation algorithm.This means that general type algorithm is actual has two parts: the one group of demand condition that is used for describing the actual instruction of algorithm essence logic and correctly specifies the character that its parameter type must satisfy.Its core is exactly that abstract condition becomes core in the programming procedure, thereby replaced the core status of type in the OO the inside, exactly because type not at the emphasis of considering, type becomes the coat of abstract condition, so claim such program thought to be general type thought, promptly extensive type.In native system, realize general inquiry, increase, change, deletion and BulkRead/BulkWrite operation by several stencil function.Each general type algorithm is handled concrete object, obtains GetSelecter, GetInserter, GetUpdater, GetDeleter, Read semanteme during operation, realizes general database manipulation.
These objects are mapped to the record of corresponding table, and best property of attribute mapping is mapped as table for the field of record with object sequence.The operation of general type algorithm is divided into operation of table one-level and the operation of record one-level.The operation of table one-level comprises select (inquiry), bulkread (piece is read), bulkwrite operations such as (piece are write); The operation of record one-level: comprise insert (insertion), update (renewal), delete (deletion) operation is the operation at concrete some objects.Ensured sustained development object implementation strategy has a principle, it by table one-level operational instancesization after, himself be one " Smart object ", can self status change, the ensured sustained development operation is finished oneself in self-destruction.
By analyzing general type algorithm, the semantic minimal set that can find the ensured sustained development object to provide.It needs to be noted when assert semanteme, we should use the template method in the behavior pattern in the Design Mode, complete empty method that is used for assembly unit SQL of definition in the parent of ensured sustained development object, as: GetColumnName, GetTableName, GetWhereCondition, GetOrderByCondition or the like.Concrete ensured sustained development object doing suitable selectable heavy duty, is accomplished the unification of dirigibility and ease for use thus when modeling.
Concrete POS class definition attribute and this attribute method related of self with the database table field, understand for general type algorithm.
The CPerBase class is the core of POS, the parent of the POS class that each is concrete, and unification is stored the semantic of concrete POS object surely and interface is provided, for general type algorithm invokes.An its inner CProxy class and CFieldExchange class of preserving, the CProxy class is responsible for understanding the semanteme of each concrete POS class of storage, and the CFieldExchange class then is responsible for reading from database information pours in the attribute of POS class or the attribute of POS class is poured in the database.In fact the effect of CPerBase is equivalent to a register, and concrete POS class is registered to it when its object of structure, and general type algorithm is searched from this register when handling the POS object, if do not find the registration of then being correlated with.When specific implementation, technical scheme of the present invention has solved two concrete technology: how to break object accesses control barrier and how to allow collection class vector identification xenogenesis data type.For first technology,, therefore cannot use the ClassObject.m_Attrib method owing in the CPerBase class, do not know ClassObject.And for second technology, the present invention program provides a default situation, and promptly a vector only can preserve the variable of a data type.
The workflow of the system of above-mentioned realization object ensured sustained development service is as follows:
Definition self attributes and this attribute and database table field correlating method in sustainableization objects services module, and be reported to sustainableization object basic module.
Sustainableization object basic module receives and registers the semanteme that sustainableization objects services module reports.Registration has comprised the implication of understanding and storing two aspects.
When carrying out database manipulation, the associated databases procedure routine that the database manipulation module invokes realizes by general type algorithm, and use the semanteme of registering in the sustainableization object basic module to finish concrete query sentence of database.For example, in the time of need carrying out the delete operation, the framework that has only general type algorithm to realize in the database manipulation module, can't finish concrete Sq1 statement, need call sustainableization object basic module, registered in this module and finished the details that concrete Sq1 statement needs, can finish the establishment of concrete Sq1 statement according to these details.
Carry out concrete query sentence of database, finish the exchanges data between the attribute of sustainableization objects services module and the database table field related with it.The concrete mode of exchanges data is defined among the CperBase.
Though by reference some preferred embodiment of the present invention, the present invention is illustrated and describes, but those of ordinary skill in the art should be understood that, can do various changes to it in the form and details, and the spirit and scope of the present invention that do not depart from appended claims and limited.