com.twitter.chill.config
Class ConfiguredInstantiator

java.lang.Object
  extended by com.twitter.chill.KryoInstantiator
      extended by com.twitter.chill.config.ConfiguredInstantiator
All Implemented Interfaces:
java.io.Serializable

public class ConfiguredInstantiator
extends KryoInstantiator

This is the standard Config based KryoInstantiator. It delegates to another KryoInstantiator that is described a Config object. This is either done via reflection or reflection AND serialization. If the KEY is not set, the delegate is the default: new KryoInstantiator() In the case of reflection, the class name of the delegate instantiator is given. In the case of serialization, we first reflect to create the KryoInstatiator we use to get the Kryo we need to deserialize.

See Also:
Serialized Form

Field Summary
protected  KryoInstantiator delegate
           
static java.lang.String KEY
          Key we use to configure this class.
 
Constructor Summary
ConfiguredInstantiator(Config conf)
           
 
Method Summary
protected static KryoInstantiator deserialize(com.esotericsoftware.kryo.Kryo k, java.lang.String base64Value)
           
 KryoInstantiator getDelegate()
          Return the delegated KryoInstantiator
 com.esotericsoftware.kryo.Kryo newKryo()
          Calls through to the delegate
protected static java.lang.String serialize(com.esotericsoftware.kryo.Kryo k, KryoInstantiator ki)
           
static void setReflect(Config conf, java.lang.Class<? extends KryoInstantiator> instClass)
          In this mode, we are just refecting to another delegated class.
static void setSerialized(Config conf, java.lang.Class<? extends KryoInstantiator> reflector, KryoInstantiator ki)
          If this reflector needs config to be set, that should be done PRIOR to making this call.
static void setSerialized(Config conf, KryoInstantiator ki)
          Use the default KryoInstantiator to serialize the KryoInstantiator ki same as: setSerialized(conf, KryoInstantiator.class, ki)
 
Methods inherited from class com.twitter.chill.KryoInstantiator
setInstantiatorStrategy, setReferences, setRegistrationRequired, withRegistrar
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

delegate

protected final KryoInstantiator delegate

KEY

public static final java.lang.String KEY
Key we use to configure this class. Format: (:) if there is no serialized instantiator, we use the reflected instance as the delegate

See Also:
Constant Field Values
Constructor Detail

ConfiguredInstantiator

public ConfiguredInstantiator(Config conf)
                       throws ConfigurationException
Throws:
ConfigurationException
Method Detail

newKryo

public com.esotericsoftware.kryo.Kryo newKryo()
Calls through to the delegate

Overrides:
newKryo in class KryoInstantiator

getDelegate

public KryoInstantiator getDelegate()
Return the delegated KryoInstantiator


setReflect

public static void setReflect(Config conf,
                              java.lang.Class<? extends KryoInstantiator> instClass)
In this mode, we are just refecting to another delegated class. This is preferred if you don't have any configuration to do at runtime (i.e. you can make a named class that has all the logic for your KryoInstantiator).


setSerialized

public static void setSerialized(Config conf,
                                 KryoInstantiator ki)
                          throws ConfigurationException
Use the default KryoInstantiator to serialize the KryoInstantiator ki same as: setSerialized(conf, KryoInstantiator.class, ki)

Throws:
ConfigurationException

setSerialized

public static void setSerialized(Config conf,
                                 java.lang.Class<? extends KryoInstantiator> reflector,
                                 KryoInstantiator ki)
                          throws ConfigurationException
If this reflector needs config to be set, that should be done PRIOR to making this call. This mode serializes an instance (ki) to be used as the delegate. Only use this mode if reflection alone will not work.

Throws:
ConfigurationException

deserialize

protected static KryoInstantiator deserialize(com.esotericsoftware.kryo.Kryo k,
                                              java.lang.String base64Value)
                                       throws ConfigurationException
Throws:
ConfigurationException

serialize

protected static java.lang.String serialize(com.esotericsoftware.kryo.Kryo k,
                                            KryoInstantiator ki)