Alan McKean wrote:
To write persistent objects
require 'java'
require 'employee'
require 'persistence'
include Persistence
I presume you would normally include this into a custom type rather than
into Object, but it's pretty convenient you can do this anywhere to gain
persistence functionality.
persistent 'people'
This feels a bit like the attr* methods, perhaps it could work the same way?
persistent :people
people.store(person)
Or something more rubyish?
people << person
person = Person.new('Alan')
employee = Employee.new('Bob', 12345)
@people.store(person)
@people.store(employee)
person.children = Array.new
employee.children = Array.new
person.add_child(Person.new('Jesse'))
person.add_child(Person.new('Blake'))
employee.add_child(Person.new('Ben'))
@people.commit
puts 'Committed people'
Some rubyisms missing here:
person.children = []
employee.children = []
To read persistent objects (in another VM)
require 'java'
require 'employee'
require 'persistence'
include Persistence
persistent 'people'
person = @people.fetch(0)
employee = @people.fetch(1)
puts 'Person name = ' + person.name
person.children.each {|child| puts 'child = ' << child.name}
puts
puts 'Employee name = ' + employee.name
puts 'Employee ssn = ' + employee.ssn.to_s
employee.children.each {|child| puts 'child = ' << child.name }
All told the API looks pretty nice. What sort of querying facilities are
there?
Is this only applicable to running on/with something GemStone-y?
- Charlie
---------------------------------------------------------------------
To unsubscribe from this list please visit:
http://xircles.codehaus.org/manage_email