Skip to content

Instantly share code, notes, and snippets.

View fmbenhassine's full-sized avatar

Mahmoud Ben Hassine fmbenhassine

View GitHub Profile
@fmbenhassine
fmbenhassine / DemoApplication.java
Created October 17, 2022 21:18
SF overloaded setter selection
package com.example.demo;
import org.springframework.context.support.ClassPathXmlApplicationContext;
import org.springframework.retry.policy.SimpleRetryPolicy;
public class DemoApplication {
public static void main(String[] args) {
ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext("application-context.xml");
SimpleRetryPolicy bean = context.getBean(SimpleRetryPolicy.class);
import org.springframework.batch.core.ExitStatus;
import org.springframework.batch.core.Job;
import org.springframework.batch.core.JobParameters;
import org.springframework.batch.core.Step;
import org.springframework.batch.core.configuration.annotation.EnableBatchProcessing;
import org.springframework.batch.core.configuration.annotation.JobBuilderFactory;
import org.springframework.batch.core.configuration.annotation.StepBuilderFactory;
import org.springframework.batch.core.launch.JobLauncher;
import org.springframework.batch.repeat.RepeatStatus;
import org.springframework.beans.factory.annotation.Autowired;
@fmbenhassine
fmbenhassine / MultiResourcePartitionerSample.java
Created November 2, 2020 12:22
#SpringBatch MultiResourcePartitioner job sample
package org.springframework.batch.sample;
import org.springframework.batch.core.Job;
import org.springframework.batch.core.JobParameters;
import org.springframework.batch.core.JobParametersBuilder;
import org.springframework.batch.core.Step;
import org.springframework.batch.core.configuration.annotation.EnableBatchProcessing;
import org.springframework.batch.core.configuration.annotation.JobBuilderFactory;
import org.springframework.batch.core.configuration.annotation.StepBuilderFactory;
import org.springframework.batch.core.configuration.annotation.StepScope;
package org.springframework.batch.sample;
import javax.sql.DataSource;
import javax.xml.bind.annotation.XmlRootElement;
import org.springframework.batch.core.Job;
import org.springframework.batch.core.JobParameters;
import org.springframework.batch.core.configuration.annotation.EnableBatchProcessing;
import org.springframework.batch.core.configuration.annotation.JobBuilderFactory;
import org.springframework.batch.core.configuration.annotation.StepBuilderFactory;
@fmbenhassine
fmbenhassine / ArchiveRoomRawJson.java
Created June 24, 2020 10:12
#SpringBatch gitter room archiver
package com.example.demo;
import java.io.IOException;
import java.nio.charset.StandardCharsets;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.nio.file.StandardOpenOption;
import java.time.Duration;
import java.time.Instant;
@fmbenhassine
fmbenhassine / TestCustomApacheConverter.java
Created March 1, 2020 21:28
Custom Apache beanutils converter with EasyProps
import java.util.Date;
import org.apache.commons.beanutils.ConvertUtils;
import org.apache.commons.beanutils.converters.DateConverter;
import org.jeasy.props.annotations.SystemProperty;
import org.junit.Before;
import org.junit.Test;
import static org.assertj.core.api.Assertions.assertThat;
@fmbenhassine
fmbenhassine / SynchronizedItemStreamWriterTest.java
Created March 27, 2019 21:08
#SpringBatch SynchronizedItemStreamWriterTest PR#665 for BATCH-2762
package org.springframework.batch.item.support;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
@fmbenhassine
fmbenhassine / ConsumerItemWriter.java
Created January 29, 2019 22:12
#SpringBatch java.util.function components
package org.springframework.batch.item.function;
import java.util.List;
import java.util.function.Consumer;
import org.springframework.batch.item.ItemWriter;
import org.springframework.util.Assert;
public class ConsumerItemWriter<T> implements ItemWriter<T> {
/*
* Copyright 2018 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
/*
* Copyright 2018 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software