Package com.esotericsoftware.kryo.serialize

Examples of com.esotericsoftware.kryo.serialize.FieldSerializer


    waitForThreads();
  }

  static public void register (Kryo kryo) {
    kryo.register(short[].class);
    kryo.register(SomeData.class, new DeltaCompressor(kryo, new FieldSerializer(kryo, SomeData.class), 2048, 4));
    kryo.register(SomeOtherData.class);
  }
View Full Code Here


    waitForThreads();
  }

  static public void register (Kryo kryo) {
    kryo.register(short[].class);
    kryo.register(SomeData.class, new DeflateCompressor(new FieldSerializer(kryo, SomeData.class)));
    kryo.register(ArrayList.class, new CollectionSerializer(kryo));
  }
View Full Code Here

   * @see Kryo#register(Class, Serializer) */
  static public void registerClasses (Kryo kryo) {
    kryo.register(Object[].class);
    kryo.register(InvokeMethod.class);

    FieldSerializer serializer = (FieldSerializer)kryo.register(InvokeMethodResult.class).getSerializer();
    serializer.getField("objectID").setClass(int.class, new IntSerializer(true));

    kryo.register(InvocationHandler.class, new Serializer() {
      public void writeObjectData (ByteBuffer buffer, Object object) {
        RemoteInvocationHandler handler = (RemoteInvocationHandler)Proxy.getInvocationHandler(object);
        IntSerializer.put(buffer, handler.objectID, true);
View Full Code Here

/**
* This test does all possible Kryo serializer optimizations.
*/
public class KryoOptimizedSerializer extends KryoSerializer {
  public KryoOptimizedSerializer () {
    FieldSerializer imageSerializer = (FieldSerializer)kryo.getSerializer(Image.class);
    imageSerializer.setFieldsCanBeNull(false);

    FieldSerializer mediaContentSerializer = (FieldSerializer)kryo.getSerializer(MediaContent.class);
    mediaContentSerializer.setFieldsCanBeNull(false);

    CachedField imagesField = mediaContentSerializer.getField("_images");
    CollectionSerializer imagesSerializer = new CollectionSerializer(kryo);
    imagesSerializer.setElementClass(Image.class);
    imagesSerializer.setElementsCanBeNull(false);
    imagesSerializer.setLength(2);
    imagesField.setClass(ArrayList.class, imagesSerializer);

    CachedField mediaField = mediaContentSerializer.getField("_media");
    FieldSerializer mediaSerializer = new FieldSerializer(kryo, Media.class);
    mediaSerializer.setFieldsCanBeNull(false);
    mediaField.setClass(Media.class, mediaSerializer);

    CachedField personsField = mediaSerializer.getField("_persons");
    CollectionSerializer personsSerializer = new CollectionSerializer(kryo);
    personsSerializer.setElementClass(String.class);
    personsSerializer.setElementsCanBeNull(false);
    personsSerializer.setLength(2);
    personsField.setClass(ArrayList.class, personsSerializer);

    mediaSerializer.getField("_copyright").setCanBeNull(true);
  }
View Full Code Here

    }

    @Override
    public Serializer newSerializer( final Class<?> type ) {
        if ( SERIALIZED_CLASS_NAME.equals( type.getName() ) ) {
            return new FieldSerializer( _kryo, type );
        }
        return null;
    }
View Full Code Here

    @Override
    public Serializer newSerializer( final Class<?> type ) {
        if( HIBERNATE_ABSTRACT_COLLECTION_CLASS == null ) {
            return null;
        } else if ( HIBERNATE_ABSTRACT_COLLECTION_CLASS.isAssignableFrom( type ) ) {
            return new FieldSerializer( _kryo, type );
        }
        return null;
    }
View Full Code Here

  /**
   * Called by {@link #newSerializer(Class)} when a serializer could not otherwise be determined. The default implementation
   * returns a new {@link FieldSerializer}.
   */
  protected Serializer newDefaultSerializer (Class type) {
    return new FieldSerializer(this, type);
  }
View Full Code Here

TOP

Related Classes of com.esotericsoftware.kryo.serialize.FieldSerializer

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.