Swingweb
Swingweb是一个web框架,它能够在一个Web容器中操作AWT/Swing应用程序并把它作为一个纯HTML/CSS/javascript的Web应用程序呈现给浏览器.
Swingweb is a web-application framework that enables AWT/Swing application to operate inside a web container and presented as a web application to the web browser, purely in HTML/CSS/javascript. The swing application will render and behave in the web-container the same as it would as a desktop application. There is little knowledge required for the developer to start developing swingweb application as long as they are familiar with swing UI development.
The main goals of the Swingweb framework are to:
- Enable true component-based web-application development platform
Swingweb allows the developer to specify the web-application in terms of UI components and their interactions. The functionality of the web-application is more formally defined as opposed to page-centric model where functionality is composed by gluing the webpages loosely together. Furthermore, the application functionality is more predictable and guaranteed to work as long as all UI components are unit-tested. There will be no more page-management and http session-state manipulation hassle. Once written, the component, either fine-grain like a text-box, or coarse-grain like calendar, will be reusable and save development costs over time.
- Use swing UI model for web application development
Swing component model is one of the best and most-practiced UI model for java platform. There should be no learning curve for most Java developer to pick up web-application development using swingweb. Swingweb tries to make distinction between desktop and web application development as transparent as it could be yet at the same time maintains flexibility on the controls of the look and feel of the web-application through UI component template system.
- Allow rapid development using existing GUI editors for web application development
There are a lot of good tools for swing application development. Most java IDEs (including eclipse) also contain GUI editors. The editors allow the developer to rapidly develop, maintain and change the application in response to changed requirement.
- Save development cost by merging the development process of swing desktop application and (e.g. in-house) web application
Given the right architecture, the desktop and web application development can be merged into a single process and thus reduces development cost.
Some of the features of Swingweb include the following:
- Support web-environment with multiple concurrent application sessions
While most desktop applications are designed to run in a stand-alone jvm, swingweb extended the AWT toolkit implementation so that multiple concurrent application sessions can run in the web container jvm, yet making each application session isolated so that the running applications will not interfere with each other's operations.
- Component-oriented architecture that allows developers to enable existing swing component to web environment easily
Swingweb underlying framework allows developer to control how the interaction and event-input of each component individually. Thus it is very easy to extend an existing swing component (e.g. some third-party widget) so that it can operate in web environment.
- Flexible template-based approach allowing changing look/functionality of component/application
The rendering of the each swing components is provided through a template file that is written in jxp template language (essentially java language). Thus it is very easy to control the look and feel of a component as web widget. Furthermore, the template can be configured per component type or per instance.
- Transparent URL manipulation and session management inside swingweb application
Swingweb support url manipulation so the developer can customize how the browser url changes as the interface changes. The application can also access and react to url changes using very simple API. This allow implementation of webapplication that allows bookmarking, back-button and other advanced features such as component caching and sharing. There is also API for per session variables.
- Light-weight, performance focus, and scalable for high traffic web-applications
The (awt)toolkit implementation utilizes several techniques including lightweight peers, threadless event queue, custom repaint manager to reduce memory footprint and increase the performance of the swing application in the web context. There is also a special deployment mode, share-app mode, which allows sharing of component instances across the application sessions for scalability.
- Natural adaptation of components to the web Some adaptation has been made to the components for the web development - e.g. - FileDialog will upload local files to webserver, all button icons will be buffered and rendered property as <img src=""> tag, all components that uses Graphics2D can be rendered nicely as image (with a flag set of the component) etc.