Bonjour

J'essaye en Spring Batch 4 d'implementer un custom serialisze comme ceci san succes.
J"ai besoin de gerer les deux modes de serialisation pendannt un certains temps.
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
 
 <?xml version = "1.0" encoding = "UTF-8" ?  >
     < beans xmlns = "http://www.springframework.org/schema/beans" xmlns : xsi = "http://www.w3.org/2001/XMLSchema-instance" xmlns : jdbc = "http://www.springframework.org/schema/jdbc" xmlns: batch = "http://www.springframework.org/schema/batch"
    xsi: schemaLocation = "http://www.springframework.org/schema/batch http://www.springframework.org/schema/batch/spring-batch.xsd
    http://www.springframework.org/schema/jdbc http://www.springframework.org/schema/jdbc/spring-jdbc.xsd
    http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd" >
 
     <!--initialize spring batch technical tables-- >
     <jdbc:initialize-database enabled = "true" ignore - failures = "ALL" >
		<jdbc:script location = "classpath:${batch.dataSource.metadata.schema.create}" />
     </jdbc:initialize-database>
 
     < batch: job - repository
    id = "jobRepository"
    isolation - level - for  - create = "READ_COMMITTED"
        serializer = "xsExecutionContext"
        transaction - manager = "transactionManager" /  >
 
    <bean id = "xsExecutionContext"
        class = "batch.launch.XStreamOrJackson2ExecutionContextSerializer" >
    </bean>
 
</beans>
 
        ___________________
 
package batch.launch;
 
import java.io.BufferedInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.util.Map;
import com.fasterxml.jackson.core.JsonProcessingException;
import org.springframework.batch.core.repository.ExecutionContextSerializer;
import org.springframework.batch.core.repository.dao.Jackson2ExecutionContextStringSerializer;
import org.springframework.batch.core.repository.dao.XStreamExecutionContextStringSerializer;
 
/**
 * Enables Spring Batch 4 to read both ExecutionContext entries written by ealier versions and the Spring 5 format. Entries are
 * written in Spring 5 format.
 */
 @ SuppressWarnings(“deprecation”)
class XStreamOrJackson2ExecutionContextSerializer implements ExecutionContextSerializer {
    private final XStreamExecutionContextStringSerializer xStream = new XStreamExecutionContextStringSerializer();
    private final Jackson2ExecutionContextStringSerializer jackson = new Jackson2ExecutionContextStringSerializer();
 
    public XStreamOrJackson2ExecutionContextSerializer()throws Exception {
        xStream.afterPropertiesSet();
    }
 
    // The caller closes the stream; and the decoration by ensureMarkSupported does not need any cleanup.
     @ SuppressWarnings(“resource”)
     @ Override
    public Map < String,
    Object > deserialize(InputStream inputStream)throws IOException {
        InputStream repeatableInputStream = ensureMarkSupported(inputStream);
        repeatableInputStream.mark(Integer.MAX_VALUE);
 
        try {
            return jackson.deserialize(repeatableInputStream);
        } catch (JsonProcessingException e) {
            repeatableInputStream.reset();
            return xStream.deserialize(repeatableInputStream);
        }
    }
 
    private static InputStream ensureMarkSupported(InputStream in) {
        return in.markSupported() ? in : new BufferedInputStream(in);
    }
 
     @ Override
    public void serialize(Map < String, Object > object, OutputStream outputStream)throws IOException {
        jackson.serialize(object, outputStream);
    }
}
Ou est mon erreur ?
Merci