Buttons Menu Map - loading... 
RD45 basic concepts 

Objectivity/DB and JAVA

 
 Last Update: 16 December 1998   

Objectivity/Java

    The platforms supported for Objectivity 5.0/JAVA are indicated here. NOTE: SOLARIS AND NT ONLY ! 

    Objectivity for Java requires that you have access to following software: 

      Objectivity/DB 
      Objectivity for Java 
      Java Development Kit (JDK) Release 1.1.3 or higher. 

    You can access to the Objectivity/JAVA product directly  (via NICE or AFS). 

    If you do not have access to the previous installations you have to install the Objectivity product locally: 
       - To install the complete product click here
       - To install the Objectivity/JAva click here

    Check that the installation is fine by running an example
     

Local Installation of Objectivity/Java on NT  
 
    1. If you have already a local installation of the Objectivity/DB product but not the Java API  you just have to run  the setup.exe installation program and choose from the menu window the following option: 
      Objectivity for Java 
       
    Objectivity for Java will be installed on the installDir  that you specified. 
     

    2. Add the Objectivity for Java library path 
     

      CLASSPATH installDir\lib\oojava.jar 
       
    note: some application development enironments such as Visual J++ or Visual Cafe require you to specify CLASSPATH from within the tool. 
 

Access from NICE or AFS  

    from NICE: at the moment Objectivity 5.0 with the  Java API is not installed . You should  install Objectivity/DB  locally in your NT system. You can access to JDK 1.1.5 from NICE. 

    from AFS in Solaris: 

    You can access to Objectivity/JAVA 5.0 -Solaris  directly by calling the RD45 scripts, they set also the access to JDK1.1.6. 

    Bourne Shell syntax: 

                    export OBJY_VERS=5.0;    
           source /afs/cern.ch/rd45/objy/objyenv.sh
 
 
    C Shell Syntax: 
          setenv OBJY_VERS 5.0   
          source /afs/cern.ch/rd45/objectivity/objyenv.csh 
          At the moment the Objectivity/Java API is working perfectly with JDK 1.1.* releases, we have tested it with JDK 1.2 betaX and we have some problems, we will wait for the JDK1.2 final release. 
 
    C Shell Syntax 
     
      #JAVA settings to use another version of JDK  different from JDK1.1.6 
      setenv JAVA_HOME  "/usr/local/libexec/jdk/<version>" 
      setenv PATH "${JAVA_HOME}/bin:${PATH}" 
      setenv CLASSPATH ".:/afs/cern.ch/sw/lhcxx/specific/sun/Objectivity/5.0/java/lib/ 
      oojava.jar:${JAVA_HOME}/lib/classes.zip:${CLASSPATH}" 
      setenv LD_LIBRARY_PATH "${JAVA_HOME}/lib:${LD_LIBRARY_PATH}"
         
    NOTE: if you are using JDK1.2betaX you have to set the THREADS_FLAG environment variable to native. Objectivity/Java is not working with green threads, it works with Solaris native threads. If you can not compile even with the native flag set, you may need to install patches needed to use Native Threads on Solaris 2.5.1.  On Solaris (SPARCTM Platform Edition), the required patches are 103566-08 and 103640-08. On Solaris (Intel Platform Edition), the required patches are 104241-0 and 103641-08.
