@Override public void serialize( final DataObjectSerializerRegistry reg, final DataObject obj, final BindingStreamEventWriter stream) throws IOException { if (obj instanceof Augmentable<?>) { final Map<Class<? extends Augmentation<?>>, Augmentation<?>> augmentations; if (reg instanceof AugmentationReader) { augmentations = ((AugmentationReader) reg).getAugmentations(obj); } else if (Proxy.isProxyClass(obj.getClass())) { augmentations = getFromProxy(obj); } else { augmentations = BindingReflections.getAugmentations((Augmentable<?>) obj); } for (final Entry<Class<? extends Augmentation<?>>, Augmentation<?>> aug : augmentations.entrySet()) { emitAugmentation(aug.getKey(), aug.getValue(), stream, reg); } } }
/** * Transforms POJO message into ByteBuf * * @param version version used for encoding received message * @param out ByteBuf for storing and sending transformed message * @param message POJO message */ public void messageToBuffer(short version, ByteBuf out, DataObject message) { OFSerializer<DataObject> serializer = registry.getSerializer(new MessageTypeKey<>(version, message.getImplementedInterface())); serializer.serialize(message, out); }