Examples of KryoReflectionFactorySupport


Examples of de.javakaffee.kryoserializers.KryoReflectionFactorySupport

    }

    private Triple<Kryo, SerializerFactory[], UnregisteredClassHandler[]> createKryo( final ClassLoader classLoader,
            final String[] customConverterClassNames, final boolean copyCollectionsForSerialization ) {
       
        final Kryo kryo = new KryoReflectionFactorySupport() {
           
            @Override
            @SuppressWarnings( { "rawtypes", "unchecked" } )
            public Serializer newSerializer(final Class clazz) {
                final Serializer customSerializer = loadCustomSerializer( clazz );
                if ( customSerializer != null ) {
                    return customSerializer;
                }
                if ( EnumSet.class.isAssignableFrom( clazz ) ) {
                    return new EnumSetSerializer( this );
                }
                if ( EnumMap.class.isAssignableFrom( clazz ) ) {
                    return new EnumMapSerializer( this );
                }
                if ( SubListSerializer.canSerialize( clazz ) ) {
                    return new SubListSerializer( this, clazz );
                }
                if ( copyCollectionsForSerialization ) {
                    final Serializer copyCollectionSerializer = loadCopyCollectionSerializer( clazz, this );
                    if ( copyCollectionSerializer != null ) {
                        return copyCollectionSerializer;
                    }
                }
                if ( Date.class.isAssignableFrom( clazz ) ) {
                    return new DateSerializer( clazz );
                }
                return super.newSerializer( clazz );
            }
           
            @SuppressWarnings( { "rawtypes" } )
            @Override
            protected void handleUnregisteredClass( final Class clazz ) {
                if ( _unregisteredClassHandlers != null ) {
                    for( int i = 0; i < _unregisteredClassHandlers.length; i++ ) {
                        final boolean handled = _unregisteredClassHandlers[i].handleUnregisteredClass( clazz );
                        if ( handled ) {
                            if ( LOG.isDebugEnabled() ) {
                                LOG.debug( "UnregisteredClassHandler " + _unregisteredClassHandlers[i].getClass().getName() + " handled class " + clazz );
                            }
                            return;
                        }
                    }
                }
                super.handleUnregisteredClass( clazz );
            }
           
            @Override
            protected Serializer newDefaultSerializer( @SuppressWarnings( "rawtypes" ) final Class type ) {
                return _defaultSerializerFactory.newDefaultSerializer( this, type );
            }

        };
       
        if ( classLoader != null ) {
            kryo.setClassLoader( classLoader );
        }
       
        // com.esotericsoftware.minlog.Log.TRACE = true;
       
        kryo.setRegistrationOptional( true );
        kryo.register( ArrayList.class );
        kryo.register( LinkedList.class );
        kryo.register( HashSet.class );
        kryo.register( HashMap.class );
        kryo.register( Arrays.asList( "" ).getClass(), new ArraysAsListSerializer( kryo ) );
        kryo.register( Currency.class, new CurrencySerializer( kryo ) );
        kryo.register( StringBuffer.class, new StringBufferSerializer( kryo ) );
        kryo.register( StringBuilder.class, new StringBuilderSerializer( kryo ) );
        kryo.register( Collections.EMPTY_LIST.getClass(), new CollectionsEmptyListSerializer() );
        kryo.register( Collections.EMPTY_MAP.getClass(), new CollectionsEmptyMapSerializer() );
        kryo.register( Collections.EMPTY_SET.getClass(), new CollectionsEmptySetSerializer() );
        kryo.register( Collections.singletonList( "" ).getClass(), new CollectionsSingletonListSerializer( kryo ) );
        kryo.register( Collections.singleton( "" ).getClass(), new CollectionsSingletonSetSerializer( kryo ) );
        kryo.register( Collections.singletonMap( "", "" ).getClass(), new CollectionsSingletonMapSerializer( kryo ) );
        kryo.register( Class.class, new ClassSerializer( kryo ) );
        kryo.register( BigDecimal.class, new BigDecimalSerializer() );
        kryo.register( BigInteger.class, new BigIntegerSerializer() );
        kryo.register( GregorianCalendar.class, new GregorianCalendarSerializer() );
        kryo.register( InvocationHandler.class, new JdkProxySerializer( kryo ) );
        UnmodifiableCollectionsSerializer.registerSerializers( kryo );
        SynchronizedCollectionsSerializer.registerSerializers( kryo );
        kryo.register( Locale.class, new LocaleSerializer() );
       
        final Triple<KryoCustomization[], SerializerFactory[], UnregisteredClassHandler[]> pair = loadCustomConverter( customConverterClassNames,
                classLoader, kryo );
       
        final KryoCustomization[] customizations = pair.a;
View Full Code Here

Examples of de.javakaffee.kryoserializers.KryoReflectionFactorySupport

public class SpringSecurityUserSerializerTest {

  @Test
  public void testSpringSecurityUserSerializer() {
    final Kryo kryo = new KryoReflectionFactorySupport();
    kryo.setRegistrationOptional(true);
   
    new SpringSecurityUserRegistration().customize(kryo);
   
    final Collection<? extends GrantedAuthority> authorities = Arrays.asList(new SimpleGrantedAuthority("foo"));
    final User user = new User("foo", "bar", authorities);
View Full Code Here

Examples of de.javakaffee.kryoserializers.KryoReflectionFactorySupport

   *
   * @return
   */
  protected Kryo createKryo()
  {
    return new KryoReflectionFactorySupport();
  }
View Full Code Here

Examples of de.javakaffee.kryoserializers.KryoReflectionFactorySupport

    internalInit(kryo);
  }

  protected Kryo createKryo()
  {
    return new KryoReflectionFactorySupport();
  }
View Full Code Here

Examples of de.javakaffee.kryoserializers.KryoReflectionFactorySupport

    private WicketTester _wicketTester;

    @BeforeTest
    @SuppressWarnings( "unchecked" )
    protected void beforeTest() {
        _kryo = new KryoReflectionFactorySupport() {
           
            @SuppressWarnings("rawtypes")
            @Override
            public Serializer getDefaultSerializer( final Class type ) {
                if ( SERIALIZED_CLASS_NAME.equals( type.getName() ) ) {
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.