SerializationServiceImpl(
      InputOutputFactory inputOutputFactory,
      int version,
      ClassLoader classLoader,
      Map<Integer, ? extends DataSerializableFactory> dataSerializableFactories,
      Map<Integer, ? extends PortableFactory> portableFactories,
      Collection<ClassDefinition> classDefinitions,
      boolean checkClassDefErrors,
      ManagedContext managedContext,
      PartitioningStrategy partitionStrategy,
      int initialOutputBufferSize,
      boolean enableCompression,
      boolean enableSharedObject) {

    this.inputOutputFactory = inputOutputFactory;
    this.classLoader = classLoader;
    this.managedContext = managedContext;
    this.globalPartitioningStrategy = partitionStrategy;
    this.outputBufferSize = initialOutputBufferSize;

    PortableHookLoader loader = new PortableHookLoader(portableFactories, classLoader);
    serializationContext =
        new SerializationContextImpl(this, loader.getFactories().keySet(), version);
    for (ClassDefinition cd : loader.getDefinitions()) {
      serializationContext.registerClassDefinition(cd);
    }

    dataSerializerAdapter =
        new StreamSerializerAdapter(
            this, new DataSerializer(dataSerializableFactories, classLoader));
    portableSerializer = new PortableSerializer(serializationContext, loader.getFactories());
    portableSerializerAdapter = new StreamSerializerAdapter(this, portableSerializer);

    registerConstant(DataSerializable.class, dataSerializerAdapter);
    registerConstant(Portable.class, portableSerializerAdapter);
    registerConstant(Byte.class, new ByteSerializer());
    registerConstant(Boolean.class, new BooleanSerializer());
    registerConstant(Character.class, new CharSerializer());
    registerConstant(Short.class, new ShortSerializer());
    registerConstant(Integer.class, new IntegerSerializer());
    registerConstant(Long.class, new LongSerializer());
    registerConstant(Float.class, new FloatSerializer());
    registerConstant(Double.class, new DoubleSerializer());
    registerConstant(byte[].class, new TheByteArraySerializer());
    registerConstant(char[].class, new CharArraySerializer());
    registerConstant(short[].class, new ShortArraySerializer());
    registerConstant(int[].class, new IntegerArraySerializer());
    registerConstant(long[].class, new LongArraySerializer());
    registerConstant(float[].class, new FloatArraySerializer());
    registerConstant(double[].class, new DoubleArraySerializer());
    registerConstant(String.class, new StringSerializer());

    safeRegister(Date.class, new DateSerializer());
    safeRegister(BigInteger.class, new BigIntegerSerializer());
    safeRegister(BigDecimal.class, new BigDecimalSerializer());
    safeRegister(Externalizable.class, new Externalizer(enableCompression));
    safeRegister(Serializable.class, new ObjectSerializer(enableSharedObject, enableCompression));
    safeRegister(Class.class, new ClassSerializer());
    safeRegister(Enum.class, new EnumSerializer());

    registerClassDefinitions(classDefinitions, checkClassDefErrors);
  }
 private void registerConstant(Class type, Serializer serializer) {
   registerConstant(type, createSerializerAdapter(serializer));
 }