Run an example to see that the JAVA installation is fine  
 
    Note: Make sure that the path to JDK  and  Objectivity class library for Java are set properly. 

    1.Compile the files Vehicle.java , Fleet.java , VrcInit.java , and Vrc.java located in the GettingStarted subdirectory of the programming samples directory. 
     

      javac VrcInit.java 
      javac Vrc.java
       

      Note: you may get the error: 

        SIGSEGV   11*  segmentation violation
            si_signo [11]: SIGSEGV   11*  segmentation violation
            si_errno [0]: Error 0
            si_code [1]: SEGV_MAPERR [addr: 0xad7ae2bc]

                stackbase=EFFFE9A0, stackpointer=EFFFE6E0

      Objectivity for java in Solaris uses the system native threads, while the java virtual machine, by default, starts using green threads. To specify to the virtual machine that you want to use native threads, you should specify following flag:

        > java -native YourClass

     

    The bytecodes will be generated and stored on the .class files. In GettingStarted directory you will have following files : 
     

      Fleet.class 
      Fleet.java 
      Vehicle.class 
      Vehicle.java 
      Vrc.class 
      Vrc.java 
      VrcInit.class 
      VrcInit.java 
       
    2.Start an Objectivity/DB lockserver in your system, 
     
      d:\installDir\java\samples\GettingStarted\oolockserver 
       
    3.Create a federated database called Vrc in the GettingStarted sample directory. 
     
      d:\installDir\java\samples\GettingStarted\oonewfd -fdfilepath D:\objy50\docs\java\samples\GettingStarted\Vrc.fdb -lockserverhost <your host> Vrc  
       
    The output will be: 
     
      Objectivity/DB (TM) Create Federated Database Utility, Version 5.0 Build:  58 
      Copyright (c) Objectivity, Inc 1993, 1998. All rights reserved. 

      Federated Database "Vrc" created. 
       

    You can check the catalog of the federated database  if  everything is right : 
     
      D:\objy50\docs\java\samples\GettingStarted>oodumpcatalog Vrc 

      Objectivity/DB (TM) List Database Files Utility, Version 5.0 Build:  58 
      Copyright (c) Objectivity, Inc 1990, 1998. All rights reserved. 

      FD Name   = Vrc 
      FD ID     = 1 
      FD File   = pc-01::D:\objy50\docs\java\samples\GettingStarted\Vrc.fdb 
      Boot File = pc-01::D:\objy50\docs\java\samples\GettingStarted\Vrc 
      Jnl Dir   = pc-01::D:\objy50\docs\java\samples\GettingStarted 
      Lock Host = pc-01 

     

    4.Execute VrcInit to initialize the federated database. 
     

      d:\installDir\java\samples\GettingStarted\java VrcInit 
    When you execute VrcInit , the output will be: 

              Created database "VehiclesDB". 
        Created container "VehiclesContainer". 

        Added vehicle: License:CA1234 Class:G Doors:4 MANUAL Rate:40 
        Added vehicle: License:CA7654 Class:H Doors:4 AUTOMATIC Rate:40 
     

    Note: You can find more information about this example in the "Getting Started" chapter of the Objectivity for Java doucmentation. 
    You will find other examples as indicated in the "Programming Examples" chapter. 

     
    5. Use oobrowse (in NT) or ootoolmgr (in UNIX) to browse  the database VehiclesDB. 
     

      d:\installDir\java\samples\GettingStarted\oobrowse Vrc 
       

Documentation

