11.13.1 Some Important Data Characteristics In the example of bonForum XML data content at runtime shown previously, you can notice the following two characteristics of the way the chat
Trang 1wally::Hey! I’m here charlie Are you there?
11.12.1 Chat Data in the XML Data Example
At the time the bonForum data was dumped to an XML file, two chats had been started.The nicknames and ages of the two chat hosts are stored inside hostelements
as children of the actorselement Only one guest has joined a chat, and that guest’s nickname and age are stored in a guestelement also as a child of the actorselement Adam is the host of a topic with the subject Vehicles.Trucks.Other and the topic
“my other truck is a ferrari.” Adam is still awaiting his first guest, and only his own single message appears in the chat It could be displayed as follows:
[Saturday 05 09:08:09 2000] adam::this is dynamite!
Charlie is the host of a chat with the subject Animals.Fish.Piranhas and the topic “pet piranha stories.” Charlie and his guest,Wally, have each entered one message to the chat, which could be displayed as follows:
[Saturday 05 09:19:02 2000] charlie::Is anybody there?
[Saturday 05 10:09:35 2000] wally::I’m here, charlie
11.13 More ForestHashtable Considerations
In this last part of this chapter, we will mention a few final things that are important
to the understanding and future development of the ForestHashtableclass.
11.13.1 Some Important Data Characteristics
In the example of bonForum XML data content at runtime shown previously, you can notice the following two characteristics of the way the chat data is kept in the
ForestHashtable:
Trang 211.13 More ForestHashtable Considerations
1 The objects stored in a Hashtablehave no order.Therefore, the order of sibling elements in the XML document has no meaning For human readability, if that
is needed, some XML elements could be sorted by modifying the XSLT style sheet Sorting could also be implemented by changing the underlying data struc- ture to a SortedMapimplementer, such as TreeMap, or by keeping an external sorted index in the manner of an RDB.
2 The NodeKeyvalues are referred to by other key attributes, to relate the tion in different elements together For example, a chat element has a hostKey
informa-child that contains the value of the chat’s host’s NodeKey.That is why we serve the NodeKeyvalues in NodeKey” attributes within each element when the XML is output from the ForestHashtable.
pre-11.13.2 Setting ForestHashtable Capacity
By reading the API documentation on the java.util.Hashtableclass, you can learn about the issue of the capacity of a Hashtableobject.The only way we have dealt with this so far is to provide a constructor for the class that takes an argument called
capacity, which (surprise!) sets the capacity of a ForestHashtable The idea is that this capacity setting can be determined by the Web application, perhaps by having it saved as a parameter in the Web app deployment descriptor (web.xml) of the application For the bonForum Web chat application example, we set the capacity to 5000.This number was selected by estimating 200 bytes per node.
More testing is necessary to tune this factor, which is very important for the ence of using the Web application Setting the capacity correctly can minimize the inevitable rehashing time.
experi-11.13.3 XPATH Modeling Planned
One premise behind the design of ForestHashtableis that is could be easier or faster
to manipulate a triple-valued key than to work with the (infinitely) long path sions that can be present in an XML data document.The hierarchy of nodes can be modeled as a forest of trees by a table with a double- or triple-valued key.
expres-A plan for the future is to see if we can create methods that fulfill all the XPexpres-ATH functionality solely by processing the keys in the table.
11.13.4 Self-Healing XML Documents
Another idea of ours is to create an XML document representation that would create,
by default, any “missing” set of nodes.These nodes that would be supplied form a node path connection between a “disconnected” XML fragment and the “closest”
existing related node.
Why do that? Because that means you can put a tree-fragment into empty space in the forest.Then you could either tell or ask the forest to “decide” which tree the frag-
Trang 3ment belongs in.This would cause the forest to “grow” any necessary branches to nect the fragment with the tree, thus creating one new tree that can be expressed as a valid XML document.
con-Two practical outcomes appear here First, if the keys for the forest are globally unique identifiers, you can throw together two or more forests of data, and they will still function as a forest (that is, the keys will not clash).That would be great for mix- ing data from laptops and servers, for example Second, the self-sticking tree fragment addition to the forest means that relations among combined data sets can be “patched”
by using default values, which preserves displayability and processability, in many cases.
It might even keep your browser from choking!
11.13.5 Improvement of Algorithms
Much of the code in this class, as in the bonForum project in general, is intentionally written in a “dumb” style, leaving much room for optimization Rather than trying to get too smart and doing many things in one statement, we think that it is easier to debug code that is spread out over smaller steps Our motto is, “First get it working, and then get it working right!”
moveNode()
Further optimization will include addition of new methods One candidate, for ple, is a moveNode()method that would have the following signature:
exam-moveNode(NodeKey KeyOfNodeToMove, NodeKey KeyOfNewParentNode, Boolean IfLeafOnly);
The moveNode()method would also have a leafOnlyargument, as the deleteNode()
method does If IfLeafOnlyis true, then the node would not be moved if it has one
or more child nodes If IfLeafOnlyis false, then the node and all its descendants would be moved.
Another argument called NewParentNodewould tell the method the destination to which it should move a node If the NewParentNodeis null, then the NodeToMovewould
be made a root node in the forest.
11.13.6 Enforcing Uniqueness Among Nodes
In the addNode()method of ForestHashtable, uniqueness is enforced for
nodeNameHashtableentries.When we remove an “old” cached NodeKeyfrom the nodeNameHashtable, we cannot simultaneously remove the node in the
ForestHashtablebecause it may be in use in other thread.
However, we need to enforce unique sibling names in some situations—for ple within descendant levels of the Subjects subtree in the bonForum Web chat appli- cation XML data Also, at least in that application of the ForestHashtable, we would like to somehow enforce unique chatTopicvalues and nickNamevalues by using a mechanism intrinsic to the ForestHashtable.This is left as a task for a future time.
Trang 411.13 More ForestHashtable Considerations
11.13.7 Usability of the ForestHashtable Class
Without having tested the ForestHashtableexperimental class sufficiently, it is not yet possible to characterize its runtime performance versus the quantity of data and thread loading Certainly, processing will slow down at some point, but that depends on many factors, including the hardware on which it is running.
ForestHashtable Is a Design Laboratory
The ForestHashtableclass is primarily a design laboratory.We will be implementing some of the ideas tried out there in a relational database system.You are invited to bring your comments and participation to http://www.bonforum.org, our open source site for the bonForum project on SourceForge.
Trang 6Online Information Sources
12.1 Always Useful Sites
Web site for the bonForum Web application project
Trang 7A great multilingual text editor
Sun Java Forums
http://forum.java.sun.com/
12.2 Apache Software Foundation
Apache Software Foundation
News about Apache
Trang 912.8 Java
12.8.1 Java: Compilers and SDKs
Java 2 SDK, Standard Edition, download
http://java.sun.com/j2se/1.3/download-windows.html
12.8.2 Java: Books, Articles, and Magazines
Thinking in Java, free downloadable book
Trang 1012.9.1 JSP: Main Web Site
JavaServer Pages technology
http://java.sun.com/products/jsp/
Trang 1212.10 Java Servlets
JSP versus ASP
http://java.sun.com/products/jsp/jsp-asp.html Introduction to JavaServer Pages
12.10.1 Servlets: Main Web Site
Servlet Web site at Sun
12.10.3 Servlets: Books, Articles, and Magazines
Server-side Java magazine online
http://www.servletcentral.com
Trang 15Open Source Enhydra Java-XML Application Server Home
Mozilla (open source Netscape Web browser)
Trang 1712.17.4 XML: Editors and Tools
Links and information for many XML editors
Trang 2112.18.2 XSL: Articles, Books, and Magazines
XSL Transformations: book chapter
Trang 24CD-ROM Contents
A
THIS APPENDIX DISCUSSES WHAT YOUcan find on the CD-ROM that comes with this book.
At this time, all software developed by this book’s author on the CD-ROM has
been tested only with Windows NT 4.0 (Service Pack 5) Of course, much of the
soft-ware should be portable to other operating systems, because it is all written in Java, JSP, HTML, XML, and so on, but no guarantees of any kind can be given Please check the Web site at http://www.bonforum.orgfor possible information about using the software with operating systems other than Windows NT 4.0.That Web site also lists known problems, fixes, and updates for the software featured in this book and CD-ROM.
Please be aware that all the software files on this CD-ROM, whether created by this book’s author or other parties, are licensed and have associated copyrights.You can find the appropriate licenses and distribution files in Appendix B, “Some Copyrights and Licenses.” Please use and distribute the software products on this CD-ROM only
in accordance with the provisions of their respective licenses!
Chapter 12, “Online Information Sources,” is in the root folder of the CD-ROM
so that you can load it into your Web browser Please take advantage of its many Web links to find information related to the topics covered in this book.We especially rec- ommend the links related to the Open Source software movement.
There are five folders in the root of the CD-ROM.The following text describes their contents in a general way, without listing all the subfolders or their contents in detail.
Trang 25You will also find on the CD-ROM some later releases of these three products—
the latest that were available when this CD-ROM was produced.These have not been
tested with the book or with the bonForum project software! We will post tion about using these, and later releases that become available, at the bonForum open source project Web site at http://www.bonforum.org.
informa-In addition, the CD-ROM contains other open source products released by Apache Software Foundation projects, which should interest readers of this book.These other products (Cocoon, ant, xang, and jakarta-taglibs) are not discussed in this book.You can find further information about them on the Apache Software Foundation Web site
at http://www.apache.org.
\bonForum
The bonForum folder contains files related to the bonForum open source Web cation project, which is thoroughly discussed in this book It is a prototype for a Web chat application that is intended to test design concepts for Web applications of various
appli-types In its present state, it is not intended for public deployment on the Internet as a
chat application! None of the necessary security provisions for it are provided for in the design and implementation of the bonForum Web application, because its intent is purely and solely instructional and experimental.
Unless covered by another license, all the software (in both binary and source form) found in the bonForum folder and its subfolders has been released by the author under an open source license called the “bonForum license.” A copy of it is included
on the CD-ROM and appears in Appendix B Distribution and use of the bonForum Web application software is covered by that license, so please read it if you use or dis- tribute the software.
The bonForum project files are supplied in three forms, which are described next.
Trang 26Projects_bonForum_001107_0503.zip
Note that the date and time at the end of this name may vary.This is a zipped archive
of all the source code for the chat application, ready to add to the ElixirIDE projects folder, or wherever you want to use it.The pathnames of the zipped files all begin with “bonForum.”
You are encouraged to experiment with it, fix it, hack it, and generally do whatever
is consistent with the included copyrights, disclaimers, notices, and warnings.This is tutorial software without warranties of any kind A few parts of the source are based
on demonstration code that is supplied with various Apache Software Foundation jects (Xalan, Xerces, and Tomcat).We have included their license information in the source files involved and in Appendix B.You should check these to see if and how they apply to any code you derive from us or them.
pro-Note
Any changes you make to files here must first be copied to the Tomcat webapps bonForum hierarchybefore you see any change to the application That includes HTML, JSP, XSL, class, image, and other filesused by bonForum
If you are not using an IDE, you can use the batch file provided It will compile the Java files into the same folders where they are kept.The resulting class files must be used to overwrite the class files in the Tomcat application folders before the changes will appear in bonForum Note that the BonForumRobot.class file is in two locations
in the Tomcat webapps bonForum hierarchy.
Note
It is best not to copy the zipped file to your TOMCAT_HOME\webapps folder and unzip it there If you
want the source there, it is better to unzip into a temp folder and then move the bonForum\src folderhierarchy where you want it Any zip file in TOMCAT_HOME\webapps will create a webapp when Tomcatstarts up Also, depending on your configuration of Tomcat, files might end up being browseable thatshould not be
Trang 27This contains the complete source code hierarchy as it was installed in the C:Elixir\Projects folder on the author’s machine It was zipped to create the source code archive provided separately as something like bonForum_O_S1.zip.You can copy this to a projects folder for your IDE, if you want Note that the source was also copied into an src folder under WEB-INF folder in the bonForum WAR file (discussed earlier).
\tools
The tools folder contains trial versions of three products from Elixir Technologies.This book discusses only ElixirIDE, but the other products (ElixirCASE and ElixirReport) look interesting and have been included for you to try Chapter 2, “An Environment for Java Software Development,” discusses the use of ElixirIDE, a Java Integrated Development Environment.You may use it to compile the Web application project example (bonForum) upon which this book is based Alternatively, you may use your own familiar tools or the Java SDK command-line environment Also in the tools folder are some plug-in modules that can be used with ElixirIDE See its manual for details.
Also in the tools folder is a trial version of the TextPad editor, which I have found
to be very useful for development I usually put all the JSP files in one workspace and open that with one instance of TextPad I put all the Java files in another workspace and open that in another instance of TextPad A third instance and workspace makes all other project files (XSL, HTML, etc.) available.The “Find in Files” command in the Search menu is particularly useful.
E-Book
The E-Book folder contains this book in PDF format.This is copyrighted material and permission is required for commercial use and reproduction.