org.jenkinsci.jruby
Class RubyRuntimeResolver

java.lang.Object
  extended by org.jenkinsci.jruby.RubyRuntimeResolver

public abstract class RubyRuntimeResolver
extends Object

When persistence of multiple JRuby runtime is involved, the caller can provide an implementation of this interface to (1) write out enough keys to reconnect back to the right runtime, and (2) read those info and actually resolve the instance of Ruby.

When a single XStream instance may involve reading/writing an object graph that consists of Ruby objects from multiple separate JVMs, this abstraction provides you a means to preserve them.

Author:
Kohsuke Kawaguchi

Constructor Summary
RubyRuntimeResolver()
           
 
Method Summary
abstract  void marshal(org.jruby.runtime.builtin.IRubyObject instance, com.thoughtworks.xstream.io.HierarchicalStreamWriter writer, com.thoughtworks.xstream.converters.MarshallingContext context)
          Write out the necessary attributes/elements for the unmarshal(HierarchicalStreamReader, UnmarshallingContext) method to reconnect back later.
static RubyRuntimeResolver of(org.jruby.Ruby runtime)
          Returns an implementation that always resolves to the single ruby runtime.
abstract  org.jruby.Ruby unmarshal(com.thoughtworks.xstream.io.HierarchicalStreamReader reader, com.thoughtworks.xstream.converters.UnmarshallingContext context)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

RubyRuntimeResolver

public RubyRuntimeResolver()
Method Detail

unmarshal

public abstract org.jruby.Ruby unmarshal(com.thoughtworks.xstream.io.HierarchicalStreamReader reader,
                                         com.thoughtworks.xstream.converters.UnmarshallingContext context)
Returns:
Return the ruby runtime from which the object in question will be unmarshalled from.

marshal

public abstract void marshal(org.jruby.runtime.builtin.IRubyObject instance,
                             com.thoughtworks.xstream.io.HierarchicalStreamWriter writer,
                             com.thoughtworks.xstream.converters.MarshallingContext context)
Write out the necessary attributes/elements for the unmarshal(HierarchicalStreamReader, UnmarshallingContext) method to reconnect back later.

Parameters:
instance - Ruby object being serialized.

of

public static RubyRuntimeResolver of(org.jruby.Ruby runtime)
Returns an implementation that always resolves to the single ruby runtime. No data is added to the persisted form.



Copyright © 2004-2011. All Rights Reserved.