Tabnine Logo
StepListenerFactoryBean.setDelegate
Code IndexAdd Tabnine to your IDE (free)

How to use
setDelegate
method
in
org.springframework.batch.core.listener.StepListenerFactoryBean

Best Java code snippets using org.springframework.batch.core.listener.StepListenerFactoryBean.setDelegate (Showing top 20 results out of 315)

origin: spring-projects/spring-batch

/**
 * Convenience method to wrap any object and expose the appropriate
 * {@link StepListener} interfaces.
 *
 * @param delegate a delegate object
 * @return a StepListener instance constructed from the delegate
 */
public static StepListener getListener(Object delegate) {
  StepListenerFactoryBean factory = new StepListenerFactoryBean();
  factory.setDelegate(delegate);
  return (StepListener) factory.getObject();
}
origin: spring-projects/spring-batch

/**
 * 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;
}
origin: spring-projects/spring-batch

/**
 * 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;
}
origin: spring-projects/spring-batch

/**
 * 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;
}
origin: spring-projects/spring-batch

/**
 * 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;
}
origin: spring-projects/spring-batch

@Test(expected = IllegalArgumentException.class)
public void testWrongSignatureAnnotation() {
  AbstractTestComponent delegate = new AbstractTestComponent() {
    @AfterWrite
    public void aMethod(Integer item) {
      executed = true;
    }
  };
  factoryBean.setDelegate(delegate);
  factoryBean.getObject();
}
origin: spring-projects/spring-batch

@Test
public void testNonListener() throws Exception {
  Object delegate = new Object();
  factoryBean.setDelegate(delegate);
  assertTrue(factoryBean.getObject() instanceof StepListener);
}
origin: spring-projects/spring-batch

@Test(expected = IllegalArgumentException.class)
public void testWrongSignatureNamedMethod() {
  AbstractTestComponent delegate = new AbstractTestComponent() {
    @SuppressWarnings("unused")
    public void aMethod(Integer item) {
      executed = true;
    }
  };
  factoryBean.setDelegate(delegate);
  Map<String, String> metaDataMap = new HashMap<>();
  metaDataMap.put(AFTER_WRITE.getPropertyName(), "aMethod");
  factoryBean.setMetaDataMap(metaDataMap);
  factoryBean.getObject();
}
origin: spring-projects/spring-batch

@Test
public void testEmptySignatureNamedMethod() {
  AbstractTestComponent delegate = new AbstractTestComponent() {
    @SuppressWarnings("unused")
    public void aMethod() {
      executed = true;
    }
  };
  factoryBean.setDelegate(delegate);
  Map<String, String> metaDataMap = new HashMap<>();
  metaDataMap.put(AFTER_WRITE.getPropertyName(), "aMethod");
  factoryBean.setMetaDataMap(metaDataMap);
  @SuppressWarnings("unchecked")
  ItemWriteListener<String> listener = (ItemWriteListener<String>) factoryBean.getObject();
  listener.afterWrite(Arrays.asList("foo", "bar"));
  assertTrue(delegate.isExecuted());
}
origin: spring-projects/spring-batch

@Test
public void testAnnotatingInterfaceResultsInOneCall() throws Exception {
  MultipleAfterStep delegate = new MultipleAfterStep();
  factoryBean.setDelegate(delegate);
  Map<String, String> metaDataMap = new HashMap<>();
  metaDataMap.put(AFTER_STEP.getPropertyName(), "afterStep");
  factoryBean.setMetaDataMap(metaDataMap);
  StepListener listener = (StepListener) factoryBean.getObject();
  ((StepExecutionListener) listener).afterStep(stepExecution);
  assertEquals(1, delegate.callcount);
}
origin: spring-projects/spring-batch

@Test
public void testAllThreeTypes() throws Exception {
  // Test to make sure if someone has annotated a method, implemented the
  // interface, and given a string
  // method name, that all three will be called
  ThreeStepExecutionListener delegate = new ThreeStepExecutionListener();
  factoryBean.setDelegate(delegate);
  Map<String, String> metaDataMap = new HashMap<>();
  metaDataMap.put(AFTER_STEP.getPropertyName(), "destroy");
  factoryBean.setMetaDataMap(metaDataMap);
  StepListener listener = (StepListener) factoryBean.getObject();
  ((StepExecutionListener) listener).afterStep(stepExecution);
  assertEquals(3, delegate.callcount);
}
origin: spring-projects/spring-batch

@Test
public void testEmptySignatureAnnotation() {
  AbstractTestComponent delegate = new AbstractTestComponent() {
    @AfterWrite
    public void aMethod() {
      executed = true;
    }
  };
  factoryBean.setDelegate(delegate);
  @SuppressWarnings("unchecked")
  ItemWriteListener<String> listener = (ItemWriteListener<String>) factoryBean.getObject();
  listener.afterWrite(Arrays.asList("foo", "bar"));
  assertTrue(delegate.isExecuted());
}
origin: spring-projects/spring-batch

@Test
public void testRightSignatureAnnotation() {
  AbstractTestComponent delegate = new AbstractTestComponent() {
    @AfterWrite
    public void aMethod(List<String> items) {
      executed = true;
      assertEquals("foo", items.get(0));
      assertEquals("bar", items.get(1));
    }
  };
  factoryBean.setDelegate(delegate);
  @SuppressWarnings("unchecked")
  ItemWriteListener<String> listener = (ItemWriteListener<String>) factoryBean.getObject();
  listener.afterWrite(Arrays.asList("foo", "bar"));
  assertTrue(delegate.isExecuted());
}
origin: spring-projects/spring-batch

@Test
public void testRightSignatureNamedMethod() {
  AbstractTestComponent delegate = new AbstractTestComponent() {
    @SuppressWarnings("unused")
    public void aMethod(List<String> items) {
      executed = true;
      assertEquals("foo", items.get(0));
      assertEquals("bar", items.get(1));
    }
  };
  factoryBean.setDelegate(delegate);
  Map<String, String> metaDataMap = new HashMap<>();
  metaDataMap.put(AFTER_WRITE.getPropertyName(), "aMethod");
  factoryBean.setMetaDataMap(metaDataMap);
  @SuppressWarnings("unchecked")
  ItemWriteListener<String> listener = (ItemWriteListener<String>) factoryBean.getObject();
  listener.afterWrite(Arrays.asList("foo", "bar"));
  assertTrue(delegate.isExecuted());
}
origin: spring-projects/spring-batch

@Test
public void testVanillaInterfaceWithProxy() throws Exception {
  MultipleAfterStep delegate = new MultipleAfterStep();
  ProxyFactory factory = new ProxyFactory(delegate);
  factoryBean.setDelegate(factory.getProxy());
  Object listener = factoryBean.getObject();
  assertTrue(listener instanceof StepExecutionListener);
  ((StepExecutionListener) listener).beforeStep(stepExecution);
  assertEquals(1, delegate.callcount);
}
origin: spring-projects/spring-batch

@Test
public void testVanillaInterface() throws Exception {
  MultipleAfterStep delegate = new MultipleAfterStep();
  factoryBean.setDelegate(delegate);
  Object listener = factoryBean.getObject();
  assertTrue(listener instanceof StepExecutionListener);
  ((StepExecutionListener) listener).beforeStep(stepExecution);
  assertEquals(1, delegate.callcount);
}
origin: spring-projects/spring-batch

public void testStepAndChunk() throws Exception {
  TestListener testListener = new TestListener();
  factoryBean.setDelegate(testListener);
origin: org.springframework.batch/spring-batch-core

/**
 * Convenience method to wrap any object and expose the appropriate
 * {@link StepListener} interfaces.
 *
 * @param delegate a delegate object
 * @return a StepListener instance constructed from the delegate
 */
