Summary of the invention
Related method and system of disposing conventional application on cloud computing platform in the mode of SOA in the present invention, have solved the problems to the cloud computing platform smooth migration based on SOA by a large amount of existed systems (or in a conventional manner application system of exploitation).The implication that it has comprised the following aspects:
First, user disposes source program and configuration file, has recorded which class in source program and, by moving in the mode of service, be called service class in configuration file, and its class not being included in configuration file is called customer class.System reads configuration file, and in internal memory, generates corresponding service class list.
Secondly, system is upgraded the code structure of customer class automatically, to originally call service sector of breakdown and change into and call Stub service call code, the part that wherein needs to change comprises that the declarative statement relevant to service class, method call statement and statement call the statement of its method simultaneously.
Finally, in the source code that user is uploaded, the part relevant to service class is deployed in service container, and remaining part is deployed in application server together in conjunction with Stub service call code.
The invention provides a kind of method of disposing conventional application on cloud computing platform in the mode of SOA, comprise the following steps:
1) resolve the configuration file that user sets, and in internal storage structure, generate a service class list, conveniently by service class, generate dynamically updating of corresponding wsdl document and customer class code.
2), according to the information in service class list, the source code file of disposing from user, extract service class, and generate corresponding wsdl document.
3) according to the wsdl document generating, produce corresponding Stub service code, Stub service call code is added in the source file of user's deployment.
4) according to service class list, automatically upgrade customer class, the declarative statement relevant to service class, method call statement etc. is dynamically adjusted into the mode matching with Stub service call.
5) part relevant from service class in source code is deployed to respectively in different service containers, remaining part class is deployed in application server together in conjunction with Stub service call code.
Wherein, in described step 1) in, the configuration file of disposing by resolving user builds a corresponding class of service table by user configured service class in internal storage structure.User configured service class represents in cloud computing platform, in the mode of service, to move, and comes with the customer class difference of calling them.The configuration file format that user sets is XML file, and service class exists with the right likeness in form of namel-class.By DOM technology, can complete the parsing of XML configuration file.
Wherein, in described step 2) in, first according to the content of service class list, the source file of uploading from user, extract corresponding service class, then tool using (as java2wsdl order) is for each service class generates corresponding wsdl document, and whole process is completed automatically by program.
Wherein, in described step 3) in, first, according to the wsdl document generating, tool using (as wsdl2java order) generates corresponding Stub service call code, wsdl2java is not the reverse operation of java2wsdl, but produces the encapsulation code to wsdl document.Then the Stub service call code producing is embedded in source program, whole process is completed automatically by program.
Wherein, described step 4) in, automatically upgrading customer class is by performance analysis customer class source program, and the statement that the declarative statement relevant to service class, method call statement and statement is called simultaneously to its method is dynamically adjusted into the mode matching with Stub service call.By lexical analysis, navigate to the statement relevant to service class, then which kind of statement judgement belongs to, if service class declarative statement is the declarative statement of respective class in Stub service call code with regard to update service class.If service object's method call statement is updated to the statement relevant to Stub service call equally.If the statement of its method is called in statement simultaneously, according to aforementioned two kinds of methods, complete respectively renewal, until all statements relevant to service class finish after upgrading, whole process is completed automatically by program.
Wherein, described step 5) in, the deployment of application system minute two parts complete.A part is service, first service is automatically converted into and can disposes parts, wherein comprises service class itself and corresponding deployment descriptor file.Then by service arrangement in service container.Another part is and user-dependent applying portion that this part is deployed in application server.
Embodiment
For making feature of the present invention and advantage obtain more clearly understanding, below in conjunction with accompanying drawing, be described below in detail: as shown in Figure 1, conventional application as an integral deployment in application server.The performance of this application server has proposed very high requirement, all application operate on a station server simultaneously, when the application of disposing is more, to contention for resources such as CPU, storages, will become very fierce, thereby cause server performance to decline, also affect the normal operation of institute's application deployment simultaneously.In order to address this problem, proposed application system to be deployed in SOA mode the thought of cloud computing platform.The core concept of cloud computing is computational resource unified management and the scheduling connecting with network in a large number, form a computational resource pond to user or application service, although solved the problem of single server performance deficiency, but also brought the communication issue between a plurality of computational resources, the introducing of SOA has well made up this defect.Computational resource is divided into application server and service container, so just a large amount of logical process and data access operations consuming time can be encapsulated as to service, and operates in service container.After Fig. 2 has shown use the inventive method, conventional application deployment moves schematic diagram to cloud computing platform in SOA mode, as shown in the figure, user uses which class in the conventional application of configuration file mark to move in the mode of service, and is together deployed on cloud computing platform in conjunction with application itself.Then, cloud computing platform, by routine application SOAization, the part reserve part relevant to user interactions is deployed in application server, and the distribution mechanisms by cloud computing platform is deployed in the service container of dispersion by user configured service.Make to dispose in this way conventional application and will bring following benefit: application server only moves and partly relevant application of user interactions, and a large amount of logical process consuming time, data access are transferred to the service execution in service container, greatly reduce the calculated amount of application server, guarantee the operation that application server can be good.A plurality of delivery of services, in different service containers, can be realized to the load balancing of computing power, support the executed in parallel of a plurality of services simultaneously, improve the overall performance of application system.The mode that logical process, data access is converted to service is moved, and by serving to share, realizes the multiplexing of logical process, data access.
As mentioned above, SOA is applicable to cloud computing platform very much, and directly adopting the mode Application and Development of SOA and being deployed on cloud computing platform is the mode that is worth high praise.But this splits on the one hand a person and requires too high, difficulty is larger, also need to relearn the knowledge that SOA is relevant, also existing application is kept outside of the door on the other hand, want existing application deployment to cloud computing platform, also will adopt the mode of SOA again to develop according to the regulation of cloud computing platform, this be all huge waste undoubtedly concerning human and material resources.So the present invention proposes a kind of method of disposing conventional application on cloud computing platform in the mode of SOA, be intended to solve the wide gap between conventional application and cloud computing platform deployment, can, by a large amount of existing application deployments in cloud computing platform, remove the cost that exploitation brings again from simultaneously.
More than set forth the plurality of advantages of disposing conventional application process on cloud computing platform in the mode of SOA, introduced in detail the principle that realizes of the method below, as shown in Figure 3, described the detailed step of realizing the method.
Step 1: by reading configuration file, the list of initialization service class.Configuration file adopts the form storage data of XML (Extensive Makeup Language), and its structure is as follows:
XML file is converted into the internal storage structure of service class list, service class is to exist with the right form of namel-class in XML file.By DOM technology, can complete the parsing of XML configuration file.
Step 2: according to the service class list generating in step 1, locate these service class in source file, and use java2wsdl order that service class is generated to corresponding wsdl document.Detailed directions is as follows:
java2wsdl-cp.-cn?package.TestClassService-of?TestClassService.wsdl
Wherein ,-cp parameter specified class path ,-cn representation class title ,-of represents output file title.So said method is illustrated under current class.path, use the class of package.TestClassService by name to generate the file that is called TestClassService.wsdl.TestClassService.wsdl is corresponding one by one with package.TestClassService class, described all methods that package.TestClassService comprises, namely described with package.TestClassService service and carried out agreement and the information format that need to bind when mutual.
Step 3: generate Stub service call code.It is not necessary generating Stub service call code, and customer class is directly accessed wsdl document also can realize service call.But directly access wsdl document and call service more complicated, this has proposed challenge for automatically upgrading customer class below.And use wsdl2java order can use wsdl document to generate corresponding Stub service call code.Customer class is realized service call by operation Stub service call code, and does not need and wsdl document direct communication again.Wsdl2java detailed directions is as follows:
wsdl2java-uri?TestClassService.wsdl-p?package-s-ssi-o?build/service
Wherein,-uri parameter is specified the path of wsdl document, and-p specifies the bag name that generates java program code, and it is synchronization of access mode that-s specifies the service call mode of the code producing, the interface that-ssi specifies the service of generation to realize ,-o specifies the storing directory of producing program code.Carry out the method, will automatically generate Stub service call code.It is noted that wsdl2java is not the reverse process of java2wsdl, java2wsdl generates corresponding wsdl document by real service class, i.e. the detailed description file of service.And wsdl2java is for generation of resolving wsdl document, produce the code encapsulation of calling active service.That is to say, the Stub service call code that wsdl2java produces is by wsdl document, to call actual service class to carry out corresponding operating.And actual service class is exactly for generation of the class of wsdl document in java2wsdl order.
Step 4: upgrade customer class.As mentioned above, according to user configured service class, generate corresponding wsdl document, then produced corresponding Stub service call code.Service class and customer class are deployed on different servers the most at last.Between them, by Stub service call code, communicate, customer class, by Stub service call code, calls the logical process that active service class provides.But in the source file that user submits to, that customer class is used or directly to the calling of service class, this has just produced contradiction.Solution to this problem is to dynamically update customer class, by original logic transition of directly realizing by service class for to realize by Stub service call code.By analyzing, need the place of upgrading to comprise three aspects, respectively: declarative statement part, attribute & method call statement part and statement comprise the statement part of method call simultaneously.Concrete renewal process as shown in Figure 4.
Because needs dynamically update customer class, need to carry out lexical analysis, thereby which place of mark needs to upgrade.Lexical analysis adopts finite automaton to realize, owing to not needing that each word is analyzed, because all, need the statement upgrading all in a sentence, so adopt the morphology analysis methods of simplifying, Yi Juwei unit analyzes, the standard of weighing sentence be ' { ', ' } ', '; ' character.So just obtained each sentence in customer class code.
Before morphology analysis methods that adopt to simplify, produce each time a sentence.Service class statement location is exactly the place that positioning service class correlative occurs in a sentence, then upgrades corresponding customer class.Service class correlative has 3 kinds of forms of expression in customer class.They are respectively:
1) service class declarative statement.
2) statement of its method of object reference that service class is stated.
3) when service class is stated, call the statement of its method.
Due to 2) in may not there is not service class title, and just there is the object that service class is stated, so maintain the mapping of a service class and its object oriented in whole system is necessary very much, total energy guarantees to navigate to the object that service class is stated like this, because object before calling must statement, this is just 1) in complete.
After service class correlative location, just need to dynamically update customer class.Illustrate update rule below:
Service class declarative statement, when positioning service is included in service class list to certain class, and while stating, just need to upgrade, update rule is: after service class, add Stub character string, represent a new class, this class is in Stub service call code.This new class need to be imported parameter into, uses the url having configured to add that class name claims to navigate to the address of specific service.
Illustrate as follows:
Before renewal:
TestClassService?tcs=new?TestClassService();
After renewal:
url=base_url+″TestClassService″;
TestClassServiceStub?tcs=new?TestClassServiceStub(url);
Wherein, url and base_url are predefined variable, wherein
url=″″;
base_url=″http://localhost:8080/axis2/services/″;
Base_url has specified the address of disposing single service, add that TestClassService represents complete service path, and Stub character string is only just added in the variation of declarative statement after class name, TestClassServicestub is exactly the class in the Stub service call code automatically generating, and has encapsulated the details of access specific service.After having upgraded declarative statement, need to record service class and mapping thereof to TestClassServiceStub-tcs.
The statement of its method of object reference that service class is stated, now update rule is: according to the object of method call, find out corresponding service class.Then in Stub service call code, find out corresponding and method name, class that method rreturn value is relevant, and for method name sets a property in corresponding, the initial caps of parameter name in attribute method statement by name.By class and the attribute found out above, the class of statement method name correspondence, set a property, state class corresponding to method rreturn value and use the Stub object reference method state above and result is returned to class corresponding to rreturn value, the class corresponding by rreturn value can obtain actual value.Illustrate as follows:
Before renewal:
int?s1=tcs.add(10,20);
After renewal:
TestClassServiceStub.Add?add=new?TestClassServiceStub.Add();
add.setl1(10);
add.setl2(20);
TestClassServiceStub.AddResponse?addResponse=tcs.add(add);
int?s1=addResponse.get_return();
The semanteme of method call statement is to import two parameters into, is respectively 10 and 20, and calls the add method processing parameter of the object tcs that service class states, and result is deposited in s1.I1 is the attribute of method class, that is to say the parameter of service class add method.
In the time of service class statement, call the statement of its method, update rule is the summation of two kinds of situations above, update method is substantially constant, what just service class was claimed as object has done little change nominally, for fear of duplication of name, adopt service class initial small letter to add the integer variable that an overall situation increases progressively.Finally also need to record service class and mapping thereof to TestClassServiceStub-testClassServiceStub1.Illustrate as follows:
Before renewal:
int?s5=new?TestClassService().sub(20,10);
After renewal:
TestClassServiceStub?testClassServiceStub1=
new?TestClassServiceStub(base_url+″TestClassService″);
TestClassServiceStub.Sub?sub=new?TestClassServiceStub.Sub();
su?b.setl1(20);
sub.setl2(10);
TestClassServiceStub.SubResponse?subResponse=testClassServiceStub1.sub(sub);
int?s5=subResponse.get_return();
Step 5: system is disposed.System is disposed and is comprised two parts, and a part is the deployment of service, and another part is the deployment of customer class.The deployment of customer class is disposed as broad as long with traditional application system, only need to copy under the corresponding catalogue of application server, under the webapps catalogue under Tomcat.The deployment of service is relatively more loaded down with trivial details, first needs to generate for service class the description configuration file services.xml of coupling, is then packaged into a whole file (* .aar) issue.Services.xml configuration file is generated automatically by system, and its file layout is as follows:
Automatically generated after services.xml, under put it into/tmp/META-INF/ catalogue, under copy to/tmp of the binary file catalogue then source file being generated, finally by jar order, generated corresponding service arrangement file, jar order is used as follows:
cd/tmp
jar?cvf?TestClassService.aar.
First enter/tmp catalogue, is then packaged into TestClassService.aar by the All Files under current directory, finally TestClassService.aar is copied to corresponding catalogue under service container.When using Axis as service operation container, its catalogue is: AXI_HOME/WEB-INF/services.
Above-described content is described in detail each step of the inventive method; but specific implementation form of the present invention is not limited to this; for the those skilled in the art of the art, in the situation that do not deviate from the spirit of the method for the invention and various apparent change that claim scope is carried out it all within protection scope of the present invention.