@Override public Object intercept(MethodInvocationContext context) { Object target = context.getTarget(); Lock lock = refreshScope.getLock(target).readLock(); try { lock.lock(); return context.proceed(); } finally { lock.unlock(); } } }
@Override public Object intercept(MethodInvocationContext context) { if (executableValidator == null) { return context.proceed(); } else { Method targetMethod = context.getTargetMethod(); if (targetMethod.getParameterTypes().length == 0) { return context.proceed(); } else { Set<ConstraintViolation<Object>> constraintViolations = executableValidator .validateParameters( context.getTarget(), targetMethod, context.getParameterValues() ); if (constraintViolations.isEmpty()) { return context.proceed(); } else { throw new ConstraintViolationException(constraintViolations); } } } } }
if (LOG.isErrorEnabled()) { LOG.debug(nase.getMessage(), nase); LOG.error("Type [{}] attempting to resolve fallback for unavailable service [{}]", context.getTarget().getClass().getName(), nase.getServiceID()); LOG.error("Type [" + context.getTarget().getClass().getName() + "] executed with error: " + exception.getMessage(), exception); try { if (LOG.isDebugEnabled()) { LOG.debug("Type [{}] resolved fallback: {}", context.getTarget().getClass().getName(), fallbackMethod); throw new FallbackException("Error invoking fallback for type [" + context.getTarget().getClass().getName() + "]: " + e.getMessage(), e);
MethodExecutionHandle<?, Object> fallbackHandle = fallbackMethod.get(); if (LOG.isDebugEnabled()) { LOG.debug("Type [{}] resolved fallback: {}", context.getTarget().getClass(), fallbackHandle);
/** * Finds a fallback method for the given context. * * @param context The context * @return The fallback method if it is present */ public Optional<? extends MethodExecutionHandle<?, Object>> findFallbackMethod(MethodInvocationContext<Object, Object> context) { Class<?> declaringType = context.getTarget().getClass(); Optional<? extends MethodExecutionHandle<?, Object>> result = beanContext .findExecutionHandle(declaringType, Qualifiers.byStereotype(Fallback.class), context.getMethodName(), context.getArgumentTypes()); if (!result.isPresent()) { Set<Class> allInterfaces = ReflectionUtils.getAllInterfaces(declaringType); for (Class i : allInterfaces) { result = beanContext .findExecutionHandle(i, Qualifiers.byStereotype(Fallback.class), context.getMethodName(), context.getArgumentTypes()); if (result.isPresent()) { return result; } } } return result; }
MethodExecutionHandle<?, Object> fallbackHandle = fallbackMethod.get(); if (LOG.isDebugEnabled()) { LOG.debug("Type [{}] resolved fallback: {}", context.getTarget().getClass(), fallbackHandle);