Package javax.interceptor

Examples of javax.interceptor.Interceptors


      List<MetaDataBridge<InterceptorMetaData>> interceptorBridges = new ArrayList<MetaDataBridge<InterceptorMetaData>>();
      interceptorBridges.add(new InterceptorMetaDataBridge());
      repository.addComponentMetaDataLoaderFactory(new InterceptorComponentMetaDataLoaderFactory(interceptorBridges));
      repository.addMetaDataBridge(new BeanInterceptorMetaDataBridge());
     
      Interceptors interceptors = (Interceptors) repository.resolveClassAnnotation(Interceptors.class);
      assertNotNull(interceptors);
      Class<?> expected[] = { DummyInterceptor.class };
      assertArrayEquals(expected, interceptors.value());
     
      Class<?> parameterTypes[] = { InvocationContext.class };
     
      Method aroundInvoke = DummyInterceptor.class.getMethod("aroundInvoke", parameterTypes);
      assertTrue(repository.hasAnnotation(DummyInterceptor.class, aroundInvoke, AroundInvoke.class));
View Full Code Here


                /*
                 * @Interceptors
                 */
                final List<Annotated<Class<?>>> annotatedClasses = sortClasses(annotationFinder.findMetaAnnotatedClasses(Interceptors.class));
                for (final Annotated<Class<?>> interceptorsAnnotatedClass : annotatedClasses) {
                    final Interceptors interceptors = interceptorsAnnotatedClass.getAnnotation(Interceptors.class);
                    final EjbJar ejbJar = ejbModule.getEjbJar();
                    for (final Class interceptor : interceptors.value()) {
                        if (ejbJar.getInterceptor(interceptor.getName()) == null) {
                            ejbJar.addInterceptor(new Interceptor(interceptor.getName()));
                        }
                    }

                    final InterceptorBinding binding = new InterceptorBinding(bean);
                    assemblyDescriptor.getInterceptorBinding().add(0, binding);

                    for (final Class interceptor : interceptors.value()) {
                        binding.getInterceptorClass().add(interceptor.getName());
                    }
                }

                final List<Annotated<Method>> annotatedMethods = sortMethods(annotationFinder.findMetaAnnotatedMethods(Interceptors.class));
                for (final Annotated<Method> method : annotatedMethods) {
                    final Interceptors interceptors = method.getAnnotation(Interceptors.class);
                    if (interceptors != null) {
                        final EjbJar ejbJar = ejbModule.getEjbJar();
                        for (final Class interceptor : interceptors.value()) {
                            if (ejbJar.getInterceptor(interceptor.getName()) == null) {
                                ejbJar.addInterceptor(new Interceptor(interceptor.getName()));
                            }
                        }

                        final InterceptorBinding binding = new InterceptorBinding(bean);
                        assemblyDescriptor.getInterceptorBinding().add(0, binding);

                        for (final Class interceptor : interceptors.value()) {
                            binding.getInterceptorClass().add(interceptor.getName());
                        }

                        binding.setMethod(new NamedMethod(method.get()));
                    }
View Full Code Here

    }

    protected HandlerProcessingResult processAnnotation(AnnotationInfo ainfo,
            EjbContext[] ejbContexts) throws AnnotationProcessorException {

        Interceptors interceptors = (Interceptors) ainfo.getAnnotation();

       
        EjbBundleDescriptorImpl ejbBundle =
            ((EjbDescriptor)ejbContexts[0].getDescriptor()).
                getEjbBundleDescriptor();
       
        // Process each of the interceptor classes.
        for(Class interceptor : interceptors.value()) {
            processInterceptorClass(interceptor, ejbBundle, ainfo);
        }

        for(EjbContext next : ejbContexts) {

            EjbDescriptor ejbDescriptor = (EjbDescriptor) next.getDescriptor();

            // Create binding information. 
            InterceptorBindingDescriptor binding =
                new InterceptorBindingDescriptor();

            binding.setEjbName(ejbDescriptor.getName());

            for(Class interceptor : interceptors.value()) {
                binding.appendInterceptorClass(interceptor.getName());
            }
           
            if(ElementType.METHOD.equals(ainfo.getElementType())) {
                Method m = (Method) ainfo.getAnnotatedElement();
View Full Code Here

        }
    }

    private <T> void collectEjbInterceptors(List<Interceptor<?>> ejbInterceptors, Annotated annotated, boolean unproxyable, Set<Type> types)
    {
        Interceptors interceptorsAnnot = annotated.getAnnotation(Interceptors.class);
        if (interceptorsAnnot != null)
        {
            if (unproxyable)
            {
                throw new WebBeansConfigurationException(annotated + " is not proxyable, but an Interceptor got defined on it!");
            }

            if (types == null)
            {
                types = Collections.emptySet();
            }

            for (Class interceptorClass : interceptorsAnnot.value())
            {
                if (types.contains(interceptorClass)) // don't create another bean for it
                {
                    continue;
                }
View Full Code Here

        }
    }

    private <T> void collectEjbInterceptors(List<Interceptor<?>> ejbInterceptors, Annotated annotated, boolean unproxyable, Set<Type> types)
    {
        Interceptors interceptorsAnnot = annotated.getAnnotation(Interceptors.class);
        if (interceptorsAnnot != null)
        {
            if (unproxyable)
            {
                throw new WebBeansConfigurationException(annotated + " is not proxyable, but an Interceptor got defined on it!");
            }

            if (types == null)
            {
                types = Collections.emptySet();
            }

            for (Class interceptorClass : interceptorsAnnot.value())
            {
                if (types.contains(interceptorClass)) // don't create another bean for it
                {
                    continue;
                }
View Full Code Here

      if (!isExcludedDefaultInterceptors(advisor))
      {
         lifecycleInterceptorClasses.addAll(defaultInterceptorClasses);
      }
     
      Interceptors interceptorsAnnotation = (Interceptors) advisor.resolveAnnotation(Interceptors.class);
      List<Class<?>> classInterceptorClasses = new ArrayList<Class<?>>();
      if(interceptorsAnnotation != null)
      {
         for(Class<?> classInterceptorClass : interceptorsAnnotation.value())
         {
            classInterceptorClasses.add(classInterceptorClass);
//            if(!interceptorClasses.contains(classInterceptorClass))
//               interceptorClasses.add(classInterceptorClass);
            if(!lifecycleInterceptorClasses.contains(classInterceptorClass))
               lifecycleInterceptorClasses.add(classInterceptorClass);
         }
      }
      log.debug("Found class interceptors " + classInterceptorClasses);
     
      {
         // Ordering of lifecycle interceptors
         InterceptorOrder order = (InterceptorOrder) advisor.resolveAnnotation(InterceptorOrder.class);
         if(order != null)
         {
            List<Class<?>> orderedInterceptorClasses = Arrays.asList(order.value());
            if(!orderedInterceptorClasses.containsAll(lifecycleInterceptorClasses))
               throw new IllegalStateException("EJB3 12.8.2 footnote 59: all applicable lifecycle interceptors must be listed in the interceptor order");
            lifecycleInterceptorClasses = orderedInterceptorClasses;
         }
      }
      this.lifecycleInterceptorClasses.addAll(lifecycleInterceptorClasses);
      for(Class<?> interceptorClass : lifecycleInterceptorClasses)
      {
         if(!interceptorClasses.contains(interceptorClass))
            interceptorClasses.add(interceptorClass);
      }
     
      Class<?> beanClass = advisor.getClazz();
      for(Method beanMethod : ClassHelper.getAllMethods(beanClass))
      {
         interceptorsAnnotation = (Interceptors) advisor.resolveAnnotation(beanMethod, Interceptors.class);
         List<Class<?>> methodInterceptorClasses = new ArrayList<Class<?>>();
         if(interceptorsAnnotation != null)
         {
            for(Class<?> interceptorClass : interceptorsAnnotation.value())
               methodInterceptorClasses.add(interceptorClass);
         }
        
         // Interceptors applicable for this bean method
         List<Class<?>> methodApplicableInterceptorClasses = new ArrayList<Class<?>>();
View Full Code Here

    */
   private void addClassLevelInterceptorBindingAnnotations(
         EJBContainer container, InterceptorBindingMetaData binding)
         throws ClassNotFoundException
   {
      Interceptors interceptors = (Interceptors) container
            .resolveAnnotation(Interceptors.class);
      if (binding != null)
      {
         Interceptors impl = createInterceptorsFromInterceptorBinding(interceptors, binding);

         addClassAnnotation(container, impl.annotationType(), impl);
      }

      boolean exclude = false;
      if (binding != null)
         exclude = binding.isExcludeDefaultInterceptors();
View Full Code Here

                /*
                 * @Interceptors
                 */
                final List<Annotated<Class<?>>> annotatedClasses = sortClasses(annotationFinder.findMetaAnnotatedClasses(Interceptors.class));
                for (Annotated<Class<?>> interceptorsAnnotatedClass : annotatedClasses) {
                    Interceptors interceptors = interceptorsAnnotatedClass.getAnnotation(Interceptors.class);
                    EjbJar ejbJar = ejbModule.getEjbJar();
                    for (Class interceptor : interceptors.value()) {
                        if (ejbJar.getInterceptor(interceptor.getName()) == null) {
                            ejbJar.addInterceptor(new Interceptor(interceptor.getName()));
                        }
                    }

                    InterceptorBinding binding = new InterceptorBinding(bean);
                    assemblyDescriptor.getInterceptorBinding().add(0, binding);

                    for (Class interceptor : interceptors.value()) {
                        binding.getInterceptorClass().add(interceptor.getName());
                    }
                }

                final List<Annotated<Method>> annotatedMethods = sortMethods(annotationFinder.findMetaAnnotatedMethods(Interceptors.class));
                for (Annotated<Method> method : annotatedMethods) {
                    Interceptors interceptors = method.getAnnotation(Interceptors.class);
                    if (interceptors != null) {
                        EjbJar ejbJar = ejbModule.getEjbJar();
                        for (Class interceptor : interceptors.value()) {
                            if (ejbJar.getInterceptor(interceptor.getName()) == null) {
                                ejbJar.addInterceptor(new Interceptor(interceptor.getName()));
                            }
                        }

                        InterceptorBinding binding = new InterceptorBinding(bean);
                        assemblyDescriptor.getInterceptorBinding().add(0, binding);

                        for (Class interceptor : interceptors.value()) {
                            binding.getInterceptorClass().add(interceptor.getName());
                        }

                        binding.setMethod(new NamedMethod(method.get()));
                    }
View Full Code Here

/* 54 */     super(finder);
/*    */   }
/*    */
/*    */   public void process(InterceptorBindingsMetaData metaData, T type)
/*    */   {
/* 59 */     Interceptors interceptors = (Interceptors)this.finder.getAnnotation(type, Interceptors.class);
/* 60 */     if (interceptors == null)
/* 61 */       return;
/* 62 */     ExcludeClassInterceptors excludeClass = (ExcludeClassInterceptors)this.finder.getAnnotation(type, ExcludeClassInterceptors.class);
/* 63 */     ExcludeDefaultInterceptors excludeDefaults = (ExcludeDefaultInterceptors)this.finder.getAnnotation(type, ExcludeDefaultInterceptors.class);
/*    */
/* 65 */     Method method = null;
/* 66 */     if ((type instanceof Method)) {
/* 67 */       method = (Method)type;
/*    */     }
/* 69 */     String ejbName = (String)EjbNameThreadLocal.ejbName.get();
/* 70 */     InterceptorBindingMetaData interceptor = new InterceptorBindingMetaData();
/* 71 */     interceptor.setEjbName(ejbName);
/* 72 */     interceptor.setExcludeClassInterceptors(excludeClass != null);
/* 73 */     interceptor.setExcludeDefaultInterceptors(excludeDefaults != null);
/* 74 */     if (method != null)
/*    */     {
/* 76 */       NamedMethodMetaData namedMethod = new NamedMethodMetaData();
/* 77 */       namedMethod.setMethodName(method.getName());
/* 78 */       MethodParametersMetaData methodParams = ProcessorUtils.getMethodParameters(method);
/* 79 */       namedMethod.setMethodParams(methodParams);
/* 80 */       interceptor.setMethod(namedMethod);
/*    */     }
/* 82 */     InterceptorClassesMetaData classes = new InterceptorClassesMetaData();
/* 83 */     for (Class c : interceptors.value())
/*    */     {
/* 85 */       classes.add(c.getName());
/*    */     }
/* 87 */     interceptor.setInterceptorClasses(classes);
/*    */
View Full Code Here

/*      */   }
/*      */
/*      */   private void addClassLevelInterceptorBindingAnnotations(EJBContainer container, InterceptorBindingMetaData binding)
/*      */     throws ClassNotFoundException
/*      */   {
/* 1239 */     Interceptors interceptors = (Interceptors)container.resolveAnnotation(Interceptors.class);
/*      */
/* 1241 */     if (binding != null)
/*      */     {
/* 1243 */       Interceptors impl = createInterceptorsFromInterceptorBinding(interceptors, binding);
/*      */
/* 1245 */       addClassAnnotation(container, impl.annotationType(), impl);
/*      */     }
/*      */
/* 1248 */     boolean exclude = false;
/* 1249 */     if (binding != null)
/* 1250 */       exclude = binding.isExcludeDefaultInterceptors();
View Full Code Here

TOP

Related Classes of javax.interceptor.Interceptors

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.