Time sequence diagram generation method and device, electronic equipment and storage medium

By automatically generating sequence diagrams and utilizing event triggering and monitoring components to generate a call chain tree structure, the complexity of manually processing sequence diagrams in existing technologies is solved, achieving efficient sequence diagram generation and consistency in interaction description.

CN114489588BActive Publication Date: 2026-04-14JD DIGITS HAIYI INFORMATION TECHNOLOGY CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
JD DIGITS HAIYI INFORMATION TECHNOLOGY CO LTD
Filing Date
2022-02-07
Publication Date
2026-04-14

AI Technical Summary

Technical Problem

In existing technologies, the interaction sequence diagrams between software system modules or objects are usually processed manually, which increases the complexity of scenario analysis and sequence diagram processing for developers.

Method used

By responding to event triggers, the program is determined to run, the called methods and their nesting relationships are obtained, a tree structure of call chains is generated, and a sequence diagram is automatically generated based on the traversal results of the tree structure. Syntax transformation is performed using monitoring components and preset drawing models.

Benefits of technology

This reduces the workload of R&D personnel in sorting and drawing sequence diagrams, ensures the consistency between the generated sequence diagrams and the running program, and improves the accuracy of interaction descriptions.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN114489588B_ABST
    Figure CN114489588B_ABST
Patent Text Reader

Abstract

The present disclosure provides a timing diagram generation method, device, electronic equipment and computer readable storage medium, relating to the technical field of timing processing. Wherein, the timing diagram generation method comprises: in response to the triggering operation of an event, determining the running program corresponding to the event; acquiring a calling method for executing the running program and positioning the nested relationship of the method; generating a tree structure of a calling chain based on the method and the corresponding nested relationship; generating a timing diagram based on the traversal result of the tree structure. Through the technical scheme of the present disclosure, on the one hand, it is beneficial to reduce the workload of researchers in combing and drawing timing diagrams, and on the other hand, it is beneficial to ensure the consistency between the generated timing diagram and the running program.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This disclosure relates to the field of software development technology, and in particular to a timing diagram generation method, apparatus, electronic device, and computer-readable storage medium. Background Technology

[0002] In the design and development of software systems, sequence diagrams are used to describe the time sequence of messages sent between subsystems, modules, and objects to show the dynamic collaboration and interaction between multiple objects. However, the sequence diagrams for interactions between modules or objects in existing systems are usually processed manually.

[0003] Since manual processing requires developers to familiarize themselves with and organize system scenarios, the increasing complexity of the system also leads to increased complexity for developers in tasks such as scenario analysis and sequence diagram processing.

[0004] It should be noted that the information disclosed in the background section above is only used to enhance the understanding of the background of this disclosure, and therefore may include information that does not constitute prior art known to those skilled in the art. Summary of the Invention

[0005] The purpose of this disclosure is to provide a method, apparatus, electronic device, and computer-readable storage medium for generating timing diagrams, which can at least to some extent improve the problem of the large amount of manual work required by researchers in related technologies for scene analysis and timing diagram processing.

[0006] Other features and advantages of this disclosure will become apparent from the following detailed description, or may be learned in part by practice of this disclosure.

[0007] According to one aspect of this disclosure, a timing diagram generation method is provided, comprising: in response to a triggering operation of an event, determining a running program corresponding to the event; obtaining a method call for executing the running program and locating the nesting relationship of the method call; generating a tree structure of a call chain based on the method call and the corresponding nesting relationship; and generating a timing diagram based on the traversal result of the tree structure.

[0008] In one embodiment, obtaining the calling methods for executing the running program and locating the nesting relationship of the calling methods specifically includes: monitoring the running program based on a monitoring component of a specified application framework to obtain the execution order of multiple calling methods for executing the running program; and obtaining and locating the nesting relationship of each calling method.

[0009] In one embodiment, the monitoring component includes a first monitoring interface and a second monitoring interface. The step of obtaining and locating the nesting relationship of each of the called methods specifically includes: locating the called methods required to execute the running program based on the first monitoring interface; locating the objects required to execute the running program based on the second monitoring interface; determining a first nesting relationship from the object to the corresponding called method based on enhancements of the monitoring component; determining the module to which the object belongs, and a second nesting relationship from the enhancements to the object; and determining the nesting relationship of the called methods based on the second nesting relationship and the first nesting relationship.

[0010] In one embodiment, generating a call chain-like tree structure based on the calling methods and the corresponding nesting relationships specifically includes: generating tree nodes based on the nesting relationships of the calling methods; determining the connecting edges between two sequentially executed calling methods based on the execution order; and generating the chain-like tree structure based on the tree nodes and the connecting edges.

[0011] In one embodiment, generating a timing graph based on the traversal result of the tree structure specifically includes: performing a traversal operation on the tree structure; performing a syntax transformation on the traversal result of the traversal operation based on a preset drawing model; and generating the timing graph based on the result of the syntax transformation.

[0012] In one embodiment, performing syntax transformation on the traversal result of the traversal operation based on a preset drawing model specifically includes: obtaining node information of each tree node in the tree structure sequentially based on the traversal result; determining the object recorded in the node information as the interaction object of the preset drawing model; determining the calling method recorded in the node information as the interaction message for interaction between the interaction objects; and determining the module recorded in the node information as the annotation of the interaction message.

