This application relates to a JavaScript™ programming extension.
JavaScript™ is a scripting language that is used for client-side web development. Despite its name, and while designed to look like Java™, JavaScript™ is unrelated to the Java™ programming language. Rather, JavaScript™ is a dynamic, weakly typed, prototype-based language intended to be easier for non-programmers to work with. “JavaScript™” is a trademark of Sun Microsystems.
In the past twelve years, JavaScript™ (JS) has been a de facto client-side scripting language for web pages. With the adoption of Web-2.0 for supporting rich client experience without sacrificing the easy accessibility of web application over WAN, the JavaScript™ programming in connection with cascading style sheets (CSS) and Markup language become a focal point of many web-technology efforts.
Embodiments of the present invention are illustrated by way of example and not limitation in the figures of the accompanying drawings, in which like reference numbers indicate similar elements and in which:
A JavaScript™ programming extension is described. In the following description, for purposes of explanation, numerous specific details are set forth in order to provide a thorough understanding of an embodiment of the present invention. It will be evident, however, to one skilled in the art that the present invention may be practiced without these specific details.
Several open-source and commercial projects had attempted to enhance the JavaScript™ programming model in recent years. Most of them provide a thin layer of abstraction to support componentized JavaScript™ programming and to isolate browser incompatibility in terms of native events. There have also been some attempts to have a complete server-side construct to facilitate an active programming in Java™ to produce JavaScript™ for the client runtime. However, due to the language incompatibilities between Java™ and JavaScript™, as well as runtime difference (server virtual machine (VM) and client browser), there is still no proven clean and simple server-side programming model. A set of client-side-centric widget kits have been introduced recently that boast componentization approaches and the ease of use.
However, all those attempts didn't address a number of issues that were identified by the inventors of the JavaScript™ programming extension. Some of these issues identified by the inventors are outlined below. For example, existing technologies lack clean server-side application programming interface (API) for referencing client-side JavaScript™ components, which pushes the client-side-script referencing to be a set of string-concatenation operations in the server side without any type/API validation at compile time and runtime. Furthermore, there is no direct support available for transformation from non-typed JavaScript™ API to typed Java™ API, which makes it difficult to directly use typed data in server-side programming when referencing client-side JavaScript™ components.
Another deficiency identified by the inventors is the lack of systematic dependency management for using client-side JavaScript™ components, which makes JavaScript™ bundling/externalization difficult. The inventors also identified the lack of systematic approach for controlling JavaScript™ scope mash-up applications fragile, e.g., due to possible naming conflicts at runtime. Because there is no support for running multiple JavaScript™ runtimes/frameworks on same page, migration of JavaScript™ components may prove very difficult if the content of a web page come from different servers, because the server-side JavaScript™ generation could be based on different JavaScript™ runtime/frameworks at different servers. For example, the content of a web page may be provided, e.g., via (a) server-side page assembly for portal pages, (b) client-side page assembly, or (c) AJAX calls.
In one example embodiment, a JavaScript™ programming extension is implemented in Java™ with smooth integration of integrated development environment (IDE), such as, e.g., Eclipse. An example JavaScript™ programming extension may be utilized to provide satisfactory solutions to the above mentioned problems identified by the named inventors. An example contract-centric system may be implemented in the context of a network environment 100 illustrated in
As shown in
The client system 110 may utilize the browser application 112 to access services provided by the server system 140. The server system 140 may employ a JavaScript™ programming extension 142, e.g., to access a JavaScript™ file, validate JavaScript™ definitions in the JavaScript™ file, and to generate a Java™ representation of the JavaScript™ file. An example system to provide a JavaScript™ programming extension is illustrated in
The code generator 210, in one example embodiment, may be configured to access an existing JavaScript™ file, validate JavaScript™ definitions in the existing JavaScript™ file (e.g., by utilizing the JavaScript™ parser 202 and the JavaScript™ definitions validator 204), and to invoke the Jsr class generator to generate Jsr class for the existing JavaScript™ file. The generated Jsr class embodies a Java™ representation of the existing JavaScript™ file. a Java™ representation of the existing JavaScript™ file. The set of converters 240, which may be referred to as a JavaScript™ reference converter, may be configured to generate a validated JavaScript™ corresponding to the existing JavaScript™. The dependencies manager 206, may be configured to maintain one or more dependencies among one or more JavaScript™ components in the validated JavaScript™ file. the communications module 280 may be configured to provide a validated JavaScript™ file to a browser application.
It will be noted, that while
An example of server-side JavaScript™ referencing is discussed below. In one example embodiment, a JavaScript™ referencing programming model is provided at the server side. A JavaScript™ referencing programming model may be implemented within the system 200 of
The generated JavaScript™ referencing class, e.g., the Jsr class generated by the Jsr class generator 220 of
As shown in
As mentioned above, with reference to
The method 400 may be performed by processing logic that may comprise hardware (e.g., dedicated logic, programmable logic, microcode, etc.), software (such as run on a general purpose computer system or a dedicated machine), or a combination of both. In one example embodiment, the processing logic resides at the server system 140 of
As shown in
One example feature of a JavaScript™ reference model is value-binding support. All generated Java™ functions can take typed-value-binding as their arguments, and the return type from a method invocation is also a typed-value-binding. Therefore, one can naturally pass function calls as other function's arguments, even though these function calls would produce JavaScript™ referencing code at server side instead of real values. In addition to general JavaScript™ components, more specific JavaScript™ object types may be enabled. Such specific object types, e.g., event handler and service request/response handlers may be supported in an example JavaScript™ reference model when other add-on runtime services (such as, e.g., EventDispater and ClientServiceEngine) enabled.
In one example embodiment, dependencies between JavaScript™ components may be automatically maintained via generated component spec based on JavaScript™ import/require statements. The dependencies may be maintained utilizing a dependencies manager 206 of
Static Java™ Invocation:
Java™:
Generated JavaScript™:
Example JavaScript™ scope is discussed below. In order to support multiple runtimes, as well as general mash-up applications, a standardized runtime scoping mechanism may be provided (e.g., utilizing the scope control module 270 of
Example ID generation and naming reservation is discussed below. In order to support JavaScript™ component's instantiation, initialization and referencing without requiring unique variable assignment in generated JavaScript™ code, an example Java™ Script Programming Extension optionally uses server-side IdGenerator to uniquely register component instances to client-side Registry. The IdGenerator can be scoped to avoid naming conflict form different dynamic page fragments, such as those from remote portlets. The scope name can be reserved via naming reservation system, which ensures that only the reservee, who reserves the name from a reservor in a domain, can access that value. Each reservor may be required to guarantee the uniqueness of the reservation ticket. Domain specific reservor can also obtain its own scope (prefix) from a global reservor in order to avoid naming conflict at large scale.
Example control of obfuscation and verbosity is discussed below. In one example embodiment, all JavaScript™ code is retrieved or generated at server side either at build time or at runtime. The standard access pattern for JavaScript™ resource provides complete control on the final form of JavaScript™, both in aggregated external JavaScript™ files and in-line JavaScript™ on the pages. Obfuscation can be applied to all or some JavaScript™ for eliminating comments, JsDocs and extra spaces, as well as for obfuscating variable names, etc. Obfuscation may be performed by the obfuscation module 208 of
Example JavaScript™ Resource Slotting is discussed below. In order to permit controlling of the JavaScript™ ordering and physical locations on a page and to achieve desired functional and performance characteristics, according to one example embodiment, a generic logical slotting mechanism had been provided. The slotting mechanism, implemented in one embodiment as the slotting module 260 of
Example JavaScript™ Externalization and Versioning is discussed below. In one example embodiment, a generic JavaScript™ resource extraction/aggregation mechanism has been derived to pre-aggregate system runtime JavaScript™ libraries as well as page-level JavaScript™ files. The versioning strategy via deployed table of content, that may be implemented via the versioning module 250 of
Example Integrated Development and Testing is discussed below. An example JavaScript™ Programming Extension JS-to-Java™ code generation may be integrated with a popular IDE-Eclipse. Both on-demand and auto code-gen may be supported via Eclipse plug-in. A standard ant task enables pre-build step for Jsr generation based on JavaScript™ files.
The techniques described herein may be utilized beneficially. e.g., in component JavaScript™ testing.
Example Runtime JavaScript™ Builder is discussed below. In order to support debug and testing over deployed application, one can proxy the external JavaScript™ links to a local IDE to rebuild the JavaScript™ with either verbose form or with new fixes without requiring any production re-roll.
Example JavaScript™ programming extension may be utilized advantageously in the context of server-side-centric web application development with Java™ or other languages, such as. e.g., .net, C++, etc. Example JavaScript™ programming extension may contribute to adoption of existing JavaScript™ widgets by providing server-side JavaScript™ referencing model via some example Java™ Script Programming Extension wrappers.
Machine readable medium will be understood as a medium that is capable of storing data in a form that can be accessed by an automated sensing device. Examples of machine-readable media include magnetic disks, cards, tapes, and optical disks, as well as other forms of volatile and non-volatile memory devices.
The example computer system 500 includes a processor 502 (e.g., a central processing unit (CPU), a graphics processing unit (GPU) or both), a main memory 504 and a static memory 506, which communicate with each other via a bus 508. The computer system 500 may further include a video display unit 510 (e.g., a liquid crystal display (LCD) or a cathode ray tube (CRT)). The computer system 500 also includes an alpha-numeric input device 512 (e.g., a keyboard), a user interface (UI) navigation device 514 (e.g., a cursor control device), a disk drive unit 516, a signal generation device 518 (e.g., a speaker) and a network interface device 520.
The disk drive unit 516 includes a machine-readable medium 522 on which is stored one or more sets of instructions and data structures (e.g., software 524) embodying or utilized by any one or more of the methodologies or functions described herein. The software 524 may also reside, completely or at least partially, within the main memory 504 and/or within the processor 502 during execution thereof by the computer system 500, with the main memory 504 and the processor 502 also constituting machine-readable media.
The software 524 may further be transmitted or received over a network 526 via the network interface device 520 utilizing any one of a number of well-known transfer protocols (e.g., Hyper Text Transfer Protocol (HTTP)).
While the machine-readable medium 522 is shown in an example embodiment to be a single medium, the term “machine-readable medium” should be taken to include a single medium or multiple media (e.g., a centralized or distributed database, and/or associated caches and servers) that store the one or more sets of instructions. The term “machine-readable medium” shall also be taken to include any medium that is capable of storing, encoding or carrying a set of instructions for execution by the machine and that cause the machine to perform any one or more of the methodologies of embodiments of the present invention, or that is capable of storing, encoding or carrying data structures utilized by or associated with such a set of instructions. The term “machine-readable medium” shall accordingly be taken to include, but not be limited to, solid-state memories, optical and magnetic media. Such media may also include, without limitation, hard disks, floppy disks, flash memory cards, digital video disks, random access memory (RAMs), read only memory (ROMs), and the like.
The embodiments described herein may be implemented in an operating environment comprising software installed on a computer, in hardware, or in a combination of software and hardware.
Thus, a programming extension for authoring style rules has been described. Although embodiments have been described with reference to specific example embodiments, it will be evident that various modifications and changes may be made to these embodiments without departing from the broader spirit and scope of the inventive subject matter. Accordingly, the specification and drawings are to be regarded in an illustrative rather than a restrictive sense.
This application is related to and hereby claims the priority benefit of U.S. Provisional Patent Application No. 60/961,647 filed Jul. 23, 2007 and entitled “JAVASCRIPT PROGRAMMING EXTENSION”, which application is incorporated herein by reference in its entirety.
Number | Date | Country | |
---|---|---|---|
60961647 | Jul 2007 | US |