Comments
Richard Davies wrote: The UK has a good crop of technology pioneers in cloud computing - for example ElasticHosts, FlexiScale, Flexiant, OnApp - and also some strong government initiatives such as G-Cloud. We will have to see whether this kind of technical leadership converts into swift mass-market adoption or not.
Cloud Expo on Google News


2008 West
DIAMOND SPONSOR:
Data Direct
SOA, WOA and Cloud Computing: The New Frontier for Data Services
PLATINUM SPONSORS:
Red Hat
The Opening of Virtualization
GOLD SPONSORS:
Appsense
User Environment Management – The Third Layer of the Desktop
Cordys
Cloud Computing for Business Agility
EMC
CMIS: A Multi-Vendor Proposal for a Service-Based Content Management Interoperability Standard
Freedom OSS
Practical SOA” Max Yankelevich
Intel
Architecting an Enterprise Service Router (ESR) – A Cost-Effective Way to Scale SOA Across the Enterprise
Sensedia
Return on Assests: Bringing Visibility to your SOA Strategy
Symantec
Managing Hybrid Endpoint Environments
VMWare
Game-Changing Technology for Enterprise Clouds and Applications
Click For 2008 West
Event Webcasts

2008 West
PLATINUM SPONSORS:
Appcelerator
Get ‘Rich’ Quick: Rapid Prototyping for RIA with ZERO Server Code
Keynote Systems
Designing for and Managing Performance in the New Frontier of Rich Internet Applications
GOLD SPONSORS:
ICEsoft
How Can AJAX Improve Homeland Security?
Isomorphic
Beyond Widgets: What a RIA Platform Should Offer
Oracle
REAs: Rich Enterprise Applications
Click For 2008 Event Webcasts
SYS-CON.TV
Top Links You Must Click On


A String Bean: Making JavaBeans With VAJ
A String Bean: Making JavaBeans With VAJ

Visual Age for Javaª provides a good IDE for object oriented development. One of the strong points of Visual Age for Java is its support for JavaBeans. As everyone in the world knows by now JavaBeans are components, or software parts, from which applications can be built. This has been the holy grail of object-oriented development, and Visual Age for Java supports it well. It provides a convenient, connect-the-dots metaphor for assembling an application from parts.

One of the obvious questions one might ask, of course, is, "Where do the parts come from?" IBM does supply some JavaBeans with Visual Age for Java but, naturally, they won't do everything. If you need parts, and they're not available, Visual Age for Java makes the process easy. Once you've made the new parts they are reusable in any application. They can even be exported for use outside VAJ.

I'll illustrate this with the String Bean. Let's say you've developed a number of string handling functions that could be used in various situations or programs. You could simply include them when they're needed in a new application but JavaBeans provides a better alternative. You can reuse Beans without changing, or even knowing about, the code itself. You can then expose the methods or properties of the Bean and connect your application to them.

For example, you might need to parse an input string into its component words. If a method for this was included in a String Bean, you could design the input applet or application frame visually in Visual Age for Java using the supplied design beans, adding an instance of the String Bean to your frame and then connecting the JavaBeans. These are the steps you need to take to create a simple application that will allow input of a text string, and then display the individual words of the string in a list box at the click of a button.

First, open Visual Age for Java and create a new applet. When prompted for project and package names, use StringBeanProj and StringBeanPack. The hierarchy should look something like that in Figure1.

Next, create a new class and name it StringBean, but choose not to design it visually. Be sure to import the java.awt.* and java.util.* packages when prompted. Then, create a new method for the StringBean class called stringToken with a signature of public static void stringToken (String Instring, List fillList). Add the code block in Listing 1 and save it.

Now, if you select the BeanInfo tab you see a list of all available features and properties for the new StringBean bean. It should look like Figure 2.

Next, select the StringBeanPack package in the hierarchy and click the C button to build a new class. Call this class StringBeanView and select the choice to design it visually, or go to the Visual Composition editor. After the blank applet panel is displayed, you'll need to add the appropriate beans from those supplied with Visual Age for Java to complete the application/applet. First, add a TextField bean. Then, add a List bean. Finally, add a Button bean and change the label property of the bean to String Bean.

