@Override public void advise(MethodInvocation invocation) { invocation.proceed(); Storage storage = (Storage) invocation.getReturnValue(); invocation.setReturnValue(new SecureStorage(storage, indexer, securityManager, appStateManager.getIfExists(JsonSessionState.class))); } };
@Override public void advise(MethodInvocation invocation) { String className = (String) invocation.getParameter(0); final Class<?> replacement = componentReplacer.getReplacement(className); if (replacement != null) { invocation.setParameter(0, replacement.getName()); } invocation.proceed(); } };
@Override protected Object proceed(MethodInvocation invocation) throws Throwable { invocation.proceed(); if (invocation.didThrowCheckedException()) { invocation.rethrow(); } return invocation.getReturnValue(); }
@Override protected Object[] getParameters(MethodInvocation invocation) { Object[] parameters = new Object[invocation.getMethod().getParameterTypes().length]; for (int i = 0; i < parameters.length; i++) { parameters[i] = invocation.getParameter(i); } return parameters; }
public void advise(MethodInvocation invocation) { Class<?>[] parameterTypes = invocation.getMethod().getParameterTypes(); for (int i = 0; i < parameterTypes.length; i++) { if (parameterTypes[i].equals(String.class)) { String value = (String) invocation.getParameter(i); invocation.setParameter(i, reverse(value)); } } invocation.proceed(); if (invocation.getMethod().getReturnType().equals(String.class)) { if (invocation.didThrowCheckedException()) { Exception thrown = invocation.getCheckedException(Exception.class); invocation.setReturnValue(String.format("Invocation of method %s() failed with %s.", invocation.getMethod().getName(), thrown.getClass().getName())); return; } String value = (String) invocation.getReturnValue(); invocation.setReturnValue(reverse(value)); } }
@Override public void run() { invocation.proceed(); } };
public void advise(MethodInvocation invocation) { MethodResultCache cache = getOrCreateCache(invocation); if (cache.isCached()) { invocation.setReturnValue(cache.get()); return; } invocation.proceed(); if(!invocation.didThrowCheckedException()) { cache.set(invocation.getReturnValue()); } }
public void advise(final MethodInvocation invocation) { final ComponentEvent event = (ComponentEvent) invocation.getParameter(0); boolean matches = !event.isAborted() && event.matches(eventType, "", minContextValues); if (matches) { tracker.run(operationDescription, new Runnable() { public void run() { Component instance = (Component) invocation.getInstance(); handler.handleEvent(instance, event); } }); } // Order of operations is key here. This logic takes precedence; base class event dispatch and event handler methods // in the class come AFTER. invocation.proceed(); if (matches) { invocation.setReturnValue(true); } } }
@Override public void advise(MethodInvocation invocation) { final Method method = invocation.getMethod(); boolean annotationFoundInMethod = checkAnnotation(method.getAnnotation(Advise.class)); boolean annotationFoundThroughAnnotationProvider = checkAnnotation(invocation.getAnnotation(Advise.class)); IntermediateType parameterAnnotation = null; final Annotation[][] parameterAnnotations = method.getParameterAnnotations(); if (parameterAnnotations.length > 0 && parameterAnnotations[0].length > 0) { parameterAnnotation = (IntermediateType) parameterAnnotations[0][0]; } boolean annotationParameter = parameterAnnotation != null && parameterAnnotation.value() == String.class; if (annotationFoundInMethod && annotationFoundThroughAnnotationProvider && annotationParameter) { invocation.setReturnValue(ANNOTATION_FOUND); } else { invocation.proceed(); } }
invocation.proceed(); return; invocation.proceed(); if (invocation.didThrowCheckedException()) Exception thrown = invocation.getCheckedException(Exception.class);
public void advise(MethodInvocation invocation) { MarkupWriter writer = (MarkupWriter) invocation.getParameter(0); invocation.proceed(); Element el = writer.getElement().getElementByAttributeValue("class", "t-calendar-trigger"); if(el != null){ el.remove(); } } });
public void advise(MethodInvocation invocation) { invocation.proceed(); Object instance = invocation.getInstance(); for (MethodHandle handle : handles) { handle.invoke(instance); } } });
public void advise(MethodInvocation invocation) { invocation.proceed(); if (invocation.didThrowCheckedException()) return; ComponentResources resources = invocation.getInstanceContext().get(ComponentResources.class); resources.discardPersistentFieldChanges(); } };
public void advise(MethodInvocation invocation) { ComponentResources resources = invocation.getInstanceContext().get(ComponentResources.class); Binding binding = bindingSource.newBinding("@Cached watch", resources, BindingConstants.PROP, watch); bindingFieldHandle.set(invocation.getInstance(), binding); invocation.proceed(); } });
if (invocation.hasAnnotation(CommitAfter.class)) final PersistenceContext annotation = invocation.getAnnotation(PersistenceContext.class); final EntityTransaction transaction = getTransaction(annotation); invocation.proceed(); } catch (final RuntimeException e) invocation.proceed();
public void advise(MethodInvocation invocation) { ComponentResources resources = invocation.getInstanceContext().get(ComponentResources.class); for (ComponentIdValidator validator : validators) { validator.validate(resources); } invocation.proceed(); } }
/** * Invoked when a method exits (possibly returning a value). * * @param invocation identifies method invocation and result value */ public void exit(MethodInvocation invocation) { StringBuilder buffer = new StringBuilder(BUFFER_SIZE); buffer.append(format("[%s] %s", EXIT, invocation.getMethod().getName())); if (invocation.getMethod().getReturnType() != void.class) { buffer.append(" ["); convert(buffer, invocation.getReturnValue()); buffer.append(']'); } logger.debug(buffer.toString()); }
@Override public void advise(MethodInvocation invocation) { try { invocation.setReturnValue(this.cacheResult(cacheContextSource, invocation)); } catch (Throwable e) { throw new RuntimeException(e); } }
@Override protected Method getMethod(MethodInvocation invocation) { return invocation.getMethod(); }
@Override public MethodInvocation invoke() { return invocation.proceed(); } });