proj_name
stringclasses
131 values
relative_path
stringlengths
30
228
class_name
stringlengths
1
68
func_name
stringlengths
1
48
masked_class
stringlengths
78
9.82k
func_body
stringlengths
46
9.61k
len_input
int64
29
2.01k
len_output
int64
14
1.94k
total
int64
55
2.05k
relevant_context
stringlengths
0
38.4k
spring-projects_spring-batch
spring-batch/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/file/transform/FormatterLineAggregator.java
FormatterLineAggregator
doAggregate
class FormatterLineAggregator<T> extends ExtractorLineAggregator<T> { private String format; private Locale locale = Locale.getDefault(); private int maximumLength = 0; private int minimumLength = 0; /** * Public setter for the minimum length of the formatted string. If this is not set * the default is to...
Assert.notNull(format, "A format is required"); String value = String.format(locale, format, fields); if (maximumLength > 0) { Assert.state(value.length() <= maximumLength, String .format("String overflowed in formatter -" + " longer than %d characters: [%s", maximumLength, value)); } if (minimumL...
350
165
515
<methods>public non-sealed void <init>() ,public java.lang.String aggregate(T) ,public void setFieldExtractor(FieldExtractor<T>) <variables>private FieldExtractor<T> fieldExtractor
spring-projects_spring-batch
spring-batch/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/file/transform/PassThroughFieldExtractor.java
PassThroughFieldExtractor
extract
class PassThroughFieldExtractor<T> implements FieldExtractor<T> { /** * Get an array of fields as close as possible to the input. The result depends on the * type of the input: * <ul> * <li>A {@link FieldSet} or array will be returned as is</li> * <li>For a Collection the <code>toArray()</code> method will ...
if (item.getClass().isArray()) { return (Object[]) item; } if (item instanceof Collection<?>) { return ((Collection<?>) item).toArray(); } if (item instanceof Map<?, ?>) { return ((Map<?, ?>) item).values().toArray(); } if (item instanceof FieldSet) { return ((FieldSet) item).getValues();...
299
130
429
<no_super_class>
spring-projects_spring-batch
spring-batch/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/file/transform/Range.java
Range
checkMinMaxValues
class Range { public final static int UPPER_BORDER_NOT_DEFINED = Integer.MAX_VALUE; final private int min; final private int max; public Range(int min) { this(min, UPPER_BORDER_NOT_DEFINED); } public Range(int min, int max) { checkMinMaxValues(min, max); this.min = min; this.max = max; } public in...
Assert.isTrue(min > 0, "Min value must be higher than zero"); Assert.isTrue(min <= max, "Min value should be lower or equal to max value");
243
48
291
<no_super_class>
spring-projects_spring-batch
spring-batch/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/file/transform/RangeArrayPropertyEditor.java
RangeArrayPropertyEditor
getAsText
class RangeArrayPropertyEditor extends PropertyEditorSupport { private boolean forceDisjointRanges = false; /** * Set force disjoint ranges. If set to TRUE, ranges are validated to be disjoint. For * example: defining ranges '1-10, 5-15' will cause IllegalArgumentException in case * of forceDisjointRanges=TRU...
Range[] ranges = (Range[]) getValue(); StringBuilder sb = new StringBuilder(); for (int i = 0; i < ranges.length; i++) { if (i > 0) { sb.append(", "); } sb.append(ranges[i]); } return sb.toString();
880
91
971
<methods>public void <init>() ,public void <init>(java.lang.Object) ,public synchronized void addPropertyChangeListener(java.beans.PropertyChangeListener) ,public void firePropertyChange() ,public java.lang.String getAsText() ,public java.awt.Component getCustomEditor() ,public java.lang.String getJavaInitializationStr...
spring-projects_spring-batch
spring-batch/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/file/transform/RecordFieldExtractor.java
RecordFieldExtractor
extract
class RecordFieldExtractor<T> implements FieldExtractor<T> { private List<String> names; private final Class<? extends T> targetType; private final RecordComponent[] recordComponents; public RecordFieldExtractor(Class<? extends T> targetType) { Assert.notNull(targetType, "target type must not be null"); Ass...
List<Object> values = new ArrayList<>(); for (String componentName : this.names) { RecordComponent recordComponent = getRecordComponentByName(componentName); Object value; try { value = recordComponent.getAccessor().invoke(item); values.add(value); } catch (IllegalAccessException | Invocatio...
479
139
618
<no_super_class>
spring-projects_spring-batch
spring-batch/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/file/transform/RecursiveCollectionLineAggregator.java
RecursiveCollectionLineAggregator
aggregate
class RecursiveCollectionLineAggregator<T> implements LineAggregator<Collection<T>> { private static final String LINE_SEPARATOR = System.getProperty("line.separator"); private LineAggregator<T> delegate = new PassThroughLineAggregator<>(); /** * Public setter for the {@link LineAggregator} to use on single ite...
StringBuilder builder = new StringBuilder(); for (T value : items) { builder.append(delegate.aggregate(value)).append(LINE_SEPARATOR); } return builder.delete(builder.length() - LINE_SEPARATOR.length(), builder.length()).toString();
200
77
277
<no_super_class>
spring-projects_spring-batch
spring-batch/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/file/transform/RegexLineTokenizer.java
RegexLineTokenizer
doTokenize
class RegexLineTokenizer extends AbstractLineTokenizer { private Pattern pattern; @Override protected List<String> doTokenize(String line) {<FILL_FUNCTION_BODY>} /** * Sets the regex pattern to use. * @param pattern Regular Expression pattern */ public void setPattern(Pattern pattern) { Assert.notNull(p...
Matcher matcher = pattern.matcher(line); boolean matchFound = matcher.find(); if (matchFound) { List<String> tokens = new ArrayList<>(matcher.groupCount()); for (int i = 1; i <= matcher.groupCount(); i++) { tokens.add(matcher.group(i)); } return tokens; } return Collections.emptyList();
192
114
306
<methods>public non-sealed void <init>() ,public boolean hasNames() ,public void setFieldSetFactory(org.springframework.batch.item.file.transform.FieldSetFactory) ,public transient void setNames(java.lang.String[]) ,public void setStrict(boolean) ,public org.springframework.batch.item.file.transform.FieldSet tokenize(j...
spring-projects_spring-batch
spring-batch/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/jms/JmsItemReader.java
JmsItemReader
read
class JmsItemReader<T> implements ItemReader<T>, InitializingBean { protected Log logger = LogFactory.getLog(getClass()); protected Class<? extends T> itemType; protected JmsOperations jmsTemplate; /** * Setter for JMS template. * @param jmsTemplate a {@link JmsOperations} instance */ public void setJmsT...
if (itemType != null && itemType.isAssignableFrom(Message.class)) { return (T) jmsTemplate.receive(); } Object result = jmsTemplate.receiveAndConvert(); if (itemType != null && result != null) { Assert.state(itemType.isAssignableFrom(result.getClass()), "Received message payload of wrong type: expec...
433
126
559
<no_super_class>
spring-projects_spring-batch
spring-batch/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/jms/JmsItemWriter.java
JmsItemWriter
setJmsTemplate
class JmsItemWriter<T> implements ItemWriter<T> { protected Log logger = LogFactory.getLog(getClass()); private JmsOperations jmsTemplate; /** * Setter for JMS template. * @param jmsTemplate a {@link JmsOperations} instance */ public void setJmsTemplate(JmsOperations jmsTemplate) {<FILL_FUNCTION_BODY>} /...
this.jmsTemplate = jmsTemplate; if (jmsTemplate instanceof JmsTemplate template) { Assert.isTrue(template.getDefaultDestination() != null || template.getDefaultDestinationName() != null, "JmsTemplate must have a defaultDestination or defaultDestinationName!"); }
247
82
329
<no_super_class>
spring-projects_spring-batch
spring-batch/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/jms/JmsMethodArgumentsKeyGenerator.java
JmsMethodArgumentsKeyGenerator
getKey
class JmsMethodArgumentsKeyGenerator implements MethodArgumentsKeyGenerator { /** * If the message is a {@link Message} then returns the JMS message ID. Otherwise just * return the first argument. * * @see org.springframework.retry.interceptor.MethodArgumentsKeyGenerator#getKey(Object[]) * @throws Unexpecte...
for (Object item : items) { if (item instanceof Message) { try { return ((Message) item).getJMSMessageID(); } catch (JMSException e) { throw new UnexpectedInputException("Could not extract message ID", e); } } } if (items.length == 0) { throw new IllegalArgumentException( ...
147
130
277
<no_super_class>
spring-projects_spring-batch
spring-batch/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/jms/JmsMethodInvocationRecoverer.java
JmsMethodInvocationRecoverer
recover
class JmsMethodInvocationRecoverer<T> implements MethodInvocationRecoverer<T> { protected Log logger = LogFactory.getLog(getClass()); private JmsOperations jmsTemplate; /** * Setter for jms template. * @param jmsTemplate a {@link JmsOperations} instance */ public void setJmsTemplate(JmsOperations jmsTempla...
try { for (Object item : items) { jmsTemplate.convertAndSend(item); } return null; } catch (JmsException e) { logger.error("Could not recover because of JmsException.", e); throw e; }
233
80
313
<no_super_class>
spring-projects_spring-batch
spring-batch/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/jms/JmsNewMethodArgumentsIdentifier.java
JmsNewMethodArgumentsIdentifier
isNew
class JmsNewMethodArgumentsIdentifier<T> implements NewMethodArgumentsIdentifier { /** * If any of the arguments is a message, check the JMS re-delivered flag and return * it, otherwise return false to be on the safe side. * * @see org.springframework.retry.interceptor.NewMethodArgumentsIdentifier#isNew(java....
for (Object item : args) { if (item instanceof Message) { try { return !((Message) item).getJMSRedelivered(); } catch (JMSException e) { throw new UnexpectedInputException("Could not extract message ID", e); } } } return false;
124
91
215
<no_super_class>
spring-projects_spring-batch
spring-batch/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/jms/builder/JmsItemReaderBuilder.java
JmsItemReaderBuilder
build
class JmsItemReaderBuilder<T> { protected Class<? extends T> itemType; protected JmsOperations jmsTemplate; /** * Establish the JMS template that will be used by the JmsItemReader. * @param jmsTemplate a {@link JmsOperations} instance * @return this instance for method chaining. * @see JmsItemReader#setJm...
Assert.notNull(this.jmsTemplate, "jmsTemplate is required."); JmsItemReader<T> jmsItemReader = new JmsItemReader<>(); jmsItemReader.setItemType(this.itemType); jmsItemReader.setJmsTemplate(this.jmsTemplate); return jmsItemReader;
367
91
458
<no_super_class>
spring-projects_spring-batch
spring-batch/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/jms/builder/JmsItemWriterBuilder.java
JmsItemWriterBuilder
build
class JmsItemWriterBuilder<T> { private JmsOperations jmsTemplate; /** * Establish the JMS template that will be used by the {@link JmsItemWriter}. * @param jmsTemplate a {@link JmsOperations} instance * @return this instance for method chaining. * @see JmsItemWriter#setJmsTemplate(JmsOperations) */ publ...
Assert.notNull(this.jmsTemplate, "jmsTemplate is required."); JmsItemWriter<T> jmsItemWriter = new JmsItemWriter<>(); jmsItemWriter.setJmsTemplate(this.jmsTemplate); return jmsItemWriter;
204
74
278
<no_super_class>
spring-projects_spring-batch
spring-batch/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/json/GsonJsonObjectReader.java
GsonJsonObjectReader
open
class GsonJsonObjectReader<T> implements JsonObjectReader<T> { private final Class<? extends T> itemType; private JsonReader jsonReader; private Gson mapper; private InputStream inputStream; /** * Create a new {@link GsonJsonObjectReader} instance. * @param itemType the target item type */ public GsonJ...
Assert.notNull(resource, "The resource must not be null"); this.inputStream = resource.getInputStream(); this.jsonReader = this.mapper.newJsonReader(new InputStreamReader(this.inputStream)); Assert.state(this.jsonReader.peek() == JsonToken.BEGIN_ARRAY, "The Json input stream must start with an array of Jso...
481
109
590
<no_super_class>
spring-projects_spring-batch
spring-batch/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/json/JacksonJsonObjectMarshaller.java
JacksonJsonObjectMarshaller
marshal
class JacksonJsonObjectMarshaller<T> implements JsonObjectMarshaller<T> { private ObjectMapper objectMapper; public JacksonJsonObjectMarshaller() { this(new ObjectMapper()); } public JacksonJsonObjectMarshaller(ObjectMapper objectMapper) { this.objectMapper = objectMapper; } /** * Set the {@link ObjectM...
try { return objectMapper.writeValueAsString(item); } catch (JsonProcessingException e) { throw new ItemStreamException("Unable to marshal object " + item + " to Json", e); }
177
64
241
<no_super_class>
spring-projects_spring-batch
spring-batch/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/json/JacksonJsonObjectReader.java
JacksonJsonObjectReader
open
class JacksonJsonObjectReader<T> implements JsonObjectReader<T> { private final Class<? extends T> itemType; private JsonParser jsonParser; private ObjectMapper mapper; private InputStream inputStream; /** * Create a new {@link JacksonJsonObjectReader} instance. * @param itemType the target item type */...
Assert.notNull(resource, "The resource must not be null"); this.inputStream = resource.getInputStream(); this.jsonParser = this.mapper.getFactory().createParser(this.inputStream); Assert.state(this.jsonParser.nextToken() == JsonToken.START_ARRAY, "The Json input stream must start with an array of Json obje...
504
96
600
<no_super_class>
spring-projects_spring-batch
spring-batch/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/json/JsonFileItemWriter.java
JsonFileItemWriter
doWrite
class JsonFileItemWriter<T> extends AbstractFileItemWriter<T> { private static final char JSON_OBJECT_SEPARATOR = ','; private static final char JSON_ARRAY_START = '['; private static final char JSON_ARRAY_STOP = ']'; private JsonObjectMarshaller<T> jsonObjectMarshaller; /** * Create a new {@link JsonFileIt...
StringBuilder lines = new StringBuilder(); Iterator<? extends T> iterator = items.iterator(); if (!items.isEmpty() && state.getLinesWritten() > 0) { lines.append(JSON_OBJECT_SEPARATOR).append(this.lineSeparator); } while (iterator.hasNext()) { T item = iterator.next(); lines.append(' ').append(this....
516
170
686
<methods>public non-sealed void <init>() ,public void close() ,public void open(org.springframework.batch.item.ExecutionContext) throws org.springframework.batch.item.ItemStreamException,public void setAppendAllowed(boolean) ,public void setEncoding(java.lang.String) ,public void setFooterCallback(org.springframework.b...
spring-projects_spring-batch
spring-batch/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/json/JsonItemReader.java
JsonItemReader
doOpen
class JsonItemReader<T> extends AbstractItemCountingItemStreamItemReader<T> implements ResourceAwareItemReaderItemStream<T> { private static final Log LOGGER = LogFactory.getLog(JsonItemReader.class); private Resource resource; private JsonObjectReader<T> jsonObjectReader; private boolean strict = true; /**...
Assert.notNull(this.resource, "The resource must not be null."); Assert.notNull(this.jsonObjectReader, "The json object reader must not be null."); if (!this.resource.exists()) { if (this.strict) { throw new IllegalStateException("Input resource must exist (reader is in 'strict' mode)"); } LOGGER.wa...
583
216
799
<methods>public non-sealed void <init>() ,public void close() throws org.springframework.batch.item.ItemStreamException,public int getCurrentItemCount() ,public boolean isSaveState() ,public void open(org.springframework.batch.item.ExecutionContext) throws org.springframework.batch.item.ItemStreamException,public T rea...
spring-projects_spring-batch
spring-batch/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/json/builder/JsonFileItemWriterBuilder.java
JsonFileItemWriterBuilder
build
class JsonFileItemWriterBuilder<T> { private WritableResource resource; private JsonObjectMarshaller<T> jsonObjectMarshaller; private FlatFileHeaderCallback headerCallback; private FlatFileFooterCallback footerCallback; private String name; private String encoding = JsonFileItemWriter.DEFAULT_CHARSET; pri...
Assert.notNull(this.resource, "A resource is required."); Assert.notNull(this.jsonObjectMarshaller, "A json object marshaller is required."); if (this.saveState) { Assert.hasText(this.name, "A name is required when saveState is true"); } JsonFileItemWriter<T> jsonFileItemWriter = new JsonFileItemWriter<...
1,670
355
2,025
<no_super_class>
spring-projects_spring-batch
spring-batch/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/json/builder/JsonItemReaderBuilder.java
JsonItemReaderBuilder
build
class JsonItemReaderBuilder<T> { protected Log logger = LogFactory.getLog(getClass()); private JsonObjectReader<T> jsonObjectReader; private Resource resource; private String name; private boolean strict = true; private boolean saveState = true; private int maxItemCount = Integer.MAX_VALUE; private int ...
Assert.notNull(this.jsonObjectReader, "A json object reader is required."); if (this.saveState) { Assert.state(StringUtils.hasText(this.name), "A name is required when saveState is set to true."); } if (this.resource == null) { logger.debug("The resource is null. This is only a valid scenario when " ...
950
245
1,195
<no_super_class>
spring-projects_spring-batch
spring-batch/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/kafka/KafkaItemReader.java
KafkaItemReader
open
class KafkaItemReader<K, V> extends AbstractItemStreamItemReader<V> { private static final String TOPIC_PARTITION_OFFSETS = "topic.partition.offsets"; private static final long DEFAULT_POLL_TIMEOUT = 30L; private final List<TopicPartition> topicPartitions; private Map<TopicPartition, Long> partitionOffsets; p...
this.kafkaConsumer = new KafkaConsumer<>(this.consumerProperties); if (this.partitionOffsets == null) { this.partitionOffsets = new HashMap<>(); for (TopicPartition topicPartition : this.topicPartitions) { this.partitionOffsets.put(topicPartition, 0L); } } if (this.saveState && executionContext.co...
1,603
257
1,860
<methods>public non-sealed void <init>() <variables>
spring-projects_spring-batch
spring-batch/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/kafka/KafkaItemWriter.java
KafkaItemWriter
writeKeyValue
class KafkaItemWriter<K, T> extends KeyValueItemWriter<K, T> { protected KafkaTemplate<K, T> kafkaTemplate; protected final List<CompletableFuture<SendResult<K, T>>> completableFutures = new ArrayList<>(); private long timeout = -1; @Override protected void writeKeyValue(K key, T value) {<FILL_FUNCTION_BODY>} ...
if (this.delete) { this.completableFutures.add(this.kafkaTemplate.sendDefault(key, null)); } else { this.completableFutures.add(this.kafkaTemplate.sendDefault(key, value)); }
435
72
507
<methods>public non-sealed void <init>() ,public void afterPropertiesSet() throws java.lang.Exception,public void setDelete(boolean) ,public void setItemKeyMapper(Converter<T,K>) ,public void write(Chunk<? extends T>) throws java.lang.Exception<variables>protected boolean delete,protected Converter<T,K> itemKeyMapper
spring-projects_spring-batch
spring-batch/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/kafka/builder/KafkaItemReaderBuilder.java
KafkaItemReaderBuilder
build
class KafkaItemReaderBuilder<K, V> { private Properties consumerProperties; private String topic; private List<Integer> partitions = new ArrayList<>(); private Map<TopicPartition, Long> partitionOffsets; private Duration pollTimeout = Duration.ofSeconds(30L); private boolean saveState = true; private Stri...
if (this.saveState) { Assert.hasText(this.name, "A name is required when saveState is set to true"); } Assert.notNull(consumerProperties, "Consumer properties must not be null"); Assert.isTrue(consumerProperties.containsKey(ConsumerConfig.BOOTSTRAP_SERVERS_CONFIG), ConsumerConfig.BOOTSTRAP_SERVERS_CONFI...
1,070
476
1,546
<no_super_class>
spring-projects_spring-batch
spring-batch/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/kafka/builder/KafkaItemWriterBuilder.java
KafkaItemWriterBuilder
build
class KafkaItemWriterBuilder<K, V> { private KafkaTemplate<K, V> kafkaTemplate; private Converter<V, K> itemKeyMapper; private boolean delete; private long timeout = -1; /** * Establish the KafkaTemplate to be used by the KafkaItemWriter. * @param kafkaTemplate the template to be used * @return this ins...
Assert.notNull(this.kafkaTemplate, "kafkaTemplate is required."); Assert.notNull(this.itemKeyMapper, "itemKeyMapper is required."); KafkaItemWriter<K, V> writer = new KafkaItemWriter<>(); writer.setKafkaTemplate(this.kafkaTemplate); writer.setItemKeyMapper(this.itemKeyMapper); writer.setDelete(this.delete...
666
134
800
<no_super_class>
spring-projects_spring-batch
spring-batch/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/ldif/LdifReader.java
LdifReader
afterPropertiesSet
class LdifReader extends AbstractItemCountingItemStreamItemReader<LdapAttributes> implements ResourceAwareItemReaderItemStream<LdapAttributes>, InitializingBean { private static final Logger LOG = LoggerFactory.getLogger(LdifReader.class); private Resource resource; private LdifParser ldifParser; private int ...
Assert.state(resource != null, "A resource is required to parse."); Assert.state(ldifParser != null, "A parser is required");
971
43
1,014
<methods>public non-sealed void <init>() ,public void close() throws org.springframework.batch.item.ItemStreamException,public int getCurrentItemCount() ,public boolean isSaveState() ,public void open(org.springframework.batch.item.ExecutionContext) throws org.springframework.batch.item.ItemStreamException,public org.s...
spring-projects_spring-batch
spring-batch/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/ldif/MappingLdifReader.java
MappingLdifReader
doOpen
class MappingLdifReader<T> extends AbstractItemCountingItemStreamItemReader<T> implements ResourceAwareItemReaderItemStream<T>, InitializingBean { private static final Logger LOG = LoggerFactory.getLogger(MappingLdifReader.class); private Resource resource; private LdifParser ldifParser; private int recordCou...
if (resource == null) throw new IllegalStateException("A resource has not been set."); if (!resource.exists()) { if (strict) { throw new IllegalStateException("Input resource must exist (reader is in 'strict' mode): " + resource); } else { LOG.warn("Input resource does not exist " + resource.g...
872
187
1,059
<methods>public non-sealed void <init>() ,public void close() throws org.springframework.batch.item.ItemStreamException,public int getCurrentItemCount() ,public boolean isSaveState() ,public void open(org.springframework.batch.item.ExecutionContext) throws org.springframework.batch.item.ItemStreamException,public T rea...
spring-projects_spring-batch
spring-batch/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/ldif/builder/LdifReaderBuilder.java
LdifReaderBuilder
build
class LdifReaderBuilder { private Resource resource; private int recordsToSkip = 0; private boolean strict = true; private RecordCallbackHandler skippedRecordsCallback; private boolean saveState = true; private String name; private int maxItemCount = Integer.MAX_VALUE; private int currentItemCount; /*...
Assert.notNull(this.resource, "Resource is required."); if (this.saveState) { Assert.hasText(this.name, "A name is required when saveState is set to true"); } LdifReader reader = new LdifReader(); reader.setResource(this.resource); reader.setRecordsToSkip(this.recordsToSkip); reader.setSaveState(this....
1,126
219
1,345
<no_super_class>
spring-projects_spring-batch
spring-batch/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/ldif/builder/MappingLdifReaderBuilder.java
MappingLdifReaderBuilder
build
class MappingLdifReaderBuilder<T> { private Resource resource; private int recordsToSkip = 0; private boolean strict = true; private RecordCallbackHandler skippedRecordsCallback; private RecordMapper<T> recordMapper; private boolean saveState = true; private String name; private int maxItemCount = Integ...
Assert.notNull(this.resource, "Resource is required."); Assert.notNull(this.recordMapper, "RecordMapper is required."); if (this.saveState) { Assert.hasText(this.name, "A name is required when saveState is set to true"); } MappingLdifReader<T> reader = new MappingLdifReader<>(); reader.setResource(this....
1,292
257
1,549
<no_super_class>
spring-projects_spring-batch
spring-batch/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/mail/DefaultMailErrorHandler.java
DefaultMailErrorHandler
handle
class DefaultMailErrorHandler implements MailErrorHandler { private static final int DEFAULT_MAX_MESSAGE_LENGTH = 1024; private int maxMessageLength = DEFAULT_MAX_MESSAGE_LENGTH; /** * The limit for the size of message that will be copied to the exception message. * Output will be truncated beyond that. Defau...
String msg = message.toString(); throw new MailSendException( "Mail server send failed: " + msg.substring(0, Math.min(maxMessageLength, msg.length())), exception);
257
53
310
<no_super_class>
spring-projects_spring-batch
spring-batch/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/mail/SimpleMailMessageItemWriter.java
SimpleMailMessageItemWriter
write
class SimpleMailMessageItemWriter implements ItemWriter<SimpleMailMessage>, InitializingBean { private MailSender mailSender; private MailErrorHandler mailErrorHandler = new DefaultMailErrorHandler(); /** * A {@link MailSender} to be used to send messages in {@link #write(Chunk)}. * @param mailSender The {@li...
try { mailSender.send(chunk.getItems().toArray(new SimpleMailMessage[chunk.size()])); } catch (MailSendException e) { Map<Object, Exception> failedMessages = e.getFailedMessages(); for (Entry<Object, Exception> entry : failedMessages.entrySet()) { mailErrorHandler.handle((SimpleMailMessage) entry.ge...
353
117
470
<no_super_class>
spring-projects_spring-batch
spring-batch/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/mail/builder/SimpleMailMessageItemWriterBuilder.java
SimpleMailMessageItemWriterBuilder
build
class SimpleMailMessageItemWriterBuilder { private MailSender mailSender; private MailErrorHandler mailErrorHandler = new DefaultMailErrorHandler(); /** * A {@link MailSender} to be used to send messages in * {@link SimpleMailMessageItemWriter#write(Chunk)}. * @param mailSender strategy for sending simple m...
Assert.notNull(this.mailSender, "A mailSender is required"); SimpleMailMessageItemWriter writer = new SimpleMailMessageItemWriter(); writer.setMailSender(this.mailSender); if (mailErrorHandler != null) { writer.setMailErrorHandler(this.mailErrorHandler); } return writer;
333
96
429
<no_super_class>
spring-projects_spring-batch
spring-batch/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/mail/javamail/MimeMessageItemWriter.java
MimeMessageItemWriter
write
class MimeMessageItemWriter implements ItemWriter<MimeMessage> { private JavaMailSender mailSender; private MailErrorHandler mailErrorHandler = new DefaultMailErrorHandler(); /** * A {@link JavaMailSender} to be used to send messages in {@link #write(Chunk)}. * @param mailSender service for doing the work of ...
try { mailSender.send(chunk.getItems().toArray(new MimeMessage[chunk.size()])); } catch (MailSendException e) { Map<Object, Exception> failedMessages = e.getFailedMessages(); for (Entry<Object, Exception> entry : failedMessages.entrySet()) { mailErrorHandler.handle(new MimeMailMessage((MimeMessage) ...
350
123
473
<no_super_class>
spring-projects_spring-batch
spring-batch/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/redis/RedisItemReader.java
RedisItemReader
read
class RedisItemReader<K, V> implements ItemStreamReader<V> { private final RedisTemplate<K, V> redisTemplate; private final ScanOptions scanOptions; private Cursor<K> cursor; public RedisItemReader(RedisTemplate<K, V> redisTemplate, ScanOptions scanOptions) { Assert.notNull(redisTemplate, "redisTemplate must ...
if (this.cursor.hasNext()) { K nextKey = this.cursor.next(); return this.redisTemplate.opsForValue().get(nextKey); } else { return null; }
235
61
296
<no_super_class>
spring-projects_spring-batch
spring-batch/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/redis/RedisItemWriter.java
RedisItemWriter
writeKeyValue
class RedisItemWriter<K, T> extends KeyValueItemWriter<K, T> { private RedisTemplate<K, T> redisTemplate; @Override protected void writeKeyValue(K key, T value) {<FILL_FUNCTION_BODY>} @Override protected void init() { Assert.notNull(this.redisTemplate, "RedisTemplate must not be null"); } /** * Set the {...
if (this.delete) { this.redisTemplate.delete(key); } else { this.redisTemplate.opsForValue().set(key, value); }
174
52
226
<methods>public non-sealed void <init>() ,public void afterPropertiesSet() throws java.lang.Exception,public void setDelete(boolean) ,public void setItemKeyMapper(Converter<T,K>) ,public void write(Chunk<? extends T>) throws java.lang.Exception<variables>protected boolean delete,protected Converter<T,K> itemKeyMapper
spring-projects_spring-batch
spring-batch/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/redis/builder/RedisItemWriterBuilder.java
RedisItemWriterBuilder
build
class RedisItemWriterBuilder<K, V> { private RedisTemplate<K, V> redisTemplate; private Converter<V, K> itemKeyMapper; private boolean delete; /** * Set the {@link RedisTemplate} to use to write items to Redis. * @param redisTemplate the template to use. * @return The current instance of the builder. * ...
Assert.notNull(this.redisTemplate, "RedisTemplate is required."); Assert.notNull(this.itemKeyMapper, "itemKeyMapper is required."); RedisItemWriter<K, V> writer = new RedisItemWriter<>(); writer.setRedisTemplate(this.redisTemplate); writer.setItemKeyMapper(this.itemKeyMapper); writer.setDelete(this.delete...
436
116
552
<no_super_class>
spring-projects_spring-batch
spring-batch/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/support/AbstractItemCountingItemStreamItemReader.java
AbstractItemCountingItemStreamItemReader
open
class AbstractItemCountingItemStreamItemReader<T> extends AbstractItemStreamItemReader<T> { private static final String READ_COUNT = "read.count"; private static final String READ_COUNT_MAX = "read.count.max"; private int currentItemCount = 0; private int maxItemCount = Integer.MAX_VALUE; private boolean save...
super.open(executionContext); try { doOpen(); } catch (Exception e) { throw new ItemStreamException("Failed to initialize the reader", e); } if (!isSaveState()) { return; } if (executionContext.containsKey(getExecutionContextKey(READ_COUNT_MAX))) { maxItemCount = executionContext.getInt(ge...
1,257
284
1,541
<methods>public non-sealed void <init>() <variables>
spring-projects_spring-batch
spring-batch/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/support/ClassifierCompositeItemWriter.java
ClassifierCompositeItemWriter
write
class ClassifierCompositeItemWriter<T> implements ItemWriter<T> { private Classifier<T, ItemWriter<? super T>> classifier = new ClassifierSupport<>(null); /** * @param classifier the classifier to set */ public void setClassifier(Classifier<T, ItemWriter<? super T>> classifier) { Assert.notNull(classifier, "...
Map<ItemWriter<? super T>, Chunk<T>> map = new LinkedHashMap<>(); for (T item : items) { ItemWriter<? super T> key = classifier.classify(item); if (!map.containsKey(key)) { map.put(key, new Chunk<>()); } map.get(key).add(item); } for (ItemWriter<? super T> writer : map.keySet()) { writer....
185
143
328
<no_super_class>
spring-projects_spring-batch
spring-batch/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/support/CompositeItemProcessor.java
CompositeItemProcessor
afterPropertiesSet
class CompositeItemProcessor<I, O> implements ItemProcessor<I, O>, InitializingBean { private List<? extends ItemProcessor<?, ?>> delegates; /** * Default constructor */ public CompositeItemProcessor() { } /** * Convenience constructor for setting the delegates. * @param delegates array of {@link ItemP...
Assert.state(delegates != null, "The 'delegates' may not be null"); Assert.state(!delegates.isEmpty(), "The 'delegates' may not be empty");
589
54
643
<no_super_class>
spring-projects_spring-batch
spring-batch/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/support/CompositeItemStream.java
CompositeItemStream
register
class CompositeItemStream implements ItemStream { private final List<ItemStream> streams = new ArrayList<>(); /** * Public setter for the {@link ItemStream}s. * @param streams {@link List} of {@link ItemStream}. */ public void setStreams(List<ItemStream> streams) { this.streams.addAll(streams); } /** ...
synchronized (streams) { if (!streams.contains(stream)) { streams.add(stream); } }
718
41
759
<no_super_class>
spring-projects_spring-batch
spring-batch/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/support/CompositeItemWriter.java
CompositeItemWriter
open
class CompositeItemWriter<T> implements ItemStreamWriter<T>, InitializingBean { private List<ItemWriter<? super T>> delegates; private boolean ignoreItemStream = false; /** * Default constructor */ public CompositeItemWriter() { } /** * Convenience constructor for setting the delegates. * @param dele...
for (ItemWriter<? super T> writer : delegates) { if (!ignoreItemStream && (writer instanceof ItemStream)) { ((ItemStream) writer).open(executionContext); } }
738
55
793
<no_super_class>
spring-projects_spring-batch
spring-batch/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/support/IteratorItemReader.java
IteratorItemReader
read
class IteratorItemReader<T> implements ItemReader<T> { /** * Internal iterator */ private final Iterator<T> iterator; /** * Construct a new reader from this iterable (could be a collection), by extracting an * instance of {@link Iterator} from it. * @param iterable in instance of {@link Iterable} * *...
if (iterator.hasNext()) return iterator.next(); else return null; // end of data
294
32
326
<no_super_class>
spring-projects_spring-batch
spring-batch/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/support/ScriptItemProcessor.java
ScriptItemProcessor
process
class ScriptItemProcessor<I, O> implements ItemProcessor<I, O>, InitializingBean { public static final String ITEM_BINDING_VARIABLE_NAME = "item"; private String language; private ScriptSource script; private ScriptSource scriptSource; private ScriptEvaluator scriptEvaluator; private String itemBindingVaria...
Map<String, Object> arguments = new HashMap<>(); arguments.put(itemBindingVariableName, item); return (O) scriptEvaluator.evaluate(getScriptSource(), arguments);
983
54
1,037
<no_super_class>
spring-projects_spring-batch
spring-batch/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/support/SingleItemPeekableItemReader.java
SingleItemPeekableItemReader
update
class SingleItemPeekableItemReader<T> implements ItemStreamReader<T>, PeekableItemReader<T> { private ItemReader<T> delegate; private T next; private ExecutionContext executionContext = new ExecutionContext(); /** * The item reader to use as a delegate. Items are read from the delegate and passed * to the c...
if (next != null) { // Get the last state from the delegate instead of using // current value. for (Entry<String, Object> entry : this.executionContext.entrySet()) { executionContext.put(entry.getKey(), entry.getValue()); } return; } updateDelegate(executionContext);
780
89
869
<no_super_class>
spring-projects_spring-batch
spring-batch/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/support/SynchronizedItemReader.java
SynchronizedItemReader
read
class SynchronizedItemReader<T> implements ItemReader<T> { private final ItemReader<T> delegate; private final Lock lock = new ReentrantLock(); public SynchronizedItemReader(ItemReader<T> delegate) { Assert.notNull(delegate, "The delegate must not be null"); this.delegate = delegate; } /** * This method ...
this.lock.lock(); try { return this.delegate.read(); } finally { this.lock.unlock(); }
153
47
200
<no_super_class>
spring-projects_spring-batch
spring-batch/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/support/SynchronizedItemStreamReader.java
SynchronizedItemStreamReader
afterPropertiesSet
class SynchronizedItemStreamReader<T> implements ItemStreamReader<T>, InitializingBean { private ItemStreamReader<T> delegate; private final Lock lock = new ReentrantLock(); public void setDelegate(ItemStreamReader<T> delegate) { this.delegate = delegate; } /** * This delegates to the read method of the <c...
Assert.state(this.delegate != null, "A delegate item reader is required");
274
27
301
<no_super_class>
spring-projects_spring-batch
spring-batch/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/support/SynchronizedItemStreamWriter.java
SynchronizedItemStreamWriter
afterPropertiesSet
class SynchronizedItemStreamWriter<T> implements ItemStreamWriter<T>, InitializingBean { private ItemStreamWriter<T> delegate; private final Lock lock = new ReentrantLock(); /** * Set the delegate {@link ItemStreamWriter}. * @param delegate the delegate to set */ public void setDelegate(ItemStreamWriter<T>...
Assert.state(this.delegate != null, "A delegate item writer is required");
318
27
345
<no_super_class>
spring-projects_spring-batch
spring-batch/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/support/SynchronizedItemWriter.java
SynchronizedItemWriter
write
class SynchronizedItemWriter<T> implements ItemWriter<T> { private final ItemWriter<T> delegate; private final Lock lock = new ReentrantLock(); public SynchronizedItemWriter(ItemWriter<T> delegate) { Assert.notNull(delegate, "The delegate must not be null"); this.delegate = delegate; } /** * This method ...
this.lock.lock(); try { this.delegate.write(items); } finally { this.lock.unlock(); }
159
48
207
<no_super_class>
spring-projects_spring-batch
spring-batch/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/support/builder/ClassifierCompositeItemProcessorBuilder.java
ClassifierCompositeItemProcessorBuilder
build
class ClassifierCompositeItemProcessorBuilder<I, O> { private Classifier<? super I, ItemProcessor<?, ? extends O>> classifier; /** * Establishes the classifier that will determine which {@link ItemProcessor} to use. * @param classifier the classifier to set * @return this instance for method chaining * @see...
Assert.notNull(classifier, "A classifier is required."); ClassifierCompositeItemProcessor<I, O> processor = new ClassifierCompositeItemProcessor<>(); processor.setClassifier(this.classifier); return processor;
231
66
297
<no_super_class>
spring-projects_spring-batch
spring-batch/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/support/builder/ClassifierCompositeItemWriterBuilder.java
ClassifierCompositeItemWriterBuilder
build
class ClassifierCompositeItemWriterBuilder<T> { private Classifier<T, ItemWriter<? super T>> classifier; /** * Establish the classifier to be used for the selection of which {@link ItemWriter} * to use. * @param classifier the classifier to set * @return this instance for method chaining * @see org.spring...
Assert.notNull(classifier, "A classifier is required."); ClassifierCompositeItemWriter<T> writer = new ClassifierCompositeItemWriter<>(); writer.setClassifier(this.classifier); return writer;
233
64
297
<no_super_class>
spring-projects_spring-batch
spring-batch/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/support/builder/CompositeItemProcessorBuilder.java
CompositeItemProcessorBuilder
build
class CompositeItemProcessorBuilder<I, O> { private List<? extends ItemProcessor<?, ?>> delegates; /** * Establishes the {@link ItemProcessor} delegates that will work on the item to be * processed. * @param delegates list of {@link ItemProcessor} delegates that will work on the * item. * @return this ins...
Assert.notNull(delegates, "A list of delegates is required."); Assert.notEmpty(delegates, "The delegates list must have one or more delegates."); CompositeItemProcessor<I, O> processor = new CompositeItemProcessor<>(); processor.setDelegates(this.delegates); return processor;
356
92
448
<no_super_class>
spring-projects_spring-batch
spring-batch/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/support/builder/CompositeItemWriterBuilder.java
CompositeItemWriterBuilder
build
class CompositeItemWriterBuilder<T> { private List<ItemWriter<? super T>> delegates; private boolean ignoreItemStream = false; /** * Establishes the policy whether to call the open, close, or update methods for the * item writer delegates associated with the CompositeItemWriter. * @param ignoreItemStream if...
Assert.notNull(delegates, "A list of delegates is required."); Assert.notEmpty(delegates, "The delegates list must have one or more delegates."); CompositeItemWriter<T> writer = new CompositeItemWriter<>(); writer.setDelegates(this.delegates); writer.setIgnoreItemStream(this.ignoreItemStream); return writ...
554
106
660
<no_super_class>
spring-projects_spring-batch
spring-batch/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/support/builder/ScriptItemProcessorBuilder.java
ScriptItemProcessorBuilder
build
class ScriptItemProcessorBuilder<I, O> { private String language; private Resource scriptResource; private String scriptSource; private String itemBindingVariableName; /** * Sets the {@link org.springframework.core.io.Resource} location of the script to * use. The script language will be deduced from the ...
if (this.scriptResource == null && !StringUtils.hasText(this.scriptSource)) { throw new IllegalArgumentException("scriptResource or scriptSource is required."); } if (StringUtils.hasText(this.scriptSource)) { Assert.hasText(this.language, "language is required when using scriptSource."); } ScriptItem...
605
217
822
<no_super_class>
spring-projects_spring-batch
spring-batch/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/support/builder/SingleItemPeekableItemReaderBuilder.java
SingleItemPeekableItemReaderBuilder
build
class SingleItemPeekableItemReaderBuilder<T> { private ItemReader<T> delegate; /** * The item reader to use as a delegate. Items are read from the delegate and passed * to the caller in * {@link org.springframework.batch.item.support.SingleItemPeekableItemReader#read()}. * @param delegate the delegate to se...
Assert.notNull(this.delegate, "A delegate is required"); SingleItemPeekableItemReader<T> reader = new SingleItemPeekableItemReader<>(); reader.setDelegate(this.delegate); return reader;
236
68
304
<no_super_class>
spring-projects_spring-batch
spring-batch/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/support/builder/SynchronizedItemStreamReaderBuilder.java
SynchronizedItemStreamReaderBuilder
build
class SynchronizedItemStreamReaderBuilder<T> { private ItemStreamReader<T> delegate; /** * The item stream reader to use as a delegate. Items are read from the delegate and * passed to the caller in * {@link org.springframework.batch.item.support.SynchronizedItemStreamReader#read()}. * @param delegate the d...
Assert.notNull(this.delegate, "A delegate is required"); SynchronizedItemStreamReader<T> reader = new SynchronizedItemStreamReader<>(); reader.setDelegate(this.delegate); return reader;
233
66
299
<no_super_class>
spring-projects_spring-batch
spring-batch/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/support/builder/SynchronizedItemStreamWriterBuilder.java
SynchronizedItemStreamWriterBuilder
build
class SynchronizedItemStreamWriterBuilder<T> { private ItemStreamWriter<T> delegate; /** * Set the delegate {@link ItemStreamWriter}. * @param delegate the delegate to set * @return this instance for method chaining */ public SynchronizedItemStreamWriterBuilder<T> delegate(ItemStreamWriter<T> delegate) { ...
Assert.notNull(this.delegate, "A delegate item writer is required"); SynchronizedItemStreamWriter<T> writer = new SynchronizedItemStreamWriter<>(); writer.setDelegate(this.delegate); return writer;
171
68
239
<no_super_class>
spring-projects_spring-batch
spring-batch/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/util/FileUtils.java
FileUtils
setUpOutputFile
class FileUtils { // forbids instantiation private FileUtils() { } /** * Set up output file for batch processing. This method implements common logic for * handling output files when starting or restarting file I/O. When starting output * file processing, creates/overwrites new file. When restarting output ...
Assert.notNull(file, "An output file is required"); try { if (!restarted) { if (!append) { if (file.exists()) { if (!overwriteOutputFile) { throw new ItemStreamException("File already exists: [" + file.getAbsolutePath() + "]"); } if (!file.delete()) { throw new IOExcep...
408
388
796
<no_super_class>
spring-projects_spring-batch
spring-batch/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/validator/BeanValidatingItemProcessor.java
BeanValidatingItemProcessor
afterPropertiesSet
class BeanValidatingItemProcessor<T> extends ValidatingItemProcessor<T> { private final Validator validator; /** * Create a new instance of {@link BeanValidatingItemProcessor} with the default * configuration. */ public BeanValidatingItemProcessor() { try (LocalValidatorFactoryBean localValidatorFactoryBea...
SpringValidatorAdapter springValidatorAdapter = new SpringValidatorAdapter(this.validator); SpringValidator<T> springValidator = new SpringValidator<>(); springValidator.setValidator(springValidatorAdapter); springValidator.afterPropertiesSet(); setValidator(springValidator); super.afterPropertiesSet();
253
82
335
<methods>public void <init>() ,public void <init>(Validator<? super T>) ,public void afterPropertiesSet() throws java.lang.Exception,public T process(T) throws org.springframework.batch.item.validator.ValidationException,public void setFilter(boolean) ,public void setValidator(Validator<? super T>) <variables>private b...
spring-projects_spring-batch
spring-batch/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/validator/SpringValidator.java
SpringValidator
appendCollection
class SpringValidator<T> implements Validator<T>, InitializingBean { private org.springframework.validation.Validator validator; /** * @see Validator#validate(Object) */ @Override public void validate(T item) throws ValidationException { if (!validator.supports(item.getClass())) { throw new ValidationEx...
for (Object value : collection) { builder.append("\n"); builder.append(value.toString()); }
423
36
459
<no_super_class>
spring-projects_spring-batch
spring-batch/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/validator/ValidatingItemProcessor.java
ValidatingItemProcessor
process
class ValidatingItemProcessor<T> implements ItemProcessor<T, T>, InitializingBean { private Validator<? super T> validator; private boolean filter = false; /** * Default constructor */ public ValidatingItemProcessor() { } /** * Creates a ValidatingItemProcessor based on the given Validator. * @param v...
try { validator.validate(item); } catch (ValidationException e) { if (filter) { return null; // filter the item } else { throw e; // skip the item } } return item;
395
75
470
<no_super_class>
spring-projects_spring-batch
spring-batch/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/xml/builder/StaxEventItemReaderBuilder.java
StaxEventItemReaderBuilder
build
class StaxEventItemReaderBuilder<T> { protected Log logger = LogFactory.getLog(getClass()); private boolean strict = true; private Resource resource; private Unmarshaller unmarshaller; private final List<String> fragmentRootElements = new ArrayList<>(); private boolean saveState = true; private String nam...
StaxEventItemReader<T> reader = new StaxEventItemReader<>(); if (this.resource == null) { logger.debug("The resource is null. This is only a valid scenario when " + "injecting resource later as in when using the MultiResourceItemReader"); } if (this.saveState) { Assert.state(StringUtils.hasText(th...
1,547
319
1,866
<no_super_class>
spring-projects_spring-batch
spring-batch/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/xml/stax/DefaultFragmentEventReader.java
DefaultFragmentEventReader
alterEvent
class DefaultFragmentEventReader extends AbstractEventReaderWrapper implements FragmentEventReader { // true when the next event is the StartElement of next fragment private boolean startFragmentFollows = false; // true when the next event is the EndElement of current fragment private boolean endFragmentFollows =...
if (startFragmentFollows) { fragmentRootName = ((StartElement) event).getName(); if (!peek) { startFragmentFollows = false; insideFragment = true; } return startDocumentEvent; } else if (endFragmentFollows) { if (!peek) { endFragmentFollows = false; insideFragment = false; fake...
1,132
133
1,265
<methods>public void <init>(javax.xml.stream.XMLEventReader) ,public void close() throws javax.xml.stream.XMLStreamException,public java.lang.String getElementText() throws javax.xml.stream.XMLStreamException,public java.lang.Object getProperty(java.lang.String) throws java.lang.IllegalArgumentException,public boolean ...
spring-projects_spring-batch
spring-batch/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/xml/stax/UnclosedElementCollectingEventWriter.java
UnclosedElementCollectingEventWriter
add
class UnclosedElementCollectingEventWriter extends AbstractEventWriterWrapper { private final LinkedList<QName> unclosedElements = new LinkedList<>(); public UnclosedElementCollectingEventWriter(XMLEventWriter wrappedEventWriter) { super(wrappedEventWriter); } @Override public void add(XMLEvent event) throws ...
if (event.isStartElement()) { unclosedElements.addLast(event.asStartElement().getName()); } else if (event.isEndElement()) { unclosedElements.removeLast(); } super.add(event);
125
69
194
<methods>public void <init>(javax.xml.stream.XMLEventWriter) ,public void add(javax.xml.stream.events.XMLEvent) throws javax.xml.stream.XMLStreamException,public void add(javax.xml.stream.XMLEventReader) throws javax.xml.stream.XMLStreamException,public void close() throws javax.xml.stream.XMLStreamException,public voi...
spring-projects_spring-batch
spring-batch/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/xml/stax/UnopenedElementClosingEventWriter.java
UnopenedElementClosingEventWriter
add
class UnopenedElementClosingEventWriter extends AbstractEventWriterWrapper { private final LinkedList<QName> unopenedElements; private final Writer ioWriter; public UnopenedElementClosingEventWriter(XMLEventWriter wrappedEventWriter, Writer ioWriter, List<QName> unopenedElements) { super(wrappedEventWriter);...
if (isUnopenedElementCloseEvent(event)) { QName element = unopenedElements.removeLast(); String nsPrefix = !StringUtils.hasText(element.getPrefix()) ? "" : element.getPrefix() + ":"; try { super.flush(); ioWriter.write("</" + nsPrefix + element.getLocalPart() + ">"); ioWriter.flush(); } ca...
245
164
409
<methods>public void <init>(javax.xml.stream.XMLEventWriter) ,public void add(javax.xml.stream.events.XMLEvent) throws javax.xml.stream.XMLStreamException,public void add(javax.xml.stream.XMLEventReader) throws javax.xml.stream.XMLStreamException,public void close() throws javax.xml.stream.XMLStreamException,public voi...
spring-projects_spring-batch
spring-batch/spring-batch-infrastructure/src/main/java/org/springframework/batch/poller/DirectPoller.java
DirectPollingFuture
get
class DirectPollingFuture<S> implements Future<S> { private final long startTime = System.currentTimeMillis(); private volatile boolean cancelled; private volatile S result = null; private final long interval; private final Callable<S> callable; public DirectPollingFuture(long interval, Callable<S> ca...
try { result = callable.call(); } catch (Exception e) { throw new ExecutionException(e); } long nextExecutionTime = startTime + interval; long currentTimeMillis = System.currentTimeMillis(); long timeoutMillis = TimeUnit.MILLISECONDS.convert(timeout, unit); while (result == null && !...
324
287
611
<no_super_class>
spring-projects_spring-batch
spring-batch/spring-batch-infrastructure/src/main/java/org/springframework/batch/repeat/context/RepeatContextSupport.java
RepeatContextSupport
close
class RepeatContextSupport extends SynchronizedAttributeAccessor implements RepeatContext { private final RepeatContext parent; private int count; private volatile boolean completeOnly; private volatile boolean terminateOnly; private final Map<String, Set<Runnable>> callbacks = new HashMap<>(); /** * Cons...
List<RuntimeException> errors = new ArrayList<>(); Set<Map.Entry<String, Set<Runnable>>> copy; synchronized (callbacks) { copy = new HashSet<>(callbacks.entrySet()); } for (Map.Entry<String, Set<Runnable>> entry : copy) { for (Runnable callback : entry.getValue()) { /* * Potentially we co...
449
289
738
<methods>public non-sealed void <init>() ,public java.lang.String[] attributeNames() ,public boolean equals(java.lang.Object) ,public java.lang.Object getAttribute(java.lang.String) ,public boolean hasAttribute(java.lang.String) ,public int hashCode() ,public java.lang.Object removeAttribute(java.lang.String) ,public v...
spring-projects_spring-batch
spring-batch/spring-batch-infrastructure/src/main/java/org/springframework/batch/repeat/context/SynchronizedAttributeAccessor.java
SynchronizedAttributeAccessor
toString
class SynchronizedAttributeAccessor implements AttributeAccessor { /** * All methods are delegated to this support object. */ AttributeAccessorSupport support = new AttributeAccessorSupport() { /** * Generated serial UID. */ private static final long serialVersionUID = -7664290016506582290L; }; @Ov...
StringBuilder buffer = new StringBuilder("SynchronizedAttributeAccessor: ["); synchronized (support) { String[] names = attributeNames(); for (int i = 0; i < names.length; i++) { String name = names[i]; buffer.append(names[i]).append("=").append(getAttribute(name)); if (i < names.length - 1) { ...
611
139
750
<no_super_class>
spring-projects_spring-batch
spring-batch/spring-batch-infrastructure/src/main/java/org/springframework/batch/repeat/exception/CompositeExceptionHandler.java
CompositeExceptionHandler
handleException
class CompositeExceptionHandler implements ExceptionHandler { private ExceptionHandler[] handlers = new ExceptionHandler[0]; public void setHandlers(ExceptionHandler[] handlers) { this.handlers = Arrays.asList(handlers).toArray(new ExceptionHandler[handlers.length]); } /** * Iterate over the handlers delegat...
for (ExceptionHandler handler : handlers) { handler.handleException(context, throwable); }
168
31
199
<no_super_class>
spring-projects_spring-batch
spring-batch/spring-batch-infrastructure/src/main/java/org/springframework/batch/repeat/exception/LogOrRethrowExceptionHandler.java
LogOrRethrowExceptionHandler
handleException
class LogOrRethrowExceptionHandler implements ExceptionHandler { /** * Logging levels for the handler. * * @author Dave Syer * */ public enum Level { /** * Key for {@link Classifier} signalling that the throwable should be rethrown. If * the throwable is not a RuntimeException it is wrapped in a ...
Level key = exceptionClassifier.classify(throwable); if (Level.ERROR.equals(key)) { logger.error("Exception encountered in batch repeat.", throwable); } else if (Level.WARN.equals(key)) { logger.warn("Exception encountered in batch repeat.", throwable); } else if (Level.DEBUG.equals(key) && logger.i...
508
153
661
<no_super_class>
spring-projects_spring-batch
spring-batch/spring-batch-infrastructure/src/main/java/org/springframework/batch/repeat/exception/RethrowOnThresholdExceptionHandler.java
RethrowOnThresholdExceptionHandler
getCounter
class RethrowOnThresholdExceptionHandler implements ExceptionHandler { protected static final IntegerHolder ZERO = new IntegerHolder(0); protected final Log logger = LogFactory.getLog(RethrowOnThresholdExceptionHandler.class); private Classifier<? super Throwable, IntegerHolder> exceptionClassifier = (Classifier<...
String attribute = RethrowOnThresholdExceptionHandler.class.getName() + "." + key; // Creates a new counter and stores it in the correct context: return new RepeatContextCounter(context, attribute, useParent);
794
59
853
<no_super_class>
spring-projects_spring-batch
spring-batch/spring-batch-infrastructure/src/main/java/org/springframework/batch/repeat/exception/SimpleLimitExceptionHandler.java
SimpleLimitExceptionHandler
afterPropertiesSet
class SimpleLimitExceptionHandler implements ExceptionHandler, InitializingBean { private final RethrowOnThresholdExceptionHandler delegate = new RethrowOnThresholdExceptionHandler(); private Collection<Class<? extends Throwable>> exceptionClasses = Collections .<Class<? extends Throwable>>singleton(Exception.cla...
if (limit <= 0) { return; } Map<Class<? extends Throwable>, Integer> thresholds = new HashMap<>(); for (Class<? extends Throwable> type : exceptionClasses) { thresholds.put(type, limit); } // do the fatalExceptionClasses last so they override the others for (Class<? extends Throwable> type : fatalE...
811
144
955
<no_super_class>
spring-projects_spring-batch
spring-batch/spring-batch-infrastructure/src/main/java/org/springframework/batch/repeat/interceptor/RepeatOperationsInterceptor.java
RepeatOperationsInterceptor
invoke
class RepeatOperationsInterceptor implements MethodInterceptor { private RepeatOperations repeatOperations = new RepeatTemplate(); /** * Setter for the {@link RepeatOperations}. * @param batchTemplate template to be used * @throws IllegalArgumentException if the argument is null. */ public void setRepeatOp...
final ResultHolder result = new ResultHolder(); // Cache void return value if intercepted method returns void final boolean voidReturnType = Void.TYPE.equals(invocation.getMethod().getReturnType()); if (voidReturnType) { // This will be ignored anyway, but we want it to be non-null for // convenience of...
628
525
1,153
<no_super_class>
spring-projects_spring-batch
spring-batch/spring-batch-infrastructure/src/main/java/org/springframework/batch/repeat/listener/CompositeRepeatListener.java
CompositeRepeatListener
after
class CompositeRepeatListener implements RepeatListener { private List<RepeatListener> listeners = new ArrayList<>(); /** * Default constructor */ public CompositeRepeatListener() { } /** * Convenience constructor for setting the {@link RepeatListener}s. * @param listeners {@link List} of RepeatListene...
for (RepeatListener listener : listeners) { listener.after(context, result); }
646
30
676
<no_super_class>
spring-projects_spring-batch
spring-batch/spring-batch-infrastructure/src/main/java/org/springframework/batch/repeat/policy/CompletionPolicySupport.java
CompletionPolicySupport
isComplete
class CompletionPolicySupport implements CompletionPolicy { /** * If exit status is not continuable return <code>true</code>, otherwise delegate to * {@link #isComplete(RepeatContext)}. * * @see org.springframework.batch.repeat.CompletionPolicy#isComplete(org.springframework.batch.repeat.RepeatContext, * Re...
if (result != null && !result.isContinuable()) { return true; } else { return isComplete(context); }
381
44
425
<no_super_class>
spring-projects_spring-batch
spring-batch/spring-batch-infrastructure/src/main/java/org/springframework/batch/repeat/policy/CompositeCompletionPolicy.java
CompositeCompletionPolicy
isComplete
class CompositeCompletionPolicy implements CompletionPolicy { CompletionPolicy[] policies = new CompletionPolicy[0]; /** * Setter for the policies. * @param policies an array of completion policies to be used to determine * {@link #isComplete(RepeatContext)} by consensus. */ public void setPolicies(Complet...
RepeatContext[] contexts = ((CompositeBatchContext) context).contexts; CompletionPolicy[] policies = ((CompositeBatchContext) context).policies; for (int i = 0; i < policies.length; i++) { if (policies[i].isComplete(contexts[i], result)) { return true; } } return false;
869
100
969
<no_super_class>
spring-projects_spring-batch
spring-batch/spring-batch-infrastructure/src/main/java/org/springframework/batch/repeat/policy/CountingCompletionPolicy.java
CountingCompletionPolicy
isComplete
class CountingCompletionPolicy extends DefaultResultCompletionPolicy { /** * Session key for global counter. */ public static final String COUNT = CountingCompletionPolicy.class.getName() + ".COUNT"; private boolean useParent = false; private int maxCount = 0; /** * Flag to indicate whether the count is ...
int count = ((CountingBatchContext) context).getCounter().getCount(); return count >= maxCount;
684
30
714
<methods>public non-sealed void <init>() ,public boolean isComplete(org.springframework.batch.repeat.RepeatContext, org.springframework.batch.repeat.RepeatStatus) ,public boolean isComplete(org.springframework.batch.repeat.RepeatContext) <variables>
spring-projects_spring-batch
spring-batch/spring-batch-infrastructure/src/main/java/org/springframework/batch/repeat/support/RepeatSynchronizationManager.java
RepeatSynchronizationManager
setAncestorsCompleteOnly
class RepeatSynchronizationManager { private static final ThreadLocal<RepeatContext> contextHolder = new ThreadLocal<>(); private RepeatSynchronizationManager() { } /** * Getter for the current context. A context is shared by all items in the batch, so * this method is intended to return the same context obj...
RepeatContext context = getContext(); while (context != null) { context.setCompleteOnly(); context = context.getParent(); }
510
47
557
<no_super_class>
spring-projects_spring-batch
spring-batch/spring-batch-infrastructure/src/main/java/org/springframework/batch/repeat/support/ResultHolderResultQueue.java
ResultHolderResultQueue
take
class ResultHolderResultQueue implements ResultQueue<ResultHolder> { // Accumulation of result objects as they finish. private final BlockingQueue<ResultHolder> results; // Accumulation of dummy objects flagging expected results in the future. private final Semaphore waits; private final Object lock = new Objec...
if (!isExpecting()) { throw new NoSuchElementException("Not expecting a result. Call expect() before take()."); } ResultHolder value; synchronized (lock) { value = results.take(); if (isContinuable(value)) { // Decrement the counter only when the result is collected. count--; return value...
1,023
171
1,194
<no_super_class>
spring-projects_spring-batch
spring-batch/spring-batch-infrastructure/src/main/java/org/springframework/batch/repeat/support/ThrottleLimitResultQueue.java
ThrottleLimitResultQueue
isExpecting
class ThrottleLimitResultQueue<T> implements ResultQueue<T> { // Accumulation of result objects as they finish. private final BlockingQueue<T> results; // Accumulation of dummy objects flagging expected results in the future. private final Semaphore waits; private final Object lock = new Object(); private vol...
// Base the decision about whether we expect more results on a // counter of the number of expected results actually collected. // Do not synchronize! Otherwise put and expect can deadlock. return count > 0;
542
53
595
<no_super_class>
spring-projects_spring-batch
spring-batch/spring-batch-infrastructure/src/main/java/org/springframework/batch/support/AnnotationMethodResolver.java
AnnotationMethodResolver
findMethod
class AnnotationMethodResolver implements MethodResolver { private final Class<? extends Annotation> annotationType; /** * Create a {@link MethodResolver} for the specified Method-level annotation type. * @param annotationType establish the annotation to be used. */ public AnnotationMethodResolver(Class<? ex...
Assert.notNull(candidate, "candidate object must not be null"); Class<?> targetClass = AopUtils.getTargetClass(candidate); if (targetClass == null) { targetClass = candidate.getClass(); } return this.findMethod(targetClass);
595
79
674
<no_super_class>
spring-projects_spring-batch
spring-batch/spring-batch-infrastructure/src/main/java/org/springframework/batch/support/DefaultPropertyEditorRegistrar.java
DefaultPropertyEditorRegistrar
setCustomEditors
class DefaultPropertyEditorRegistrar implements PropertyEditorRegistrar { private Map<Class<?>, PropertyEditor> customEditors; /** * Register the custom editors with the given registry. * * @see org.springframework.beans.PropertyEditorRegistrar#registerCustomEditors(org.springframework.beans.PropertyEditorReg...
this.customEditors = new HashMap<>(); for (Entry<?, ? extends PropertyEditor> entry : customEditors.entrySet()) { Object key = entry.getKey(); Class<?> requiredType; if (key instanceof Class<?>) { requiredType = (Class<?>) key; } else if (key instanceof String className) { requiredType = Cla...
269
190
459
<no_super_class>
spring-projects_spring-batch
spring-batch/spring-batch-infrastructure/src/main/java/org/springframework/batch/support/IntArrayPropertyEditor.java
IntArrayPropertyEditor
setAsText
class IntArrayPropertyEditor extends PropertyEditorSupport { @Override public void setAsText(String text) throws IllegalArgumentException {<FILL_FUNCTION_BODY>} }
String[] strs = StringUtils.commaDelimitedListToStringArray(text); int[] value = new int[strs.length]; for (int i = 0; i < value.length; i++) { value[i] = Integer.parseInt(strs[i].trim()); } setValue(value);
44
88
132
<methods>public void <init>() ,public void <init>(java.lang.Object) ,public synchronized void addPropertyChangeListener(java.beans.PropertyChangeListener) ,public void firePropertyChange() ,public java.lang.String getAsText() ,public java.awt.Component getCustomEditor() ,public java.lang.String getJavaInitializationStr...
spring-projects_spring-batch
spring-batch/spring-batch-infrastructure/src/main/java/org/springframework/batch/support/LastModifiedResourceComparator.java
LastModifiedResourceComparator
compare
class LastModifiedResourceComparator implements Comparator<Resource> { /** * Compare the two resources by last modified time, so that a sorted list of resources * will have oldest first. * @throws IllegalArgumentException if one of the resources doesn't exist or its last * modified date cannot be determined ...
Assert.isTrue(r1.exists(), "Resource does not exist: " + r1); Assert.isTrue(r2.exists(), "Resource does not exist: " + r2); try { long diff = r1.getFile().lastModified() - r2.getFile().lastModified(); return diff > 0 ? 1 : diff < 0 ? -1 : 0; } catch (IOException e) { throw new IllegalArgumentExcepti...
127
139
266
<no_super_class>
spring-projects_spring-batch
spring-batch/spring-batch-infrastructure/src/main/java/org/springframework/batch/support/MethodInvokerUtils.java
MethodInvokerUtils
getMethodInvokerByAnnotation
class MethodInvokerUtils { private MethodInvokerUtils() { } /** * Create a {@link MethodInvoker} using the provided method name to search. * @param object to be invoked * @param methodName of the method to be invoked * @param paramsRequired boolean indicating whether the parameters are required, if * fal...
Assert.notNull(target, "Target must not be null"); Assert.notNull(annotationType, "AnnotationType must not be null"); Assert.isTrue( ObjectUtils.containsElement(annotationType.getAnnotation(Target.class).value(), ElementType.METHOD), "Annotation [" + annotationType + "] is not a Method-level annotation."...
1,609
357
1,966
<no_super_class>
spring-projects_spring-batch
spring-batch/spring-batch-infrastructure/src/main/java/org/springframework/batch/support/PatternMatcher.java
PatternMatcher
match
class PatternMatcher<S> { private final Map<String, S> map; private final List<String> sorted; /** * Initialize a new {@link PatternMatcher} with a map of patterns to values * @param map a map from String patterns to values */ public PatternMatcher(Map<String, S> map) { super(); this.map = map; // So...
int patIdxStart = 0; int patIdxEnd = pattern.length() - 1; int strIdxStart = 0; int strIdxEnd = str.length() - 1; char ch; boolean containsStar = pattern.contains("*"); if (!containsStar) { // No '*'s, so we make a shortcut if (patIdxEnd != strIdxEnd) { return false; // Pattern and string do ...
650
1,232
1,882
<no_super_class>
spring-projects_spring-batch
spring-batch/spring-batch-infrastructure/src/main/java/org/springframework/batch/support/PropertiesConverter.java
PropertiesConverter
propertiesToString
class PropertiesConverter { private static final String LINE_SEPARATOR = "\n"; // prevents the class from being instantiated private PropertiesConverter() { } /** * Parse a String to a Properties object. If string is empty, an empty Properties * object will be returned. The input String should be a set of k...
Assert.notNull(propertiesToParse, "propertiesToParse must not be null"); if (propertiesToParse.isEmpty()) { return ""; } List<String> keyValuePairs = new ArrayList<>(); for (Map.Entry<Object, Object> entry : propertiesToParse.entrySet()) { keyValuePairs.add(entry.getKey() + "=" + entry.getValue()); }...
441
125
566
<no_super_class>
spring-projects_spring-batch
spring-batch/spring-batch-infrastructure/src/main/java/org/springframework/batch/support/ReflectionUtils.java
ReflectionUtils
findMethod
class ReflectionUtils { private ReflectionUtils() { } /** * Returns a {@link java.util.Set} of {@link java.lang.reflect.Method} instances that * are annotated with the annotation provided. * @param clazz The class to search for a method with the given annotation type * @param annotationType The type of ann...
return Arrays.stream(org.springframework.util.ReflectionUtils.getAllDeclaredMethods(clazz)) .filter(method -> AnnotationUtils.findAnnotation(method, annotationType) != null) .collect(Collectors.toSet());
168
65
233
<no_super_class>
spring-projects_spring-batch
spring-batch/spring-batch-infrastructure/src/main/java/org/springframework/batch/support/SimpleMethodInvoker.java
SimpleMethodInvoker
hashCode
class SimpleMethodInvoker implements MethodInvoker { private final Object object; private Method method; public SimpleMethodInvoker(Object object, Method method) { Assert.notNull(object, "Object to invoke must not be null"); Assert.notNull(method, "Method to invoke must not be null"); this.method = method; ...
int result = 25; result = 31 * result + object.hashCode(); result = 31 * result + method.hashCode(); return result;
818
46
864
<no_super_class>
spring-projects_spring-batch
spring-batch/spring-batch-infrastructure/src/main/java/org/springframework/batch/support/SystemPropertyInitializer.java
SystemPropertyInitializer
afterPropertiesSet
class SystemPropertyInitializer implements InitializingBean { /** * Name of system property used by default. */ public static final String ENVIRONMENT = "org.springframework.batch.support.SystemPropertyInitializer.ENVIRONMENT"; private String keyName = ENVIRONMENT; private String defaultValue; /** * Set ...
Assert.state(defaultValue != null || System.getProperty(keyName) != null, "Either a default value must be specified or the value should already be set for System property: " + keyName); System.setProperty(keyName, System.getProperty(keyName, defaultValue));
272
79
351
<no_super_class>
spring-projects_spring-batch
spring-batch/spring-batch-infrastructure/src/main/java/org/springframework/batch/support/transaction/ResourcelessTransactionManager.java
ResourcelessTransactionManager
doGetTransaction
class ResourcelessTransactionManager extends AbstractPlatformTransactionManager { @Override protected void doBegin(Object transaction, TransactionDefinition definition) throws TransactionException { ((ResourcelessTransaction) transaction).begin(); } @Override protected void doCommit(DefaultTransactionStatus st...
Object transaction = new ResourcelessTransaction(); List<Object> resources; if (!TransactionSynchronizationManager.hasResource(this)) { resources = new ArrayList<>(); TransactionSynchronizationManager.bindResource(this, resources); } else { @SuppressWarnings("unchecked") List<Object> stack = (Lis...
498
136
634
<methods>public void <init>() ,public final void commit(org.springframework.transaction.TransactionStatus) throws org.springframework.transaction.TransactionException,public final int getDefaultTimeout() ,public final org.springframework.transaction.TransactionStatus getTransaction(org.springframework.transaction.Trans...
spring-projects_spring-batch
spring-batch/spring-batch-infrastructure/src/main/java/org/springframework/batch/support/transaction/TransactionAwareBufferedWriter.java
TransactionAwareBufferedWriter
getBufferSize
class TransactionAwareBufferedWriter extends Writer { private final Object bufferKey; private final Object closeKey; private final FileChannel channel; private final Runnable closeCallback; // default encoding for writing to output files - set to UTF-8. private static final String DEFAULT_CHARSET = "UTF-8"; ...
if (!transactionActive()) { return 0L; } try { return getCurrentBuffer().toString().getBytes(encoding).length; } catch (UnsupportedEncodingException e) { throw new WriteFailedException( "Could not determine buffer size because of unsupported encoding: " + encoding, e); }
1,449
89
1,538
<methods>public java.io.Writer append(java.lang.CharSequence) throws java.io.IOException,public java.io.Writer append(char) throws java.io.IOException,public java.io.Writer append(java.lang.CharSequence, int, int) throws java.io.IOException,public abstract void close() throws java.io.IOException,public abstract void fl...
spring-projects_spring-batch
spring-batch/spring-batch-infrastructure/src/main/java/org/springframework/batch/support/transaction/TransactionAwareProxyFactory.java
TransactionAwareInterceptor
invoke
class TransactionAwareInterceptor implements MethodInterceptor { @Override public Object invoke(MethodInvocation invocation) throws Throwable {<FILL_FUNCTION_BODY>} }
if (!TransactionSynchronizationManager.isActualTransactionActive()) { return invocation.proceed(); } T cache; if (!TransactionSynchronizationManager.hasResource(this)) { cache = begin(target); TransactionSynchronizationManager.bindResource(this, cache); TransactionSynchronizationManager....
52
374
426
<no_super_class>
spring-projects_spring-batch
spring-batch/spring-batch-integration/src/main/java/org/springframework/batch/integration/aot/IntegrationRuntimeHints.java
IntegrationRuntimeHints
registerHints
class IntegrationRuntimeHints implements RuntimeHintsRegistrar { @Override public void registerHints(RuntimeHints hints, ClassLoader classLoader) {<FILL_FUNCTION_BODY>} }
// reflection hints MemberCategory[] memberCategories = MemberCategory.values(); hints.reflection().registerType(ChunkRequest.class, memberCategories); hints.reflection().registerType(ChunkResponse.class, memberCategories); hints.reflection().registerType(StepExecutionRequestHandler.class, memberCategories);...
52
174
226
<no_super_class>
spring-projects_spring-batch
spring-batch/spring-batch-integration/src/main/java/org/springframework/batch/integration/async/AsyncItemProcessor.java
AsyncItemProcessor
process
class AsyncItemProcessor<I, O> implements ItemProcessor<I, Future<O>>, InitializingBean { private ItemProcessor<I, O> delegate; private TaskExecutor taskExecutor = new SyncTaskExecutor(); /** * Check mandatory properties (the {@link #setDelegate(ItemProcessor)}). * * @see InitializingBean#afterPropertiesSet...
final StepExecution stepExecution = getStepExecution(); FutureTask<O> task = new FutureTask<>(() -> { if (stepExecution != null) { StepSynchronizationManager.register(stepExecution); } try { return delegate.process(item); } finally { if (stepExecution != null) { StepSynchronizationM...
461
131
592
<no_super_class>
spring-projects_spring-batch
spring-batch/spring-batch-integration/src/main/java/org/springframework/batch/integration/async/AsyncItemWriter.java
AsyncItemWriter
write
class AsyncItemWriter<T> implements ItemStreamWriter<Future<T>>, InitializingBean { private static final Log logger = LogFactory.getLog(AsyncItemWriter.class); private ItemWriter<T> delegate; @Override public void afterPropertiesSet() throws Exception { Assert.state(delegate != null, "A delegate ItemWriter mus...
List<T> list = new ArrayList<>(); for (Future<T> future : items) { try { T item = future.get(); if (item != null) { list.add(item); } } catch (ExecutionException e) { Throwable cause = e.getCause(); if (cause instanceof Exception) { logger.debug("An exception was thrown whi...
499
170
669
<no_super_class>
spring-projects_spring-batch
spring-batch/spring-batch-integration/src/main/java/org/springframework/batch/integration/async/StepExecutionInterceptor.java
StepExecutionInterceptor
preSend
class StepExecutionInterceptor implements ChannelInterceptor { /** * The name of the header */ public static final String STEP_EXECUTION = "stepExecution"; @Override public Message<?> preSend(Message<?> message, MessageChannel channel) {<FILL_FUNCTION_BODY>} }
StepContext context = StepSynchronizationManager.getContext(); if (context == null) { return message; } return MessageBuilder.fromMessage(message).setHeader(STEP_EXECUTION, context.getStepExecution()).build();
83
66
149
<no_super_class>
spring-projects_spring-batch
spring-batch/spring-batch-integration/src/main/java/org/springframework/batch/integration/chunk/ChunkMessageChannelItemWriter.java
LocalState
pollChunkResponses
class LocalState { private final AtomicInteger current = new AtomicInteger(-1); private final AtomicInteger actual = new AtomicInteger(); private final AtomicInteger expected = new AtomicInteger(); private final AtomicInteger redelivered = new AtomicInteger(); private StepExecution stepExecution; priv...
Collection<ChunkResponse> set = new ArrayList<>(); synchronized (contributions) { ChunkResponse item = contributions.poll(); while (item != null) { set.add(item); item = contributions.poll(); } } return set;
478
82
560
<no_super_class>
spring-projects_spring-batch
spring-batch/spring-batch-integration/src/main/java/org/springframework/batch/integration/chunk/ChunkProcessorChunkHandler.java
ChunkProcessorChunkHandler
process
class ChunkProcessorChunkHandler<S> implements ChunkHandler<S>, InitializingBean { private static final Log logger = LogFactory.getLog(ChunkProcessorChunkHandler.class); private ChunkProcessor<S> chunkProcessor; @Override public void afterPropertiesSet() throws Exception { Assert.state(chunkProcessor != null, ...
Chunk chunk = chunkRequest.getItems(); Throwable failure = null; try { chunkProcessor.process(stepContribution, chunk); } catch (SkipLimitExceededException | NonSkippableReadException | SkipListenerFailedException | RetryException | JobInterruptedException e) { failure = e; } catch (Exception ...
521
169
690
<no_super_class>
spring-projects_spring-batch
spring-batch/spring-batch-integration/src/main/java/org/springframework/batch/integration/chunk/ChunkRequest.java
ChunkRequest
toString
class ChunkRequest<T> implements Serializable { private static final long serialVersionUID = 1L; private final long jobId; private final Chunk<? extends T> items; private final StepContribution stepContribution; private final int sequence; public ChunkRequest(int sequence, Chunk<? extends T> items, long job...
return getClass().getSimpleName() + ": jobId=" + jobId + ", sequence=" + sequence + ", contribution=" + stepContribution + ", item count=" + items.size();
273
52
325
<no_super_class>
spring-projects_spring-batch
spring-batch/spring-batch-integration/src/main/java/org/springframework/batch/integration/chunk/ChunkResponse.java
ChunkResponse
toString
class ChunkResponse implements Serializable { private static final long serialVersionUID = 1L; private final StepContribution stepContribution; private final Long jobId; private final boolean status; private final String message; private final boolean redelivered; private final int sequence; public Chun...
return getClass().getSimpleName() + ": jobId=" + jobId + ", sequence=" + sequence + ", stepContribution=" + stepContribution + ", successful=" + status;
504
51
555
<no_super_class>