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

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

Best Java code snippets using org.springframework.batch.core.listener.StepListenerFactoryBean.getObject (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

Integer writeItem = 2;
List<Integer> writeItems = Arrays.asList(writeItem);
StepListener listener = (StepListener) factoryBean.getObject();
((StepExecutionListener) listener).beforeStep(stepExecution);
((StepExecutionListener) listener).afterStep(stepExecution);
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.listenerStepListenerFactoryBeangetObject

Popular methods of StepListenerFactoryBean

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

Popular in Java

  • Updating database using SQL prepared statement
  • getSystemService (Context)
  • scheduleAtFixedRate (ScheduledExecutorService)
  • getApplicationContext (Context)
  • Hashtable (java.util)
    A plug-in replacement for JDK1.5 java.util.Hashtable. This version is based on org.cliffc.high_scale
  • Iterator (java.util)
    An iterator over a sequence of objects, such as a collection.If a collection has been changed since
  • Set (java.util)
    A Set is a data structure which does not allow duplicate elements.
  • Cipher (javax.crypto)
    This class provides access to implementations of cryptographic ciphers for encryption and decryption
  • JLabel (javax.swing)
  • Options (org.apache.commons.cli)
    Main entry-point into the library. Options represents a collection of Option objects, which describ
  • Best plugins for Eclipse
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