CN100435114C - Online method for checking out software based on interceptor - Google Patents

Online method for checking out software based on interceptor Download PDF

Info

Publication number
CN100435114C
CN100435114C CNB2006100112322A CN200610011232A CN100435114C CN 100435114 C CN100435114 C CN 100435114C CN B2006100112322 A CNB2006100112322 A CN B2006100112322A CN 200610011232 A CN200610011232 A CN 200610011232A CN 100435114 C CN100435114 C CN 100435114C
Authority
CN
China
Prior art keywords
interceptor
message
verification
code
content
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.)
Expired - Fee Related
Application number
CNB2006100112322A
Other languages
Chinese (zh)
Other versions
CN101004705A (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.)
Peking University
Original Assignee
Peking University
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 Peking University filed Critical Peking University
Priority to CNB2006100112322A priority Critical patent/CN100435114C/en
Publication of CN101004705A publication Critical patent/CN101004705A/en
Application granted granted Critical
Publication of CN100435114C publication Critical patent/CN100435114C/en
Expired - Fee Related legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Abstract

A method for on-line calibrating software based on intercepter includes realizing calibration code in tintercepter mode and organizing different calibration content in single intercepter mode, carrying out analysis on external communication message and object code by intercepter to judge whether message content is in according with preset condition or not and carrying out relevant treatment by intercepter if content deviation of message is discovered.

Description

