Click here to close now.

Welcome!

Java Authors: Pat Romanski, Elizabeth White, Carmen Gonzalez, Liz McMillan, Yeshim Deniz

Related Topics: Java

Java: Article

Extending Rich GUI Clients with Jython

Implementing a solution

Allowing extensibility of a rich Java GUI is a daunting task. Each user may require slightly different functionality - this one wants to be able to import data from an Excel spreadsheet, and another wants to generate custom XML reports of particular artifacts in the application. You want to make every user happy, but you very rapidly see yourself with multiple code branches trying to satisfy those custom requirements - every Java developer's configuration management nightmare.

Not only is it undesirable to dirty the code base with customer-specific functionality, but you don't want to derail the core development team with continual disruptions for customer requests for simple enhancements to the GUI; it would be much more effective for the customer to be able to add all the functionality that is needed.

At Unicorn Solutions (www.unicorn.com), we developed a Scripting Extension Framework, developed in Jython and XML, that allows non-Java developers to easily enhance our out-of-the-box Swing-based application with custom, rich GUI features. This has greatly increased the extensibility of the Unicorn System, our platform for enterprise metadata management and semantic enterprise information management.

This article is aimed at both developers who are struggling with the task of multiple requests to customize their rich Java client for different customers, and developers who have an interest in Jython and examples of how it integrates with Java applications. It covers the requirements for the framework, and details the design and implementation of the Scripting Extension Framework with sample code. It covers both the usage of XML descriptors for extensions as well as how to call the Jython Interpreter from Java. It will give the target audience in-depth knowledge on how to implement a similar solution in any similar application.

Introduction - Flexing the Inflexible Application Release day has finally arrived - the full-featured Swing application that you've been developing for the past two years is finally going out to the customers on time. The problems start when each customer wants slightly different enhancements, most of which you'd rather not incorporate into the main product. The type of features that a customer might want could range from a simple "Find and Replace" feature, to any of the following customer-specific features (see Figure 1):

  • Batch loading of data from external legacy sources (flat file, Excel)
  • Verification procedures on custom data
  • Wizards for automating custom tasks
  • Generation of reports in different file formats (CSV, XML, or Excel)
  • Automated processes to update data
If this isn't bad enough as it is, it has become apparent that the customer is not going to stop with those requests but will continue to bombard you with enhancement and utility-feature requests for the long-term future.

The traditional ways of addressing such requirements range from releasing a different version of the product for each customer to providing code-hooks that the customer can code against to add the required functionality.

Releasing a different version of the product to each customer is a Configuration Manager's biggest nightmare - the task of maintaining multiple branches of the same release, together with tracking which features are in which version, is an error-prone process that is very expensive on resources. Not only that, but the amount of R&D development time to work on non-generic customer enhancements can be a big drain on resources, both in development and testing.

Providing code-hooks are generally very limiting in the breadth of functionality that can be exposed, and, generally, most custom enhancements can't be fully implemented in this framework.

Making the Application Flexible
Before getting down to making your rich GUI application flexible, we need to understand what it means to be flexible and what we'd like to see from the framework that provides this flexibility.

  1. Low levels of programming skills to develop extensions. Already at Unicorn, there are several customers writing their own extensions with minimal support required from R&D.
  2. The extensions should be developed in an easy-to-learn scripting language that integrates well with the main product.
  3. Customer should be able to create simple GUI dialogs for their enhancements that control user-input, display reports visually, etc.
  4. Seamless integration with core product features. It should not be obvious to users of the customized application which features are part of the core product and which have been developed as custom enhancements.
  5. Ease of deployment - it should be easy for developers of the custom features to deploy these features to the core product. Complicated build processes should be totally avoided.
  6. Customer extensions should be guaranteed to be compatible with future versions of the core product.
The Scripting Framework
In order to answer the above list of requirements to create a flexible rich GUI, at Unicorn we developed a full-fledged scripting framework, allowing in-house developers at customer sites to to create all the extensions that were required. The Scripting Framework consists of a controller that connects all deployed extensions to the application at runtime. Each extension consists of a descriptor, written in XML, that contains relevant information about the extension; for example, display name, input parameters, and a pointer to the script that contains the execution logic of the script.

The Scripting Framework is needed to adopt a programming language. It was decided to use a language that could tightly interact with Java programs, and there were obvious advantages to an interpreted language for ease of development of scripts. This naturally led to the choice of Jython as the language for the Scripting Framework.

