SofaHessianSerializer extends AbstractSerializer { protected SerializerFactory getSerializerFactory(boolean multipleClassLoader, boolean generic) { if (generic) { return multipleClassLoader ? new GenericMultipleClassLoaderSofaSerializerFactory() : new GenericSingleClassLoaderSofaSerializerFactory(); } else { return multipleClassLoader ? new MultipleClassLoaderSofaSerializerFactory() : new SingleClassLoaderSofaSerializerFactory(); } } SofaHessianSerializer(); @Override AbstractByteBuf encode(Object object, Map<String, String> context); @Override Object decode(AbstractByteBuf data, Class clazz, Map<String, String> context); @Override void decode(AbstractByteBuf data, Object template, Map<String, String> context);  }
@Test public void getSerializerFactory() { Assert.assertEquals(SingleClassLoaderSofaSerializerFactory.class, serializer.getSerializerFactory(false, false).getClass()); Assert.assertEquals(MultipleClassLoaderSofaSerializerFactory.class, serializer.getSerializerFactory(true, false).getClass()); Assert.assertEquals(GenericSingleClassLoaderSofaSerializerFactory.class, serializer.getSerializerFactory(false, true).getClass()); Assert.assertEquals(GenericMultipleClassLoaderSofaSerializerFactory.class, serializer.getSerializerFactory(true, true).getClass()); }