CN117707547B - Method for analyzing quotation relation among java items - Google Patents

Method for analyzing quotation relation among java items Download PDF

Info

Publication number
CN117707547B
CN117707547B CN202410161497.9A CN202410161497A CN117707547B CN 117707547 B CN117707547 B CN 117707547B CN 202410161497 A CN202410161497 A CN 202410161497A CN 117707547 B CN117707547 B CN 117707547B
Authority
CN
China
Prior art keywords
java
character string
item
marking
jenkins
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
CN202410161497.9A
Other languages
Chinese (zh)
Other versions
CN117707547A (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.)
Yunzhu Information Technology Chengdu Co ltd
Original Assignee
Yunzhu Information Technology Chengdu 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 Yunzhu Information Technology Chengdu Co ltd filed Critical Yunzhu Information Technology Chengdu Co ltd
Priority to CN202410161497.9A priority Critical patent/CN117707547B/en
Publication of CN117707547A publication Critical patent/CN117707547A/en
Application granted granted Critical
Publication of CN117707547B publication Critical patent/CN117707547B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Landscapes

  • Devices For Executing Special Programs (AREA)
  • Stored Programmes (AREA)

Abstract

The invention discloses a method for analyzing a quotation relation between java items, which comprises the steps of constructing java items for realizing services based on a jenkins pipeline; copying a python script formed by packing source codes of java items into jenkins workspaces; reading a pore file of a java item through a python script, and extracting data of an item referenced by the java item; acquiring a catalog path of jenkins workspaces; dividing the character string of the directory path into a plurality of sub-character strings; and marking the last substring of the character string segmentation of the directory path as the name of the current service, and marking the data of the item referenced by the extracted java item as the name of the service referenced by the current service. According to the invention, all the services cited by the current service are acquired based on jenkins, so that project personnel can understand the relationship between the services more quickly, and the problem investigation time is reduced.

Description

