/** * Find the bean name for the current invocation. Assumes that an ExposeBeanNameAdvisor * has been included in the interceptor chain, and that the invocation is exposed * with ExposeInvocationInterceptor. * @return the bean name (never {@code null}) * @throws IllegalStateException if the bean name has not been exposed */ public static String getBeanName() throws IllegalStateException { return getBeanName(ExposeInvocationInterceptor.currentInvocation()); }
/** * Get the current join point match at the join point we are being dispatched on. */ @Nullable protected JoinPointMatch getJoinPointMatch() { MethodInvocation mi = ExposeInvocationInterceptor.currentInvocation(); if (!(mi instanceof ProxyMethodInvocation)) { throw new IllegalStateException("MethodInvocation is not a Spring ProxyMethodInvocation: " + mi); } return getJoinPointMatch((ProxyMethodInvocation) mi); }
@Override public Object getTarget() throws Exception { MethodInvocation invocation = ExposeInvocationInterceptor.currentInvocation(); return TransactionSynchronizationManager.getResource(invocation.getMethod()); }
@Override public Object invoke(MethodInvocation invocation) throws Throwable { if (!context) { assertNoInvocationContext(); } else { assertNotNull("have context", ExposeInvocationInterceptor.currentInvocation()); } return s; } };
/** * Throw an exception if there is an Invocation. */ private void assertNoInvocationContext() { try { ExposeInvocationInterceptor.currentInvocation(); fail("Expected no invocation context"); } catch (IllegalStateException ex) { // ok } }
/** * Lazily instantiate joinpoint for the current invocation. * Requires MethodInvocation to be bound with ExposeInvocationInterceptor. * <p>Do not use if access is available to the current ReflectiveMethodInvocation * (in an around advice). * @return current AspectJ joinpoint, or through an exception if we're not in a * Spring AOP invocation. */ public static JoinPoint currentJoinPoint() { MethodInvocation mi = ExposeInvocationInterceptor.currentInvocation(); if (!(mi instanceof ProxyMethodInvocation)) { throw new IllegalStateException("MethodInvocation is not a Spring ProxyMethodInvocation: " + mi); } ProxyMethodInvocation pmi = (ProxyMethodInvocation) mi; JoinPoint jp = (JoinPoint) pmi.getUserAttribute(JOIN_POINT_KEY); if (jp == null) { jp = new MethodInvocationProceedingJoinPoint(pmi); pmi.setUserAttribute(JOIN_POINT_KEY, jp); } return jp; }
@Override public Object invoke(MethodInvocation mi) throws Throwable { String task = "get invocation on way IN"; try { MethodInvocation current = ExposeInvocationInterceptor.currentInvocation(); assertEquals(mi.getMethod(), current.getMethod()); Object retval = mi.proceed(); task = "get invocation on way OUT"; assertEquals(current, ExposeInvocationInterceptor.currentInvocation()); return retval; } catch (IllegalStateException ex) { System.err.println(task + " for " + mi.getMethod()); ex.printStackTrace(); throw ex; } } }
@Override public String getName() { MethodInvocation invocation = ExposeInvocationInterceptor.currentInvocation(); assertions(invocation); return super.getName(); }
@Override public String getName() { MethodInvocation invocation = ExposeInvocationInterceptor.currentInvocation(); assertions(invocation); return super.getName(); }
@Override public void absquatulate() { MethodInvocation invocation = ExposeInvocationInterceptor.currentInvocation(); assertions(invocation); super.absquatulate(); }
@Override public void absquatulate() { MethodInvocation invocation = ExposeInvocationInterceptor.currentInvocation(); assertions(invocation); super.absquatulate(); }
Object thisObject = null; try { MethodInvocation mi = ExposeInvocationInterceptor.currentInvocation(); targetObject = mi.getThis(); if (!(mi instanceof ProxyMethodInvocation)) {
@Override public View getView() { final MethodInvocation invocation = ExposeInvocationInterceptor.currentInvocation(); final Map<Object, Object> map = VIEW_METADATA.get(); return (map == null) ? null : (View) map.get(invocation.getMethod()); }
@Override public View getView() { final MethodInvocation invocation = ExposeInvocationInterceptor.currentInvocation(); final Map<Object, Object> map = VIEW_METADATA.get(); return (map == null) ? null : (View) map.get(invocation.getMethod()); }
@Override public Object getTarget() throws Exception { MethodInvocation invocation = ExposeInvocationInterceptor.currentInvocation(); return TransactionSynchronizationManager.getResource(invocation.getMethod()); }
@Override public Object getTarget() throws Exception { MethodInvocation invocation = ExposeInvocationInterceptor.currentInvocation(); return TransactionSynchronizationManager.getResource(invocation.getMethod()); }
/** * Get the current join point match at the join point we are being dispatched on. */ @Nullable protected JoinPointMatch getJoinPointMatch() { MethodInvocation mi = ExposeInvocationInterceptor.currentInvocation(); if (!(mi instanceof ProxyMethodInvocation)) { throw new IllegalStateException("MethodInvocation is not a Spring ProxyMethodInvocation: " + mi); } return getJoinPointMatch((ProxyMethodInvocation) mi); }
@Override public Object getTarget() throws Exception { MethodInvocation invocation = ExposeInvocationInterceptor.currentInvocation(); return TransactionSynchronizationManager.getResource(invocation.getMethod()); }
/** * Find the bean name for the current invocation. Assumes that an ExposeBeanNameAdvisor * has been included in the interceptor chain, and that the invocation is exposed * with ExposeInvocationInterceptor. * @return the bean name (never {@code null}) * @throws IllegalStateException if the bean name has not been exposed */ public static String getBeanName() throws IllegalStateException { return getBeanName(ExposeInvocationInterceptor.currentInvocation()); }
/** * Find the bean name for the current invocation. Assumes that an ExposeBeanNameAdvisor * has been included in the interceptor chain, and that the invocation is exposed * with ExposeInvocationInterceptor. * @return the bean name (never {@code null}) * @throws IllegalStateException if the bean name has not been exposed */ public static String getBeanName() throws IllegalStateException { return getBeanName(ExposeInvocationInterceptor.currentInvocation()); }