A Persistence Service
for the OSGi framework
Carl Rosenberger
Chief Software Architect
db4objects Inc.
2
What is an object?
• ?
3
What is an object?
• a conceptional unit with
• Identity
• State
• Behaviour
• an instance of a class
• Car car = new Car("Ferrari");
4
• Car car = new Car("Ferrari");
• from user entry
• from machine generated data
• over the network
• from a database
Where do objects come from?
5
“Databases”
• Flat files (Roll Your Own)
• Java Serialization
• INSERT INTO car(name)VALUES("Ferrari")
6
“Databases”
• Flat files (Roll Your Own)
• Is your development team experienced at writing database
engines?
• Will flat files be failsafe and will they provide ACID transactions?
• Will you have querying functionality?
• How much will the development cost?
• How long will it take until the system stable?
7
“Databases”
• Java Serialization
• will break upon modifications to classes
• requires loading complete graphs of objects to memory
• is not transactional
• does not provide querying functionality
• is explicitely not recommended for longterm persistence by the
Java Language Specification
8
• INSERT INTO car(name)VALUES("Ferrari")
• Is SQL the best choice for storing objects?
“Databases”
Using tables to store objects is like driving your car home and
then disassembling it to put it in the garage. It can be assembled
again in the morning, but one eventually asks whether this is the
most efficient way to park a car.
Esther Dyson
9
How much SQL do you want to write?
• public class Car {
• Colour colour;
• Motor motor;
• List<Door> doors;
• List<Wheel> wheels;
• Brake brake;
• /*
• [ 50 more fields here ]
• */
• }
10
Is there an easier way to store objects?
• Car car = new Car("Ferrari");
11
• Car car = new Car("Ferrari");
• something.store(car);
Is there an easier way to store objects?
12
Is there an easier way to store objects?
• Car car = new Car("Ferrari");
• database.store(car);
• Simply
• store objects to the database
• get objects back from the database
• Persistence by reachability
• Database engine can analyze class schema
13
What about queries?
• SELECT * FROM
car, car_brake, brake, car_motor, motor
• WHERE car.id = car_brake.car_id
• AND brake.id = car_brake.brake_id
• AND car.id = car_motor.car_id
• AND motor.id = car_motor.motor_id
• AND brake.type = 'Ceramic'
• AND motor.power > 400;
14
Is there an easier way to query for objects?
• car.brake.type == "Ceramic"
• && car.motor.power > 400;
15
Introducing Native Queries
• return car.brake.type == "Ceramic"
• && car.motor.power > 400;
16
Introducing Native Queries
• public boolean match(Car car){
• return car.brake.type == "Ceramic"
• && car.motor.power > 400;
• }
17
Introducing Native Queries
• new Predicate <Car>(){
• public boolean match(Car car){
• return car.brake.type == "Ceramic"
• && car.motor.power > 400;
• }
• }
18
Introducing Native Queries
• List<Car> cars =
• database.query(new Predicate <Car>(){
• public boolean match(Car car){
• return car.brake.type == "Ceramic"
• && car.motor.power > 400;
• }
• });
19
Outlook: Native Queries using Closures
• List<Car> cars =
• database.query({
• Car car =>
• car.brake.type == "Ceramic"
• && car.motor.power > 400;
• }
• );
20
Object-Oriented Persistence
• 100% pure Java
• 100% refactorable
• 100% typesafe
• 100% checked at compile-time
• no O-R impedance mismatch
• minimum code
• maximum performance
21
Object-Oriented Persistence
• Store Objects
• Native Queries
22
Introducing db4o
• database
• 4
• objects
23
Introducing db4o
• database
• 4
• OSGi
24
Introducing db4o
• Plain Object Persistence
• Zero Administration
• Automatic Schema Management
• Optimized Native Queries
• compile time
• load time
• run time
• OSGi Service Interface
• OSGi ClassLoader aware
25
Introducing db4objects
• Open Source Project db4o
• GPL License
• Registered Community of 20,000 developers
26
Introducing db4objects
• Commercial db4o Licenses
• Customers include Boeing, RICOH, Bosch, Indra
27
db4o for OSGi
• db4objects is a member of the OSGi alliance
• Dedicated db4o version for OSGi
• Partnership with ProSyst
• ProSyst bundles db4o with mBedded Server
28
Thank You!
http://www.db4o.com/OSGi