Method for analyzing quotation relation among java items
Technical Field
The invention relates to the technical field of computers, in particular to a method for analyzing a quotation relationship among java items.
Background
Micro-services are a software architecture model in which an application is broken down into small, autonomous services, each of which is in turn implemented by a java item. Each service has independent functions and responsibilities. Each service can be independently developed, tested, deployed and expanded, thereby improving maintainability, expandability and flexibility of the application program. The call relationship between services in the micro-services is realized through a registry, but other project personnel except the developer do not know the dependency relationship between services. In short, a service a is called by one Api, but the service B is down (the service a is not known to call the service B at this time), and the project personnel can only check all the services one by one until the down service B is found, and the problem can not be found and solved. If the service A is directly known to depend on the service B, namely, the reference relation between two corresponding java items of the service, the problem checking time is greatly reduced.
Therefore, the invention provides a method for analyzing the quotation relation among java items, which at least solves the technical problems.
Disclosure of Invention
Aiming at the problems, the invention provides a method for analyzing the quotation relationship among java items, which is used for acquiring all the services quoted by the current service based on jenkins, so that project personnel can understand the relationship among the services more quickly, and the problem investigation time is reduced.
In order to achieve the above purpose, the technical scheme adopted by the invention is as follows:
a method for analyzing the quotation relation between java items comprises the following steps:
step 1, constructing java items for realizing services based on jenkins pipelines;
Step 2, copying a python script formed by packing source codes of java items into a jenkins working space;
step 3, reading a pore file of the java item through the python script, and extracting data of the item referenced by the java item;
step 4, acquiring a catalog path of jenkins working spaces;
step 5, dividing the character string of the directory path into a plurality of sub character strings;
And 6, marking the last sub-string segmented in the step 5 as the name of the current service, and marking the data extracted in the step 2 as the name of the service referenced by the current service.
Further, step 1 includes: step 11, pulling source codes of java items from a Git warehouse; and step 12, packaging the source code into a python script, and waiting for the execution of the python script.
Further, in step2, jenkins the workspace is the last layer directory of the task of constructing the java item, and the pore file is located in the last layer directory of the task of constructing the java item.
Further, in step 2, the name of the task for constructing the java item is set as the name of the java item.
Further, step 3 includes: step 31, reading configuration information of the pom file as a character string by a python script writing file reading method; and 32, acquiring coordinate information defining a unique identifier of the java item from the character string, and extracting data of the item referenced by the java item from the first coordinate information.
Further, in step 32, the regular expression is used to obtain coordinate information defining the unique identifier of the java item from the character string.
Further, in step 32, a regular expression is used to extract data of the item referenced by the java item from the first coordinate information.
Further, step 5 includes: step 51, defining an empty character string, namely a marked character string, defining an empty list and namely a marked list; step 52, using the forward slash symbol as a keyword for cyclic traversal to circularly traverse the character string of the directory path; step 53, when the traversed element is not a forward slash symbol, adding the current element to the tail of the marking character string, when the traversed element is a forward slash symbol, skipping over the current element and judging the length of the marking character string, when the length of the marking character string is not 0, adding the current marking character string to the marking list, and resetting the marking character string to be empty; step 54, repeating step 53 until the character string of the directory path is segmented, and marking all sub-character strings after the character string of the directory path is segmented in the list.
Further, the method further comprises the following steps: and 7, defining two empty lists, namely a master list and a slave list, respectively, adding the last sub-character string segmented in the step 5 into the master list, adding the data extracted in the step 2 into the slave list, wherein the master list contains the names of the current service, and the slave list contains the names of all the services referenced by the current service.
Compared with the prior art, the invention has the following beneficial effects:
According to the invention, all the services cited by the current service are acquired based on jenkins, so that project personnel can understand the relationship between the services more quickly, and the problem investigation time is reduced. The invention combines the working space of jenkins, can be applied to any java item, has strong portability, does not need to make any adaptation, and can be realized by only executing the python script of the java item in a jenkins pipeline.
Drawings
FIG. 1 is a flow chart of the method of the present invention.
Detailed Description
Term interpretation:
jenkins: is an open source software project and is a continuous integration tool based on Java development.
The present invention will be described in further detail with reference to the accompanying drawings, in order to make the objects, technical solutions and advantages of the present invention more apparent. It will be apparent that the described embodiments are only some, but not all, embodiments of the invention. All other embodiments, which can be made by those skilled in the art based on the embodiments of the invention without making any inventive effort, are intended to be within the scope of the invention.
As shown in FIG. 1, the method for analyzing the quotation relationship among java items provided by the invention comprises the following steps:
step 1, constructing java items for realizing services based on jenkins pipelines;
Step 2, copying a python script formed by packing source codes of java items into a jenkins working space;
step 3, reading a pore file of the java item through the python script, and extracting data of the item referenced by the java item;
step 4, acquiring a catalog path of jenkins working spaces;
step 5, dividing the character string of the directory path into a plurality of sub character strings;
And 6, marking the last sub-string segmented in the step 5 as the name of the current service, and marking the data extracted in the step 2 as the name of the service referenced by the current service.
According to the invention, all the services cited by the current service are acquired based on jenkins, so that project personnel can understand the relationship between the services more quickly, and the problem investigation time is reduced.
Jenkins pipeline construction realizes the java item of the service, and the construction steps of the java item can be customized.
In some embodiments, the constructing the java item includes: pulling source code of a java item from a Git repository; the source code is packaged into a python script, awaiting execution of the python script.
The python script is typically placed in a fixed location in a directory on the server, which is not specified and can be arbitrarily agreed upon. When jenkins pipeline constructs the project, jenkins automatically generates a catalog, but the task for constructing each java project is a unique catalog, and the name of the task is set as the current service name, so the name of the last layer of the task catalog is the name of the current service, namely jenkins working space is the last layer of the task catalog. Because the pon file of the java item is placed in the last layer of the task directory, i.e., jenkins workspace, the python script formed by packing the source code is copied to jenkins workspace so that the python script and the pon file are in the same directory.
Because the python script and the pom file are in the same catalog, the pom file can be directly read through the python script, and the data of the item referenced by the java item can be extracted.
In some embodiments, the configuration information of the pom file is read as a string by the python script writing file reading method readline; coordinate information defining a unique identifier of a java item is obtained from the character string, and data of the item referenced by the java item is extracted from the first coordinate information. The pore file is an XML file, is one of core files of the project, and describes basic information, dependency items, construction, release and other information of the project. Wherein the coordinate information defining the unique identifier of the java item is a character string beginning with ARTIFACTID and ending with ARTIFACTID, the item referenced by the pon file exists in the coordinate information defining the unique identifier of the java item, for example, the name of one referenced item is named as sample-app, and the corresponding coordinate information in the pon file is < ARTIFACTID > sample-app < ARTIFACTID >, so that the name of the item referenced by the current java item is obtained by extracting the data sample-app between the two ARTIFACTID, and the name of each service is the same as the name of the corresponding java item, for which the name of the service referenced by the current service can be obtained. Specifically, all the coordinate information is obtained from the character string through a regular expression "< ARTIFACTID > < ARTIFACTID > $", and then data of an item referenced by the java item is extracted through the regular expression. The invention combines the working space of jenkins, can use the method in any java project, has strong portability, does not need to make any adaptation, and can obtain the name of the service referenced by the current service by adding a command execution python script in a jenkins pipeline.
The name of the java item cannot be obtained after the java item is executed, and the name is also the name of the corresponding service, and at the moment, the last layer of directory of the task of the java item can be constructed by obtaining a directory path of jenkins working spaces, specifically, the obtaining is realized by writing and executing shell command pwd; and then, acquiring the task names, namely the names of the corresponding java items and services by analyzing the directory path of the jenkins working space, and specifically, extracting the task names by segmenting the character strings of the directory path.
In some embodiments, the dividing the string of the directory path into a plurality of substrings specifically includes: defining an empty character string, marking the character string as a marking character string, and defining an empty list, marking the character string as a marking list; the forward slash symbol "/" is used as a character string of a keyword circulation traversing directory path, and "/" is a standard path separator used in an operating system and is used for separating a hierarchical structure of directory and file names; when the traversed element is not the forward slash symbol "/", adding the current element to the tail part of the marking character string, when the traversed element is the forward slash symbol "/", skipping the current element and judging the length of the marking character string, when the length of the marking character string is not 0, adding the current marking character string to the marking list, and resetting the marking character string to be empty; and (5) traversing the steps until the character string of the directory path is segmented, and marking all sub-character strings after the character string of the directory path is segmented in a list. For example, if the string of the directory path is "/a/B/C/D/", the segmented substrings are "a", "B", "C", "D", where the last substring "D" is the name of the current task and is also the name of the corresponding java item and service.
The last sub-string separated by the string of the directory path is the name of the current service, and the data of the item referenced by the java item extracted by the pon file is the name of the service referenced by the current service. Preferably, two empty lists can be defined and respectively recorded as a master list and a slave list, the last sub-string of the string partition of the directory path is added into the master list, the data of the item referenced by the java item extracted by the pore file is added into the slave list, the master list contains the name of the current service, and the slave list contains the names of all the services referenced by the current service.
Finally, it should be noted that: the above embodiments are merely preferred embodiments of the present invention for illustrating the technical solution of the present invention, but not limiting the scope of the present invention; although the invention has been described in detail with reference to the foregoing embodiments, it will be understood by those of ordinary skill in the art that: the technical scheme described in the foregoing embodiments can be modified or some or all of the technical features thereof can be replaced by equivalents; such modifications and substitutions do not depart from the spirit of the corresponding technical solutions; that is, even though the main design concept and spirit of the present invention is modified or finished in an insubstantial manner, the technical problem solved by the present invention is still consistent with the present invention, and all the technical problems are included in the protection scope of the present invention; in addition, the technical scheme of the invention is directly or indirectly applied to other related technical fields, and the technical scheme is included in the scope of the invention.