public static StepListener getListener(Object delegate) {
  StepListenerFactoryBean factory = new StepListenerFactoryBean();
  factory.setDelegate(delegate);
  return (StepListener) factory.getObject();
}
origin: org.springframework.batch.core/org.motechproject.org.springframework.batch.core

/**
 * Convenience method to wrap any object and expose the appropriate
 * {@link StepListener} interfaces.
 *
 * @param delegate a delegate object
 * @return a StepListener instance constructed from the delegate
 */
public static StepListener getListener(Object delegate) {
  StepListenerFactoryBean factory = new StepListenerFactoryBean();
  factory.setDelegate(delegate);
  return (StepListener) factory.getObject();
}
origin: org.springframework.batch/org.springframework.batch.core

/**
 * Convenience method to wrap any object and expose the appropriate
 * {@link StepListener} interfaces.
 * 
 * @param delegate a delegate object
 * @return a StepListener instance constructed from the delegate
 */
public static StepListener getListener(Object delegate) {
  StepListenerFactoryBean factory = new StepListenerFactoryBean();
  factory.setDelegate(delegate);
  return (StepListener) factory.getObject();
}
org.springframework.batch.core.listenerStepListenerFactoryBeansetDelegate

Popular methods of StepListenerFactoryBean

  • <init>
  • getListener
    Convenience method to wrap any object and expose the appropriate StepListener interfaces.
  • getObject
  • isListener
    Convenience method to check whether the given object is or can be made into a StepListener.
  • setMetaDataMap

Popular in Java

  • Updating database using SQL prepared statement
  • getOriginalFilename (MultipartFile)
    Return the original filename in the client's filesystem.This may contain path information depending
  • setContentView (Activity)
  • setRequestProperty (URLConnection)
  • BorderLayout (java.awt)
    A border layout lays out a container, arranging and resizing its components to fit in five regions:
  • Font (java.awt)
    The Font class represents fonts, which are used to render text in a visible way. A font provides the
  • Graphics2D (java.awt)
    This Graphics2D class extends the Graphics class to provide more sophisticated control overgraphics
  • Time (java.sql)
    Java representation of an SQL TIME value. Provides utilities to format and parse the time's represen
  • DateTimeFormat (org.joda.time.format)
    Factory that creates instances of DateTimeFormatter from patterns and styles. Datetime formatting i
  • Runner (org.openjdk.jmh.runner)
  • Top 12 Jupyter Notebook extensions
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now