Codota Logo
AbstractMethodInvokingDelegator
Code IndexAdd Codota to your IDE (free)

How to use
AbstractMethodInvokingDelegator
in
org.springframework.batch.item.adapter

Best Java code snippets using org.springframework.batch.item.adapter.AbstractMethodInvokingDelegator (Showing top 20 results out of 315)

  • Add the Codota plugin to your IDE and get smart completions
private void myMethod () {
Connection c =
  • Codota IconDataSource dataSource;dataSource.getConnection()
  • Codota IconString url;DriverManager.getConnection(url)
  • Codota IconIdentityDatabaseUtil.getDBConnection()
  • Smart code suggestions by Codota
}
origin: spring-projects/spring-batch

/**
 * Null argument value doesn't cause trouble when validating method
 * signature.
 */
@Test
public void testDelegationWithCheckedNullArgument() throws Exception {
  delegator.setTargetMethod("setName");
  delegator.setArguments(new Object[] { null });
  delegator.afterPropertiesSet();
  delegator.invokeDelegateMethod();
  assertNull(foo.getName());
}
origin: spring-projects/spring-batch

/**
 * Invokes the target method with given arguments.
 *
 * @param args arguments for the invoked method
 * @return object returned by invoked method
 *
 * @throws Exception exception thrown when executing the delegate method.
 */
protected T invokeDelegateMethodWithArguments(Object[] args) throws Exception {
  MethodInvoker invoker = createMethodInvoker(targetObject, targetMethod);
  invoker.setArguments(args);
  return doInvoke(invoker);
}
origin: spring-projects/spring-batch

@Override
public void afterPropertiesSet() throws Exception {
  Assert.notNull(targetObject, "targetObject must not be null");
  Assert.hasLength(targetMethod, "targetMethod must not be empty");
  Assert.state(targetClassDeclaresTargetMethod(),
      "target class must declare a method with matching name and parameter types");
}
origin: spring-projects/spring-batch

@Before
public void setUp() throws Exception {
  delegator.setTargetObject(foo);
  delegator.setArguments(null);
}
origin: spring-projects/spring-batch

/**
 * Exception scenario - target method is called with incorrect number of
 * arguments.
 */
@Test
public void testTooFewArguments() throws Exception {
  delegator.setTargetMethod("setName");
  delegator.afterPropertiesSet();
  try {
    // single argument expected but none provided
    delegator.invokeDelegateMethod();
    fail("Expected IllegalArgumentException");
  }
  catch (IllegalArgumentException e) {
    // expected
  }
}
origin: spring-projects/spring-batch

/**
 * Regular use - calling methods directly and via delegator leads to same
 * results
 */
@Test
@Ignore //FIXME
public void testDelegationWithMultipleArguments() throws Exception {
  FooService fooService = new FooService();
  delegator.setTargetObject(fooService);
  delegator.setTargetMethod("processNameValuePair");
  delegator.afterPropertiesSet();
  final String FOO_NAME = "fooName";
  final int FOO_VALUE = 12345;
  delegator.invokeDelegateMethodWithArguments(new Object[] { FOO_NAME, FOO_VALUE });
  Foo foo = fooService.getProcessedFooNameValuePairs().get(0);
  assertEquals(FOO_NAME, foo.getName());
  assertEquals(FOO_VALUE, foo.getValue());
}
origin: spring-projects/spring-batch

/**
 * Exception scenario - target method is called with invalid arguments.
 */
@Test
public void testInvalidArgumentsForExistingMethod() throws Exception {
  delegator.setTargetMethod("setName");
  delegator.afterPropertiesSet();
  try {
    delegator.invokeDelegateMethodWithArgument(new Object());
    fail("Expected IllegalArgumentException");
  }
  catch (IllegalArgumentException e) {
    // expected
  }
}
origin: spring-projects/spring-batch

/**
 * Exception scenario - incorrect static arguments set.
 */
@Test
public void testIncorrectNumberOfStaticArguments() throws Exception {
  delegator.setTargetMethod("setName");
  // incorrect argument count
  delegator.setArguments(new Object[] { "first", "second" });
  try {
    delegator.afterPropertiesSet();
    fail();
  }
  catch (IllegalStateException e) {
    // expected
  }
  // correct argument count, but invalid argument type
  delegator.setArguments(new Object[] { new Object() });
  try {
    delegator.afterPropertiesSet();
    fail();
  }
  catch (IllegalStateException e) {
    // expected
  }
}
origin: spring-projects/spring-batch

@Override
public void afterPropertiesSet() throws Exception {
  super.afterPropertiesSet();
  Assert.notEmpty(fieldsUsedAsTargetMethodArguments, "fieldsUsedAsTargetMethodArguments must not be empty");
}
origin: spring-projects/spring-batch

MethodInvoker invoker = createMethodInvoker(targetObject, targetMethod);
origin: spring-projects/spring-batch

@Test
public void testTooManyArguments() throws Exception {
  delegator.setTargetMethod("setName");
  // single argument expected but two provided
  delegator.invokeDelegateMethodWithArguments(new Object[] { "name", "anotherName" });
  assertEquals("name", foo.getName());
}
origin: spring-projects/spring-batch

/**
 * Regular use - calling methods directly and via delegator leads to same
 * results
 */
@Test
public void testDelegation() throws Exception {
  delegator.setTargetMethod("getName");
  delegator.afterPropertiesSet();
  assertEquals(foo.getName(), delegator.invokeDelegateMethod());
}
origin: apache/servicemix-bundles

