This application claims priority under 35 U.S.C. §119 from Chinese Patent Application No. filed 201110337788.1 filed on Oct. 31, 2011, the entire contents of which are incorporated herein by reference.
1. Field of the Invention
The present invention generally relates to information processing technology. More particularly, the present invention relates to a method and system for processing published events and subscribed events.
2. Related Art
Widgets are a kind of currently popular applications. Generally speaking, a widget occupies a small part of region on the desk of a user's operating system, and accomplishes some specific functions.
A widget is an end-to-end application, and the functions it accomplishes are specific and unitary. A widget usually provides a specific configuration function, allowing a user to customize. Since their functions are specific, they have high reusability. Widgets are usually built on some platform, which is responsible for their management; in the mean time, the platform will provide a series of APIs for use by the widgets. A third party can develop its own widgets based on the development specifications provided by the platform, and run the widgets on the platform. Widgets can mainly be classified into the following categories based on the types of the operating platforms: desktop widgets, mobile widgets, and web widgets.
In the following will be described in detail web widgets related to the present invention. Just as the name implies, a web widget uses the web as its operating platform, and can be embedded in a web application. General speaking, the popularity of web widget specifications cannot do without the support of a complete ecosystem. A mature web widget ecosystem shall be composed of the following parts:
Specifications, APIs and documents: This part is mainly for developers. Clearly-defined specifications, APIs and sufficient documents can help developers to develop web widgets more rapidly.
Operating Platform: This part is mainly for end users. End users need this platform to use widgets developed by developers.
Community: A complete web widget ecosystem cannot do without a perfect community support. The community is a bridge between end users and developers. Developers can publish the widgets they have developed, and end users can browser and search for the widgets, and add interested ones into their own runtime environments. In the mean time, the end users can comment and score the web widgets.
Taking the web widget ecosystem by Google® as an example, Google® gadgets have corresponding specifications, and have detailed development documents. The operating platforms for Google gadgets include iGoogle®, Slogger®, Gmail®, etc; Google® offers a gadget directory, and users can publish, comment on and score gadgets. Netvibes® uses the Universal Widget API (UWA) as its specification; netvibes.com is its operating platform; eco.netvibes.com is its community. Web application developers use these specifications and development documents to develop web applications including various widgets.
A related webpage of a web application invokes a related widget container, which is for rendering and managing widgets on the page and is platform independent, and usually is JS API. A widget container can be provided by the server, or by the client, such as JS library, or it can be provided by server-Fclient, and currently there are corresponding tools in the market.
Web widgets communicate with each other through events. Usually there are two types of communication: one is topic-based communications represented by Open Social Gadget®, and the other is defining events and event types, and communicatively connecting events of widgets by programming or end user wiring.
Web widgets are widely used in currently popular Mashup applications. Mashups are a new type of web applications, and they have the features of the second generation of web applications (Web 2.0), and can use contents retrieved from external data sources to create brand-new innovative services. Usually an end user can set up web widgets by dragging, and typical applications are map mashups, video and image mashups, search and shopping mashups and news mashup, etc.
Therefore, a method and system that can properly improve the current technology are needed to alleviate related development and programming work.
A method for processing published and subscribed events. The method includes the steps of: parsing definitions of published events and subscribed events in widget definition files in a webpage, generating a set of published events and a set of subscribed events, respectively, based on the definitions of the published events and the subscribed events, and generating a definition file of a hidden widget based on the set of published events and the set of subscribed events, where at least one step of the method is carried out on a computer device.
A system for processing published and subscribed events. The system includes: at least one computer processor configured to: parse definitions of published events and subscribed events in widget definition files in a webpage, generate a set of published events and a set of subscribed events, respectively, based on the definitions of the published events and the subscribed events, and generate a definition file of a hidden widget based on the set of published events and the set of subscribed events.
In order to describe the features and advantages of the embodiments of the present invention in more detail, reference is made to the following accompanying drawings. If possible, same or similar reference signs are used in the accompanying drawings and the description to denote the same or similar parts. In the drawings:
In one aspect of the present invention, there is provided a method for processing published events and subscribed events, including: parsing definitions of published events and subscribed events in widget definition files in a webpage; generating a set of published events and a set of subscribed events based on the definitions of the published events and the subscribed events; and generating a definition file of a hidden widget based on the set of published events and the set of subscribed events.
In another aspect of the present invention, there is provided a system for processing published events and subscribed events, including: parsing means configured to parse definitions of published events and subscribed events in widget definition files in a webpage; set generating means configured to generate a set of published events and a set of subscribed events based on the definitions of the published events and the subscribed events; and definition file generating means configured to generate a definition file of a hidden widget based on the set of published events and the set of subscribed events.
By using embodiments of the present invention, web application developers do not need to rewrite the code of a related widget for publishing events or defining events due to an update of the related widget in a web application, and can ensure the normal operation of the original widget of which the code is not amended, so as to save the web application developers large amounts of time and effort, thus saving large amounts of development costs of web applications.
Now detailed description will be made by referring to the exemplary embodiments of the present invention, examples of which are illustrated in the drawings, where the same reference signs denote the same elements throughout the drawings. It should be understood that the present invention is not limited to the disclosed exemplary embodiments. It should also be understood that not every feature of the method and system is necessary for implementing the present invention claimed by any claim. In addition, in the entire disclosure, when a process or method is displayed or described, the steps of the method can be executed in any order or executed simultaneously, unless it can be seen clearly from the context that one step depends on another step executed previously. Further, there can be obvious temporal intervals between the steps.
First a basic concept of the present invention is introduced. Considering the defects in the prior art, the inventor of the present invention finds through long time and arduous study that, due to the flexibility of the publishing and subscription of widgets, the contents of events published and subscribed by the widgets vary greatly, and it is very hard and costly to only rely on program developers passively amending the code of the widgets to adapt to the changes.
The inventor of the present application conceived a new concept of using a hidden widget as a bridge between widgets, which can greatly save the workload of program developers.
As shown in
In the following is shown, as an example, part of the definitions of the events published by the main search widget in
The parsing process is to, by traversing the definition files of the widgets in the webpage (those skilled in the art know that the related definition files can be obtained through APIs of the widget container), detect whether the value of “published” of an event in the definition files of the widgets is true; and if it is, determine that the event needs to be published.
For example, the event “searchComplete” in the above definition file needs to be published. payloadType=“searchResult” means that the event data type payloadType of the published event is “searchResult”; and <iw:payloadDef name=“searchResult”> and <iw:payloadDef name=“tagType”> represent that the closely followed related event contents are specific definition contents. The specifically published event instance can be represented in json data. A specific example of one published event instance in
In the following is shown, as an example, the definition of an event subscribing to the event related to tags in the widget file in
A similar parsing method can be used for subscribed events, and is not repeated here. By parsing the definitions of the published events and subscribed events in the widget definition files in the webpage, the published events and the subscribed events in all the widgets in the webpage can be known.
At step 403, based on the definitions of the published events and the subscribed events, generate a set of published events and a set of subscribed events respectively. Based on the published events and subscribed events known in the previous step, the published events and the subscribed events are formed as a set of published events and a set of subscribed events.
Those skilled in the art know that forming sets is only one implementation, and those skilled in the art can, based on the concept of the present application, contemplate any other suitable forms of data, e.g., the published events and definitions events can also form a list with different identifiers added, and forms such as an array of published events and an array of subscribed events, etc.
At step 405, based on the set of published events and the set of subscribed events, generate a definition file of a hidden widget. At this step, based on the set of published events and the set of subscribed events, and according to the event data types of the subscribed events, match the corresponding published events in the set of published events, and gather the matching events and generate the logic code for republishing the matching events, so that the definition file of the hidden widget is formed.
The logic code can be JavaScript, and an example of simple main logic code for publishing an event is: this.iContext.iEvents.publishedEvent(“sendData”,dateTime), which represents that an event with the name of sendData, and with the time content of dataTime is published, and the contents of the event instance can be obtained by variable assignment. Those skilled in the art understand that it is common knowledge to automatically generate the logic code for republishing an event based on a related specification of widgets, and in order to save space, it is not repeated here. The following example gives the definition of a republished event in a generated hidden widget definition file:
The above first paragraph of definitions presents the subscription code of the hidden widget generated according to the specification, and the second paragraph of definitions is the republished event definition of the event “publishedTags”, and it can be seen that it is (a matching event) extracted from the definitions of the published events of the main search widget.
Another aspect of the present invention provides another preferred embodiment for generating the definition file of the hidden widget. Logic code for processing the set of published event and the set of subscribed events is generated, and the logic code is for: searching in the set of published events based on the event data type of at least one subscribed event in the set of subscribed events; in response to finding published events matching the event data type in the set of published events, extracting corresponding contents of the published events; in response to having traversed the set of published events, gathering the contents of all the matching published events and republishing the matching published events to form the definition file.
The difference between the preferred embodiment mentioned in the directly preceding paragraph and the embodiment shown in
Preferably, the set of the published events and the set of subscribed events can be stored in attributes of the definition file of the hidden widget, such that the information of the set of the published events and the set of subscribed events can be directly obtained from the attributes of the hidden widget, thus the event matching processing is convenient.
The present invention also includes loading the hidden widget into the page. The hidden widget is hidden from or transparent to the end user, and it resides in the background processing instances of related published and subscribed events in the webpage (at runtime).
The present invention can be realized by JavaScript (of course, those skilled in the art can realize the present invention based on the present invention by using any other web application development languages), and can be contained in a corresponding widget container.
Web application developers can use the method for the present invention by referencing the related widget container. In this way, the widget is enabled to published all the events it can publish according to the related platform standard specification; and other widgets can also freely subscribe to the published related events based on the related platform standard specification, without needing the programmers to additionally rewrite part of the code of the widget related to the published events and the subscribed events.
If something like iWidget® by IBM® is used as the widget platform, since the platform needs to communicatedly wire widget events through programming or end user wiring, the code for events wiring needs to be rewritten in the HTML document of the webpage, where one rewritten instance is as follows:
The code of event wiring in the original subscribed events is rewritten from:
to as follows in the definition file of the hidden widget:
And the event wiring code in the widget of the subscribed events is rewritten as:
The present invention also provides a system 600 for processing published events and subscribed events. System 600 includes: parsing means 601 configured to parse definitions of published events and subscribed events in widget definition files in a webpage; set generating means 603 configured to generate a set of published events and a set of subscribed events based on the definitions of the published events and the subscribed events; and definition file generating means 605 configured to generate a definition file of a hidden widget based on the set of published events and the set of subscribed events.
In addition, the definition file generating means 605 includes: traversing means configured to traverse the set of published events based on event data type of at least one subscribed event in the set of subscribed events; extracting means configured to, in response to finding published events matching the event data type in the set of published events, extract corresponding contents of the published events; gather means configured to, in response to having traversed the set of published events, gather the contents of all the matching published events to form the definition file of the hidden widget; and logic code generating means configured to generate logic code for republishing the matching published events as part of the definition file of the hidden widget.
In addition, system 600 further includes storage means configured to store the set of the published events and the set of the subscribed events into attributes of the hidden widget.
In addition, system 600 further includes loading means configured to load the hidden widget into the page.
In addition, system 600 further includes: rewriting means configured to rewrite the logic code for event wiring in the HTML document of the webpage.
In addition, the definition file generating means 605 includes: logic code generating means configured to generate logic code for processing the set of published events and the set of the subscribed events, the logic codes being for: traversing the set of published events based on the event data type of at least one subscribed event in the set of subscribed events; in response to finding published events matching the event data type in the set of published events, extracting corresponding contents of the published events; in response to having traversed the set of the published events, gathering the contents of all the matching published events and republishing the matching published events to form the definition file of the hidden widget.
The functions of each component in
The entire system shown in
Although the computer system described in
Although the exemplary embodiments of the present invention are described by referring to the accompanying drawings, it should be understood that the present invention is not limited to these specific embodiments, and those of ordinary skill in the art can make various changes to the embodiments without departing from the scope and sprits of the present invention. All these changes and modifications are intended to be included within the scope of the present invention defined in the appended claims.
Moreover, based on the above description, those skilled in the art will appreciate that aspects of the present invention can be embodied as a system, method or computer program product. Accordingly, aspects of the present invention can take the form of an entirely hardware embodiment, an entirely software embodiment (including firmware, resident software, micro-code, etc.) or an embodiment combining software and hardware aspects that can all generally be referred to herein as a “circuit,” “module” or “system.” Furthermore, aspects of the present invention can take the form of a computer program product embodied in one or more computer readable medium(s) having computer readable program code embodied thereon.
Any combination of one or more computer readable medium(s) can be utilized. The computer readable medium can be a computer readable signal medium or a computer readable storage medium.
A computer readable storage medium can be, for example, but not limited to, an electronic, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus, or device, or any suitable combination of the foregoing. More specific examples (a non-exhaustive list) of the computer readable storage medium can include the following: an electrical connection having one or more wires, a portable computer diskette, a hard disk, a random access memory (RAM), a read-only memory (ROM),an erasable programmable read-only memory (EPROM or Flash memory), an optical fiber, a portable compact disc read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the foregoing.
In the context of this document, a computer readable storage medium can be any tangible medium that can contain, or store a program for use by or in connection with an instruction execution system, apparatus, or device. A computer readable signal medium can include a propagated data signal with computer readable program code embodied therein, for example, in baseband or as part of a carrier wave. Computer-readable program code can be transmitted using any appropriate medium, including but not limited to wireless, wireline, optical fiber cable, RF, etc.
Computer program code for carrying out operations for aspects of the present invention can be written in any combination of one or more programming languages, including an object oriented programming language such as Java, Smalltalk, C++ or the like and conventional procedural programming languages, such as the “C” programming language or similar programming languages. The program code can execute entirely on the user's computer, partly on the user's computer, as a stand-alone software package, partly on the user's computer and partly on a remote computer or entirely on the remote computer or server. In the latter scenario, the remote computer can be connected to the user's computer through any type of network, including a local area network (LAN) or a wide area network (WAN), or the connection can be made to an external computer (for example, through the Internet using an Internet Service Provider).
In addition, each block of the flowchart illustrations and/or block diagrams of the present invention, and combinations of blocks in the flowchart illustrations and/or block diagrams, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general purpose computer, special purpose computer, or other programmable data processing apparatus to produce a machine, such that the instructions, which execute via the processor of the computer or other programmable data processing apparatus, create means for implementing the functions/acts specified in the flowchart and/or block diagram block or blocks.
These computer program instructions can also be stored in a computer readable medium that can direct a computer, other programmable data processing apparatus, or other devices to function in a particular manner, such that the instructions stored in the computer readable medium produce an article of manufacture including instruction means which implement the function/act specified in the flowchart and/or block diagram block or blocks.
The computer program instructions can also be loaded onto a computer, other programmable data processing apparatus, or other devices to cause a series of operational steps to be performed on the computer, other programmable apparatus or other devices to produce a computer implemented process such that the instructions which execute on the computer or other programmable apparatus provide processes for implementing the functions/acts specified in the flowchart and/or block diagram block or blocks.
The flowchart and block diagrams in the Figures illustrate the architecture, functionality, and operation of possible implementations of systems, methods and computer program products according to various embodiments of the present invention. In this regard, each block in the flowchart or block diagrams can represent a module, segment, or portion of code, which includes one or more executable instructions for implementing the specified logical function(s).
It should also be noted that, in some alternative implementations, the functions noted in the block can occur out of the order noted in the figures. For example, two blocks shown in succession can, in fact, be executed substantially concurrently, or the blocks can sometimes be executed in the reverse order, depending upon the functionality involved. It will also be noted that each block of the block diagrams and/or flowchart illustration, and combinations of blocks in the block diagrams and/or flowchart illustration, can be implemented by special purpose hardware-based systems that perform the specified functions or acts, or combinations of special purpose hardware and computer instructions.
Using the method or system of the present invention can save web application developers large amounts of time for amending program code related to subscribed and published events.
Number | Date | Country | Kind |
---|---|---|---|
201110337788.1 | Oct 2011 | CN | national |