Tabnine Logo
MethodExecutionAction
Code IndexAdd Tabnine to your IDE (free)

How to use
MethodExecutionAction
in
com.netflix.hystrix.contrib.javanica.command

Best Java code snippets using com.netflix.hystrix.contrib.javanica.command.MethodExecutionAction (Showing top 18 results out of 315)

origin: PipelineAI/pipeline

private CommandAction createCommandAction(MetaHolder metaHolder) {
  return new MethodExecutionAction(metaHolder.getObj(), metaHolder.getMethod(), metaHolder.getArgs(), metaHolder);
}
origin: PipelineAI/pipeline

/**
 * Invokes the method. Also private method also can be invoked.
 *
 * @return result of execution
 */
@Override
public Object executeWithArgs(ExecutionType executionType, Object[] args) throws CommandActionExecutionException {
  if(ExecutionType.ASYNCHRONOUS == executionType){
    Closure closure = AsyncClosureFactory.getInstance().createClosure(metaHolder, method, object, args);
    return executeClj(closure.getClosureObj(), closure.getClosureMethod());
  }
  return execute(object, method, args);
}
origin: PipelineAI/pipeline

@Override
public Object execute(ExecutionType executionType) throws CommandActionExecutionException {
  return executeWithArgs(executionType, _args);
}
origin: PipelineAI/pipeline

private Object executeClj(Object o, Method m, Object... args){
  Object result = null;
  try {
    m.setAccessible(true); // suppress Java language access
    result = m.invoke(o, args);
  } catch (IllegalAccessException e) {
    propagateCause(e);
  } catch (InvocationTargetException e) {
    propagateCause(e);
  }
  return result;
}
origin: PipelineAI/pipeline

/**
 * Gets method name to be used to get a key for request caching.
 *
 * @return method name
 */
public String getCacheKeyMethodName() {
  return cacheKeyMethod != null ? cacheKeyMethod.getMethod().getName() : null;
}
origin: PipelineAI/pipeline

public HystrixGeneratedCacheKey generateCacheKey(CacheInvocationContext<? extends Annotation> cacheInvocationContext) throws HystrixCacheKeyGenerationException {
  MethodExecutionAction cacheKeyMethod = cacheInvocationContext.getCacheKeyMethod();
  if (cacheKeyMethod != null) {
    try {
      return new DefaultHystrixGeneratedCacheKey((String) cacheKeyMethod.execute(cacheInvocationContext.getExecutionType()));
    } catch (Throwable throwable) {
      throw new HystrixCacheKeyGenerationException(throwable);
    }
  } else {
    if (cacheInvocationContext.hasKeyParameters()) {
      StringBuilder cacheKeyBuilder = new StringBuilder();
      for (CacheInvocationParameter parameter : cacheInvocationContext.getKeyParameters()) {
        CacheKey cacheKey = parameter.getCacheKeyAnnotation();
        if (cacheKey != null && StringUtils.isNotBlank(cacheKey.value())) {
          appendPropertyValue(cacheKeyBuilder, Arrays.asList(StringUtils.split(cacheKey.value(), ".")), parameter.getValue());
        } else {
          cacheKeyBuilder.append(parameter.getValue());
        }
      }
      return new DefaultHystrixGeneratedCacheKey(cacheKeyBuilder.toString());
    } else {
      return DefaultHystrixGeneratedCacheKey.EMPTY;
    }
  }
}
origin: PipelineAI/pipeline

/**
 * Invokes the method.
 *
 * @return result of execution
 */
private Object execute(Object o, Method m, Object... args) throws CommandActionExecutionException {
  Object result = null;
  try {
    m.setAccessible(true); // suppress Java language access
    if (isCompileWeaving() && metaHolder.getAjcMethod() != null) {
      result = invokeAjcMethod(metaHolder.getAjcMethod(), o, metaHolder, args);
    } else {
      result = m.invoke(o, args);
    }
  } catch (IllegalAccessException e) {
    propagateCause(e);
  } catch (InvocationTargetException e) {
    propagateCause(e);
  }
  return result;
}
origin: com.netflix.hystrix/hystrix-javanica