@Override
public void afterPropertiesSet() throws Exception {
  super.afterPropertiesSet();
  Assert.notEmpty(fieldsUsedAsTargetMethodArguments, "fieldsUsedAsTargetMethodArguments must not be empty");
}
origin: apache/servicemix-bundles

MethodInvoker invoker = createMethodInvoker(targetObject, targetMethod);
origin: spring-projects/spring-batch

/**
 * Exception scenario - target method is successfully invoked but throws
 * exception. Such 'business' exception should be re-thrown as is (without
 * wrapping).
 */
@Test
public void testDelegateException() throws Exception {
  delegator.setTargetMethod("fail");
  delegator.afterPropertiesSet();
  try {
    delegator.invokeDelegateMethod();
    fail();
  }
  catch (Exception expected) {
    assertEquals(Foo.FAILURE_MESSAGE, expected.getMessage());
  }
}
origin: spring-projects/spring-batch

/**
 * Regular use - calling methods directly and via delegator leads to same
 * results
 */
@Test
public void testDelegationWithArgument() throws Exception {
  delegator.setTargetMethod("setName");
  final String NEW_FOO_NAME = "newFooName";
  delegator.afterPropertiesSet();
  delegator.invokeDelegateMethodWithArgument(NEW_FOO_NAME);
  assertEquals(NEW_FOO_NAME, foo.getName());
  // using the arguments setter should work equally well
  foo.setName("foo");
  assertTrue(!foo.getName().equals(NEW_FOO_NAME));
  delegator.setArguments(new Object[] { NEW_FOO_NAME });
  delegator.afterPropertiesSet();
  delegator.invokeDelegateMethod();
  assertEquals(NEW_FOO_NAME, foo.getName());
}
origin: spring-projects/spring-batch

/**
 * Invokes the target method with given argument.
 *
 * @param object argument for the target method
 * @return object returned by target method
 *
 * @throws Exception exception thrown when executing the delegate method.
 */
protected T invokeDelegateMethodWithArgument(Object object) throws Exception {
  MethodInvoker invoker = createMethodInvoker(targetObject, targetMethod);
  invoker.setArguments(new Object[] { object });
  return doInvoke(invoker);
}
origin: apache/servicemix-bundles

@Override
public void afterPropertiesSet() throws Exception {
  Assert.notNull(targetObject, "targetObject must not be null");
  Assert.hasLength(targetMethod, "targetMethod must not be empty");
  Assert.state(targetClassDeclaresTargetMethod(),
      "target class must declare a method with matching name and parameter types");
}
origin: spring-projects/spring-batch

/**
 * Exception scenario - target method is not declared by target object.
 */
@Test
public void testInvalidMethodName() throws Exception {
  delegator.setTargetMethod("not-existing-method-name");
  try {
    delegator.afterPropertiesSet();
    fail("Expected IllegalStateException");
  }
  catch (IllegalStateException e) {
    // expected
  }
  try {
    delegator.invokeDelegateMethod();
    fail("Expected IllegalArgumentException");
  }
  catch (IllegalArgumentException e) {
    // expected
  }
}
origin: spring-projects/spring-batch

/**
 * Invoker the target method with arguments set by
 * {@link #setArguments(Object[])}.
 *
 * @return object returned by invoked method
 *
 * @throws Exception exception thrown when executing the delegate method.
 */
protected T invokeDelegateMethod() throws Exception {
  MethodInvoker invoker = createMethodInvoker(targetObject, targetMethod);
  invoker.setArguments(arguments);
  return doInvoke(invoker);
}
org.springframework.batch.item.adapterAbstractMethodInvokingDelegator

Javadoc

Superclass for delegating classes which dynamically call a custom method of injected object. Provides convenient API for dynamic method invocation shielding subclasses from low-level details and exception handling. Exceptions thrown by a successfully invoked delegate method are re-thrown without wrapping. In case the delegate method throws a Throwable that doesn't subclass Exception it will be wrapped by InvocationTargetThrowableWrapper.

Most used methods

  • afterPropertiesSet
  • createMethodInvoker
    Create a new configured instance of MethodInvoker.
  • doInvoke
    Prepare and invoke the invoker, rethrow checked exceptions as unchecked.
  • targetClassDeclaresTargetMethod
  • invokeDelegateMethod
    Invoker the target method with arguments set by #setArguments(Object[]).
  • invokeDelegateMethodWithArgument
    Invokes the target method with given argument.
  • invokeDelegateMethodWithArguments
    Invokes the target method with given arguments.
  • setArguments
  • setTargetMethod
  • setTargetObject

Popular in Java

  • Creating JSON documents from java classes using gson
  • onRequestPermissionsResult (Fragment)
  • scheduleAtFixedRate (Timer)
    Schedules the specified task for repeated fixed-rate execution, beginning after the specified delay.
  • notifyDataSetChanged (ArrayAdapter)
  • BufferedImage (java.awt.image)
    The BufferedImage subclass describes an java.awt.Image with an accessible buffer of image data. All
  • Properties (java.util)
    The Properties class represents a persistent set of properties. The Properties can be saved to a st
  • Executor (java.util.concurrent)
    An object that executes submitted Runnable tasks. This interface provides a way of decoupling task s
  • JFrame (javax.swing)
  • JTable (javax.swing)
  • Option (scala)
Codota Logo
  • Products

    Search for Java codeSearch for JavaScript codeEnterprise
  • IDE Plugins

    IntelliJ IDEAWebStormAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimAtomGoLandRubyMineEmacsJupyter
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogCodota Academy Plugin user guide Terms of usePrivacy policyJava Code IndexJavascript Code Index
Get Codota for your IDE now