Java IoT Authors: Elizabeth White, Pat Romanski, Zakia Bouachraoui, William Schmarzo, Yeshim Deniz

Related Topics: Java IoT

Java IoT: Article

Enterprise Java - Properties Editor Framework

Solving the problem of managing application properties

The PropertyEditorDialog class is responsible for a big part of the work involved in creating the user interface for the component. As the name suggests, it extends JDialog; it also implements the Observer and ListSelectionListener interfaces. The Observer interface is implemented to change the title of the dialog when any of the property value is changed.

The PropertyEditorDialog obtains the number of groups of property key-values in the EditorFile and creates an equal number of JTables to render them. These JTables are, in turn, put in a JTabbedPane, one tab for each group, the tab's title corresponding to the group name. The PropertyEditorDialog attaches itself as the ListSelectionListeners for all the Jtables. The PropertyEditorDialog gets the description text for the property on the valueChanged event and displays it on the description JEdtiorPane.

Finally, let's look at the rendering and editing mechanisms for the Property Key-Value pairs.

The toVisual method of the Group creates the EditorTable and the TableModel for the EditorTable. The EditorTable, in turn, creates and sets an instance of the EditorTableCellRenderer as the cell renderer and an instance of the EditorTableCellEditor as the cell editor for the columns of the Editor-Table.

The EditorTableCellRenderer and EditorTableCellEditor create the controls necessary to render and edit the property values. The different controls for each Property type are listed in Table 4.

EditorTableCellEditor adds an anonymous inner class to each control overriding the functionality for updating the controls to include actions to set the new value back to the model and invalidate the model.

Persisting the Properties
Writing the Property key-values back to the Properties File is pretty straightforward. A BufferedWriter is created with the instance of EditorFile as the FileWriter. The Parameters are written group-by-group into this file. Concatenating the text form of each instance of the Parameter hierarchy creates each group.

Extending the Framework To Add New Type and Controls
Now we'll discuss adding a new type for a property and the corresponding control to edit the property's value. Say your application uses JDBC to connect to a database and you want to give the user the ability to specify the JDBC driver to use via a property. The framework, by default, doesn't support the required type, which lets you choose a valid driver from a list. We'll see how to extend the framework to add this new type.

To display all the JDBC drivers we could use a dropdown list with all the JDBC drivers in the classpath. Let's name the new parameter type JDBCDRIVER.

For the new type, we'd need to define a new class on the model side, say, ParameterJDBCDriver, which is a sub-class of the ParameterSymbol class. The new class needs to implement the method "toText" that should return the driver's fully qualified class name. The following code snippet does just that:

public class ParameterJDBCDriver extends ParameterSymbol {
String strBaseClassName;
public ParameterJDBCDriver(String name, String value, String baseClassName,
boolean editable, String doc) {
Driver[] driversInClasspath = ClassUtils.findAllDriversInClasspath(baseClassName);
type = "JDBCDRIVER";
public String toText(){
String newLine = System.getProperty("line.separator");
return toTextType() + newLine + toTextValue();

Now we need to add the following code to the createParameter method of the Parser class. It creates an instance of ParameterJDBCDriver when the Parameter type "JDBC-DRIVER" is encountered in the properties file.

if (pType.compareToIgnoreCase("JDBCDRIVER") == 0) {
p = new ParameterJDBCDriver(pName, pValue, pBaseClass,pEdit, pDoc);

This completes the changes needed on the model. On the view front, since we have decided to show the values in a drop down list, we can reuse the combo box control used to display values of type Symbol/Boolean. But we have to make changes in a couple of classes to ensure that the dropdown list is correctly rendered for the new Property type.

The following code needs to be added to the createComponent method of the EditorTableCellRenderer class. It will render the FormattedComboBox control for the new Property type.

else if (cellValue instanceof ParameterJDBCDriver) {
o = new FormattedComboBox(cellValue,
((ParameterJDBCDriver) cellValue).getAllowedValues(),
value.toString()) {
public void itemStateChanged(ItemEvent e) {


Now we need to add the following code to the createComponent method of EditorTableCellEditor class to ensure that editing changes are reflected correctly.

else if (cellValue instanceof ParameterJDBCDriver) {
o = new FormattedComboBox(cellValue, ((ParameterJDBCDriver)
cellValue).getAllowedValues(), value.toString()) {
public void itemStateChanged(ItemEvent e) {
((ParameterJDBCDriver) cellValue).setValue(getSelectedItem().toString());

The last step is to compile all the changes and we're good to go! You can fire up the PropertyEditor Dialog and verify that it works.

More Stories By David Bismut

David Bismut is a third-year student at the Ecole des Mines in Nantes (EMN), a French engineering school. He specializes in information management technologies. He was part of InStep, Infosys's global internship program in 2004.

More Stories By Krishnakumar Pooloth

Krishnakumar Pooloth is a senior technical architect with Infosys Technologies. His areas of expertise include object design, component technology, Java, and expert systems. He holds a Bachelor's degree in electronics and communication from Calicut University, India.

More Stories By Swaminathan Natarajan

Swaminathan Natarajan is a technical architect with Infosys Technologies. His area of expertise is Java, repository technologies, and metadata management.

Comments (1)

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.

IoT & Smart Cities Stories
Atmosera delivers modern cloud services that maximize the advantages of cloud-based infrastructures. Offering private, hybrid, and public cloud solutions, Atmosera works closely with customers to engineer, deploy, and operate cloud architectures with advanced services that deliver strategic business outcomes. Atmosera's expertise simplifies the process of cloud transformation and our 20+ years of experience managing complex IT environments provides our customers with the confidence and trust tha...
With the introduction of IoT and Smart Living in every aspect of our lives, one question has become relevant: What are the security implications? To answer this, first we have to look and explore the security models of the technologies that IoT is founded upon. In his session at @ThingsExpo, Nevi Kaja, a Research Engineer at Ford Motor Company, discussed some of the security challenges of the IoT infrastructure and related how these aspects impact Smart Living. The material was delivered interac...
Intel is an American multinational corporation and technology company headquartered in Santa Clara, California, in the Silicon Valley. It is the world's second largest and second highest valued semiconductor chip maker based on revenue after being overtaken by Samsung, and is the inventor of the x86 series of microprocessors, the processors found in most personal computers (PCs). Intel supplies processors for computer system manufacturers such as Apple, Lenovo, HP, and Dell. Intel also manufactu...
Darktrace is the world's leading AI company for cyber security. Created by mathematicians from the University of Cambridge, Darktrace's Enterprise Immune System is the first non-consumer application of machine learning to work at scale, across all network types, from physical, virtualized, and cloud, through to IoT and industrial control systems. Installed as a self-configuring cyber defense platform, Darktrace continuously learns what is ‘normal' for all devices and users, updating its understa...
At CloudEXPO Silicon Valley, June 24-26, 2019, Digital Transformation (DX) is a major focus with expanded DevOpsSUMMIT and FinTechEXPO programs within the DXWorldEXPO agenda. Successful transformation requires a laser focus on being data-driven and on using all the tools available that enable transformation if they plan to survive over the long term. A total of 88% of Fortune 500 companies from a generation ago are now out of business. Only 12% still survive. Similar percentages are found throug...
OpsRamp is an enterprise IT operation platform provided by US-based OpsRamp, Inc. It provides SaaS services through support for increasingly complex cloud and hybrid computing environments from system operation to service management. The OpsRamp platform is a SaaS-based, multi-tenant solution that enables enterprise IT organizations and cloud service providers like JBS the flexibility and control they need to manage and monitor today's hybrid, multi-cloud infrastructure, applications, and wor...
Apptio fuels digital business transformation. Technology leaders use Apptio's machine learning to analyze and plan their technology spend so they can invest in products that increase the speed of business and deliver innovation. With Apptio, they translate raw costs, utilization, and billing data into business-centric views that help their organization optimize spending, plan strategically, and drive digital strategy that funds growth of the business. Technology leaders can gather instant recomm...
The Master of Science in Artificial Intelligence (MSAI) provides a comprehensive framework of theory and practice in the emerging field of AI. The program delivers the foundational knowledge needed to explore both key contextual areas and complex technical applications of AI systems. Curriculum incorporates elements of data science, robotics, and machine learning-enabling you to pursue a holistic and interdisciplinary course of study while preparing for a position in AI research, operations, ...
Codete accelerates their clients growth through technological expertise and experience. Codite team works with organizations to meet the challenges that digitalization presents. Their clients include digital start-ups as well as established enterprises in the IT industry. To stay competitive in a highly innovative IT industry, strong R&D departments and bold spin-off initiatives is a must. Codete Data Science and Software Architects teams help corporate clients to stay up to date with the mod...
In his session at 21st Cloud Expo, Raju Shreewastava, founder of Big Data Trunk, provided a fun and simple way to introduce Machine Leaning to anyone and everyone. He solved a machine learning problem and demonstrated an easy way to be able to do machine learning without even coding. Raju Shreewastava is the founder of Big Data Trunk (www.BigDataTrunk.com), a Big Data Training and consulting firm with offices in the United States. He previously led the data warehouse/business intelligence and Bi...