@Override public Serializer getDefaultSerializer(Class type) { if (_override) { return new SerializableSerializer(); } else { return super.getDefaultSerializer(type); } } }
@Override public Serializer getDefaultSerializer(Class type) { if (_override) { return new SerializableSerializer(); } else { return super.getDefaultSerializer(type); } } }
@Override public Serializer getDefaultSerializer(Class type) { if (type == null) { throw new IllegalArgumentException("type cannot be null."); } /** * Kryo requires every class to provide a zero argument constructor. For any class does not match this condition, kryo have two ways: * 1. Use JavaSerializer, * 2. Set 'kryo.setInstantiatorStrategy(new DefaultInstantiatorStrategy(new StdInstantiatorStrategy()));', StdInstantiatorStrategy can generate an instance bypassing the constructor. * * In practice, it's not possible for Dubbo users to register kryo Serializer for every customized class. So in most cases, customized classes with/without zero argument constructor will * default to the default serializer. * It is the responsibility of kryo to handle with every standard jdk classes, so we will just escape these classes. */ if (!ReflectionUtils.isJdk(type) && !type.isArray() && !type.isEnum() && !ReflectionUtils.checkZeroArgConstructor(type)) { if (logger.isWarnEnabled()) { logger.warn(type + " has no zero-arg constructor and this will affect the serialization performance"); } return new JavaSerializer(); } return super.getDefaultSerializer(type); } }
@Override public Serializer getDefaultSerializer(Class type) { if (type == null) { throw new IllegalArgumentException("type cannot be null."); } /** * Kryo requires every class to provide a zero argument constructor. For any class does not match this condition, kryo have two ways: * 1. Use JavaSerializer, * 2. Set 'kryo.setInstantiatorStrategy(new DefaultInstantiatorStrategy(new StdInstantiatorStrategy()));', StdInstantiatorStrategy can generate an instance bypassing the constructor. * * In practice, it's not possible for Dubbo users to register kryo Serializer for every customized class. So in most cases, customized classes with/without zero argument constructor will * default to the default serializer. * It is the responsibility of kryo to handle with every standard jdk classes, so we will just escape these classes. */ if (!ReflectionUtils.isJdk(type) && !type.isArray() && !type.isEnum() && !ReflectionUtils.checkZeroArgConstructor(type)) { if (logger.isWarnEnabled()) { logger.warn(type + " has no zero-arg constructor and this will affect the serialization performance"); } return new JavaSerializer(); } return super.getDefaultSerializer(type); } }
@Override @SuppressWarnings( { "rawtypes" } ) public Serializer<?> getDefaultSerializer(final Class clazz) { final Serializer<?> customSerializer = loadCustomSerializer( clazz, serializerFactories ); if ( customSerializer != null ) { return customSerializer; } if ( copyCollectionsForSerialization ) { // could also be installed via addDefaultSerializer final Serializer<?> copyCollectionSerializer = loadCopyCollectionSerializer( clazz ); if ( copyCollectionSerializer != null ) { return copyCollectionSerializer; } } return super.getDefaultSerializer( clazz ); }
kryo.register(pair.getValue0(), new UnshadedSerializerAdapter(((ShadedSerializerAdapter) pair.getValue1()).getSerializerShim())); else kryo.register(pair.getValue0(), kryo.getDefaultSerializer(pair.getValue0()));
@Override public Serializer getDefaultSerializer(Class type) { if(_override) { return new SerializableSerializer(); } else { return super.getDefaultSerializer(type); } } }
@Override @SuppressWarnings("rawtypes") // superclass doesn't use types public Serializer getDefaultSerializer(Class type) { if (override) { return new SerializableSerializer(); } else { return super.getDefaultSerializer(type); } } }
@Override public Serializer getDefaultSerializer(Class type) { if(_override) { return new SerializableSerializer(); } else { return super.getDefaultSerializer(type); } } }
@Override public Serializer getDefaultSerializer(Class type) { if (override) { return new SerializableSerializer(); } else { return super.getDefaultSerializer(type); } } }
public void registerExplicit(ClassIdPair pair) throws ClassNotFoundException { //logger.debug("registering class {} => {}", pair.classname, pair.id); //pairs.add(pair); Class type = Class.forName(pair.classname, false, Thread.currentThread().getContextClassLoader()); register(new Registration(type, kryo.getDefaultSerializer(type), pair.id)); if (nextAvailableRegistrationId <= pair.id) { nextAvailableRegistrationId = pair.id + 1; } }
/** Registers the class using the lowest, next available integer ID and the {@link Kryo#getDefaultSerializer(Class) default * serializer}. If the class is already registered, no change will be made and the existing registration will be returned. * Registering a primitive also affects the corresponding primitive wrapper. * <p> * Because the ID assigned is affected by the IDs registered before it, the order classes are registered is important when * using this method. The order must be the same at deserialization as it was for serialization. */ public Registration register (Class type) { Registration registration = classResolver.getRegistration(type); if (registration != null) return registration; return register(type, getDefaultSerializer(type)); }
/** Registers the class using the specified ID and the {@link Kryo#getDefaultSerializer(Class) default serializer}. If the * class is already registered this has no effect and the existing registration is returned. Registering a primitive also * affects the corresponding primitive wrapper. * <p> * IDs must be the same at deserialization as they were for serialization. * @param id Must be >= 0. Smaller IDs are serialized more efficiently. IDs 0-8 are used by default for primitive types and * String, but these IDs can be repurposed. */ public Registration register (Class type, int id) { Registration registration = classResolver.getRegistration(type); if (registration != null) return registration; return register(type, getDefaultSerializer(type), id); }
/** Registers the class using the specified ID and the {@link Kryo#getDefaultSerializer(Class) default serializer}. If the ID is * already in use by the same type, the old entry is overwritten. If the ID is already in use by a different type, a * {@link KryoException} is thrown. Registering a primitive also affects the corresponding primitive wrapper. * <p> * IDs must be the same at deserialization as they were for serialization. * @param id Must be >= 0. Smaller IDs are serialized more efficiently. IDs 0-8 are used by default for primitive types and * String, but these IDs can be repurposed. */ public Registration register (Class type, int id) { Registration registration = classResolver.getRegistration(type); if (registration != null) return registration; return register(type, getDefaultSerializer(type), id); }
/** Registers the class using the lowest, next available integer ID and the {@link Kryo#getDefaultSerializer(Class) default * serializer}. If the class is already registered, the existing entry is updated with the new serializer. Registering a * primitive also affects the corresponding primitive wrapper. * <p> * Because the ID assigned is affected by the IDs registered before it, the order classes are registered is important when * using this method. The order must be the same at deserialization as it was for serialization. */ public Registration register (Class type) { Registration registration = classResolver.getRegistration(type); if (registration != null) return registration; return register(type, getDefaultSerializer(type)); }
/** Registers the class using the specified ID and the {@link Kryo#getDefaultSerializer(Class) default serializer}. If the * class is already registered this has no effect and the existing registration is returned. Registering a primitive also * affects the corresponding primitive wrapper. * <p> * IDs must be the same at deserialization as they were for serialization. * @param id Must be >= 0. Smaller IDs are serialized more efficiently. IDs 0-8 are used by default for primitive types and * String, but these IDs can be repurposed. */ public Registration register (Class type, int id) { Registration registration = classResolver.getRegistration(type); if (registration != null) return registration; return register(type, getDefaultSerializer(type), id); }
/** Registers the class using the lowest, next available integer ID and the {@link Kryo#getDefaultSerializer(Class) default * serializer}. If the class is already registered, no change will be made and the existing registration will be returned. * Registering a primitive also affects the corresponding primitive wrapper. * <p> * Because the ID assigned is affected by the IDs registered before it, the order classes are registered is important when * using this method. The order must be the same at deserialization as it was for serialization. */ public Registration register (Class type) { Registration registration = classResolver.getRegistration(type); if (registration != null) return registration; return register(type, getDefaultSerializer(type)); }
@Override @SuppressWarnings("rawtypes") public Registration registerImplicit(Class type) { while (getRegistration(nextAvailableRegistrationId) != null) { nextAvailableRegistrationId++; } //logger.debug("adding new classid pair {} => {}", nextAvailableRegistrationId, type.getName()); pairs.add(new ClassIdPair(nextAvailableRegistrationId, type.getName())); return register(new Registration(type, kryo.getDefaultSerializer(type), nextAvailableRegistrationId++)); }
@Override public Serializer<?> getDefaultSerializer(@SuppressWarnings("rawtypes") final Class type) { final Serializer<?> result = super.getDefaultSerializer(type); if(result instanceof FieldSerializer && ((FieldSerializer<?>) result).getFieldSerializerConfig().getIgnoreSyntheticFields()) { // don't ignore synthetic fields so that inner classes work (see KryoTest.testInnerClass) FieldSerializer<?> fieldSerializer = (FieldSerializer<?>) result; fieldSerializer.getFieldSerializerConfig().setIgnoreSyntheticFields(false); fieldSerializer.updateFields(); } return result; }
@Override public Serializer<?> getDefaultSerializer(@SuppressWarnings("rawtypes") final Class type) { final Serializer<?> result = super.getDefaultSerializer(type); if(result instanceof FieldSerializer && ((FieldSerializer<?>) result).getFieldSerializerConfig().getIgnoreSyntheticFields()) { // don't ignore synthetic fields so that inner classes work (see KryoTest.testInnerClass) FieldSerializer<?> fieldSerializer = (FieldSerializer<?>) result; fieldSerializer.getFieldSerializerConfig().setIgnoreSyntheticFields(false); fieldSerializer.updateFields(); } return result; }