Revert JRuby callback to use RubyBSONCallback

This commit is contained in:
Kyle Banker 2010-10-01 13:57:16 -04:00
parent 159c89b8b4
commit c04dfec1db
3 changed files with 3 additions and 9 deletions

Binary file not shown.

View File

@ -2,23 +2,17 @@ include Java
module BSON
class BSON_JAVA
# TODO: Pool or cache instances of RubyBSONEncoder so that
# we don't create a new one on each call to #serialize.
def self.serialize(obj, check_keys=false, move_id=false)
raise InvalidDocument, "BSON_JAVA.serialize takes a Hash" unless obj.is_a?(Hash)
enc = Java::OrgJbson::RubyBSONEncoder.new(JRuby.runtime)
ByteBuffer.new(enc.encode(obj))
end
def self.get_encoder
@@enc ||= Java::OrgJbson::RubyBSONEncoder.new(JRuby.runtime)
end
def self.get_decoder
@@dec ||= Java::OrgBson::BSONDecoder.new
end
def self.deserialize(buf)
dec = Java::OrgBson::BSONDecoder.new
callback = Java::OrgJbson::RubyBSONJavaCallback.new(JRuby.runtime)
callback = Java::OrgJbson::RubyBSONCallback.new(JRuby.runtime)
dec.decode(buf.to_s.to_java_bytes, callback)
callback.get
end