Speedo Tutorial

 FinalLogo.jpg
 FinalLogo.jpg
  1. Introduction
  2. Tutorial architecture
  3. Tutorial Environment
  4. The TutorialHelper class
  5. Basics (steps 1-2)
  6. Mapping (step 3)
  7. Additional (step 4-5)
  8. Additional (step 6-7)
  9. Speedo.properties edition (step 8)
  10. Speedo & J2EE (step 9)

Speedo documentation, User manual




Introduction

The Speedo tutorial shows how to use Speedo to manage persistent objects via the JDO specification. The tutorial consists of nine steps. The seven first steps are programs to discover the jdo features.

Steps 1-2 show how to use the basic JDO features such as making an object persistent, updating and deleting it.
Step 3 deals with the mappping of java classes via the jdo file.
Steps 4-7 show how to use additional features such as retrieving persistent objects using queries, the mapping of inherited object graph and the definition of a fetch plan.
Step 8 illustrates the way to edit the speedo.properties file using the eclipse plugin provided within the speedo distribution: JDO Driver Properties Editor.
Step 9 demonstrates how Speedo can be integrated into application servers as a resource adapter.

Top

Tutorial architecture

    The source code of the classes used throughout this tutorial is located in the org.objectweb.speedo.tutorial.pobjects package and its sub packages. These packages consist of the java classes         and the jdo files associated. The source code of the applications is located in the org.objectweb.speedo.tutorial.appli package and its sub packages.

   
   

  Top

Tutorial environment

Ant

   Install ant before beginning the tutorial (ant.apache.org).

Eclipse

   It is recommended to have eclipse installed before beginning the tutorial (eclipse.org).

Java

  Istall the jdk 1.4.2 before beginning the tutorial (java.sun.com).

Speedo

    You must have the Speedo distribution to run the tutorial (speedo.objectweb.org).
    Before running the tutorial, you must:

Database

   Before running the tutorial, ensure that you have launched your database in server mode. For the default hsql database,  move to the dist directory and launch the database in  server mode         typing:

java -cp speedo.jar org.hsqldb.Server -database.0 mydb -dbname.0 xdb 

Database Manager

    To navigate through the hsql database (by default), launch the database manager from the dist directory:
   
java -cp speedo.jar org.hsqldb.util.DatabaseManager& 
   Fill in the connection form as follows:

   
   
    You can shutdown the database you launched in server mode via this database manager executing the "shutdown" command.

     Top

TutorialHelper class

   The TutorialHelper class provides to the user a method to get a PersistenceManagerFactory (PMF). The PMF is the main element of the jdo architecture: it enables to           create PersistenceManager. The PersistenceManager manages persistent objects.
   The PMF is configured from the speedo.properties file. The database connection is defined in the speedo.properties file.
   

package org.objectweb.speedo.tutorial;

import java.io.FileInputStream;
import java.io.IOException;
import java.util.Properties;

import javax.jdo.JDOHelper;
import javax.jdo.PersistenceManagerFactory;

/**
* This class enables to get a persistence manager factory from the speedo.properties file.
*/
public class TutorialHelper {

protected static PersistenceManagerFactory pmf = null;

public TutorialHelper(String propertiesFileName)throws IOException {
Properties p = new Properties();
p.load(new FileInputStream(propertiesFileName));
pmf = JDOHelper.getPersistenceManagerFactory(p);
System.out.println("PersistenceManagerFactory instanciated ("+ pmf.getConnectionURL() + ")");
}

public PersistenceManagerFactory getPMF(){
return pmf;
}
}

    Top

Following step