[0013] In one embodiment, generating the sequence diagram based on the result of the syntax transformation specifically includes: generating the sequence diagram based on the interaction object, the interaction message, and the annotation.

[0014] In one embodiment, before determining the running program corresponding to the event in response to the event triggering operation, the method further includes: determining a specified operation of received user input as the triggering operation; and / or determining an operation of calling a system interface as the triggering operation; and / or determining an execution task of a timed execution practice as the triggering operation.

[0015] According to a second aspect of this disclosure, a timing diagram generation apparatus is provided, comprising: a determining module, configured to determine a running program corresponding to an event in response to a triggering operation of an event; an acquiring module, configured to acquire a method call for executing the running program and locate the nesting relationship of the calling methods; a first generating module, configured to generate a tree structure of a call chain based on the calling methods and the corresponding nesting relationship; and a second generating module, configured to generate a timing diagram based on the traversal result of the tree structure.

[0016] According to a third aspect of this disclosure, an electronic device is provided, comprising: a processor; and a memory for storing executable instructions of the processor; wherein the processor is configured to perform a timing diagram generation method of any one of the above via executing the executable instructions.

[0017] According to a fourth aspect of this disclosure, a computer-readable storage medium is provided, on which a computer program is stored, wherein the timing diagram generation method is implemented when the computer program is executed by a processor.

[0018] The timing diagram generation scheme provided in the embodiments of this disclosure determines the corresponding running program when an event is triggered. Based on the monitoring results of the calling methods of the running program and the nesting relationship of the calling methods, a corresponding tree structure is generated. Furthermore, a timing diagram is generated based on the traversal results of the tree structure. This realizes the automatic generation of timing diagrams during the running of the program. On the one hand, this timing diagram generation method helps to reduce the workload of R&D personnel in sorting and drawing timing diagrams. On the other hand, it helps to ensure the consistency between the generated timing diagram and the running program.

[0019] It should be understood that the above general description and the following detailed description are exemplary and explanatory only, and are not intended to limit this disclosure. Attached Figure Description

[0020] The accompanying drawings, which are incorporated in and form part of this specification, illustrate embodiments consistent with this disclosure and, together with the description, serve to explain the principles of this disclosure. It is obvious that the drawings described below are merely some embodiments of this disclosure, and those skilled in the art can obtain other drawings based on these drawings without any inventive effort.

[0021] Figure 1 This diagram illustrates a timing diagram generation system structure according to an embodiment of the present disclosure.

[0022] Figure 2 This diagram illustrates a timing diagram generation method according to an embodiment of the present disclosure.

[0023] Figure 3This illustration shows a tree structure diagram of a timing diagram generation scheme according to an embodiment of the present disclosure;

[0024] Figure 4 A flowchart of another timing diagram generation method in an embodiment of this disclosure is shown;

[0025] Figure 5 A flowchart of yet another timing diagram generation method in an embodiment of this disclosure is shown;

[0026] Figure 6 A flowchart illustrating yet another timing diagram generation method according to an embodiment of the present disclosure is shown;

[0027] Figure 7 A flowchart illustrating yet another timing diagram generation method in this disclosure is shown;

[0028] Figure 8 A timing diagram of a timing diagram generation scheme according to an embodiment of this disclosure is shown;

[0029] Figure 9 This diagram illustrates a timing diagram generation apparatus according to an embodiment of the present disclosure;

[0030] Figure 10 A schematic diagram of an electronic device according to an embodiment of the present disclosure is shown. Detailed Implementation

[0031] Exemplary embodiments will now be described more fully with reference to the accompanying drawings. However, these exemplary embodiments can be implemented in many forms and should not be construed as limited to the examples set forth herein; rather, they are provided so that this disclosure will be more comprehensive and complete, and will fully convey the concept of the exemplary embodiments to those skilled in the art. The described features, structures, or characteristics may be combined in any suitable manner in one or more embodiments.

[0032] Furthermore, the accompanying drawings are merely illustrative of this disclosure and are not necessarily drawn to scale. The same reference numerals in the drawings denote the same or similar parts, and therefore repeated descriptions of them will be omitted. Some block diagrams shown in the drawings are functional entities and do not necessarily correspond to physically or logically independent entities. These functional entities may be implemented in software, in one or more hardware modules or integrated circuits, or in different network and / or processor devices and / or microcontroller devices.

[0033] The solution provided in this application determines the corresponding running program when an event is triggered. Based on the monitoring results of the calling methods of the running program and the nesting relationship of the calling methods, a corresponding tree structure is generated. Furthermore, a sequence diagram is generated based on the traversal results of the tree structure. This achieves automatic generation of the sequence diagram during the running of the program. On the one hand, this method of generating the sequence diagram helps reduce the workload of R&D personnel in sorting and drawing the sequence diagram. On the other hand, it helps ensure the consistency between the generated sequence diagram and the running program.

[0034] To facilitate understanding, the following is an explanation of several terms used in this application.

[0035] Spring Boot: A new framework provided by the Pivotal team, designed to simplify the initial setup and development process of new Spring applications. This framework uses specific configuration methods, eliminating the need for developers to define boilerplate configurations.

[0036] Spring is an open-source J2EE runtime environment.

[0037] Java EE (Java Platform, Enterprise Edition) is an enterprise-level runtime version released by Sun Microsystems (which was acquired by Oracle on April 20, 2009).