Jython
Jython is an implementation of the high-level, dynamic, object-oriented language Python written in 100% Pure Java, and seamlessly integrated with the Java platform. It thus allows you to run Python on any Java platform. In addition to allowing the use of regular Python syntax, it is also possible to create Java objects and call methods on them within a regular Python expression.

Jython is freely available for both commercial and non-commercial use and is distributed with source code. Jython is complementary to Java and is especially suited for the following tasks:

  • Embedded scripting: Java programmers can add the Jython libraries to their system to allow end users to write simple or complicated scripts that add functionality to the application.
  • Rapid application development: Jython programs are typically 2-10X shorter than the equivalent Java program. This translates directly to increased programmer productivity. The seamless interaction between Python and Java allows developers to freely mix the two languages both during development and in shipping products.
  • Dynamic compilation to Java byte codes: Leads to the highest possible performance without sacrificing interactivity.
  • Ability to extend existing Java classes in Jython: Allows the effective use of abstract classes.
The Python language combines remarkable power with very clear syntax. It also supports a full object-oriented programming model, making it a natural fit for Java's OO design.

Let's look at the steps needed to develop an extension, and how extensions are loaded and executed.

Extension Descriptor
The extension descriptor contains instructions on how the executable script should be bound to the application at runtime. The descriptor contains the following information:

  • Display name of the extension.
  • Informal description of the extension.
  • Optional hotkey for the convenient quick launch of the extension.
  • Menu/Toolbar location information - the extension developer can decide where the extension will appear in menus/toobars.
  • Instructions for displaying a rich GUI input dialog - this will typically hold a list of parameters, each describing a single piece of input that the user of the extension can enter at runtime, which will subsequently be passed to the script. Each parameter holds the following information:
    - Internal identifier for input parameter
    - Display name of parameter
    - Type of parameter. This can be simple types such as string, password, number, boolean, string list, or this could also be application-specific objects like Employee, Address, or Company.
  • A pointer to the location of the Jython script to be executed.
It's clear that each extension descriptor contains all of the instructions required for extending the application with the extension, including providing the user with a high-usability user interface for accessing the extension.

We chose XML as the file format for the extension descriptor for several reasons. XML is a popular format for expressing information in a structured manner - parsers and validation tools are readily available. Also, by choosing XML, we are able to validate all descriptors against the XML Schema, which allows for catching badly structured descriptors at an early stage. By publishing the XML Schemas to extension developers, we are also providing the developers with a very handy tool to help create syntactically correct descriptors.

More Stories By Hayden Marchant

Hayden Marchant is a Software Engineer in the Information Integration Solutions group at IBM. He has 10 years of experience in software engineering. Hayden has a 1st class honors BA in mathematics from Cambridge University, England, and is a Sun Certified Programmer.

Comments (2) View Comments

Share your thoughts on this story.

Add your comment
You must be signed in to add a comment. Sign-in | Register

In accordance with our Comment Policy, we encourage comments that are on topic, relevant and to-the-point. We will remove comments that include profanity, personal attacks, racial slurs, threats of violence, or other inappropriate material that violates our Terms and Conditions, and will block users who make repeated violations. We ask all readers to expect diversity of opinion and to treat one another with dignity and respect.


Most Recent Comments
demo 01/22/06 03:24:44 PM EST

Where the source??

SYS-CON Belgium News Desk 01/15/06 02:13:56 PM EST

Allowing extensibility of a rich Java GUI is a daunting task. Each user may require slightly different functionality - this one wants to be able to import data from an Excel spreadsheet, and another wants to generate custom XML reports of particular artifacts in the application. You want to make every user happy, but you very rapidly see yourself with multiple code branches trying to satisfy those custom requirements - every Java developer's configuration management nightmare.

