public void produceMissingPersistenceUnits(@Observes AfterTypeDiscovery event, BeanManager beanManager) { for (String unitName : injectedPersistenceUnits) injectedPersistenceContexts.remove(unitName); for (AnnotatedMember<?> member : injectedPersistenceContexts.values()) { if (!member.isAnnotationPresent(SpearalEnabled.class)) continue; PersistenceContext persistenceContext = member.getAnnotation(PersistenceContext.class); try { final Set<Annotation> annotations = new HashSet<Annotation>(member.getAnnotations()); Iterator<Annotation> ia = annotations.iterator(); while (ia.hasNext()) { Annotation a = ia.next(); if (a.annotationType().equals(PersistenceContext.class)) ia.remove(); } PersistenceUnit persistenceUnit = new PersistenceUnitAnnotation(persistenceContext.name(), persistenceContext.unitName()); annotations.add(persistenceUnit); final AnnotatedType<PersistenceUnitProducer> annotatedPU = new AnnotatedPersistenceUnitProducerType(annotations); event.addAnnotatedType(annotatedPU, "org.spearal.jpa2.PersistenceUnit." + persistenceContext.unitName()); } catch (Exception e) { log.logp(Level.WARNING, SpearalExtension.class.getName(), "afterTypeDiscovery", "Could not setup PersistenceUnit integration {0}", new Object[] { persistenceContext.unitName() }); } } }
/** * Warns user if there's none onr more than one {@link MongoClientDefinition} in the application */ void checkMongoClientUniqueness(@Observes AfterTypeDiscovery atd) { if (mongoDef == null) { log.warning("No MongoDB data sources found, mongo CDI extension will do nothing"); } else if (moreThanOne) { log.log(Level.WARNING, "You defined more than one MongoDB data source. Only the one with name {0} will be " + "created", mongoDef .name()); } }
void afterTypeDiscovery(@Observes AfterTypeDiscovery atd) { logger.info("finished the scanning process"); afterTypeDiscovery++; }
void logLifecycleEvent(@Observes AfterTypeDiscovery event) { LOGGER.info("AfterTypeDiscovery: alternatives=" + event.getAlternatives() + ", interceptors=" + event.getInterceptors() + ", decorators=" + event.getDecorators()); }