/** * Registers objects using the annotation based listener configuration. * * @param listener the object that has a method configured with listener annotation * @return this for fluent chaining */ @SuppressWarnings("unchecked") @Override public SimpleStepBuilder<I, O> listener(Object listener) { super.listener(listener); Set<Method> itemListenerMethods = new HashSet<>(); itemListenerMethods.addAll(ReflectionUtils.findMethod(listener.getClass(), BeforeRead.class)); itemListenerMethods.addAll(ReflectionUtils.findMethod(listener.getClass(), AfterRead.class)); itemListenerMethods.addAll(ReflectionUtils.findMethod(listener.getClass(), BeforeProcess.class)); itemListenerMethods.addAll(ReflectionUtils.findMethod(listener.getClass(), AfterProcess.class)); itemListenerMethods.addAll(ReflectionUtils.findMethod(listener.getClass(), BeforeWrite.class)); itemListenerMethods.addAll(ReflectionUtils.findMethod(listener.getClass(), AfterWrite.class)); itemListenerMethods.addAll(ReflectionUtils.findMethod(listener.getClass(), OnReadError.class)); itemListenerMethods.addAll(ReflectionUtils.findMethod(listener.getClass(), OnProcessError.class)); itemListenerMethods.addAll(ReflectionUtils.findMethod(listener.getClass(), OnWriteError.class)); if(itemListenerMethods.size() > 0) { StepListenerFactoryBean factory = new StepListenerFactoryBean(); factory.setDelegate(listener); itemListeners.add((StepListener) factory.getObject()); } @SuppressWarnings("unchecked") SimpleStepBuilder<I, O> result = this; return result; }
/** * Registers objects using the annotation based listener configuration. * * @param listener the object that has a method configured with listener annotation * @return this for fluent chaining */ @Override @SuppressWarnings("unchecked") public SimpleStepBuilder<I, O> listener(Object listener) { super.listener(listener); Set<Method> skipListenerMethods = new HashSet<>(); skipListenerMethods.addAll(ReflectionUtils.findMethod(listener.getClass(), OnSkipInRead.class)); skipListenerMethods.addAll(ReflectionUtils.findMethod(listener.getClass(), OnSkipInProcess.class)); skipListenerMethods.addAll(ReflectionUtils.findMethod(listener.getClass(), OnSkipInWrite.class)); if(skipListenerMethods.size() > 0) { StepListenerFactoryBean factory = new StepListenerFactoryBean(); factory.setDelegate(listener); skipListeners.add((SkipListener) factory.getObject()); } @SuppressWarnings("unchecked") SimpleStepBuilder<I, O> result = this; return result; }
/** * Registers objects using the annotation based listener configuration. * * @param listener the object that has a method configured with listener annotation * @return this for fluent chaining */ @Override public B listener(Object listener) { super.listener(listener); Set<Method> chunkListenerMethods = new HashSet<>(); chunkListenerMethods.addAll(ReflectionUtils.findMethod(listener.getClass(), BeforeChunk.class)); chunkListenerMethods.addAll(ReflectionUtils.findMethod(listener.getClass(), AfterChunk.class)); chunkListenerMethods.addAll(ReflectionUtils.findMethod(listener.getClass(), AfterChunkError.class)); if(chunkListenerMethods.size() > 0) { StepListenerFactoryBean factory = new StepListenerFactoryBean(); factory.setDelegate(listener); this.listener((ChunkListener) factory.getObject()); } @SuppressWarnings("unchecked") B result = (B) this; return result; }
/** * Registers objects using the annotation based listener configuration. * * @param listener the object that has a method configured with listener annotation * @return this for fluent chaining */ public B listener(Object listener) { Set<Method> stepExecutionListenerMethods = new HashSet<>(); stepExecutionListenerMethods.addAll(ReflectionUtils.findMethod(listener.getClass(), BeforeStep.class)); stepExecutionListenerMethods.addAll(ReflectionUtils.findMethod(listener.getClass(), AfterStep.class)); if(stepExecutionListenerMethods.size() > 0) { StepListenerFactoryBean factory = new StepListenerFactoryBean(); factory.setDelegate(listener); properties.addStepExecutionListener((StepExecutionListener) factory.getObject()); } @SuppressWarnings("unchecked") B result = (B) this; return result; }
@Test public void testFindAnnotatedMethod() { Set<Method> methods = ReflectionUtils.findMethod(AnnotatedClass.class, Transactional.class); assertEquals(1, methods.size()); assertEquals("toString", methods.iterator().next().getName()); }
@Test public void testFindNoAnnotatedMethod() { Set<Method> methods = ReflectionUtils.findMethod(AnnotatedClass.class, Autowired.class); assertEquals(0, methods.size()); }
@Test public void testFindAnnotatedMethodHierarchy() { Set<Method> methods = ReflectionUtils.findMethod(AnnotatedSubClass.class, Transactional.class); assertEquals(2, methods.size()); boolean toStringFound = false; boolean methodOneFound = false; Iterator<Method> iterator = methods.iterator(); String name = iterator.next().getName(); if(name.equals("toString")) { toStringFound = true; } else if(name.equals("methodOne")) { methodOneFound = true; } name = iterator.next().getName(); if(name.equals("toString")) { toStringFound = true; } else if(name.equals("methodOne")) { methodOneFound = true; } assertTrue(toStringFound && methodOneFound); }
/** * Registers objects using the annotation based listener configuration. * * @param listener the object that has a method configured with listener annotation * @return this for fluent chaining */ @Override public SimpleStepBuilder listener(Object listener) { super.listener(listener); Set<Method> itemListenerMethods = new HashSet<Method>(); itemListenerMethods.addAll(ReflectionUtils.findMethod(listener.getClass(), BeforeRead.class)); itemListenerMethods.addAll(ReflectionUtils.findMethod(listener.getClass(), AfterRead.class)); itemListenerMethods.addAll(ReflectionUtils.findMethod(listener.getClass(), BeforeProcess.class)); itemListenerMethods.addAll(ReflectionUtils.findMethod(listener.getClass(), AfterProcess.class)); itemListenerMethods.addAll(ReflectionUtils.findMethod(listener.getClass(), BeforeWrite.class)); itemListenerMethods.addAll(ReflectionUtils.findMethod(listener.getClass(), AfterWrite.class)); itemListenerMethods.addAll(ReflectionUtils.findMethod(listener.getClass(), OnReadError.class)); itemListenerMethods.addAll(ReflectionUtils.findMethod(listener.getClass(), OnProcessError.class)); itemListenerMethods.addAll(ReflectionUtils.findMethod(listener.getClass(), OnWriteError.class)); if(itemListenerMethods.size() > 0) { StepListenerFactoryBean factory = new StepListenerFactoryBean(); factory.setDelegate(listener); itemListeners.add((StepListener) factory.getObject()); } @SuppressWarnings("unchecked") SimpleStepBuilder result = this; return result; }
/** * Registers objects using the annotation based listener configuration. * * @param listener the object that has a method configured with listener annotation * @return this for fluent chaining */ @SuppressWarnings("unchecked") @Override public SimpleStepBuilder<I, O> listener(Object listener) { super.listener(listener); Set<Method> itemListenerMethods = new HashSet<>(); itemListenerMethods.addAll(ReflectionUtils.findMethod(listener.getClass(), BeforeRead.class)); itemListenerMethods.addAll(ReflectionUtils.findMethod(listener.getClass(), AfterRead.class)); itemListenerMethods.addAll(ReflectionUtils.findMethod(listener.getClass(), BeforeProcess.class)); itemListenerMethods.addAll(ReflectionUtils.findMethod(listener.getClass(), AfterProcess.class)); itemListenerMethods.addAll(ReflectionUtils.findMethod(listener.getClass(), BeforeWrite.class)); itemListenerMethods.addAll(ReflectionUtils.findMethod(listener.getClass(), AfterWrite.class)); itemListenerMethods.addAll(ReflectionUtils.findMethod(listener.getClass(), OnReadError.class)); itemListenerMethods.addAll(ReflectionUtils.findMethod(listener.getClass(), OnProcessError.class)); itemListenerMethods.addAll(ReflectionUtils.findMethod(listener.getClass(), OnWriteError.class)); if(itemListenerMethods.size() > 0) { StepListenerFactoryBean factory = new StepListenerFactoryBean(); factory.setDelegate(listener); itemListeners.add((StepListener) factory.getObject()); } @SuppressWarnings("unchecked") SimpleStepBuilder<I, O> result = this; return result; }
/** * Registers objects using the annotation based listener configuration. * * @param listener the object that has a method configured with listener annotation * @return this for fluent chaining */ @SuppressWarnings("unchecked") @Override public SimpleStepBuilder<I, O> listener(Object listener) { super.listener(listener); Set<Method> itemListenerMethods = new HashSet<>(); itemListenerMethods.addAll(ReflectionUtils.findMethod(listener.getClass(), BeforeRead.class)); itemListenerMethods.addAll(ReflectionUtils.findMethod(listener.getClass(), AfterRead.class)); itemListenerMethods.addAll(ReflectionUtils.findMethod(listener.getClass(), BeforeProcess.class)); itemListenerMethods.addAll(ReflectionUtils.findMethod(listener.getClass(), AfterProcess.class)); itemListenerMethods.addAll(ReflectionUtils.findMethod(listener.getClass(), BeforeWrite.class)); itemListenerMethods.addAll(ReflectionUtils.findMethod(listener.getClass(), AfterWrite.class)); itemListenerMethods.addAll(ReflectionUtils.findMethod(listener.getClass(), OnReadError.class)); itemListenerMethods.addAll(ReflectionUtils.findMethod(listener.getClass(), OnProcessError.class)); itemListenerMethods.addAll(ReflectionUtils.findMethod(listener.getClass(), OnWriteError.class)); if(itemListenerMethods.size() > 0) { StepListenerFactoryBean factory = new StepListenerFactoryBean(); factory.setDelegate(listener); itemListeners.add((StepListener) factory.getObject()); } @SuppressWarnings("unchecked") SimpleStepBuilder<I, O> result = this; return result; }
/** * Registers objects using the annotation based listener configuration. * * @param listener the object that has a method configured with listener annotation * @return this for fluent chaining */ @Override public B listener(Object listener) { super.listener(listener); Set<Method> chunkListenerMethods = new HashSet<>(); chunkListenerMethods.addAll(ReflectionUtils.findMethod(listener.getClass(), BeforeChunk.class)); chunkListenerMethods.addAll(ReflectionUtils.findMethod(listener.getClass(), AfterChunk.class)); chunkListenerMethods.addAll(ReflectionUtils.findMethod(listener.getClass(), AfterChunkError.class)); if(chunkListenerMethods.size() > 0) { StepListenerFactoryBean factory = new StepListenerFactoryBean(); factory.setDelegate(listener); this.listener((ChunkListener) factory.getObject()); } @SuppressWarnings("unchecked") B result = (B) this; return result; }
/** * Registers objects using the annotation based listener configuration. * * @param listener the object that has a method configured with listener annotation * @return this for fluent chaining */ @Override @SuppressWarnings("unchecked") public SimpleStepBuilder<I, O> listener(Object listener) { super.listener(listener); Set<Method> skipListenerMethods = new HashSet<Method>(); skipListenerMethods.addAll(ReflectionUtils.findMethod(listener.getClass(), OnSkipInRead.class)); skipListenerMethods.addAll(ReflectionUtils.findMethod(listener.getClass(), OnSkipInProcess.class)); skipListenerMethods.addAll(ReflectionUtils.findMethod(listener.getClass(), OnSkipInWrite.class)); if(skipListenerMethods.size() > 0) { StepListenerFactoryBean factory = new StepListenerFactoryBean(); factory.setDelegate(listener); skipListeners.add((SkipListener) factory.getObject()); } @SuppressWarnings("unchecked") SimpleStepBuilder<I, O> result = this; return result; }
/** * Registers objects using the annotation based listener configuration. * * @param listener the object that has a method configured with listener annotation * @return this for fluent chaining */ @Override @SuppressWarnings("unchecked") public SimpleStepBuilder<I, O> listener(Object listener) { super.listener(listener); Set<Method> skipListenerMethods = new HashSet<Method>(); skipListenerMethods.addAll(ReflectionUtils.findMethod(listener.getClass(), OnSkipInRead.class)); skipListenerMethods.addAll(ReflectionUtils.findMethod(listener.getClass(), OnSkipInProcess.class)); skipListenerMethods.addAll(ReflectionUtils.findMethod(listener.getClass(), OnSkipInWrite.class)); if(skipListenerMethods.size() > 0) { StepListenerFactoryBean factory = new StepListenerFactoryBean(); factory.setDelegate(listener); skipListeners.add((SkipListener) factory.getObject()); } @SuppressWarnings("unchecked") SimpleStepBuilder<I, O> result = this; return result; }
/** * Registers objects using the annotation based listener configuration. * * @param listener the object that has a method configured with listener annotation * @return this for fluent chaining */ public B listener(Object listener) { Set<Method> stepExecutionListenerMethods = new HashSet<Method>(); stepExecutionListenerMethods.addAll(ReflectionUtils.findMethod(listener.getClass(), BeforeStep.class)); stepExecutionListenerMethods.addAll(ReflectionUtils.findMethod(listener.getClass(), AfterStep.class)); if(stepExecutionListenerMethods.size() > 0) { StepListenerFactoryBean factory = new StepListenerFactoryBean(); factory.setDelegate(listener); properties.addStepExecutionListener((StepExecutionListener) factory.getObject()); } @SuppressWarnings("unchecked") B result = (B) this; return result; }
/** * Registers objects using the annotation based listener configuration. * * @param listener the object that has a method configured with listener annotation * @return this for fluent chaining */ public B listener(Object listener) { Set<Method> stepExecutionListenerMethods = new HashSet<Method>(); stepExecutionListenerMethods.addAll(ReflectionUtils.findMethod(listener.getClass(), BeforeStep.class)); stepExecutionListenerMethods.addAll(ReflectionUtils.findMethod(listener.getClass(), AfterStep.class)); if(stepExecutionListenerMethods.size() > 0) { StepListenerFactoryBean factory = new StepListenerFactoryBean(); factory.setDelegate(listener); properties.addStepExecutionListener((StepExecutionListener) factory.getObject()); } @SuppressWarnings("unchecked") B result = (B) this; return result; }
/** * Registers objects using the annotation based listener configuration. * * @param listener the object that has a method configured with listener annotation * @return this for fluent chaining */ public B listener(Object listener) { Set<Method> stepExecutionListenerMethods = new HashSet<Method>(); stepExecutionListenerMethods.addAll(ReflectionUtils.findMethod(listener.getClass(), BeforeStep.class)); stepExecutionListenerMethods.addAll(ReflectionUtils.findMethod(listener.getClass(), AfterStep.class)); if(stepExecutionListenerMethods.size() > 0) { StepListenerFactoryBean factory = new StepListenerFactoryBean(); factory.setDelegate(listener); properties.addStepExecutionListener((StepExecutionListener) factory.getObject()); } @SuppressWarnings("unchecked") B result = (B) this; return result; }
/** * Registers objects using the annotation based listener configuration. * * @param listener the object that has a method configured with listener annotation * @return this for fluent chaining */ @Override public B listener(Object listener) { super.listener(listener); Set<Method> chunkListenerMethods = new HashSet<>(); chunkListenerMethods.addAll(ReflectionUtils.findMethod(listener.getClass(), BeforeChunk.class)); chunkListenerMethods.addAll(ReflectionUtils.findMethod(listener.getClass(), AfterChunk.class)); chunkListenerMethods.addAll(ReflectionUtils.findMethod(listener.getClass(), AfterChunkError.class)); if(chunkListenerMethods.size() > 0) { StepListenerFactoryBean factory = new StepListenerFactoryBean(); factory.setDelegate(listener); this.listener((ChunkListener) factory.getObject()); } @SuppressWarnings("unchecked") B result = (B) this; return result; }
skipListenerMethods.addAll(ReflectionUtils.findMethod(listener.getClass(), OnSkipInRead.class)); skipListenerMethods.addAll(ReflectionUtils.findMethod(listener.getClass(), OnSkipInProcess.class)); skipListenerMethods.addAll(ReflectionUtils.findMethod(listener.getClass(), OnSkipInWrite.class)); chunkListenerMethods.addAll(ReflectionUtils.findMethod(listener.getClass(), BeforeChunk.class)); chunkListenerMethods.addAll(ReflectionUtils.findMethod(listener.getClass(), AfterChunk.class)); chunkListenerMethods.addAll(ReflectionUtils.findMethod(listener.getClass(), AfterChunkError.class));