CN110457013B - Program component configuration device and method - Google Patents

Program component configuration device and method Download PDF

Info

Publication number
CN110457013B
CN110457013B CN201910631088.XA CN201910631088A CN110457013B CN 110457013 B CN110457013 B CN 110457013B CN 201910631088 A CN201910631088 A CN 201910631088A CN 110457013 B CN110457013 B CN 110457013B
Authority
CN
China
Prior art keywords
class
model class
original
new annotation
annotation
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Active
Application number
CN201910631088.XA
Other languages
Chinese (zh)
Other versions
CN110457013A (en
Inventor
杨贾冰
陈双
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Advanced Nova Technology Singapore Holdings Ltd
Original Assignee
Advanced New Technologies Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Advanced New Technologies Co Ltd filed Critical Advanced New Technologies Co Ltd
Priority to CN201910631088.XA priority Critical patent/CN110457013B/en
Publication of CN110457013A publication Critical patent/CN110457013A/en
Application granted granted Critical
Publication of CN110457013B publication Critical patent/CN110457013B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F8/00Arrangements for software engineering
    • G06F8/20Software design
    • G06F8/24Object-oriented

Landscapes

  • Engineering & Computer Science (AREA)
  • Software Systems (AREA)
  • General Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Physics & Mathematics (AREA)
  • General Physics & Mathematics (AREA)
  • Stored Programmes (AREA)

Abstract

An embodiment of the invention provides a device and a method for configuring a program component, wherein the device comprises: the annotation processor is used for converting the original data model class marked by the unified annotation into a new annotation model class matched with the database frame type based on the database frame type adopted by the application program; a database operation interface for receiving a call request from the application program to the program component; and the reflection processor is used for responding to the calling request and transmitting a new annotation model class corresponding to the type of the database framework adopted by the application program to the database framework adopted by the application program.

Description

Program component configuration device and method
Technical Field
The present invention relates to software technology, and more particularly to unified programming of program components for different database frameworks.
Background
The software modular design enables software function scalability. Typically, in order to implement a specific function, a developer may design a specific functional component, package the required function into a Software Development Kit (SDK) component, and provide the Software Development Kit (SDK) component to an APP, where the functional component is embedded in the APP as required, for example, in a plug-in form, and the APP only needs to call an interface provided by the SDK to implement the packaged function, thereby achieving the function of enriching the application.
In APP component development, the SDK component often needs to perform database storage operations, for example, the message box component needs to store the content of the message locally, and the database storage must be implemented by calling the database framework to which the APP itself has access. It is therefore necessary to develop corresponding SDK components for APPs conforming to different database frameworks. For example for storing message details, wherein the message details comprise a title and a content. If APP uses sqlite database framework for database storage, then the model class needs to be defined in the message box component:
and then, calling the sqlite database framework interface to realize the storage of the specific Message data.
For implementing the same function of storing message details, if the APP uses the orm lite framework for database storage, then the model class needs to be defined additionally:
and then, calling an orm Lite database framework interface to store Message data in the model class.
It can be seen that for APP supporting different database framework types, even for developing SDK components of the same functionality, different programs need to be compiled separately, e.g. under the sqlite database framework, there is no markup solution, while under the orm lite framework, it is often necessary to define annotations at programming time, i.e. syntax in the above programs that is booted at @.
Disclosure of Invention
In order to avoid developing SDK components with exactly the same functionality but with different programming due to different database frameworks supported by APPs, it is desirable to provide uniform programming code from a component design perspective that can be configured for APP use under different database frameworks rather than configuring data classes and invoking code logic stored by the database according to the case where the different APPs use the database frameworks.
Therefore, the invention provides a scheme for converting the custom annotation into the annotation suitable for each different database frame by using the unified custom annotation through the annotation processor in the compiling stage, and converting the annotation model class through reflection operation in the program running stage, thereby realizing the purpose of running under different application programs APP by using the same set of codes.
According to one aspect of the present invention, there is provided an apparatus for configuring a program component, wherein the program component contains an original data model class annotated with a uniform annotation, the apparatus comprising: an annotation processor for converting the original data model class into a new annotation model class matching the database frame type based on the database frame type employed by the application; a database operation interface for receiving a call request from the application program to the program component; and the reflection processor is used for responding to the calling request and transmitting a new annotation model class corresponding to the type of the database framework adopted by the application program to the database framework adopted by the application program. In a preferred embodiment, the configuration means of the program component further comprises: a type determining module for determining a type of database framework employed by the application program loading the program component; wherein if the original data model class in the program component does not match the database frame type, the annotation processor converts the original data model class to a new annotation model class that matches the database frame type.
According to one aspect of the invention, there is provided a method of configuring a program component, wherein the program component contains an original data model class annotated with a uniform annotation, comprising: converting the original data model class into a new annotation model class matched with the database frame type based on the database frame type adopted by the application program; receiving a call request from the application program to the program component; and responding to the call request, and transmitting a new annotation model class corresponding to the type of the database framework adopted by the application program to the database framework adopted by the application program. .
According to an aspect of the present invention, there is provided an intelligent terminal including: a memory for storing an application program; a processor for executing the application program, wherein the application program is programmed to include a plug-in comprising: the database operation interface is used for receiving a call request from the application program to the plug-in; and a reflection processor, configured to transmit, in response to the call request, a new annotation model class corresponding to a database framework type adopted by the application program in the plugin to a database framework used by the application program, where the new annotation model class is generated based on an original data model class that is annotated with a unified annotation in the plugin, so as to implement a function of the plugin.
According to one aspect of the present invention there is provided a machine readable medium having stored thereon program code which when executed by a machine causes the machine to perform the method of the present invention.
Drawings
FIG. 1 illustrates a schematic block diagram of program components, according to one embodiment;
FIG. 2A illustrates a schematic block diagram of compile-time data model class conversion, in accordance with one embodiment;
FIG. 2B illustrates a schematic block diagram of a program runtime data model class call, in accordance with one embodiment;
FIG. 3 illustrates a schematic block diagram of a program runtime data model class call, in accordance with another embodiment;
FIG. 4 illustrates a schematic diagram of the interoperation of an APP, component, annotation processor, and reflection processor, in accordance with one embodiment;
FIG. 5 illustrates a flowchart of program component execution according to one embodiment;
fig. 6 shows a schematic diagram of a terminal according to an embodiment of the invention.
Detailed Description
The following describes in detail the apparatus and method provided by the embodiments of the present invention with reference to the accompanying drawings. While the preferred embodiments of the present disclosure are shown in the drawings, it should be understood that the present disclosure may be embodied in various forms and should not be limited to the embodiments set forth herein. Rather, these embodiments are provided so that this disclosure will be thorough and complete, and will fully convey the scope of the disclosure to those skilled in the art. The following describes the concepts and embodiments of the present invention using Java programming as an example.
The Java language is now widely used, particularly in Java language version 5.0, to support special syntax metadata added to source code. Classes, methods, variables, parameters, packages, etc. in the Java language can be annotated and custom Java annotations are supported. Unlike Java doc, java labels can obtain label content through reflection. During the compilation of Java source code, annotations may be processed by the annotation processor and generated as messages containing information or as additional Java source code files or resources, while newly added Java source code files may also be compiled and processed and modify the annotated code itself. Furthermore, the Java language provides Java reflection mechanisms for observing and modifying the behavior of programs at runtime. In Java, reflection allows classes, interfaces, fields and methods to be checked at runtime without knowing the name of the interface, fields (i.e. member variables), method during compilation. It also allows calls to instantiate new objects and different methods based on the determination. One or more embodiments of the present invention utilize the annotation interpretation and reflection mechanism of Java to achieve unified programming for multi-database frameworks.
Fig. 1 illustrates a program component 100 according to one embodiment of the invention, where the program component 100 may be a stand-alone SDK component or plug-in that may be embedded in an application APP to invoke functionality preprogrammed by the SDK component, such as access to a database. In accordance with one or more embodiments of the present invention, the configuration device 102 is integrated within the program component 100. When it is desired to integrate the program component 100 into the application program APP, the configuration device 102 may adaptively configure the program and operating mechanism of the program component 100 according to the characteristics of the application program APP. The application APP here may be any application known to run on a smart terminal, which may be a computing device including, for example, a computer, a cell phone, a tablet, etc.
As shown in fig. 1, the program component 100 includes a program 101 and a configuration device 102. The program 101 stores therein an Original data model Class origin_class labeled with a unified annotation for realizing a predetermined function. The unified annotation here may be a custom annotation, such as a custom Java annotation. One example of the raw data model Class origin_class annotated with custom annotations is shown below:
in this example, a database model class Message class is annotated with a unified annotation IAPDatabaseTable, IAPDatabaseField, in which the operational parameters such as methods, attributes, etc. are defined.
The configuration device 102 includes a type determination module 104, an annotation processor 106, a database operation interface 108, and a reflection processor 110. When the SDK component 100 is integrated into the application APP and compiled, the type determination module 104 determines the database Frame type db_frame employed by the application APP that loads the SDK component 100. The database framework type here may be any type known in the art that is common across APPs, such as SQlite, ormLite, greenDAO, etc. As one example, the type determination module 104 may further determine whether the Original data model Class origin_class in the SDK component matches the determined database Frame type db_frame, where the matching is whether the Original data model Class and its unified annotation are supported by the database Frame. For example, when the database Frame db_frame supports the unified annotation or when the database Frame db_frame does not require an annotation at runtime, then the original data model class is considered to match the database Frame type db_frame.
If the Original data model Class origin_class in the program 101 does not match the database Frame type DB_frame, the annotation processor 106 generates a New annotation model Class New_class matching the database Frame type DB_frame based on the Original data model Class origin_class and stores the New annotation model Class New_class into the program 101, where the Original data model Class and the New annotation model Class implement the same predetermined function of the SDK component. In generating the New annotation model Class New_class, according to one example of the invention, the annotation processor 106 scans the unified annotation of the Original data model Class original_class to convert the unified annotation into a specific annotation conforming to the database Frame type DB_frame for annotating the New annotation model Class New_class. At the same time, a new annotation model class is associated with the original data class using an identifier field, e.g., an identifier is added to the class name of the original data class.
By way of example, FIG. 2A illustrates class conversion implemented by annotation processor 106 when application APP employs an ormLite database framework. As shown, in this example, the SDK component 100 is a Message box component for storing messages having an original data model class Message in which the title (title) and content (content) of the Message are defined, and further, the Message is annotated with custom uniform annotations @ IAPDatabaseTable, @ IAPDatabaseField to the databases and method attributes involved in the class. Because the custom unified annotation @ IAPDatabaseTable, @ IAPDatabaseField is not an annotation supported by the database framework ormLite employed by the current application APP, during compilation, the annotation processor 106 scans the Message box assembly with the unified annotation model class Message class, converts the unified annotation @ IAPDatabaseTable, @ IAPDatabaseField to an annotation @ databaseTable, @ databaseField supported by the ormLite, respectively, and creates a new annotation model class GenMessage class whose name consists of the original model class name Message plus the prefix "Gen".
When the application APP runs and wishes to Call the SDK component to implement a predetermined function, the database operation interface 108 receives a call_sdk from the application APP for the Call of the SDK component, and transmits a database operation specific request, such as storage, of the database framework used by the application APP through the component database operation interface 108.
It should be noted here that the SDK component 100 is implemented using the Original model Class original_class when performing a specific database operation, but the actual database storage is implemented by an application APP database framework such as (orm lite). To this end, the reflection processor 110 transmits a class object of a New annotation model class new_class corresponding to the database frame type employed by the application APP to the database frame of the application APP in response to the Call request call_sdk. Taking an application APP that uses the orm lite database framework as an example, as shown in fig. 2B, the reflection processor 110 receives a Call request call_sdk of the application APP by using the database operation interface 108, and may determine that the annotation model class supported by the current APP is an orm lite data model class. Thus, the reflection processor 110 traverses the original data model class to obtain class objects of the model class, which include parameters in the class and parameter values for each parameter that the SDK component generates when performing a particular database operation. Taking the above message box component as an example, through the reflection processing, the reflection processor 110 may obtain a class object (message. Class) of the original data model class and specific values of a message title (title) and a content (content) in the class object, and the reflection processor 110 encapsulates the obtained specific values of parameters into corresponding characteristic parameters title and content in the new annotation model class GenMessage. The reflection processor 110 then transmits the class object genmessage class of the new annotation model class to the orm lite database framework in the application APP to implement the database storing the message.
It should be noted that, the Message Class is only used as an example for illustration, but the Original data model Class origin_class is not limited to one entity Class, and may include other types of classes and a greater number of entity classes, and in operation, the reflection processor 110 may traverse all entity classes and objects in the classes and switch to the New annotation model Class new_class.
Furthermore, it should be noted that the type determining module 104 is not an essential component in the configuration device 102 in this example, for example, the configuration device 102 may directly receive the database Frame type db_frame employed by the application program APP specified by the user from the outside, and further determine whether the Original data model Class original_class in the program component 100 matches the specified database Frame type db_frame.
Fig. 3 shows an example in which the Original data model Class original_class in the SDK component matches the database Frame type db_frame, with a message box component as an example of the SDK component. As shown, the APP here employs the SQLite database framework, which does not require annotations at runtime, so the annotation processor 106 does not need to make any transformations of the unified annotations during the compilation phase. When the APP is operated, each object in the original data model class Message can be directly used through a database operation interface.
Fig. 4 shows a schematic diagram of the operation between the application APP, the SDK component, the annotation processor and the reflection processor in the compiling and executing stage, where the SDK component, the annotation processor and the reflection processor are separately provided for the purpose of illustration.
As shown in FIG. 1.1, the Original data model Class, labeled with a uniform annotation, is pre-programmed in the program 101 of the SDK component. For example, for the Message box component shown in FIG. 2A, the Message class of the original data model class is annotated with custom uniform annotations @ IAPDatabase Table, @ IAPDatabase Field. As shown in figure 1.2, in the compilation phase, when it is desired to integrate an SDK component into an APP, the database framework types db_frames supported by the APP may be transferred to the annotation processor. As shown in FIG. 1.3, the annotation processor generates a corresponding new annotation model class supporting the database Frame DB_frame from the database Frame type DB_frame. As shown in fig. 2A, when the database Frame type db_frame is orm lite, the annotation processor scans the model class Message class with unified annotation in the SDK component, converts the unified annotation @ IAPDatabaseTable, @ IAPDatabaseField therein into a new annotation @ DatabaseTable, @ DatabaseField supporting orm lite, and creates a data model class GenMessage class, the new annotation model class name of which is composed of the model class name Message plus a prefix identifier "Gen". The annotation processor then returns the created data model class GenMessage class to the SDK component, e.g., stored in program 101, at 1.4.
When the APP runs, for example, it wants to call the SDK component to implement a predetermined function, for example, message storage, as shown in fig. 2.1, the APP issues a call request call_sdk to the SDK component through the database operation interface, and the SDK component operates the original data model class, for example, the Message class, to perform a Message storage operation, and the operation result is that, for example, the title and content of the Message are stored in the title and content attributes of the Message class. Meanwhile, as shown in 2.2, the reflection processor searches for a New annotation model class new_class corresponding to the type db_frame from the program 101 based on the database Frame type db_frame of the current APP that issued the call request. For example, as shown in FIG. 2B, when the APP supports an ormLite database framework, the reflection processor may determine that the corresponding new annotation model class is an ormLite. Subsequently, as shown in 2.3, the reflection processor obtains a Class object, e.g., message Class, of the original model Class to generate a Class object, e.g., genMessage Class, of the new annotation model Class. As one example, the process of generating a Class object of a new annotation model Class by a reflection processor is as follows:
(1) And obtaining a class (class) object of the new annotation model class from a mapping relation cache of the class object of the original model class and the class object of the new annotation model class. If the cache does not exist, the class name of the model class is obtained from the class object of the original model class through reflection, an identifier such as Gen is added to form the class name of the new annotation model class, then the class object of the new annotation model class is generated based on the class object of the original model class through reflection, and the mapping relation between the class object of the original model class and the class object of the new annotation model class is stored in the mapping cache.
(2) Obtaining the mapping relation between the member variable names of the original model class and the new annotation model class and the Field (Field) object from the cache, wherein any cache does not exist, and obtaining the mapping relation between the member variable names on the original model class or the new annotation model class and the Field object through reflection and writing the mapping relation into the cache;
(3) Traversing the member variable names of the new annotation model class, obtaining the field object from the mapping relation cache of the member variable names of the original model class and the field object for each member variable name, obtaining the values of the same-name member variables on the original model class object through reflection, and setting the member variable values of the original model class object to the same-name member variables of the new annotation model class object through reflection.
Returning to FIG. 4, after reflection processing, the reflection processor returns a class object GenMessage. Class of the new annotation model class, as shown in FIG. 2.4. Thus, as shown in 2.5 and 2.6, the actual operation on the database is realized based on the class object GenMessage.class of the new annotation model class under the ormLite database framework of the APP, and the APP can return the result of the operation such as message storage.
Fig. 5 shows a flowchart for configuring an SDK component according to one embodiment of the present invention, in the following example, a message box component is taken as an example, and APP uses both the orm lite and SQLite database frameworks to perform database operations, respectively, for convenience of explanation. The message box component encapsulates the raw data model class with a unified annotation markup that is custom in the Java language, e.g.,
as shown in fig. 5, when it is desired to integrate the message box combination in the APP, at step 502, a database Frame type db_frame employed by the application APP that is desired to load the message box component is determined at the APP compilation stage, as described above, wherein determining the Frame type db_frame may be implemented either by user specification or by self-judgment. The process then proceeds to step 504 where it is determined whether the database Frame type DB_frame matches the Original data model Class original_class. If the database Frame DB_frame employed by the current APP does not match the Original data model Class original_class, e.g., the current APP employs the orm Lite Frame, then the process proceeds to step 506.
At step 506, the unified annotation of the Original data model Class original_class is scanned with the annotation processor to convert the unified annotation into a specific annotation conforming to the database Frame type DB_frame of the current APP for annotating the New annotation model Class New_class. At the same time, a new annotation model class is associated with the original data class using an identifier field. As illustrated in the example of FIG. 2A, when the current APP employs the ormLite database framework, the annotation processor 106 scans the Message box component, converting the unified annotation @ IAPDatabase Table, @ IAPDatabase Field to the annotations @ Database Table, @ Database Field supported by the ormLite, respectively, while creating a new annotation model class GenMessage class whose name is composed of the model class name Message prefixed by the prefix "Gen". Furthermore, the compiling process of the whole APP is completed. If it is determined in step 504 that the database framework adopted by the current APP matches the Original data model Class origin_class, for example, when the current APP adopts the SQLite framework, the whole APP compiling process is completed directly without annotating the conversion process.
In step 508, a call request, such as a message store operation, is received from the APP through the database operation interface during the application APP run phase. At step 510, a data model class is determined that matches the database framework of the current application APP based on the call request. As described in the previous example, if the current APP adopts the SQLite framework, the data storage operation can be directly performed based on the Original data model Class original_class, as shown in FIG. 3; and if the current APP employs the orm lite framework, proceed to step 512. As previously described, in the compilation stage, the new annotation model class, the ormLite data model class, has been previously converted in the SDK component, as shown in FIG. 2B, so in step 512, the ormLite new annotation model class corresponding to the ormLite framework employed by the application is transferred to the ormLite database framework in the application APP in response to the call request using the reflection mechanism. For the message box component in this example, through reflection processing, the reflection processor may obtain a class object (message. Class) of the original data model class and specific values of a message title (title) and content (content) in the class object, and the reflection processor encapsulates the obtained specific values of parameters into corresponding feature parameters title and content in a new annotation model class GenMessage. Then, in step 514, the reflection processor transmits the class object genmessage/class of the new annotation model class to the orm lite database framework in the application APP to implement the operation of the database in storing the message.
By utilizing the scheme of the invention, the new annotation model class aiming at different database frameworks (for example SQlite, ormLite) can be automatically generated through the annotation processor, and then the generated new annotation class object is acquired by using a Java reflection mechanism in the actual database operation, so that the actual database operation is carried out under different database frameworks by using the original data model class on the basis of the same set of unified annotation.
According to the invention, the application APP can be installed on any terminal, such as a computer, a mobile phone, etc. Fig. 6 illustrates an intelligent terminal comprising a memory storing an application APP and a processor, wherein the processor can execute the stored application to enable database access. In accordance with one or more embodiments of the present invention, an application APP is programmed to include a plug-in to implement a predetermined function, wherein the plug-in includes: the system comprises a database operation interface and a reflection processor, wherein the database operation interface is used for receiving a call request from an application program to a plugin, and then responding to the call request, the reflection processor transmits a new annotation model class corresponding to a database framework type adopted by an application program APP in the plugin to a database framework used by the application program, wherein the new annotation model class is generated based on an original data model class marked by unified annotation in the plugin so as to realize the function of the plugin. In one example, a reflection processor obtains feature parameters and parameter values thereof in an original data model class, wherein the parameter values in the original data model class are generated by the program component operating the original data model class, and encapsulates the obtained parameter values as parameter values of corresponding feature parameters in the new annotation model class. It should be noted that, in addition to the processor, the memory, and the nonvolatile memory shown in fig. 6, the intelligent terminal implementing the execution of the program component in the embodiment generally may further include other hardware according to its actual functions, which will not be described herein.
It should be noted here that while the invention has been described in connection with the preferred embodiments described above, it is obvious that the invention is not limited thereto. Further, the modules in fig. 1 may include processors, electronics devices, hardware devices, electronics components, logic circuits, memories, software codes, firmware codes, etc., or any combination thereof. Those of skill would further appreciate that the various illustrative logical blocks, modules, and method steps described in connection with the disclosure herein may be implemented as electronic hardware, computer software, or combinations of both. Taking a software implementation as an example, as a device in a logic sense, the device is formed by a processor executing corresponding computer program instructions in a nonvolatile memory to read the corresponding computer program instructions from the memory. Another embodiment of the invention provides a machine-readable medium having stored thereon machine-readable instructions which, when executed by a computer, cause the computer to perform any of the methods disclosed herein. In particular, a system or apparatus may be provided that is equipped with a machine-readable medium on which is stored software program code that implements the functionality of any of the above embodiments, and causes a computer of the system to read and execute machine-readable instructions stored in the machine-readable medium. In this case, the program code itself, read from a machine-readable medium, may implement the functions of any of the above-described embodiments, and thus the machine-readable code and the machine-readable medium storing the machine-readable code form part of the present invention.
It should be noted that not all steps or modules in the above-described flow and structure of the apparatus are necessary, and some steps or modules may be omitted according to actual needs. The execution sequence of the steps is not fixed and can be adjusted as required. The system structure described in the above embodiments may be a physical structure or a logical structure, that is, some modules may be implemented by the same physical entity, or some modules may be implemented by multiple physical entities, or may be implemented jointly by some components in multiple independent devices.
While the invention has been illustrated and described in detail in the drawings and in the preferred embodiments, the invention is not limited to the disclosed embodiments, and it will be appreciated by those skilled in the art that the code audits of the various embodiments described above may be combined to produce further embodiments of the invention, which are also within the scope of the invention.

Claims (12)

1. An apparatus for configuring a program component, wherein the program component contains an original data model class annotated with a uniform annotation, the apparatus comprising:
an annotation processor for converting the original data model class into a new annotation model class matching the database frame type based on the database frame type employed by the application, wherein the annotation processor scans the unified annotation of the original data model class to convert the unified annotation into a specific annotation conforming to the database frame type for annotating the new annotation model class and associates the new annotation model class with the original data model class using an identifier field;
a database operation interface for receiving a call request from the application program to the program component; and
and the reflection processor is used for responding to the calling request and transmitting a new annotation model class corresponding to the type of the database framework adopted by the application program to the database framework adopted by the application program.
2. The apparatus of claim 1, further comprising:
a type determining module for determining a type of database framework employed by the application program loading the program component;
wherein if the original data model class in the program component does not match the database frame type, the annotation processor converts the original data model class to a new annotation model class that matches the database frame type.
3. The apparatus of claim 1 or 2, wherein the reflection processor obtains feature parameters and parameter values thereof in an original data model class, and encapsulates the obtained parameter values as parameter values for corresponding feature parameters in the new annotation model class, wherein the parameter values in the original data model class are generated by the program component operating the original data model class.
4. The apparatus of claim 3, wherein the annotation processor and the reflection processor are Java type processors, and the reflection processor further obtains a Class object of an original model Class to generate a Class object of a new annotation model Class, comprising:
(1) Obtaining a class object of the new annotation model class from a mapping relation cache of the class object of the original model class and the class object of the new annotation model class; if the cache does not exist, obtaining the class name of the model class from the class object of the original model class through reflection, adding an identifier to form the class name of the new annotation model class, then generating the class object of the new annotation model class through reflection based on the class object of the original model class, and storing the mapping relation between the class object of the original model class and the class object of the new annotation model class into the mapping cache;
(2) Obtaining the mapping relation between the member variable names of the original model class and the new annotation model class and the Field objects from the cache, wherein if the mapping relation between the member variable names of the cache and the Field objects does not exist, the mapping relation between the member variable names of the original model class or the new annotation model class and the Field objects is obtained through reflection and written into the cache;
(3) Traversing the member variable names of the new annotation model class, obtaining the field object from the mapping relation cache of the member variable names of the original model class and the field object for each member variable name, obtaining the values of the same-name member variables on the original model class object through reflection, and setting the member variable values of the original model class object to the same-name member variables of the new annotation model class object through reflection.
5. A method of configuring a program component, wherein the program component contains an original data model class annotated with a uniform annotation, comprising:
based on the database frame type adopted by the application program, converting the original data model class into a new annotation model class matched with the database frame type by using an annotation processor, wherein the method comprises the steps of scanning unified annotations of the original data model class to convert the unified annotations into specific annotations conforming to the database frame type for annotating the new annotation model class, and simultaneously associating the new annotation model class with the original data model class by using an identifier area;
receiving a call request from the application program to the program component;
and responding to the call request, and transmitting a new annotation model class corresponding to the type of the database framework adopted by the application program to the database framework adopted by the application program by utilizing a reflection processor.
6. The method of claim 5, further comprising:
determining a database framework type adopted by the application program loading the program component;
and if the original data model class in the program component is not matched with the database frame type, converting the original data model class into a new annotation model class matched with the database frame type.
7. The method of claim 5 or 6, wherein transmitting a new annotation model class corresponding to a database framework type employed by the application to the database framework employed by the application further comprises:
and acquiring characteristic parameters and parameter values thereof in an original data model class by using the reflection processor, and packaging the acquired parameter values into parameter values of corresponding characteristic parameters in the new annotation model class, wherein the parameter values in the original data model class are generated by operating the original data model class by the program component.
8. The method of claim 7, wherein the annotation processor and the reflection processor are Java type processors, and the reflection processor further obtains a Class object of an original model Class to generate a Class object of a new annotation model Class, comprising:
(1) Obtaining a class object of the new annotation model class from a mapping relation cache of the class object of the original model class and the class object of the new annotation model class; if the cache does not exist, obtaining the class name of the model class from the class object of the original model class through reflection, adding an identifier to form the class name of the new annotation model class, then generating the class object of the new annotation model class through reflection based on the class object of the original model class, and storing the mapping relation between the class object of the original model class and the class object of the new annotation model class into the mapping cache;
(2) Obtaining the mapping relation between the member variable names of the original model class and the new annotation model class and the Field objects from the cache, wherein if the mapping relation between the member variable names of the cache and the Field objects does not exist, the mapping relation between the member variable names of the original model class or the new annotation model class and the Field objects is obtained through reflection and written into the cache;
(3) Traversing the member variable names of the new annotation model class, obtaining the field object from the mapping relation cache of the member variable names of the original model class and the field object for each member variable name, obtaining the values of the same-name member variables on the original model class object through reflection, and setting the member variable values of the original model class object to the same-name member variables of the new annotation model class object through reflection.
9. An intelligent terminal, comprising:
a memory for storing an application program;
a processor for executing the application program, wherein the application program is programmed to include a plug-in comprising:
the database operation interface is used for receiving a call request from the application program to the plug-in; and
and a reflection processor for transmitting a new annotation model class corresponding to the database framework type adopted by the application program in the plugin to the database framework used by the application program in response to the call request, wherein the new annotation model class is generated by using an original data model class marked by the unified annotation in the plugin so as to realize the function of the plugin, wherein the new annotation model class is marked by scanning the unified annotation of the original data model class to convert the unified annotation into a specific annotation conforming to the database framework type, and the new annotation model class is associated with the original data model class by using an identifier area.
10. The intelligent terminal of claim 9, wherein the reflection processor obtains feature parameters and parameter values thereof in an original data model class, and encapsulates the obtained parameter values as parameter values for corresponding feature parameters in the new annotation model class, wherein the parameter values in the original data model class are generated by a program component operating the original data model class.
11. The intelligent terminal of claim 9 or 10, wherein the reflection processor is a Java type processor, and the reflection processor further obtains a Class object of an original model Class to generate a Class object of a new annotation model Class, comprising:
(1) Obtaining a class object of the new annotation model class from a mapping relation cache of the class object of the original model class and the class object of the new annotation model class; if the cache does not exist, obtaining the class name of the model class from the class object of the original model class through reflection, adding an identifier to form the class name of the new annotation model class, then generating the class object of the new annotation model class through reflection based on the class object of the original model class, and storing the mapping relation between the class object of the original model class and the class object of the new annotation model class into the mapping cache;
(2) Obtaining the mapping relation between the member variable names of the original model class and the new annotation model class and the Field objects from the cache, wherein if the mapping relation between the member variable names of the cache and the Field objects does not exist, the mapping relation between the member variable names of the original model class or the new annotation model class and the Field objects is obtained through reflection and written into the cache;
(3) Traversing the member variable names of the new annotation model class, obtaining the field object from the mapping relation cache of the member variable names of the original model class and the field object for each member variable name, obtaining the values of the same-name member variables on the original model class object through reflection, and setting the member variable values of the original model class object to the same-name member variables of the new annotation model class object through reflection.
12. A machine readable medium having stored thereon program code, wherein the program code when executed by a machine causes the machine to perform the method of claims 5-8.
CN201910631088.XA 2019-07-12 2019-07-12 Program component configuration device and method Active CN110457013B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201910631088.XA CN110457013B (en) 2019-07-12 2019-07-12 Program component configuration device and method

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201910631088.XA CN110457013B (en) 2019-07-12 2019-07-12 Program component configuration device and method

Publications (2)

Publication Number Publication Date
CN110457013A CN110457013A (en) 2019-11-15
CN110457013B true CN110457013B (en) 2023-11-17

Family

ID=68481167

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201910631088.XA Active CN110457013B (en) 2019-07-12 2019-07-12 Program component configuration device and method

Country Status (1)

Country Link
CN (1) CN110457013B (en)

Families Citing this family (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN113448995A (en) * 2020-03-25 2021-09-28 北京沃东天骏信息技术有限公司 Database operation method, device and system, electronic equipment and storage medium
CN112068902B (en) * 2020-09-10 2021-07-30 北京五八信息技术有限公司 Plug-in calling method and device, electronic equipment and storage medium

Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN103020064A (en) * 2011-09-20 2013-04-03 佳都新太科技股份有限公司 Method and configuration for generating query condition in annotation way
CN105868270A (en) * 2016-03-17 2016-08-17 央广视讯传媒股份有限公司 Android object storing framework based on reflection mechanism
CN106302442A (en) * 2016-08-12 2017-01-04 广州慧睿思通信息科技有限公司 A kind of network communication packet analytic method based on Java language
CN106295390A (en) * 2015-06-08 2017-01-04 阿里巴巴集团控股有限公司 A kind of method and device of information processing
CN108628635A (en) * 2018-05-07 2018-10-09 广州视源电子科技股份有限公司 Method, apparatus, equipment and the storage medium of the name that gets parms and local variable name

Family Cites Families (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20060031820A1 (en) * 2004-08-09 2006-02-09 Aizhong Li Method for program transformation and apparatus for COBOL to Java program transformation
US20140181630A1 (en) * 2012-12-21 2014-06-26 Vidinoti Sa Method and apparatus for adding annotations to an image
US9430523B2 (en) * 2013-09-06 2016-08-30 Sap Se Entity-relationship model extensions using annotations

Patent Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN103020064A (en) * 2011-09-20 2013-04-03 佳都新太科技股份有限公司 Method and configuration for generating query condition in annotation way
CN106295390A (en) * 2015-06-08 2017-01-04 阿里巴巴集团控股有限公司 A kind of method and device of information processing
CN105868270A (en) * 2016-03-17 2016-08-17 央广视讯传媒股份有限公司 Android object storing framework based on reflection mechanism
CN106302442A (en) * 2016-08-12 2017-01-04 广州慧睿思通信息科技有限公司 A kind of network communication packet analytic method based on Java language
CN108628635A (en) * 2018-05-07 2018-10-09 广州视源电子科技股份有限公司 Method, apparatus, equipment and the storage medium of the name that gets parms and local variable name

Non-Patent Citations (4)

* Cited by examiner, † Cited by third party
Title
Java反射机制在数据持久层轻量级ORM框架中的应用研究;丁春玲 等;《西安文理学院学报( 自然科学版)》;全文 *
Spoon: Annotation-Driven Program Transformation-the AOP case;Renaud Pawlak;《proceedings of the 1st workshop on aspect oriented middleware development》;20051128;第1-6页 *
基于Annotation数据结构自动生成的研究与实现;王雪梅;李彩虹;慕富强;李廉;;微电子学与计算机(01);全文 *
基于网络支付与移动客户端的集体食堂菜品购销***设计与实现;罗多多;《中国优秀硕士学位论文全文数据库 信息科技辑》;20160115(第1期);第3.6节 *

Also Published As

Publication number Publication date
CN110457013A (en) 2019-11-15

Similar Documents

Publication Publication Date Title
US9811360B2 (en) Dynamic determination of application server runtime classloading
US8997070B2 (en) Extension mechanism for scripting language compiler
CN108920133B (en) Cross-language programming method and device, electronic equipment and storage medium
US9086931B2 (en) System for translating diverse programming languages
CN106155749B (en) Monitoring plug-in extension method and device
US20150242194A1 (en) System for Translating Diverse Programming Languages
CN109032631B (en) Application program patch package obtaining method and device, computer equipment and storage medium
CN103399734A (en) Method for generating REST service and achieving REST and corresponding equipment
CN111506314B (en) Project development method, device, server and medium
CN110109671B (en) Webpack label size and style conversion method and device
CN110457013B (en) Program component configuration device and method
CN112769706B (en) Componentized routing method and system
JP2022545489A (en) Smart contract client program generation method, system, device, and medium
CN111913741B (en) Object interception method, device, medium and electronic equipment
CN113407362A (en) SOMEIP communication intermediate layer implementation method and system based on SOA architecture of vehicle-mounted Android system
CN114327477A (en) Intelligent contract execution method and device, electronic device and storage medium
US8606766B2 (en) Method and system to handle java class versioning
CN112000320A (en) Automatic code generation method, device, equipment and storage medium
CN110674205B (en) Single table query method, device, terminal and readable storage medium
US20180081677A1 (en) Using Annotation Processors Defined By Modules with Annotation Processors Defined By Non-Module Code
CN109558121A (en) Development approach, device, equipment and the storage medium of interface drive program
CN111488144B (en) Data processing method and device
CN112416612A (en) Service calling method and device, computer equipment and readable storage medium
US20050246677A1 (en) Native method invocation (NMI) custom marshalling stub service
CN111596970A (en) Dynamic library delay loading method, device, equipment and storage medium

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination
TA01 Transfer of patent application right
TA01 Transfer of patent application right

Effective date of registration: 20201010

Address after: English genus

Applicant after: Innovative advanced technology Co.,Ltd.

Address before: English genus

Applicant before: Advanced innovation technology Co.,Ltd.

Effective date of registration: 20201010

Address after: English genus

Applicant after: Advanced innovation technology Co.,Ltd.

Address before: A four-storey 847 mailbox in Grand Cayman Capital Building, British Cayman Islands

Applicant before: Alibaba Group Holding Ltd.

GR01 Patent grant
GR01 Patent grant
TR01 Transfer of patent right
TR01 Transfer of patent right

Effective date of registration: 20240227

Address after: Guohao Times City # 20-01, 128 Meizhi Road, Singapore

Patentee after: Advanced Nova Technology (Singapore) Holdings Ltd.

Country or region after: Singapore

Address before: English genus

Patentee before: Innovative advanced technology Co.,Ltd.

Country or region before: United Kingdom