Software applications are written using one or more programming languages. To create a software application, a developer writes the code that contains the instructions that the computer should perform. Some types of code may be compiled into an executable file, while in other types of code may be interpreted at runtime. In either scenario, the code is transformed at some point into machine instructions that the computer can execute.
Computers are becoming more and more powerful every day, and can communicate with one another over different communication channels, such as company networks or the Internet. This increase in computing power and networking between computers has enabled software developers to write software applications that execute across multiple computer locations. However, development of such distributed applications is difficult due to the complexity of the task. Part of the complication has to do with the numerous protocols, languages, and technologies that need to be mastered individually and then used in combination with each other in order to create a distributed application.
Various technologies and techniques are disclosed for enabling code to be executed on one or more execution contexts based upon annotations contained in the code or other locations. An annotation associated with a region of code is located. The annotation specifies information about an execution context where the region of code should be executed. A caller proxy is generated that is responsible for calling a callee adapter to execute the region of code. The callee adapter is generated that is responsible for receiving a call from the caller proxy and for dispatching a call to the region of code on the execution context. At runtime, the caller proxy receives a request to call the region of code and sends an execution request to the callee adapter. The callee adapter receives the execution request and dispatches a call to an executable version of the region of code. In one implementation, the execution environment is loaded in the callee adapter.
In one implementation, a method for invoking a call to a region of code through a callee adapter from a caller proxy is described. A request is received at a caller proxy to call a region of code. The region of code has a caller proxy and a callee adapter that were generated based upon at least some information specified in an annotation to the region of code to indicate that the region of code should be executed on a certain execution context. A call to the region of code is located in the caller proxy. An execution request for the region of code is passed to the callee adapter over a communication channel. The execution request contains a request that the callee adapter execute the region of code at the execution context.
In another implementation, a method for invoking a call to a region of code from a callee adapter upon request from a caller proxy is described. An execution request is received at a callee adapter from a caller proxy to execute a region of code. The caller proxy and the callee adapter were generated based upon at least some information specified in an annotation to the region of code to indicate that the region of code should be executed on an execution context. A call entry for the region of code is located in the callee adapter. A call is dispatched to an executable version of the region of code based upon information in the call entry.
This Summary was provided to introduce a selection of concepts in a simplified form that are further described below in the Detailed Description. This Summary is not intended to identify key features or essential features of the claimed subject matter, nor is it intended to be used as an aid in determining the scope of the claimed subject matter.
The technologies and techniques herein may be described as techniques for enabling code to be executed on one or more execution contexts based upon annotations contained in the code or other locations, but the technologies and techniques also serve other purposes in addition to these. In one implementation, one or more of the techniques described herein can be implemented as features within a software development program such as MICROSOFT® VISUAL STUDIO®, or from any other type of program or service that manages one or more parts of the software development and/or execution process.
An annotation associated with a particular region of code indicates that the region of code should be executed in a certain execution context (or more than one execution context). The term “region of code” as used herein is meant to include one or more contiguous or non-contiguous portions of code. A few non-limiting examples of a region of code can include a class, method, or other grouping of code. The term “execution context” as used herein is meant to include a context or location upon which an executable version of code can be run. Examples of execution contexts include a different computer, processor, thread, core on a processor, and so on. In one implementation, the annotation contains complete details about the execution context where the region of code should be executed.
In another implementation, the annotation is just an indirect reference or other indicator to designate that the region of code should be executed elsewhere. Other information, such as configuration data sources (files, data stores, etc.) can then be consulted at compile time and/or at runtime to determine this exact execution context. As another example, decisions about where to execute the region of code can be made a runtime by a load balancer based upon system availability. As yet another example, a setting or other option can be provided to specify when the annotations should be ignored altogether so that the splitting processes described herein are ignored and the application is simply run on a single tier or execution context, such as for testing. In yet another implementation, all or partial information about the execution context can be provided in the annotation, but information from other sources can still be consulted for further details. Other variations are also possible. The process of generating the caller proxies and callee adapters is described in further detail in
The code 12 is analyzed and a caller proxy 14 and callee adapter 16 are generated for each annotation that specifies an execution context on which the particular region of code should be executed. The term “caller proxy” as used herein is meant to include a program, service, or other executable logic that is responsible for receiving and forwarding a request to execute a region of code to a callee adapter. The term “callee adapter” as used herein is meant to include a program, service, or other executable logic that is responsible for receiving a request to execute a region of code and for dispatching a call to an executable version of the region of code. With respect to
In one implementation, a caller-side cache 20 is used by the caller proxy 14 to allow the caller proxy 14 to identify the objects for which execution is being requested. In other words, the caller-side cache 20 allows the caller proxy 14 to keep track of an identifier that allows a particular object or instance of that object to be identified on other execution contexts. So when the caller proxy 14 receives communications back from the callee adapter 16, the caller proxy 14 can use the caller-side cache 20 to determine what object (e.g. method or other region of code) is being referenced. Similarly, a callee-side cache 22 is used by the callee adapter 16 to keep track of an identifier or other information that allows a particular object or instance of that object to be identified by the callee adapter. These and other details regarding declarative execution context splitting system 10 will now be described in further detail in
Turning now to
The annotations and/or other details are then analyzed and/or interpreted (stage 104). In other words, the code (source code, intermediate version of the code, etc.) is parsed to identify the annotations that specify one or more execution contexts for executing the code. New code is then generated to create a caller proxy and a callee adapter (stage 106), as described in further detail in
For the sake of illustration, some exemplary code is shown below to provide an example of how a method, class, or other region of code can be annotated to indicate that it should be executed on a certain execution context.
[RunAtServer(“http://localhost:8081”)]
In the above code sample, notice how the entire Class called C has been decorated with an annotation (e.g. attribute) called RunAtServer, where the argument within double quotes represents the server's URI.
[RunAtServer(“http://localhost:8081”)]
The RunAtServer annotation in this example indicates that all of the methods contained in the Class C should be executed on a server at the specified location. This is just a non-limiting example, and various other types of annotations could be used in other implementation, such as for smaller or larger regions of code, as described previously. For example, the annotation could just contain an indirect reference or other indicator to designate that the region of code should be executed elsewhere. In such a scenario, the details surrounding the execution context could be located in a configuration or other file or data store that should be checked to get the exact execution context. Other variations are also possible.
To further illustrate the concepts of
[RunAtServer(“http://localhost:8081”)]
As shown above, each portion of the original code for Class C has been modified to include code for calling the callee adapter for each line of code.
The following code is an example of what the callee adapter for the Method C might look like in the hypothetical example.
As shown in the callee adapter example code above, each of the cases in the switch statement correspond to a particular region of the code in the original code. For example, case statement 1 corresponds to the region of code associated with property Y. Case statement 2 corresponds to the region of code associated with function F, and so on. Each case statement is then responsible for calling the executable version of the original code for Class C. These are just hypothetical examples, and numerous other styles and formats for creating caller proxies and callee adapters could also be used.
Now that a background has been given on the generation of caller proxies and callee adapters, the runtime use of the proxies will now be described in further detail.
The callee adapter then receives the request to call the region of code and locates a call in the callee adapter that points to executable version of the region of code (stage 158). An executable version of the region of code is then executed (stage 160). These stages are described in further detail in
Turning now to
As shown in
Additionally, device 300 may also have additional features/functionality. For example, device 300 may also include additional storage (removable and/or non-removable) including, but not limited to, magnetic or optical disks or tape. Such additional storage is illustrated in
Computing device 300 includes one or more communication connections 314 that allow computing device 300 to communicate with other computers/applications 315. Device 300 may also have input device(s) 312 such as keyboard, mouse, pen, voice input device, touch input device, etc. Output device(s) 311 such as a display, speakers, printer, etc. may also be included. These devices are well known in the art and need not be discussed at length here. In one implementation, computing device 300 includes one or more portions of declarative code splitter system 10 that was described in the earlier figures.
Although the subject matter has been described in language specific to structural features and/or methodological acts, it is to be understood that the subject matter defined in the appended claims is not necessarily limited to the specific features or acts described above. Rather, the specific features and acts described above are disclosed as example forms of implementing the claims. All equivalents, changes, and modifications that come within the spirit of the implementations as described herein and/or by the following claims are desired to be protected.
For example, a person of ordinary skill in the computer software art will recognize that the examples discussed herein could be organized differently on one or more computers to include fewer or additional options or features than as portrayed in the examples.