Claims (6)

1. A method for analyzing a reference relation between java items is characterized by comprising the following steps:
step 1, constructing java items for realizing services based on jenkins pipelines;
Step 2, copying a python script formed based on source codes of java items into jenkins working spaces;
step 3, reading a pore file of the java item through the python script, and extracting data of the item referenced by the java item;
step 4, acquiring a catalog path of jenkins working spaces;
step 5, dividing the character string of the directory path into a plurality of sub character strings;
step 6, marking the last sub-character string segmented in the step 5 as the name of the current service, and marking the data extracted in the step 3 as the name of the service referenced by the current service;
The step 3 comprises the following steps: step 31, reading configuration information of the pom file as a character string by a python script writing file reading method; step 32, acquiring coordinate information defining a unique identifier of a java item from a character string, and extracting data of the item referenced by the java item from the coordinate information; the pop file is an xml file, the pop file comprises basic information, dependency information, construction information and release information of a java item, coordinate information defining a unique identifier of the java item is a character string beginning with ARTIFACTID and ending with ARTIFACTID, and an item referenced by the pop file exists in the coordinate information defining the unique identifier of the java item;
The step 5 comprises the following steps: step 51, defining an empty character string, namely a marked character string, defining an empty list and namely a marked list; step 52, using the forward slash symbol as a keyword for cyclic traversal to circularly traverse the character string of the directory path; step 53, when the traversed element is not a forward slash symbol, adding the current element to the tail of the marking character string, when the traversed element is a forward slash symbol, skipping over the current element and judging the length of the marking character string, when the length of the marking character string is not 0, adding the current marking character string to the marking list, and resetting the marking character string to be empty; step 54, repeating step 53 until the character string of the directory path is segmented, and marking all sub-character strings after the character string of the directory path is segmented in the list.
2. The method of claim 1, wherein in step 2, jenkins is a last-layer directory of tasks for constructing java items, and the pore file is located in the last-layer directory of tasks for constructing java items.
3. The method for analyzing the reference relation between java items according to claim 1, wherein in step 1, the name of the task for constructing the java item is set as the name of the java item.
4. The method of claim 1, wherein in step 32, a regular expression is used to obtain coordinate information defining a unique identifier of a java item from a character string.
5. The method of claim 1, wherein in step 32, a regular expression is used to extract data of the item referenced by the java item from the coordinate information.
6. The method for resolving a referential relationship among java items according to claim 1, further comprising: and 7, defining two empty lists, namely a master list and a slave list, respectively, adding the last sub-character string segmented in the step 5 into the master list, adding the data extracted in the step 3 into the slave list, wherein the master list contains the names of the current service, and the slave list contains the names of all the services referenced by the current service.
CN202410161497.9A 2024-02-05 2024-02-05 Method for analyzing quotation relation among java items Active CN117707547B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202410161497.9A CN117707547B (en) 2024-02-05 2024-02-05 Method for analyzing quotation relation among java items

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202410161497.9A CN117707547B (en) 2024-02-05 2024-02-05 Method for analyzing quotation relation among java items