Online method for checking out software based on interceptor
Technical field:
The present invention relates to a kind of method of calibration of software,, be applicable to the maintenance and the evolution of software, belong to software technology field particularly based on the online method for checking out software of interceptor.
Background technology:
The quality that how to improve software is the content that studies for a long period of time of soft project.Accurately description demand, strict test code, tighten management or the like all are crucial software quality raising methods, mistake do not occur but said method all can not guarantee software after reaching the standard grade.Accurate fully the description is unpractical, and test can only be found software defect, can not guarantee not have defective, manages always relative for the raising of quality.Based on this present situation, part Study personnel begin the countermeasure of considering that some are real: constantly constantly software is carried out verification at running software, find the deviation of software action as early as possible, handle timely giving, avoid the generation of adverse consequences.In software, detected code is realized the functional demand of software usually, and detection of code realizes the restrictive demand of software usually.Existing time of running, method of calibration followed traditional Function Decomposition method, was basic module with function, subfunction, and the realization that will retrain disperses to be implemented between the different functional modules, finally check code has been embedded into by in the check code body.For example, assert that (Assersion) promptly is the technology of check system base attribute of being widely adopted etc.Although it is higher to do efficient like this, have the deficiency of following several respects: (1) code is clear inadequately: mixed by check code and check code, be unfavorable for that other people understand code; (2) code underaction: no matter be check code or by check code, when we attempt to one of them safeguard, when developing because code mixes, the opposing party's code tends to be adjusted together.
Summary of the invention:
At the problems referred to above, the purpose of this invention is to provide a kind of online method for checking out software based on interceptor.This method is a mutation of existing online method for checking out software, compares with other method, and it mainly improves and is to have introduced interceptor mechanism: allow independently interceptor bear verifying function.By introducing interceptor mechanism, realized allowing check code still keep independently effect, and then software systems can be detected and verification easily flexibly in the time of running.Interceptor is a kind of typical software pattern, and its basic ideas are that the running environment of object code is transformed, and makes interceptor can obtain object code and extraneous interactive messages, can analyze message then, even processing.
According to purpose of the present invention, comprise step based on the online method for checking out software of interceptor:
(1) form with interceptor realizes check code, and different verification contents is organized with the form of single interceptor or interceptor chain:
Utilize interceptor mechanism, can carry out the verification of multiple purpose to same object code, this just need reasonably organize dissimilar check code.These different check code have multiple organizational form: a) various check code can be implemented as single interceptor, such organizational form implementation efficiency height, but very flexible; B) dissimilar check code are embodied as different interceptors, thereby constitute the verification interceptor chain of certain-length, and such organizational form realizes that dirigibility is best, but the verification expense is bigger, thereby influential to the normal runnability of system; C) the verification content of various check code is done concrete analysis, constitute the verification interceptor chain of reasonable length.In concrete implementation procedure, can select interceptor or interceptor chain flexibly according to check code.
To by the detection of check code being carrying out alternately by code and outside.Actual verification object includes but not limited to following type: both can be request message (issuing code server from client codes), also can be response message (issuing client codes from code server); Both can be each concrete parameter range in the particular message, also can be the request order of distinct methods message; Both can be to replying the verification of message response time, also can be to the response message verification of precision as a result, or the like.
(2) interceptor is analyzed object code and outside communication information, judges whether message content meets predefined constraint condition.For example: whether parameter value is in the span of setting, and whether the request order is correct or the like.
(3) if interceptor finds that deviation appears in message, then handle accordingly.
When check code notes abnormalities, can carry out multiple processing: a) for simple unusual, for example: parameter value crosses the border, method call is made mistakes in proper order, or the like, check code can be handled voluntarily, for example: the transmission of termination messages, back-checking error result; B) unusual for complexity, for example the response time overtime etc., check code is sent unexpected message to the unusual software part of special disposal, to make appropriate reply and processing, for example: according to rule some parameters of software are adjusted etc.
The interceptor that comprises check code can be managed in system's operational process neatly: at any time, as long as suspecting software or its environment has unusually, just can easily check code be inserted in the system as required, system is carried out concrete detection and verification; And after the verification task is finished, can easily check code being removed again, thereby the operational efficiency of raising system.
Further, said method can also be included in the step that increases new verification content the time of running: exploitation comprises the new interceptor of check code, by Classloader it is loaded in the system then.
If change the verification content in the time of running, then on the basis of existing interceptor, exploitation comprises the interceptor of new verification content, uses the current interceptor of the online replacement of interceptor of redaction then.
Further, said method can also be included in the step of deleting the verification content time of running, realizes by dual mode:
A) for only comprising the interceptor of deleting verification content corresponding check sign indicating number with desire, directly this interceptor is deleted from system;
B) for the interceptor that comprises a plurality of check codes, then need to develop and do not comprise the new interceptor that will delete the verification content, and the current interceptor of online replacement.
According to above-mentioned method, the structure diagram in system when operation as shown in Figure 1, wherein, " target Java object " by the object of verification, each object comprises some methods, can respond request message, and provide response message.Form in each interceptor of interceptor chain and comprise concrete check code, can be according to predefined constraint condition analysis by verification object and outside interaction message: request message and response message, and with this residing state of judgement system.
Technique effect of the present invention is: compare with existing on-line testing method, the method that the present invention proposes makes object code, check code more clear, and provides good support for the flexible configuration of check code (comprising adding, cancellation etc.).Especially for carrying out efficient and reliability all than higher system, the present invention can provide a kind of solution preferably.
Description of drawings
Structure diagram when Fig. 1 represents system's operation in the present invention.
Embodiment:
Below in conjunction with accompanying drawing, a preferred embodiment of invention is described.
Present embodiment provides a better embodiment based on the JAVA language in conjunction with the example of a shopping online.A crucial class of shopping online is a shopping cart, and its interface thes contents are as follows:
Interface?public?class?ShoppingCart{ public?Integer?addItem(Integer?n,String?p); public?void?setClientInfo(String?info); public?Double?checkout(); ...... }
Code 1
In the conventional online detection technique, detection of code is dispersed in the diverse ways, and its expression-form can be shown in code 2:
public?class?ShoppingCart{ //states?for?method?order?verification Boolean?a_invoked=false; Boolean?s_invoked=false; Boolean?c_just_invoked=false; ...... public?Integer?addItem(Integer?n,String?p){ Interger?m=null; //verify?input?value if(n<=0){......}; //function?code ...... if(m<=0){......};//verify?output?value a_invoked=true; c_just_invoked=false; return?m; }; public?void?setClientInfo(String?Addr){ //function?code ...... s_invoked=true; c_just_invoked=false; }; public?Double?checkout(){ Double?total=null; //verify?method?invocation?order if((a_invoked==false)
||(s_invoked==false) ||(c_just_invoked==true)){......} //function?code ...... //verify?output?value If(total<=0){......}; p_just_invoked=true; return?total; }; }
Code 2
And in the present embodiment, will detection of code be concentrated in the interceptor code by interceptor mechanism.The realization of interceptor mechanism depends on the Classloader (ClassLoader) in the JAVA platform (JVM).In the JAVA platform, internal memory is searched and be loaded into to each class all by a Classloader.Each class loaders all has the loading path of oneself, and searches and the load classes bytecode according to this path.Moreover, all must could finally be realized through searching of a series of Classloaders calling all of a class.This makes the running space of JAVA program obtain division on the one hand, thereby makes fine-grained JAVA program management become possibility; On the other hand, also provide chance for realizing by Classloader to the intercepting of message: the user can define the loader of oneself as required.By the heavy duty to default Classloader middle part separating method, new loader can be analyzed the message that is truncated to easily.The process of specific implementation interceptor is:
(1), obtains corresponding check code (seeing that code 3 7-37 are capable), and it is encapsulated as interceptor class a: ConsInterceptor (seeing code 3 the 1st row) according to predefined interface constraints information.This interceptor class has realized interceptor interface: Interceptor (seeing code 3 the 1st row), can analyze the message that is truncated to, whether for example concrete parameter range is correct, and whether the request order of distinct methods message is correct, and whether the response time satisfies etc.Check code can be handled message voluntarily, for example, and the transmission of termination messages, back-checking error result; Also can send unexpected message,, for example, some parameters of software be adjusted etc. according to rule to make appropriate reply and processing to special abnormality processing software part.In the present embodiment, the realization that comprises verification contents interception device is shown in code 3.This interceptor carries out to request message and corresponding response message that verification: 7-28 is capable to carry out verification to request message, and wherein, order, first parameter value of the capable method of calibration of 24-28 " addItem " are called in the capable verification of 7-22.33-37 is capable to carry out verification to response message, wherein, and the rreturn value of the capable method of calibration of 34-35 " addItem ", the rreturn value of the capable verification of 36-37 " checkout ".
1?public?class?ConsInterceptor?implements?Interceptor{ 2 private?int?Class_State=0; 3 public?Object?invoke(Invocation?invocation){ 4 MethodInvocation?mi=(MethodInvocation)invocation; 5 String?mn=mi.getMethod().toString(); 6 //verify?invocation?order 7 switch(Class_State){ 8 case?0:Class_State=(mn.equals(″checkout″))? -1:(mn.equals(″addItem″))?1:2; 9 break; 10 case?1:Class_State=(mn.equals(″checkout″))? 11 -1:(mn.equals(″addItem″))?1:3; 12 break; 13 case?2:Class_State=(mn.equals(″checkout″))? 14 -1:(mn.equals(″addItem″))?3:2; 15 break; 16 case?3:Class_State=(mn.equals(″checkout″))?4:3; 17 break; 18 case?4:Class_State=(mn.equals(″checkout″))?-1:3; 19 break; 20 } 21 if(Class_State==-1){...} 22 23 //verify?input?parameters 24 if(mn.equals(″addItem″)){ 25 Object[]args=mi.getArguments(); 26 Double?d=double?args[0]; 27 if((args[0]<=0)){...} 28 } 29 //Invoke?the?real?object?or?next?interceptor 30 Object?r=invocation.invokeNext(); 31 32 //verify?return?value: 33 Double?dd=Double?r; 34 if(mn.equals(″addItem″)&&(dd.doubleValue()<0)) 35 {......} 36 if(mn.equals(″checkout″)″)&&(dd.doubleValue()<0)) 37 {......}
38 return?r; 39?}
Code 3
(2) on the basis of the built-in Classloader of JVM, exploitation has the Classloader of the machine-processed function of intercepting.This Classloader heavy duty the certain methods in the default Classloader of JVM, thereby make interceptor can analyze message.
(3) start JVM.For will be by the target class of verification, the self-defining Classloader of designated user be such Classloader; The class that appointment comprises check code is an interceptor, its information is recorded carry in the Classloader.
So far, when normally moving in system, each interceptor can be truncated to the response message that all request messages of issuing destination object and destination object return, and contrasts predefined constraint then, respectively these message is analyzed.Generally, request message all can finally send to destination object, echo reply message then.
When needs increased new verification content, having dual mode to can be implemented in line increases interceptor: a) exploitation comprised the new interceptor of check code, by Classloader it is loaded in the system then; B) on the basis of existing interceptor, increase new verification content, use the current interceptor of the online replacement of interceptor of redaction then.
Accordingly, when a certain verification no longer needs, two kinds of possible online cancellation interceptor situations are arranged: a) this check code is then directly deleted it by an independently interceptor realization from system; B) this check code and other check codes are implemented in the same interceptor, then need to develop the interceptor of the corresponding check code of deletion, use the current interceptor of the online replacement of interceptor of redaction then.

