@Override public SerializedType typeForClass(Class type) { return delegate.typeForClass(type); }
private String getSagaTypeName(Class<?> sagaType) { return serializer.typeForClass(sagaType).getName(); }
private String sagaTypeName(Class<?> sagaType) { return serializer.typeForClass(sagaType).getName(); }
@SuppressWarnings("unchecked") public <T> SerializedObject<T> serializePayload(Serializer serializer, Class<T> expectedRepresentation) { synchronized (payloadGuard) { SerializedObject existingForm = serializedPayload.get(serializer); if (existingForm == null) { SerializedObject<T> serialized = serializer.serialize(message.getPayload(), expectedRepresentation); if (message.getPayload() == null) { // make sure the payload type is maintained serialized = new SimpleSerializedObject<>(serialized.getData(), serialized.getContentType(), serializer.typeForClass(message.getPayloadType())); } serializedPayload.put(serializer, serialized); return serialized; } else { return serializer.getConverter().convert(existingForm, expectedRepresentation); } } }
@Override public SerializedType typeForClass(Class type) { return serializer.typeForClass(type); }
@Override public SerializedType typeForClass(Class type) { return delegate.typeForClass(type); }
private String sagaTypeName(Class<?> sagaType) { return serializer.typeForClass(sagaType).getName(); }
private String getSagaTypeName(Class<?> sagaType) { return serializer.typeForClass(sagaType).getName(); }
private String sagaTypeName(Class<?> sagaType) { return serializer.typeForClass(sagaType).getName(); }
private String getSagaTypeName(Class<?> sagaType) { return serializer.typeForClass(sagaType).getName(); }
private String getSagaTypeName(Class<?> sagaType) { return serializer.typeForClass(sagaType).getName(); }
private String getSagaTypeName(Class<?> sagaType) { return serializer.typeForClass(sagaType).getName(); }
/** * Constructs a new SagaEntry for the given {@code saga}. The given saga must be serializable. The provided * saga is not modified by this operation. * * @param identifier The identifier of the saga * @param saga The saga to store * @param associationValues The associations of the saga * @param serializer The serialization mechanism to convert the Saga to a byte stream */ public SagaEntry(String identifier, T saga, Set<AssociationValue> associationValues, Serializer serializer) { this.sagaId = identifier; SerializedObject<byte[]> serialized = serializer.serialize(saga, byte[].class); this.serializedSaga = serialized.getData(); this.sagaType = serializer.typeForClass(saga.getClass()).getName(); this.saga = saga; this.associationValues = new HashSet<>(associationValues); }
/** * Constructs a new SagaEntry for the given {@code saga}. The given saga must be serializable. The provided * saga is not modified by this operation. * * @param identifier The identifier of the saga * @param saga The saga to store * @param associationValues The associations of the saga * @param serializer The serialization mechanism to convert the Saga to a byte stream */ public SagaEntry(String identifier, T saga, Set<AssociationValue> associationValues, Serializer serializer) { this.sagaId = identifier; SerializedObject<byte[]> serialized = serializer.serialize(saga, byte[].class); this.serializedSaga = serialized.getData(); this.sagaType = serializer.typeForClass(saga.getClass()).getName(); this.saga = saga; this.associationValues = new HashSet<>(associationValues); }
@SuppressWarnings("unchecked") public <T> SerializedObject<T> serializePayload(Serializer serializer, Class<T> expectedRepresentation) { synchronized (payloadGuard) { SerializedObject existingForm = serializedPayload.get(serializer); if (existingForm == null) { SerializedObject<T> serialized = serializer.serialize(message.getPayload(), expectedRepresentation); if (message.getPayload() == null) { // make sure the payload type is maintained serialized = new SimpleSerializedObject<>(serialized.getData(), serialized.getContentType(), serializer.typeForClass(message.getPayloadType())); } serializedPayload.put(serializer, serialized); return serialized; } else { return serializer.getConverter().convert(existingForm, expectedRepresentation); } } }
/** * Utility method that serializes the payload of the given {@code message} using given {@code serializer} * and {@code expectedRepresentation}. This method will verify if the {@code eventMessage} is {@link * SerializationAware}. * * @param message The message containing the payload to serialize * @param serializer The serializer to serialize the payload with * @param expectedRepresentation The data type to serialize to * @param <T> The data type to serialize to * @return a Serialized Object containing the serialized for of the message's payload */ public static <T> SerializedObject<T> serializePayload(Message<?> message, Serializer serializer, Class<T> expectedRepresentation) { if (message instanceof SerializationAware) { return ((SerializationAware) message).serializePayload(serializer, expectedRepresentation); } SerializedObject<T> serializedObject = serializer.serialize(message.getPayload(), expectedRepresentation); if (message.getPayload() == null) { // make sure the payload type is maintained return new SimpleSerializedObject<>(serializedObject.getData(), serializedObject.getContentType(), serializer.typeForClass(message.getPayloadType())); } return serializedObject; }