ODWEK BasicsAndBeyond
ODWEK BasicsAndBeyond
Wei-Dong Zhu
Mark Mikeal
Hassan A. Shazly
Elliott Wade
Sebastian Welter
ibm.com/redbooks
International Technical Support Organization
December 2008
SG24-7646-00
Note: Before using this information and the product it supports, read the information in
“Notices” on page ix.
This edition applies to Version 8 Release 4 of IBM Content Manager OnDemand (program
number 5724-J33).
Notices . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ix
Trademarks . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . x
Preface . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . xi
The team that wrote this book . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . xii
Become a published author . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . xiv
Comments welcome. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . xiv
iv IBM Content Manager OnDemand Web Enablement Kit Java APIs: The Basics and Beyond
6.6.2 Other timeouts. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 139
6.6.3 Implementing an application timeout by using the ODServer.cancel()
method . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 140
6.6.4 Recommended timeout implementation for a Web application . . . . 141
Contents v
9.1.4 Delivering documents . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 181
9.2 Retrieval API overview . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 182
9.2.1 Retrieval APIs in the ODHit class . . . . . . . . . . . . . . . . . . . . . . . . . . 182
9.3 AFP resource retrieval and custom caching . . . . . . . . . . . . . . . . . . . . . . 185
9.4 Segmented retrieval and large object support. . . . . . . . . . . . . . . . . . . . . 187
9.4.1 Retrieving segmented documents. . . . . . . . . . . . . . . . . . . . . . . . . . 189
9.4.2 Obtaining segment information . . . . . . . . . . . . . . . . . . . . . . . . . . . . 190
9.5 Avoiding memory issues for large files . . . . . . . . . . . . . . . . . . . . . . . . . . 190
9.6 Getting document type information . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 191
9.7 Retrieving converted data . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 193
9.7.1 Supported data conversions and viewers . . . . . . . . . . . . . . . . . . . . 195
vi IBM Content Manager OnDemand Web Enablement Kit Java APIs: The Basics and Beyond
12.5.2 Garbage collection performance . . . . . . . . . . . . . . . . . . . . . . . . . . 232
12.6 Startup parameters . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 236
12.6.1 Supported commands and available options . . . . . . . . . . . . . . . . 236
12.6.2 Performance and analysis commands . . . . . . . . . . . . . . . . . . . . . 238
12.6.3 Memory allocation commands . . . . . . . . . . . . . . . . . . . . . . . . . . . 242
12.6.4 Customizing the heap size . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 244
12.6.5 Customizing the object generations . . . . . . . . . . . . . . . . . . . . . . . 245
12.6.6 ODWEK Java API memory usage . . . . . . . . . . . . . . . . . . . . . . . . 246
12.7 Other performance areas . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 247
12.7.1 Network . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 247
12.7.2 Disk . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 250
12.7.3 Processor . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 250
12.7.4 Physical memory . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 250
Contents vii
13.5.3 Visual Performance Analyzer . . . . . . . . . . . . . . . . . . . . . . . . . . . . 272
13.6 Getting support . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 273
13.6.1 OnDemand User Group . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 273
13.6.2 Opening a Problem Management Record. . . . . . . . . . . . . . . . . . . 273
Index . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 279
viii IBM Content Manager OnDemand Web Enablement Kit Java APIs: The Basics and Beyond
Notices
This information was developed for products and services offered in the U.S.A.
IBM may not offer the products, services, or features discussed in this document in other countries. Consult
your local IBM representative for information on the products and services currently available in your area.
Any reference to an IBM product, program, or service is not intended to state or imply that only that IBM
product, program, or service may be used. Any functionally equivalent product, program, or service that
does not infringe any IBM intellectual property right may be used instead. However, it is the user's
responsibility to evaluate and verify the operation of any non-IBM product, program, or service.
IBM may have patents or pending patent applications covering subject matter described in this document.
The furnishing of this document does not give you any license to these patents. You can send license
inquiries, in writing, to:
IBM Director of Licensing, IBM Corporation, North Castle Drive, Armonk, NY 10504-1785 U.S.A.
The following paragraph does not apply to the United Kingdom or any other country where such
provisions are inconsistent with local law: INTERNATIONAL BUSINESS MACHINES CORPORATION
PROVIDES THIS PUBLICATION "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS OR
IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF NON-INFRINGEMENT,
MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. Some states do not allow disclaimer
of express or implied warranties in certain transactions, therefore, this statement may not apply to you.
This information could include technical inaccuracies or typographical errors. Changes are periodically made
to the information herein; these changes will be incorporated in new editions of the publication. IBM may
make improvements and/or changes in the product(s) and/or the program(s) described in this publication at
any time without notice.
Any references in this information to non-IBM Web sites are provided for convenience only and do not in any
manner serve as an endorsement of those Web sites. The materials at those Web sites are not part of the
materials for this IBM product and use of those Web sites is at your own risk.
IBM may use or distribute any of the information you supply in any way it believes appropriate without
incurring any obligation to you.
Information concerning non-IBM products was obtained from the suppliers of those products, their published
announcements or other publicly available sources. IBM has not tested those products and cannot confirm
the accuracy of performance, compatibility or any other claims related to non-IBM products. Questions on
the capabilities of non-IBM products should be addressed to the suppliers of those products.
This information contains examples of data and reports used in daily business operations. To illustrate them
as completely as possible, the examples include the names of individuals, companies, brands, and products.
All of these names are fictitious and any similarity to the names and addresses used by an actual business
enterprise is entirely coincidental.
COPYRIGHT LICENSE:
This information contains sample application programs in source language, which illustrate programming
techniques on various operating platforms. You may copy, modify, and distribute these sample programs in
any form without payment to IBM, for the purposes of developing, using, marketing or distributing application
programs conforming to the application programming interface for the operating platform for which the
sample programs are written. These examples have not been thoroughly tested under all conditions. IBM,
therefore, cannot guarantee or imply reliability, serviceability, or function of these programs.
The following terms are trademarks of the International Business Machines Corporation in the United States,
other countries, or both:
Adobe Reader, Adobe, and Portable Document Format (PDF) are either registered trademarks or
trademarks of Adobe Systems Incorporated in the United States, other countries, or both.
SAP, and SAP logos are trademarks or registered trademarks of SAP AG in Germany and in several other
countries.
Cell Broadband Engine and Cell/B.E. are trademarks of Sony Computer Entertainment, Inc., in the United
States, other countries, or both and is used under license therefrom.
100% Pure Java, Java, Javadoc, JavaScript, JavaServer, JDK, JNI, JSP, JVM, Solaris, Sun, SunOS, and all
Java-based trademarks are trademarks of Sun Microsystems, Inc. in the United States, other countries, or
both.
ESP, Excel, Internet Explorer, Microsoft, Windows Vista, Windows, and the Windows logo are trademarks of
Microsoft Corporation in the United States, other countries, or both.
Intel Pentium M, Intel Pentium, Intel, Pentium M, Pentium, Intel logo, Intel Inside logo, and Intel Centrino logo
are trademarks or registered trademarks of Intel Corporation or its subsidiaries in the United States, other
countries, or both.
UNIX is a registered trademark of The Open Group in the United States and other countries.
Linux is a trademark of Linus Torvalds in the United States, other countries, or both.
Other company, product, or service names may be trademarks or service marks of others.
x IBM Content Manager OnDemand Web Enablement Kit Java APIs: The Basics and Beyond
Preface
The ODWEK Java APIs can be incorporated into any Java-based application,
including stand-alone applications, portlets, servlets and Web services. We
illustrate the APIs by using servlet-based code to encourage an integrated
understanding of the topics.
This book is intended for application developers who are responsible for
developing Web applications that interface with Content Manager OnDemand. It
also serves as a good reference guide for developers and system administrators
to fine-tune and troubleshoot Content Manager OnDemand Web applications.
Mark Mikeal is a senior managing consultant team leader with IBM Enterprise
Content Management Lab Services. He has more than 25 years of software
development and integration experience in enterprise content management.
Mark joined IBM in 1984 and is a Certified Specialist for cross-industry solutions
related to enterprise content management. He has presented at multiple industry
conferences. Mark holds a Bachelor of Science degree in Business
Administration from the University of South Carolina.
Elliott Wade is a software engineer and architect with more than 10 years of
Java development experience. He has worked as a technology consultant in the
financial services and manufacturing sectors and is currently a senior developer
at ADP Retirement Services. His Content Manager OnDemand projects have
included stand-alone applications, batch processes, and middle-tier integration.
Elliott studied Computer Science at Boston University.
xii IBM Content Manager OnDemand Web Enablement Kit Java APIs: The Basics and Beyond
from the University of Corporate Education in Mannheim and a Bachelor of Arts
degree in Business Administration.
Many thanks to the following people who have shared their knowledge and
contributed substantial material for this book:
Gordon Campbell, Certified Software IT Specialist, for providing the base
sample API programs and API description documentation
Nelson Chen, Content Manager OnDemand Software Developer, for providing
education and globalization documentation
Brian Hoyt, Content Manager OnDemand Software Architect, for providing
programming insight, information, and review
Hubert Hwang, Content Manager OnDemand Level 2 Support, for providing
valuable troubleshooting hints and tips documentation
Bob Lichens, Content Manager OnDemand Software Developer, for providing
guidance and documentation on best practices, hints, and tips
We also thank the following people for their contributions to this project:
Stephen Henrikson
Thomas Garcia
Gregory Felderman
Eric Hann
Ben Boltz
Janice L. Holoman
Kevin Van Winkle
IBM Software Group, Content Manager OnDemand, Boulder, Colorado
Preface xiii
Become a published author
Join us for a two- to six-week residency program! Help write a book dealing with
specific products or solutions, while getting hands-on experience with
leading-edge technologies. You will have the opportunity to team with IBM
technical professionals, Business Partners, and Clients.
Your efforts will help increase product acceptance and customer satisfaction. As
a bonus, you will develop a network of contacts in IBM development labs, and
increase your productivity and marketability.
Find out more about the residency program, browse the residency index, and
apply online at:
ibm.com/redbooks/residencies.html
Comments welcome
Your comments are important to us!
xiv IBM Content Manager OnDemand Web Enablement Kit Java APIs: The Basics and Beyond
Part 1
Before we provide an overview of the ODWEK Java APIs, you must have an
overall understanding of Content Manager OnDemand system, which we provide
briefly in the next section. If you are already familiar with Content Manager
OnDemand, skip the next section and proceed to 1.3, “ODWEK Java APIs
function overview” on page 11.
4 IBM Content Manager OnDemand Web Enablement Kit Java APIs: The Basics and Beyond
y j
Temp
Storage
Cache
Storage
ODBC DB2
TCP/IP
Network Library Server (1)
Temp
Storage
Client Cache
Storage
Load
Proces
s
Library Server
The Library Server maintains a central database that contains an index of the
reports and documents that are stored in Content Manager OnDemand. The
Library Server database also contains administrative objects such as users,
groups, printers, application groups, applications, folders, cabinets, and storage
sets. The Library Server processes client logons, queries, print requests, and
updates to the database.
Object Server
An Object Server maintains documents on persistent storage volumes. A storage
volume is either a cache or an archive volume. A cache volume is typically
disk-based and is intended to store frequently-accessed documents. Many
Content Manager OnDemand installations implement only this type of storage.
An Object Server loads data, retrieves documents, and expires documents. Data
loading and maintenance utilities are installed on Object Servers.
Logical server
The combination of a single Library Server and multiple Object Servers is
regarded as a logical server. Any of this server’s components can run on a
supported operating system.
6 IBM Content Manager OnDemand Web Enablement Kit Java APIs: The Basics and Beyond
The billing report contains the property tax billing statement for every property
owner in the county. The BILLS application uses the document indexing method
to divide the report into documents. Each property owner’s billing statement in
the report becomes a document in Content Manager OnDemand. A user can
retrieve a billing statement with a specific date. Content Manager OnDemand
retrieves the corresponding document based on the property owner or property
number, and the user specified date.
The transaction report includes all the payment transactions by the property
owners. The TRANS application uses the report indexing method to divide the
report into documents. A group of 100 pages in the report becomes a document.
Each group is indexed by using the first and last sorted transaction values that
occur in the group. A user can retrieve a group of pages that contains a specific
transaction number by specifying the date and the transaction number. Content
Manager OnDemand retrieves the corresponding document that contains the
value that is entered by the user.
Document
Report
Application
An application describes the physical characteristics of a report or document to
Content Manager OnDemand. Typically, you define an application for each report
or document type to be stored in Content Manager OnDemand.
The application includes information about the format of the data, the orientation
of the data on the page, the paper size, the record length, and the code page of
the data. The application also includes parameters that the indexing program
uses to locate and extract index data. In addition, it includes processing
instructions that Content Manager OnDemand uses to load index data into the
Library Server database and to load report and document data into the Content
Manager OnDemand Object Server.
The student and faculty example in Figure 1-2 shows three applications,
Transcripts, Grades, and Parents Payments, which generate student transcripts,
grade reports, and payment information.
8 IBM Content Manager OnDemand Web Enablement Kit Java APIs: The Basics and Beyond
Application group
An application group is a collection of one or more applications with compatible
indexing and storage management requirements. The application group defines
the index information that is used to load, search for, and retrieve reports.
Multiple applications are combined into an application group so that users can
access the documents in all of the grouped applications with a single query. The
index keys of all applications in an application group must be compatible. That is,
they must be of the same data type and length.
For the student and faculty example in Figure 1-2 on page 8, the Transcripts
application uses student social security numbers (SSN) and course numbers
(Course) as indexes for student transcripts. The Grades application also uses
these two indexing fields for the grade reports. Therefore, these two applications
can be grouped into one application group, called Student Transcripts. The
Parents Payments application uses only the SSN as the index for the report. This
application belongs to a separate application group, called Students.
Folder
A folder contains one or more application groups. A folder provides users with a
convenient way to find related information that is stored in Content Manager
OnDemand, regardless of the source of the information or how the data was
prepared. By using folders, an administrator can set up a common query panel
for several application groups that might use different indexing schemes. A user
can retrieve the data with a single query.
In the student and faculty example in Figure 1-2 on page 8, a Student Information
folder contains student transcripts, grades, and payment information. This
information is stored in different application groups (Student Transcripts and
Students) that are defined in different applications (Transcripts, Grades, Parents
Payments) and are created by different programs. When a folder search is
performed, Content Manager OnDemand searches within each application group
that is part of the folder.
Cabinet
A cabinet is a container for one or more folders. You can identify a group of
folders as belonging to a cabinet for convenient navigation. A folder can belong to
multiple cabinets.
The student and faculty example in Figure 1-2 on page 8 shows one cabinet that
contains both the Course Information and Student Information folders and
another cabinet that contains both the Student Information and the Faculty
Information folders. Therefore, with the first cabinet, a user can locate folders that
contain information that is related to both students and course information. For
Indexing
The reports that are stored in Content Manager OnDemand must be indexed.
Library Server index entries for a particular report provide users an efficient
means to request and view specific report data. Content Manager OnDemand
supports several types of index data and indexing programs (also known as
indexers).
An administrator defines the index files and other processing parameters that are
used by the selected indexer to locate and extract index information from reports.
Data types that can be indexed and loaded include line data, AFP, TIF, PDF, and
others.
TIF data: Technically, Content Manager OnDemand does not index TIF data.
Content Manager OnDemand loads TIF data through the generic indexer,
which does not index data, but rather gets the indexes from a specified file.
With Content Manager OnDemand, data can be indexed externally prior to being
used in the system.
Loading
The Content Manager OnDemand data loading programs read the index data
and load it into the Content Manager OnDemand database. The data loading
programs obtain processing parameters from the Content Manager OnDemand
database. Sample parameters include those that are used to segment,
compress, and store report data in cache storage or archive storage.
10 IBM Content Manager OnDemand Web Enablement Kit Java APIs: The Basics and Beyond
1.3 ODWEK Java APIs function overview
The ODWEK Java APIs enable access to the OnDemand server from any IP
network, whether intranet or Internet. By using the APIs, you can write
applications that can access data stored in Content Manager OnDemand.
The ODWEK Java APIs provide the following functions for users to perform:
Log into an OnDemand server.
List cabinets or folders.
Search for a specific set of documents in a folder.
Retrieve documents.
View documents.
Log off from the system.
In addition to the common functions, by using the ODWEK Java APIs, users can
perform the following functions:
Change the Content Manager OnDemand account password.
Print documents.
Add document annotations.
Update documents.
Custom applications can support some or all of these functions. This book
addresses programming to support these functions and other functions that are
not listed here for a simplified introduction.
The ODWEK Java APIs can access OnDemand servers that are running on any
supported platform, including IBM z/OS®, System i®, AIX®, Linux® on
System z, and Microsoft® Windows®.
Figure 1-3 shows a workstation with a Web browser that uses the ODWEK Java
APIs to access data from an OnDemand server.
Intranet
Internet z/OS, System i, Multiplatform
oror (AIX, HP-UX, Linux, Sun Solaris,
Intranet Windows, Linux on System z)
Internet
Library Server
Browser - Microsoft or Firefox
- Applet supported data types
-Line Data viewer
-AFP2HTML viewer
- Web Viewers invoked for other data types
-AFP, PDF, Image
Object Server or Servers
We discuss applets and Web viewers shown in Figure 1-3 in 1.5.2, “Viewers” on
page 14.
12 IBM Content Manager OnDemand Web Enablement Kit Java APIs: The Basics and Beyond
You can use the ODWEK Java APIs to develop Web applications and to develop
both batch and stand-alone applications. In addition, you can use the ODWEK
Java APIs to create middleware that integrates existing applications with Content
Manager OnDemand.
Figure 1-4 illustrates the common architectural modes of the ODWEK Java APIs.
User interface
Browser
Custom application
TCP/IP
Optional
TCP/IP User interface
WebSphere or other Web technologies
Java interface code
Java code Java program
ODWEK Java API ODWEK Java API
TCP/IP
CMOD server
For a list of distributed files, see 1.5.3, “ODWEK Java API distribution files” on
page 15.
1.5.2 Viewers
Most ODWEK applications are capable of displaying retrieved documents or
report segments. ODWEK provides several viewers that can display various
document types in a browser window. Each viewer adds a toolbar to its display
window, providing controls that help users to work with the retrieved documents.
The viewers that are provided with ODWEK retrieve documents from an
OnDemand server in compressed forms. A viewer uncompresses the documents
before displaying them in the browser. When a document is stored in Content
Manager OnDemand as a large object, the viewer retrieves and uncompresses
segments of the document as they are needed. That is, as the user scrolls
through the document’s pages.
14 IBM Content Manager OnDemand Web Enablement Kit Java APIs: The Basics and Beyond
Viewers other than those provided with ODWEK can be integrated with the
ODWEK Java APIs. Such viewers can support additional document types or
provide custom document-related functions.
The following list of ODWEK Java API binary distribution files is provided to
acquaint developers with the distribution as an aid to use ODWEK in
development environments, application servers, or stand-alone deployments.
This listing might change because the distributed modules are subject to change
and vary slightly by platform and release level.
16 IBM Content Manager OnDemand Web Enablement Kit Java APIs: The Basics and Beyond
Viewers (and transforms)
– Configuration files for transforms
• afp2html.ini Configures the AFP2WEB Transform
• afp2pdf.ini Configures the AFP2PDF Transform
• arsxenos.ini Configures the XENOS Transform
– Applets
• ODLineDataViewer2.jar
The Content Manager OnDemand Line Data Viewer applet
• ODAfp2Html2.jar
The Content Manager OnDemand AFP Transform applet
• IEFix.js
The JavaScript™ file that assists the applet launch
– Plug-ins
Plug-ins are distributed as InstallShield self-extracting installations. To
install a plug-in, download the installation file to the target Windows XP,
Windows 2000, Windows 2003, or Windows Vista® system, and execute
the file. If a browser is running while the installation is in progress, then
you must restart the browser before you can use the new plug-in.
• afpplgin.exe
Content Manager OnDemand AFP Web Viewer (Plugin/ActiveX);
supports all languages, double-byte character set (DBCS)
• afpplgin.zip
Content Manager OnDemand AFP Web Viewer (Plugin/ActiveX);
compressed format, supports all languages, DBCS
• imgplgin.exe
Content Manager OnDemand Image Web Viewer (Plugin/ActiveX);
supports all languages
It is beyond the scope of this book to discuss WEBi in details. The information
provided here is for reference purposes only.
Browser
WEBI
DHTML Components
Synchronous
AJAX
request/response
Struts/Tiles/XSLT Events
Java Struts Controller
Web Components
The following windows show some of the WEBi user interface so that you can
see the type of the application and user interface that you can create with the
ODWEK Java APIs. Figure 1-6 on page 19 shows a WEBi user interface with a
returned list of search result.
18 IBM Content Manager OnDemand Web Enablement Kit Java APIs: The Basics and Beyond
Figure 1-6 WEBi user interface
Figure 1-7 shows a sample WEBi window with a retrieved hand-written customer
inquiry.
Figure 1-7 Sample WEBi window showing a retrieved hand-written customer inquiry
Figure 1-9 shows a sample WEBi window with a retrieved bank statement.
20 IBM Content Manager OnDemand Web Enablement Kit Java APIs: The Basics and Beyond
2
The sections below survey the highlights of selected APIs. Consult the
Javadoc documentation for a complete list of available methods.
Data model classes expose the OnDemand data model and metadata that
relates to document storage. This group includes the following classes:
ODCabinet
ODFolder
ODApplication
ODApplicationGroup
ODApplicationGroupField
22 IBM Content Manager OnDemand Web Enablement Kit Java APIs: The Basics and Beyond
Search classes are used to perform document searches. This group includes the
following classes:
ODFolder
ODCriteria
ODNamedQuery
ODNamedQueryCriteria
Document data retrieval classes convey search results and are used to retrieve
OnDemand documents. This group includes the following classes:
ODHit
ODHitProperties
ODNote
The error handling class consists of the ODException class, which handles
Content Manager OnDemand exception errors.
getDocument ODNote
retrieve ODCallback
retrieveSegment
byte [ ] getLogicalView Functional relationships among ODConstant
ODLogicalView ODWEK Java API classes
01011... The highlighted path illustrates the typical
4. Retrieve document data connect-search-retrieve workflow Helper classes
In the next several sections, we take a closer look at some of these classes.
ODConfig
Use an instance of the ODConfig class to configure a connection to Content
Manager OnDemand. Prior to Content Manager OnDemand version 8.4, these
settings were specified in the arswww.ini file. In version 8.4, the proper way to
specify connection parameters is to use the ODConfig object.
With the parameters of the ODConfig class, you can specify such settings as the
conversion mechanism to be used for document data viewing, the ODWEK’s
temporary directory, and the level of detail for runtime log files.
24 IBM Content Manager OnDemand Web Enablement Kit Java APIs: The Basics and Beyond
The ODConfig class has three constructors:
ODConfig() with no parameters
Instantiating ODConfig with no parameters initializes the configuration with
default values (see Table 2-1).
ODConfig() with all parameters except the advanced properties
An ODConfig object can be instantiated with all the parameters listed in
Table 2-1 without specifying the optional properties. If there is no requirement
for AFP2PDF or AFP2WEB data conversions, then use this constructor.
ODConfig() with all parameters
If you want to use AFP2PDF or AFP2WEB document conversions, then pass
properties that specify AFP2xxx parameters.
Table 2-1 shows the meaning of the constructor parameters and their default
values.
String getAFPViewerType()
Get the AFP viewer type.
String getAppletDirectory()
Get the URL path or alias of the applet JAR file.
String getLanguageForMessages()
Get the three character language abbreviation for messages.
String getLineViewerType()
Get the Line viewer type.
long getMaxNumberOfHitsToDisplay()
Get the maximum number of search result hits.
String getMetaViewerType()
Get the META viewer type.
String getTemporaryWorkingDirectory()
Get the temp directory for OnDemand working files.
String getTraceDirectory()
Get the directory in which to place the arswww.trace files.
int getTraceLevel()
Get the trace level, which determines the detail of the
arswww.trace content.
void printConfig()
Print the configuration settings.
ODServer
The ODServer class manages a connection to an OnDemand server. No other
API class (except ODConfig) can be instantiated until a valid connection has
been established through the ODServer object. If a connection becomes invalid,
perhaps timed out due to inactivity, the same ODServer instance can be used to
log on again.
26 IBM Content Manager OnDemand Web Enablement Kit Java APIs: The Basics and Beyond
Prior to Content Manager OnDemand version 8.4, ODServer instances could be
instantiated with a no- argument constructor. With Version 8.4, you must pass an
ODConfig object to create new ODServer instances.
void cancel()
Cancel the current search or retrieve operation on this
connection.
java.util.Enumeration getCabinets()
(of ODCabinet instances) Get a list of the cabinets that are defined on the connected
server.
int getNumCabinets()
Get the number of cabinets that are defined on the
connected server.
int getNumFolders()
Get the number of folders that are defined on the
connected server.
java.util.Enumeration getFolders()
(of ODFolder instances) Get the folders that are defined on the connected server.
void logon()
Log on the configured user.
void logoff()
Log off the configured user.
void terminate()
Terminate this connection to the server.
boolean isServerTimedOut()
Get the timeout status of this connection.
boolean keepServerAlive()
Reset the connection timeout.
String[] getServerPrinters()
Get a list of printers that are defined on the server.
28 IBM Content Manager OnDemand Web Enablement Kit Java APIs: The Basics and Beyond
ODCabinet
ODCabinet instances represent Content Manager OnDemand cabinets, which
are defined by the administrator to group a particular set of folders for the
convenience of users. Obtain the list of cabinets for your server by calling the
ODServer.getCabinets() method. Remember that a folder can belong to multiple
cabinets. Searches cannot be performed against the ODCabinet class.
String getDescription()
Get this cabinet’s description.
String[] getFolderNames()
Get folder names for this cabinet.
Note: First call open() to populate the folder list.
String getName()
Get this cabinet’s name.
int getNumFolders()
Get the number of folders for this cabinet.
Note: Call the open() method first to retrieve the number of
folders for this cabinet.
void open()
Open this cabinet.
ODFolder
ODFolder instances represent Content Manager OnDemand folders. To obtain a
usable ODFolder instance, call ODServer.openFolder(). Instances of ODFolder
expose the server’s definition of folders, and the criteria used to search them for
documents. Searches are usually performed by setting values into ODCriteria
objects obtained from an ODFolder, and then calling the folder’s search()
method.
void open()
Open this folder.
void close()
Close this folder.
String[] getApplGrpNames()
Get the application groups for this folder.
java.util.Enumeration getCriteria()
(of ODCriteria instances) Get the search criteria for this folder.
String getDescription()
Get this folder’s description.
java.util.Vector getHits()
(of ODHit instances) Get the ODHit results of the last search performed
by this folder.
java.util.Enumeration getNamedQueryNames()
(of String) Get a list of named query names for this folder.
java.util.Vector search()
(of ODHit instances) Perform a search. Call after search criteria are set.
30 IBM Content Manager OnDemand Web Enablement Kit Java APIs: The Basics and Beyond
Data type returned Method and description
long searchCountHits()
Get the total number of hits that will be returned by
a search of this folder by using the
currently-specified criteria.
ODApplicationGroup
ODApplicationGroup instances correspond to Content Manager OnDemand
application groups. Obtain ODApplicationGroup instances by calling the
getApplicationGroup() method on an ODServer instance.
String[] getApplicationNames()
Get the names of all applications that are associated
with this application group.
String getDescription()
Get this application group’s description.
java.util.Enumeration getFields()
(of ODApplicationGroupField Get the fields that are defined in this application group.
instances)
String getName()
Get the name of this application group.
String getDescription()
Get this application’s description.
char getDocumentType()
(one of the FileTypeXXX constants Get the document type defined for this
defined in interface ODConstant; application.
see the Javadoc documentation)
String getName()
Get the name of this application.
ODApplicationGroupField
ODApplicationGroupField objects represent OnDemand application group fields.
Obtain instances by calling the ODApplicationGroup.getFields() or
ODApplicationGroup.getField() methods.
short getMask()
Get the mask for this application group Field.
String getName()
Get this application group Field’s name.
32 IBM Content Manager OnDemand Web Enablement Kit Java APIs: The Basics and Beyond
ODCriteria
Administrators define the search criteria, which ODCriteria objects represent,
that are relevant to a given folder. Obtain the set of ODCriteria instances that
pertain to a folder by calling the ODFolder.getCriteria() method. Then prepare a
search by setting the operator and search value or values for each ODCriteria
instance. Search values are passed as strings and are converted by the API for
comparison with the corresponding field when executing the search. Note that
not all operators apply to all data types.
String[] getApplicationGroupNames()
Get the application group names to which this ODCriteria is
mapped.
boolean getAscending()
Get the ascending/descending sort search type for this
criterion.
String[] getFixedValues()
Get valid search values for this criterion, if configured.
String getName()
Get this criterion’s name.
int getOperator()
Get this criterion’s current operator.
String[] getSearchValues()
Get this criterion’s current search values.
char getType()
Get the type for this criterion.
int[] getValidOperators()
Get the valid operators for this criterion.
boolean isRequired()
Determine whether a search value is required for this criterion.
boolean isQueryable()
Determine whether this criterion can be used to narrow a
search.
boolean isDisplayable()
Determine whether this criterion may be displayed to users.
ODNamedQuery
ODNamedQuery objects represent Content Manager OnDemand named
queries. Use ODNamedQuery objects in conjunction with ODFolder to retrieve or
execute existing named queries and save new named queries.
String getName()
Get this named query’s name.
int getNumCriteria()
Get the number of criteria that this named query
specifies.
Enumeration getCriteria()
(of ODNamedQueryCriteria) Get this named query’s criteria.
34 IBM Content Manager OnDemand Web Enablement Kit Java APIs: The Basics and Beyond
ODNamedQueryCriteria
ODNamedQueryCriteria objects represent the criteria of an OnDemand named
query. Obtain the criteria by calling the ODNamedQuery.getCriteria() method.
String getName()
Get the criterion name.
int getOperator()
Get the search operator.
String[] getSearchValues()
Get the search values.
ODHit
ODHit objects represent single Content Manager OnDemand document index
entries.
The ODFolder.search() method returns a Java vector that contains the hits, if any,
that satisfy the ODFolder object’s current search criteria. ODHit objects convey
criterion and display values for their containing folder’s index fields. The display
values are suitable for presentation to users. Be sure to adhere to the folder’s
display order so that the users’ view of document index data is consistent.
Each ODHit object stores a document ID (docid) that uniquely identifies the
document on the server. Given this document ID, you can obtain the
corresponding ODHit object with a call to the ODFolder.recreateHit() method.
Note that the document IDs are occasionally altered by server operations.
Therefore, it is unwise to store them indefinitely as persistent bookmarks.
char getDocType()
(one of the FileTypeXXX Get document type for this hit.
constants defined in interface
ODConstant; see the
Javadoc documentation)
byte[] getDocument()
Get document content for this hit.
String getFolderName()
Get the name of the folder associated with this hit.
String getMimeType()
Get the MIME type for the document referenced by this
hit.
Vector getNotes()
Get notes associated with the referenced document.
String[] getPrinterNames()
Get list of server printers specific to this hit.
ODHitProperties getProperties()
Get the OnDemand internal properties for this hit.
int getNumSegments()
Get number of segments for this hit.
String getDocId()
Get the persistent document ID.
Attention: If a document is updated or otherwise
modified, this document ID can and will change.
36 IBM Content Manager OnDemand Web Enablement Kit Java APIs: The Basics and Beyond
ODHitProperties
The ODHitProperties object represents internal property values of an ODHit
object. Obtain the property information by calling the ODHit.getProperties()
method.
String getApplicationGroupName()
Get the name of the referenced document’s application group.
String getApplicationName()
Get the name of the referenced document’s application.
long getLength()
Get the full length of the referenced document in bytes.
String getLoadName()
Get the load ID; this value is shared by all documents that are
loaded in the same arsload batch.
ODNote
ODNote objects convey OnDemand document notes. Obtain the document note
information by calling the ODHit.getNotes() method.
String getDateTime()
Get the date and time this note was created.
int getPageNum()
Get the page number for this note.
String getUserId()
Get the creator of this note.
boolean isPublic()
Get whether this note is public.
String getText()
Get this note’s text.
ODException
The ODException class is for all exceptions thrown by the ODWEK Java APIs. If
ODWEK’s logging is enabled, the APIs log diagnostic information to disk when an
ODException is created. Application programs should place all API calls within
try and catch blocks or at least bracket every logical unit of work such as a
document search.
When you catch an ODException, ensure that your application does not leak
native resources through the ODServer instance. That is, no ODServer can go
out of scope for garbage collection before its logoff() and terminate() methods
are called.
int getErrorId()
Get the error ID code.
String getErrorMsg()
Get the error message.
Tip: For information about Content Manager OnDemand error codes, see IBM
Content Manager OnDemand: Messages and Codes, SC27-1379, which
contains detailed descriptions. Although the guide lists the error codes with
the prefix ARS as used in the OnDemand system log, the integer maps
correctly to the error ID that is obtained from an ODException.
38 IBM Content Manager OnDemand Web Enablement Kit Java APIs: The Basics and Beyond
2.2 Sample console application
In this section, we show a simple console application that logs on to an
OnDemand server and lists the folders that have been defined. This program can
be used as a ping utility to test connectivity to the server.
When running this program from the command line, do not forget to specify the
java.library.path, so that Java can locate the ARS3WAPI.DLL file. The ICU
libraries are loaded via dependencies and must be in the default library search
path. Specify the java.library.path parameter by using the -D command line
option, as in the following example (on Windows):
java -classpath ".;C:\Program Files\IBM\OnDemand Web Enablement
Kit\api\ODApi.jar" ODPing -Djava.library.path="C:\Program
Files\IBM\OnDemand Web Enablement Kit\"
Example 2-1 shows the source code for the ODPing console application. After
you run this code, you see a message like the following example along with a list
of the folders that are defined on your OnDemand server:
import com.ibm.edms.od.ODConfig;
import com.ibm.edms.od.ODConstant;
import com.ibm.edms.od.ODException;
import com.ibm.edms.od.ODFolder;
import com.ibm.edms.od.ODServer;
/**
* This class demonstrates connecting to an OnDemand
* server using Version 8.4 of the ODWEK Java API
* by providing a simple ping console utility.
40 IBM Content Manager OnDemand Web Enablement Kit Java APIs: The Basics and Beyond
*/
public class ODPing
{
public static void main (String[] args) {
String serverName = "mydocserver"; // Name or IP address
String userId = "myUsername"; // User ID
String pwd = "myPassword"; // User password
int port = 1445; // Default port for OD. Configurable.
//
// Configure a new OnDemand server connection with
// the default configuration for this
// platform
//
ODServer odServer = new ODServer (new ODConfig ());
try {
//
// Set server and log-on credentials
//
odServer.setConnectType (ODConstant.CONNECT_TYPE_TCPIP);
odServer.setServerName (serverName); // Name or IP address
odServer.setPort (port);
odServer.setUserId (userId);
odServer.setPassword (pwd);
//
// Initialize the ODServer connection;
// once initialized, connection MUST be
// terminated when we're finished.
// Note use of this class' name, ODPing,
// as parameter to initialize().
//
odServer.initialize ("ODPing");
//
// Log on
//
odServer.logon ();
//
// Report ping status
//
System.out.println ("OnDemand server " +
odServer.getServerName () + " is alive");
//
// ALWAYS terminate connections that
// are no longer needed
//
odServer.terminate ();
}
}
42 IBM Content Manager OnDemand Web Enablement Kit Java APIs: The Basics and Beyond
throws Exception
{
Enumeration en = odServer.getFolders ();
while (en.hasMoreElements ()) {
System.out.println ("Folder: " +
((ODFolder) en.nextElement ()).getName ());
}
}
}
When running the application in your environment, make sure that you update
the sample file with your OnDemand server name, user ID, and password (as
indicated by use of the bold text in the sample code).
44 IBM Content Manager OnDemand Web Enablement Kit Java APIs: The Basics and Beyond
After the desired workspace is open, configure a new Web development project.
1. Switch to the Web perspective and create a new Web project:
a. Select File → New → Project → Dynamic Web Project.
b. In the Dynamic Web Project window (Figure 2-4), enter a project name. In
this scenario, we type ITSOWEK. Click Next.
46 IBM Content Manager OnDemand Web Enablement Kit Java APIs: The Basics and Beyond
d. In the Web Module window (Figure 2-6), if necessary, change to the Web
context to anything you want. Otherwise, accept the default values and
click Finish.
3. In the Edit System Variable window (Figure 2-8), update the path system
environment variable to include the <odwek installation root> directory by
using the method that is appropriate for your platform.
The ODWEK library consists of Java classes that rely on native components.
One method of referencing the native libraries is to update the system search
path to include the ODWEK installation directory.
Then click OK.
Figure 2-8 Updating the path system variable to include the ODWEK base installation
directory
48 IBM Content Manager OnDemand Web Enablement Kit Java APIs: The Basics and Beyond
4. Add the ITSO ear project (ITSOWEKEAR) to the test server:
a. Before you start the server, select the servers tab, right-click the
WebSphere® Application Server 6.1 server and select Add and
Remove Projects.
b. In the Add and Remove Projects window (Figure 2-9), in the Available
projects pane, select the ITSOWEKEAR project and click Add to add the
project to the Configured Projects pane. Click Finish to save the server
configuration.
50 IBM Content Manager OnDemand Web Enablement Kit Java APIs: The Basics and Beyond
Figure 2-11 Adding a new shared library
The project is ready to start adding Web components such as servlets and
JavaServer™ Pages.
Important: Use the code as is and at your own discretion. IBM will not provide
support for the example code.
In most cases, the examples that are discussed are depicted as code snippets
rather than the entire block of code for the Java class. No attempt is made to
create an application that can be used as-is in a production environment in this
chapter. The fact that servlets are used in these examples gives you the flexibility
to reuse the code snippets as you want within your own framework, such as
Struts, with minimal changes.
JSP files are used to render the Web pages. The focus of these discussions is on
the actual API calls to Content Manager OnDemand that are done at the servlet
level rather than the JSP level. Designing a JSP is not discussed in any detail.
54 IBM Content Manager OnDemand Web Enablement Kit Java APIs: The Basics and Beyond
Table 3-1 shows a list of the JSPs, servlets, utility files, and Java beans that are
used in the example program.
searchresults ODSearchEntry
hitproperties ODSearch
ODDisplayDocument
ODPassthru
ODOpenHit
Java beans
The com.ibm.itsowek.beans package contains Java classes that are used as
data Java beans for holding Content Manager OnDemand information as a result
of an API call. These bean classes hold information about different OnDemand
components such as a folder, cabinet, search criteria, search results, and a
document. Table 3-2 lists the beans.
Table 3-2 Beans
Name Description
ODListFolders Retrieves all cabinets and folders that a user has permissions
to view.
ODSearchEntry Retrieves the folder field information that a user can use for
document searches.
ODInit Default servlet that is invoked from the URL to display the logon
page.
ODPassthru Handles a line data applet or AFP viewer callback for document
content.
Utility packages
The com.ibm.istowek.utils package contains Java classes that are general
purpose utilities that act as helper classes to other classes within the application.
Table 3-4 lists the utilities.
Table 3-4 Utilities
Name Description
56 IBM Content Manager OnDemand Web Enablement Kit Java APIs: The Basics and Beyond
JSP files
It should be noted that all of the JSPs used in the examples are in the
WebContent folder in the ITSOWEK project. Table 3-5 shows the JSPs that are
used in these examples.
searchentry.JSP ODSearchEntry
searchresults.JSP ODSearch
hitproperties.JSP ODOpenHit
Throughout our examples, each servlet has the doGet and doPost methods
redirected to a processRequest method to handle either type of HTTP request as
shown in Example 3-1.
58 IBM Content Manager OnDemand Web Enablement Kit Java APIs: The Basics and Beyond
3.1.2 Program flow and control
Figure 3-1 shows a summary of the example program flow and control. We
explain the details of the program in the following sections.
ODServerConnection.getCabinets
Display list of folders listfolders.jsp ODListFolders
ODServerConnection.getFolders
Info button
Select button
ODServerConnection.getCabinets
ODServerConnection.getFolders
Enter search criteria searchentry.jsp ODSearchEntry
ODServerConnection.getCabinetFolders
ODServerConnection.getCriteriaInfo
ODDisplayDocument
Display document Info hitproperties.jsp ODServerConnection.getListProperties
*.jsp ODLogoff
Logoff button
logoff
web.xml ODListener
The ODConfig object replaces the need to have the arswww.ini configuration
settings read in by the application.
Consider the Web page rendered by the logon.jsp file as shown in Figure 3-2.
The user supplies the user ID and password and server name. The server name
can come from any method you choose. Typically, a list of available OnDemand
servers is displayed by name as a selection for the user to choose. These values
can come from a properties or XML file that is read in by the application. Then
the user clicks Logon.
synchronized (session) {
String userid = request.getParameter("userid");
String password = request.getParameter(“password”);
String server = request.getParameter(“server”);
ODServer odServer = null;
try {
// get the custom properties
Properties props = new java.util.Properties();
60 IBM Content Manager OnDemand Web Enablement Kit Java APIs: The Basics and Beyond
java.net.URL url =
ClassLoader.getSystemResource(“ODWEK.properties”);
props.load(url.openStream());
The servlet receives the request parameters and loads a custom properties file
that has application specific directives as shown in Example 3-3.
62 IBM Content Manager OnDemand Web Enablement Kit Java APIs: The Basics and Beyond
// logon to the ODServer
odServer.logon(server, userid, password);
return odServer;
After the servlet receives the new ODServer object, the reference is saved in the
session object as shown in the following example:
session.setAttribute(“odServer”, odServer);
Finally, if no exceptions are thrown, the servlet forwards the HTTP request and
response references to either another servlet or a JSP. In the case of a
successful OnDemand connection, the servlet forwards to the ODListFolders
servlet as shown in the following example:
request.getRequestDispatcher(“/ODListFolders”).forward(request,
response);
The following example shows how to display any existing cabinet and folder
information based on the logged on user’s permissions. The ODListFolders
servlet is used to gather information about cabinets and folders and uses the
listfolders.jsp file to render the results on a Web page.
synchronized (session) {
ODServer odServer = (ODServer) session.getAttribute(“odServer”);
try {
// get cabinets if any exist
ODServerConnection odServerConnection = new ODServerConnection();
List listCabinets = odServerConnection.getCabinets(odServer);
if (listCabinets != null) {
request.setAttribute(“cabinets”, listCabinets);
}
// get folders
List listFolders = odServerConnection.getFolders(odServer);
if (listFolders != null) {
request.setAttribute(“folders”, listFolders);
}
}
64 IBM Content Manager OnDemand Web Enablement Kit Java APIs: The Basics and Beyond
odCabinetBean.setFolderNames(Arrays.asList(cabinet.getFolderNames()));
listCabinets.add(odCabinetBean);
}
return listCabinets;
By using the JSTL taglib, the JSP can iterate through the list of ODCabinet and
ODFolder beans as shown in Example 3-8.
66 IBM Content Manager OnDemand Web Enablement Kit Java APIs: The Basics and Beyond
In our example, each ODFolder object that is displayed can select the Info button
in the listfolders.jsp file. This action invokes the ODFolderInfo servlet
processRequest method as shown in Example 3-9.
synchronized (session) {
ODServer odServer = (ODServer) session.getAttribute("odServer");
try {
String folderName = request.getParameter("folder");
stringOrder = odFolder.getDisplayOrder();
odFolderBean.setDisplayOrder(ODUtils.stringArray(stringOrder, "|"));
stringOrder = odFolder.getQueryOrder();
odFolderBean.setQueryOrder(ODUtils.stringArray(stringOrder, "|"));
68 IBM Content Manager OnDemand Web Enablement Kit Java APIs: The Basics and Beyond
</tr>
<tr>
<td>Max Hits</td>
<td>${folderinfo.maxHits}</td>
</tr>
</TABLE>
</c:if>
4-ODListFolders
8- ODFolderInfo
Figure 3-5 Program flow for connecting to the server and displaying the list of folders
Our example shows how to retrieve the folder fields for display purposes so that a
user can complete the appropriate search information. The ODSearchEntry
servlet retrieves folder field information to be displayed in the searchentry.jsp file.
The user invokes the ODSearchEntry.processRequest() method by clicking the
Search Criteria link from the listfolders.jsp file.
70 IBM Content Manager OnDemand Web Enablement Kit Java APIs: The Basics and Beyond
In this example, the user is given the ability to select a folder from a cabinet to
search or to select any folder that the user has permissions to search. For any
folder that is chosen, the ODSearchEntry servlet retrieves a list of ODCriteria
objects, which represent information about each OnDemand folder field, as
shown in Example 3-12.
synchronized (session) {
ODServer odServer = (ODServer) session.getAttribute("odServer");
String selectedCabinetName = request.getParameter("Cabinet");
String selectedFolderName = request.getParameter("Folder");
try {
ODServerConnection odServerConnection = new ODServerConnection();
// get cabinets if any exist
if (selectedCabinetName != null) {
List listCabinets = odServerConnection.getCabinets(odServer);
if (listCabinets != null) {
request.setAttribute("cabinets", listCabinets);
}
}
// get all alll folders for display or get only cabinet folders
List listFolders = null;
if (!selectedCabinetName.equals("List All Folders")) {
listFolders = odServerConnection.getFolders(odServer);
}
else {
listFolders = odServerConnection.getCabinetFolders(odServer,
selectedCabinetName);
}
if (listFolders != null) {
request.setAttribute("folders", listFolders);
}
// get criteria
List listCriteria = odServerConnection.getCriteriaInfo(odServer,
selectedFolderName);
if (listCriteria != null) {
request.setAttribute("criterias", listCriteria);
}
}
return listFolders;
72 IBM Content Manager OnDemand Web Enablement Kit Java APIs: The Basics and Beyond
char typeCriteria = criteria.getType();
odCriteriaBean.setTypeName(ODUtils.getTypeName(typeCriteria));
// get the operators that have been defined for this field
int opers[] = criteria.getValidOperators();
String[] validOperatorNames = new String[opers.length];
for (int i = 0; i < opers.length; i++) {
validOperatorNames[i] = ODUtils.operatorName(opers[i]);
}
odCriteriaBean.setValidOperatorNames(Arrays.asList(validOperatorNames))
;
listCriterias.add(odCriteriaBean);
}
}
return listCriterias;
Our example shows how to receive search information from the searchentry.jsp
file and perform a search to obtain a list of objects that represent OnDemand
content such as a document. The ODSearch servlet receives search information
from the searchentry.jsp file and performs the folder search.
The ODSearch servlet receives the search values and folder names from the
searchentry.jsp file. The servlet iterates across each ODCriteria object in the
folder and sets each folder field’s value or values based on whether the value
was specified in the searchentry.jsp file as shown in Example 3-15 on page 75.
74 IBM Content Manager OnDemand Web Enablement Kit Java APIs: The Basics and Beyond
Example 3-15 ODSearch servlet code snippet
HttpSession session = request.getSession();
synchronized (session) {
ODServer odServer = (ODServer) session.getAttribute("odServer");
String selectedFolderName = request.getParameter("Folder");
String sqlStatement = request.getParameter("SQL_Statement");
String applGroup = request.getParameter("appl_group");
String value = null;
try {
// open the selected folder
ODFolder odFolder = odServer.openFolder(selectedFolderName);
ODFolderBean odFolderBean = new ODFolderBean();
String[] folderFieldDisplayNames = odFolder.getDisplayOrder();
odFolderBean.setDisplayOrderArray(folderFieldDisplayNames);
odFolderBean.setName(selectedFolderName);
if (sqlStatement != null) {
odFolder.setApplGroupForSearchWithSQL(applGroup);
}
else {
for (Enumeration criteria_enum = odFolder.getCriteria();
criteria_enum.hasMoreElements();) {
criteria.setOperator(oper);
// The parameter 'Name_2' will have the second value for
// the BETWEEN/NOTBETWEEN operators
if (oper == ODConstant.OPBetween || oper ==
ODConstant.OPNotBetween) {
}
else {
// Just set the one value for the search
criteria.setSearchValue(value);
}
}
}
if (request.getParameter("andOr").equals("OR")) {
odFolder.setOrSearchCriteria(true);
}
else {
odFolder.setOrSearchCriteria(false);
}
}
// Return the search result vector after all criteria is set.
ODServerConnection odServerConnection = new ODServerConnection();
List listHits = odServerConnection.getSearchResults(odServer,
odFolder, sqlStatement,
odFolderBean.getDisplayOrderArray());
if (listHits != null) {
request.setAttribute("hits", listHits);
}
if (odFolder != null) {
session.setAttribute("folderbean", odFolderBean);
}
}
76 IBM Content Manager OnDemand Web Enablement Kit Java APIs: The Basics and Beyond
When the folder field (ODCriteria) values are set, the ODSearch servlet calls the
ODServerConnection.getSearchResults() method to perform the OnDemand
search. This method generates a list of ODHit objects that represent the
OnDemand document information that is returned from a successful search as
shown in Example 3-16.
// for each folder field to display, get the field value for
display
String[] displayVals = new
String[folderFieldDisplayNames.length];
for (int i = 0; i < folderFieldDisplayNames.length; i++) {
displayVals[i] =
odHit.getDisplayValue(folderFieldDisplayNames[i]);
}
odHitBean.setDisplayCriteria(displayVals);
listHits.add(odHitBean);
}
}
return listHits;
78 IBM Content Manager OnDemand Web Enablement Kit Java APIs: The Basics and Beyond
Figure 3-8 shows a summary of how the application displays folder search fields
and lists the search results.
1-listfolders.jsp
Select Search Criteria link
Servlets
com.ibm.itsowek.servlets
2-ODSearchEntry
Utilities
ODSearchEntry.processRequest
com.ibm.itsowek.utils
// get criteria
List listCriteria = odServerConnection.getCriteriaInfo(odServer, selectedFolderName); 6-ODServerConnection.getCriteriaInfo
return return listCriterias;
ODCriteria objects
ODCriteria objects
ODCriteria objects
7-searchentry.jsp.
Display Folder field information
Select folder search values and
folder names 8-ODSearch
List listHits = odServerConnection.getSearchResults(… 9-odServerConnection.getSearchResults
… return listHits;
ODHit objects
10- searchresults.jsp ODHit objects
ODHit objects
Display the document hit list
Figure 3-8 Program flow for displaying search fields and listing the search results
synchronized (session) {
try {
ODServer odServer = (ODServer) session.getAttribute("odServer");
String folderName = request.getParameter("folder");
String docId = request.getParameter("docid");
response.setContentType(odHitBean.getMimeType());
80 IBM Content Manager OnDemand Web Enablement Kit Java APIs: The Basics and Beyond
The servlet calls the retrieve() method to retrieve the content of the OnDemand
document as a byte array. This method is also used to retrieve document
information as shown in Example 3-18.
return odHitBean;
82 IBM Content Manager OnDemand Web Enablement Kit Java APIs: The Basics and Beyond
Example 3-19 ODServerConnection.getHitProps() method code snippet
odHitBean.setResourceID(odHit.getResourceID());
odHitBean.setViewerType(ODUtils.getViewerTypeString(odHit.getViewerType
()));
odHitBean.setViewExt(odHit.getViewExt());
ODHitProperties hitProps = odHit.getProperties();
odHitBean.setLength(String.valueOf(hitProps.getLength()));
odHitBean.setCompLength(String.valueOf(hitProps.getCompLength()));
odHitBean.setCompOffset(String.valueOf(hitProps.getCompOffset()));
odHitBean.setOffset(String.valueOf(hitProps.getOffset()));
odHitBean.setLoadName(hitProps.getLoadName());
odHitBean.setStartDate(hitProps.getStartDate());
odHitBean.setEndDate(hitProps.getEndDate());
odHitBean.setTableName(hitProps.getTableName());
return odHitBean;
odHitBean.setViewMimeType(odHit.getViewMimeType());
When the applet is invoked by the browser for the first time, it prompts the user
with a certificate for approval to run locally on the user’s machine. When the
applet is loaded, it makes callbacks to the Web application to retrieve the
document content and format it locally. The applet makes a callback to a servlet
that is identified when the ODServer object was initialized. We initialized the
ODServer object as shown in the following example:
odServer.initialize(new StringBuffer()
.append("/").append(contextRoot).append("/ODPassthru").toString());
Line data can be searched and retrieved from the Loan Delinquency Reports LO
folder and searched by the default criteria set by the administrator. Figure 3-11
on page 85 shows the search results page.
84 IBM Content Manager OnDemand Web Enablement Kit Java APIs: The Basics and Beyond
Figure 3-11 The rendered searcresults.jsp page
When a user wants to display a line document, the applet is retrieved, and the
call back is made from within the HTML as shown in Example 3-20.
"v7126-9241-9243-9242-NOB1-1FAAA%24-0-1446-25257-6849-85-79-0-1-0-%5E%0
19040%0110000%011000999",
"plugin",
"0");
</script>
</body>
</html>
synchronized (session) {
try {
ODServer odServer = (ODServer) session.getAttribute("odServer");
byte[] results =
odServer.viewerPassthru(request.getQueryString());
OutputStream outputStream = response.getOutputStream();
outputStream.write(results);
}
86 IBM Content Manager OnDemand Web Enablement Kit Java APIs: The Basics and Beyond
Figure 3-12 shows the document as displayed by using the applet viewer.
1- searchresults.jsp
Display the document hit list Servlets
Select a document com.ibm.itsowek.servlets
or
Select the info button 2-ODDisplayDocument
// find selected document within ODHiit objects
String docId = request.getParameter("docid");
Utilities
// use the docid to retrieve the document com.ibm.itsowek.utils
ODHitBean odHitBean = odServerConnection.getDocument(..);
3-odServerConnection.getDocument
hitproperties.jsp
A-ODServerConnection.getHitProps
// get document properties
ODHitProperties hitProps = odHit.getProperties();
return odHitBean;
88 IBM Content Manager OnDemand Web Enablement Kit Java APIs: The Basics and Beyond
The ODLogoff servlet is invoked whenever a user selects to log off their
OnDemand connection from any of the JSP files. The application should always
try to perform the ODServer.logoff() and ODServer.terminate() methods as
shown in Example 3-22. These methods clean up user connections and enable
the shared libraries to free up allocated native system memory.
synchronized (session) {
ODServer odServer = (ODServer) session.getAttribute("odServer");
try {
if (odServer != null) {
odServer.logoff();
odServer.terminate();
}
session.removeAttribute("odServer");
session.removeAttribute("folderbean");
}
Figure 3-14 shows a summary of how the application disconnects from the
OnDemand server.
Servlets
com.ibm.itsowek.servlets
ODSessionListener
public void sessionCreated(HttpSessionEvent sessionEvent)
Invalid HttpSession object invoked logoff {
if (odServer != null)
{
web.xml
odServer.logoff();
// create session istener
odServer.terminate();
<listener-class>com.ibm.itsowek.utils.ODSessionListener</listener-class>
}
}
90 IBM Content Manager OnDemand Web Enablement Kit Java APIs: The Basics and Beyond
4
The customer is usually a user who is registered to the company’s Web site. The
registration process gives entitlement back to the user in the form of credentials,
perhaps a user ID and password. To gain access to the company applications,
the user submits their credentials from a Web page, such as a portal, to be
authenticated by the company’s Web application. After the user is authenticated,
the application places constraints on what tasks the user can perform when
navigating the Web site.
Currently Content Manager OnDemand requires each user who needs access to
have a defined user ID. However, it is not manageable to create an OnDemand
user ID for each registered Internet user. The user population can reach into the
thousands or millions. Therefore, most applications perform a search on behalf of
a user by using a user ID that has the permissions to search a specific folder and
retrieve one or more documents. The assumption is that if the user is
authenticated, and the constraints are placed on the search values to guarantee
unique results, then one or more user IDs can be defined to have full permissions
to the folder that is searched.
92 IBM Content Manager OnDemand Web Enablement Kit Java APIs: The Basics and Beyond
viewer program locally installed on their machine, or data conversion must
occur to provide a data stream that is more palatable for viewing. In many
cases, transforms are performed by the application, such as AFP to PDF, to
make it easier for the user to view. The PDF viewer is easily obtainable if it is
not already installed on the user’s machine. The AFP viewer, from a plug-in
for example, might be more difficult to obtain and manage by the company
that is providing the Web service.
The examples in Chapter 3, “ODWEK Java API examples” on page 53, do not
show connection pooling, but show methods on how to save the ODServer
connection in the HttpServletSession object. This gives the sense of persisting
the user’s connection throughout their set of transactions. The application is
dependent upon detecting a session termination by either the user explicitly
selecting a logoff link or by another condition such as a session time-out that
invokes the HTTP session listener implementation.
Implementing a connection pool can take on many different designs. While there
are several methods to implement connection pooling, the method that is
selected is based on a design decision made by the architects. The example in
this chapter shows a pool of OnDemand connections that are created
automatically during the initialization of a servlet. The connections are retrieved
and returned during the doGet and doPost methods. All of the OnDemand
connections are terminated after the servlet instance is destroyed. Either the
connection pool or the application can own the responsibility of creating and
opening the ODFolder object. In our example, the application creates the
ODFolder object.
The connections in the pool are represented by ODServer object instances. For
internet users, such as banking customers, where all of the statements are
accessed from one OnDemand folder, the connection pool can be extended to
also open the folder as part of creating the ODServer instance. For applications
where the OnDemand folder is selected at random by the user, then it might
make more sense to open the folder outside of the connection pooling
implementation.
94 IBM Content Manager OnDemand Web Enablement Kit Java APIs: The Basics and Beyond
Our example uses an ODConnectionPool class to manage the OnDemand
server connections. when the servlet initializes, it calls the ODConnectionPool
constructor to create a predefined number of ODServer connections as shown
Example 4-1.
this.maxConnections = maxConnections;
this.waitIfBusy = waitIfBusy;
...code...
private ODServer makeNewConnection() throws Exception {
try {
// get the custom afp2pdf transform properties
String transformPropsName =
myProps.getProperty("TransformProperties");
Properties transformProps = new Properties();
transformProps.load(new FileInputStream(transformPropsName));
if (!existingConnection.isInitialized()) {
notifyAll(); // Freed up a spot for anybody waiting
96 IBM Content Manager OnDemand Web Enablement Kit Java APIs: The Basics and Beyond
return (getConnection());
}
else {
busyConnections.addElement(existingConnection);
return (existingConnection);
}
}
else {
// Three possible cases:
// 1) You haven't reached maxConnections limit. So
// establish one in the background if there isn't
// already one pending, then wait for
// the next available connection (whether or not
// it was the newly established one).
// 2) You reached maxConnections limit and waitIfBusy
// flag is false. Throw SQLException in such a case.
// 3) You reached maxConnections limit and waitIfBusy
// flag is true. Then do the same thing as in second
// part of step 1: wait for next available connection.
try {
System.out.println(" Please wait...");
wait();
}
catch (InterruptedException ie) {
}
After the user enters their credentials, an authentication process can occur. We
simulated this by calling an ODAuthenticate servlet (Example 4-3). The servlet
calls another process to authenticate the user and returns the user’s account
number in order for our application to perform a search that is unique to the user.
The account number is a folder field. When this field is searched by a given
value, all of the results are returned for the specified account number value.
// test
String accountNumber = request.getParameter("testacct");
request.setAttribute("accountnumber", accountNumber);
// end test
}
For this example, all statements are defined to one OnDemand folder. Two folder
field names are used to perform the searches. Rather than try to discover the
folder field names by iterating through the list of ODCriteria objects as we did in
98 IBM Content Manager OnDemand Web Enablement Kit Java APIs: The Basics and Beyond
Chapter 3, “ODWEK Java API examples” on page 53, we identify those fields in a
properties file to improve performance. The OnDemand administrator must keep
the application developer aware of any changes to the folder name or folder field.
The servlet init method is invoked whenever the servlet is first instantiated. We
elected to have the servlet loaded during the application server startup as shown
in the following Web.xml configuration file:
<load-on-startup>-1</load-on-startup>
synchronized (session) {
ODServer odServer = null;
ODFolder odFolder = null;
try {
100 IBM Content Manager OnDemand Web Enablement Kit Java APIs: The Basics and Beyond
odFolder.setOrSearchCriteria(false);
// perform search
ODFolderBean odFolderBean = new ODFolderBean();
String[] folderFieldDisplayNames = odFolder.getDisplayOrder();
odFolderBean.setDisplayOrderArray(odFolder.getDisplayOrder());
}
else {
odFolderBean.setDisplayOrderArray(userDisplayFields);
}
.getDisplayOrderArray());
if (listHits != null) {
request.setAttribute("hits", listHits);
}
// odFolderBean.setDisplayOrderArray(folderFieldDisplayNames);
session.setAttribute("folderbean", odFolderBean);
odFolder.close();
request.getRequestDispatcher("/searchresultsexternal.jsp").forward(requ
est, response);
}
else {
if (requestFunction != null &&
requestFunction.equals("displaydoc")) {
// get request parameters
String docId = request.getParameter("docid");
In this case, the user is presented with a list of statements for the last six months.
The user can click the Display button, and the ODSearchRetrieve servlet is
102 IBM Content Manager OnDemand Web Enablement Kit Java APIs: The Basics and Beyond
invoked, but this time with a request parameter to displaydoc. The servlet
requests an OnDemand connection from the connection pool and retrieves the
document by using the document ID that passed in from the
searchresultsexternal.jsp file. This action might not be desirable for some Web
applications. As discussed in Chapter 3, “ODWEK Java API examples” on
page 53, another technique is to create a list of ODHit objects that can be
maintained in some way on the server. Instead of sending the document ID as
part of the search results, the search results JSP sends the relative location of
the selected document. The search servlet matches the selected relative location
with the ODHit object in the saved list.
In this example, we convert the AFP data stream to PDF by calling the AFP2PDF
transformation utility. This is accomplished by either how the ODConfig object
properties are set or how the retrieve method is invoked on the ODHit object.
When we determine that the file type is AFP, we set the ODHit object viewer to
PDF (Example 4-6).
Figure 4-3 shows the results of the AFP document being transformed and
displayed as a PDF document by using Adobe® Reader.
104 IBM Content Manager OnDemand Web Enablement Kit Java APIs: The Basics and Beyond
Part 2
Resource allocation and memory problems occur in applications that fail to open
and close connections to the OnDemand server in an appropriate manner. We
also provide a detailed understanding of the allocation of resources by Content
Manager OnDemand connections and explain how to create and terminate
connections properly.
Chapter 7, “Globalization”
Many OnDemand servers store documents in multiple languages and serve
clients with different languages, locales, and character sets. To ensure successful
implementation of the OnDemand system, you must understand and take into
consideration the usage of different encoding schemes and conversions.
108 IBM Content Manager OnDemand Web Enablement Kit Java APIs: The Basics and Beyond
Chapter 9, “Document retrieval”
After documents are located, they can be retrieved and displayed to users.
Documents are stored in Content Manager OnDemand either as a unit or in
segments (for OnDemand large documents), in which case the segments are
retrieved sequentially.
In this chapter, we explain how the plugs-ins and transforms are used in
document retrieval. We pay special attention to AFP resources and large objects.
In this chapter, we discuss these APIs and address care that you must take when
performing server updates using the APIs.
110 IBM Content Manager OnDemand Web Enablement Kit Java APIs: The Basics and Beyond
6
Connection pooling allows for the reduction of resource consumption through the
re-use of objects by multiple incoming connections (user requests). Therefore,
the use of connection pooling improves performance.
If we do the same logon and the same folder open thousands of times per hour, it
is more efficient to perform these requests only a few times and store the results
in a pool that can be re-used over and over again.
112 IBM Content Manager OnDemand Web Enablement Kit Java APIs: The Basics and Beyond
Connection pooling helps to reduce CPU consumption.
The Web server issues fewer requests since the pooled objects are already
available. The processing of fewer requests results in a reduction in CPU
consumption. The OnDemand server also receives fewer requests and thus
consumes fewer CPU resources.
Connection pooling helps to improve response time.
Accessing the pooled objects directly on the Web server is much faster than
retrieving another copy of the objects from the OnDemand server. When a
request is sent to the OnDemand server, it executes faster because fewer
requests are issued against the server.
Connection pooling helps to reduce network traffic.
Reduced network traffic is the result of the reduced number of requests and
responses that are sent over the network. The reduction in network traffic can
also lead to improved network throughput.
The main class that represents an OnDemand session is the ODServer class.
Each ODServer class can handle a connection and a login to a single
OnDemand server.
The ODServer class provides five important methods for connection and session
handling:
constructor
All configuration data is passed to the constructor. No other method exists to
change the configuration data. The ODConfig object is instantiated within the
constructor and acts as a container for the configuration data for the specific
session.
114 IBM Content Manager OnDemand Web Enablement Kit Java APIs: The Basics and Beyond
Figure 6-1 illustrates the relationship between threads, methods, and objects for
two cases, batch and interactive cases. There are many different interaction
possibilities and flow scenarios that can result in different thread allocations.
Time
Logon ODServer Logon ODServer
Start thread
Folder search End thread Folder search
Start thread
Hit list ODHit End thread Hit list ODHit
Start thread
Document retrieve End thread Document retrieve
Start thread
Logoff End thread Logoff
End thread
Figure 6-1 Content Manager OnDemand threads, methods, and objects (simplified)
The left side of Figure 6-1 shows the batch case. In this case, a batch program
issues the API requests sequentially, logon through logoff. All the requests run on
a single thread. All of the objects are created as needed and are destroyed when
the program terminates.
The right side of the diagram in Figure 6-1 illustrates the interactive case, which
is also known as the conversational case. This case can be thought of as a Web
server application that supports a set of pages in a browser through which users
can enter their requests and view the retrieved data.
When a user enters a user ID and password on the logon page, a servlet is
invoked on its own thread in the Web server. The servlet calls both the initialize
and the logon methods, which results in the creation of two objects, ODConfig
and ODServer. By using the ODServer object, a folder list is obtained and
downloaded to the browser for display, at which point, the Web server thread is
Time
Time
End thread Folder list End thread Folder list End thread Folder list
116 IBM Content Manager OnDemand Web Enablement Kit Java APIs: The Basics and Beyond
6.2.3 The ODWEK Java API pool levels
The concept of connection pooling entails locally storing objects that can be used
by multiple users, thus avoiding continuous requests for the same objects from
the server. When looking at the ODWEK Java API objects, in general, there are
three connection pool usage scenarios, which are summarized in Table 6-1.
The most basic connection pooling level is at the ODServer object level. The
ODServer object is created and initialized and is common to all types of user
access to the Java APIs. Each user must then be logged on and off between
transactions. Pooling at this level is beneficial in the intranet case where there are
have tens of thousands of users, each of whom has their own Content Manager
OnDemand IDs and permissions.
If the ODServer objects in the pool are used in an environment where you can
map multiple users to a single user ID, then these objects can be initialized and
logged on. Rather than logging off the user between requests, the ODServer
object stays logged on between requests. After the user request is completed,
the ODServer object is returned to the pool and is available for subsequent
requests.
If the ODServer objects in the pool are used in an environment where you can
map multiple users to a single user ID and where users all access the same
folder (online billing, as a prime example), then all ODServer objects that are
stored in the pool should have their folder left open. The application developer
must know the folder name and be able to obtain the ODFolder without
re-opening the folder. In this case, the application developer must collect and
store the folder name somewhere, for example, in the session object.
Important: The example code presented in this section is not intended for
use. Its purpose is only to illustrate the concepts of connection pooling.
Status ODServers
-Application releases
Status=1 OdServer object pooled object
118 IBM Content Manager OnDemand Web Enablement Kit Java APIs: The Basics and Beyond
When the connection pool class (ODPool) is instantiated, a predetermined
number of ODServer objects are created, initialized, and logged on to the
OnDemand server. These objects are then stored in the ODServers array.
Additionally, a second array (the Status array) is created in which the status of
these objects is stored. The initial status value for all of the created objects is set
to 1. This indicates that the objects were created and are available for use by the
Web server application program.
When the Web server code requests an ODServer object from the pool, the
ODServer object is retrieved from the ODServer array and then forwarded to the
Web server application. The status of the object in the Status array is changed
from a 1 to a 2 indicating that the object is in use. The pool code searches for an
available object from the beginning of the array. Thus the objects at the beginning
of the array are used more frequently than the objects toward the end of the
array.
When the Web server application is finished using the ODServer object, the
application returns the ODServer object to the pool. The connection pool code
then changes the ODServer status for that object from 2 to 1, indicating that the
object is now available for reuse.
The use of arrays is one of multiple mechanisms that are available for object
storage. Other collection storage methods, such as vectors or hash tables, are
also feasible.
ODPool
2- Application getODServer
uses and
releases ODServer ODServers
ODServer
objects putODServer ODServer
ODServer
3- Application Status
periodically toString
retrieves ODPool
status and
ensures that all
servers are active keepServersAlive
terminateServers
120 IBM Content Manager OnDemand Web Enablement Kit Java APIs: The Basics and Beyond
Release a connection.
This function is implemented in the putODServer() method. The ODServer
object is returned to the pool. The ODPool code then changes the Status
array value to indicate that the ODServer object is now available for reuse.
Keep the pool connections alive.
This function is accomplished by polling the OnDemand server from each of
the ODServer objects at predefined intervals. Alternatively, connections can
be prevented from timing out by setting the OnDemand server timeout period
to “Never time out.” Pooled connections do not timeout unless some
mechanism that is external to the ODPool code forces the time out.
Get the current ODPool status.
The toString() method returns the current pool information including the
maximum used and currently used server objects.
Shut down the connection pool.
The terminateServers() method closes down all the server connections prior
to terminating the ODPool code.
The code must include a reference to the package that contains the ODApi.jar
file:
package com.ibm.edms.od;
String username User ID with correct privileges to service all users requests
The constructor creates a new ODServer object. It then initializes the object and
performs an odServer.logon() method to log on to the OnDemand server. After
the successful logon, the object is stored in the ODServers array. The ODServer
object’s status is updated to Available in the Status array, and the number of
available servers (availableServers) is incremented by one.
Any method that uses the ODServer object in the future does not have to go
through the initialization and server logon process again.
Example 6-1 shows the code snippet for the ODPool() constructor method.
this.username = username;
this.password = password;
this.maxServers = maxServers;
availableServers =0;
122 IBM Content Manager OnDemand Web Enablement Kit Java APIs: The Basics and Beyond
try
{
/* place the ODServer objects in the array */
for( int i=0; i<maxServers; i++ )
{
// create the odConfig object
ODConfig odConfig = new ODConfig();
catch(ODException e)
{
throw new ODException("createPool error: " + e);
}
124 IBM Content Manager OnDemand Web Enablement Kit Java APIs: The Basics and Beyond
System.out.println("No Servers available.. need to specify higher
maxServers");
throw new Exception("Connection limit reached");
}
} // end method getODServer
try
{
// check to see that odserver is still connected
if (!odServer.isInitialized())
{
// logoff then logon
odServer.logoff();
odServer.logon(server, username, password);
}
else
{
// just keep the server alive
odServer.keepServerAlive();
}
// place ODServer back in array
ODServers[i] = odServer;
}
catch(ODException e2)
{
throw new ODException("keepServersAlive error: " + e2);
}
} // end if (Status[i]
} // end for (int i=0
126 IBM Content Manager OnDemand Web Enablement Kit Java APIs: The Basics and Beyond
The toString() method
The toString() method (Example 6-5) returns information about the ODPool
including the user name, current ODServer objects in use, maximum number of
ODServer objects in use, and size of the ODPool (maxObjects). maxObjects is
the maximum number of concurrent connections, which is the same as the
maximum number of ODServer objects.
return(info);
} // end method toString
By setting the appropriate pool size, you can ensure optimum usage of
connection pooling in your environment.
The ODPool class must support both multithreading and object synchronization.
You must fully understand these two concepts and implement them within your
Web server application.
As illustrated in Figure 6-1 on page 115 and Figure 6-2 on page 116, running the
Java APIs in a multi-user environment results in the creation of many threads and
many objects within the ODWEK Java APIs and the Web server application code.
The number of concurrent threads and in-memory objects varies depending on
the design and usage pattern of the system. However, it is safe to say that there
will be many of each. To ensure the proper operation of the system, you must
ensure thread safety.
128 IBM Content Manager OnDemand Web Enablement Kit Java APIs: The Basics and Beyond
6.4.1 Instance variables
The Java virtual machine (JVM™) keeps local variables, method parameters,
and return values on the Java stack, and each thread has its own stack.
Therefore, no thread can harm another thread’s stack. This is what we call
thread-safe.
Instance variables and class variables are only thread-safe if they are private. By
making them private, you can control access to the data by controlling access to
the code that manipulates the data.
Read-only data does not need to be private. For example, constants, such as
static final variables, do not change. They are read only, and therefore, cannot be
corrupted by multiple threads that access them at the same time.
The ODWEK Java APIs are no exception. The APIs are grouped into classes of
objects. The object instance must only be accessed by a single thread at a time.
Therefore, each thread instance has its own object instance for all the Java API
objects.
6.4.2 Synchronization
A critical section of code is a method or a block of code that must be executed
atomically as a single, indivisible operation. By declaring the method to be
synchronized by using the synchronized keyword, only one thread at a time is
allowed to execute that method. By using synchronized objects, you can use
wait() and notify() methods to get threads to cooperate in achieving some
common goal.
Since ODWEK version 7.1.2.7, all API functions are fully synchronized and
thread safe. All operations within the API are synchronized. The only exception is
the ODServer.cancel() method, which is discussed further in 6.6.3,
“Implementing an application timeout by using the ODServer.cancel() method”
on page 140.
However, you cannot regard the synchronization that is built into the ODWEK
Java APIs as the only level of synchronization when building Web applications.
When each call to a servlet is wrapped in its own thread, ensure that each thread
uses the right ODServer instance. In Web applications, you typically keep the
ODServer object within the Web application server session data, which enables
the threads to have access to the right ODServer objects that belong to the user
session.
Guaranteeing a single ODServer instance per session does not eliminate the
threading issue. A common issue in Web application is when users mistakenly
submit multiple identical transactions. Examples include when a user clicks the
Submit button of a form multiple times, when a user clicks the browser Stop
button and resubmits a transaction, and when a user clicks a link several times.
Each operation creates multiple transactions at a mid-tier level and a new thread.
Each thread accesses the same ODServer instance, which violates the ODWEK
Java API requirements of one thread at a time per ODServer instance.
Subsequent access by multiple threads is blocked through the synchronization at
130 IBM Content Manager OnDemand Web Enablement Kit Java APIs: The Basics and Beyond
the API level. To prevent possible loss of data or unexpected behavior, you must
implement synchronization handling on the session object.
wwwsession= req.getSession(true);
synchronized(wwwsession) {
odserver = (ODServer)wwwsession.getAttribute("ODServer");
ODFolder fld = odserver.openFolder("Statements");
...
}
...
}
132 IBM Content Manager OnDemand Web Enablement Kit Java APIs: The Basics and Beyond
Initialization steps
An ODWEK session can be initialized with the following actions:
1. An ODConfig object is instantiated and its configuration data is set.
2. An ODServer object is created, specifying the ODConfig object as a
constructor parameter.
3. The ODServer.initialize() method is called to initialize a new Content Manager
OnDemand client session, which then can be used to perform a logon to an
OnDemand server.
The ODConfig object contains the configuration data and makes the
configuration reusable when creating multiple sessions. ODConfig objects are
configured though the constructor. An ODConfig object cannot be reconfigured,
but its configuration can be queried by using multiple methods.
ODConfig parameters
The ODConfig class supports three constructors:
ODConfig()
The ODConfig() constructor initializes the object by using the default
configuration values.
ODConfig(String afpViewer, String lineViewer, String metaViewer,
long maxHits, String appletDir, String language, String tempDir,
String traceDir, int traceLevel)
This ODConfig constructor is the default when specifying a custom
configuration. All standard configuration settings that are available in ODWEK
are represented by the parameters.
ODConfig(String afpViewer, String lineViewer, String metaViewer,
long maxHits, String appletDir, String language, String tempDir,
String traceDir, int traceLevel, java.util.Properties props)
This ODConfig constructor requires the same configuration options as the
previous one, but includes a Properties object, which can hold additional
properties. The Properties object is used for providing configuration data for
the AFP2WEB and Xenos transformations.
afpViewer ODConstant.PLUGIN Default conversion method or viewer for AFP data documents
lineViewer ODConstant.APPLET Default conversion method or viewer for line data documents
For tempDir and traceDir, the default value is the path of the temporary directory
that the system uses. This value is retrieved by using the
System.getProperty("java.io.tmpdir") Java method.
134 IBM Content Manager OnDemand Web Enablement Kit Java APIs: The Basics and Beyond
The language parameter configures the language in which ODWEK produces
messages. The only type of messages that you receive from ODWEK classes
are exceptions. The language setting is irrelevant unless you plan to display the
exception messages to users. If this is the case, you must set the language
parameter to the language in which your application is running. See Chapter 7,
“Globalization” on page 143, for a list of supported languages. If you do not want
to expose the exception message to users, you can create your own messages.
Consider the following points when logging off and terminating a client
connection:
A session that is terminated by an ODServer.terminate() call before an
ODServer.logoff() call becomes unusable, but the logon token still persists on
the system for a while until it times out.
If an ODServer class instance is not used anymore, for example, because of
an exception in the application, an explicit logoff, a close on the client
interface, or a timeout of the Web application, ensure that the
ODServer.logoff() and ODServer.terminate() methods are called. The best
practice is to call the ODServer.logoff() method (if an active logon still exists)
and then call the ODServer.terminate() method.
Ensure that your exception handling code contains functionality to correctly
terminate a Content Manager OnDemand session. When handling a critical
application error, which can force a user to actively logon to your application
again, make sure that you end the ODServer session by using the
ODServer.logoff() method (if applicable) and calling the ODServer.terminate()
method.
When handling exceptions within your login or initialization code, see if
ODServer has been initialized before calling the terminate() method because
the exception might be thrown during the ODServer.initialize() call. To check
whether the ODServer is initialized, use the ODServer.isInitialized() method.
136 IBM Content Manager OnDemand Web Enablement Kit Java APIs: The Basics and Beyond
the resource data that is located in memory. The resource data is not freed
until all active client connections are terminated.
Hitlist
Only one active hitlist is cached in memory for each session (ODServer
instance). Each time a search is performed, the resulting hitlist is cached in
memory and is overwritten by the next search.
In addition to the objects in memory during retrieval and the hitlist creation, the
AFP resources are the main consumers of memory. They are loaded into
memory the first time that a user requests an AFP document, but they are not
released as long as there is an open session.
6.6 Timeout
In this section, we discuss the inactivity timeout, which is defined to Content
Manager OnDemand and can be used to interrupt sessions. We also discuss
methods by which you can create your own timeout.
Figure 6-5 Configuring the inactivity time out in the administration client
The inactivity timeout does not force a connection termination or logoff. The
timeout is internally maintained by the API code at client level and is an indication
that the logon session for the user has expired due to inactivity.
Resetting the inactivity timeout counter: You can reset the inactivity
timeout counter through any API operation that communicates with the
OnDemand server.
The inactivity timeout can be used to help ensure your application knows when to
properly terminate the API objects so that it does not cause memory issues. As
mentioned in 6.1, “Connection pooling overview” on page 112, it is important to
call the ODServer.terminate() method after a session is not required anymore.
Issuing the ODServer.terminate() method decrements an internal Content
Manager OnDemand counter, allowing the ODWEK Java APIs to recognize when
there are no more required connections. That is when the counter is at zero.
When this occurs, the ODWEK Java APIs release any unneeded shared
resources from memory.
138 IBM Content Manager OnDemand Web Enablement Kit Java APIs: The Basics and Beyond
The inactivity timeout allows your exception handling code to check if you still
need the connection session (based on how your client interface works). If you
do not need the connection session, call the ODServer.logoff() and
ODServer.terminate() methods to finalize and terminate the unused connection.
Depending on how you design your application, a timeout can be enforced by the
Web application server. For example, you can configure a session timeout to
cancel the execution of a Web application after a defined time. In this case, check
to see what happens within the Java application at the time that the Web
application server enforces the timeout:
If a Java exception is thrown, make sure that your application is informed that
your request is no longer needed.
If the timeout occurs within a search or retrieve operation, call the
ODServer.cancel() method. See 6.6.3, “Implementing an application timeout
by using the ODServer.cancel() method” on page 140.
If the timeout renders the current session invalid or no longer in use,
terminate it correctly. See 6.5.2, “Logging off and terminating a client
connection” on page 135.
140 IBM Content Manager OnDemand Web Enablement Kit Java APIs: The Basics and Beyond
6.6.4 Recommended timeout implementation for a Web application
In Web applications, users do not synchronously communicate with the
application. Instead, all interactions are done by requesting content through the
use of a Web browser. Users tend to ignore this fact and act as though they are
using a standard application, which may lead to problematic situations. We
describe one such situation in the following section.
If the user wants to perform another search, a new search request is issued for
the same OnDemand session. Because the ODWEK Java APIs are
synchronized on the session object, only one search operation can be performed
in one session. Therefore, when the user clicks the Stop button, the first search
still carries on for the OnDemand session. The new search (or any other
operation) that is issued by the same user is blocked until the first search is
finished. From the user’s perspective, the result is a non-responsive application.
To avoid this behavior, your application must be able to detect a running search
or retrieve operations. For every call made to a session, check if a search or
retrieve operation is currently in progress. If such an operation is in progress,
consider canceling it before executing the next search or retrieve operation.
Multiple tab functionality: Many browsers offer the ability of opening multiple
tabs. Users can use this functionality to issue parallel requests in the same
session. For example, if a user is viewing a hitlist and wants to retrieve two
different documents in two new tabs, then two retrieve calls are made in
parallel.
You can solve this problem by using an operation-ongoing flag. When the first
search is performed, the flag is set to be true. If another search is requested and
the operation-ongoing flag is already set to true, then you can display a window
that informs the user of the ongoing operation. Instead of simply canceling the
existing running operation and starting a new one, the window should offer the
user the ability to cancel the existing running operation, in favor of the new
request, or cancel the new request.
If the page contains a self-reloading mechanism, which reloads the page every
second and checks every time if a flag is still set, then you can also satisfy users
who work with multiple tabs. In the example mentioned previously, now the first
document retrieval runs, and the second tab shows the information page until the
first retrieval is finished. Afterward, Content Manager OnDemand retrieves the
second document automatically.
142 IBM Content Manager OnDemand Web Enablement Kit Java APIs: The Basics and Beyond
7
Chapter 7. Globalization
In this chapter, we discuss globalization in association with IBM Content
Manager OnDemand (OnDemand) and OnDemand Web Enablement Kit
(ODWEK). Many of the Content Manager OnDemand implementations do not
run in a homogenous environment. Multiple clients that use the same application
may be running with different languages, locale, and code page settings. Even
with a homogenous environment, the Content Manager OnDemand
implementation might use languages and code page settings that are different
than standard default.
Content Manager OnDemand is designed for the global market for worldwide
distribution. Content Manager OnDemand can be configured to work in different
locales to support various languages. The OnDemand server runs in Unicode so
that client interfaces can be displayed in various languages.
Each code page represents a mapping of the Unicode characters for a specified
language and locale, ranging from one byte to multiple bytes per character
(single byte character set (SBCS), double byte character set (DBCS), and
multiple byte character set (MBCS)).
For example, ISO 8859-1 is one of the most common code pages that is used to
represent western European languages. In ISO 8859-1, the first 127 characters
144 IBM Content Manager OnDemand Web Enablement Kit Java APIs: The Basics and Beyond
are the standard ASCII characters. They are followed in positions 128 through
256 by many of the signs and characters that are used in western European
languages.
Different countries and languages use different code pages. Custom font and
character sets, such as those used in Advanced Function Presentation
(AFP)-applications, might also have their own code pages.
If a Content Manager OnDemand system uses a single code page, then no code
page translation is required. However, consider an example where line data
spools are loaded from an external system that runs an Extended Binary Coded
Decimal Interchange Code (EBCDIC) 500 code page and the Windows clients
use Windows-1252 code page. In this case, without code page conversion, users
cannot read the displayed data on their client application because the data
stream bytes are mapped with different values in different code pages.
A portion of the Windows-1252 code page is shown in Figure 7-1, and portion of
the EBCDIC 500 code page is shown in Figure 7-2 on page 146. For both code
pages, each character is shown with its Unicode equivalent underneath and its
decimal code at the bottom.
For example, the small letter “a” has a Unicode value of 97 in Windows-1252
code page. However, the same value 97 on the EBCDIC 500 code page
represents the forward slash character (/). The small letter “a” on the EBCDIC
500 code page is represented by 129. Without code page conversion, the data
that is loaded from the external system using EBCDIC 500 code page is not
correctly represented by the Windows client application, where the Windows
client application uses the Windows-1252 code page.
—0 —1 —2 —3 —4 —5 —6 —7 —8 —9 —A —B —C —D —E —F
` a b c d e f g h i j k l m n o
6- 60 61 62 63 64 65 66 67 68 69 006A 006B 006C 006D 006E 006F
96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111
p q r s t u v w x y z { | } ~ DEL
7- 70 71 72 73 74 75 76 77 78 79 007A 007B 007C 007D 007E 007F
112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127
€ ‚ ƒ „ … † ‡ ˆ ‰ Š ‹ Œ Ž
8- 20AC 201A 192 201E 2026 2020 2021 02C6 2030 160 2039 152 017D
128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143
Figure 7-1 Partial Windows-1252 code page
Figure 7-3 on page 147 shows the Content Manager OnDemand and ODWEK
data encoding architecture. It includes areas in which different code pages are
used for these two types of data and where the code page conversions occur.
The diagram illustrates the Content Manager OnDemand instance, the ODWEK
instance, the Web browser, and the data encoding between the different
components. The cogged (toothed) wheels represent the points within the
system where the data conversions occur. As a general rule, all data interfaces to
the server are in UTF-16 data, except for document data, which is transferred in
its native code page.
146 IBM Content Manager OnDemand Web Enablement Kit Java APIs: The Basics and Beyond
DB code page
set at
DB creation
ODWEK Java – UTF-16
Error messages
ODConfig - language Database
Error messages
OD instance
code page matches
DB code page
Figure 7-3 The Content Manager OnDemand and ODWEK data encoding architecture
The database code page is set at database creation time and cannot be
changed. When creating an Content Manager OnDemand instance, its code
page must match the database code page. Therefore, no data conversion is
required between these two components.
Note: The OnDemand server runs in the same code page as the Content
Manager OnDemand database.
TCP/IP traffic that is composed of indexes, annotations, and control data (such
as user-login, folders, and other internal data) and is transferred between a
server and client (regardless of client type, ODWEK, or Windows) is always
transferred in UTF-16. All index and annotation data are converted from the
native database and server code page to UTF-16 for data transmission. Later the
UTF-16 data is converted into other code pages by the client, for example, to
UTF-8 for ODWEK or to the Windows locale for a Windows client.
The UTF-16 conversion is required since the server does not know which code
page a client is using. Therefore, the server cannot send the data in the client’s
code page directly. Additionally, the client might not know the code page that the
Content Manager OnDemand instance and database are using. By standardizing
the transmission code page, both the client and server can be more efficient in
handling conversions.
To the OnDemand server, ODWEK is just another client. Since Web browsers
transmit and display UTF-8 data, ODWEK is designed to work completely in
UTF-8. This allows ODWEK and the Web browsers to directly exchange data by
using UTF-8 without undergoing any further code page translations. Data that is
exchanged with the OnDemand server is converted automatically from UTF-8 to
UTF-16 and vice versa.
The Java layer of the ODWEK environment uses UTF-16, because UTF-16 is the
only native Java code page. The conversion between Java’s UTF-16 code page
and ODWEK’s native UTF-8 code page is done automatically within the ODWEK
Java APIs.
148 IBM Content Manager OnDemand Web Enablement Kit Java APIs: The Basics and Beyond
7.2.3 Document data conversions
Document data is generally stored untouched in its native format. When the data
is loaded by using the Content Manager OnDemand load mechanisms (arsload,
Store API, Monitors, Indexer), no data conversion is applied. The data is stored
as is, in its native code page and format.
The only moment in time in which conversions on data come into play is at the
presentation level. If required, conversions and handling of custom font mappings
(for AFP) are done on the client. A line data document that is archived on an
EBCDIC computer cannot be displayed on a Windows computer without either a
code page conversion or a viewer that is capable of displaying the EBCDIC code
page on the client.
Depending on the data and type of the client, different processes occur on the
client computer system. The standard Windows client incorporates a line data
viewer component and viewing capabilities for AFP documents. Both modules
internally map the code pages and display the characters in the way they should
be displayed. For binary document data, and data that is in a format or code
page unknown to the viewers, the native document data is passed to the
associated application for further processing.
When implementing a Java application by using the ODWEK Java APIs, you
must be aware of the code conversions that are taking place. Java internally
operates in UTF-16. Data that is returned from the ODWEK Java API functions
are automatically converted from UTF-8 to UTF-16 by Java. When you pass
strings from Java to the ODWEK methods, you do not need to perform any
additional tasks. The UTF-16 data is converted by the native ODWEK code to
UTF-8.
If you are delivering index data to any external applications by using your
ODWEK-based Java application, make sure that those applications can handle
Unicode data. Otherwise, you must convert the data manually. The same
implications apply if you save any index or annotation data to a file. If you do not
do any explicit conversion, the data is written as a Unicode data stream.
Web browsers usually are capable of displaying and sending UTF-8 data.
Therefore, this does not present itself as an issue when implementing Web
applications.
For more details about document data conversions in ODWEK and how you can
request data in different formats, see Chapter 10, “Applets, plug-ins, and
transforms” on page 197.
150 IBM Content Manager OnDemand Web Enablement Kit Java APIs: The Basics and Beyond
7.4 The ICU conversion library
Content Manager OnDemand performs conversion or mapping from different
code pages to other code pages by using a standard component called
International Components for Unicode (ICU). ICU is an open source project that
was developed by IBM and other companies. It is a library that is available for
Java and C and is used for multicultural support. ICU provides services such as
character conversion between different code pages, language-sensitive collation,
and locale and resource management support.
ICU is used by Content Manager OnDemand at different locations for code page
conversion and text operations. Figure 7-4 shows the components within the
Content Manager OnDemand architecture that the ICU library uses to convert
data.
ODWEK
OnDemand
AFP Plug-in
Windows client
Figure 7-4 Content Manager OnDemand components that use the ICU library
Each component uses ICU for different use cases, but all do code page
conversions, which enables communication with other parts of the Content
Manager OnDemand infrastructure:
The OnDemand server uses ICU for index and annotation conversions. All
TCP/IP traffic is in UTF-16, but the index and annotation data are stored in the
database code page format. Therefore, ICU is used for data conversion
between the database instance code page and UTF-16.
Tip: Using Unicode as the database code page can help to solve some of the
issues that you might experience when dealing with multiple code pages and
languages.
152 IBM Content Manager OnDemand Web Enablement Kit Java APIs: The Basics and Beyond
When Content Manager OnDemand and database Unicode
encoding are needed
In most scenarios, it is not necessary to use Unicode for the server and database
encoding. If you are working in an environment in which data from different code
pages must be handled, Unicode encoding might help to store the data correctly.
The different byte-length for each character can lead to issues concerning the
maximum length of the database application group fields in Content Manager
OnDemand. Each application group field in Content Manager OnDemand
corresponds to a field in a database table. When creating an application group
string field, you specify the maximum character length of this field. Internally at
the database level, the field length is not enforced by the number of characters.
Instead, it is calculated based on the number of bytes.
Important: If you work with other pieces of ODWEK, especially the CGI
module, you have to specify the code page of the OnDemand server and
Content Manager OnDemand database in the arswww.ini file. This setting is
not required for the ODWEK Java APIs.
In this section, we discuss how to set language for ODWEK output and what you
need to pay attention to when dealing with multiple languages.
Supported languages
The multicultural support that is provided by ODWEK is the same as the
multicultural support that is provided by other components of Content Manager
OnDemand. You can specify a language in which all messages are displayed.
Table 7-1 shows the list of available languages that can be used with ODWEK.
154 IBM Content Manager OnDemand Web Enablement Kit Java APIs: The Basics and Beyond
Language code Region or country ISO and Windows code page
The value that is used to configure ODWEK is the language code (the first
column in Table 7-1). The third column in Table 7-1 provides additional
information about the code page that is internally used when data is represented
in the selected language. For the double-byte languages (CHS, CHT, JPN, and
KOR), the code pages are used by AIX, Solaris™, and Windows. Because this is
handled internally, you do not need to configure the code page information,
according to the ODWEK language settings.
If you must have multiple ODWEK message languages, deploy your application
as multiple Web applications. However, before doing deploying the application,
consider whether the language used by ODWEK for messages is really of
interest to your users. Your users might never see any of the messages if you do
not use ODWEK applets or expose other ODWEK material directly to the users.
In such cases, configure the ICU conversion engines in your Content Manager
OnDemand system to correctly handle your custom code page.
156 IBM Content Manager OnDemand Web Enablement Kit Java APIs: The Basics and Beyond
AFP workbench viewer: The Content Manager OnDemand Windows client
uses the AFP workbench viewer, which is installed automatically during the
client setup. However, as the components of the workbench viewer are directly
integrated into the client, the ICU installation of the client is used to render
AFP documents. You do not have to configure the AFP workbench viewer
installation if you view custom code pages in the Content Manager
OnDemand Windows client.
AFP plug-in
If your Web application is running in an environment where the AFP plug-in is
deployed, then you must configure custom code pages.
ODWEK
ODWEK uses the ICU engine for two data conversions.
The first data conversion is for UTF-16 data (indexes and annotations as they are
transferred by using the TCP/IP connection to the server) to UTF-8, which is
used by the internal native part of ODWEK.
The second conversion is for line data documents from their native code page in
which they are stored in the server to UTF-8 when they are passed to ODWEK.
This conversion is required when an application uses the line data Java applet.
Therefore, you must configure the custom code page data in the ODWEK ICU if
you want to use the line data Java applet.
http://www.ibm.com/support/docview.wss?rs=129&context=SSEPCD&dc=DB520&d
c=DB560&uid=swg21290484&loc=en_US&cs=UTF-8&lang=en&rss=ct129db2
You can also see the Content Manager OnDemand for Multiplatforms Support
page at the following address:
http://www.ibm.com/software/data/ondemand/mp/support.html
On this page, in the search field, type the following search string:
Customizing code page mappings for the OnDemand Client
Several articles are returned from the search. Select the article that covers the
OnDemand client version that you currently work with.
158 IBM Content Manager OnDemand Web Enablement Kit Java APIs: The Basics and Beyond
Although portions of the Java framework in the packages java.text and java.util
are already based on ICU code, ICU provides the following, among other,
additional functionality:
Code page conversions, which is the function ICU is used for in the Content
Manager OnDemand infrastructure
ICU conversion tables are based on the charset data that is provided by IBM.
It can be considered one of the most complete collections of charset
conversions available.
String functions such as locale-based comparing and sorting
The national conventions used by ICU are based on the Common Locale
Data Repository (CLDR) project that is maintained by Unicode.
Date and time formatting and calendar support based on the regional or
locale settings
This support includes translating month and day names into the selected
language, choosing appropriate abbreviations and ordering fields correctly,
and dealing with different calendars and time zones.
Text analysis and regular expression support for Unicode data, as well as line
wrapping and text boundary functions
You can download the ICU library and binaries for various platforms from the
following Web page:
http://www.icu-project.org
For the Javadoc documentation for ICU4J, go to the following Web page:
http://www.icu-project.org/apiref/icu4j
162 IBM Content Manager OnDemand Web Enablement Kit Java APIs: The Basics and Beyond
3. For each ODCriteria String name that is returned:
a. Instantiate the ODCriteria object by issuing the
ODFolder.getCriteria(criteria_name) method.
b. Obtain a list of valid search operators to display.
c. Display or set the selected search operator to a valid search operator.
odCriteria.setOperator(oper);
d. Set one or two search values depending on the search operator.
e. Perform the ODFolder object search.
For any Date field, make sure that the date pattern conforms to the default
format for the folder field as defined by the OnDemand administrator.
The default format for a Date field is %m/%d/%y or mm/dd/yy. Before the search
page is written, the application must try to get the OnDemand folder date
pattern, convert it to something more meaningful for users, for example,
dd/mm/yyyy, and make a notation by the Date entry fields. Any date string that
Always use the criteria search instead of an SQL search whenever possible.
However, there might be times when a complex search is required, and an SQL
search is the only way to provide correct search results.
164 IBM Content Manager OnDemand Web Enablement Kit Java APIs: The Basics and Beyond
You can choose to search any field or predicate combination as long as you know
the application group field names. A criteria search uses folder field names, and
an SQL search uses application group field names.
Each application group field can be displayed for the user to enter data values.
After the matching values are received by the application, the query string can be
created. The data type for each application group field must be known in order to
create a correct SQL WHERE clause. The data type can be determined by
calling the ODApplicationGroupField.getType() method.
If the OnDemand folder has multiple application groups and this method is not
called, then OnDemand performs a search across all application groups that are
mapped to the folder.
When dealing with date values in the SQL search, the ODWEK Java APIs can
handle either the default date format or a specified date format as shown in the
following example:
String whereClause = "WHERE lname = 'DOE'";
Vector searchResults = folder.search(whereClause,"10/03/95",
"10/03/96","%m/%d/%y");
lname is the application group database field name. The two dates are the start
and end of a date range for OnDemand to search using the date format that is
specified as the last parameter in the method. An SQL search offers a more
flexible search than a criteria search provides. When using a criteria search, you
can query any of the folder fields that are available and specify the search
concatenation between the selected fields to set as an OR condition or an AND
condition. By using an SQL search, you can specifying the OR and AND
conditions between each field or group of fields as desired.
166 IBM Content Manager OnDemand Web Enablement Kit Java APIs: The Basics and Beyond
Before presenting a search results list to a user, make sure that the display
order of each ODCriteria field matches the OnDemand administrator’s folder
field definitions. A value of zero (0) means that it is not eligible to display.
Use the following code to obtain the display order:
String[] displayOrderedFieldNames = odFolder.getDisplayOrder();
The OnDemand administrator has the ability to define the default sort orders of
the folder fields as they are displayed in the result list. This is not to be confused
with the display order or query order sequences that are also defined for each
folder field. We explain sorting by values within each folder field (or application
group field).
In most cases, how a search result collection is sorted is closely tied to the
number of maximum hits (maxhits) that can be returned for an OnDemand folder.
The number of maxhits can be obtained by invoking the ODFolder.getMaxHits()
method after a given ODFolder object is opened. This call returns either the
maxhits value that is specified when the ODConfig object is instantiated or the
value that is specified by the OnDemand administrator for the folder, depending
on the lesser value. The number of maxhits can also be dynamically changed by
invoking the ODFolder.setMaxHits() method.
For criteria searches, the search results are sorted as how the folder field sort
order is specified, either by the API or by the OnDemand administrator. The
application can explicitly set the sort order for each ODCriteria object by invoking
the ODCriteria.setSortOrder() method. The value can be 0 to n, where 0 means
that no sorting is specified. If all folder fields have their sort order settings equal
to 0, then the search results are returned in the database order, which is based
on random loads and optimizations.
If we apply the same assumptions as in the previous example, but change the
sort location to OD_SORT_LOCATION_SERVER, then the following actions
occur:
1. The database query is set to take the overhead to obtain all 3000 rows that
match the search criteria,
2. The database sorts all 3000 rows.
3. The database returns only the first 200 rows from the sorted list to
OnDemand.
4. ODWEK Java APIs pass the hitlist as is, with no additional sorting.
168 IBM Content Manager OnDemand Web Enablement Kit Java APIs: The Basics and Beyond
8.3 Search results
A search result list consists of the ODHit objects that represent an OnDemand
document. The application uses the ODHit object to retrieve the documents as a
byte array that can either be streamed directly to the requesting client or be
written to a file on a shared file system.
Your application must also check whether the OnDemand folder field can be
displayed, which can be done in ways that are similar to checking whether the
field can be queried. After opening the ODFolder object:
Call the ODFolder.getDisplayOrder() method to get a string array of the folder
field names in the order in which they are defined by the OnDemand
administrator for the folder. The string array has only the folder fields that have
a non-zero display order value defined.
After a list of ODCriteria objects is obtained from the selected ODFolder
object, call the ODCriteria.getDisplayOrder() method to obtain the value as
defined by the OnDemand administrator. A value of zero means that the folder
field is not eligible to be displayed in the results list.
Call the ODCriteria.isDisplayable() method. The method returns true if the
folder field has a non-zero display value defined, or it returns false if the value
is zero.
The OnDemand administrator can set the maximum number of results that are
returned during a folder search. Your application must honor this configuration
setting or a lesser value when monitoring the impact of the search by users. For
example, a call to the ODFolder.getMaxHits() method returns results based on
either how the OnDemand administrator has the maximum hits value defined or
how the ODConfig object property value is configured during the instantiation of
the ODServer object, whichever is the lesser value.
After a client submits the search criteria to the application, a call to the
ODFolder.searchCountHits() method can be made to determine the impact of the
search. IBM DB2® has optimized APIs that are used to only get the count back
for a specific query, but does not pass any data back. Therefore, overhead is
avoided at both the OnDemand server and the mid-tier of setting up the hit
structures. A decision in the application can be made based on the number of
hits returned. For example, it can refuse the client search request or honor the
request at another time of day.
If the maxhits size is not specifically set in the ODConfig object or the ODFolder
object, or by the OnDemand administrator, ODWEK defaults the number of
maxhits to 200.
Your application must add the date criteria as part of the client searches to
eliminate potential performance issues on the OnDemand server. OnDemand
converts all date formats into a common internal format when performing
searches. Your application should check how a date field should be formatted
when using it in a search. For example, the OnDemand administrator might
define a date pattern for a folder date field as %m-%d-%y, which should be
170 IBM Content Manager OnDemand Web Enablement Kit Java APIs: The Basics and Beyond
presented to the client as a search string pattern of mm-dd-yy. If no format is
defined for the folder date field, it defaults to %m/%d/%y.
Different techniques are available to recreate the ODHit object that is used to
retrieve the document. One technique is to persist the docID and recreate the
ODHit object from the ODFolder object that has been persisted:
String docId = request.getParameter(“docId”);
ODFolder odFolder = (ODFolder) session.getAttribute(“odFolder”);
ODHit odHit = odFolder.recreateHit(docId);
This technique may not be desirable for applications that do not want to keep the
docID persistent, perhaps in the browser search results HTML page.
Another technique is to obtain the ODHit object by its relative location within a
collection of ODHit objects that has been persisted by the application or within a
collection of ODHit objects that is recreated by calling the ODFolder.getHits()
method. This method returns a list of ODHit objects from the last successful
ODFolder search:
String hitPosition = request.getParameter(“hitPosition”);
ODFolder odFolder = (ODFolder) session.getAttribute(“odFolder”);
Vector odHits = odFolder.getHits();
ODHit odHit = (ODHit) odHits.get(Integer.parseInt(hitPosition));
As of ODWEK version 8.4, the full query results are cached in the folder object,
just as for a non-callback search. However, this caching behavior might change
in future versions of the API to allow more memory-efficient result handling.
At present, searching with a callback provides the following benefits when you
handle the result hits one by one:
Provide users with a more dynamic experience by reporting and acting on
partial results immediately.
Cancel a running search.
Apart from invoking your custom callback logic, the behavior of callback searches
match their non-callback counterparts. After you define a custom callback class,
pass an instance of it to the ODFolder.search() method that matches your
desired search type.
172 IBM Content Manager OnDemand Web Enablement Kit Java APIs: The Basics and Beyond
java.lang.String docId,
char type,
int hit_location,
java.lang.String[] values)
These two methods are the same except for the int hit_location parameter. The
ODCallback class is not abstract. Therefore, you must only implement the
method for the particular callback that you want to handle. All ODFolder search
methods except the following one invoke the callback method without
hit_location:
java.util.Vector search (
ODCallback odCallback,
boolean use_docloc_hit_callback)
Passing true for the boolean parameter causes the API to invoke the alternative
HitCallback() method instead. The API passes a hit_location value that is one of
the DocLocationXxx values that is defined in ODConstant. These values indicate
the physical storage tier in which the referenced document resides. See the
Javadoc documentation for ODConstant to view the possible values.
try
{
ODFolder folder = odServer.openFolder ("myfoldername");
MyCallback callback = getCallback (folder);
folder.search (callback);
folder.close ();
}
catch (Exception e) { e.printStackTrace (); }
finally
{
disconnect ();
}
}
174 IBM Content Manager OnDemand Web Enablement Kit Java APIs: The Basics and Beyond
) throws Exception
{
odServer = new ODServer (new ODConfig ());
odServer.initialize (applicationName);
odServer.setPort (port);
odServer.setServer (server);
odServer.setUserId (usr);
odServer.setPassword (pwd);
odServer.setConnectType (ODConstant.CONNECT_TYPE_TCPIP);
odServer.logon ();
}
/**
* Factory method
*
* @param folder An open ODFolder
* @return A callback that prints displayable hit fields
* in correct display order for the given
* folder
*/
public static MyCallback getCallback (ODFolder folder)
{
String[] displayOrder = folder.getDisplayOrder ();
String[] queryOrder = folder.getQueryOrder ();
/**
* Custom callback class that prints search results
* to the console. Display values for hit fields
* are printed in the order given to the constructor.
*/
public static class MyCallback extends ODCallback
{
int[] displayOrder = null;
try
{
response = in.readLine ();
176 IBM Content Manager OnDemand Web Enablement Kit Java APIs: The Basics and Beyond
}
catch (IOException e)
{
e.printStackTrace ();
System.err.println (
"Error reading user input; search cancelled.");
return false;
}
Retrieval can be complex when dealing with different data types and you have to
present the data to users. For example, if you deal with line data, you do not want
to show users a large retrieved spool as a big flow of Extended Binary Coded
Decimal Interchange Code (EBCDIC) data in a browser. Instead, you want to use
a line data viewer that is opened within the browser and let the viewer display the
spool. Alternatively, you can use InfoPrint’s AFP2WEB functionality to transform
an AFP spool into a PDF document for viewing.
If you retrieve a complete AFP document, then the AFP resources are loaded
into shared memory and are served from there for each request. If you deal with
several different AFP documents or if you have large resources, this might not be
optimal behavior. Likewise, if you retrieve multiple AFP documents to be
processed in another application, you might not want the system to automatically
load all the AFP resources. In these scenarios, you might want to deal with the
AFP resources directly.
The OnDemand APIs provide methods to retrieve documents and rely on the
resources being loaded into shared native memory. In addition, it is also possible
to retrieve raw document streams and resource streams separately and have
them written directly to file.
For more details about working with resources, see 9.3, “AFP resource retrieval
and custom caching” on page 185.
180 IBM Content Manager OnDemand Web Enablement Kit Java APIs: The Basics and Beyond
9.1.2 Large objects versus small objects
You must treat large objects differently than small objects. Large documents must
be differentiated in objects that have been loaded by using large object support,
as explained in the following section, and large binary objects.
When retrieving documents that are large binary objects, for example, large
PDF-files or large user-defined data types, it is important to consider memory
usage. When you do a standard retrieval in a native format by calling the
ODHit.retrieve() method, the system downloads the data from the OnDemand
server and stores it in native memory to be delivered to the client. When working
with large documents and many users, the system might run out of contiguous
native heap. This issue can be addressed by bypassing memory and retrieving to
file. See 9.5, “Avoiding memory issues for large files” on page 190, for more
information.
Large spools that need to be transmitted in chunks have been archived by using
large object support. OnDemand large object support is a feature that can be
enabled to have large reports processed more efficiently by dividing it into
segments. For example, a report that typically contains more than 1000 pages is
divided into smaller chunks of 100 pages, for example. Each time a user views
the document, only the requested chunk is retrieved and transferred. The API
provides methods for the retrieval of specified segments.
For more details about dealing with segmented retrieval in general, see 9.4,
“Segmented retrieval and large object support” on page 187. For details about
how to enable the Line Data Applet in dealing with segmented objects, see 10.2,
“ODWEK Java applets” on page 200.
For more information about conversion and transformation, see 9.7, “Retrieving
converted data” on page 193.
There are three ways to retrieve data by using the retrieval methods:
Retrieval of the entire document
Segmented retrieval of large-object documents in chunks
Retrieval of the data to file instead of memory
All three ways are applicable for document retrieval. For resources, they are
never segmented. Therefore, the segmented retrieval does not apply.
Most retrieval methods are placed in the ODHit class, which represents a
document hit in a searched hitlist. Calling one of the retrieve methods within an
ODHit object delivers the document that is represented by this ODHit instance.
In this section, we list and briefly explain all retrieval methods in the ODWEK
Java APIs. For a detailed description and how to use them, see 9.3, “AFP
resource retrieval and custom caching” on page 185, and 9.4, “Segmented
retrieval and large object support” on page 187.
182 IBM Content Manager OnDemand Web Enablement Kit Java APIs: The Basics and Beyond
Methods that retrieve documents in raw format:
– byte[] getDocument()
This method retrieves documents that are represented by the ODHit object
in its native raw format as an array of bytes. For documents that have the
large object flag enabled, only the first segment is returned.
– getDocument(java.lang.String filename, boolean allsegs)
This method retrieves the document in its native raw format and directly
writes the data to a file. The allsegs parameter only applies to documents
that have the large object flag enabled. For those documents, the
parameter can be controlled if only the first segment or the entire
document is retrieved.
Tip: The getDocument methods always return the document data in native
format. No conversion or transform is applied to the data, and no applet
code can be returned. If you want to enable data conversions, use the
retrieve method instead.
Example 9-1 shows how to use some of the retrieval methods that are provided
by the ODHit class. For detailed information about how to use the
retrieveSegment methods, see 9.4, “Segmented retrieval and large object
support” on page 187.
if(hits.size() > 0) {
//We are going to take the first hit
odHit = (ODHit) hits.elementAt(0);
184 IBM Content Manager OnDemand Web Enablement Kit Java APIs: The Basics and Beyond
//retrieve the native document and store it to a file:
odHit.getDocument("C:\\file", true);
}
odFolder.close();
odServer.logoff();
odServer.terminate();
Example 9-1 does not include any exception handling or information about the
initial configuration, which might lead to unforeseen results. See Chapter 6,
“Connection pooling and connection handling” on page 111, for details about why
exception handling is necessary and how to initialize and terminate connections.
Accessing the resources from shared memory enables a fast and efficient way to
work with AFP documents, but it can have a significant effect on memory
consumption. As mentioned in 6.5.3, “Allocation and release of resources and
sessions” on page 136, shared resources are not released until all ODWEK client
sessions (all ODServer objects including their dependent classes) are
terminated. In environments in which you must deal with a large number of
different reports, you might have a lot of different AFP resources that are loaded
as shared memory in the machine that is running the Web application server.
Because these resources can contain graphics, it is possible that the resource
data for each report consist of several megabytes, which can lead to an
increasing consumption of native memory over time.
186 IBM Content Manager OnDemand Web Enablement Kit Java APIs: The Basics and Beyond
Having stored resource data is only the first part. You must also determine which
resource you have in your cache, which you can do by using the getResourceID()
method of the ODHit class. This method returns a string that uniquely identifies
the resource that is being used by this document. The resource ID is a string that
is constructed out of server name (IP), application ID, and AFP resource ID. Two
ODHit objects that return the same resource ID use identical AFP resource data.
Non-AFP documents or documents without any resources return null as a
resource ID.
If you develop an application that deals more than just AFP documents, then
check whether an ODHit really represents an AFP document, which you can do
by using the ODHit.getDocType() method. This method returns a char. If the
returned char equals the constant ODConstant.FileTypeAFP, then the document
represented by this ODHit is an AFP document. You can continue to get the
resourceID and check if you already stored resource data for this AFP. If you
have stored the data, use the cached one. If you have not stored the data,
retrieve the resources and store them.
When large object support is enabled, implementing Web applications with the
ODWEK Java APIs implies the usage of segmented retrieval. If an object is
archived with large object support enabled, the behavior of the ODHit.retrieve()
and ODHit.getDocument() methods changes as outlined in Table 9-2 on
page 188.
byte[] getDocument() Returns the entire document in Returns only the first segment of
native format. the document in native format.
getDocument(String filename, Writes the entire document to file. Depending on allsegs, either the
boolean allsegs) The allsegs parameter is entire document or just the first
ignored. segment is written to file.
byte[] retrieve(String viewer) The entire document data ODWEK passes either a single
for other conversions handled by (converted) is returned. document or a segment.
transforms (for example PDF)
With the change in the behavior of the retrieval methods, additional methods are
required to get the segments other than the first segment:
byte[] retrieveSegment(int segment)
This method retrieves a specified segment through its segment number.
retrieveSegment(int segment, String filename)
This method retrieves a specified segment (identified by segment number)
directly to file, by bypassing native memory allocation.
getNumSegments()
This method returns the amount of segments for the document.
getNumPagesInSegment() and getNumPagesInLastSegment()
This method returns the number of pages of which each segment consists.
When dealing with large object spools, we are limited to the use of the
retrieve(…) and retrieveSegment(…) methods. This use implies no real limitation
as long as the retrieve methods require a viewer parameter to be specified.
188 IBM Content Manager OnDemand Web Enablement Kit Java APIs: The Basics and Beyond
9.4.1 Retrieving segmented documents
In 9.7, “Retrieving converted data” on page 193, we describe the different
possibilities and conversions in detail. Regarding large objects and segments,
the conversions change their behavior as shown in Table 9-2 on page 188.
You must ensure that the retrieve(String viewer) method is always called first. For
example, if you know that you need only the tenth segment, you must retrieve the
first one by using retrieve(String viewer).Then you can retrieve the tenth segment
by using the retrieveSegment() method.
Like the OnDemand Windows client, the plug-in and the Java applets
automatically retrieve only the pages that are viewed by the user if the document
is a segmented large object. The viewer displays the first page, and then the user
decides which segments the viewer must retrieve afterwards by scrolling to other
pages.
For more details about the two applets and how to implement the callback class,
see 10.2, “ODWEK Java applets” on page 200. For more information about
dealing with the AFP2WEB Transform, see 10.3, “AFP2WEB Transform” on
page 205.
After you call the ODHit.retrieve() method, ODWEK internally has the data about
the number of segments and pages that are available. Therefore, only calling the
getNumSegments(), getNumPagesInSegment(), or
getNumPagesInLastSegment() method after ODHit.retrieve returns the correct
data.
Tip: To determine whether a document is a large object, you can use the
ODHit.isLargeObject() method. If this method returns true, then calling the
ODHit.retrieve() method returns either the first segment of data or lets the
document handle it by a transform or conversion. After that, you can call the
ODHit.getNumSegments() method, for example, to get more information about
the segmentation.
When you retrieve a document directly into a Java byte array by using either the
ODHit.retrieve() or the ODHit.getDocument() methods, the documents are
loaded into native memory of the server that is running ODWEK. Because each
document requires a contiguous block of memory for being loaded, you can
reach memory limits if too many documents or documents that are too large are
retrieved.
190 IBM Content Manager OnDemand Web Enablement Kit Java APIs: The Basics and Beyond
You can determine the size of a document before retrieving it by using the
ODHitProperties object, which can be obtained by calling the
ODHit.getProperties() method. The ODHitProperties object provides information
such as application (group) name, load name, application group ID, and other
internal information. It also has an ODHitProperties.getLength() method that
returns the uncompressed length in bytes of the document.
You can use the length information to decide how to retrieve the document in
your application. If it is a small document, you can save the overhead of writing it
to file. For big documents, you must have the data written to file and then pass
out the data by using the httpResponse stream without holding much data in
memory.
Because the conversions are designed to handle line data and AFP
documents, if you do not deal with these document types, use the
ODHit.getDocument() method instead.
As mentioned in 9.5, “Avoiding memory issues for large files” on page 190, you
can obtain an ODHitProperties object through the ODHit.getProperties() method.
The ODHitProperties class provides additional information such as application
group ID, application ID, resource ID, load data, table name, and compressed
and uncompressed document length.
192 IBM Content Manager OnDemand Web Enablement Kit Java APIs: The Basics and Beyond
Example 9-2 Document information about USERDEF documents
getDocType: U (which is ODConstant.FileTypeUSRDEF)
getFileExt: xls
getMimeType: application/ondemand extension-field=xls
getViewerType: 1 (which is ODConstant.VIEWER_BROWSER)
getViewExt: xls
getViewMimeType: application/unknown
For more information about large object support and segmented retrieval of
spools, see 9.4, “Segmented retrieval and large object support” on page 187.
The two retrieve() methods require a string parameter called viewer. Depending
on the value that you specify, the data is converted to different formats or
displayed by using a special viewer. The effect on the data that you receive as a
return value depends on the type of viewer conversion that you choose. The
available conversions can be separated into three groups:
Viewers
Viewers do not transfer document data in any way. Instead they have
information for calling a specific viewer that is transferred. OnDemand has
three viewers delivered with ODWEK:
– A line data Java applet to display line data
– An AFP2HTML Java applet to display AFP documents in the Web browser
– An AFP browser plug-in
Transformations
Data conversions are done on the documents. OnDemand supports the
AFP2WEB technology and the Xenos transforms. By using AFP2WEB, AFP
documents can be converted to other formats such as HTML or PDF. Xenos
allows more configurable conversations from various formats including
metacode, line data, and AFP to HTML, line data, XML, PDF, and so on. See
10.3, “AFP2WEB Transform” on page 205, and 10.4, “Xenos transforms” on
page 211, for details.
194 IBM Content Manager OnDemand Web Enablement Kit Java APIs: The Basics and Beyond
Native retrieval
Retrieve data in the same format as it is stored. This viewer type is the only
one that is supported by all data types.
For detailed information about how the applets, plug-ins, and transformations are
used, see Chapter 10, “Applets, plug-ins, and transforms” on page 197.
196 IBM Content Manager OnDemand Web Enablement Kit Java APIs: The Basics and Beyond
10
Compatibility: The plug-in viewers that are provided by IBM require Netscape
Navigator 7.1 or later or Microsoft Internet Explorer 6.0 or later.
If the AFP plug-in is installed on the client Web browser, it can be used to directly
display all AFP documents in the browser.
198 IBM Content Manager OnDemand Web Enablement Kit Java APIs: The Basics and Beyond
If it is possible to distribute the plug-in to all client computers that require access
to AFP documents, we recommend this option for display because it requires no
conversion of data.
The two applets that are available with ODWEK serve two document types:
Line data applet
The line data applet is developed to display line data. The applet itself
provides no conversion. However, with the applet, you can enable Web users
to view line data the same way as in the OnDemand Windows client. In
addition to viewing a line data document, the applet also provides annotation
functions. You can enable users to view and create annotations for the line
data in a Web-based application.
AFP2HTML applet
The AFP2HTML applet works in a different way than the AFP plug-in. AFP
documents are transformed to HTML by using the AFP2WEB Transform. After
the transformation, the HTML content is displayed in the Web browser. If you
want to provide additional features, such as segmented document retrieval,
you can configure to display the converted AFP by using the AFP2HTML
instead of letting the browser deal with the rendered AFP HTML.
Using the applets for viewing line data and AFP documents offers the following
advantages:
Users have nearly the same functionality with Web browsers as when they
use standard OnDemand Windows clients.
There is no need for any client installation. You do not need to install the
applet anywhere, like you must do with the AFP viewer plug-in.
The applets support segmented retrieval for large object documents. Only the
segment that is currently being viewed by the user is retrieved from
OnDemand. Other segments are retrieved whenever they are needed.
200 IBM Content Manager OnDemand Web Enablement Kit Java APIs: The Basics and Beyond
For more information about large object support and segmented retrieval, see
9.3, “AFP resource retrieval and custom caching” on page 185.
The applets require Java version 1.4.1 on the client Web browser. Java is
available for a variety of operating systems, including Windows, MacOS, and
Linux.
In your Java application, provide a method that can be called by the applet. This
method must pass the requests of the applets further on to the ODWEK Java
APIs.
Figure 10-2 shows the link between the applet, your Web application, and
ODWEK.
Applet
Applet callbacks
When a user requests a document from the Web application and the document
retrieval code in the application decides to send the document as an applet, then
ODWEK returns the HTML code, which embeds the applet invocation. With this
HTML code, the browser can execute the applet in its Java virtual machine
(JVM).
The data itself is requested by the applet through a callback methodology that
must be implemented by the Web application. The callback method passes the
requests to the ODWEK Java APIs. Within ODWEK, the applet requests are
handled, and then the callback method delivers the results to the applet.
Therefore, for the data stream, the callback method that your application
implements is just a proxy that passes requests and data through.
Callbacks: Callbacks are not used for just applets. The AFP plug-in uses
them as well for large object documents.
The first step in implementing the applet callback servlet is to inform ODWEK
about where to find the servlet. You do this in the initialization code of your
application.
synchronized (wwwsession) {
odServer = (ODServer) wwwsession.getAttribute("MyODSession");
results = odServer.viewerPassthru(request.getQueryString());
}
OutputStream outputStream = response.getOutputStream();
outputStream.write(results);
202 IBM Content Manager OnDemand Web Enablement Kit Java APIs: The Basics and Beyond
} catch (Exception ex) {
...
}
}
As you can see, the ODServer object is obtained from the session object, in
which it is stored as MyODSession in the initialization and login code for this
example. By placing this code in a servlet class and modifying how you get the
ODServer object, you finish the implementation of the applet callback code. If
you then use this servlet as the applicationName parameter in the
ODServer.initialize() method, you meet all requirements for using the viewers.
The servlet is automatically used for all viewers that call back to OnDemand.
The retrieve() method: When using the Java applets, you cannot use the
retrieve() method with the file parameter.
ODHit.retrieve(ODConstant.APPLET, “c:\\file.ext”) leads to an
exception. You can only use the following retrieve() method, which directly
returns the HTML as a byte array:
byte[] x = ODHit.retrieve(ODConstant.APPLET).
204 IBM Content Manager OnDemand Web Enablement Kit Java APIs: The Basics and Beyond
See 10.3, “AFP2WEB Transform” on page 205, for more information about
AFP2WEB and how it can be configured.
After you have configured the AFP2WEB environment, to use the AFP2HTML
applet, implement the callback servlet, if you have not already done this for the
line data applet. Then retrieve the documents by using the
ODHit.retrieve(ODConstant.HTML) method.
The AFP2HTML applet, which displays AFP documents by using a Java applet in
the browser, also uses the AFP2WEB Transform to process information.
Because the return of the AFP2WEB Transform is valid HTML, you can omit the
AFP2HTML applet and directly pass on the HTML to the browser depending on
how the transform is configured.
After you extract the AFP2WEB and AFP2PDF Transforms, they are ready to
use. You can test the functionality by calling the executable by using an AFP
document such as the one provided in the installation directories (insure.afp).
To test, enter either of the following statements on a command line, which results
respectively in an insure.pdf and an insure.html file:
afp2pdf insure.afp
afp2web insure.afp
Configuration files
You must configure the transform that you want to use in ODWEK. You do this by
using an INI file that is already present in the ODWEK directory. Open and modify
the INI file that applies to the transformation that you want to use:
afp2html.ini (AFP to HTML Transform uses afp2web binaries)
afp2pdf.ini (AFP to PDF Transform uses afp2pdf binaries)
afp2xml.ini (AFP to XML Transform)
Each INI file is built in the same way. For each application group and application
pair in OnDemand, you can set different configuration values. In addition, a
default section exists that applies to all applications that are not configured
explicitly.
To set the configuration values for the default configuration, you must have a
[default] section. The configuration that you enter is used for all applications
that are not explicitly configured. In some environments, it might be sufficient to
have just the [default] section and nothing else, which causes all applications
to use the same configuration.
206 IBM Content Manager OnDemand Web Enablement Kit Java APIs: The Basics and Beyond
Example 10-2 shows an afp2html.ini file. It is taken from the sample default
configuration that ships with ODWEK.
[default]
UseApplet=TRUE
ScaleFactor=1.0
CreateGIF=TRUE
ShadeFlag=FALSE
SuppressFonts=FALSE
FontMapFile=
ImageMapFile=c:\inetpub\scripts\ondemand\imagemap.cfg
The sample file contains one explicit configuration for the application CREDIT of
the application group CREDIT. For all other applications, the configuration values
of the [default] section apply.
ScaleFactor Scales the output with the given scale factor. The default value
is 1.0. The default size is derived from the Zoom setting on the
Logical Views page in the OnDemand application.
FontMapFile Identifies the full path name of the font map file. The font map
file contains a list of fonts that require special processing. See
the AFP2WEB Transform documentation for details about the
font map file.
ImageMapFile Identifies the image mapping file. The image mapping file can
be used to remove images from the output, improve the look
of shaded images, and substitute existing images for images
that are created by the AFP2WEB Transform. Mapping
images that are common across your AFP documents, for
example, a company logo, reduces the time that is required to
transform documents.
For more detailed information about the configuration values that you can set in
the INI files, see Appendixes F and G in the IBM DB2 Content Manager
OnDemand for Multiplatforms Ver 8.4: Web Enablement Kit Implementation
Guide, SC18-9231.
Configuring AFP2PDF
For the AFP2PDF transformation, only a subset of the AFP2WEB options is
applicable. That is ImageMapFile and AllObjects, which are described in
Table 10-1 on page 207.
208 IBM Content Manager OnDemand Web Enablement Kit Java APIs: The Basics and Beyond
In addition to these two common options, there is the OptionsFile option. The
OptionsFile parameter identifies the full path name of the file that contains the
transform options that are used by the AFP2PDF Transform. The transform
options are used for AFP documents that require special processing. See the
AFP2PDF Transform documentation for details about the transform options file.
The configuration of the ODWEK session is done by using a set of properties that
are set in the constructor of the ODConfig class. In addition to the standard
parameters that are mandatory, you can create an instance of an ODConfig
object by specifying an additional parameter of type Properties. In this Properties
object, place the data that ODWEK must know about each transformation:
Installation directory
Path to the INI configuration file
Example 10-3 shows how to create an ODConfig object. You can then use this
ODConfig object to initialize the ODServer object.
props.put(
ODConfig.AFP2PDF_CONFIG_FILE, "c:\\opt\\afp2pdf\\afp2pdf.ini");
props.put(
ODConfig.AFP2PDF_INSTALL_DIR, "c:\\opt\\afp2pdf");
props.put(
ODConfig.AFP2HTML_CONFIG_FILE, "c:\\opt\\afp2web\\afp2html.ini");
props.put(
ODConfig.AFP2HTML_INSTALL_DIR, "c:\\opt\\afp2web");
To use the AFP2WEB Transform, you can use the following viewer conversions
as a parameter for the ODHit.retrieve() method. See 9.7, “Retrieving converted
data” on page 193, for a more detailed description of how to use the viewer
conversion constants.
ODConstant.HTML converts the AFP to HTML.
210 IBM Content Manager OnDemand Web Enablement Kit Java APIs: The Basics and Beyond
10.4 Xenos transforms
Xenos transforms can be used to apply transformations to AFP, line data, and
Metacode documents when retrieving them from an OnDemand server. For
example, you can use ODWEK to retrieve a Metacode document from the
system, call the Xenos transform to convert the Metacode document, and send
the converted output to the browser. The Xenos conversion is used with
ODConstant.XENOS when calling the ODHit.retrieve() method.
When retrieving documents from the system by using ODWEK, you can use the
Xenos transforms to perform the following tasks:
Convert AFP documents to HTML, PDF, or XML files.
Convert line data documents to AFP, HTML, PDF, or XML files.
Convert Metacode documents to AFP, HTML, PDF, or XML files.
Important: Before you attempt to use the Xenos transforms on your system,
you must obtain the transform programs, license, and documentation. See
your IBM representative for more information. Also see your IBM
representative for information about education and other types of help and
support for installing and configuring the transform programs and processing
input files with the transform programs.
The structure of the arsxenos.ini file is similar to the configuration files that are
used for the AFP2WEB Transform. For each application and application group, a
section must be created in the format [applicationgroup-application]. For all
applications that do not have specific sections, the [default] section applies.
Example 10-4 on page 212 shows a configuration for the CREDIT application
group and the CSTATEMENTS application.
Delay for large object support: If you enable large object support for very
large documents, users might experience a significant delay before they
can view the document.
212 IBM Content Manager OnDemand Web Enablement Kit Java APIs: The Basics and Beyond
WarningLevel
This option determines how ODWEK handles the return codes from the
Xenos transform. The Xenos transform sets a return code after each
document is converted. Use this parameter to specify the maximum return
code that ODWEK considers to be good and send the converted document to
the viewer. For example, if you specify a value of four (4), then the return code
that is set by the Xenos transform must be four or less. Otherwise, ODWEK
does not send the converted document to the viewer. The default value is
zero.
The main part of configuring Xenos is done in the ParamFile and ScriptFile by
using conversion parameters and script statements. For information and samples
about how these files should look like, see Appendix E, “Xenos transforms” in the
IBM DB2 Content Manager OnDemand for Multiplatforms Ver 8.4: Web
Enablement Kit Implementation Guide, SC18-9231, or the Xenos product
documentation.
The configuration of the ODWEK session is done by using a set of properties that
are set in the constructor of the ODConfig class. In addition to the standard
parameters, which are mandatory, you can create an instance of an ODConfig
object by specifying an additional parameter of the Properties type.
Example 10-5 shows how an ODConfig object be displayed. If you want to use
the AFP2WEB Transform as well, you must include the AFP2PDF or AFP2HTML
configuration values such as shown in Example 10-1 on page 207.
props.put(ODConfig.XENOS_CONFIG_FILE, "c:\\xenos\\arsxenos.ini");
props.put(ODConfig.XENOS_INSTALL_DIR, "c:\\xenos");
Further information
You can find information about how to integrate configure and use Xenos with
OnDemand and ODWEK in Appendix E, “Xenos transforms” in the IBM DB2
Content Manager OnDemand for Multiplatforms Ver 8.4: Web Enablement Kit
Implementation Guide, SC18-9231.
214 IBM Content Manager OnDemand Web Enablement Kit Java APIs: The Basics and Beyond
11
Another example of using the update API might be for documents that are
archived with references to SAP® business objects. Instead of writing a user exit
program that is invoked during the load process, you can create a Java
application that later queries additional data from SAP and updates the index
values in OnDemand.
Depending on how you use OnDemand, you can also implement some custom
applications by using the ODWEK Java APIs where you might want to change
index values on a regular basis. For example, you might want to use a flag field to
represent the current state of a document in a workflow.
216 IBM Content Manager OnDemand Web Enablement Kit Java APIs: The Basics and Beyond
Both methods work by using a hash table, which contains field name and field
value pairs. The field names that are used here are not the names of the
database fields that you have set when creating the application group. Instead
you must specify the field names as they are used in the folder through which this
document is accessed. All fields and values should be specified to avoid errors.
The value to which you want to update a database field must be specified as a
string. Despite the fact that a hash table can take all Java data types, storing a
data type other than string in the hash table results in an exception. The strings
are evaluated and converted automatically into the data type that is required by
the application group. Similar techniques for converting strings are used in the
generic indexer.
Date formats
When altering database values of the date format, you must specify the date in a
standard U.S. format. That is, a date and time in the range '01/01/70' to '09/17/59'
is required. Two-digit years less than 70 are interpreted as year 20nn.
Note: The date format, which is configured in the load information of the
application (by using OnDemand administrator), is not evaluated here. You
must use the U.S. date format.
Use of the DocID: Because the DocID is constructed every time an ODHit is
created (or the index field values of the hit are changed), do not use it as a
persistent never changing value. Instead use it only as a short-term document
reference.
Also, the DocID is an IBM internal data type, and it can change at anytime. Do
not attempt to parse data from this structure. If data stored within the DocID is
required by your application, see ODHitProperties.
Permissions
If you update the document database values, the user ID that you use must have
the Document Update permission set in the application group.
The permission is set by selecting the Update check box of the Document
section on the Permissions tab of the application group properties in the
Administrator.
You can check whether the user ID that you logged in with has the permissions to
update database index values for a document by calling the
ODHit.hasPermToUpdateDoc() method. This method returns a Boolean value
that indicates whether the user can perform an updateValuesforHit() method.
218 IBM Content Manager OnDemand Web Enablement Kit Java APIs: The Basics and Beyond
11.2 Storing documents
OnDemand provides monitored directories and the ARSLOAD command to load
data into the archive. Therefore, storing or archiving documents into an
OnDemand system is usually a task that is not done by using the ODWEK Java
APIs. However, in some use cases, you might need to directly store documents
into Content Manager OnDemand by using the ODWEK Java APIs as an ad hoc
method.
Because the method is in the ODFolder class, you must first open a folder that
maps the application group into which you want to store data. The parameters
that are required by the storeDocument() method are self-explaining:
path specifies the path to the file in the local file system on which the
application is running.
appl_grp_name specifies the application group name.
appl_name specifies the application name.
values[] specifies an array of strings that contain the database field values
for the new document.
The array that contains the index values for the new document is a
one-dimensional string array. The order in which the values are sorted in the
array is relevant for the method. You must specify the values for the application
group fields in the same order as they are displayed on the Field definition tab of
the application group.
If you do not know which fields are needed in which order, you can evaluate the
return of the ODFolder.getStoreDocFields() method. This method returns a
two-dimensional array for the application or application group. The returning
array contains either the application group field name (database field name) or
the folder field name, in the same order in which you must create your array of
new values for the storeDocument() method.
When creating the array of the index fields for the new document, set the value
for ARCHIVEDATE first, then for CUSTNO, and then for RPTID.
If you must enter date values, do not specify them in the mask that you set on the
Load Information tab. Instead provide the values in the form %m/%d/%y in the
220 IBM Content Manager OnDemand Web Enablement Kit Java APIs: The Basics and Beyond
range from ‘01/01/70’ to ‘09/17/59’ where years less than 70 are interpreted as
year 20nn. However, you can enter special characters such as t for the current
date.
Note: The date format, which is configured in the load information of the
application (by using OnDemand administrator), is not evaluated here. You
must use the U.S. date format.
All other data is treated similar to the way in which the generic indexer converts
strings into the corresponding database data type.
Expiration type
Because the storeDocument() method does not use a real load process, you
cannot use this method on all application groups. For each application group, an
expiration type is configured. The expiration type determines how the system
expires and deletes data from the application group and can be of the following
types:
LOAD
LOAD is the default expiration type. The system deletes an input file at a time
from the application group. If the database organization is single load per
database table, the system deletes a segment (table of index data and
associated documents) at a time.
STORAGE MANAGER
The Object Access Method (OAM) or Virtual Storage Access Method (VSAM)
storage manager deletes the data. The storage manager works with the
ARSEXPIR program.
SEGMENT
The system deletes a segment (table) of data at a time from the application
group.
DOCUMENT
The system deletes a document from the application group depending on the
value of the Expire Data field.
Because no load process exists in storing a document, you cannot store any
documents into an application group that has the expiration type set to LOAD.
The application group must be set to either SEGMENT or DOCUMENT in order
to enable the storeDocument() method. Calling the storeDocument() method with
an expiration type of LOAD raises an ODException with the following message:
The server failed while storing a document.
ODWEK contains the deleteDocs() method in the ODFolder class. This method
requires a vector of ODHit objects. The purpose of the method is to remove the
documents from the OnDemand database. The API is not designed to remove
documents physically, which is a process that is often not possible, because data
is aggregated into blocks and stored under control of WORM-media or an IBM
Tivoli® Storage Manager system.
By calling the deleteDocs() method on documents, the database rows for these
documents are deleted. The documents are no longer searchable, retrievable, or
displayed on any hitlists. Also, because the exact position on the data blocks
cannot be recovered, the document cannot be recovered in any way.
Permissions
By default, user IDs do not have permission to delete documents even if they are
system administrators. You must manually set the permission in the application
group for each user ID or user group. The permission is set by using the Update
check box of the Document section on the Permissions tab of the application
group properties.
You can check whether the user ID that you are logged in with has the
permissions to update database index values for a document by calling the
ODHit.hasPermToDeleteDoc() method. This method returns a Boolean value
that indicates whether the user can perform an ODFolder.deleteDocs() call.
222 IBM Content Manager OnDemand Web Enablement Kit Java APIs: The Basics and Beyond
12
General tuning of these subsystems is beyond the scope of this book. However, it
is important to plan enough capacity in each subsystem to support your
application’s anticipated usage. Also note that new Java releases frequently
incorporate performance enhancements. Therefore, keeping your Java platform
updated is an important element of performance management.
Internet
Internet CPU
Memory
(real, virtual)
intranet
intranet
I/O
(channels, disk I/O)
DASD
Network I/O
224 IBM Content Manager OnDemand Web Enablement Kit Java APIs: The Basics and Beyond
12.2 Memory
The interface that is presented to applications by core Java libraries is a standard
set by Sun™ Microsystems, but the internal workings of Java virtual machine
(JVM) implementations differ by operating system, JVM release, and vendor. In
the following sections, we avoid details or methods that are specific to particular
platforms and Java implementations.
Note: JVMs are continually enhanced. See the documentation for your
particular JVM for details concerning its internal operation.
Users of the IBM Java 5.0 implementation can consult the Java Diagnostics
Guide 5.0 at the following Web address for JVM profiling and troubleshooting
information:
http://publib.boulder.ibm.com/infocenter/javasdk/v5r0/index.jsp?topi
c=/com.ibm.java.doc.diagnostics.50/diag/problem_determination/aix_me
mory.html
Virtual memory
The operating system maps portions of physical RAM and hard disk into a virtual
address space, which applications see as one contiguous area of accessible
memory. The physical location of program data changes as the operating system
caches unneeded data to disk and loads currently needed data into random
access memory (RAM). This is done in units called pages. This page-swapping
system of virtual memory allows a group of running programs to consume more
memory than there is physical real memory (RAM).
Figure 12-2 on page 227 illustrates the concept of virtual address space for a
Java application. The size of the address space depends upon the hardware and
operating system. The 32-bit systems can address a theoretical 4 GB of memory
(232 one-byte addresses). The 64-bit systems can address terabytes to exabytes
of memory depending on the number of bytes per address.
The fraction of this address space that is available for use is often much less than
the theoretical maximum. Recent 32-bit Windows versions, for example, allow
programs to allocate up to 2 GB of memory, reserving 2 GB for the operating
system. Overhead and allocation inefficiencies reduce the usable amount to less
than 2 GB. Some 32-bit UNIX types allow programs to allocate roughly 3.75 GB.
The native heap comprises memory that the operating system allocates to a
process. The amount of memory available corresponds to the usable portion of
the virtual address space. The Java heap is allocated from this space.
A native stack is allocated by the operating system for each running thread. Each
Java thread has a corresponding native thread and resources that are requested
from the operating system by the JVM. Native libraries that are invoked through
the Java Native Interface (JNI™) can create their own threads independently of
Java.
The JVM requests Java heap memory from the operating system. The JVM
makes this space available for the storage of data that pertains to Java class and
array instances. The Java heap consumes a fraction of the total memory that is
available to the running JVM process or rather a fraction of the native heap.
Although it is common to speak of the Java and native heaps as though they
were separate entities, the Java heap is simply that portion of the available native
heap space that has been reserved by the JVM for this purpose. Most JVMs
require that the entire Java heap be allocated as one contiguous (that is,
unbroken) range of native memory addresses. Operating systems load native
libraries and other data into various portions of the process’ address space,
which fragments the address space. When this happens, the maximum Java
heap size is reduced to the largest remaining contiguous block.
226 IBM Content Manager OnDemand Web Enablement Kit Java APIs: The Basics and Beyond
Figure 12-2 shows the memory usage by Java applications.
ODWEK-based applications are Java programs that access native code by using
the JNI. As such, depending on the implementation, they might place additional
demands on the native heap separately from the JVM and Java heap. Optimizing
the memory usage of an ODWEK-based application involves maximizing the
amount of physical real memory (RAM) that is available to the running process. It
also involves balancing the fraction of this memory given to the Java heap
against the fraction that is remaining for use by the ODWEK native code.
Reducing the Java heap size frees memory for use by native components.
Virtual memory
Virtual memory’s swapping of pages to disk degrades performance dramatically.
If possible, do not allocate more memory than there is physical real memory
(RAM) in the system. In addition, avoid running other memory-intensive
applications on middle-tier machines that run ODWEK applications. Set equal
sizes for the operating system’s minimum and maximum page file sizes to
minimize page-file management.
Native libraries
The more native libraries that are loaded by a JVM process, the more likely it is
that the process’ native memory is fragmented. When possible, run ODWEK-
enabled applications in their own JVM process. Also, avoid loading other native
libraries into your ODWEK applications JVM process.
On Windows systems, if other shared libraries (dynamic link library (DLLs)) must
share a JVM process with ODWEK, sometimes it is possible to “rebase” those
other DLLs (not the ODWEK DLLs). By doing this, they occupy “out-of-the-way”
addresses in a virtual address space of a process. The object of rebasing DLLs
is to force them to occupy either very high or very low addresses, thus preserving
the maximum contiguous block in the middle.
Allocating memory: When allocating memory, make sure that enough native
memory remains unallocated to the Java heap to accommodate the volume of
data that flows through the native layer of the APIs.
Working with large amounts of native memory means working with a smaller
Java heap. In the following sections, we take a closer look at the Java heap
allocation and garbage collection and how to tune both.
228 IBM Content Manager OnDemand Web Enablement Kit Java APIs: The Basics and Beyond
There is a single Java heap per JVM, and a single JVM is instantiated per
process. Thus, the Java heap is shared by all threads that are running within a
process.
Note: The developer must ensure that access to object instances by multiple
threads does not result in unexpected behavior. See 6.4, “Thread safety” on
page 128.
System memory
Maximum size
Java Heap
Current size
Object n
Object 3
Object 2
Minimum size
Object 1
AIX 4 MB 64 MB
zOS 1 MB 64 MB
Stack memory is allocated in frames, each of which represents one method call.
Nested method calls have the effect of pushing multiple frames onto the stack,
which is why a stack trace partially exposes a program’s flow of execution. Some
JVM implementations support parameters that control initial stack size.
Memory allocation failures that involve a thread’s stack throw the following types
of errors:
If a thread requires a larger Java stack than the maximum stack size, then the
JVM throws a StackOverflowError.
If the JVM has insufficient memory to create or expand the Java stack, then
the JVM throws an OutOfMemoryError.
230 IBM Content Manager OnDemand Web Enablement Kit Java APIs: The Basics and Beyond
12.5 Garbage collection
Applications continually create and release object references. At some point,
attempts to allocate new object instances begin to fail. Or a usage threshold is
reached, and the JVM attempts to deallocate unused objects and return memory
to the Java heap. The Garbage Collector is the agent that is responsible for
deallocating unused memory and compacting the used memory in the Java
heap. This process increases the contiguous free memory in the Java heap.
When a given object can no longer be reached through references that are held
by active object instances, the JVM marks the unreferenced object as unneeded,
that is, as garbage. The garbage collection process removes garbage objects
that are marked as garbage from the heap and compacts the memory that is
used by the remaining objects.
It is rare that significant garbage collection delays occur after tuning the serial
Garbage Collector. However if garbage collection performance problems persist,
consider using a more sophisticated garbage collection implementation. Large,
multi-threaded applications that run on multiple processors and use large
amounts of memory can benefit. See your Java vendor’s documentation for other
garbage collection options.
Garbage Collection
Object 2
(not in use) Vector
free
Reachable
objects
Object 1 Object 1
(in use) (in use)
compare compact
Object 3
Vector (in use) Compacted
In use
Object 3 allocated Object 3 objects
(in use) objects (in use) Object 1
(in use)
JVM heap
JVM heap after GC
before GC
While the Garbage Collector is running, the JVM appears to be frozen. This is
because the JVM must lock all objects in memory, preventing access to them
while Garbage Collector runs. The duration of the garbage collection process is a
function of the number of objects in the heap, especially the number of live
objects. The larger the heap is, the more likely more objects will exist, and
therefore, the longer the garbage collection process will run. The number of
processors also affects garbage collection time. That is more processors require
a longer collection time.
232 IBM Content Manager OnDemand Web Enablement Kit Java APIs: The Basics and Beyond
Tuning the garbage collection process: Tuning the garbage collection
process is a priority for applications that maintain large heaps or run on
multiple processors.
As illustrated in Figure 12-5, garbage collection (GC) for a large heap runs longer
but less frequently. Garbage collection on a small heap runs faster but more
often. While large and small are relative terms, the ideal size depends on your
use of the ODWEK Java APIs.
GC GC GC GC GC GC GC GC
Time
Time
Wait times
Throughput
Figure 12-5 Garbage collection frequency and its impact on wait time and throughput
Throughput
Throughput is the percentage of time spent on activities other than collecting
garbage over a long time period. Throughput includes time spent in allocation of
memory and other memory management activities.
Wait time
Wait time is the percentage of time that an application appears unresponsive
because garbage collection is running.
Memory usage
Memory usage counts the memory that is allocated while a process is running.
Limited physical memory negatively affects system scalability.
A practical heap allocation strategy is to set the heap size large enough that you
do not run out of memory. However, do not set the heap size so large that there is
room to store too many marked-as-garbage objects before a garbage collection
occurs.
When objects are first created, they are allocated in the young generation space.
As these objects age, they move to the tenured generation space. Objects that
describe classes and methods are stored in the permanent generation space.
234 IBM Content Manager OnDemand Web Enablement Kit Java APIs: The Basics and Beyond
Minor collections, which run only against the young generation space, execute
faster than collections that run against the entire heap. Ideally, minor collections
involve the removal of many objects. Major collections run against the tenured
generation space. They run less frequently and take longer than minor
collections, and typically remove fewer objects. The size of the permanent
generation space is important for applications that dynamically generate and
load a large number of classes. If the permanent generation space does not have
enough memory, then an OutOfMemoryError is thrown.
At JVM initialization, only the initial (minimum) size of the Java heap is allocated.
The maximum size of the Java heap memory is virtually reserved but not
allocated. The young, tenured, and permanent spaces each consist of allocated
and virtual memory.
Generation sizing involves trading off throughput, wait time, memory usage, and
memory availability. Figure 12-7 presents a decision matrix for the sizing of the
young and tenured generation spaces.
Large Large
Large young tenured
generation generation
Object
size
Small Small
Small young tenured
generation generation
Short Long
Object lifetime
-help
The java -help or java -? command produces a list of the supported command
line options as shown in Example 12-1.
236 IBM Content Manager OnDemand Web Enablement Kit Java APIs: The Basics and Beyond
-cp <class search path of directories and zip/jar files>
-classpath <class search path of directories and zip/jar files>
A ; separated list of directories, JAR archives,
and ZIP archives to search for class files.
-D<name>=<value>
set a system property
-verbose[:class|gc|jni]
enable verbose output
-version print product version and exit
-version:<value>
require the specified version to run
-showversion print product version and continue
-jre-restrict-search | -jre-no-restrict-search
include/exclude user private JREs in the version
search
-? -help print this help message
-X print help on non-standard options
-ea[:<packagename>...|:<classname>]
-enableassertions[:<packagename>...|:<classname>]
enable assertions
-da[:<packagename>...|:<classname>]
-disableassertions[:<packagename>...|:<classname>]
disable assertions
-esa | -enablesystemassertions
enable system assertions
-dsa | -disablesystemassertions
disable system assertions
-agentlib:<libname>[=<options>]
load native agent library <libname>, e.g.
-agentlib:hprof
see also, -agentlib:jdwp=help and
-agentlib:hprof=help
-agentpath:<pathname>[=<options>]
load native agent library by full pathname
-javaagent:<jarpath>[=<options>]
load Java programming language agent, see
java.lang.instrument
-splash:<imagepath>
show splash screen with specified image
-Xprof
The -Xprof option causes the JVM to report CPU activity. A report is generated
for each terminating thread that shows the methods that consumed the most time
while that thread ran.
238 IBM Content Manager OnDemand Web Enablement Kit Java APIs: The Basics and Beyond
Example 12-3 shows an example of output that is generated by using the -Xprof
parameter in a batch program that is connected to an OnDemand server over
dial-up. Each thread’s output is delimited by a header that starts, “Flat profile
of...” and provides these details:
In the first column, the percentage of CPU time spent executing a given
method (or function in the case of a JNI invocation)
In the second column, the amount of time spent in Java code
In the third column, the amount of time spent in native code
In the fourth column, the name of the method or function that is being
executed
The methods are ordered by percentage of CPU time taken to execute, with the
method that took the longest listed first. The global summary at the end of the
profile provides information such as how much time was spent loading classes.
Thread-local ticks:
0.0% 2 Class loader
0.0% 2 Unknown: thread_state
Thread-local ticks:
99.2% 6781 Blocked (of total)
33.3% 19 Class loader
Thread-local ticks:
50.0% 2 Class loader
25.0% 1 Unknown: thread_state
240 IBM Content Manager OnDemand Web Enablement Kit Java APIs: The Basics and Beyond
-verbose[:class|gc|jni]
The -verbose:gc option causes the JVM to output information about each
garbage collection event. In Example 12-4, you see two minor garbage
collections and a full garbage collection.
The number before the arrow shows the total size of all objects before the
garbage collection.
The number after the arrow gives the total size of all live objects after the
garbage collection.
The number in parenthesis gives the total available heap space in the young
and tenured generation spaces. The permanent generation is not counted.
The value 0.0042673 secs is the amount of time that it took the Garbage
Collector to run.
-XX:+PrintGCDetails
The -XX:+PrintGCDetails option causes the JVM to output detailed information
about each GC event. As illustrated in Example 12-5, this information includes:
The generation or generations that are affected
Space allocated to objects before and after garbage collection
Total available space
Time taken to perform the garbage collection
After all threads terminate, a heap summary is produced that shows the memory
usage for the overall process.
–XX:+PrintGCTimeStamps
The –XX:+PrintGCTimeStamps option when used with the -XX:+PrintGCDetails
option produces a time stamp at the start of each garbage collection in addition
to the information provided by -XX:+PrintGCDetails. The time stamps are
relative to the start of process execution and reveal the timing and duration of
garbage collection events. Example 12-6 shows sample output is produced by
using this option.
242 IBM Content Manager OnDemand Web Enablement Kit Java APIs: The Basics and Beyond
things, including a stack for each thread. It is normal for the total memory
consumed by the JVM to exceed the value of -Xmx.
-Xms
The -Xms parameter changes the initial (minimum) size of the Java heap memory
allocation from its default value. The default value is listed in Table 12-1 on
page 230. The value is specified in bytes. Typical values are in the MB range.
The following examples show the different syntax for specifying memory:
-Xms6291456
-Xms6144k
-Xms6m
-Xmx
The -Xmx parameter changes the maximum size of the Java heap memory
allocation from its default value. The default value is listed in Table 12-1 on
page 230. The value is specified in bytes. Typical values are in the MB range.
The following examples show the different syntax for specifying memory:
-Xmx83886080
-Xmx81920k
-Xmx80m
-Xmn
The -Xmn parameter indicates the size of the heap for the young generation
space.
Value: The value of -Xmn should be less than the value of -Xmx.
-Xss
Each Java thread has two stacks, one for Java code and one for native code. The
-Xss option sets the maximum thread stack size that can be used by the native
code in a thread. Every thread that is spawned during the execution of the
program has the specified value as its native stack size.
When a garbage collection occurs, the JVM resizes the heap to keep its usage
within the range specified by -Xms and -Xmx. When possible, the new size reflects
a desired fraction of free space, determined by the following parameters:
-XX:MinHeapFreeRatio=<minimum>
-XX:MaxHeapFreeRatio=<maximum>
Memory management involves trading off Garbage Collector run time and run
frequency. If Garbage Collector runs often while always freeing memory, the Java
heap is probably filling too quickly, and the application can benefit from a larger
heap. In addition to using the -Xmx option to specify a larger heap, you can adjust
the heap free ratio so that the every current heap allocation anticipates your
application’s forward needs.
For example, if you specify a minimum free space ratio of 30% (expressed as 0.3
for the IBM JVM or 30 for the Sun JVM), then the virtual memory expands the
heap to try to keep at least 30% of the heap free. By increasing this number
beyond the default setting, you force the virtual memory to increase the heap
size in anticipation of increasing usage.
Setting the initial memory allocations -Xmx and -Xms to the same size prevents
dynamic resizing of the heap, making any FreeRatio setting superfluous.
Even if the minimum (-Xms) heap is small, you must specify the maximum heap
size to ensure that one contiguous area is available should the heap require
expansion.
244 IBM Content Manager OnDemand Web Enablement Kit Java APIs: The Basics and Beyond
To evaluate virtual memory management:
1. Use a load generator program to test the performance of the Web server or
application under the maximum expected load.
2. Use the -verbosegc option to measure time and resources that are consumed
by the garbage collection.
3. Redirect standard error and standard output to a log file as in the following
example:
Java <parameters> -verbosegc >> logfile.txt
4. Review the timestamps of the log outputs. Note the frequency of garbage
collections and the time taken for each. Also note the average memory usage
by checking the heap size after each garbage collection.
If the garbage collection process always frees most of your heap and the process
runs for too long a period, consider reducing the heap size so that Garbage
Collector runs more often. Always remember to retest your application under
maximum load to verify the impact of changes.
If your system spends too much time on garbage collection, it is possible that
your heap size is larger than the available physical memory, causing the
operating system to swap portions of the heap from memory to disk and back.
Your system administrator can help you determine the amount of free physical
memory on your system.
Tip: Setting -Xms and -Xmx to the same value can improve performance by
eliminating the memory allocation and deallocation that are involved in
keeping the heap size within a range.
The NewSize and MaxNewSize parameters control the minimum and maximum
size of the young generation space. Setting parameters equal to one another has
the same effect on the young generation space as setting the -Xms and -Xmx
parameters equal on the total heap.
The design and usage of your ODWEK application determines the ratio of the
size of the young generation space to size of the tenured generation space.
Enough free memory must be reserved in the tenured generation space to
accommodate all the live objects from the young generation space.
Tip: If your application creates large numbers of objects whose life times are
skewed heavily toward either transience or long life, consider tuning the JVM’s
heap generations.
Requests for data from the OnDemand server flow from your application through
the Java component of the ODWEK Java APIs to the native component. The
native component makes the TCP/IP connection to the OnDemand server, sends
requests, and receives the results. Upon receipt of the results, bulk data, such as
Advanced Function Presentation (AFP) resources and document data, are
stored in the native heap.
Adjust the size of the native heap, by allocating a smaller maximum Java heap to
free more native memory or vice versa, according to the size of your documents
and the expected number of concurrent retrievals. This adjustment entails a kind
of balancing act, since the Java component of the ODWEK Java APIs caches
document data in Java arrays. The size of the Java heap must be large enough to
accommodate the data, but in general, memory allocation should be biased in
favor of native space.
246 IBM Content Manager OnDemand Web Enablement Kit Java APIs: The Basics and Beyond
The sizes of the Java and native stacks, which reflect the number and depth of
active method calls, are most affected by the number of concurrent threads that
are maintained by the Web server or application. The number of threads usually
correlates with the number of concurrent users.
12.7.1 Network
Web server applications establish multiple network connections to the
OnDemand server and to browsers or other clients. Ensure that TCP/IP stacks
and network routes to both are configured for efficiency. Terminology and support
for parameters given in the following sections vary by platform. Therefore, we
present general descriptions, rather than specific instructions.
Number of sockets
Web server applications connect to the OnDemand server and browser clients,
and constantly create and destroy sockets. Verify that your system defines
enough sockets and that your application is not delayed by waiting for in-use
sockets to be freed.
For example, if the TCP/IP receive buffer is too small, the receive window is
prone to overrun. Upon overrun, the flow control mechanism stops data transfer
until the receive buffer is empty. Flow control can consume significant CPU time
and result in additional network latency.
Keep in mind that TCP/IP buffers can be too large. If applications do not process
data fast enough, paging can increase. The goal is to specify a value that is large
enough to avoid undue flow control overhead, but not so large that the buffer
accumulates more data than the system can process.
nodelayack option
If the nodelayack option is left unset, TCP waits for the buffer to fill before
sending. This option reduces the number of TCP sends and thus decreases
stack overhead. It is good for sending large amounts of data (documents). When
small quantities of data are to be sent, as for requests, you normally want
immediate transmission for improved response time and accept additional CPU
utilization as a cost for the additional flow control.
Setting the nodelayack option causes the data to be sent by TCP/IP as soon as
applications request that it be sent. The combination of a large buffer size and
setting the nodelayack option usually improves overall performance for mixed
small (control) and large (data) transmissions.
248 IBM Content Manager OnDemand Web Enablement Kit Java APIs: The Basics and Beyond
MaxConnect Backlog
The MaxConnect Backlog parameter indicates the maximum number of
connections that can be queued when waiting for TCP socket assignment.
Increase this number if many connection attempts are received simultaneously
and you know that they will be serviced relatively quickly before the waiting
connections time out.
Keepalive_interval
The Keepalive_interval option is the default TCP keep-alive interval for
applications that enable the SO_KEEPALIVE socket option. Do not override the
interval by using the TCP_KEEPALIVE option. A typical range is 0-35791 minutes,
with a default of 120. A value of zero (0) disables the keep-alive function so that
sockets for which SO_KEEPALIVE is specified do not perform the TCP keep-alive
function. In this case, sockets that specify an interval by using TCP_KEEPALIVE
continue to send keep-alive probes.
When thousands of sockets are constantly created and disposed, the delay is an
unnecessary load on the system. Performance testing usually reveals an
appropriate value of considerably less than five minutes.
MTU_size
The maximum transmission unit (MTU) in bytes. The MTU_size value can be up
to 65535. The default value of this field can be as low as 576. Larger units are
more efficient for transmitting large amounts of data, but are more costly to
recover in the event of a transmission error. In general, a smaller MTU works
better on slow or unreliable networks that drop packets frequently, such as over
dial-up or DSL. Larger MTU sizes are appropriate for fast, reliable networks.
Network adapters
Your Web server application transmits a lot of data both from the OnDemand
server and to browser clients. Verify that your network adapters are running both
full duplex and at the maximum transfer rate that is supported by the cards and
your network.
Spread the disk processing across as many disks as possible to avoid contention
issues that can occur with one- or two-disk systems. Placing database tables on
separate disks from those that store database logs reduces contention and
improves throughput.
12.7.3 Processor
In the absence of other bottlenecks, increasing the processor speed improves
throughput and response time. A processor with a larger L2 or L3 cache yields
higher throughput than a processor of the same speed with a smaller cache.
250 IBM Content Manager OnDemand Web Enablement Kit Java APIs: The Basics and Beyond
13
252 IBM Content Manager OnDemand Web Enablement Kit Java APIs: The Basics and Beyond
Enabling the ODWEK trace engine
To enable trace logging, specify the appropriate traceDir and traceLevel
parameter values when initializing the ODConfig object that is passed to new
ODServer connections. See Example 13-1.
The traceLevel parameter controls the level of detail and minimum severity of
entries that is written to the arswww.trace file. Table 13-1 describes the output
that each trace level produces.
Higher levels are used to troubleshoot current ODWEK issues. Lower levels are
used to monitor an ODWEK application that is in a steady state. For example, in
a test environment, setting traceLevel to 1 entails minimal overhead while
informing you of errors.
Important: A full trace (level 4) can degrade performance. Always set the
trace level to 1 (ERROR) so that ERROR generation occurs when there is an
error. In addition, always monitor the trace files to catch and respond to errors
as soon as they occur. The ERROR trace level has little or no impact in
production, as long as errors are not occuring.
Trace files are located in the directory given by the traceDir parameter. A new
trace file is created when an application’s first ODServer object is initialized. A
new trace file is also created when the first new ODServer is initialized after all
previous ODServer connections are logged-off and terminated. Any existing
trace file is renamed to arswww.trace<timestamp>. Ensure that adequate disk
space is available on the directory’s file system. The historical trace files must be
deleted manually to avoid exhausting the file system.
The output of the arswww.trace file includes the following columns, which are
output in a comma-separated format (CSV):
PPID: The current working or child process ID
PID: The parent process ID
TID: The current thread ID for this request (typically maps to a user session)
DATE: Date in the month/day/year format
TIME: Transaction time stamp
LEVEL: Level of message
FUNCTION: The native function to which the message applies
OUTPUT: Detailed message text
254 IBM Content Manager OnDemand Web Enablement Kit Java APIs: The Basics and Beyond
If you receive an ENTER or RETURN message, then a numeric value that
represents the ODWEK session ID for the function call is in the OUTPUT field.
Error messages
To check for error messages, search the LEVEL column for ERROR. Examine
the FUNCTION column and determine which function was executing when the
error occurred. Then work your way backward through the trace to determine the
cause of the error, which may be the result of the following common culprits:
Bad data passed to the function
Network failure
Poor response time from the server due to network bottlenecks or server
overload
Check the server log to determine the server’s load.
Out-of-memory condition
Errors that are thrown by Content Manager OnDemand native components are
written as text in the patterns CSV_RC=<num> and CSV_ID=<Num>. A detail message
is normally provided. See 13.1.5, “Return codes and message IDs” on page 258,
for tables of return codes and message IDs.
Performance
To check for performance issues, compare consecutive time stamps in the TIME
column. Time differences between the most consecutive entries are subsecond
except while data is retrieved from the server. Identify any large time difference
between one time stamp and the next and note the function that is indicated in
the FUNCTION column.
The time that is required to return data from the server might be several seconds
or more. Retrieval performance depends on the OnDemand server’s capacity, the
quantity of data that is returned, network speed, and (if present) the middle tier
256 IBM Content Manager OnDemand Web Enablement Kit Java APIs: The Basics and Beyond
Table 13-2 shows the arswww.trace details for the same retrieve() call that is
given in Example 13-2. To obtain a similar table for your trace, import your file
into Microsoft Excel® as CSV.
Table 13-2 Details of the arswww.trace file for the retrieve() call in Example 13-2
PPID PID TID DATE TIME LEVEL FUNCTION OUTPUT
3272 4196 316 2/17/2007 3:59:42 INFO Java_com_ibm_edms_ Document type is 'T'
od_ArsWWWInterface_
apiRetrieve
0 CSV_RC_OKAY
1 CSV_RC_OKAY_WITH_MESSAGE
2 CSV_RC_CANCEL
3 CSV_RC_PASSWORD_CHANGE
4 CSV_RC_DOC_UNAVAILABLE
5 CSV_RC_INVALID_SEARCH
6 CSV_RC_NO_PERMISSION
7 CSV_RC_TIMEOUT
8 CSV_RC_DATA_CONVERSION_ERROR
9 CSV_RC_MISC_ERROR
10 CSV_RC_EXISTS
258 IBM Content Manager OnDemand Web Enablement Kit Java APIs: The Basics and Beyond
13.2 Common problems and their solutions
In this section, we cover the following common problems and their solutions:
Application is unresponsive or JVM out-of-memory error occurs.
Application terminates with a ‘DLL could not be found’ message.
Performance degrades with a large number of server connections; the
OnDemand server refuses network connections (Windows only).
Document retrieval is long-running.
Folder search does not produce a correct hitlist after upgrading ODWEK.
Entire document is not retrieved.
When the JVM cannot allocate enough Java heap memory for the current
operation, the JVM throws an out-of-memory error and exits.
You might have to lower your maximum Java heap allocation to accommodate a
larger native heap. See Chapter 12, “Memory and performance” on page 223,
especially 12.6, “Startup parameters” on page 236, for more information about
native and Java heap allocation. As a rule-of-thumb, set the native heap size
based on the following equation:
2 x (average document size) x (number of concurrent users)
Applications that run on 32-bit Java platforms might continue to run out of
memory despite allocation and tuning of the maximum possible 32-bit heap.
Consider upgrading such 32-bit installations to 64-bit versions, which support a
much larger address space for both native and Java heaps. A better solution is
for them to modify their application to use the retrieve to file operation, which
completely removes this problem.
When dealing with large AFP resources, also consider implementing custom
AFP resource caching, by which you can avoid holding large AFP resources in
The ODWEK Java APIs are not 100% Pure Java™. There are both native and
Java code. For the native code, the Java run time (JVM) must be told where to
find these native libraries, just as it must be told where to find the Java classes
that you want to execute. While Java classes are located by using the classpath
setting (command line argument or environment setting), the location of native
shared libraries is specified by the java.library.path virtual memory argument.
This solves the loading of libraries that are loaded by using the
System.loadLibrary Java method call. If any of these libraries have other libraries
that they need to load, such as ICU, then these other libraries can only be found
through the environment path variable.
260 IBM Content Manager OnDemand Web Enablement Kit Java APIs: The Basics and Beyond
To specify the java.library.path at the command line, use the -D parameter, as
in the following example (Windows style, with ODWEK installed in the default
directory):
java -cp ".;C:\Program Files\IBM\OnDemand Web Enablement
Kit\api\ODApi.jar" redbook.PingServer -Djava.library.path="C:\Program
Files\IBM\OnDemand Web Enablement Kit"
If the netstat reports usage of port numbers in the high 4000s, it is possible that
the Windows default of 5000 user ports is exhausted by heavy traffic. When that
happens, network connections to and from the affected machine are rejected.
To resolve this, update the registry values for TcpTimedWaitDelay and MaxerPort
on machines that are subject to high network traffic.
TcpTimedWaitDelay
TcpTimed WaitDelay determines the time that must elapse before TCP/IP can
release a closed connection and reuse its resources. This interval between
closure and release is known as the TIME_WAIT state or twice the maximum
segment lifetime (2MSL) state.
During this time, reopening the connection to the client and server costs less
than establishing a new connection. By reducing the value of this entry, TCP/IP
can release closed connections faster and provide more resources for new
connections. Adjust this parameter if the running application requires rapid
release, the creation of new connections, or an adjustment because of a low
throughput caused by multiple connections in the TIME_WAIT state.
262 IBM Content Manager OnDemand Web Enablement Kit Java APIs: The Basics and Beyond
To view or set TcpTimedWaitDelay:
1. Type the regedit command.
2. Access the registry subkey HKEY_LOCAL_MACHINE\SYSTEM\
CurrentControlSet\ Services\TCPIP\Parameters, and create a new
REG_DWORD value named TcpTimedWaitDelay.
3. Set the value to decimal 30, which is hexadecimal 0x0000001e. This sets the
wait time to 30 seconds.
4. Stop and restart the system.
The default value is 0xF0, which sets the wait time to 240 seconds (4 minutes).
We recommend that you use a minimum value of 0x1E, which sets the wait time
to 30 seconds.
MaxUserPort
MaxUserPort determines the highest port number that TCP/IP can assign when
an application requests an available user port from the system.
To view or set MaxUserPort:
1. Type the regedit command.
2. Access the registry subkey HKEY_LOCAL_MACHINE\SYSTEM\
CurrentControlSet\ Services\TCPIP\Parameters, and create a new
REG_DWORD value named MaxUserPort.
3. Set this value to at least decimal 32768.
4. Stop and restart the system.
The default value is 0x1388 (5000 decimal) for most Windows versions. We
recommend that you use a value from decimal 32768 to 65534. For more details,
see the following Microsoft document:
http://support.microsoft.com/kb/120642/
ODWEK does not directly support query or data transfer timeouts. However an
application can implement its own timeout feature and use the
ODServer.cancel() method to end long-running server requests. Supported
methods that can be canceled are logon, search, and retrieve. The call must be
made in a separate thread. Providing the cancel functionality enables the
application to respond to the client in a timely manner. Users can also find a
Cancel button convenient. Providing Web clients with this feature helps to avoid
orphaned server requests.
264 IBM Content Manager OnDemand Web Enablement Kit Java APIs: The Basics and Beyond
13.2.5 Folder search does not produce a correct hitlist after
upgrading ODWEK
Because an existing ODFolder reference is now reused, open folders retain any
previously set ODCriteria search values. Applications must either close folders
immediately after use or set all of their criteria before each search, setting
unused criteria values to null.
For more information about document retrieval with large object support enabled,
see 9.4, “Segmented retrieval and large object support” on page 187.
The contents of the dump file vary by operating system and JVM implementation,
but generally provide information about threads, memory, the native stack, and
locks. Some JVMs provide environment variables and runtime switches with
which you can customize the Java dump.
For more information, see IBM Thread and Monitor Dump Analyzer in IBM
alphaWorks® at the following address:
http://www.alphaworks.ibm.com/tech/jca
13.3.2 HeapAnalyzer
HeapAnalyzer is a graphical tool for discovering possible Java heap leaks. It
analyzes a Java heap dump and produces a heap map and a list of heap leak
suspect objects.
Find more information about HeapAnalyzer, see the following alphaWorks page:
http://www.alphaworks.ibm.com/tech/heapanalyzer
13.3.3 HeapRoots
HeapRoots is a another tool for debugging memory leaks in Java applications.
This tool provides commands to analyze heap dumps. Use HeapRoots to
investigate the heap object-by-object and to capture summary information and
statistics about the heap and the objects that are stored.
266 IBM Content Manager OnDemand Web Enablement Kit Java APIs: The Basics and Beyond
13.4.1 The jmap command
The jmap command is a command-line utility that produces a memory map for a
running JVM or Java application. We describe frequently used parameters in the
sections that follow. The jmap command requires the following command-line
usage:
jmap parameter pid
If no parameters are specified, then jmap prints a list of the shared objects that
are loaded.
For more information, see the Sun Web page at the following address:
http://java.sun.com/j2se/1.5.0/docs/tooldocs/share/jmap.html
-histo parameter
The –histo parameter produces a histogram of all the classes in the heap. For
each class in the heap, this parameter shows the class names, instance totals,
and the total number of bytes that are consumed by those objects. Example 13-3
shows a sample of the output of jmap -histo.
-heap parameter
The –heap parameter outputs the name and details of the garbage collector, the
heap configuration, and the heap usage summary.
-permstat parameter
The –permstat parameter lists statistics for the objects in the permanent
generation.
Definitions:
<option> An option reported by the -options option
<vmid> Virtual Machine Identifier. A vmid takes the following form:
<lvmid>[@<hostname>[:<port>]]
Where <lvmid> is the local vm identifier for the target
Java virtual machine, typically a process id;
<hostname> is the name of the host running the target Java virtual
machine; and
<port> is the port number for the rmiregistry on the target host. See
the jvmstat documentation for a more complete description of the
Virtual Machine Identifier.
<lines> Number of samples between header lines.
<interval> Sampling interval. The following forms are allowed:
<n>["ms"|"s"]
268 IBM Content Manager OnDemand Web Enablement Kit Java APIs: The Basics and Beyond
Where <n> is an integer and the suffix specifies the
units as milliseconds("ms") or seconds("s"). The default units are
"ms".
<count> Number of samples to take before terminating.
-J<flag> Pass <flag> directly to the runtime system.
For more information about the jstat command, see the Sun Web page at the
following address:
http://java.sun.com/j2se/1.5.0/docs/tooldocs/share/jstat.html
The output of HPROF includes CPU usage, heap dumps, monitors, and threads.
For a listing of supported HPROF parameters on your system, enter the following
command:
java -agentlib:hprof=help
Obsolete Options
----------------
gc_okay=y|n
Examples
--------
- Get sample cpu information every 20 millisec, with a stack depth of
3:
java -agentlib:hprof=cpu=samples,interval=20,depth=3 classname
- Get heap usage information based on the allocation sites:
java -agentlib:hprof=heap=sites classname
Notes
-----
- The option format=b cannot be used with monitor=y.
- The option format=b cannot be used with cpu=old|times.
- Use of the -Xrunhprof interface can still be used, e.g.
java -Xrunhprof:[help]|[<option>=<value>, ...]
will behave exactly the same as:
java -agentlib:hprof=[help]|[<option>=<value>, ...]
Warnings
--------
- This is demonstration code for the JVMTI interface and use of BCI,
it is not an official product or formal part of the JDK.
- The -Xrunhprof interface will be removed in a future release.
- The option format=b is considered experimental, this format may
change in a future release.
For more information about HPROF, see the Sun Developer Network Web page
at the following address:
http://java.sun.com/developer/technicalArticles/Programming/HPROF.html
270 IBM Content Manager OnDemand Web Enablement Kit Java APIs: The Basics and Beyond
13.4.4 Java Heap Analysis Tool (jhat)
Starting with Java SE 6, Heap Analysis Tool (hat) has been replaced with jhat,
which is included with the standard Sun distribution. jhat allows you to browse
the objects in a heap snapshot generated from HPROF, and can identify all
objects referenced by a root object.
For more information, see the Heap Analysis Tool 1.1 (HAT) page on java.net at
the following address:
https://hat.dev.java.net/
Alternatively, see the jhat page at the following address on Sun’s Web site:
http://java.sun.com/javase/6/docs/technotes/tools/share/jhat.html
Version 1.3 comes with built-in parsers for IBM JVM versions 1.5.0, 1.4.2, and
1.2.2. Developers can implement custom parsers for unsupported JVM levels.
For more information, see Diagnostic Tool for Java Garbage Collector page in
alphaWorks at the following address:
http://www.alphaworks.ibm.com/tech/gcdiag
13.5.1 JUNIT
JUnit is a free unit-testing framework that supports the development of
automated tests for the Java programming language. JUnit was created by Kent
Beck and Erich Gamma and has become an important standard (as many would
say) tool of test-driven development.
For more information about JUNIT, see the Web page at the following address:
http://www.junit.org/home
13.5.2 ConTest
ConcurrentTesting - Advanced Testing for Multi-Threaded Applications (ConTest)
improves the quality of testing by exposing potential problems earlier in the
testing process. ConTest controls the scheduling and execution of program
threads over multiple executions. Each time, it adds different sleep and yield
instructions to exercise program thread synchronization. By using a preferences
file, you can specify which of your classes are tested.
For more information, see the ConTest page at the following address:
http://www.alphaworks.ibm.com/tech/contest
272 IBM Content Manager OnDemand Web Enablement Kit Java APIs: The Basics and Beyond
Trace Analyzer
Trace Analyzer visualizes Cell Broadband Engine™ traces that contain
information such as direct memory access (DMA) communication, locking
and unlocking activities, and mailbox messages.
Control Flow Analyzer
Control Flow Analyzer is a tool that analyzes call trace data that is collected
by such tools as Jprof, which is part of Performance Inspector. The call trace
data contains information about each method call, such as how much time is
spent in every invocation and who calls whom.
The publications listed in this section are considered particularly suitable for a
more detailed discussion of the topics covered in this book.
IBM Redbooks
For information about ordering these publications, see “How to get Redbooks” on
page 277. Note that some of the documents referenced here may be available in
softcopy only.
Content Manager OnDemand Guide, SG24-6915
Implementing Content Manager OnDemand Solutions with Case Studies,
SG24-7511
Other publications
These publications are also relevant as further information sources:
DB2 Content Manager OnDemand for Multiplatforms Ver 8.4: Installation and
Configuration Guide, SC18-9232
DB2 Content Manager OnDemand: User's Guide, SC27-0836
IBM Content Manager OnDemand for i5/OS Common Server ODWEK
Installation and Configuration Guide, SC27-1163
IBM DB2 Content Manager OnDemand for Multiplatforms Ver 8.4: Web
Enablement Kit Implementation Guide, SC18-9231
IBM Content Manager OnDemand: Messages and Codes, SC27-1379
276 IBM Content Manager OnDemand Web Enablement Kit Java APIs: The Basics and Beyond
– ConcurrentTesting - Advanced Testing for Multi-Threaded Applications
(ConTest)
http://www.alphaworks.ibm.com/tech/contest
– Visual Performance Analyzer (VPA)
http://www.alphaworks.ibm.com/tech/vpa
280 IBM Content Manager OnDemand Web Enablement Kit Java APIs: The Basics and Beyond
considerations for SQL search 166 session 130, 136, 156
console application, sample 39 statement 92
constructor method 122 system 144–145
constructor ODServer method 113 system architecture 4
Content Manager OnDemand system overview 4
administrator 72, 99, 162–163, 192, 217, 221 Windows client code page configuration 156
application 8 ConTest 272
application group 9, 162, 165 contrast images 199
fields 32 Control Flow Analyzer 273
cabinet 9, 64 conversion
client AFP to PDF 103
application 17 browser 150
session 133 code page in ODWEK 149
connection 58–60, 93 document data 150
initial set 99 converted data, retrieving 193
data 6, 146 Counter Analyzer 272
indexing and loading 10 creator of note 37
model 7 criteria search 108, 162–165
database Unicode encoding 153 criterion
document 55, 77, 79, 99, 161, 169, 171 current operator 33
folder 9, 29, 55, 72, 93–94, 162–163 current values 33
field 55, 70–72, 169 display 34
field value 93 name 33, 35
information 66 operator 34
search 70, 74, 99 query 34
search field 70 required search value 34
instance 146, 148 search order 34
internal properties 36 search value 34
Internet Client 4 search values 34
Library Server 4 type 34
logical server 6 valid operators 34
multicultural support library 157 valid search value 33
Object Server 4 custom caching 186
origin of ODWEK Java APIs 4 custom callback 172
reports and documents 6 custom code pages, 156
server 59, 70, 108–109, 112–114, 144, 168, custom font mapping, handling 149
170, 181, 202, 227, 239, 255, 262 customization
application disconnects 90 AFP resource caching 264
code page 154 object generations 245
connection 95 of heap size 244
flow 246
index data 35
instance 153
D
data 6
memory 112
conversion 93, 146–149, 181, 183, 191
name 43
CMOD deals 147
port 122
ICU engine 157
potential performance issues 170
EBCDIC 180
side 112
index 10, 35, 147, 150, 221
server environment 4
Index 281
indexing 10 hit 36
loading 10 content retrieval 36
model 7 data 112, 146–147, 180, 183, 246
model classes 22 conversion 147, 150
OnDemand 146 data retrieval
read only 129 classes 35
resource 114, 137, 184–185, 218 data retrieval classes 23
internal ID 186 deletion 222
retrieval of converted data 193 ID 35, 103
transfer 199 indexing method 7
type 25–27, 29, 92, 162, 165, 180, 193, 217, indexing process 6
221 large object support 263
using the information 193 Metacode 211–212
database not retrieved, troubleshooting 265
code page, Unicode 152 notes 36
log 250 retrieval 36, 109, 142, 179–180, 260, 264
manager 5 impractically long time 264
Unicode encoding 153 troubleshooting 263
values retrieval, long-running 263
updating 216 storing 219
date storing and updating 109
search 170 type 32, 150, 191–192, 200
date format 166, 170, 217, 220 different actions 193
database values 217 hit 36
date•time note created 37 updating database values 216
DBCS (Double Byte Character Set) 144 document data conversion 149
default value 207, 213, 220, 230 document ID 36
deleteDocs() method 222 Document Update permission 218
diagnostic information 38 doGet 57, 94
diagnostic tools doPost 57, 94
HPROF 269 Double Byte Character Set (DBCS) 144
Java 266
jhat 271
jmap command 267
E
EBCDIC 145, 149
jstat command 268
data 180
disconnecting the application from the OnDemand
big flow 180
server 90
error
disk
code 38, 252
input 250
handling 38
performance 250
class 23
processing 250
ODException 38
speed 250
ID code 38
display field value 36
message 38, 260
display order 35, 66, 164, 167
reporting 252
distribution files 15
European code page 153
DLL not found 260
Extended Binary Coded Decimal Interchange Code
DLLs, rebasing 228
(EBCDIC) 145, 149
document 6
content
282 IBM Content Manager OnDemand Web Enablement Kit Java APIs: The Basics and Beyond
F getAFPViewerType() 26
Faces components 54 getAppletDirectory() 26
FINWAIT2TIME, network performance 249 getApplGrpNames() 30
first segment 183, 188, 190, 208, 212, 265 getApplication(String name) 31
remaining segments 183 getApplicationGroupName() 37
folder 9 getApplicationGroupNames() 33
application group 9 getApplicationName() 37
common query screen 9 getApplicationNames() 31
display a list of 70 getApplNames(String applGroup) 30
obtaining 63 getAscending() 33
open 112 getCabinets() 27
query 112 getConnection() 62
folder field 66, 70, 92, 162, 166 getCriteria() 30, 34
default format 163 getCriteria(String name) 30
default sort orders 167 getDateTime() 37
OnDemand administrator 164 getDefaultFmt 171
folder name getDescription() 29–32
hit 36 getDisplayValue(String criteriaName) 36
folderinfo.JSP 57 getDocId() 36
folderinfo.jsp 68 getDocType() 36
font map file 208 getDocument() 36, 188
frames 230 getDocumentType() 32
frequency getErrorId() 38, 252
garbage collection 245 getErrorMsg() 38
functional relationship of core API classes 23 getFields() 31
getFixedValues() 33
getFolderDescription(String fldname) 28
G getFolderName() 36
garbage collection 38, 228, 231
getFolderNames() 29
frequency 245
getFolders method 72
generational collection 234
getFolders() 28
log outputs 245
getHits() 30
memory availability 234
getLanguageForMessages() 26
memory usage 233
getLength() 37
phases 231
getLineViewerType() 26
process 245
getLoadName() 37
three-step process 231
getMaxNumberOfHitsToDisplay() 26
throughput 233
getMetaViewerType() 26
too much time 245
getMimeType() 36
tuning the process 233
getName() 29, 31–35
wait time 233
getNamedQuery() 30
Garbage Collector 231, 268, 271
getNamedQueryNames() 30
single-threaded (serial) 231
getNotes() 36
-verbose 241
getNumCabinets() 27
generational garbage collection 234
getNumCriteria() 34
major collections 235
getNumFolders() 28–29
minor collections 235
getNumSegments() 36
permanent generation space 234
getOperator() 33, 35
tenured generation space 234
getPageNum() 37
Index 283
getPrinterNames() 36 -histo parameter 267
getProperties() 36 hit
getQueryOrder() 169 AFP resources 36
getResourceID() 187 document content 36
getResources() 186 document type 36
getResources(String fileName) 36 folder name 36
getSearchValues() 33, 35 MIME type 36
getServerPrinters() 28 number of segments 36
getStoreDocFields() 219 OnDemand internal properties 36
getTemporaryWorkingDirectory() 26 server printers 36
getText() 37 hitL results for maximum number 26
getTraceDirectory() hitlist 74
arswww.trace file 26 allocation and release of resources and ses-
getTraceLevel() sions 137
arswww.trace file 26 troubleshooting 265
getType() 34 hitproperties.JSP 57
getUserId() 37 HPROF 269
getValidOperators() 34 output 269
getViewMimeType() 192 HTML
GIF 199 code 201, 208, 210
global summary 239 convert from AFP 210
globalization 144 output 208, 210
applications by using ICU 158 HTTP
request 56, 264
session 26
H HttpServletRequest request 202
hardware
HttpServletResponse response 202
manual 250
HttpSession (session) object 58
platform 228
HttpSession session 100
hash table 217
HttpSessionListener 89
hasPermToDeleteDoc 222
heap 266
allocation strategy 234 I
configuration 268 I/O buffering 250
dump 266 IBM JVM 244, 271
HeapRoots 266 IBM Thread and Monitor Dump Analyzer for Java
leak 266 Technology 266
suspect objects 266 ICONV
map 266 character set conversion engine 157
size 226–227, 244–245 library 151
garbage collection 245 ICU (International Components for Unicode) 151
swap 245 code 159
Heap Analysis Tool (hat) 271 conversion engine 154
-heap parameter 268 conversion library 151
Heap Profiler (HPROF) 269 globalizing applications 158
HeapAnalyzer 266 library 151, 157
HeapRoots 266 support 16
heap dump 266 ICU conversion library
help 236 code page conversion 151
284 IBM Content Manager OnDemand Web Enablement Kit Java APIs: The Basics and Beyond
multicultural support 151 conversions 149
services 151 Java applet 205
text operations 151 Java application 226
image plug-in 198–199 Java classes
Image Web Viewer plug-in 14–15 packages 54
ImageMapFile option 208 Java command
implementation -help 236
timeout 141 -verbose 241
inactivity timeout 138 -X 238
incremented 137 -Xprof 238
index data 10, 147, 150, 221 -XX:+PrintGCDetails 241
OnDemand server 35 -XX:+PrintGCTimeStamps 242
indexer 10 Java diagnostic tools 266
indexing Java dump 132, 265
data 10 file 265
method Java heap 226, 246, 259
report 7 contiguous free memory 231
method, document 7 default size 230
process 6 dump 266
program 10 leaks 266
reports 10 used memory 231
INI file 206 Java Heap Analysis Tool (jhat) 271
initial stack size 230 Java Line Data Viewer applet 14–15
initialization Java Native Interface (JNI) 226, 255
connection 132 Java stack 226
initialize ODServer method 114 Java virtual machine (JVM) 129, 201, 225–226,
initialize(String applicationName) 28 259–260
instance 146, 148 dump 266
integrating custom code pages 156 implementation 225, 230, 265
International Components for Unicode (ICU) 151 process 226, 228
application globaliztion 158 java.io.tmpd ir 134
code 159 java.lang.String 267
conversion engine 154 filename 183
conversion library 151, 157 viewer 183
support 16 Java_com_ibm_edms_od_ 255
Internet user 94 javacore 265
isDisplayable() 34 jhat 271
isPublic() 37 jmap command 267
isQueryable() 34 JNI (Java Native Interface) 226, 255
isRequired() 34 Jprof 273
isServerTimedOut() 28 JSP 54, 56
level 54
jstat command 268
J JSTL taglib 65, 68
Java AFP2HTML Viewer
JUnit 271
applet 14–15
JVM (Java virtual machine) 129, 201, 225–226,
toolbar 15
259–260
Java and native executable 14
dump 266
Java API 16
implementation 225, 230, 265
Index 285
process 226, 228 M
major collections 235
mark phase, garbage collection 231
K
Keepalive_interval, network performance 249 Max user port (32768) parameter 248
keepServerAlive MaxConnect Backlog, network performance 249
ODServer 139 maxHits 133, 167–168, 170, 253
keepServerAlive() 28 maximum number 122, 170, 249
maximum transmission unit (MTU) 249
MaxUserPort 263
L memory 109, 234, 250
language allocation 226
configuration 154 allocation commands 242
parameter 135 availability 234
supported 154 trade off 235
large file, avoiding memory issues 190 issues, avoiding, large files 190
large object 14 leak
handling 179 troubleshooting 266
retrieval 181, 189 module 250
support 183, 187 physical 233, 245
versus small object 181 performance 250
large object support 263 usage 233
Library Server 4, 146–147 monitor 245
set of managers 5 ODWEK Java APIs 246
LicenseFile option 212 trade off 235
lifetime 246 memory allocation 228
line data 84, 145–146, 149–150, 180–181, 198, Metacode document 211–212
200 method, synchronized 129
applet 84, 198, 203 middle-tier component 107
applet callback 56 MIME
documents 84 document type 104
Java applet, ODWEK 157 type 36
listfolders.JSP 57 minor collections 235
load monitor 266
expected load 245 MTU_size, network performance 249
generator program 245 multicultural support
ID 37 globalization 144
loading of data 10 ICU conversion library 151
locale 16 library in Content Manager OnDemand 157
information 151 Multiple Byte Character Set (MBCS) 144
location configuration 156 multiple processors 231
logical server 6 multiple tab functionality 141
logoff ODServer method 114 multi-threaded application 231, 250
logoff() method 28
logon ODServer method 114
logon() method 28 N
logon.JSP 57 name criterion 33, 35
long-running request cancellation 264 named query
criteria 34
name 34
286 IBM Content Manager OnDemand Web Enablement Kit Java APIs: The Basics and Beyond
number of criteria 34 thread safe 128
ODNamedQuery objects 34 Object Server 4–5, 146
ODNamedQueryCriteria 35 OD_SORT_LOCATION_MIDTIER 168
National Language Support 144 OD_SORT_LOCATION_NONE 168
native format 149–150, 181, 183, 188 OD_SORT_LOCATION_SERVER 168
standard retrieval 181 ODApi.jar file 39
native heap 226 ODApplication
native libraries 228 class 28
native memory 180–181, 188, 226, 228, 259–260 ODApplicationGroup
increasing consumption over time 185 class 28
large amounts 228 methods 31–32
native retrieval 195 ODApplicationGroupField
native shared libraries 16 class 28
native sockets interface 16 ODAuthenticate 98
native stack 226 ODCabinet 65
network adapter, network performance 249 class 28–29
network architecture optimization 264 searches 29
network connection refused, troubleshooting 262 ODCallback 172
network performance 247 ODConfig 62–63, 113, 115, 210, 213
FINWAIT2TIME 249 class 132–133, 155, 183, 209, 213
Keepalive_interval 249 constructors 24
Max user port (32768) parameter 248 methods 25–26
MaxConnect Backlog 249 object 26, 60–61, 133, 155, 167, 170, 209, 213,
MTU_size 249 253
network adapters 249 property 103
nodelayack option 248 parameters 133
sockets 247 prior to 8.4 24
TCP/IP buffer sizes 248 ODConfig()
TcpTimedWaitDelay 249 all parameters 25
NewRatio parameter 246 all parameters except advanced properties 25
nodelayack option, network performance 248 no parameters 25
NOT BETWEEN 34 ODConnectionPool 95, 99
note ODConstant.APP ET 134
creator 37 ODConstant.APPLET 203, 210
date/time created 37 ODConstant.NATIVE 134, 189
get text 37 ODConstant.OPBetween operator 162
page number 37 ODConstant.OPNotBetween operator 162
public 37–38 ODConstant.XENOS 211
set text 38 ODCriteria 32, 116, 163, 169
object 29, 33, 70, 73–74, 98, 162–164
appropriate data 70
O sort order 167
object
valid operators 163
creation 231–232
search objects 164
generations, customizing 245
ODDisplayDocument 56
large 14
ODException 38, 138, 221, 252
state 128
class 38, 252
support 181, 201, 212, 265
methods 38
document retrieval 265
ODException class 23
Index 287
ODFolder 32, 65, 116, 162, 172 connection 27, 94, 253
class 28, 216, 219 instance 94, 130, 137
application groups 30 keepServerAlive() 139
methods 30 methods 27, 114
object 63, 94, 162–163 object 58, 60, 62, 94, 114, 117, 170, 185, 203,
ODHit object 171 209, 260
search 167 object reference 58
several ways 169 server connection Java class 26
ODFolder.search 33, 35, 140, 162, 186 session 130, 183, 186, 202
ODFolder.search() method 164 ODServer object
ODFolder.setOrSearchCriteria 33, 164 level 118
ODFolderBean 65, 68 ODServer.getCabinets() method 29
ODFolderInfo 56, 68 ODServer.initialize
servlet, processRequest method 67 applicationName parameter 203
ODHit 30, 77, 80, 103, 171, 180–181, 191, 193, odServer.initialize 114, 202–203
216–217 ODServer.logoff 63, 89, 135
class 35, 182, 216 ODServer.logoff() method 27
API function 188 ODServer.logon 27, 114
instance 30, 182, 216 ODServer.open folder 29, 131
methods 36 ODServer.terminate() method 27, 63, 89, 114, 135
object 30, 80, 103, 169, 171, 182–184, 187, 222 ODServerConnection 56, 62, 65, 72
OnDemand document 80 ODUG (OnDemand User Group) 273
selected relative location 103 ODUtils 56
odHit.getDocId 217–218 ODWEK (OnDemand Web Enablement Kit)
ODHit.getDocument 140, 186 143–144, 197–198, 223–224
ODHit.getProperties 37, 191 application 250
ODHitProperties 191 configuring to use Xenos transforms 211
class 37 default 170
methods 37 installation 198, 205
ODInit 56 Java and native executable 16
ODListener 56 Java applets 201
ODListFolders 56, 64–65 language
servlet 57, 63 configuring 155
ODLogon 56, 64 line data Java applet 157
ODNamedQuery 30, 32 location configuration 157
class 34 plug-ins 198
ODNamedQueryCriteria 32 session 133, 135, 203
class 35 user interface 18
ODNote UTF-8 144
methods 37 ODWEK Java APIs 1, 109, 146, 150, 168, 181,
ODOpenHit 56 202, 216, 254
ODPassthru 56 architecture 12
ODPool 121 binary distribution files 15
ODSearch 56 code page conversion 149
ODSearchEntry 56 components 13
servlet 70, 72 deletion of documents 222
ODSearchRetrieve 99 dianostic information 38
ODServer 59, 63, 96, 113–115, 117, 185, 210, 214 distribution files 15
class methods 113 effective use 3
288 IBM Content Manager OnDemand Web Enablement Kit Java APIs: The Basics and Beyond
function 149 P
function overview 11 packages, Java class 54
implementation 108 page number of note 37
implementing synchronization 130 pages 225
Java and native executables 14 page-swapping system 225
Java component 246 parametric search 162
language configuration 154 ParmFile option 212
memory usage 246 path for trace file 25
multithreaded behavior 132 PCX 199
native components 39 PDF document 180
object 114 performance 107, 109, 191
origin 4 degrade, troubleshooting 262
pool level 117 disk 250
session 135 improve 245
support multi-threading 130 issues 255
update methods 216 network 247
viewers 14 other areas 247
Web applications 11 physical memory 250
off-peak access 256 problems 132
OnDemand User Group (ODUG) 273 processor 250
OnDemand Web Enablement Kit (ODWEK) Performance Inspector 273
143–144, 197–198, 223–224 permanent generation 235
application 250 permanent generation space 234
configuring to use Xenos transforms 211 permission, Document Update 218
default 170 -permstat parameter 268
installation 198, 205 persistent document ID 36
Java and native executable 16 physical memory 233, 245
Java applets 201 physical memory performance 250
language Pipeline Analyzer 272
configuration 155 plug-in
line data Java applet 157 AFP 198
location configuration 157 image plug-in 198
plug-ins 198 PMR (Problem Management Record) 273
session 133, 135, 203 printConfig() 26
user interface 18 printDocuments(java.util.Vector hits,String print-
open() 29–30 er,int copies) 30
openFolder(String fldname) 28 printing configuration settings 26
operating system 198, 200, 225–226, 250, Problem Management Record (PMR) 273
265–266 processor 250
operator, criterion 33–34 performance 250
optimization of the network architecture 264 Profile Analyzer 272
option 241 Properties prop 209, 213
OptionsFile option 209 public note 37–38
OR condition
multiple ODCriteria search objects 164
OutOfMemoryError 230, 234–235 Q
query
OutputType option 212
application group fields 165
large object document 190
Index 289
R S
RAID (Redundant Array of Independent Disks) 250 same folder 112
Rational Application Developer 43, 54, 261 sample console application 39
Web development environment setup 43 sample program
read-only data 129 ODPing 40
rebasing DLLs 228 SBCS (Single Byte Character Set) 144
recreateHit(String docid) 30 scalability 107
Redbooks Web site 277 ScriptFile option 212
Contact us xiv search 169–170
Redundant Array of Independent Disks (RAID) 250 by date 170
referenced document criteria search 162
full length in bytes 37 criterion 30, 70, 92, 162, 168
name of application 37 document 108
name of application group 37 folder 108
retrieval 36 hit results, maximum number 26
relative location 171 Java classes 23
report 6 ODCriteria 32
indexing 10 ODFolder 32
indexing method 7 ODNamedQuery 32
request ODNamedQueryCriteria 32
manager 5 operation 99
parameter 60, 99 operator 35
request.getSession 202 page 163
resource result 74, 92–93, 140, 161, 164
consumption control 132 result size 170
data 114, 137, 184–185, 218 sorting results 167
internal ID 186 SQL search 162
tuning 109 SQL search, considerations 166
response.getOutputStream 202 type, ascending/descending sort 33
result size 170 value 35, 74, 92, 162
retrieval value, criterion 33–34
converted data 193 required 34
document 179–180 search() 30
content 36 search(ODNamedQuery namedQ) 30
troubleshooting 265 search(String sqlWhereClause) 31
large object 189 searchCountHits() 31, 170
segmented document 189 searchentry.jsp 57, 70
retrieve() method 203 searchresults.JSP 57
retrieve(String viewer) 36 searchresultsexternal.jsp 99
retrieveSegment 184, 189 segment information, obtaining 190
retrieveSegment() method 194 segmented document 189
retrieveSegment(int segment) 36 retrieval 189
return code 213, 256, 258 viewer 189
rotating images 199 segmented retrieval 181–182, 187, 200, 204
running JVM segments, hit 36
memory map 267 serial Garbage Collector 231
server 112–113, 144, 227, 239, 255, 262
code page 154
connection
290 IBM Content Manager OnDemand Web Enablement Kit Java APIs: The Basics and Beyond
Java classes 22 String appl_name 219
ODConfig 24 String appletDir 133, 253
ODServer 26 String fileName 183
connections, troubleshooting 262 Struts 54
environment 4 support
flow 246 large object 263
instance 153 supported languages 154
memory 112 sweep phase, garbage collection 231
port 122 synchronization
print manager 5 methods 129
printers 36 session object 131
process 250 synchronized code block 58
side 112 synchronized performance problem 132
servlet 54, 94, 96, 115, 128, 202–203 sys 241
classes 56 system 233
session 130, 136, 156 system architecture 4
session object 63, 131, 203 system overview 4
object references 89 System.gc() method 232
synchronization handling 131
synchronized 131
setOperator(int op) 34
T
TCP/IP 248
setPublic(boolean isPublic) 38
buffer sizes, network performance 248
setSearchValue(String val) 34
TCP_KEEPALIVE 249
setSearchValues(String val1, String val2) 34
TcpTimedWaitDelay 262
setSortLocation 168
network performance 249
setSortOrder(int val) 34
temporary directory 134
setText(String text) 38
tenured generation space 234
Single Byte Character Set (SBCS) 144
terminate
single-threaded (serial) Garbage Collector 231
connection 89
small object
ODServer method 114
retrieval 181
terminate() 28
social security number (SSN) 9, 112
testing tools
sockets, network performance 247
ConTest 272
sort
JUnit 271
order, field 34
Visual Performance Analyzer (VPA) 272
search results 167
text, note 37–38
SQL search 31, 108, 162, 164
thread 114
considerations 166
allocation 115
criteria search 162
Thread and Monitor Dump Analyzer for Java Tech-
Date values 166
nology 266
WHERE clause 164
thread-safe object 128
SSN (social security number) 9, 112
throughput 233
stack trace 265
trade off 235
StackOverflowError 230
TIFF 199
stand-alone AFP viewer 157
time stamps
startup parameters 236
consecutive 255
storage volume 5
TIME_WAIT state 262
storeDocument 219–220
timeout 137, 139
storing document 219
Index 291
implementation 141 UTF conversion 148
trace 254, 265 UTF-16 148
engine 253 UTF-8 144
file 134, 252, 254 utilities 56
absolute path 25 utility classes 56
special note 134
log sample 256
logging 252
V
valid operators, criterion 34
Trace Analyzer 273
verbose garbage collection 271
traceLevel 253
viewer 194
trade off 235
and transforms 17
transaction report 7
applet 14
TransForm 63
browser plug-in 14
transformation 63, 194
large object 14
transforms 17
parameter 183, 188
configuration files 17
segmented document 189
troubleshooting 110
viewerPassthru(String queryString) 28
application termination 260
viewers 14
document retrieval 265
virtual memory 225, 228
hitlist 265
Visual Performance Analyzer (VPA) 272–273
long running document retrieval 263
VPA (Visual Performance Analyzer) 272–273
memory leak 266
network connection refused 262
performance degrade 262 W
server connections 262 wait time 233
twice the maximum segment lifetime (2MSL) state trade off 235
262 WarningLevel option 213
type, criterion 34 Web 2.0, WEBi 18
Web application 11, 53–54, 92, 103, 107, 112, 128,
130–131, 150, 156, 187, 193, 198, 200–201
U ODWEK Java APIs 53
UCS (Universal Character Set) 144
timeout implementation 141
Unicode 144, 153
Web development
application group field length 153
environment setup 43
Content Manager OnDemand 153
Web site 92–93, 267, 271
database code page 152
WEBi
database encoding 153
client 17
OnDemand server 144
components and architecture 18
Unicode Transformation Format (UTF) 144, 146
retrieved bank statement 20
Universal Character Set (UCS) 144
retrieved customer statement 20
UnsatisfiedLinkError 260
retrieved hand-written customer inquiry 19
updateValuesForHits 216
returned search result list 18
updating
Web 2.0 18
database values 216
WHERE clause
UseApplet option 208
SQL search 164
user access 116–117
Windows XP
user ID 92, 94, 115, 218, 222
Professional SP 2.07 43
application group 218
UTF (Unicode Transformation Format) 144, 146
292 IBM Content Manager OnDemand Web Enablement Kit Java APIs: The Basics and Beyond
X
Xenos transforms 211
configuration in ODWEK 211
-Xms parameter 243
-Xmx parameter 243
-Xprof
global summary 239
Java command option 238
-XX:+PrintGCDetails 241
-XX:+PrintGCTimeStamps 242
-XX:MaxHeapFreeRatio 244
-XX:MinHeapFreeRatio 244
Y
young generation space 234–236, 245
live objects 246
maximum size 246
relative size 245
same effect 246
Z
zooming images 199
Index 293
294 IBM Content Manager OnDemand Web Enablement Kit Java APIs: The Basics and Beyond
IBM Content Manager OnDemand Web Enablement Kit Java APIs: The Basics and Beyond
(0.5” spine)
0.475”<->0.875”
250 <-> 459 pages
Back cover ®
Develop Web IBM Content Manager OnDemand is the industry leading report
applications by management product. It provides enterprise report management INTERNATIONAL
using ODWEK V8.4 and electronic statement presentment. It is high-performance TECHNICAL
Java APIs middleware for automatic management of formatted computer SUPPORT
output and reports. It helps companies gain significant return on ORGANIZATION
investment by transforming costly high-volume print output to
Gain insightful best
electronic information capture and presentation in support of
practices, hints,
customer service.
and tips BUILDING TECHNICAL
In this IBM Redbooks publication, we provide an overview of the INFORMATION BASED ON
Tune and OnDemand Web Enablement Kit (ODWEK) version 8.4 Java APIs and PRACTICAL EXPERIENCE
explain the commonly used APIs for application development. In
troubleshoot
addition, we examine the capabilities and usage of the APIs through
OnDemand Web IBM Redbooks are developed by
use cases, best practices, hints and tips, and code snippets. We
applications the IBM International Technical
explain connection pooling, folder searching, document retrieval, Support Organization. Experts
document storing and updating, memory and performance, and from IBM, Customers and
troubleshooting in terms of application development. Partners from around the world
create timely technical
ODWEK Java APIs can be incorporated into any Java-based information based on realistic
application, including stand-alone applications, portlets, servlets and scenarios. Specific
Web services. We illustrate the APIs by using servlet-based code. recommendations are provided
to help you implement IT
This book is intended for application developers who are solutions more effectively in
responsible for developing Web applications that interface with your environment.
Content Manager OnDemand. It also serves as a good reference
guide for developers and system administrators to fine-tune and
troubleshoot Content Manager OnDemand Web applications.
For more information:
ibm.com/redbooks