@Override public void addTransactionCommitAdvice(MethodAdviceReceiver receiver) { for (Method m : receiver.getInterface().getMethods()) { if (m.getAnnotation(CommitAfter.class) != null) { receiver.adviseMethod(m, advice); } } } }
@Override public void addTransactionCommitAdvice(MethodAdviceReceiver receiver) { for (Method m : receiver.getInterface().getMethods()) { if (m.getAnnotation(CommitAfter.class) != null) { receiver.adviseMethod(m, advice); } } } }
@Override public void addLazyMethodInvocationAdvice(MethodAdviceReceiver methodAdviceReceiver) { for (Method m : methodAdviceReceiver.getInterface().getMethods()) { if (filter(m)) addAdvice(m, methodAdviceReceiver); } }
@SuppressWarnings("unchecked") public void addTransactionCommitAdvice(MethodAdviceReceiver receiver) { if (receiver.getInterface().getAnnotation(Transactional.class) != null) { Transactional annotation = (Transactional) receiver.getInterface().getAnnotation(Transactional.class); if (isIntercepted(annotation)) { for (Method m : receiver.getInterface().getMethods()) { if (m.getAnnotation(NotTransactional.class) == null) { receiver.adviseMethod(m, advice); } } } } else { for (Method m : receiver.getInterface().getMethods()) { if (m.getAnnotation(Transactional.class) != null) { Transactional annotation = m.getAnnotation(Transactional.class); if (isIntercepted(annotation)) { receiver.adviseMethod(m, advice); } } } } }
@Override public void addLazyMethodInvocationAdvice(MethodAdviceReceiver methodAdviceReceiver) { for (Method m : methodAdviceReceiver.getInterface().getMethods()) { if (filter(m)) addAdvice(m, methodAdviceReceiver); } }
@Override public void addTransactionCommitAdvice(MethodAdviceReceiver receiver) { for (final Method m : receiver.getInterface().getMethods()) { if (m.getAnnotation(CommitAfter.class) != null) { PersistenceContext annotation = receiver.getMethodAnnotation(m, PersistenceContext.class); receiver.adviseMethod(m, methodAdvices.get(annotation == null ? null : annotation.unitName())); } } }
@Match("ScriptingServices") public static void adviseSafe(final Logger log, final ApplicationStateManager appStateManager, final Indexer indexer, final PortalSecurityManager securityManager, MethodAdviceReceiver receiver) { MethodAdvice advice = new MethodAdvice() { @Override public void advise(MethodInvocation invocation) { invocation.proceed(); Storage storage = (Storage) invocation.getReturnValue(); invocation.setReturnValue(new SecureStorage(storage, indexer, securityManager, appStateManager.getIfExists(JsonSessionState.class))); } }; try { Method method = receiver.getInterface().getMethod("getStorage", new Class[]{}); receiver.adviseMethod(method, advice); } catch (Exception e) { log.error("Failed to advise: {}", e.getMessage()); } }
@Override public void addOperationAdvice(MethodAdviceReceiver receiver) { for (Method m : receiver.getInterface().getMethods()) { Operation annotation = receiver.getMethodAnnotation(m, Operation.class); if (annotation != null) { String value = annotation.value(); receiver.adviseMethod(m, createAdvice(value)); } } }
Method method = receiver.getInterface().getMethod("search", new Class[]{SearchRequest.class, OutputStream.class}); receiver.adviseMethod(method, advice);
@Override public void addOperationAdvice(MethodAdviceReceiver receiver) { for (Method m : receiver.getInterface().getMethods()) { Operation annotation = receiver.getMethodAnnotation(m, Operation.class); if (annotation != null) { String value = annotation.value(); receiver.adviseMethod(m, createAdvice(value)); } } }
@Order("after:Logging") public static void adviseGreeter(MethodAdviceReceiver receiver) { MethodAdvice advice = new MethodAdvice() { @Override public void advise(MethodInvocation invocation) { invocation.proceed(); String result = (String) invocation.getReturnValue(); if (result != null) invocation.setReturnValue(result.toUpperCase()); } }; for (Method m : receiver.getInterface().getMethods()) { if (m.getReturnType().equals(String.class)) { receiver.adviseMethod(m, advice); } } } }
private static void advise(Class<? extends Annotation> annotationClass, ObjectLocator objectLocator, Class<? extends CacheMethodAdvice> adviceClass, MethodAdviceReceiver methodAdviceReceiver) { // TAP5-2466: create the advice on-demand to avoid recursion issues MethodAdvice advice = null; if (methodAdviceReceiver.getClassAnnotationProvider().getAnnotation(annotationClass) != null) { advice = build(objectLocator, adviceClass); methodAdviceReceiver.adviseAllMethods(advice); } else { for (Method method : methodAdviceReceiver.getInterface().getMethods()) { if (methodAdviceReceiver.getMethodAnnotation(method, annotationClass) != null) { if(advice== null) { advice = build(objectLocator, adviceClass); } methodAdviceReceiver.adviseMethod(method, advice); } } } }