javax.enterprise.inject.spi.ProcessManagedBean Java Examples

The following examples show how to use javax.enterprise.inject.spi.ProcessManagedBean. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: MetricCdiInjectionExtension.java    From smallrye-metrics with Apache License 2.0 6 votes vote down vote up
private <X> void findAnnotatedMethods(@Observes ProcessManagedBean<X> bean) {
    Package pack = bean.getBean().getBeanClass().getPackage();
    if (pack != null && pack.equals(GaugeRegistrationInterceptor.class.getPackage())) {
        return;
    }
    ArrayList<AnnotatedMember<?>> list = new ArrayList<>();
    for (AnnotatedMethod<? super X> aMethod : bean.getAnnotatedBeanClass().getMethods()) {
        Method method = aMethod.getJavaMember();
        if (!method.isSynthetic() && !Modifier.isPrivate(method.getModifiers())) {
            list.add(aMethod);
        }
    }
    list.addAll(bean.getAnnotatedBeanClass().getConstructors());
    if (!list.isEmpty()) {
        metricsFromAnnotatedMethods.put(bean.getBean(), list);
    }
}
 
Example #2
Source File: FaultToleranceExtension.java    From smallrye-fault-tolerance with Apache License 2.0 5 votes vote down vote up
/**
 * Observe all enabled managed beans and identify/validate FT operations. This allows us to:
 * <ul>
 * <li>Skip validation of types which are not recognized as beans (e.g. are vetoed)</li>
 * <li>Take the final values of AnnotatedTypes</li>
 * <li>Support annotations added via portable extensions</li>
 * </ul>
 *
 * @param event
 */
void collectFaultToleranceOperations(@Observes ProcessManagedBean<?> event) {
    AnnotatedType<?> annotatedType = event.getAnnotatedBeanClass();
    for (AnnotatedMethod<?> annotatedMethod : annotatedType.getMethods()) {
        FaultToleranceOperation operation = FaultToleranceOperation.of(annotatedMethod);
        if (operation.isLegitimate()) {
            operation.validate();
            LOGGER.debugf("Found %s", operation);
            faultToleranceOperations.put(getCacheKey(annotatedType.getJavaClass(), annotatedMethod.getJavaMember()),
                    operation);
        }
    }
}
 
Example #3
Source File: MBeanExtension.java    From deltaspike with Apache License 2.0 5 votes vote down vote up
protected void processBean(@Observes final ProcessManagedBean<?> bean, final BeanManager bm) throws Exception
{
    if (!isActivated)
    {
        return;
    }

    MBean mBeanAnnotation = bean.getAnnotated().getAnnotation(MBean.class);
    if (mBeanAnnotation != null)
    {
        registerObject(bean, mBeanAnnotation, bm);
    }
}