Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
  /*
   * JBoss, Home of Professional Open Source
   * Copyright 2013, Red Hat, Inc., 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.interceptor.proxy;
 
 import static org.jboss.weld.interceptor.spi.model.InterceptionType.AROUND_INVOKE;
 import static org.jboss.weld.interceptor.spi.model.InterceptionType.AROUND_TIMEOUT;
 import static org.jboss.weld.interceptor.spi.model.InterceptionType.POST_ACTIVATE;
 import static org.jboss.weld.interceptor.spi.model.InterceptionType.POST_CONSTRUCT;
 import static org.jboss.weld.interceptor.spi.model.InterceptionType.PRE_DESTROY;
 import static org.jboss.weld.interceptor.spi.model.InterceptionType.PRE_PASSIVATE;
 import static org.jboss.weld.util.collections.WeldCollections.immutableMap;
 import static org.jboss.weld.util.reflection.Reflections.cast;
 
 import java.util.List;
 import java.util.Map;
 import java.util.Set;
 
 
 
Holds interceptor metadata and interceptor instances throughout the lifecycle of the intercepted instance.

Author(s):
Jozef Hartinger
 
 public class InterceptionContext implements Serializable {
 
     private static final Set<InterceptionTypeCONSTRUCTOR_INTERCEPTION_TYPES = ImmutableSet.of(.);
 
     public static InterceptionContext forConstructorInterception(InterceptionModel interceptionModelCreationalContext<?> ctxBeanManagerImpl managerSlimAnnotatedType<?> type) {
         return of(interceptionModelctxmanagertype);
     }
 
     public static InterceptionContext forNonConstructorInterception(InterceptionModel interceptionModelCreationalContext<?> ctxBeanManagerImpl managerSlimAnnotatedType<?> type) {
         return of(interceptionModelctxmanagertype);
     }
 
     private static InterceptionContext of(InterceptionModel interceptionModelCreationalContext<?> ctxBeanManagerImpl managerSet<InterceptionTypeinterceptionTypesSlimAnnotatedType<?> type) {
         return new InterceptionContext(initInterceptorInstanceMap(interceptionModelctxmanagerinterceptionTypes), managerinterceptionModeltype);
     }
 
     private static final long serialVersionUID = 7500722360133273633L;
 
     private final transient InterceptionModel interceptionModel;
 
     private final Map<Class<?>, ObjectinterceptorInstances;
     private final BeanManagerImpl manager;
     private final SlimAnnotatedType<?> annotatedType;
 
     private InterceptionContext(Map<Class<?>, ObjectinterceptorInstancesBeanManagerImpl managerInterceptionModel interceptionModelSlimAnnotatedType<?> type) {
         this. = interceptorInstances;
         this. = manager;
         this. = interceptionModel;
         this. = type;
     }
 
     private static Map<Class<?>, ObjectinitInterceptorInstanceMap(InterceptionModel modelCreationalContext ctxBeanManagerImpl managerSet<InterceptionTypeinterceptionTypes) {
         Map<Class<?>, ObjectinterceptorInstances = new HashMap<Class<?>, Object>();
         for (InterceptorClassMetadata<?> interceptor : model.getAllInterceptors()) {
             for (InterceptionType interceptionType : interceptionTypes) {
                 if (interceptor.isEligible(interceptionType)) {
                     interceptorInstances.put(interceptor.getJavaClass(), interceptor.getInterceptorFactory().create(ctxmanager));
                 }
             }
         }
         return immutableMap(interceptorInstances);
     }
 
        return ;
    }
    public <T> T getInterceptorInstance(InterceptorClassMetadata<T> interceptorMetadata) {
        return cast(.get(interceptorMetadata.getJavaClass()));
    }
    private Object readResolve() throws ObjectStreamException {
        InterceptionModel interceptionModel = .getInterceptorModelRegistry().get();
        return new InterceptionContext(interceptionModel);
    }
    public List<InterceptorMethodInvocationbuildInterceptorMethodInvocations(Object instanceMethod methodInterceptionType interceptionType) {
        List<? extends InterceptorClassMetadata<?>> interceptorList = .getInterceptors(interceptionTypemethod);
        List<InterceptorMethodInvocationinterceptorInvocations = new ArrayList<InterceptorMethodInvocation>(interceptorList.size());
        for (InterceptorClassMetadata<?> interceptorMetadata : interceptorList) {
            interceptorInvocations.addAll(interceptorMetadata.getInterceptorInvocation(getInterceptorInstance(interceptorMetadata), interceptionType)
                    .getInterceptorMethodInvocations());
        }
        TargetClassInterceptorMetadata targetClassInterceptorMetadata = getInterceptionModel().getTargetClassInterceptorMetadata();
        if (targetClassInterceptorMetadata != null && targetClassInterceptorMetadata.isEligible(interceptionType)) {
            interceptorInvocations
                    .addAll(targetClassInterceptorMetadata.getInterceptorInvocation(instanceinterceptionType).getInterceptorMethodInvocations());
        }
        return ImmutableList.copyOf(interceptorInvocations);
    }
        List<? extends InterceptorClassMetadata<?>> interceptorList = .getConstructorInvocationInterceptors();
        List<InterceptorMethodInvocationinterceptorInvocations = new ArrayList<InterceptorMethodInvocation>(interceptorList.size());
        for (InterceptorClassMetadata<?> metadata : interceptorList) {
            Object interceptorInstance = getInterceptorInstance(metadata);
            InterceptorInvocation invocation = metadata.getInterceptorInvocation(interceptorInstance.);
            interceptorInvocations.addAll(invocation.getInterceptorMethodInvocations());
        }
        return ImmutableList.copyOf(interceptorInvocations);
    }
New to GrepCode? Check out our FAQ X