@ThingsExpo Stories
The worldwide cellular network will be the backbone of the future IoT, and the telecom industry is clamoring to get on board as more than just a data pipe. In his session at @ThingsExpo, Evan McGee, CTO of Ring Plus, Inc., discussed what service operators can offer that would benefit IoT entrepreneurs, inventors, and consumers. Evan McGee is the CTO of RingPlus, a leading innovative U.S. MVNO and wireless enabler. His focus is on combining web technologies with traditional telecom to create a new breed of unified communication that is easily accessible to the general consumer. With over a de...
Disruptive macro trends in technology are impacting and dramatically changing the "art of the possible" relative to supply chain management practices through the innovative use of IoT, cloud, machine learning and Big Data to enable connected ecosystems of engagement. Enterprise informatics can now move beyond point solutions that merely monitor the past and implement integrated enterprise fabrics that enable end-to-end supply chain visibility to improve customer service delivery and optimize supplier management. Learn about enterprise architecture strategies for designing connected systems tha...
Cloud is not a commodity. And no matter what you call it, computing doesn’t come out of the sky. It comes from physical hardware inside brick and mortar facilities connected by hundreds of miles of networking cable. And no two clouds are built the same way. SoftLayer gives you the highest performing cloud infrastructure available. One platform that takes data centers around the world that are full of the widest range of cloud computing options, and then integrates and automates everything. Join SoftLayer on June 9 at 16th Cloud Expo to learn about IBM Cloud's SoftLayer platform, explore se...
SYS-CON Media announced today that 9 out of 10 " most read" DevOps articles are published by @DevOpsSummit Blog. Launched in October 2014, @DevOpsSummit Blog offers top articles, news stories, and blog posts from the world's well-known experts and guarantees better exposure for its authors than any other publication. The widespread success of cloud computing is driving the DevOps revolution in enterprise IT. Now as never before, development teams must communicate and collaborate in a dynamic, 24/7/365 environment. There is no time to wait for long development cycles that produce softw...
15th Cloud Expo, which took place Nov. 4-6, 2014, at the Santa Clara Convention Center in Santa Clara, CA, expanded the conference content of @ThingsExpo, Big Data Expo, and DevOps Summit to include two developer events. IBM held a Bluemix Developer Playground on November 5 and ElasticBox held a Hackathon on November 6. Both events took place on the expo floor. The Bluemix Developer Playground, for developers of all levels, highlighted the ease of use of Bluemix, its services and functionality and provide short-term introductory projects that developers can complete between sessions.
From telemedicine to smart cars, digital homes and industrial monitoring, the explosive growth of IoT has created exciting new business opportunities for real time calls and messaging. In his session at @ThingsExpo, Ivelin Ivanov, CEO and Co-Founder of Telestax, shared some of the new revenue sources that IoT created for Restcomm – the open source telephony platform from Telestax. Ivelin Ivanov is a technology entrepreneur who founded Mobicents, an Open Source VoIP Platform, to help create, deploy, and manage applications integrating voice, video and data. He is the co-founder of TeleStax, a...
The Internet of Things (IoT) promises to evolve the way the world does business; however, understanding how to apply it to your company can be a mystery. Most people struggle with understanding the potential business uses or tend to get caught up in the technology, resulting in solutions that fail to meet even minimum business goals. In his session at @ThingsExpo, Jesse Shiah, CEO / President / Co-Founder of AgilePoint Inc., showed what is needed to leverage the IoT to transform your business. He discussed opportunities and challenges ahead for the IoT from a market and technical point of vie...
With major technology companies and startups seriously embracing IoT strategies, now is the perfect time to attend @ThingsExpo in Silicon Valley. Learn what is going on, contribute to the discussions, and ensure that your enterprise is as "IoT-Ready" as it can be! Internet of @ThingsExpo, taking place Nov 3-5, 2015, at the Santa Clara Convention Center in Santa Clara, CA, is co-located with 17th Cloud Expo and will feature technical sessions from a rock star conference faculty and the leading industry players in the world. The Internet of Things (IoT) is the most profound change in personal an...
The 3rd International @ThingsExpo, co-located with the 16th International Cloud Expo – to be held June 9-11, 2015, at the Javits Center in New York City, NY – is now accepting Hackathon proposals. Hackathon sponsorship benefits include general brand exposure and increasing engagement with the developer ecosystem. At Cloud Expo 2014 Silicon Valley, IBM held the Bluemix Developer Playground on November 5 and ElasticBox held the DevOps Hackathon on November 6. Both events took place on the expo floor. The Bluemix Developer Playground, for developers of all levels, highlighted the ease of use of...
Grow your business with enterprise wearable apps using SAP Platforms and Google Glass. SAP and Google just launched the SAP and Google Glass Challenge, an opportunity for you to innovate and develop the best Enterprise Wearable App using SAP Platforms and Google Glass and gain valuable market exposure. In his session at @ThingsExpo, Brian McPhail, Senior Director of Business Development, ISVs & Digital Commerce at SAP, outlined the timeline of the SAP Google Glass Challenge and the opportunity for developers, start-ups, and companies of all sizes to engage with SAP today.
Enthusiasm for the Internet of Things has reached an all-time high. In 2013 alone, venture capitalists spent more than $1 billion dollars investing in the IoT space. With "smart" appliances and devices, IoT covers wearable smart devices, cloud services to hardware companies. Nest, a Google company, detects temperatures inside homes and automatically adjusts it by tracking its user's habit. These technologies are quickly developing and with it come challenges such as bridging infrastructure gaps, abiding by privacy concerns and making the concept a reality. These challenges can't be addressed w...
The industrial software market has treated data with the mentality of “collect everything now, worry about how to use it later.” We now find ourselves buried in data, with the pervasive connectivity of the (Industrial) Internet of Things only piling on more numbers. There’s too much data and not enough information. In his session at @ThingsExpo, Bob Gates, Global Marketing Director, GE’s Intelligent Platforms business, to discuss how realizing the power of IoT, software developers are now focused on understanding how industrial data can create intelligence for industrial operations. Imagine ...
SYS-CON Events announced today that Liaison Technologies, a leading provider of data management and integration cloud services and solutions, has been named "Silver Sponsor" of SYS-CON's 16th International Cloud Expo®, which will take place on June 9-11, 2015, at the Javits Center in New York, NY. Liaison Technologies is a recognized market leader in providing cloud-enabled data integration and data management solutions to break down complex information barriers, enabling enterprises to make smarter decisions, faster.
The 17th International Cloud Expo has announced that its Call for Papers is open. 17th International Cloud Expo, to be held November 3-5, 2015, at the Santa Clara Convention Center in Santa Clara, CA, brings together Cloud Computing, APM, APIs, Microservices, Security, Big Data, Internet of Things, DevOps and WebRTC to one location. With cloud computing driving a higher percentage of enterprise IT budgets every year, it becomes increasingly important to plant your flag in this fast-expanding business opportunity. Submit your speaking proposal today!
Hadoop as a Service (as offered by handful of niche vendors now) is a cloud computing solution that makes medium and large-scale data processing accessible, easy, fast and inexpensive. In his session at Big Data Expo, Kumar Ramamurthy, Vice President and Chief Technologist, EIM & Big Data, at Virtusa, will discuss how this is achieved by eliminating the operational challenges of running Hadoop, so one can focus on business growth. The fragmented Hadoop distribution world and various PaaS solutions that provide a Hadoop flavor either make choices for customers very flexible in the name of opti...
Cultural, regulatory, environmental, political and economic (CREPE) conditions over the past decade are creating cross-industry solution spaces that require processes and technologies from both the Internet of Things (IoT), and Data Management and Analytics (DMA). These solution spaces are evolving into Sensor Analytics Ecosystems (SAE) that represent significant new opportunities for organizations of all types. Public Utilities throughout the world, providing electricity, natural gas and water, are pursuing SmartGrid initiatives that represent one of the more mature examples of SAE. We have s...
The Internet of Things will put IT to its ultimate test by creating infinite new opportunities to digitize products and services, generate and analyze new data to improve customer satisfaction, and discover new ways to gain a competitive advantage across nearly every industry. In order to help corporate business units to capitalize on the rapidly evolving IoT opportunities, IT must stand up to a new set of challenges. In his session at @ThingsExpo, Jeff Kaplan, Managing Director of THINKstrategies, will examine why IT must finally fulfill its role in support of its SBUs or face a new round of...
The 4th International Internet of @ThingsExpo, co-located with the 17th International Cloud Expo - to be held November 3-5, 2015, at the Santa Clara Convention Center in Santa Clara, CA - announces that its Call for Papers is open. The Internet of Things (IoT) is the biggest idea since the creation of the Worldwide Web more than 20 years ago.
Wearable devices have come of age. The primary applications of wearables so far have been "the Quantified Self" or the tracking of one's fitness and health status. We propose the evolution of wearables into social and emotional communication devices. Our BE(tm) sensor uses light to visualize the skin conductance response. Our sensors are very inexpensive and can be massively distributed to audiences or groups of any size, in order to gauge reactions to performances, video, or any kind of presentation. In her session at @ThingsExpo, Jocelyn Scheirer, CEO & Founder of Bionolux, will discuss ho...
The true value of the Internet of Things (IoT) lies not just in the data, but through the services that protect the data, perform the analysis and present findings in a usable way. With many IoT elements rooted in traditional IT components, Big Data and IoT isn’t just a play for enterprise. In fact, the IoT presents SMBs with the prospect of launching entirely new activities and exploring innovative areas. CompTIA research identifies several areas where IoT is expected to have the greatest impact.