Summary of the invention
The purpose of the embodiment of the invention is to propose a kind of requesting method of JAVA object, is intended to solve that RMI can't satisfy high-throughput in the prior art, and the protobuf messaging protocol can't universalization and Componentized technical matters.
The embodiment of the invention is achieved in that a kind of requesting method of JAVA object, comprises step:
Create request data structure, response data structure and requesting method structure;
Obtain the service parameter that method of servicing and said method of servicing in the described request data structure call through calling described request method structure, convert said service parameter into the JSON format parameter, and convert said JSON format parameter to string argument;
Make up the request data structure object, said string argument assignment in the described request data structure object, is sent far call request and described request data structure object;
Receive the response data structure objects through said response data structure; Obtain the response results string in the said response data structure objects; Convert said response results string into response results JSON object, and convert said response results JSON object into response results JAVA object.
Another purpose of the embodiment of the invention is to propose a kind of response method of JAVA object, comprises step:
Create response data structure and requesting method structure;
Receiving remote call request and request data structure object; According to the string argument in the said far call acquisition request described request data structure object; Convert said string argument into the JSON format parameter, and convert said JSON format parameter into service parameter;
Obtain service implementing and the corresponding method of servicing of said service implementing that said far call request is called according to said service parameter, generate response results JAVA object through calling said method of servicing;
Convert said response results JAVA object to response results JSON form object; Convert said response results JSON form object into the response results string again; Make up the response data structure objects; Response results JAVA object assignment in said response data structure objects, is returned said response data structure objects through described request method structure.
Another purpose of the embodiment of the invention is to propose a kind of request unit of JAVA object, and said device comprises first initial module, first acquiring unit, first converting unit, second converting unit, the first assignment unit, first construction unit, first transmitting element, first receiving element, second acquisition unit, the 3rd converting unit and the 4th converting unit;
Said first initial module links to each other with said first acquiring unit, first construction unit and first receiving element, is used to create request data structure, response data structure and requesting method structure;
Said first acquiring unit links to each other with first converting unit with said first initial module, is used for obtaining the method for servicing of described request data structure and the service parameter that said method of servicing calls through calling described request method structure;
Said first converting unit links to each other with second converting unit with said first acquiring unit, is used for converting said service parameter into the JSON format parameter;
Said second converting unit links to each other with the first assignment unit with said first converting unit, is used for converting said JSON format parameter to string argument;
The said first assignment unit links to each other with first construction unit with said second converting unit, is used for said string argument assignment to the request data structure object that makes up;
Said first construction unit links to each other with first transmitting element with said first initial module, the first assignment unit, is used to make up the request data structure object, and the request data structure object after the assignment is sent to said first transmitting element;
Said first transmitting element links to each other with said first construction unit, is used to receive the request data structure object that said first construction unit sends, and sends far call request and described request data structure object;
Said first receiving element links to each other with second acquisition unit with said first initial module, is used for receiving the response data structure objects through said response data structure;
Said second acquisition unit links to each other with the 3rd converting unit with said first receiving element, is used for obtaining the response results string of said response data structure objects;
Said the 3rd converting unit links to each other with the 4th converting unit with said second acquisition unit, is used for converting said response results string into response results JSON object;
Said the 4th converting unit links to each other with said the 3rd converting unit, is used for converting said response results JSON object into response results JAVA object.
Another purpose of the embodiment of the invention is to propose a kind of responding device of JAVA object, and said device comprises that second initial module, second receiving element, the 3rd acquiring unit, the 5th converting unit, the 6th converting unit, the 4th acquiring unit, the 3rd establishment unit, the 7th converting unit, the 8th converting unit, the second assignment unit, second construction unit and first return the unit;
Said second initial module links to each other with second construction unit with said second receiving element, is used to create response data structure and requesting method structure;
Said second receiving element links to each other with the 3rd acquiring unit with said second initial module, is used for receiving remote call request and request data structure object;
Said the 3rd acquiring unit links to each other with the 5th converting unit with said second receiving element, is used for the string argument according to said far call acquisition request described request data structure object;
Said the 5th converting unit links to each other with the 6th converting unit with said the 3rd acquiring unit, is used for converting said string argument into the JSON format parameter;
Said the 6th converting unit links to each other with the 4th acquiring unit with said the 5th converting unit, is used for converting said JSON format parameter into service parameter;
Said the 4th acquiring unit links to each other with the 3rd establishment unit with said the 6th converting unit, is used for obtaining service implementing and the corresponding method of servicing of said service implementing that said far call request is called according to said service parameter;
Said the 3rd establishment unit links to each other with the 7th converting unit with said the 4th acquiring unit, is used for generating response results JAVA object through calling said method of servicing;
Said the 7th converting unit links to each other with the 8th converting unit with said the 3rd establishment unit, is used for converting said response results JAVA object to response results JSON form object;
Said the 8th converting unit links to each other with the second assignment unit with said the 7th converting unit, is used for converting said response results JSON form object into the response results string;
The said second assignment unit links to each other with the 8th converting unit with said second construction unit, is used for response results JAVA object assignment to the response data structure objects that makes up;
Said second construction unit returns the unit and links to each other with said second initial module, the second assignment unit and first, is used to make up the response data structure objects, and the response data structure objects after the assignment is sent to first returns the unit;
Said first returns the unit, links to each other with said second construction unit, is used to receive the response data structure objects that said second construction unit sends, and returns said response data structure objects through described request method structure.
Another purpose of the embodiment of the invention is also to propose a kind of responding device of JAVA object, and said device comprises that second initial module, second receiving element, the 3rd acquiring unit, the 5th converting unit, the 6th converting unit, the 4th acquiring unit, the 3rd establishment unit, the 7th converting unit, the 8th converting unit, the second assignment unit, second construction unit, first return the unit, judging unit, second returns unit and the 3rd receiving element; Wherein said second initial module comprises the 4th establishment unit, the 5th establishment unit, second loading unit, release unit and storage unit;
Said the 4th establishment unit; Link to each other with second construction unit with said the 5th establishment unit, second receiving element; Be used to create request data structure, response data structure and requesting method structure, wherein said request data structure comprises Service name, method of servicing and string argument; Said response data structure comprises response return code and response results string; Described request method structure comprises the far call method and returns the response data structure objects;
Said the 5th establishment unit links to each other with second loading unit with said the 4th establishment unit, is used for described request data structure, response data structure and requesting method structure are generated the java class;
Said second loading unit links to each other with release unit with said the 5th establishment unit, is used to load protobuf and protobuf-rpc;
Said release unit links to each other with storage unit with said second loading unit, is used for the corresponding service implementing of issuing service and said service;
Said storage unit links to each other with judging unit with said release unit, and the Service name and the service implementing that are used for storing said service are to web services registry;
Said second receiving element links to each other with the 3rd acquiring unit with said the 4th establishment unit, also is used for receiving remote call request and request data structure object;
Said the 3rd acquiring unit; Link to each other with the 5th converting unit with said second receiving element, be used for calling Service name, method of servicing and the string argument of processor according to said far call acquisition request described request data structure object through Protobuf JAVA;
Said the 5th converting unit links to each other with the 6th converting unit with said the 3rd acquiring unit, is used for converting said string argument into the JSON format parameter;
Said the 6th converting unit links to each other with judging unit with said the 5th converting unit, is used for converting said JSON format parameter into service parameter;
Said judging unit links to each other with storage unit with said the 6th converting unit, the 4th acquiring unit, is used to judge whether web services registry exists said Service name, if then send to obtain and instruct said the 4th acquiring unit;
Said the 4th acquiring unit; Link to each other with the 3rd establishment unit with said judging unit; Be used to receive the instruction of obtaining of said judging unit transmission, and obtain service implementing and the corresponding method of servicing of said service implementing that said far call request is called according to said instruction, service parameter and the method for servicing of obtaining;
Said the 3rd establishment unit returns the unit with said the 4th acquiring unit and second and links to each other, and is used for generating response results JAVA object through calling said method of servicing;
Said second returns the unit, links to each other with the 3rd receiving element with said the 3rd establishment unit, is used for that said response results JAVA object is returned to Protobuf JAVA and calls processor;
Said the 3rd receiving element returns the unit and links to each other with the 7th converting unit with said second, is used for calling processor through Protobuf JAVA and receives said response results JAVA object;
Said the 7th converting unit links to each other with the 8th converting unit with said the 3rd receiving element, is used for converting said response results JAVA object to response results JSON form object;
Said the 8th converting unit links to each other with the second assignment unit with said the 7th converting unit, is used for converting said response results JSON form object into the response results string;
The said second assignment unit links to each other with the 8th converting unit with said second construction unit, is used for response results JAVA object assignment to the response data structure objects that makes up;
Said second construction unit returns the unit and links to each other with said the 4th establishment unit, the second assignment unit and first, is used to make up the response data structure objects, and the response data structure objects after the assignment is sent to first returns the unit;
Said first returns the unit, links to each other with said second construction unit, is used to receive the response data structure objects that said second construction unit sends, and returns said response data structure objects through described request method structure.
Another purpose of the embodiment of the invention is to propose a kind of request and responding system of JAVA object, and said system comprises request unit and responding device.
Another purpose of the embodiment of the invention is to propose a kind of request of said JAVA object and terminal of responding system of including.
The present invention includes and create request data structure, response data structure and requesting method structure; Call described request method structure and obtain the service parameter that method of servicing and said method of servicing in the described request data structure call, convert said service parameter into the JSON format parameter, and convert said JSON format parameter to string argument; Make up the request data structure object, said string argument assignment in the request data structure object that makes up, is sent far call request and described request data structure object; Receive the response data structure objects through said response data structure; Obtain the response results string in the said response data structure objects; Convert said response results string into response results JSON object, and convert said response results JSON object into response results JAVA object.The present invention has realized calling the purpose of JAVA object.Through request data structure, response data structure and requesting method structure, can directly replace the interface service that former RMI realizes, need not to revise original service logic, promote interface capability.The present invention also comprises receiving remote call request and request data structure object; According to the string argument in the said far call acquisition request described request data structure object; Convert said string argument into the JSON format parameter, and convert said JSON format parameter into service parameter; Obtain service implementing and the corresponding method of servicing of said service implementing that said far call request is called according to said service parameter, generate response results JAVA object through calling said method of servicing; Convert said response results JAVA object to response results JSON form object; Convert said response results JSON form object into the response results string again; Make up the response data structure objects; Response results JAVA object assignment in the response data structure objects that makes up, is returned said response data structure objects through described request method structure.The present invention has also realized the purpose of response JAVA object, and can further expand functional demand, like parameter verification, and concurrent lock, commercial demands such as security processing.Request and response method combine and can realize high-throughput, universalization and modularization simultaneously.And each interface or business object need not to rely on any interface just can use the present invention.
Embodiment
In order to make the object of the invention, technical scheme and advantage clearer, below in conjunction with accompanying drawing and embodiment, the present invention is further elaborated, for the ease of explanation, only show the part relevant with the embodiment of the invention.Should be appreciated that the specific embodiment that this place is described, only be used to explain the present invention, not in order to restriction the present invention.
The present invention includes and create request data structure, response data structure and requesting method structure; Call described request method structure and obtain the service parameter that method of servicing and said method of servicing in the described request data structure call, convert said service parameter into the JSON format parameter, and convert said JSON format parameter to string argument; Make up the request data structure object, said string argument assignment in the request data structure object that makes up, is sent far call request and described request data structure object; Receive the response data structure objects through said response data structure; Obtain the response results string in the said response data structure objects; Convert said response results string into response results JSON object, and convert said response results JSON object into response results JAVA object.The present invention has realized calling the purpose of JAVA object.Through request data structure, response data structure and requesting method structure, can directly replace the interface service that former RMI realizes, need not to revise original service logic, promote interface capability.The present invention also comprises receiving remote call request and request data structure object; According to the string argument in the said far call acquisition request described request data structure object; Convert said string argument into the JSON format parameter, and convert said JSON format parameter into service parameter; Obtain service implementing and the corresponding method of servicing of said service implementing that said far call request is called according to said service parameter, generate response results JAVA object through calling said method of servicing; Convert said response results JAVA object to response results JSON form object; Convert said response results JSON form object into the response results string again; Make up the response data structure objects; Response results JAVA object assignment in the response data structure objects that makes up, is returned said response data structure objects through described request method structure.The present invention has also realized the purpose of response far call JAVA object, and can further expand functional demand, like parameter verification, and concurrent lock, commercial demands such as security processing.Request and response method combine and can realize high-throughput, universalization and modularization simultaneously.And each interface or business object need not to rely on any interface just can use the present invention.
Embodiment one
Fig. 1 is the first preferred embodiment process flow diagram of the requesting method of JAVA object of the present invention, and said method comprises step:
S101 creates request data structure, response data structure and requesting method structure;
Simultaneously described request data structure, response data structure and requesting method structure are generated corresponding java class;
The described request data structure comprises the service parameter paramsDescription of Service name className, method of servicing method and string format; Said response data structure comprises response return code resultCode and response results string resultDescription; Described request method structure comprises the far call method and returns the response data structure objects;
For ease of understanding, illustrates one of definition and describe the proto file that general service calls, and it is following to generate the process of corresponding java class:
The request of java end and response are encapsulated in respectively independently in the object, these object factories the general information of java call method;
Use the protobuf instrument that described request data structure, response data structure and requesting method structure are generated corresponding java class RequestServiceProtos.java;
Protobuf is a serializing framework (for example, can be the serializing framework that google provides), is similar to XML, the such data representation language of JSON, and its maximum characteristics are based on scale-of-two, therefore representes efficient much short and small than traditional XML; Though be binary data format; But it is complicated therefore not become, and the developer gives command-line tool then through the message format according to the certain grammar definition structureization; Instrument will generate relevant class automatically, can support language environments such as java, c++, python; Through these types are included in the project, can call serializing and unserializing work that correlation technique is accomplished service message very easily;
The relevant jar of service interface, protobuf and protobuf-rpc that simultaneously, also need load JAVA class RequestServiceProtos.java, service end wraps client;
Protobuf-rpc is a java class storehouse, and the framework of the RMI of Protocol Buffers agreement is provided; NIO technology based on the Netty bottom; Support TCP reuse/keep-alive, SSL encrypt, RPC calls functions such as cancellation operation, embedded daily record;
Client connects through protobuf-rpc and service end, and service that provides through service interface JAVA API Calls service end and the corresponding method of servicing of said service;
Said service interface specification the method for servicing and the purpose of the required application of client, service implementing then can go with different method of servicing realize to use;
S102; Obtain the service parameter that method of servicing and said method of servicing in the described request data structure call through calling described request method structure; Convert said service parameter into the JSON format parameter, and convert said JSON format parameter to string argument;
Said service parameter is the method for servicing parameters needed;
The method of servicing method of service that the client call service end provides and said service; Obtain the service parameter that said method of servicing method calls; Convert said service parameter into the JSON format parameter, and convert said JSON format parameter to string argument paramsDescription;
Said service for client provides needed function, is preserved client data such as to client resource being provided, and is the important channel that realization specializes, and such as the parameter of revising certain NPC, after heavily loading, in recreation, embodies at once;
Said method of servicing refers to the JAVA function, realizes a concrete function according to service parameter;
For ease of understanding, illustrate:
S103 makes up the request data structure object, and said string argument assignment in the described request data structure object, is sent far call request and described request data structure object;
Make up request data structure object requestWapper; With the conversion after the string argument assignment in the described request data structure object; Arrive service end through transmission far call request of the far call method requestJavaMethod among the JAVA class RequestServiceProtos.java and request data structure object; Promptly protobuf-rpc transmission far call request and the request data structure object through client arrives service end, communicates;
S104; Receive the response data structure objects through said response data structure; Obtain the response results string in the said response data structure objects; Convert said response results string into response results JSON object, and convert said response results JSON object into response results JAVA object.
Present embodiment can also further expand functional demand on the basis of original protobuf; Like commercial demands such as parameter verification, concurrent lock, security processing; Can expand by Componentized, also can be packaged into general jar bag and be incorporated in the application, and need not in each is used, to go independent realization.Bottom method of calling (like netty, high-property transmission frameworks such as mina) and more performance (each request of RMI all can ask a separate threads to be handled) more flexibly than RMI can be provided.
Embodiment two
Fig. 2 is the second preferred embodiment process flow diagram of the requesting method of JAVA object of the present invention, and said method comprises step:
S201 creates request data structure, response data structure and requesting method structure;
S202 generates corresponding java class with described request data structure, response data structure and requesting method structure;
S203 loads the relevant jar bag of said JAVA class, service interface, protobuf and protobuf-rpc;
S204 is through service of calling of said service interface and the corresponding method of servicing of said service;
S205; Call processor through Protobuf JAVA and obtain the service parameter that method of servicing and said method of servicing in the described request data structure call; Convert said service parameter into the JSON format parameter, and convert said JSON format parameter to string argument;
Protobuf JAVA calls processor and is mainly used in the relevant information of calling the JAVA class in the client analysis, thereby converts defined form in the definition of Protobuf service message to, carries out Network Transmission through Protobuf-RPC then; Also be used for after service end is received the Protobuf service message; It is parsed into java object (as the class of calling, interface parameters etc.); Search then after corresponding realization class calls; Wait for that JAVA calls returning of result, again be packaged into response object in Protobuf service message at last, and return to client;
The definition of said Protobuf service message is used to describe recalls information, i.e. RequestServiceProtos.java;
S206 makes up the request data structure object, and said string argument assignment in the described request data structure object, is sent far call request and request data structure object through the far call method in the JAVA class;
Illustrate: make up request data structure object requestWapper; The string argument assignment in the described request data structure object, is arrived service end through transmission far call request of the far call method requestJavaMethod among the JAVA class RequestServiceProtos.java and request data structure object;
S207; Receive the response data structure objects through said response data structure; Call processor through Protobuf JAVA and obtain the response results string in the said response data structure objects; Convert said response results string into response results JSON object, and convert said response results JSON object into response results JAVA object;
Client receives the response data structure objects that service end is sent; Call processor through Protobuf JAVA and obtain the response results string in the said response data structure objects; And convert said response results string into response results JSON object, further convert said response results JSON object into response results java object.
Present embodiment comprises creates request data structure, response data structure and requesting method structure; Call described request method structure and obtain the service parameter that method of servicing and said method of servicing in the described request data structure call, convert said service parameter into the JSON format parameter, and convert said JSON format parameter to string argument; Through making up the request data structure object, said string argument assignment in the described request data structure object, is sent far call request and described request data structure object; Receive the response data structure objects through said response data structure; Obtain the response results string in the said response data structure objects; Convert said response results string into response results JSON object, and convert said response results JSON object into response results JAVA object.Present embodiment has realized calling the purpose of JAVA object.Directly replace the interface service that former RMI realizes through request data structure, response data structure and requesting method structure, need not to revise original service logic, promote interface capability.And each interface or business object need not to rely on any interface and just can use present embodiment.
Embodiment three
Fig. 3 is the first preferred embodiment process flow diagram of the response method of JAVA object of the present invention, and said method comprises step:
S301 creates response data structure and requesting method structure;
Further, also need create request data structure, and described request data structure, response data structure and requesting method structure are generated corresponding java class;
Service end loads protobuf and the relevant jar bag of protobuf-rpc, and connects through protobuf-rpc and client;
In addition, service end is also through API, JAVA explain, the issue of Spring configuration file provides to client service and the corresponding service implementing of said service, and Service name and the service implementing of storing said service are in web services registry;
Said service implementing refers to common java class, and such provides realization for each method of servicing of stating in the service interface;
S302; Receiving remote call request and request data structure object; String argument according in the said far call acquisition request described request data structure object converts said string argument into the JSON format parameter, and converts said JSON format parameter into service parameter;
Receive the far call request and the request data structure object of the protobuf-rpc transmission of client through the protobuf-rpc of server end; According to the string argument in the said far call acquisition request described request data structure object; Convert said string argument into the JSON format parameter, and convert said JSON format parameter into service parameter;
S303 obtains service implementing and the corresponding method of servicing of said service implementing that said far call request is called according to said service parameter, generates response results JAVA object through calling said method of servicing;
S304; Convert said response results JAVA object to response results JSON form object; Convert said response results JSON form object into the response results string again, make up the response data structure objects, with response results JAVA object assignment in said response data structure objects; Return said response data structure objects through described request method structure, promptly said response data structure objects is returned to client through described request method structure.
Embodiment four
Fig. 4 is the second preferred embodiment process flow diagram of the response method of JAVA object of the present invention, and said method comprises step:
S401 creates request data structure, response data structure and requesting method structure;
S402 generates corresponding java class with described request data structure, response data structure and requesting method structure;
S403 loads the relevant jar bag of protobuf and protobuf-rpc;
S404, through API, JAVA explain, the issuing service of Spring configuration file and the corresponding service implementing of said service, and Service name and the service implementing of storing said service are in web services registry;
S405; Receiving remote call request and request data structure object; Call processor according to Service name, method of servicing and string argument in the said far call acquisition request described request data structure object through Protobuf JAVA; Convert said string argument into the JSON format parameter, and convert said JSON format parameter into service parameter;
Receive the far call request and the request data structure object of the protobuf-rpc transmission of client through the protobuf-rpc of server end; According to said far call request the described request data structure object is parsed into described request data structure object corresponding Service name className, method of servicing method and string argument; Convert said string argument into the JSON format parameter, and convert said JSON format parameter into service parameter;
S406 judges whether web services registry exists said Service name, if then get into step S407, if not, then get into step S409;
S407; Obtain service implementing and the corresponding method of servicing of said service implementing that said far call request is called according to said service parameter and method of servicing; Generate response results JAVA object through calling said method of servicing, and said response results JAVA object is returned to Protobuf JAVA call processor;
Generally obtain service implementing and the corresponding method of servicing of said service implementing that said far call request is called according to said service parameter and method of servicing through the JAVA reflex mechanism;
S408; Protobuf JAVA calls processor and receives said response results JAVA object; And convert said response results JAVA object to response results JSON form object, and convert said response results JSON form object into the response results string again, make up the response data structure objects; Response results JAVA object assignment in said response data structure objects, is returned said response data structure objects through described request method structure.
After Protobuf JAVA calls processor and receives said response results JAVA object resultDescription; Convert said response results JAVA object to response results JSON form object; Convert said response results JSON form object into the response results string again; Subsidiary simultaneously response return code resultCode; Make up response data structure ResponseWapper object, the result is set in the said response data structure objects, through described request method structure said response data structure objects returns (ResponseWapper) is returned to client then;
S409 returns corresponding error code resultcode, as 1001 etc.
The present invention includes receiving remote call request and request data structure object; According to the string argument in the said far call acquisition request described request data structure object; Convert said string argument into the JSON format parameter, and convert said JSON format parameter into service parameter; Obtain service implementing and the corresponding method of servicing of said service implementing that said far call request is called according to said service parameter, generate response results JAVA object through calling said method of servicing; Through said response results JAVA object being converted to response results JSON form object; Convert said response results JSON form object into the response results string again; Make up the response data structure objects; Response results JAVA object assignment in said response data structure objects, is returned said response data structure objects through described request method structure.The present invention has reached the purpose of response JAVA object reference request, and can further expand functional demand, like commercial demands such as parameter verification, concurrent lock, security processing.Request and response method combine and can realize high-throughput, universalization and modularization.
Embodiment five
Fig. 5 is the first preferred embodiment structural representation of the request unit of JAVA object of the present invention.
Said device comprises first initial module, first acquiring unit, first converting unit, second converting unit, the first assignment unit, first construction unit, first transmitting element, first receiving element, second acquisition unit, the 3rd converting unit and the 4th converting unit;
Said first initial module links to each other with said first acquiring unit, first construction unit and first receiving element, is used to create request data structure, response data structure and requesting method structure;
Said first acquiring unit links to each other with first converting unit with said first initial module, is used for obtaining the method for servicing of described request data structure and the service parameter that said method of servicing calls through calling described request method structure;
Said first converting unit links to each other with second converting unit with said first acquiring unit, is used for converting said service parameter into the JSON format parameter;
Said second converting unit links to each other with the first assignment unit with said first converting unit, is used for converting said JSON format parameter to string argument;
The said first assignment unit links to each other with first construction unit with said second converting unit, is used for said string argument assignment to the request data structure object that makes up;
Said first construction unit links to each other with first transmitting element with said first initial module, the first assignment unit, is used to make up the request data structure object, and the request data structure object after the assignment is sent to said first transmitting element;
Said first transmitting element links to each other with said first construction unit, is used to receive the request data structure object that said first construction unit sends, and sends far call request and described request data structure object;
Said first receiving element links to each other with second acquisition unit with said first initial module, is used for receiving the response data structure objects through said response data structure;
Said second acquisition unit links to each other with the 3rd converting unit with said first receiving element, is used for obtaining the response results string of said response data structure objects;
Said the 3rd converting unit links to each other with the 4th converting unit with said second acquisition unit, is used for converting said response results string into response results JSON object;
Said the 4th converting unit links to each other with said the 3rd converting unit, is used for converting said response results JSON object into response results JAVA object.
Embodiment six
Fig. 6 is the second preferred embodiment structural representation of the request unit of JAVA object of the present invention.
Said device comprises first initial module, first acquiring unit, first converting unit, second converting unit, the first assignment unit, first construction unit, first transmitting element, first receiving element, second acquisition unit, the 3rd converting unit and the 4th converting unit; Wherein, said first initial module comprises the first establishment unit, the second establishment unit, first loading unit and first call unit;
The said first establishment unit; Link to each other with first receiving element with the said second establishment unit, first construction unit; Be used to create request data structure, response data structure and requesting method structure, wherein said request data structure comprises Service name, method of servicing and string argument; Said response data structure comprises response return code and response results string; Described request method structure comprises the far call method and returns the response data structure objects;
The said second establishment unit links to each other with first loading unit with the said first establishment unit, is used for described request data structure, response data structure and requesting method structure are generated the java class;
Said first loading unit links to each other with first call unit with the said second establishment unit, is used to load said JAVA class, service interface, protobuf and protobuf-rpc;
Said first call unit links to each other with first acquiring unit with said first loading unit, is used for through service of calling of said service interface and the corresponding method of servicing of said service;
Said first acquiring unit links to each other with first converting unit with said first call unit, also is used for calling processor through Protobuf JAVA and obtains the method for servicing of described request data structure and the service parameter that said method of servicing calls;
Said first converting unit links to each other with second converting unit with said first acquiring unit, is used for converting said service parameter into the JSON format parameter;
Said second converting unit links to each other with the first assignment unit with said first converting unit, is used for converting said JSON format parameter to string argument;
The said first assignment unit links to each other with first construction unit with said second converting unit, is used for said string argument assignment to the request data structure object that makes up;
Said first construction unit links to each other with first transmitting element with the said first establishment unit, the first assignment unit, is used to make up the request data structure object, and the request data structure object after the assignment is sent to said first transmitting element;
Said first transmitting element links to each other with said first construction unit, is used to receive the request data structure object that said first construction unit sends, and sends far call request and request data structure object through the far call method in the JAVA class;
Said first receiving element links to each other with second acquisition unit with the said first establishment unit, is used for receiving the response data structure objects through said response data structure;
Said second acquisition unit links to each other with said first receiving element, the 3rd converting unit, also is used for calling the response results string that processor obtains said response data structure objects through Protobuf JAVA;
Said the 3rd converting unit links to each other with the 4th converting unit with said second acquisition unit, is used for converting said response results string into response results JSON object;
Said the 4th converting unit links to each other with said the 3rd converting unit, is used for converting said response results JSON object into response results JAVA object.
Present embodiment is created request data structure, response data structure and requesting method structure through first initial module; Call described request method structure through first acquiring unit and obtain the service parameter that method of servicing and said method of servicing in the described request data structure call; Convert said service parameter into the JSON format parameter through first converting unit; Convert said JSON format parameter to string argument through second converting unit; Through the first assignment unit with said string argument assignment in the request data structure object that makes up; Make up the request data structure object through first construction unit, and the request data structure object after the assignment is sent to said first transmitting element; Send far call request and described request data structure object through first transmitting element; Receive the response data structure objects through first receiving element; Obtain the response results string in the said response data structure objects through second acquisition unit; Convert said response results string into response results JSON object through the 3rd converting unit; Convert said response results JSON object into response results JAVA object through the 4th converting unit.Present embodiment has realized calling the purpose of JAVA object.Can directly replace the interface service that former RMI realizes through request data structure, response data structure and requesting method structure, need not to revise original service logic, promote interface capability.And each interface or business object need not to rely on any interface and just can use present embodiment.
Embodiment seven
Fig. 7 is the first preferred embodiment structural representation of the responding device of JAVA object of the present invention.
Said device comprises that second initial module, second receiving element, the 3rd acquiring unit, the 5th converting unit, the 6th converting unit, the 4th acquiring unit, the 3rd establishment unit, the 7th converting unit, the 8th converting unit, the second assignment unit, second construction unit and first return the unit;
Said second initial module links to each other with second construction unit with said second receiving element, is used to create response data structure and requesting method structure;
Said second receiving element links to each other with the 3rd acquiring unit with said second initial module, is used for receiving remote call request and request data structure object;
Said the 3rd acquiring unit links to each other with the 5th converting unit with said second receiving element, is used for the string argument according to said far call acquisition request described request data structure object;
Said the 5th converting unit links to each other with the 6th converting unit with said the 3rd acquiring unit, is used for converting said string argument into the JSON format parameter;
Said the 6th converting unit links to each other with the 4th acquiring unit with said the 5th converting unit, is used for converting said JSON format parameter into service parameter;
Said the 4th acquiring unit links to each other with the 3rd establishment unit with said the 6th converting unit, is used for obtaining service implementing and the corresponding method of servicing of said service implementing that said far call request is called according to said service parameter;
Said the 3rd establishment unit links to each other with the 7th converting unit with said the 4th acquiring unit, is used for generating response results JAVA object through calling said method of servicing;
Said the 7th converting unit links to each other with the 8th converting unit with said the 3rd establishment unit, is used for converting said response results JAVA object to response results JSON form object;
Said the 8th converting unit links to each other with the second assignment unit with said the 7th converting unit, is used for converting said response results JSON form object into the response results string;
The said second assignment unit links to each other with the 8th converting unit with said second construction unit, is used for response results JAVA object assignment to the response data structure objects that makes up;
Said second construction unit returns the unit and links to each other with said second initial module, the second assignment unit and first, is used to make up the response data structure objects, and the response data structure objects after the assignment is sent to first returns the unit;
Said first returns the unit, links to each other with said second construction unit, is used to receive the response data structure objects that said second construction unit sends, and returns said response data structure objects through described request method structure.
Embodiment eight
Fig. 8 is the second preferred embodiment structural representation of the responding device of JAVA object of the present invention.
Said device comprises that second initial module, second receiving element, the 3rd acquiring unit, the 5th converting unit, the 6th converting unit, the 4th acquiring unit, the 3rd establishment unit, the 7th converting unit, the 8th converting unit, the second assignment unit, second construction unit, first return the unit, judging unit, second returns unit and the 3rd receiving element; Wherein said second initial module comprises the 4th establishment unit, the 5th establishment unit, second loading unit, release unit and storage unit;
Said the 4th establishment unit; Link to each other with second construction unit with said the 5th establishment unit, second receiving element; Be used to create request data structure, response data structure and requesting method structure, wherein said request data structure comprises Service name, method of servicing and string argument; Said response data structure comprises response return code and response results string; Described request method structure comprises the far call method and returns the response data structure objects;
Said the 5th establishment unit links to each other with second loading unit with said the 4th establishment unit, is used for described request data structure, response data structure and requesting method structure are generated the java class;
Said second loading unit links to each other with release unit with said the 5th establishment unit, is used to load protobuf and protobuf-rpc;
Said release unit links to each other with storage unit with said second loading unit, is used for the corresponding service implementing of issuing service and said service;
Said storage unit links to each other with judging unit with said release unit, and the Service name and the service implementing that are used for storing said service are to web services registry;
Said second receiving element links to each other with the 3rd acquiring unit with said the 4th establishment unit, is used for receiving remote call request and request data structure object;
Said the 3rd acquiring unit; Link to each other with the 5th converting unit with said second receiving element, be used for calling Service name, method of servicing and the string argument of processor according to said far call acquisition request described request data structure object through Protobuf JAVA;
Said the 5th converting unit links to each other with the 6th converting unit with said the 3rd acquiring unit, is used for converting said string argument into the JSON format parameter;
Said the 6th converting unit links to each other with judging unit with said the 5th converting unit, is used for converting said JSON format parameter into service parameter;
Said judging unit links to each other with storage unit with said the 6th converting unit, the 4th acquiring unit, is used to judge whether web services registry exists said Service name, if then send to obtain and instruct said the 4th acquiring unit;
Said the 4th acquiring unit; Link to each other with the 3rd establishment unit with said judging unit; Be used to receive the instruction of obtaining of said judging unit transmission, and obtain service implementing and the corresponding method of servicing of said service implementing that said far call request is called according to said instruction, service parameter and the method for servicing of obtaining;
Said the 3rd establishment unit returns the unit with said the 4th acquiring unit and second and links to each other, and is used for generating response results JAVA object through calling said method of servicing;
Said second returns the unit, links to each other with the 3rd receiving element with said the 3rd establishment unit, is used for that said response results JAVA object is returned to Protobuf JAVA and calls processor;
Said the 3rd receiving element returns the unit and links to each other with the 7th converting unit with said second, is used for calling processor through Protobuf JAVA and receives said response results JAVA object;
Said the 7th converting unit links to each other with the 8th converting unit with said the 3rd receiving element, is used for converting said response results JAVA object to response results JSON form object;
Said the 8th converting unit links to each other with the second assignment unit with said the 7th converting unit, is used for converting said response results JSON form object into the response results string;
The said second assignment unit links to each other with the 8th converting unit with said second construction unit, is used for response results JAVA object assignment to the response data structure objects that makes up;
Said second construction unit returns the unit and links to each other with said the 4th establishment unit, the second assignment unit and first, is used to make up the response data structure objects, and the response data structure objects after the assignment is sent to first returns the unit;
Said first returns the unit, links to each other with said second construction unit, is used to receive the response data structure objects that said second construction unit sends, and returns said response data structure objects through described request method structure.
Present embodiment is created response data structure and requesting method structure through second initial module; Through the second receiving element receiving remote call request and request data structure object; Through the 3rd acquiring unit according to the string argument in the said far call acquisition request described request data structure object; Convert said string argument into the JSON format parameter through the 5th converting unit; Convert said JSON format parameter into service parameter through the 6th converting unit; Obtain service implementing and the corresponding method of servicing of said service implementing that said far call request is called through the 4th acquiring unit according to said service parameter; The 3rd establishment unit generates response results JAVA object through calling said method of servicing; Convert said response results JAVA object to response results JSON form object through the 7th converting unit; Convert said response results JSON form object into the response results string through the 8th converting unit; Make up the response data structure objects through second construction unit, and the response data structure objects after the assignment is sent to first return the unit; Return the unit through first and receive the response data structure objects that said second construction unit sends, and return said response data structure objects through described request method structure.Present embodiment has reached the purpose of response JAVA object reference request.Can also further expand functional demand, like commercial demands such as parameter verification, concurrent lock, security processing.Said second initial module further is refined as the 4th establishment unit, the 5th establishment unit, second loading unit, release unit and storage unit; And in said device, increase judging unit, second and return unit and the 3rd receiving element; Judge whether to exist Service name through web services registry; Thereby confirm service implementing and the corresponding method of servicing of said service implementing that far call JAVA object requests is called, further improved universalization and Componentized possibility.
Embodiment nine
Fig. 9 is the request of JAVA object of the present invention and the example structure synoptic diagram of responding system.
Said system comprises request unit and responding device;
The described request device comprises first initial module, first acquiring unit, first converting unit, second converting unit, the first assignment unit, first construction unit, first transmitting element, first receiving element, second acquisition unit, the 3rd converting unit and the 4th converting unit;
Said responding device comprises that second initial module, second receiving element, the 3rd acquiring unit, the 5th converting unit, the 6th converting unit, the 4th acquiring unit, the 3rd establishment unit, the 7th converting unit, the 8th converting unit, the second assignment unit, second construction unit and first return the unit;
Said first initial module links to each other with said first acquiring unit, first construction unit and first receiving element, is used to create request data structure, response data structure and requesting method structure;
Said second initial module links to each other with second construction unit with said second receiving element, is used to create request data structure, response data structure and requesting method structure;
Said first initial module all will be created identical request data structure, response data structure and requesting method structure with second initial module, and generates identical JAVA class, is placed on client and service end respectively;
Said first acquiring unit links to each other with first converting unit with said first initial module, is used for obtaining the method for servicing of described request data structure and the service parameter that said method of servicing calls through calling described request method structure;
Said first converting unit links to each other with second converting unit with said first acquiring unit, is used for converting said service parameter into the JSON format parameter;
Said second converting unit links to each other with the first assignment unit with said first converting unit, is used for converting said JSON format parameter to string argument;
The said first assignment unit links to each other with first construction unit with said second converting unit, is used for said string argument assignment to the request data structure object that makes up;
Said first construction unit links to each other with first transmitting element with said first initial module, the first assignment unit, is used to make up the request data structure object, and the request data structure object after the assignment is sent to said first transmitting element;
Said first transmitting element; Link to each other with second receiving element with said first construction unit; Be used to receive the request data structure object that said first construction unit sends, and send the far call request and arrive said second receiving element with the described request data structure object;
Said second receiving element links to each other with said second initial module, the 3rd acquiring unit and first transmitting element, is used to receive far call request and the request data structure object that said first transmitting element sends;
Said the 3rd acquiring unit links to each other with the 5th converting unit with said second receiving element, is used for the string argument according to said far call acquisition request described request data structure object;
Said the 3rd acquiring unit also is used for calling Service name, method of servicing and the string argument of processor according to said far call acquisition request described request data structure object through Protobuf JAVA;
Said the 5th converting unit links to each other with the 6th converting unit with said the 3rd acquiring unit, is used for converting said string argument into the JSON format parameter;
Said the 6th converting unit links to each other with the 4th acquiring unit with said the 5th converting unit, is used for converting said JSON format parameter into service parameter;
Said the 4th acquiring unit links to each other with the 3rd establishment unit with said the 6th converting unit, is used for obtaining service implementing and the corresponding method of servicing of said service implementing that said far call request is called according to said service parameter;
Said the 4th acquiring unit is used to also judge whether web services registry exists said Service name; If then obtain service implementing and the corresponding method of servicing of said service implementing that said far call request is called according to said instruction, service parameter and the method for servicing of obtaining; Promptly obtain service implementing and the corresponding method of servicing of said service implementing that said far call request is called according to said service parameter and method of servicing through the JAVA reflex mechanism;
Said the 3rd establishment unit links to each other with the 7th converting unit with said the 4th acquiring unit, is used for generating response results JAVA object through calling said method of servicing;
Said the 3rd establishment unit is used for that also said response results JAVA object is returned to ProtobufJAVA and calls processor;
Said the 7th converting unit links to each other with the 8th converting unit with said the 3rd establishment unit, is used for converting said response results JAVA object to response results JSON form object;
Said the 7th converting unit also is used for calling processor through Protobuf JAVA and receives said response results JAVA object, converts said response results JAVA object to response results JSON form object;
Said the 8th converting unit links to each other with the second assignment unit with said the 7th converting unit, is used for converting said response results JSON form object into the response results string;
The said second assignment unit links to each other with the 8th converting unit with said second construction unit, is used for response results JAVA object assignment to the response data structure objects that makes up;
Said second construction unit returns the unit and links to each other with said second initial module, the second assignment unit and first, is used to make up the response data structure objects, and the response data structure objects after the assignment is sent to first returns the unit;
Said first returns the unit; Link to each other with first receiving element with said second construction unit; Be used to receive the response data structure objects that said second construction unit sends, and return said response data structure objects to said first receiving element through described request method structure.
Said first receiving element links to each other with second acquisition unit with said first initial module, is used for receiving said first through said response data structure and returns the response data structure objects that returns the unit;
Said second acquisition unit links to each other with the 3rd converting unit with said first receiving element, is used for obtaining the response results string of said response data structure objects;
Said the 3rd converting unit links to each other with the 4th converting unit with said second acquisition unit, is used for converting said response results string into response results JSON object;
Said the 4th converting unit links to each other with said the 3rd converting unit, is used for converting said response results JSON object into response results JAVA object.
Present embodiment is through returning first transmitting element unit and be connected with second receiving element, first receiving element and first; Specified the reciprocal process of request unit and responding device; Reached the purpose of calling the JAVA object; And request unit and responding device combine, and can realize high-throughput, universalization and modularization.Present embodiment can also further expand functional demand on original protobuf basis; Like commercial demands such as parameter verification, concurrent lock, security processing; Can expand by Componentized, also can be packaged into general jar bag and be incorporated in the application, and need not in each is used, to go independent realization.Can also provide than RMI more flexibly the bottom method of calling (like netty; High-property transmission frameworks such as mina) and more performance (each request of RMI all can ask a separate threads to be handled; And be based on event notice like the netty server; Promptly a thread can be provided more high-throughput and lower operating lag by a plurality of share requests).
Following content among the embodiment five to nine is not given unnecessary details in embodiment five to nine with embodiment one to four again: the detailed description of the generative process of the particular content that is comprised in described request data structure, response data structure and the requesting method structure, proto file, java class, protobuf instrument, protobuf, loading content, protobuf-rpc, each step or each process, each explanation of nouns etc.
The request of JAVA object provided by the invention and responding system need can be applied on the terminal device of JAVA object reference, for example PC, PDA, mobile phone etc.
Those having ordinary skill in the art will appreciate that; All or part of step in realization the foregoing description method can be accomplished through the programmed instruction related hardware; Described program can be stored in the computer read/write memory medium, and described storage medium can be ROM, RAM, disk, CD etc.
The above is merely preferred embodiment of the present invention, not in order to restriction the present invention, all any modifications of within spirit of the present invention and principle, being done, is equal to and replaces and improvement etc., all should be included within protection scope of the present invention.