You're ready to add the StringBean JavaBean we just created. From the main menu select Options, then Add Bean. In the dialog box displayed, you can either type StringBean or choose to Browse through the available beans and select it off the list. Click OK, then click again anywhere outside the frame boundary and the jigsaw part icon for StringBean1 to appear.

Now that all the beans are in place it's time to connect them together. For the first connection click the right mouse button on the String Bean Button, then select Connect and then actionPerformed(java.awt.event.ActionEvent) from the drop down menus. Move the mouse pointer to the StringBean1 icon and click mouse button 1, then select All Features. From the bean Features list, select the stringToken() method created earlier.

For the second connection to the TextField bean click mouse button 2 on the first connection line and select Connect. From the list displayed, select inString. Drag the mouse pointer to the TextField bean and click mouse button 1. From the list displayed, select text.For the third connection to the List bean click mouse button 2 on the first connection line and select Connect. From the list displayed, select fillList. Drag the mouse pointer to the List bean and click mouse button 1. From the list displayed, select "this."

Now that all the connections between the beans are complete the design panel should look like Figure 3.

You can test the StringBean applet by selecting Tools->Test->Run from the main menu of Visual Age for Java. Type some text into the TextField(be sure to leave some blanks between words), click the String Bean button and a list of the words in the input string will be displayed in the list box.

I'm sure you can see how this humble foundation could be used to build more extensive applications. Other string handling and manipulation functions can be added to the StringBean bean at any time, making their addition to a new application a simple drag and drop operation. You could even add a StringBean feature that changes string text colors from black to green!

About Mike Fichtelman
Mike Fichtelman is a certified senior project manager at IBM supporting their Web hosting business. He has over 20 years' experience in the information technology field as a developer, designer, and project manager. Mike has an MBA from Hofstra University and his work has been published in a number of journals on subjects ranging from infrastructure to the development of wireless applications using Java, XML, and WAP. He also teaches an e-business course in the MBA program at the University of Phoenix.

In order to post a comment you need to be registered and logged in.

Register | Sign-in

Reader Feedback: Page 1 of 1

Enterprise Open Source Magazine Latest Stories . . .
Apache Deltacloud, the Red Hat-contributed ReSTful API that abstracts differences between clouds so services on any cloud can be managed – provided of course there’s a driver – has graduated from the Apache Foundation’s incubator and is now a full-fledged Top-Level Project (TLP). The...
With Cloud Expo 2012 New York (10th Cloud Expo) just four months away, what better time to start introducing you in greater detail to the distinguished individuals in our incredible Speaker Faculty for the technical and strategy sessions at the conference... We have technical and st...
AMD said late Tuesday that its chief sales officer Emilio Ghilardi had left the company and that CEO and president Rory Read is going to do his job while a replacement is sought. AMD didn’t say why Ghilardi left but it’s assumed Read wants his own people. Read is relatively new to th...
During the lifespan of M3 (Monitis Monitor Manager) there has always been something lacking – timers. M3 execution procedure was outlined in this previous article. The execution mentioned in the latter was a one-time-execution, whereas server monitoring requires periodic invocati...
Red Hat is putting its bought-in Gluster scale-out NAS storage technology, acquired in October, on the Amazon cloud. It’s styled Red Hat Virtual Storage Appliance for Amazon Web Services and other clouds are supposed to follow in short order.
A new episode of the screencast series is now available at the OpenNebula YouTube Channel. This screencast demonstrates the new easily-customizable self-service portal for cloud consumers. Its aim is to offer a simplified access to shared infrastructure for non-IT end users. The scree...
Subscribe to the World's Most Powerful Newsletters
Subscribe to Our Rss Feeds & Get Your SYS-CON News Live!
Click to Add our RSS Feeds to the Service of Your Choice:
Google Reader or Homepage Add to My Yahoo! Subscribe with Bloglines Subscribe in NewsGator Online
myFeedster Add to My AOL Subscribe in Rojo Add 'Hugg' to Newsburst from CNET News.com Kinja Digest View Additional SYS-CON Feeds
Publish Your Article! Please send it to editorial(at)sys-con.com!

Advertise on this site! Contact advertising(at)sys-con.com! 201 802-3021


SYS-CON Featured Whitepapers
ADS BY GOOGLE