[0038] Plantuml is a component for quickly creating UML diagrams.

[0039] IDEA: short for IntelliJ IDEA, is an integrated development environment for the Java programming language.

[0040] Spring AOP: AOP stands for "Aspect Oriented Programming". It isolates different parts of business logic, allowing developers to focus on core business logic while writing business logic, thereby improving development efficiency.

[0041] Figure 1 The diagram shows a time sequence diagram generation system according to an embodiment of the present disclosure, including multiple terminals 120 and a server cluster 140.

[0042] Terminal 120 can be a mobile terminal such as a mobile phone, game console, tablet computer, e-book reader, smart glasses, MP4 (Moving Picture Experts Group Audio Layer IV) player, smart home device, AR (Augmented Reality) device, VR (Virtual Reality) device, etc. Alternatively, terminal 120 can also be a personal computer (PC), such as a laptop computer and a desktop computer, etc.

[0043] The terminal 120 may contain a runtime program for generating the timing diagram.

[0044] Terminal 120 is connected to server cluster 140 via a communication network. Optionally, the communication network can be a wired network or a wireless network.

[0045] Server cluster 140 may be a single server, a combination of several servers, a virtualization platform, or a cloud computing service center. Server cluster 140 provides background services for the timing diagram generation and execution program. Optionally, server cluster 140 undertakes the primary computational work, and terminal 120 undertakes secondary computational work; or, server cluster 140 undertakes secondary computational work, and terminal 120 undertakes the primary computational work; or, terminal 120 and server cluster 140 collaborate on computation using a distributed computing architecture.

[0046] In some alternative embodiments, server cluster 140 is used to store timing graph generation models, etc.

[0047] Optionally, the client programs installed on different terminals 120 may be the same, or the client programs installed on two terminals 120 may be clients of the same type of program from different control system platforms. Depending on the terminal platform, the specific form of the client program may also differ; for example, the client program may be a mobile client, a PC client, or a World Wide Web (WWW) client.

[0048] Those skilled in the art will understand that the number of terminals 120 described above can be more or less. For example, there may be only one terminal, or there may be dozens or hundreds of terminals, or even more. This application does not limit the number of terminals or the type of device.

