Examples of Synthetic


Examples of org.infinispan.cdi.util.Synthetic

            for (Bean<?> processedBean : processedBeans) {
                Iterator<Entry<Synthetic, DefaultBeanType>> it = beanTypeInformation.entrySet().iterator();
                while (it.hasNext()) {
                    Entry<Synthetic, DefaultBeanType> definition = it.next();
                    if (definition.getValue().matches(processedBean)) {
                        Synthetic qual = definition.getKey();
                        Bean<?> bean = null;
                        // remove the default bean from the beans to be installed
                        bean = defaultManagedBeans.remove(qual);
                        if (bean == null) {
                            bean = defaultProducerMethods.remove(qual);
                        }
                        if (bean == null) {
                            bean = defaultProducerFields.remove(qual);
                        }
                        log.info("Preventing install of default bean " + bean);
                        it.remove();
                    }
                }
            }
        }
        Set<Synthetic> allDefaultBeanQualifiers = new HashSet<Synthetic>(defaultManagedBeans.keySet());
        allDefaultBeanQualifiers.addAll(defaultProducerFields.keySet());
        allDefaultBeanQualifiers.addAll(defaultProducerMethods.keySet());

        for (Synthetic qual : allDefaultBeanQualifiers) {
            final DefaultBeanType beanInfo = beanTypeInformation.get(qual);
            final HashSet<Type> types = new HashSet<Type>();
            types.add(Object.class);
            types.add(beanInfo.getType());
            final Set<Annotation> qualifiers = new HashSet<Annotation>(beanInfo.getQualifiers());
            if (defaultManagedBeans.containsKey(qual)) {
                Bean<?> db = DefaultManagedBean.of(defaultManagedBeans.get(qual), beanInfo.getType(), types, qualifiers, manager);
                log.debug("Installing default managed bean " + db);
                event.addBean(db);
                fireBeanInstalledEvent(db, manager);
            } else if (defaultProducerMethods.containsKey(qual)) {
                Synthetic declaringDefaultBean = this.producerToDeclaringDefaultBean.get(qual).getSyntheticQualifier();
                Set<Annotation> declaringBeanQualifiers;
                if (declaringDefaultBean != null && !beanTypeInformation.containsKey(declaringDefaultBean)) {
                    // this is a default producer method that was declared on a
                    // default bean that has been replaced
                    declaringBeanQualifiers = Collections.singleton((Annotation) declaringDefaultBean);
                } else {
                    declaringBeanQualifiers = this.producerToDeclaringDefaultBean.get(qual).getQualifiers();
                }
                DefaultProducerMethodInfo<?> info = producerAnnotatedMethods.get(qual);
                Bean<?> db = createDefaultProducerMethod(defaultProducerMethods.get(qual), qual, beanInfo, types, qualifiers, declaringBeanQualifiers, info, manager);
                log.debug("Installing default producer bean " + db);
                event.addBean(db);
                fireBeanInstalledEvent(db, manager);
            } else if (defaultProducerFields.containsKey(qual)) {
                Synthetic declaringDefaultBean = this.producerToDeclaringDefaultBean.get(qual).getSyntheticQualifier();
                Set<Annotation> declaringBeanQualifiers;
                if (declaringDefaultBean != null && !beanTypeInformation.containsKey(declaringDefaultBean)) {
                    // this is a default producer method that was declared on a
                    // default bean that has been replaced
                    declaringBeanQualifiers = Collections.singleton((Annotation) declaringDefaultBean);
View Full Code Here

Examples of org.jboss.seam.solder.reflection.Synthetic

   <X> void processAnnotatedType(@Observes ProcessAnnotatedType<X> event, BeanManager beanManager)
   {
      boolean defaultBean = false;
      AnnotatedType<X> tp = event.getAnnotatedType();
      AnnotatedTypeBuilder<X> builder = null;
      Synthetic declaringBeanSyntheticQualifier = null;
      Set<Annotation> declaringBeanQualifiers = null;
      if (event.getAnnotatedType().isAnnotationPresent(DefaultBean.class))
      {
         Set<Annotation> qualifiers = new HashSet<Annotation>();
         defaultBean = true;
         builder = new AnnotatedTypeBuilder<X>().readFromType(tp);
         for (Annotation a : tp.getAnnotations())
         {
            // remove the qualifiers
            if (beanManager.isQualifier(a.annotationType()))
            {
               qualifiers.add(a);
               builder.removeFromClass(a.annotationType());
            }
         }
         if (qualifiers.isEmpty())
         {
            qualifiers.add(DefaultLiteral.INSTANCE);
         }
         declaringBeanQualifiers = new HashSet<Annotation>(qualifiers);
         declaringBeanSyntheticQualifier = syntheticProvider.get();
         // store the qualifiers for later
         beanTypeInformation.put(declaringBeanSyntheticQualifier, new DefaultBeanType(qualifiers, tp.getAnnotation(DefaultBean.class).value()));
         builder.addToClass(declaringBeanSyntheticQualifier);
         // now loop though observer methods and replace qualifiers
         for (AnnotatedMethod<? super X> m : tp.getMethods())
         {
            AnnotatedParameter<? super X> observerParameter = null;
            for (AnnotatedParameter<? super X> p : m.getParameters())
            {
               if (p.isAnnotationPresent(Observes.class))
               {
                  observerParameter = p;
                  break;
               }
            }
            if (observerParameter != null)
            {
               // we have an observer method
               Set<Annotation> observerQualifiers = new HashSet<Annotation>();
               for (Annotation a : observerParameter.getAnnotations())
               {
                  // remove all qualifiers
                  if (beanManager.isQualifier(a.annotationType()))
                  {
                     observerQualifiers.add(a);
                     builder.removeFromMethodParameter(m.getJavaMember(), observerParameter.getPosition(), a.annotationType());
                  }
               }
               if (qualifiers.isEmpty())
               {
                  qualifiers.add(DefaultLiteral.INSTANCE);
               }
               builder.addToMethodParameter(m.getJavaMember(), observerParameter.getPosition(), declaringBeanSyntheticQualifier);
               ObserverMethodInfo<?> info = ObserverMethodInfo.of(observerQualifiers, declaringBeanQualifiers, m, declaringBeanSyntheticQualifier);
               defaultObserverMethodsByBean.put(declaringBeanSyntheticQualifier, info);
               defaultObserverMethods.put(m.getJavaMember(), info);
            }
         }
      }
      // now look for producer methods
      // if this bean is a default bean then all producers are default beans
      // otherwise the annotaion needs to be present
      for (AnnotatedMethod<? super X> m : tp.getMethods())
      {
         if (m.isAnnotationPresent(Produces.class) && (defaultBean || m.isAnnotationPresent(DefaultBean.class)))
         {
            if (declaringBeanQualifiers == null)
            {
               declaringBeanQualifiers = new HashSet<Annotation>(Beans.getQualifiers(beanManager, tp.getAnnotations()));
               if (declaringBeanQualifiers.isEmpty())
               {
                  declaringBeanQualifiers.add(DefaultLiteral.INSTANCE);
               }
            }
            if (builder == null)
            {
               builder = new AnnotatedTypeBuilder<X>().readFromType(tp);
            }
            Set<Annotation> qualifiers = new HashSet<Annotation>();
            for (Annotation a : m.getAnnotations())
            {
               // remove the qualifiers
               if (beanManager.isQualifier(a.annotationType()))
               {
                  qualifiers.add(a);
                  builder.removeFromMethod(m, a.annotationType());
               }
            }
            if (qualifiers.isEmpty())
            {
               qualifiers.add(DefaultLiteral.INSTANCE);
            }
            Synthetic syntheticQualifier = producerSyntheticProvider.get();
            // store the qualifiers for later
            Type type = null;
            // if the type is not explicity set then we infer it
            if (m.isAnnotationPresent(DefaultBean.class))
            {
               type = m.getAnnotation(DefaultBean.class).value();
            }
            else
            {
               type = m.getJavaMember().getGenericReturnType();
            }
            beanTypeInformation.put(syntheticQualifier, new DefaultBeanType(qualifiers, type));
            builder.addToMethod(m, syntheticQualifier);
            producerToDeclaringDefaultBean.put(syntheticQualifier, new DefaultBeanQualifiers(declaringBeanSyntheticQualifier, declaringBeanQualifiers));
         }
      }

      for (AnnotatedField<? super X> f : tp.getFields())
      {
         if (f.isAnnotationPresent(Produces.class) && (defaultBean || f.isAnnotationPresent(DefaultBean.class)))
         {
            if (declaringBeanQualifiers == null)
            {
               declaringBeanQualifiers = new HashSet<Annotation>(Beans.getQualifiers(beanManager, tp.getAnnotations()));
               if (declaringBeanQualifiers.isEmpty())
               {
                  declaringBeanQualifiers.add(DefaultLiteral.INSTANCE);
               }
            }
            // we do not support producer fields on normal scoped beans
            // as proxies prevent us from reading the fields
            for (Annotation i : tp.getAnnotations())
            {
               if (beanManager.isNormalScope(i.annotationType()))
               {
                  deploymentProblems.add(new RuntimeException("Default producer fields are not supported on normal scoped beans. Field: " + f + " Declaring Bean: " + tp));
               }
            }
            if (builder == null)
            {
               builder = new AnnotatedTypeBuilder<X>().readFromType(tp);
            }
            Set<Annotation> qualifiers = new HashSet<Annotation>();
            for (Annotation a : f.getAnnotations())
            {
               // remove the qualifiers
               if (beanManager.isQualifier(a.annotationType()))
               {
                  qualifiers.add(a);
                  builder.removeFromField(f, a.annotationType());
               }
            }
            if (qualifiers.isEmpty())
            {
               qualifiers.add(DefaultLiteral.INSTANCE);
            }
            Synthetic syntheticQualifier = producerSyntheticProvider.get();
            // store the qualifiers for later
            Type type = null;
            if (f.isAnnotationPresent(DefaultBean.class))
            {
               type = f.getAnnotation(DefaultBean.class).value();
View Full Code Here

Examples of org.jboss.seam.solder.reflection.Synthetic

      {
         return;
      }
      Bean<X> b = event.getBean();
      processedBeans.add(b);
      Synthetic qualifier = null;
      for (Annotation a : b.getQualifiers())
      {
         if (a instanceof Synthetic)
         {
            Synthetic sa = (Synthetic) a;
            if (sa.namespace().equals(QUALIFIER_NAMEPSACE))
            {
               qualifier = sa;
               break;
            }
         }
View Full Code Here

Examples of org.jboss.seam.solder.reflection.Synthetic

      if (beanDiscoveryOver)
      {
         return;
      }
      Bean<X> b = event.getBean();
      Synthetic qualifier = handleProducerBean(b);
      if (qualifier != null)
      {
         // store producer method information
         defaultProducerMethods.put(qualifier, event.getBean());
         AnnotatedMethod<T> method = event.getAnnotatedProducerMethod();
View Full Code Here

Examples of org.jboss.seam.solder.reflection.Synthetic

      if (beanDiscoveryOver)
      {
         return;
      }
      Bean<X> b = event.getBean();
      Synthetic qualifier = handleProducerBean(b);
      if (qualifier != null)
      {
         defaultProducerFields.put(qualifier, event.getBean());
         producerAnnotatedFields.put(qualifier, event.getAnnotatedProducerField());
      }
View Full Code Here

Examples of org.jboss.seam.solder.reflection.Synthetic

      }
   }

   <X> Synthetic handleProducerBean(Bean<X> b)
   {
      Synthetic qualifier = null;
      for (Annotation a : b.getQualifiers())
      {
         if (a instanceof Synthetic)
         {
            Synthetic sa = (Synthetic) a;
            if (sa.namespace().equals(PRODUCER_QUALIFIER_NAMEPSACE))
            {
               qualifier = sa;
               break;
            }
         }
View Full Code Here

Examples of org.jboss.seam.solder.reflection.Synthetic

      return qualifier;
   }

   <T, X> void processObserverMethod(@Observes ProcessObserverMethod<T, X> event)
   {
      Synthetic qualifier = null;
      for (Annotation a : event.getObserverMethod().getObservedQualifiers())
      {
         if (a instanceof Synthetic)
         {
            Synthetic sa = (Synthetic) a;
            if (sa.namespace().equals(QUALIFIER_NAMEPSACE))
            {
               qualifier = sa;
               break;
            }
         }
View Full Code Here

Examples of org.jboss.seam.solder.reflection.Synthetic

            while (it.hasNext())
            {
               Entry<Synthetic, DefaultBeanType> definition = it.next();
               if (definition.getValue().matches(processedBean))
               {
                  Synthetic qual = definition.getKey();
                  Bean<?> bean = null;
                  // remove the default bean from the beans to be installed
                  bean = defaultManagedBeans.remove(qual);
                  if (bean == null)
                  {
                     bean = defaultProducerMethods.remove(qual);
                  }
                  if (bean == null)
                  {
                     bean = defaultProducerFields.remove(qual);
                  }
                  log.info("Preventing install of default bean " + bean);
                  it.remove();
               }
            }
         }
      }
      Set<Synthetic> allDefaultBeanQualifiers = new HashSet<Synthetic>(defaultManagedBeans.keySet());
      allDefaultBeanQualifiers.addAll(defaultProducerFields.keySet());
      allDefaultBeanQualifiers.addAll(defaultProducerMethods.keySet());

      for (Synthetic qual : allDefaultBeanQualifiers)
      {
         final DefaultBeanType beanInfo = beanTypeInformation.get(qual);
         final HashSet<Type> types = new HashSet<Type>();
         types.add(Object.class);
         types.add(beanInfo.getType());
         final Set<Annotation> qualifiers = new HashSet<Annotation>(beanInfo.getQualifiers());
         if (defaultManagedBeans.containsKey(qual))
         {
            Bean<?> db = DefaultManagedBean.of(defaultManagedBeans.get(qual), beanInfo.getType(), types, qualifiers, manager);
            log.debug("Installing default managed bean " + db);
            event.addBean(db);
            Set<ObserverMethodInfo<?>> observers = defaultObserverMethodsByBean.get(qual);
            for (ObserverMethodInfo<?> i : observers)
            {
               DefaultObserverMethod<?, ?> obs = DefaultObserverMethod.of(i.getDelegate(), i.getAnnotatedMethod(), qualifiers, i.getObserverParameterQualifier(), db, manager);
               event.addObserverMethod(obs);
            }
         }
         else if (defaultProducerMethods.containsKey(qual))
         {
            Synthetic declaringDefaultBean = this.producerToDeclaringDefaultBean.get(qual).getSyntheticQualifier();
            Set<Annotation> declaringBeanQualifiers;
            if (declaringDefaultBean != null && !beanTypeInformation.containsKey(declaringDefaultBean))
            {
               // this is a default producer method that was declared on a
               // default bean that has been replaced
               declaringBeanQualifiers = Collections.singleton((Annotation) declaringDefaultBean);
            }
            else
            {
               declaringBeanQualifiers = this.producerToDeclaringDefaultBean.get(qual).getQualifiers();
            }
            DefaultProducerMethodInfo<?> info = producerAnnotatedMethods.get(qual);
            Bean<?> db = createDefaultProducerMethod(defaultProducerMethods.get(qual), qual, beanInfo, types, qualifiers, declaringBeanQualifiers, info, manager);
            log.debug("Installing default producer bean " + db);
            event.addBean(db);
         }
         else if (defaultProducerFields.containsKey(qual))
         {
            Synthetic declaringDefaultBean = this.producerToDeclaringDefaultBean.get(qual).getSyntheticQualifier();
            Set<Annotation> declaringBeanQualifiers;
            if (declaringDefaultBean != null && !beanTypeInformation.containsKey(declaringDefaultBean))
            {
               // this is a default producer method that was declared on a
               // default bean that has been replaced
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.