You can find all java documentation on html and pdf in following directories of the Objectivity installation: 
 
    java/index.html  
    java/api/*.html  

    java/guide.pdf 

Examples 
    java/samples/GettingStarted/*.java 
 
 

Tools

 DRO-TOOL  
    It is a Federated Database Configuration Management  tool for Objectivity/DB written in java. 
    Developed at CERN/IT/ASD/RD45 
     

     

  

Applets

    You cannot open  a Objectivity/DB federated database directly from an applet due to a security exception with the browser. 

    In principle, it should be possible to open a federated database from a browser  if you specify a boot file archive and an autonomous partition residing in the web server host,  you only try to open a socket connection between the applet and the web server, but it crashes when loading the oojava.jar file. If you use the appletviewer instead the applet is working perfectly. 

    There are some others methods to access to a federated database from an applet that helps you to solve this security problem. Two of them (agents and servlets) are discused in following agents section. The third method is using CORBA. Anyway the philosofy is the same. You have a program running in the web server that communicates with the applet and accesses to the federated database. 
     

Agents

    Another use of agents is to access to an Objectivity/DB from the web but it is not possible to do this directly from an applet, 
     The other type of agent we have developed is to access to Objectivity/DB federated databases from the web. From a Java Applet, you cannot open a federated database and work with it due to security restrictions in the browser, but using agents it is possible! 
     
    The structure of an application using agents would be the following one: 
     

     
     
    You could force your application to communicate with the federation only using the AMS server, but even in this case, you will get a security exception in the browser. 

    In this case, the agent implements all the methods for accessing the database. The Java applet starts a voyager server, and sends an agent to the host where the database resides. An applet can only communicate with the server in which the web page resides. To avoid this limitation, voyager implements a router service. All the messages sent to any agent will pass through this server. With it, you can create a voyager server in the same host as the web server, and use it as a router. Agents created in applets will have no address limitation, and can be sent and communicate with any host without any special restriction. 

    As the applet need to have access to the Objectivity for Java bindings, the agent must implement all those methods. Objectivity/DB for Java binding must be installed in the host where the agent will be sent (but it is not needed in the host where the applet is running or even in the web server host). 

    With Objectspace’s Voyager 2.0, the Java classes that will be used as agents don’t need to specify any special voyager code. Once you create a class, you must create an interface for this class. To do that, you can use the ‘igen’ program that comes with voyager. It will automatically generate the interface. In the applet, once you have created the agent with the Factory.create() method, you can access to the remote class as if it was local. 

    The clients need only a Java capable browser, where they execute an applet. In the client side, you don’t need any special software to access to Objectivity Databases, or any agent packages. All the classes required by the applet will be loaded from the web server. 

    The main steps of the application are: 
    1. Applet bytecodes are loaded from the web server into the browser. 
    2. The applet starts an agent, and send it to a remote host. 
    3. Depending of the agent task, it will check for the status of one of the servers or both, or to retrieve the data of a database locally and perform some analysis to this data. 
     

    While the agent is doing a task, the client doesn’t need to stay connected to the network. The client can connect later to monitor the task, or to retrieve the final result, once the task is done. 
     
    More information about agents you can find it here: 

    Agents Report  

    Commented code example of an applet  that retrieves information from a federated database. Requirements to run following  code:  Objectivity 5.0, Voyager 2.0.0 and jdk1.1.7

  

Servlets

 
    The original standard for server-side scripts is CGI or Common Gateway Interface. CGI is simple and widely supported. The main problem with CGIs is that is not very efficient because the server launches one copy of the script per request and the overhead can be significant. Vendors have developed proprietary alternatives such ISAPI (Microsoft) and NSAPI (Netscape) to address the performance issue. JavaSoft proposed the Java servlets as a standard efficient alternative to CGI. 

    Servlets are server-side Java programs that provide a means of generating dynamic Web content. They are not standalone applications that can be executed from the command line; instead, they run within Web servers. In order to run servlets inside a Web server the server must have a Java Virtual Machine running within itself. Unlike applets, servlets are not constrained by security restrictions. They have the capabilities of a full-fledged Java program and can access files for reading and writing, load classes, change system properties, etc. They are restricted only by the file system permissions, just like other Java application programs. 

    A servlet is loaded the first time it is used, and it remains in memory for later requests. It has an init method, where you can initialise the state of the servlet, and different methods for the different calls (doGet, doPost, doPut, doDelete). There is also a destroy method to manage the resources that are held by the servlet. 
    You can use a servlet to perform typical server-side processing. The servlet can communicate with the client computer and it can also communicate with other remote, networked computers. 

    Java servlets have full access to Java's networking features. The servlets can connect with other networked computers using sockets or Remote Method Invocation (RMI). Also, the servlet can easily connect to an Objectivity/DB using the Objectivity Java bindings. The main restriction using Objectivity federated databases is that you can only work with one federated database. As the Java bindings from Objectivity/DB uses static methods keep the information about the federated database currently opened, only one federated database can be opened per virtual machine. But the servlets are all executed in the same VM, so you can only have one federation per server. 

    One possible solution for this restriction can be done with the help of agents. As said before, a servlet has no special restrictions, so it can begin a new VM, and start there an agent server. Then the servlet can send there an agent that will open the federated database, and work with it. This solution let you open more than a federation using the same servlet, but you will have the same performance problem than using CGIs: start a new shell (in our case, a new VM) per request. 

    Follows an example code of a servlet that shows the database information of a federated database. When you first call the servlet, it shows you a form and asks for the boot file of the federation. Then, the servlet tries to open the federated database, and retrieve the information concerning the autonomous partitions, databases and containers of the federation. Atention: Once you specify a boot file, it will always show the information of the same federated database, even if you specify a different boot file later. 
     
    Example code of a servlet here ! 
     Requirements to run following  code:  Objectivity 5.0, Voyager 2.0.0 and jdk1.1.7

 
 
 

Other links  

Java Analysis Studio  
Developed at SLAC/BaBar. 

  WIRED 
Developed at CERN/IT/IPT. 

 
 
 
 
 
 

Your comments about this page are welcome ! Please send us a mail.  

If you have any applet that you think would be useful for the physics community and you would like to share it please send it to us, we will make it accessible to everybody. 
 

Eva.Arderiu@cern.ch , Javier.Conde@cern.ch