/**
 * Gets method name to be used to get a key for request caching.
 *
 * @return method name
 */
public String getCacheKeyMethodName() {
  return cacheKeyMethod != null ? cacheKeyMethod.getMethod().getName() : null;
}
origin: com.netflix.hystrix/hystrix-javanica

public HystrixGeneratedCacheKey generateCacheKey(CacheInvocationContext<? extends Annotation> cacheInvocationContext) throws HystrixCacheKeyGenerationException {
  MethodExecutionAction cacheKeyMethod = cacheInvocationContext.getCacheKeyMethod();
  if (cacheKeyMethod != null) {
    try {
      return new DefaultHystrixGeneratedCacheKey((String) cacheKeyMethod.execute(cacheInvocationContext.getExecutionType()));
    } catch (Throwable throwable) {
      throw new HystrixCacheKeyGenerationException(throwable);
    }
  } else {
    if (cacheInvocationContext.hasKeyParameters()) {
      StringBuilder cacheKeyBuilder = new StringBuilder();
      for (CacheInvocationParameter parameter : cacheInvocationContext.getKeyParameters()) {
        CacheKey cacheKey = parameter.getCacheKeyAnnotation();
        if (cacheKey != null && StringUtils.isNotBlank(cacheKey.value())) {
          appendPropertyValue(cacheKeyBuilder, Arrays.asList(StringUtils.split(cacheKey.value(), ".")), parameter.getValue());
        } else {
          cacheKeyBuilder.append(parameter.getValue());
        }
      }
      return new DefaultHystrixGeneratedCacheKey(cacheKeyBuilder.toString());
    } else {
      return DefaultHystrixGeneratedCacheKey.EMPTY;
    }
  }
}
origin: com.netflix.hystrix/hystrix-javanica

/**
 * Invokes the method. Also private method also can be invoked.
 *
 * @return result of execution
 */
@Override
public Object executeWithArgs(ExecutionType executionType, Object[] args) throws CommandActionExecutionException {
  if(ExecutionType.ASYNCHRONOUS == executionType){
    Closure closure = AsyncClosureFactory.getInstance().createClosure(metaHolder, method, object, args);
    return executeClj(closure.getClosureObj(), closure.getClosureMethod());
  }
  return execute(object, method, args);
}
origin: PipelineAI/pipeline

private static MethodExecutionAction createCacheKeyAction(String method, MetaHolder metaHolder) {
  MethodExecutionAction cacheKeyAction = null;
  if (StringUtils.isNotBlank(method)) {
    Method cacheKeyMethod = getDeclaredMethod(metaHolder.getObj().getClass(), method,
        metaHolder.getMethod().getParameterTypes());
    if (cacheKeyMethod == null) {
      throw new HystrixCachingException("method with name '" + method + "' doesn't exist in class '"
          + metaHolder.getObj().getClass() + "'");
    }
    if (!cacheKeyMethod.getReturnType().equals(String.class)) {
      throw new HystrixCachingException("return type of cacheKey method must be String. Method: '" + method + "', Class: '"
          + metaHolder.getObj().getClass() + "'");
    }
    MetaHolder cMetaHolder = MetaHolder.builder().obj(metaHolder.getObj()).method(cacheKeyMethod).args(metaHolder.getArgs()).build();
    cacheKeyAction = new MethodExecutionAction(cMetaHolder.getObj(), cacheKeyMethod, cMetaHolder.getArgs(), cMetaHolder);
  }
  return cacheKeyAction;
}
origin: com.netflix.hystrix/hystrix-javanica

private Object executeClj(Object o, Method m, Object... args){
  Object result = null;
  try {
    m.setAccessible(true); // suppress Java language access
    result = m.invoke(o, args);
  } catch (IllegalAccessException e) {
    propagateCause(e);
  } catch (InvocationTargetException e) {
    propagateCause(e);
  }
  return result;
}
origin: com.netflix.hystrix/hystrix-javanica

