Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
  /*
   * JBoss, Home of Professional Open Source
   * Copyright 2010, Red Hat, Inc. and/or its affiliates, and individual
   * contributors by the @authors tag. See the copyright.txt in the
   * distribution for a full listing of individual contributors.
   *
   * Licensed under the Apache License, Version 2.0 (the "License");
   * you may not use this file except in compliance with the License.
   * You may obtain a copy of the License at
  * http://www.apache.org/licenses/LICENSE-2.0
  * Unless required by applicable law or agreed to in writing, software
  * distributed under the License is distributed on an "AS IS" BASIS,
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
 
 package org.jboss.weld.bean.proxy;
 
 import java.util.List;
 import java.util.Set;

A class that holds the interception (and decoration) contexts which are currently in progress.

An interception context is a set of CombinedInterceptorAndDecoratorStackMethodHandler references for which interception is currently suppressed (so that self-invocation is not possible). Such references are added as soon as a CombinedMethodHandler is executed in an interception context that does not hold it.

Classes may create new interception contexts as necessary (e.g. allowing client proxies to create new interception contexts in order to make circular references interceptable multiple times).

Author(s):
Marius Bogoevici
 
 
     private InterceptionDecorationContext() {
     }
 
         if (stack == null) {
             throw new EmptyStackException();
         } else {
             try {
                 return stack.remove(stack.size() - 1);
             } finally {
                 if (stack.isEmpty()) {
                     .remove();
                 }
             }
         }
     }
 
         if (stack == null) {
             stack = new ArrayList<Set<CombinedInterceptorAndDecoratorStackMethodHandler>>();
             .set(stack);
         }
         stack.add(item);
         return item;
     }
 
         if (stack == null) {
             throw new EmptyStackException();
         } else {
             int last = stack.size() - 1;
             Set<CombinedInterceptorAndDecoratorStackMethodHandlerresult = stack.get(last);
             if (result == null) {
                 result = new HashSet<CombinedInterceptorAndDecoratorStackMethodHandler>();
                 stack.set(lastresult);
             }
             return result;
         }
     }
 
     public static boolean empty() {
         if (stack == null) {
             return true;
         } else {
             return stack.isEmpty();
         }
     }
 
 
     public static void endInterceptorContext() {
         pop();
     }
 
     public static void startInterceptorContext() {
        push(null);
    }

    
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 endInterceptorContext() after the invocation finishes.

Parameters:
context the given context
Returns:
true if the given context was pushed to the top of the stack, false if the given context was on top already
    public static boolean pushIfNotOnTop(Set<CombinedInterceptorAndDecoratorStackMethodHandlercontext) {
        if (empty() || peek() != context) { // == used intentionally instead of equals
            push(context);
            return true;
        }
        return false;
    }
New to GrepCode? Check out our FAQ X