|By David Bismut, Krishnakumar Pooloth, Swaminathan Natarajan||
|July 31, 2005 07:00 PM EDT||
Property files are frequently used in systems built using Java whether it's a thick Java client, a servlet, or a business component. Java specifies the format for a property file and provides the Properties class to read from and write to these files. However, Java is silent on the aspects related to validations of a value entered in a property file, providing room for errors to creep into an application system. How many times have you started to debug a failure in an application only to realize that it's because of an incorrect value in a property file?
The Properties Editor Framework detailed in this article was developed to solve the problem of managing application properties. It provides a convenient way to define a data type for each property and have a companion component in Swing to edit the property value. The framework can be used as a standalone tool or as part of a user interface.
One of the framework's design criteria was that it should work out of a property file, i.e., no other files or databases should be required for managing the property file. This is achieved by using certain meta-attributes to describe the characteristics of each property in the properties file. These meta-attributes are embedded along with each property in the property file as comments (Any line, in a property file, starting with '#' is considered a comment in Java).
In this article, we'll describe the framework's use, the concept of meta-attributes, and the default set of the attributes supported by the framework. And then, we'll explain the framework's design and how to extend it to support a new property data type.
Using the Property Editor Framework
The first step in using the Property Editor Framework is to decide on the Parameter type of each property in the properties file. Currently the framework supports the types listed in Table 1.
The next step is to modify the properties file and add the necessary meta-attributes for each property. Listing 1 shows a sample properties file with meta-attributes.
The final step is to set up the environment for the Property Editor Framework and invoke the Property Editor Dialog to start updating the property values. Figure 1 shows the properties as rendered in the Property editor Dialog.
The basic meta-attributes speci-fied by the framework for each property are Parameter Type, Editable, and Documentation. The Parameter Type represents the type of a property. It's used to render a suitable component for editing the property value. The table below lists the components rendered for the each of the possible values of PARAMETER TYPE.
The meta-attribute EDITABLE indicates whether the user can edit the value of a property. In the Property Editor Dialog, only properties that have a true value for EDITABLE meta-attribute are displayed. This lets the application developer make certain attributes in a property file not editable through the dialog.
The DOCUMENTATION meta-attribute specifies the text (which can be specified using HTML) that provides assistance to the end user while editing any particular property. In Figure 1, this documentation is displayed below the JTable con-taining the editable properties. As HTML tags are accepted, the <A> anchor tag can be used to provide a link to more comprehensive documentation.
Apart from the basic meta-attributes, there are two special meta-attributes. First one, GROUP NAME, is used to group related properties together. In the Property Editor Dialog, each property group is displayed in a separate tab. This could be used to group your attributes into, say, 'Basic' and 'Advanced.' Note that this parameter shouldn't be specified for each property separately. Once a GROUP NAME tag appears, all the parameters till the next GROUP NAME tag are grouped together. Another special meta-attribute is ALLOWED VALUES, which is used in conjunction with the SYMBOL parameter type. This lets you specify the list of valid choices for a SYMBOL property. These values should be separated by commas.
Now that we have a good idea about meta-attributes, let's walk through the steps in adding them to the Property File. Consider the following set of Properties.
Step 1: Decide the Grouping of the Properties
In the example the properties can be split into two groups based on their purpose, Logging and Database connection. Let's call these groups Logging and Database.
#GROUPNAME = Database
# GROUPNAME = Logging
Step 2: Decide on the Type for Each Property
In the example above, the types to be assigned to each property are shown in Table 3.
Step 3: Add Meta-Attributes to Each Property
The complete listing of this sample is available for download along with the source (see Listing 2).
Design of the Property Editor Framework
In this section, we will detail the design of the Properties Editor Framework. To reduce complexity, we'll break the discussion into: Creating the model of the Properties Editor component, creating the UI of the Properties Editor component, and the framework's persistence mechanism for the properties file.
Creating the Model
The classes involved in reading the properties file into memory and creating the data model are depicted in Figure 2.
The EditorFile class, which ex-tends the File class, is used as a thin wrapper for the Properties file. The EditorFile class provides the facility to add an Observer, which will be notified when changes are made to the property values.
The Parser class is a simple line parser that reads data from the EditorFile instance line-by-line and creates an in-memory model of the property file. It also defines the regular expression patterns to match the different meta-attributes supported by the framework. This class creates a new instance of Group class each time the meta-attribute '#GROUP NAME = <Group Name>' is encountered.
For each property key-value that falls under the same #GROUP NAME, an instance of one of the sub-classes of the Parameter class hierarchy is created. The exact sub-class is decided by the value of the meta-attribute #PARAMETER TYPE, which also keeps track of the value of meta-attribute EDITABLE that's used later by the view to decide whether to make it visible.
Creating the User Interface
The classes involved in rendering the user interface of the component are depicted Figure 3.
Referring to Figure 1, the visual area of the dialog is split between the Panel used to render the table of property key-value pairs and the JEditorPane showing the documentation text of different properties.
|Java Developer's Journal 07/31/05 06:42:09 PM EDT|
Enterprise Java - Properties Editor Framework
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...
Sep. 4, 2015 08:15 AM EDT Reads: 2,034
Consumer IoT applications provide data about the user that just doesn’t exist in traditional PC or mobile web applications. This rich data, or “context,” enables the highly personalized consumer experiences that characterize many consumer IoT apps. This same data is also providing brands with unprecedented insight into how their connected products are being used, while, at the same time, powering highly targeted engagement and marketing opportunities. In his session at @ThingsExpo, Nathan Treloar, President and COO of Bebaio, will explore examples of brands transforming their businesses by t...
Sep. 4, 2015 07:00 AM EDT Reads: 298
Through WebRTC, audio and video communications are being embedded more easily than ever into applications, helping carriers, enterprises and independent software vendors deliver greater functionality to their end users. With today’s business world increasingly focused on outcomes, users’ growing calls for ease of use, and businesses craving smarter, tighter integration, what’s the next step in delivering a richer, more immersive experience? That richer, more fully integrated experience comes about through a Communications Platform as a Service which allows for messaging, screen sharing, video...
Sep. 4, 2015 06:00 AM EDT Reads: 751
WebRTC has had a real tough three or four years, and so have those working with it. Only a few short years ago, the development world were excited about WebRTC and proclaiming how awesome it was. You might have played with the technology a couple of years ago, only to find the extra infrastructure requirements were painful to implement and poorly documented. This probably left a bitter taste in your mouth, especially when things went wrong.
Sep. 4, 2015 06:00 AM EDT Reads: 505
WebRTC services have already permeated corporate communications in the form of videoconferencing solutions. However, WebRTC has the potential of going beyond and catalyzing a new class of services providing more than calls with capabilities such as mass-scale real-time media broadcasting, enriched and augmented video, person-to-machine and machine-to-machine communications. In his session at @ThingsExpo, Luis Lopez, CEO of Kurento, will introduce the technologies required for implementing these ideas and some early experiments performed in the Kurento open source software community in areas ...
Sep. 4, 2015 05:00 AM EDT Reads: 128
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!
Sep. 4, 2015 04:30 AM EDT Reads: 1,705
In his session at @ThingsExpo, Lee Williams, a producer of the first smartphones and tablets, will talk about how he is now applying his experience in mobile technology to the design and development of the next generation of Environmental and Sustainability Services at ETwater. He will explain how M2M controllers work through wirelessly connected remote controls; and specifically delve into a retrofit option that reverse-engineers control codes of existing conventional controller systems so they don't have to be replaced and are instantly converted to become smart, connected devices.
Sep. 4, 2015 02:00 AM EDT Reads: 270
The 3rd International WebRTC Summit, to be held Nov. 4–6, 2014, at the Santa Clara Convention Center in Santa Clara, CA, announces that its Call for Papers is now open. Topics include all aspects of improving IT delivery by eliminating waste through automated business models leveraging cloud technologies. WebRTC Summit is co-located with 15th International Cloud Expo, 6th International Big Data Expo, 3rd International DevOps Summit and 2nd Internet of @ThingsExpo. WebRTC (Web-based Real-Time Communication) is an open source project supported by Google, Mozilla and Opera that aims to enable bro...
Sep. 4, 2015 01:15 AM EDT Reads: 1,630
SYS-CON Events announced today that Pythian, a global IT services company specializing in helping companies leverage disruptive technologies to optimize revenue-generating systems, has been named “Bronze Sponsor” of SYS-CON's 17th Cloud Expo, which will take place on November 3–5, 2015, at the Santa Clara Convention Center in Santa Clara, CA. Founded in 1997, Pythian is a global IT services company that helps companies compete by adopting disruptive technologies such as cloud, Big Data, advanced analytics, and DevOps to advance innovation and increase agility. Specializing in designing, imple...
Sep. 4, 2015 12:00 AM EDT Reads: 385
Containers are not new, but renewed commitments to performance, flexibility, and agility have propelled them to the top of the agenda today. By working without the need for virtualization and its overhead, containers are seen as the perfect way to deploy apps and services across multiple clouds. Containers can handle anything from file types to operating systems and services, including microservices. What are microservices? Unlike what the name implies, microservices are not necessarily small, but are focused on specific tasks. The ability for developers to deploy multiple containers – thous...
Sep. 3, 2015 10:00 PM EDT Reads: 200
SYS-CON Events announced today that IceWarp will exhibit at the 17th International Cloud Expo®, which will take place on November 3–5, 2015, at the Santa Clara Convention Center in Santa Clara, CA. IceWarp, the leader of cloud and on-premise messaging, delivers secured email, chat, documents, conferencing and collaboration to today's mobile workforce, all in one unified interface
Sep. 3, 2015 10:00 PM EDT Reads: 492
All major researchers estimate there will be tens of billions devices - computers, smartphones, tablets, and sensors - connected to the Internet by 2020. This number will continue to grow at a rapid pace for the next several decades. With major technology companies and startups seriously embracing IoT strategies, now is the perfect time to attend @ThingsExpo, November 3-5, 2015, at the Santa Clara Convention Center in Santa Clara, CA. Learn what is going on, contribute to the discussions, and ensure that your enterprise is as "IoT-Ready" as it can be.
Sep. 3, 2015 08:30 PM EDT Reads: 178
Too often with compelling new technologies market participants become overly enamored with that attractiveness of the technology and neglect underlying business drivers. This tendency, what some call the “newest shiny object syndrome,” is understandable given that virtually all of us are heavily engaged in technology. But it is also mistaken. Without concrete business cases driving its deployment, IoT, like many other technologies before it, will fade into obscurity.
Sep. 3, 2015 04:30 PM EDT Reads: 436
As more and more data is generated from a variety of connected devices, the need to get insights from this data and predict future behavior and trends is increasingly essential for businesses. Real-time stream processing is needed in a variety of different industries such as Manufacturing, Oil and Gas, Automobile, Finance, Online Retail, Smart Grids, and Healthcare. Azure Stream Analytics is a fully managed distributed stream computation service that provides low latency, scalable processing of streaming data in the cloud with an enterprise grade SLA. It features built-in integration with Azur...
Sep. 3, 2015 02:45 PM EDT Reads: 392
SYS-CON Events announced today that HPM Networks will exhibit at the 17th International Cloud Expo®, which will take place on November 3–5, 2015, at the Santa Clara Convention Center in Santa Clara, CA. For 20 years, HPM Networks has been integrating technology solutions that solve complex business challenges. HPM Networks has designed solutions for both SMB and enterprise customers throughout the San Francisco Bay Area.
Sep. 3, 2015 02:30 PM EDT Reads: 968
With the proliferation of connected devices underpinning new Internet of Things systems, Brandon Schulz, Director of Luxoft IoT – Retail, will be looking at the transformation of the retail customer experience in brick and mortar stores in his session at @ThingsExpo. Questions he will address include: Will beacons drop to the wayside like QR codes, or be a proximity-based profit driver? How will the customer experience change in stores of all types when everything can be instrumented and analyzed? As an area of investment, how might a retail company move towards an innovation methodolo...
Sep. 3, 2015 02:30 PM EDT Reads: 519
SYS-CON Events announced today the Containers & Microservices Bootcamp, being held November 3-4, 2015, in conjunction with 17th Cloud Expo, @ThingsExpo, and @DevOpsSummit at the Santa Clara Convention Center in Santa Clara, CA. This is your chance to get started with the latest technology in the industry. Combined with real-world scenarios and use cases, the Containers and Microservices Bootcamp, led by Janakiram MSV, a Microsoft Regional Director, will include presentations as well as hands-on demos and comprehensive walkthroughs.
Sep. 3, 2015 02:15 PM EDT Reads: 417
Contrary to mainstream media attention, the multiple possibilities of how consumer IoT will transform our everyday lives aren’t the only angle of this headline-gaining trend. There’s a huge opportunity for “industrial IoT” and “Smart Cities” to impact the world in the same capacity – especially during critical situations. For example, a community water dam that needs to release water can leverage embedded critical communications logic to alert the appropriate individuals, on the right device, as soon as they are needed to take action.
Sep. 3, 2015 01:30 PM EDT
With the Apple Watch making its way onto wrists all over the world, it’s only a matter of time before it becomes a staple in the workplace. In fact, Forrester reported that 68 percent of technology and business decision-makers characterize wearables as a top priority for 2015. Recognizing their business value early on, FinancialForce.com was the first to bring ERP to wearables, helping streamline communication across front and back office functions. In his session at @ThingsExpo, Kevin Roberts, GM of Platform at FinancialForce.com, will discuss the value of business applications on wearable ...
Sep. 3, 2015 10:45 AM EDT
SYS-CON Events announced today that Micron Technology, Inc., a global leader in advanced semiconductor systems, will exhibit at the 17th International Cloud Expo®, which will take place on November 3–5, 2015, at the Santa Clara Convention Center in Santa Clara, CA. Micron’s broad portfolio of high-performance memory technologies – including DRAM, NAND and NOR Flash – is the basis for solid state drives, modules, multichip packages and other system solutions. Backed by more than 35 years of technology leadership, Micron's memory solutions enable the world's most innovative computing, consumer,...
Sep. 3, 2015 10:00 AM EDT Reads: 287