Publications (2)

Publication Number Publication Date
CN117707547A CN117707547A (en) 2024-03-15
CN117707547B true CN117707547B (en) 2024-05-28

Family

ID=90153843

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202410161497.9A Active CN117707547B (en) 2024-02-05 2024-02-05 Method for analyzing quotation relation among java items

Country Status (1)

Country Link
CN (1) CN117707547B (en)

Citations (7)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
KR20180119962A (en) * 2017-04-26 2018-11-05 주식회사 평화이즈 System for analysing the effect of source code modification
CN109634612A (en) * 2018-12-04 2019-04-16 浙江数链科技有限公司 Continuous integrating method, system, computer equipment and storage medium
CN109947711A (en) * 2018-08-22 2019-06-28 重庆金康特智能穿戴技术研究院有限公司 A kind of multilingual file automating management method in pair of IOS project development process
CN111258595A (en) * 2020-03-13 2020-06-09 山东超越数控电子股份有限公司 PyInstaler-based python source code packaging method
CN111475422A (en) * 2020-06-28 2020-07-31 四川新网银行股份有限公司 Dependence checking method based on Jenkins tool
CN114327580A (en) * 2021-11-16 2022-04-12 中国电信股份有限公司 Management method, system, equipment and storage medium based on software warehouse
CN115357898A (en) * 2022-07-08 2022-11-18 深圳开源互联网安全技术有限公司 Dependency analysis method, device and medium for JAVA component