@Override
public Object execute(ExecutionType executionType) throws CommandActionExecutionException {
  return executeWithArgs(executionType, _args);
}
origin: PipelineAI/pipeline

fallbackAction = new MethodExecutionAction(fmMetaHolder.getObj(), fMethod, fmMetaHolder.getArgs(), fmMetaHolder);
origin: com.netflix.hystrix/hystrix-javanica

/**
 * Invokes the method.
 *
 * @return result of execution
 */
private Object execute(Object o, Method m, Object... args) throws CommandActionExecutionException {
  Object result = null;
  try {
    m.setAccessible(true); // suppress Java language access
    if (isCompileWeaving() && metaHolder.getAjcMethod() != null) {
      result = invokeAjcMethod(metaHolder.getAjcMethod(), o, metaHolder, args);
    } else {
      result = m.invoke(o, args);
    }
  } catch (IllegalAccessException e) {
    propagateCause(e);
  } catch (InvocationTargetException e) {
    propagateCause(e);
  }
  return result;
}
origin: com.netflix.hystrix/hystrix-javanica

private CommandAction createCommandAction(MetaHolder metaHolder) {
  return new MethodExecutionAction(metaHolder.getObj(), metaHolder.getMethod(), metaHolder.getArgs(), metaHolder);
}
origin: com.netflix.hystrix/hystrix-javanica

private static MethodExecutionAction createCacheKeyAction(String method, MetaHolder metaHolder) {
  MethodExecutionAction cacheKeyAction = null;
  if (StringUtils.isNotBlank(method)) {
    Method cacheKeyMethod = getDeclaredMethod(metaHolder.getObj().getClass(), method,
        metaHolder.getMethod().getParameterTypes());
    if (cacheKeyMethod == null) {
      throw new HystrixCachingException("method with name '" + method + "' doesn't exist in class '"
          + metaHolder.getObj().getClass() + "'");
    }
    if (!cacheKeyMethod.getReturnType().equals(String.class)) {
      throw new HystrixCachingException("return type of cacheKey method must be String. Method: '" + method + "', Class: '"
          + metaHolder.getObj().getClass() + "'");
    }
    MetaHolder cMetaHolder = MetaHolder.builder().obj(metaHolder.getObj()).method(cacheKeyMethod).args(metaHolder.getArgs()).build();
    cacheKeyAction = new MethodExecutionAction(cMetaHolder.getObj(), cacheKeyMethod, cMetaHolder.getArgs(), cMetaHolder);
  }
  return cacheKeyAction;
}
origin: com.netflix.hystrix/hystrix-javanica

fallbackAction = new MethodExecutionAction(fmMetaHolder.getObj(), fMethod, fmMetaHolder.getArgs(), fmMetaHolder);
com.netflix.hystrix.contrib.javanica.commandMethodExecutionAction

Javadoc

This implementation invokes methods using java reflection. If Method#invoke(Object,Object...) throws exception then this exception is wrapped to CommandActionExecutionExceptionfor further unwrapping and processing.

Most used methods

  • <init>
  • execute
    Invokes the method.
  • executeClj
  • executeWithArgs
    Invokes the method. Also private method also can be invoked.
  • getMethod
  • propagateCause
    Retrieves cause exception and wraps to CommandActionExecutionException.

Popular in Java

  • Running tasks concurrently on multiple threads
  • addToBackStack (FragmentTransaction)
  • notifyDataSetChanged (ArrayAdapter)
  • scheduleAtFixedRate (Timer)
  • UnknownHostException (java.net)
    Thrown when a hostname can not be resolved.
  • Path (java.nio.file)
  • DateFormat (java.text)
    Formats or parses dates and times.This class provides factories for obtaining instances configured f
  • HashMap (java.util)
    HashMap is an implementation of Map. All optional operations are supported.All elements are permitte
  • StringTokenizer (java.util)
    Breaks a string into tokens; new code should probably use String#split.> // Legacy code: StringTo
  • JFileChooser (javax.swing)
  • Top Sublime Text plugins
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