Main -> Documentation -> The OBI Interface -> Modifying the Display of Records in the OBI -> Creating a Class Package

Creating a Package for Your Formatting Classes

Introduction

This topic describes how to organize your formatting classes into a class package, and how to configure the WebZ system to use the your package for formatting records.


When Should You Create a Class Package?

It is recommended that you create a separate class package if you plan on creating many formatting classes for the databases in your WebZ system. The benefit of creating your own package is that separates your formatting classes from the classes installed with WebZ, thereby reducing the chance of corrupting or affecting any existing classes while making it easier to manage, modify, and back up your own classes.


Before You Begin

  • The tasks contained in in this topic involve editing Java source code files and compiling Java classes. This topic assumes that you have a basic understanding of the Java language and know how to complie Java class files.
     
  • Verify that your CLASSPATH environment variable is set correctly, otherwise the Java source code files will not compile and you will have to manually specify executable paths to the Java compiler in order to compile your Java source files.
     

Creating a New Package, my.own.fmts

In the following example, you will create a new Java class package called my.own.fmts. To do this, you will create the necessary package directories, assign an existing formatting class to the package, and configure the WebZ JaSSI server and a database to use the class in your package.

Note:

The MarcArticleBriefTest formatting class referred to in the following example was created in the example in the Creating a New Formatting Class topic. It is recommended that you create the MarcArticleBriefTest formatting class before proceeding with this example.


Creating the Package Directories

1. Decide on a name for the package. In this example, we will use the name, my.own.fmts.

2. Create the directory structure for the package. You must create a directory for each name level in the package name. Furthermore, the directory structure must be created in the class root directory for the WebZ system.

For example: For the my.own.fmts package, the directory structure must be <ClassRoot>/my/own/fmts, where <ClassRoot> is the directory path defined by the ClassRoot variable in the JaSSIServer.ini file. If the package directory structure is not located in the ClassRoot directory, the JaSSIServer will be unable to locate the my.own.fmts package.


Adding the MarcArticleBriefTest Formatting Class to the my.own.fmts Package

3. In the <WebZ_root>/classes/ORG/oclc/fmts/obi directory, delete the MarcArticleBriefTest.class file. Do not delete the MarcArticleBriefTest.java file. Instead, move the MarcArticleBriefTest.java source file to your package directory, <ClassRoot>/my/own/fmts.

Notes:

  • Deleting the MarcArticleBriefTest.class file from the directory ensures that only one copy of the class file of that name will exist in the WebZ system.
  • If the MarcArticleBriefTest files do not exist, you can create them by referring to the example in Creating a New Formatting Class.

4. Make the following changes to the MarcArticleBriefTest.java source file.

Change the package definition (which appears near the top of the file) from this:

package ORG.oclc.fmts.obi;

to this:

package my.own.fmts;
Note:

The formal name of the class is now my.own.fmts.MarcArticleBriefTest.class.

5. (Optional Step): Locate the following line of code in the new MarcArticleBriefTest.java source file:

protected final static String yearLabel = "Publication Date: ";

and change it to the following:

protected final static String yearLabel = "Record Date: ";
Note:

The purpose of this step is to ensure that you recognize the output of the MarcArticleBriefTest formatting class in the OBI. You can replace "Record Date:" with any text you wish.

6. Save and close the file.

7. Compile the MarcArticleBriefTest.java file into a Java class file.


Configuring the JaSSI Server to Use the my.own.fmts Package

8. Add the my.own.fmts package to the [PackageOrder] section in the JaSSIServer.ini file, located in the <WebZ_root>/ini directory. This allows the JaSSI server to locate your package. To do this, make the following change to the JaSSIServer.ini configuration file:

Add the my.own.fmts package to the [PackageOrder] section as shown below:

# Package Order for Java class loading
[PackageOrder]
package1 = ORG.oclc.obi
package2 = ORG.oclc.obi.extverb
package3 = ORG.oclc.webz
package4 = ORG.oclc.jassi
package5 = my.own.fmts
Note:

The sequence of the packages in the [PackageOrder] is significant because it determines the order in which the JaSSI server searches the packages for formatting classes (and other WebZ classes).


Configuring a Database to Use the my.own.fmts.MarcArticleBriefTest Formatting Class

9. Edit the configuration of the ABI/Inform database so that it uses the MarcArticleBriefTest formatting class to format brief records. The ABII.ini configuration file is located in the <WebZ_root>/ini/dbs directory. Make a backup copy of the file before modifying it.

In the [Formats] section of the ABII.ini configuration file, change the brief format setting to the following:

brief = my.own.fmts.MarcArticleBriefTest

After making the change, save and close the file.


Viewing the Results in the OBI

10. Stop and restart the WebZ system in order to read in the configuration changes you made to the ABI/Inform database.

11. Access the WebZ system via a browser and select the ABI/Inform database from the Database Selection screen.

12. Perform a search against the ABII database. If you performed the optional Step 5 above, then you should notice that "Record Date" (or the text you supplied) is now the label for the Date field. This indicates that the JaSSI server successfully located the my.own.fmts.MarcArticleBriefTest formatting class and successfully formatted the records for display.


[Main][Documentation][Technical Reference][Glossary][Search]