Patent Citations (7)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
KR20180119962A (en) * 2017-04-26 2018-11-05 주식회사 평화이즈 System for analysing the effect of source code modification
CN109947711A (en) * 2018-08-22 2019-06-28 重庆金康特智能穿戴技术研究院有限公司 A kind of multilingual file automating management method in pair of IOS project development process
CN109634612A (en) * 2018-12-04 2019-04-16 浙江数链科技有限公司 Continuous integrating method, system, computer equipment and storage medium
CN111258595A (en) * 2020-03-13 2020-06-09 山东超越数控电子股份有限公司 PyInstaler-based python source code packaging method
CN111475422A (en) * 2020-06-28 2020-07-31 四川新网银行股份有限公司 Dependence checking method based on Jenkins tool
CN114327580A (en) * 2021-11-16 2022-04-12 中国电信股份有限公司 Management method, system, equipment and storage medium based on software warehouse
CN115357898A (en) * 2022-07-08 2022-11-18 深圳开源互联网安全技术有限公司 Dependency analysis method, device and medium for JAVA component

Non-Patent Citations (2)

* Cited by examiner, † Cited by third party
Title
Finding Fixed Vulnerabilities with Off-the-Shelf Static Analysis;Trevor Dunlap等;《2023 IEEE 8th European Symposium on Security and Privacy (EuroS&P)》;20230731;489-505 *
基于微服务的边缘计算网关设计与实现;高凡石;《中国优秀硕士学位论文全文数据库 信息科技辑》;20210415;I136-109 *

Also Published As

Publication number Publication date
CN117707547A (en) 2024-03-15

Similar Documents

Publication Publication Date Title
CN108139891B (en) Method and system for generating suggestions to correct undefined token errors
CN109508191A (en) A kind of code generating method and system
US8028276B1 (en) Method and system for generating a test file
US9424003B1 (en) Schema-less system output object parser and code generator
US7103885B2 (en) Comment driven processing
JP2000181917A (en) Structured document managing method, executing device therefor and medium recording processing program therefor
JPH0830620A (en) Structure retrieving device
KR101183296B1 (en) Mechanisms for transferring raw data from one data structure to another representing the same item
CN112540862A (en) Interface document data generation method, device, equipment and storage medium
CN112527291A (en) Webpage generation method and device, electronic equipment and storage medium
CN111045860A (en) Improving conflict resolution within synchronized composite part-based digital assets
US20180246717A1 (en) Identification of duplicate function implementations
JP2012243127A (en) Techniques, programs and systems for reflecting manipulation of object as image of mapping in graph data
US20060129601A1 (en) System, computer program product and method of collecting metadata of application programs installed on a computer system
JP2006350729A (en) Application software construction method, application software construction processing program, and application software construction system
US20040098712A1 (en) System and apparatus for dynamically upgrading concentrated executable computer software code
US11645058B2 (en) User interface resource file optimization
CN117707547B (en) Method for analyzing quotation relation among java items
CN117008920A (en) Engine system, request processing method and device, computer equipment and storage medium
CN113342749A (en) File path matching method, device, equipment and computer readable storage medium
CN111898762B (en) Deep learning model catalog creation
CN114356404A (en) Interface document generating method, system and computer readable storage medium
US20200311048A1 (en) Extensible Validation Framework
CN112130860A (en) JSON object analysis method and device, electronic device and storage medium
JP2019179383A (en) Api processing method, terminal, and api processing program

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
GR01 Patent grant
GR01 Patent grant