I like your suggestions to make it more Rubyish. I will fix it up.I
only did it (created an instance variable @people) because I knew how
to do it. Is people (in your example) a local variable and is there
an API for creating locals?
BTW, this API is wholly my design and I am not nearly as experienced
with Ruby as yourself. So I am wide open to suggestions. I will be
adding ActiveRecord-like features to it in the coming days. Please
keep 'em coming.
(see comments below)
Alan
On Jul 16, 2007, at 12:26 PM, Charles Oliver Nutter wrote:
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.
I wrote it thinking that it would be something you put into a Rails
controller, but, yes, you could get persistence anywhere.
persistent 'people'
This feels a bit like the attr* methods, perhaps it could work the
same way?
persistent :people
people.store(person)
I'll fix it.
Or something more rubyish?
people << person
This, too.
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:
Yes, again.
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 }
Maybe find() would be better than fetch()? Finders are on their way,
both predefined and dynamic. They will be mostly based on collections
that have been indexed for performance. To do that, I need to
integrate a couple of our collections into JRuby. I have browsed
examples (JArray) but would enjoy some instruction on what the
various pieces do.
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?
Although the serialization is meant for any vm, the persistence only
works in ours. It's a certified JVM that we licensed from Sun and has
low-level tweaks for transparent persistence. It is based on a shared
page cache. Objects that are put into the page cache are faulted in
and out on demand.
We intend to make a vm available along the same lines as we are doing
with the Seaside product: free for one server and up to 4 gig of
data. After that, its a few thousand (price to be determined). For
many applications, the free version will be perfect.
We are currently in early alpha stage with our Java 1.6 port of the
product, so it is not generally available yet. When it reaches beta
(about a month), we will be happy to distribute it to the dev group.
- Charlie
---------------------------------------------------------------------
To unsubscribe from this list please visit:
http://xircles.codehaus.org/manage_email
---------------------------------------------------------------------
To unsubscribe from this list please visit:
http://xircles.codehaus.org/manage_email