To run an application, such as the Personalization application, you must perform the steps described in the following sections:
Adding Entries to Your CLASSPATH
Installing ObjectStore
For information about installation, see the README.htm file in the top-level directory of your ObjectStore installation.
c:\Odi\osji\bin
c:\Odi\osji\osji.zip;c:\Odi\osji\tools.zip
You decide whether to place the annotated files in the same directory as the source files or in a separate directory.
For example, suppose c:\Odi\osji\COM\odi\tutorial is the directory that contains the source files for the tutorial package. You decide to annotate in place. That is, you plan to instruct the postprocessor to overwrite the original class files with the annotated class files. In this case, you must add the following entry to your CLASSPATH variable:
c:\Odi\osjiThis entry allows the Java VM and ObjectStore to find the COM\odi\tutorial directory, which contains both the source files and the annotated class files.
Suppose you decide to place the annotated class files in a separate directory from the source files, for example, c:\Odi\osji\COM\odi\tutorial\osjcfpout. In this case, you must add the following entries to your CLASSPATH variable:
c:\Odi\osji\COM\odi\tutorial\osjcfpout;c:\Odi\osjiThe first entry allows ObjectStore to find the annotated class files. The second entry allows ObjectStore to find the source files.
After postprocessing your application, you can run your application. When you run your program, Java has to locate the annotated class files and the unannotated class files that have not been superseded. The location of the annotated class files must precede the location of the original class files in your CLASSPATH. This allows the Java VM to find the annotated class files before it finds the superseded (original) class files. You can find detailed instructions for doing this in ObjectStore Java API User Guide, Automatically Generating Persistence-Capable Classes.
Compiling the Program
You compile a ObjectStore application the same way you compile any other Java application. For example, to compile the Personalization application, change to the c:\Odi\osji\COM\odi\tutorial directory and enter
javac *.javaYou can use the asterisk to compile all .java files or you can compile each file individually by specifying the file name. Case is significant for the file name, so you must specify, for example, User.java and not user.java.
When you compile the Personalization application, the javac compiler outputs the following run-time byte code files:
Before you run the postprocessor, ensure that the bin directory that contains the postprocessor executable is in your path, as noted in Adding Entries to Your CLASSPATH.
Complete information about the postprocessor is in ObjectStore Java API User Guide, Chapter 8, Automatically Generating Persistence-Capable Classes.
Example of Postprocessing Classes in Place
In the Personalization application, both the Interest and User classes are persistence-capable. To postprocess these classes in place, change to the c:\Odi\osji\COM\odi\tutorial directory and enter
osjcfp -inplace -dest . Interest.class User.classWhen you specify the -inplace option, the postprocessor ignores the destination argument (-dest), but it is still required.
For example, suppose that in the c:\Odi\osji\COM\odi\tutorial directory you create the cfpargs file with these contents:
-inplace -dest . -pc User.class Interest.classThe -pc option instructs the postprocessor to make the specified classes persistence-capable. You can then run the postprocessor with this command:
osjcfp @cfpargs
osjcfp -dest osjcfpout Interest.class User.classThe -dest option specifies the destination directory for the annotated files. The argument for this option must be the same as the directory in your CLASSPATH environment variable that establishes the location of the annotated files.
In the Personalization application, this is c:\Odi\osji\COM\odi\tutorial\osjcfpout. You must explicitly create this directory before you run the postprocessor.
For example, the osjcfp command that places the annotated class files in the osjcfpout directory outputs these annotated class files:
The postprocessor must be able to examine all class files in an application when it makes any class in the application persistence-capable. There are postprocessor options that allow you to determine which classes the postprocessor makes persistence-capable. If it is inconvenient or impossible to postprocess together all classes in your application, you can postprocess separate batches of files. See ObjectStore Java API User Guide, Chapter 8, Postprocessing a Batch of Files Is Important.
It is good practice to provide accessor methods to encapsulate state in an object, as shown in the source code for the Interest class in Appendix A, Source Code. When using ObjectStore, accessor methods allow ObjectStore to automatically fetch objects from the database. It is easy to localize where ObjectStore must annotate code to perform fetch and update checks, which occur only in the accessor methods as opposed to being spread throughout your code.
Running the Program
Before you run a ObjectStore program, ensure that the ObjectStore lib directory is in your library search path. Run your ObjectStore program as a Java application.
java COM.odi.tutorial.TestDriver test.odbWhen you run an ObjectStore program, you specify the fully qualified class name to the Java VM. In this example, COM.odi.tutorial.TestDriver is the fully qualified class name.
The TestDriver program expects an argument that contains the pathname of the database's .odb file, namely test.odb. The application also creates test.odt and test.odf, and these three files (the .odb, .odt, and .odf files) form the database. You can specify any pathname you want, as long as the file name ends with .odb. This example uses a relative pathname, so ObjectStore creates the files in the directory in which you run the program.
Sample Output from the application is in Appendix B.
Updated: 10/07/98 07:05:53