Refine search
/** * Gets the current Stack. If the stack is not set, a new empty instance is created and set. * @return */ public static Stack getStack() { Stack stack = interceptionContexts.get(); if (stack == null) { stack = new Stack(interceptionContexts); interceptionContexts.set(stack); } return stack; }
private void push(CombinedInterceptorAndDecoratorStackMethodHandler item) { checkState(); elements.addFirst(item); }
@Override public Object proceed() throws Exception { final Stack stack = InterceptionDecorationContext.startIfNotOnTop(currentHandler); try { return proceedInternal(); } catch (InvocationTargetException e) { throw unwrapInvocationTargetException(e); } finally { if (stack != null) { stack.end(); } } }
/** * Pushes the given context to the stack if the given context is not on top of the stack already. * If push happens, the caller is responsible for calling {@link #endInterceptorContext()} after the invocation finishes. * @param context the given context * @return true if the given context was pushed to the top of the stack, false if the given context was on top already */ public boolean startIfNotOnTop(CombinedInterceptorAndDecoratorStackMethodHandler context) { checkState(); if (elements.isEmpty() || peek() != context) { push(context); return true; } return false; }
private CombinedInterceptorAndDecoratorStackMethodHandler pop() { checkState(); CombinedInterceptorAndDecoratorStackMethodHandler top = elements.removeFirst(); removeIfEmpty(); return top; }
public CombinedInterceptorAndDecoratorStackMethodHandler peek() { checkState(); return elements.peekFirst(); }
/** * Pushes the given context to the stack if the given context is not on top of the stack already. * If this method return a non-null value, the caller is responsible for calling {@link #endInterceptorContext()} * after the invocation finishes. * @param context the given context * @return true if the given context was pushed to the top of the stack, false if the given context was on top already */ public static Stack startIfNotOnTop(CombinedInterceptorAndDecoratorStackMethodHandler context) { Stack stack = getStack(); if (stack.startIfNotOnTop(context)) { return stack; } return null; }
public Object invoke(Stack stack, Object self, Method thisMethod, Method proceed, Object[] args, boolean intercept, boolean popStack) throws Throwable { if (intercept) { try { if (interceptorMethodHandler != null) { if (proceed != null) { if (outerDecorator == null) { // use WeldSubclass.method$$super() as proceed return this.interceptorMethodHandler.invoke(stack, self, thisMethod, proceed, args); } else { return this.interceptorMethodHandler.invoke(stack, outerDecorator, thisMethod, thisMethod, args); } } else { return this.interceptorMethodHandler.invoke(stack, self, thisMethod, null, args); } } else { if (outerDecorator != null) { SecurityActions.ensureAccessible(thisMethod); return Reflections.invokeAndUnwrap(outerDecorator, thisMethod, args); } } } finally { if (popStack) { stack.end(); } } } SecurityActions.ensureAccessible(proceed); return Reflections.invokeAndUnwrap(self, proceed, args); }
stack = InterceptionDecorationContext.startIfNotOnTop(currentHandler); } finally { if (stack != null) { stack.end();
@Override public void invalidate() { /* * This cached item is being invalidated. * It does not necessarily mean that the request is being destroyed - it may just be the case that it is being flushed in the middle * of a request (e.g. for AlterableContext.destroy()). * Therefore, we cannot remove IDC now but we just set removeWhenEmpty flag and let it remove itself once the stack gets empty. */ removeWhenEmpty = true; removeIfEmpty(); }
private static CombinedInterceptorAndDecoratorStackMethodHandler peek(Stack stack) { if (stack == null) { throw new EmptyStackException(); } else { return stack.peek(); } }
/** * Gets the current Stack. If the stack is not set, a new empty instance is created and set. * @return */ public static Stack getStack() { Stack stack = interceptionContexts.get(); if (stack == null) { stack = new Stack(interceptionContexts); interceptionContexts.set(stack); } return stack; }
/** * Gets the current Stack. If the stack is not set, a new empty instance is created and set. * @return */ public static Stack getStack() { Stack stack = interceptionContexts.get(); if (stack == null) { stack = new Stack(interceptionContexts); interceptionContexts.set(stack); } return stack; }
/** * Gets the current Stack. If the stack is not set, a new empty instance is created and set. * @return */ public static Stack getStack() { Stack stack = interceptionContexts.get(); if (stack == null) { stack = new Stack(interceptionContexts); interceptionContexts.set(stack); } return stack; }
@Override public void invalidate() { /* * This cached item is being invalidated. * It does not necessarily mean that the request is being destroyed - it may just be the case that it is being flushed in the middle * of a request (e.g. for AlterableContext.destroy()). * Therefore, we cannot remove IDC now but we just set removeWhenEmpty flag and let it remove itself once the stack gets empty. */ removeWhenEmpty = true; removeIfEmpty(); }
@Override public void invalidate() { /* * This cached item is being invalidated. * It does not necessarily mean that the request is being destroyed - it may just be the case that it is being flushed in the middle * of a request (e.g. for AlterableContext.destroy()). * Therefore, we cannot remove IDC now but we just set removeWhenEmpty flag and let it remove itself once the stack gets empty. */ removeWhenEmpty = true; removeIfEmpty(); }
private static CombinedInterceptorAndDecoratorStackMethodHandler peek(Stack stack) { if (stack == null) { throw new EmptyStackException(); } else { return stack.peek(); } }
public static AroundInvokeInvocationContext create(Object instance, Method method, Method proceed, Object[] args, List<InterceptorMethodInvocation> chain, Set<Annotation> interceptorBindings, Stack stack) { CombinedInterceptorAndDecoratorStackMethodHandler currentHandler = (stack == null) ? null : stack.peek(); if (chain.size() == 1) { return new TerminalAroundInvokeInvocationContext(instance, method, proceed, args, null, interceptorBindings, currentHandler); } else { return new NonTerminalAroundInvokeInvocationContext(instance, method, proceed, args, interceptorBindings, chain, currentHandler); } }
/** * Peeks the current top of the stack or returns null if the stack is empty * @return the current top of the stack or returns null if the stack is empty */ public static CombinedInterceptorAndDecoratorStackMethodHandler peekIfNotEmpty() { Stack stack = interceptionContexts.get(); if (stack == null) { return null; } return stack.peek(); }
private static CombinedInterceptorAndDecoratorStackMethodHandler peek(Stack stack) { if (stack == null) { throw new EmptyStackException(); } else { return stack.peek(); } }