[0049] Optionally, the system may also include a management device ( Figure 1(Not shown), the management device is connected to the server cluster 140 via a communication network. Optionally, the communication network can be a wired network or a wireless network.

[0050] Optionally, the aforementioned wireless or wired networks use standard communication technologies and / or protocols. The network is typically the Internet, but can also be any network, including but not limited to Local Area Networks (LANs), Metropolitan Area Networks (MANs), Wide Area Networks (WANs), mobile, wired or wireless networks, private networks, or any combination of virtual private networks. In some embodiments, technologies and / or formats including Hyper Text Markup Language (HTML), Extensible Markup Language (XML), etc., are used to represent data exchanged over the network. Furthermore, conventional encryption technologies such as Secure Socket Layer (SSL), Transport Layer Security (TLS), Virtual Private Networks (VPNs), and Internet Protocol Security (IPsec) can be used to encrypt all or some links. In other embodiments, custom and / or dedicated data communication technologies can be used to replace or supplement the aforementioned data communication technologies.

[0051] The steps of the timing diagram generation method in this example embodiment will now be described in more detail with reference to the accompanying drawings and embodiments.

[0052] Figure 2 This diagram illustrates a flowchart of a timing diagram generation method according to an embodiment of the present disclosure. The method provided in this embodiment can be executed by any electronic device with computing power, such as... Figure 1 Terminal 120 and / or server cluster 140 in the example. In the following illustration, terminal 120 is used as the execution subject.

[0053] like Figure 2 As shown, terminal 120 executes a timing diagram generation method, including the following steps:

[0054] Step S202: In response to the event triggering operation, determine the running program corresponding to the event.

[0055] The event triggering operations include, but are not limited to: determining the specified operation of the received user input as the triggering operation; and / or determining the operation of calling the system interface as the triggering operation; and / or determining the execution task of the timer setting that arrives at the execution practice as the triggering operation.

[0056] Specifically, events triggered by specified user input operations include, but are not limited to, receiving a user click operation on a UI button, or a link operation to access a page.

[0057] In response to the event trigger, a corresponding program will be executed after the event is triggered. The specific execution needs to be determined according to the actual scenario, such as: submitting a form, displaying a page, uploading or downloading a file, etc.

[0058] Step S204: Obtain the calling method used to execute the running program and locate the nesting relationship of the calling methods.

[0059] Specifically, since a Java project can be called a module, multiple functions are packaged or data is encapsulated to form a class. A module includes at least one class. Classes are instantiated to obtain objects, and the functions of an object are called methods.

[0060] Since a module contains multiple classes, and a class contains multiple methods, obtaining the methods used to execute the program and locating the nesting relationships of the methods can be done by separately determining the nesting relationships between modules, classes, and methods, as well as between modules and classes, and between classes and methods.

[0061] like Figure 3 As shown, in response to the event-triggered operation, the entry point of the calling method is entered, including: Module A - Method 1, then Model B - Method 2 and Model B - Method 3 are executed in sequence, then Model C - Method 4 and Model C - Method 5 are executed concurrently, and after Model C - Method 4 is executed, Model D - Method 6 is executed.

[0062] Step S206: Generate a tree structure of call chain based on the called methods and their corresponding nesting relationships.

[0063] In this process, the calling methods and their corresponding nesting relationships are processed using an abstract approach to obtain the corresponding tree structure.

[0064] Nested relationships can include the relationship between a first method and a second method that the first method calls.

[0065] For example, using form submission as the trigger event, the corresponding running program includes, but is not limited to, validation, data calculation, and data storage. By obtaining the calling methods that execute these running programs and locating the nesting relationship of the calling methods, a tree structure can be constructed accordingly.

[0066] Step S208: Generate a sequence diagram based on the traversal results of the tree structure.

[0067] Sequence diagrams describe the temporal order in which messages are passed between objects. They are used to represent the order of actions in a use case and are interaction diagrams that emphasize the temporal order of messages.

[0068] The sequence diagram is generated based on the traversal results of the tree structure. That is, the interaction information between objects can be directly determined based on the method calls and the nesting relationship of the method calls, so as to further generate the sequence diagram.

[0069] In this embodiment, by determining the corresponding running program when the event is triggered, a corresponding tree structure can be generated based on the monitoring results of the calling methods of the running program and the nesting relationship of the calling methods. Furthermore, a sequence diagram is generated based on the traversal results of the tree structure. This achieves the automatic generation of the sequence diagram during the running process. On the one hand, this method of generating the sequence diagram helps to reduce the workload of R&D personnel in sorting and drawing the sequence diagram. On the other hand, it helps to ensure the consistency between the generated sequence diagram and the running program.

[0070] Furthermore, in systems involving more complex running programs, generating a sequence diagram based on the obtained methods for executing the running program and the nesting relationships of the calling methods can also ensure the accuracy of the description of the interactions between multiple objects.

[0071] In one embodiment, obtaining the calling methods used to execute the running program and locating the nesting relationship of the calling methods specifically includes: monitoring the running program based on a monitoring component of a specified application framework to obtain the execution order of multiple calling methods used to execute the running program; and obtaining and locating the nesting relationship of each calling method.

[0072] Specifically, the application framework is specified as the Spring framework. Based on Spring's AOP (Aspect-Oriented Programming), cross-cutting concerns are determined, i.e., which methods are monitored. The monitoring component of the application framework is specified, i.e., Spring aspects. Spring aspects are abstractions of cross-cutting concerns. Based on Spring aspects, the running program is monitored to obtain the execution order of multiple methods called to execute the running program, as well as to obtain and locate the nesting relationship of each method call.

[0073] The execution order of multiple method calls can be serial and / or parallel. For each method call, Spring aspects can determine its corresponding nesting relationship, that is, how to determine the method call from the object in the module and how to determine the method call from the object.

[0074] In this embodiment, Spring aspects are set up by creating business logic interfaces and implementation classes. By setting Spring aspects, the calling methods involved in the running program and their acquisition routes can be monitored, thereby obtaining multiple calling methods used to run the program after the event is triggered, so as to further generate the corresponding tree structure.

[0075] In one embodiment, the monitoring component includes a first monitoring interface and a second monitoring interface, and obtains the nesting relationship of each calling method. Specifically, this includes: locating the calling methods required for executing the program based on the first monitoring interface; locating the objects required for executing the program based on the second monitoring interface; determining the first nesting relationship from the object to the corresponding calling method based on the enhancements of the monitoring component; determining the module to which the object belongs, and the second nesting relationship from the enhancements to the object; and determining the nesting relationship of the calling methods based on the second nesting relationship and the first nesting relationship.

[0076] In one specific implementation, the monitoring component is a Spring aspect. The first monitoring interface is the ClassFilter interface, and the second monitoring interface is the MethodMatcher interface. In addition, during the monitoring of the running program, the points inserted in the Spring aspect are join points. Join points can be understood as methods intercepted by the monitoring process. The Spring aspect also includes the Pointcut interface, which is the top-level abstraction in Spring AOP and is used to capture join points. ClassFilter and MethodMatcher are used to limit the matching scope of join points at different levels to meet different granularities of matching. ClassFilter is limited to the class level (i.e., object location), and the MethodMatcher interface is limited to the method level (i.e., method location).

[0077] like Figure 4 As shown, obtaining the nesting relationship of each called method specifically includes:

[0078] Step S402: Locate the calling methods required to execute the running program based on the MethodMatcher interface.

[0079] The cut surface includes the tangent point and the reinforcement.

[0080] Step S404: Locate the required objects for executing the program based on the ClassFilter interface.

[0081] Here, an object is an instantiation of a class.

[0082] Step S406: Based on the enhancements of Spring aspects, determine the first nesting relationship from the object to the corresponding calling method.

[0083] Among them, enhancement is a piece of program code woven into the join point of the target class. Only by combining pointcuts and enhancements can a specific join point be determined and enhancement logic be implemented.

[0084] Step S408: Determine the module to which the object belongs, and the second nesting relationship from the enhancement to the object.

[0085] Here, a module refers to a package consisting of files with the same or similar functionality within a Java project. An object is a corresponding element created during the Java compiler's compilation and runtime process through class definitions, and is stored in memory. Calling a method, like in other programming languages, is a set of commands that has input and output capabilities to complete a specific task.

[0086] Step S410: Determine the nesting relationship of the location invocation method based on the second nesting relationship and the first nesting relationship.

[0087] Within this context, nested module packages can contain classes with the same name, and different classes may also contain methods with the same name. Therefore, the method call corresponding to a given node can be uniquely identified by combining the module, object, and method call.

[0088] In this embodiment, modules and objects can be considered as descriptors of the fully nested relationship corresponding to the generated calling methods. The combination of a module, an object, and the name of the calling method can serve as a unique identifier for that calling method, thereby enabling the specific location of a certain calling method and obtaining a specific representation of each calling method in the tree structure.

[0089] like Figure 5 As shown, in one embodiment, a call chain-like tree structure is generated based on the called methods and their corresponding nesting relationships, specifically including:

[0090] Step S502: Generate tree nodes based on the nesting relationship of the calling methods.

[0091] Step S504: Determine the connection edge between two sequentially executed calling methods based on the execution order.

[0092] Step S506: Generate a chain-like tree structure based on tree nodes and connecting edges.

[0093] In this embodiment, the chain-like tree structure includes multiple tree nodes and connecting edges that connect adjacent tree nodes. By treating each calling method and its nesting relationship as a tree node, where the nesting relationship specifically refers to the relationship between related modules, classes (objects), and calling methods, and connecting edges are used to connect adjacent calling methods, a chain-like tree structure is constructed. This chain-like tree structure can ensure the reliability of the description of the execution order of calling methods on the one hand, and on the other hand, it can also ensure the reliability of the description of the nesting relationship between the calling method and its class and module on the other hand.

[0094] In one embodiment, generating a time sequence graph based on the traversal results of the tree structure specifically includes:

[0095] Perform traversal operations on the tree structure.

[0096] The traversal results of the traversal operation are syntactically transformed based on a preset drawing model. Specifically, the preset drawing model is plantuml, meaning that the traversal results of the traversal operation are syntactically transformed based on plantuml.

[0097] For example, through the Spring aspect processing described above, a string similar to module + class (object) + method call can be obtained, such as:

[0098] org.springframework.web.bind.annotation.RestController#test.

[0099] The module name is: org.springframework.web.bind.annotation.

[0100] The class name is: RestController.

[0101] The method name is: test.

[0102] Convert the string to the grammatical structure of A->B:a, that is:

[0103] root->org.springframework.web.bind.annotation.RestController:test.

[0104] Where A is the root, B is "org.springframework.web.bind.annotation.RestController", and C is "test", based on this syntax structure, we know that the module + class (B) is called in the calling method a of module + class (A), and then the tree structure can be traversed.

[0105] Furthermore, a sequence diagram is generated based on the results of the syntax transformation.

[0106] Plantuml is used to quickly create UML (Unified Modeling Language) diagrams, which show the dynamic collaboration between multiple objects by describing the time sequence of messages sent between them, i.e., the message flow order between objects.

[0107] In this embodiment, by performing a traversal operation on the tree structure, the event sequence describing the sending of messages between objects and how different objects pass messages can be obtained, thereby realizing the automatic generation process of the sequence diagram.

[0108] like Figure 6 As shown, in one embodiment, taking Plantuml as a preset drawing model as an example, a transformation operation is performed on the traversal result of the traversal operation based on the preset drawing model to generate a timing diagram, specifically including:

[0109] Step S602: Based on the traversal results, obtain the node information of each tree node in the tree structure in sequence.

[0110] Step S604: Identify the objects recorded in the node information as the interaction objects of plantuml.

[0111] Step S606: Determine the calling method recorded in the node information as the interaction message between the interactive objects.

[0112] Step S608: The modules recorded in the node information are identified as annotations for the interaction messages.

[0113] Step S610: Generate a sequence diagram based on the interaction object, interaction message, and annotation.

[0114] In this embodiment, node information includes modules, objects, and calling methods. By using the recorded objects as participants in the corresponding PlantUML, and the calling method names in the tree structure as message information for interaction between PlantUML participants, the corresponding modules can be obtained by classifying the classes in the tree structure, and annotations can be added to the calling methods to describe their content as specific information about message information between PlantUML participants. This ensures that the generated PlantUML sequence diagram has good readability while automatically generating the sequence diagram.

[0115] like Figure 7 As shown, the timing diagram construction and invocation method according to another embodiment of this disclosure specifically includes:

[0116] Step S702: In response to the event triggering operation, determine the running program corresponding to the event.

[0117] Specifically, events can include user actions (such as clicking a button or accessing a page), other system calls, scheduled task execution, etc. In a software system, after an event is triggered, a corresponding program will be executed. The specific execution needs to be determined according to the actual scenario, such as submitting a form, displaying a page, uploading or downloading a file, etc.

[0118] Step S704: Based on Spring aspects, record the execution process of the modules, objects and methods called by the running program, and form a tree structure of call chain.

[0119] The program that is executed after being triggered by an event during the runtime of a software system can be simplified into a tree structure of call chains through abstraction.

[0120] Specifically, abstraction can be simply considered as a simplification process. For example, after a form is submitted, there may be many actions, such as data validation, data calculation, and data storage. After abstraction, these can be reduced to validation, processing, and storage. There is no need to worry about the specific validation logic, data processing methods and algorithms, and storage methods and locations.

[0121] To obtain the tree structure, it is necessary to rely on and process and record it through Spring aspects. Specifically, each node in the tree structure is a method call in the program, and the module and object can be regarded as the descriptor of the full path corresponding to the method call. The module and object combined with the method call name can serve as a unique identifier, thus enabling the location of a specific method call.

[0122] By using Spring aspect-oriented programming, we can intercept each method call and record the class name and module name of this method call, for example:

[0123] By calling different methods sequentially, a tree structure of call chains can be generated.

[0124] Step S706: Transform the tree structure syntax based on PlantUML syntax.

[0125] The generated tree structure still needs to be converted into PlantUML code through a converter. A simplified correspondence is as follows: the class names recorded in the tree structure correspond to participants in PlantUML, while the method call names in the tree structure serve as message information for the interaction between PlantUML participants. Furthermore, by categorizing the classes in the tree structure into modules / systems, and by adding annotations to the method calls to describe the specific message information between PlantUML participants, the generated PlantUML sequence diagram can be made more readable.

[0126] Step S708: Generate a time sequence diagram based on the transformation results.

[0127] Based on the above-mentioned timing diagram generation scheme, the automatic generation of timing diagrams at runtime reduces the workload of developers in compiling and drawing timing diagrams. At the same time, it ensures complete consistency between the automatically generated timing diagrams and the system.

[0128] Specifically, the code for converting tree-structure syntax based on PlantUML syntax includes:

[0129] actor root

[0130] root->com.XX.demo.controller,TestController:test

[0131] com.XX.demo.controller,TestController->com.XX.demo.service.TestService:getService

[0132] com.XX.demo.service.TestService->com.XX.demo.service.DemoService:testDemo

[0133] com.XX.demo.service.TestService<--com.XX.demo.service.DemoService

[0134] com.XX.demo.controller.TestController<--com.XX.demo.service.TestService

[0135] root->com.XX.demo.controller,TestController

[0136] Among them, com.XX.demo.controller,TestController is the first object.

[0137] com.XX.demo.service.TestService is the second object.

[0138] com.XX.demo.service.DemoService is a third object.

[0139] Test is the method that calls method A, getService is the method that calls method B, and testDemo is the method that calls method C.

[0140] The corresponding generated timing diagram is as follows Figure 8 As shown.

[0141] It should be noted that the above figures are merely illustrative of the processes included in the method according to exemplary embodiments of the present invention, and are not intended to be limiting. It is readily understood that the processes shown in the above figures do not indicate or limit the temporal order of these processes. Furthermore, it is readily understood that these processes may, for example, be executed synchronously or asynchronously in multiple modules.

[0142] Those skilled in the art will understand that various aspects of the present invention can be implemented as systems, methods, or program products. Therefore, various aspects of the present invention can be specifically implemented in the following forms: a completely hardware implementation, a completely software implementation (including firmware, microcode, etc.), or a combination of hardware and software aspects, collectively referred to herein as a "circuit," "module," or "system."

[0143] The following reference Figure 9 To describe the timing diagram generation apparatus 900 according to this embodiment of the present invention. Figure 9 The timing diagram generation apparatus 900 shown is merely an example and should not impose any limitations on the functionality and scope of use of the embodiments of the present invention.

[0144] The timing diagram generation device 900 is represented in the form of a hardware module. The components of the timing diagram generation device 900 may include, but are not limited to: a determination module 902, used to determine the running program corresponding to the event in response to the event triggering operation; an acquisition module 904, used to acquire the calling methods used to execute the running program and locate the nesting relationship of the calling methods; a first generation module 906, used to generate a call chain-like tree structure based on the calling methods and the corresponding nesting relationship; and a second generation module 908, used to generate a timing diagram based on the traversal result of the tree structure.

[0145] In one embodiment, the acquisition module 904 is further configured to: monitor the running program based on the monitoring component of the specified application framework to obtain the execution order of multiple calling methods used to execute the running program; and obtain the nesting relationship of each calling method.

[0146] In one embodiment, the monitoring component includes a first monitoring interface and a second monitoring interface. The acquisition module 904 is further configured to: locate the calling methods required for executing the running program based on the first monitoring interface; locate the objects required for executing the running program based on the second monitoring interface; determine a first nesting relationship from the object to the corresponding calling method based on the enhancement of the monitoring component; determine the module to which the object belongs, and a second nesting relationship from the enhancement to the object; and determine the nesting relationship of locating the calling methods based on the second nesting relationship and the first nesting relationship.

[0147] In one embodiment, the first generation module 906 is further configured to: generate tree nodes based on the nesting relationship of the calling methods; determine the connecting edges between two sequentially executed calling methods based on the execution order; and generate a chain-like tree structure based on the tree nodes and connecting edges.

[0148] In one embodiment, the second generation module 908 is further configured to: perform a traversal operation on the tree structure; perform syntax transformation on the traversal result of the traversal operation based on a preset drawing model; and generate a sequence diagram based on the result of the syntax transformation.

[0149] In one embodiment, the second generation module 908 is further configured to: obtain the node information of each tree node in the tree structure sequentially based on the traversal results; determine the objects recorded in the node information as interactive objects of the preset drawing model; determine the calling methods recorded in the node information as interactive messages for interaction between interactive objects; and determine the modules recorded in the node information as annotations for interactive messages.

[0150] In one embodiment, the second generation module 908 is further configured to: generate a sequence diagram based on the interaction object, interaction message, and annotation.

[0151] In one embodiment, the system further includes: a determining module 910, configured to determine a specified operation of the received user input as a triggering operation; and / or determine an operation of calling a system interface as a triggering operation; and / or determine an execution task of a timed execution practice as a triggering operation.

[0152] The following reference Figure 10 To describe an electronic device 1000 according to this embodiment of the present invention. Figure 10 The electronic device 1000 shown is merely an example and should not impose any limitations on the functionality and scope of use of the embodiments of the present invention.

[0153] like Figure 10 As shown, the electronic device 1000 is manifested in the form of a general-purpose computing device. The components of the electronic device 1000 may include, but are not limited to: at least one processing unit 1010, at least one storage unit 1020, and a bus 1030 connecting different system components (including storage unit 1020 and processing unit 1010).

[0154] The storage unit stores program code, which can be executed by the processing unit 1010 to perform the steps described in the "Exemplary Methods" section of this specification according to various exemplary embodiments of the present invention. For example, the processing unit 1010 can perform, as follows: Figure 2 Steps S202 to S206 shown, and other steps defined in the timing diagram generation method of this disclosure.

[0155] Storage unit 1020 may include readable media in the form of volatile storage units, such as random access memory (RAM) 10201 and / or cache memory 10202, and may further include read-only memory (ROM) 10203.

[0156] Storage unit 1020 may also include a program / utility 10204 having a set (at least one) program module 10205, such program module 10205 including but not limited to: operating system, one or more running programs, other program modules and program data, each of these examples or some combination of these may include an implementation of a network environment.

[0157] Bus 1030 can represent one or more of several types of bus structures, including a memory cell bus or memory cell controller, a peripheral bus, a graphics acceleration port, a processing unit, or a local bus using any of the multiple bus structures.

[0158] Electronic device 1000 can also communicate with one or more external devices 1060 (e.g., keyboard, pointing device, Bluetooth device, etc.), one or more devices that enable a user to interact with the electronic device, and / or any device that enables the electronic device 1000 to communicate with one or more other computing devices (e.g., router, modem, etc.). This communication can be performed via input / output (I / O) interface 1050. Furthermore, electronic device 1000 can also communicate with one or more networks (e.g., local area network (LAN), wide area network (WAN), and / or public networks, such as the Internet) via network adapter 1050. As shown, network adapter 1050 communicates with other modules of electronic device 1000 via bus 1030. It should be understood that, although not shown in the figures, other hardware and / or software modules can be used in conjunction with the electronic device, including but not limited to: microcode, device drivers, redundant processing units, external disk drive arrays, RAID systems, tape drives, and data backup storage systems.

[0159] From the above description of the embodiments, those skilled in the art will readily understand that the exemplary embodiments described herein can be implemented by software or by combining software with necessary hardware. Therefore, the technical solutions according to the embodiments of this disclosure can be embodied in the form of a software product, which can be stored in a non-volatile storage medium (such as a CD-ROM, USB flash drive, external hard drive, etc.) or on a network, including several instructions to cause a computing device (such as a personal computer, server, terminal device, or network device, etc.) to execute the methods according to the embodiments of this disclosure.

[0160] In exemplary embodiments of this disclosure, a computer-readable storage medium is also provided, on which a program product capable of implementing the methods described above is stored. In some possible embodiments, various aspects of the present invention may also be implemented as a program product comprising program code that, when the program product is run on a terminal device, causes the terminal device to perform the steps of the various exemplary embodiments of the present invention described in the "Exemplary Methods" section above.

[0161] According to embodiments of the present invention, a program product for implementing the above-described method may employ a portable compact disc read-only memory (CD-ROM) and include program code, and may run on a terminal device, such as a personal computer. However, the program product of the present invention is not limited thereto. In this document, a readable storage medium may be any tangible medium containing or storing a program that may be used by or in conjunction with an instruction execution system, apparatus, or device.

[0162] Computer-readable signal media may include data signals propagated in baseband or as part of a carrier wave, carrying readable program code. Such propagated data signals may take various forms, including but not limited to electromagnetic signals, optical signals, or any suitable combination thereof. A readable signal medium may also be any readable medium other than a readable storage medium, capable of sending, propagating, or transmitting programs for use by or in conjunction with an instruction execution system, apparatus, or device.

[0163] The program code contained on the readable medium may be transmitted using any suitable medium, including but not limited to wireless, wired, optical fiber, RF, etc., or any suitable combination thereof.

[0164] Program code for performing the operations of this invention can be written in any combination of one or more programming languages, including object-oriented programming languages ​​such as Java and C++, and conventional procedural programming languages ​​such as C or similar languages. The program code can execute entirely on the user's computing device, partially on the user's device, as a standalone software package, partially on the user's computing device and partially on a remote computing device, or entirely on a remote computing device or server. In cases involving remote computing devices, the remote computing device can be connected to the user's computing device via any type of network, including a local area network (LAN) or a wide area network (WAN), or it can be connected to an external computing device (e.g., via the Internet using an Internet service provider).

[0165] It should be noted that although several modules or units for the device used to perform actions have been mentioned in the detailed description above, this division is not mandatory. In fact, according to embodiments of this disclosure, the features and functions of two or more modules or units described above can be embodied in one module or unit. Conversely, the features and functions of one module or unit described above can be further divided and embodied by multiple modules or units.

[0166] Furthermore, although the steps of the method in this disclosure are described in a specific order in the accompanying drawings, this does not require or imply that the steps must be performed in that specific order, or that all the steps shown must be performed to achieve the desired result. Additional or alternative steps may be omitted, multiple steps may be combined into one step, and / or a step may be broken down into multiple steps.

[0167] From the above description of the embodiments, those skilled in the art will readily understand that the exemplary embodiments described herein can be implemented by software or by combining software with necessary hardware. Therefore, the technical solutions according to the embodiments of this disclosure can be embodied in the form of a software product, which can be stored in a non-volatile storage medium (such as a CD-ROM, USB flash drive, external hard drive, etc.) or on a network, including several instructions to cause a computing device (such as a personal computer, server, mobile terminal, or network device, etc.) to execute the methods according to the embodiments of this disclosure.

[0168] Other embodiments of this disclosure will readily occur to those skilled in the art upon consideration of the specification and practice of the invention disclosed herein. This application is intended to cover any variations, uses, or adaptations of this disclosure that follow the general principles of this disclosure and include common knowledge or customary techniques in the art not disclosed herein. The specification and examples are to be considered exemplary only, and the true scope and spirit of this disclosure are indicated by the appended claims.

Claims

1. A method for generating a time series diagram, characterized in that, include: In response to the triggering operation of the event, determine the running program corresponding to the event; Obtaining the calling methods used to execute the running program and locating the nesting relationship of the calling methods includes: monitoring the running program based on a monitoring component of a specified application framework, the monitoring component including a first monitoring interface and a second monitoring interface, to obtain the execution order of multiple calling methods used to execute the running program; locating the calling methods required to execute the running program based on the first monitoring interface; locating the objects required to execute the running program based on the second monitoring interface; determining a first nesting relationship from the object to the corresponding calling method based on enhancements of the monitoring component; determining the module to which the object belongs, and a second nesting relationship from the enhancement to the object; and determining the nesting relationship of locating the calling methods based on the second nesting relationship and the first nesting relationship. A tree structure of call chain is generated based on the calling method and the corresponding nesting relationship; A timing graph is generated based on the traversal results of the tree structure.

2. The time series diagram generation method according to claim 1, characterized in that, Based on the calling methods and the corresponding nesting relationships, a tree-like structure of call chains is generated, including: Tree nodes are generated based on the nesting relationship of the called methods; Based on the execution order, determine the connection edge between the two sequentially executed calling methods; The chain-like tree structure is generated based on the tree nodes and the connecting edges.

3. The time series diagram generation method according to claim 2, characterized in that, The generation of the sequence graph based on the traversal results of the tree structure specifically includes: Perform a traversal operation on the tree structure; The traversal results of the traversal operation are subjected to syntax transformation based on a preset drawing model; The timing diagram is generated based on the result of the syntax transformation.

4. The time series diagram generation method according to claim 3, characterized in that, The step of performing syntax transformation on the traversal result of the traversal operation based on a preset drawing model specifically includes: Based on the traversal results, the node information of each tree node in the tree structure is obtained sequentially; The object recorded in the node information is identified as the interactive object of the preset drawing model; The calling method recorded in the node information is determined as the interaction message between the interactive objects; The module recorded in the node information is identified as the annotation of the interaction message.

5. The time series diagram generation method according to claim 4, characterized in that, The generation of the timing graph based on the result of the syntax transformation specifically includes: The sequence diagram is generated based on the interaction object, the interaction message, and the annotation.

6. The timing diagram generation method according to any one of claims 1 to 5, characterized in that, Before determining the corresponding running program in response to the event triggering operation, the method further includes: The specified operation of the received user input is determined as the triggering operation; and / or The obtained operation of calling the system interface is determined as the triggering operation; and / or The execution task that arrives at the scheduled time of the execution practice is determined as the trigger operation.

7. A timing diagram generation apparatus, characterized in that, include: The determination module is used to determine the running program corresponding to the event in response to the event triggering operation; An acquisition module is used to acquire the calling methods used to execute the running program and to locate the nesting relationship of the calling methods, including: monitoring the running program based on a monitoring component of a specified application framework, the monitoring component including a first monitoring interface and a second monitoring interface, to acquire the execution order of multiple calling methods used to execute the running program; locating the calling methods required to execute the running program based on the first monitoring interface; locating the objects required to execute the running program based on the second monitoring interface; determining a first nesting relationship from the object to the corresponding calling method based on enhancements of the monitoring component; determining the module to which the object belongs, and a second nesting relationship from the enhancement to the object; and determining the nesting relationship of the calling methods based on the second nesting relationship and the first nesting relationship. The first generation module is used to generate a tree structure of a call chain based on the calling method and the corresponding nesting relationship; The second generation module is used to generate a timing diagram based on the traversal results of the tree structure.

8. An electronic device, characterized in that, include: processor; as well as Memory for storing the executable instructions of the processor; The processor is configured to execute the timing diagram generation method according to any one of claims 1 to 6 by executing the executable instructions.

9. A computer-readable storage medium having a computer program stored thereon, characterized in that, When the computer program is executed by the processor, it implements the timing diagram generation method according to any one of claims 1 to 6.

Citation Information

Patent Citations

  • Code running monitoring method and device, equipment and storage medium

    CN113900896A

  • Generating sequence diagrams using call trees

    US20060053414A1