Tech all over the world
Friday, July 27, 2007
  Java Technology Fundamentals (July '07)

You are receiving this email at kiri.tech@gmail.com because you have subscribed to the Java Technology Fundamentals newsletter. To update your communications preferences, please see the links at the bottom of this message. We respect your privacy and post our privacy policy prominently on our Web site: http://www.sun.com/privacy.


July 2007

Welcome to the Java Technology Fundamentals Newsletter

This monthly newsletter provides a way for you to learn the basics of the Java programming language, discover new resources, and keep up-to-date on the latest additions to Sun Developer Network's New to Java Center.

The Java Technology Fundamentals Newsletter is now available in a blog format. Content will appear throughout the month and include extras.

Start reading the Java Technology Fundamentals Blog today!

Note : For the code in this issue of Fundamentals to compile, use the JDK 6 software.

In This Issue

»  Basic Java Technology Programming
»  Making Sense of the Java Platform Classes and Tools Annotations
»  Desktop Java Platform Development
»  Server-Side Java Platform Development
»  Java Technology Training
»  For More Information

 

  Basic Java Technology Programming

Getting to Know Sequence Diagrams

by John Zukowski

In last month's column on Generating UML From the NetBeans IDE, you generated a sequence diagram for the newContactActionPerformed() method of the ContactList class of the ABook project. This month's column explains what the diagram shows.

First, here's the diagram again:

Sequence Diagram
Figure 1. Sequence Diagram
Click here for a larger image

And here is the source code behind the method:

    private void newContactActionPerformed(ActionEvent evt) {
        contactEditor.clear();
        contactEditor.setEditable(true);
        EventQueue.invokeLater(new Runnable() {
            public void run() {
                contactEditor.setVisible(true);
            }
        });
    }

Going back to the original system design, this sequence diagram maps to what would have been the New Contact use case. It essentially says to clear and show the contact editor, with a slight nuance of automatic documentation of anonymous inner classes. Normally, those would not go in the original design, but because the diagram was reverse engineered, you get the invokeLater in there.

Although this is a simple diagram, it includes all the different pieces to provide an explanation. Overall, the diagram represents the sequence of messages that the ContactList class must execute to perform the New Contact operation.

Along the top of the diagram, you see the set of objects that are necessary to perform the task.

Sequence
Figure 2. Sequence
Click here for a larger image

Each of these boxes represents an object or process involved. The doubling of EventQueue in the list seems to be an error in the automatic generation. Because there are no boxes on the vertical line below the first EventQueue , the whole line should not be included. The ActionEvent is also without any boxes on its vertical line, so it too could be removed. However, because of the need for it as an argument to the actionPerformed() method, it appears here for completeness.

Normally, you see only the type of object involved in the box at the top, as in : EventQueue , shown in the last box. However, you can also name the object by including a name before the colon, as in evt: ActionEvent . The name helps in explaining the diagram to another user.

The horizontal arrows in the sequence diagram represent the messages exchanged between the involved objects. They are shown in a time sequence, so an arrow higher up the sequence diagram would happen earlier in the execution of events of the use case.

Sequence Message
Figure 3. Sequence Message

So for this set of two messages, clear happens before set editable.

Had this been an original sequence diagram, and not one that was reverse engineered, the first message would have more likely been the word clear alone and not shown like a method name. And the second would have been something like make editable.

Although all the messages of this sequence diagram start at the object on the far left and immediately return, it is not uncommon for a sequence diagram to include messages between other objects.

The invokeLater message partially shows another involved object, but Runnable doesn't quite get the diagram right. It shows the anonymous class usage as an int Unnamed argument of invokeLater . Because Runnable is not involved with messaging of the original object on the far left, it does not have to be shown at the very top. Instead, try limiting its visibility to the usage area. The auto generator also hides the setVisible call.

    contactEditor.setVisible(true); 

But because the call is inside the invokeLater call due to the Swing threading requirements, the diagram is technically correct, though not as one would do from the original use case.

There really is not much to a sequence diagram: just the objects involved and a timed sequence of the messages sent between them. Auto generation isn't always perfect, but when you're trying to get a handle on a large-scale project without sufficient documentation, it certainly provides a good starting point from which to understand the system.

For some pointers on creating your own diagrams, see an Introduction to UML 2 Sequence Diagrams by Scott Ambler.

  Making Sense of the Java Platform Classes and Tools

File Objects

The File class makes it easier to write platform-independent code that examines and manipulates files. The name of this class is misleading: File instances represent file names, not files. The file corresponding to the file name might not even exist.

Why create a File object for a file that doesn't exist? A program can use the object to parse a file name. Also, the file can be created by passing the File object to the constructor of some classes, such as FileWriter .

If the file does exist, a program can examine its attributes and perform various operations on the file, such as renaming it, deleting it, or changing its permissions.

A File Has Many Names

A File object contains the file name string used to construct it. That string never changes throughout the lifetime of the object. A program can use the File object to obtain other versions of the file name, some of which may or may not be the same as the original file name string passed to the constructor.

Suppose a program creates a File object with this constructor invocation:

    File a = new File("xanadu.txt"); 

The program invokes a number of methods to obtain different versions of the file name. The program is then run both on a Microsoft Windows system (in directory c:\java\examples ) and a Solaris system (in directory /home/cafe/java/examples ).

Read the tutorial

  Desktop Java Platform Development

NetBeans IDE Modules and Rich-Client Applications Learning Trail

What Is a NetBeans IDE Module?

A NetBeans IDE module is group of Java classes that provides an application with a specific feature. For example, the feature provided by the Java classes in the NetBeans Google Toolbar Module Tutorial provides a Google search toolbar. The Java classes use the manifest file to declare the module and the layer.xml configuration file to declaratively register their functionality.

NetBeans IDE 5.0 introduced wizards and templates that help you develop NetBeans modules. NetBeans IDE 5.5 Beta 2 provides several enhancements, including many new wizards and templates, such as a wizard for extending the Options window and a wizard for providing a JavaHelp help set. The same enhancements are also available for NetBeans IDE 5.0. Just download Module Development Update 1 from the NetBeans IDE 5.0 Update Center, which is found in the menu under Tools within the IDE itself.

When you have developed a NetBeans module, you can install it in NetBeans IDE or in an application created on top the NetBeans platform. The NetBeans platform is the NetBeans application framework, which allows you to quickly prototype and develop your own Swing applications, using the IDE's popular GUI Builder to design your user interface.

By developing your own NetBeans modules, you can extend an application's functionality with new features. For example, you can write modules that make your favorite cutting-edge technologies available to the NetBeans IDE. Alternatively, you might miss some low-level functionality in the Source Editor and create a module to provide it. On a higher level, you can use the core of NetBeans as a platform on top of which you develop rich-client Swing applications, out of NetBeans modules. You can save a lot of development time by reusing features readily available in the platform.

Getting Started

The following two tutorials assume that you have no background in NetBeans module development at all. The first shows you how to build a NetBeans module, which is a basic building block for building a rich-client application on the NetBeans platform. The tutorial that follows shows you how to create your first rich-client application out of NetBeans modules.

  • Introduction to NetBeans Module Development
  • Introduction to NetBeans Rich-Client Application Development
Read these tutorials
  Server-Side Java Development

Downloading and Importing Ajax and Other Components Contributed by the Visual Web Pack Tutorials Team

This tutorial shows how to download a component module from the NetBeans Visual Web Pack 5.5 Update Center and import the module into the IDE. The instructions are specific to downloading the sample BluePrints Ajax Component module for the first time. If you are downloading another component module, simply substitute the module name.

Contents

  • Downloading a Component Module

  • Importing the Module Into the IDE

  • Adding a Component Library to a Project

  • Updating, Reverting, or Removing a Component Library

Read the tutorial

  Java Technology Training

Java Technology Training: Instructor-Led, Self-Paced Web, CD, and Virtual Courses

  • Object-Oriented (OO) Analysis and Design Using UML (OO-226) :
    This course progresses through a primer on OO technology and software development methodologies, requirements gathering and analysis (including interviewing stakeholders), system architecture and design, implementation, testing, and deployment.

  • Introduction to Developing Rich-Client Applications (WJO-1107) :
    This course defines the concept of a Java technology rich-client application (also known as a Swing application) and describes how to use the Swing API. Students learn how to use the features of the NetBeans IDE for rapid application development. The course demonstrates how to extend the NetBeans platform to build a simple Swing application.

  • Developing Applications for the J2EE Platform (CDJ-310A) :
    This course provides students with the knowledge to build and deploy enterprise applications that comply with Java 2 Platform, Enterprise Edition (J2EE) standards. Students are taught how to assemble an application from reusable components and how to deploy an application in the J2EE platform runtime environment.

See the course catalog

  For More Information


To comment about the content of this newsletter, send an email to fundamentals_newsletter@sun.com.

© 2007 Sun Microsystems, Inc. All rights reserved. For information on Sun's trademarks see: http://www.sun.com/suntrademarks

To unsubscribe from this list, reply to this message with "Unsubscribe" in the subject line or use this link:
http://communications1.sun.com/r/c/r?2.1.3J1.2Vd.12SMlS.C49wiC..H.Ea%2aS.1kp2.aT1raXJpLnRlY2hAZ21haWwuY29tDaYEHEE0

To manage your Sun subscriptions, visit the Subscription Center.

Sun Microsystems, Inc., 10 Network Circle, MPK10-209 Menlo Park, CA 94025 U.S.A.





 
Comments: Post a Comment



<< Home
News, Articles, events from all over the world

My Photo
Name:
Location: India

Born on shraavana shudha chauthi of dundubhi naama samvaswara, Im kiran alias kini alias kiri bought up by loving parents. Being from agricultural family I have learnt plowing, carting but never learnt climbing trees. Now away from home I have lost touch with the agricultural skills.

ARCHIVES
January 2006 / February 2006 / March 2006 / April 2006 / May 2006 / June 2006 / July 2006 / August 2006 / September 2006 / October 2006 / November 2006 / December 2006 / April 2007 / May 2007 / June 2007 / July 2007 / August 2007 / September 2007 / October 2007 / November 2007 / December 2007 / January 2008 / February 2008 / March 2008 / April 2008 / May 2008 / June 2008 / July 2008 / August 2008 / September 2008 / October 2008 / November 2008 / December 2008 / January 2009 / February 2009 / March 2009 / April 2009 /


Powered by Blogger