Claims (6)

1. online method for checking out software based on interceptor comprises step:
(1) form with interceptor realizes check code, and different verification contents is organized with the form of single interceptor or interceptor chain;
(2) interceptor is analyzed object code and outside communication information, judges whether message content meets predetermined conditions;
(3) if interceptor finds that simple deviation appears in message, then interceptor is handled voluntarily; If interceptor is found message and the unusual of complexity occur that interceptor sends unexpected message to the unusual software part of special disposal.
2. the method for claim 1, it is characterized in that, described verification content comprise following any one or a few: the request of each concrete parameter range, distinct methods message order in request message, response message, the particular message, to the verification of replying the message response time, to the response message verification of precision as a result.
3. the method for claim 1 is characterized in that, also comprises the step that increases new verification content the time of running: exploitation comprises the new interceptor of check code, then it is loaded in the system.
4. the method for claim 1 is characterized in that, also comprises the step that changes the verification content time of running: on the basis of existing interceptor, exploitation comprises the interceptor of new verification content, uses the current interceptor of the online replacement of interceptor of redaction then.
5. the method for claim 1 is characterized in that, also comprises the step of deleting the verification content time of running: for only comprising the interceptor of deleting verification content corresponding check sign indicating number with desire, directly this interceptor is deleted from system; For the interceptor that comprises a plurality of check codes, exploitation does not comprise the new interceptor that will delete the verification content, and the current interceptor of online replacement.
6, the method for claim 1 is characterized in that, described predetermined conditions is: parameter value whether in the span of setting and/or the request order whether correct.
CNB2006100112322A 2006-01-18 2006-01-18 Online method for checking out software based on interceptor Expired - Fee Related CN100435114C (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CNB2006100112322A CN100435114C (en) 2006-01-18 2006-01-18 Online method for checking out software based on interceptor

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CNB2006100112322A CN100435114C (en) 2006-01-18 2006-01-18 Online method for checking out software based on interceptor

Publications (2)

Publication Number Publication Date
CN101004705A CN101004705A (en) 2007-07-25
CN100435114C true CN100435114C (en) 2008-11-19

Family

ID=38703872

Family Applications (1)

Application Number Title Priority Date Filing Date
CNB2006100112322A Expired - Fee Related CN100435114C (en) 2006-01-18 2006-01-18 Online method for checking out software based on interceptor

Country Status (1)

Country Link
CN (1) CN100435114C (en)

Families Citing this family (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN110968498B (en) * 2018-09-30 2023-04-07 北京国双科技有限公司 Code checking method and device

Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN1228175A (en) * 1996-08-20 1999-09-08 艾利森电话股份有限公司 Method and system for testing computer system software
CN1232222A (en) * 1998-04-01 1999-10-20 日本电气株式会社 Apparatus for evaluating interface between software development tools, and recording medium for storing software for evaluating interface between software development tools
CN1252875A (en) * 1997-02-28 2000-05-10 全斯美达有限公司 Method and apparatus for correcting errors in computer system
US6587888B1 (en) * 1999-12-15 2003-07-01 Networks Associates Technology, Inc. Dynamic software wrapper
WO2005008531A2 (en) * 2003-07-11 2005-01-27 Computer Associates Think, Inc. Performance monitoring of method calls and database statements in an application server

Patent Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN1228175A (en) * 1996-08-20 1999-09-08 艾利森电话股份有限公司 Method and system for testing computer system software
CN1252875A (en) * 1997-02-28 2000-05-10 全斯美达有限公司 Method and apparatus for correcting errors in computer system
CN1232222A (en) * 1998-04-01 1999-10-20 日本电气株式会社 Apparatus for evaluating interface between software development tools, and recording medium for storing software for evaluating interface between software development tools
US6587888B1 (en) * 1999-12-15 2003-07-01 Networks Associates Technology, Inc. Dynamic software wrapper
WO2005008531A2 (en) * 2003-07-11 2005-01-27 Computer Associates Think, Inc. Performance monitoring of method calls and database statements in an application server

Non-Patent Citations (2)

* Cited by examiner, † Cited by third party
Title
一种面向构件化软件的在线演化方法. 王晓鹏,王千祥,梅宏.计算机学报,第28卷第11期. 2005
一种面向构件化软件的在线演化方法. 王晓鹏,王千祥,梅宏.计算机学报,第28卷第11期. 2005 *

Also Published As

Publication number Publication date
CN101004705A (en) 2007-07-25

Similar Documents

Publication Publication Date Title
Yuan et al. A graph-search based approach to BPEL4WS test generation
Schlingloff et al. Modeling and model checking web services
Aalst Business alignment: using process mining as a tool for delta analysis and conformance testing
CN103778038B (en) Method and system for verifying cloud test and remote monitoring integrated circuit device
Ampatzoglou et al. The perception of technical debt in the embedded systems domain: an industrial case study
US20030055809A1 (en) Methods, systems, and articles of manufacture for efficient log record access
US20140330890A1 (en) Context-Driven Application Information Access and Knowledge Sharing
US20050240545A1 (en) Methods and systems for monitoring and diagnosing machinery
CN103095518A (en) Coverage rate test processing method and device and coverage rate test server and system
JP2003091432A (en) Software evaluation system and software evaluation tool
Ye et al. Whitening SOA testing via event exposure
CN102834806A (en) System structure managing device, method of managing system structure, and program
Ali et al. Testing highly complex system of systems: an industrial case study
CN110232279A (en) A kind of leak detection method and device
Zalewski et al. Beyond ATAM: Early architecture evaluation method for large-scale distributed systems
CN108897686A (en) It is complete to record separately automated testing method and device
US7617462B2 (en) Graphical user interface (GUI) for displaying software component availability as determined by a messaging infrastructure
Hummer et al. Testing of data‐centric and event‐based dynamic service compositions
Abiteboul et al. The AXML artifact model
CN100435114C (en) Online method for checking out software based on interceptor
CN111125066B (en) Method and device for detecting functions of database auditing equipment
EP1574980A1 (en) Context objects for accessing message content
US11119877B2 (en) Component life cycle test categorization and optimization
Fagerström et al. Verdict machinery: On the need to automatically make sense of test results
CN113592453B (en) Information system operation compliance examining method and system based on block chain

Legal Events

Date Code Title Description
C06 Publication
PB01 Publication
C10 Entry into substantive examination
SE01 Entry into force of request for substantive examination
C14 Grant of patent or utility model
GR01 Patent grant
C17 Cessation of patent right
CF01 Termination of patent right due to non-payment of annual fee

Granted publication date: 20081119

Termination date: 20110118