A Persistence Service for the OSGi Framework - Carl Rosenberger, Chief Software Architect, db4objects

  • 1.
    A Persistence Service forthe OSGi framework Carl Rosenberger Chief Software Architect db4objects Inc.
  • 2.
    2 What is anobject? • ?
  • 3.
    3 What is anobject? • a conceptional unit with • Identity • State • Behaviour • an instance of a class • Car car = new Car("Ferrari");
  • 4.
    4 • Car car= new Car("Ferrari"); • from user entry • from machine generated data • over the network • from a database Where do objects come from?
  • 5.
    5 “Databases” • Flat files(Roll Your Own) • Java Serialization • INSERT INTO car(name)VALUES("Ferrari")
  • 6.
    6 “Databases” • Flat files(Roll Your Own) • Is your development team experienced at writing database engines? • Will flat files be failsafe and will they provide ACID transactions? • Will you have querying functionality? • How much will the development cost? • How long will it take until the system stable?
  • 7.
    7 “Databases” • Java Serialization •will break upon modifications to classes • requires loading complete graphs of objects to memory • is not transactional • does not provide querying functionality • is explicitely not recommended for longterm persistence by the Java Language Specification
  • 8.
    8 • INSERT INTOcar(name)VALUES("Ferrari") • Is SQL the best choice for storing objects? “Databases” Using tables to store objects is like driving your car home and then disassembling it to put it in the garage. It can be assembled again in the morning, but one eventually asks whether this is the most efficient way to park a car. Esther Dyson
  • 9.
    9 How much SQLdo you want to write? • public class Car { • Colour colour; • Motor motor; • List<Door> doors; • List<Wheel> wheels; • Brake brake; • /* • [ 50 more fields here ] • */ • }
  • 10.
    10 Is there aneasier way to store objects? • Car car = new Car("Ferrari");
  • 11.
    11 • Car car= new Car("Ferrari"); • something.store(car); Is there an easier way to store objects?
  • 12.
    12 Is there aneasier way to store objects? • Car car = new Car("Ferrari"); • database.store(car); • Simply • store objects to the database • get objects back from the database • Persistence by reachability • Database engine can analyze class schema
  • 13.
    13 What about queries? •SELECT * FROM car, car_brake, brake, car_motor, motor • WHERE car.id = car_brake.car_id • AND brake.id = car_brake.brake_id • AND car.id = car_motor.car_id • AND motor.id = car_motor.motor_id • AND brake.type = 'Ceramic' • AND motor.power > 400;
  • 14.
    14 Is there aneasier way to query for objects? • car.brake.type == "Ceramic" • && car.motor.power > 400;
  • 15.
    15 Introducing Native Queries •return car.brake.type == "Ceramic" • && car.motor.power > 400;
  • 16.
    16 Introducing Native Queries •public boolean match(Car car){ • return car.brake.type == "Ceramic" • && car.motor.power > 400; • }
  • 17.
    17 Introducing Native Queries •new Predicate <Car>(){ • public boolean match(Car car){ • return car.brake.type == "Ceramic" • && car.motor.power > 400; • } • }
  • 18.
    18 Introducing Native Queries •List<Car> cars = • database.query(new Predicate <Car>(){ • public boolean match(Car car){ • return car.brake.type == "Ceramic" • && car.motor.power > 400; • } • });
  • 19.
    19 Outlook: Native Queriesusing Closures • List<Car> cars = • database.query({ • Car car => • car.brake.type == "Ceramic" • && car.motor.power > 400; • } • );
  • 20.
    20 Object-Oriented Persistence • 100%pure Java • 100% refactorable • 100% typesafe • 100% checked at compile-time • no O-R impedance mismatch • minimum code • maximum performance
  • 21.
    21 Object-Oriented Persistence • StoreObjects • Native Queries
  • 22.
  • 23.
  • 24.
    24 Introducing db4o • PlainObject Persistence • Zero Administration • Automatic Schema Management • Optimized Native Queries • compile time • load time • run time • OSGi Service Interface • OSGi ClassLoader aware
  • 25.
    25 Introducing db4objects • OpenSource Project db4o • GPL License • Registered Community of 20,000 developers
  • 26.
    26 Introducing db4objects • Commercialdb4o Licenses • Customers include Boeing, RICOH, Bosch, Indra
  • 27.
    27 db4o for OSGi •db4objects is a member of the OSGi alliance • Dedicated db4o version for OSGi • Partnership with ProSyst • ProSyst bundles db4o with mBedded Server
  • 28.