Java 类javax.enterprise.inject.spi.BeanAttributes 实例源码

项目:wildfly-swarm    文件:MPJWTExtension.java   
/**
 * Replace the general producer method BeanAttributes with one bound to the collected injection site
 * types to properly reflect all of the type locations the producer method applies to.
 *
 * @param pba the ProcessBeanAttributes
 * @see ClaimProviderBeanAttributes
 */
public void addTypeToClaimProducer(@Observes ProcessBeanAttributes pba) {
    if (pba.getAnnotated().isAnnotationPresent(Claim.class)) {
        Claim claim = pba.getAnnotated().getAnnotation(Claim.class);
        if (claim.value().length() == 0 && claim.standard() == Claims.UNKNOWN) {
            log.debugf("addTypeToClaimProducer: %s\n", pba.getAnnotated());
            BeanAttributes delegate = pba.getBeanAttributes();
            String name = delegate.getName();
            if (delegate.getTypes().contains(Optional.class)) {
                if (providerOptionalTypes.size() == 0) {
                    providerOptionalTypes.add(Optional.class);
                }
                pba.setBeanAttributes(new ClaimProviderBeanAttributes(delegate, providerOptionalTypes, providerQualifiers));
            } else if (name != null && name.startsWith("RawClaimTypeProducer#")) {
                if (rawTypes.size() == 0) {
                    rawTypes.add(Object.class);
                }
                pba.setBeanAttributes(new ClaimProviderBeanAttributes(delegate, rawTypes, rawTypeQualifiers));
                log.debugf("Setup RawClaimTypeProducer BeanAttributes");
            }
        }
    }
}
项目:wildfly-swarm    文件:ClaimProviderBeanAttributes.java   
/**
 * Decorate the ConfigPropertyProducer BeanAttributes to set the types the producer applies to. This set is collected
 * from all injection points annotated with @ConfigProperty.
 *
 * @param delegate - the original producer method BeanAttributes
 * @param types    - the full set of @ConfigProperty injection point types
 */
public ClaimProviderBeanAttributes(BeanAttributes<Object> delegate, Set<Type> types, Set<Annotation> qualifiers) {
    this.delegate = delegate;
    this.types = types;
    this.qualifiers = qualifiers;
    if (types.size() == 0) {
        Thread.dumpStack();
    }
}
项目:camel-cdi    文件:CdiSpiHelper.java   
/**
 * Generates a unique signature for {@link BeanAttributes}.
 */
static String createBeanAttributesId(BeanAttributes<?> attributes) {
    return Stream.of(attributes.getName(),
            attributes.getScope().getName(),
            createAnnotationCollectionId(attributes.getQualifiers()),
            createTypeCollectionId(attributes.getTypes()))
        .filter(Objects::nonNull)
        .collect(joining(","));
}
项目:HotswapAgent    文件:BeanReloadExecutor.java   
@SuppressWarnings({ "rawtypes", "unchecked" })
private static void doDefineNewManagedBean(BeanManagerImpl beanManager, String bdaId,
        Class<?> beanClass) {
    try {
        ClassTransformer classTransformer = getClassTransformer();
        SlimAnnotatedType<?> annotatedType = classTransformer.getBackedAnnotatedType(beanClass, bdaId);
        boolean managedBeanOrDecorator = Beans.isTypeManagedBeanOrDecoratorOrInterceptor(annotatedType);

        if (managedBeanOrDecorator) {
            EnhancedAnnotatedType eat = EnhancedAnnotatedTypeImpl.of(annotatedType, classTransformer);
            BeanAttributes attributes = BeanAttributesFactory.forBean(eat, beanManager);
            ManagedBean<?> bean = ManagedBean.of(attributes, eat, beanManager);
            Field field = beanManager.getClass().getDeclaredField("beanSet");
            field.setAccessible(true);
            field.set(beanManager, Collections.synchronizedSet(new HashSet<Bean<?>>()));
            // TODO:
            beanManager.addBean(bean);
            beanManager.getBeanResolver().clear();
            bean.initializeAfterBeanDiscovery();
            // define managed bean
            // beanManager.cleanupAfterBoot();
            LOGGER.debug("Bean defined '{}'", beanClass.getName());
        } else {
            // TODO : define session bean
            LOGGER.warning("Bean NOT? defined '{}', session bean?", beanClass.getName());
        }
    } catch (Exception e) {
        LOGGER.debug("Bean definition failed.", e);
    }
}
项目:tomee    文件:CdiEjbBean.java   
public CdiEjbBean(final BeanContext bc, final WebBeansContext webBeansContext, final Class beanClass, final AnnotatedType<T> at,
                  final InjectionTargetFactoryImpl<T> factory, final BeanAttributes<T> attributes) {
    super(webBeansContext, toSessionType(bc.getComponentType()), at,
            new EJBBeanAttributesImpl<T>(bc, attributes),
            beanClass, factory);
    this.beanContext = bc;
    bc.set(Bean.class, this);
    passivatingId = bc.getDeploymentID() + getReturnType().getName();

    final boolean stateful = BeanType.STATEFUL.equals(bc.getComponentType());
    final boolean isDependent = getScope().equals(Dependent.class);
    isDependentAndStateful = isDependent && stateful;
    if (webBeansContext.getBeanManagerImpl().isPassivatingScope(getScope()) && stateful) {
        if (!getBeanContext().isPassivable()) {
            throw new DefinitionException(
                    getBeanContext().getBeanClass()
                            + " is a not apssivation-capable @Stateful with a scope "
                            + getScope().getSimpleName() + " which need passivation");
        }
        passivable = true;
    } else {
        passivable = false;
    }
    if (!isDependent) {
        for (final Type type : attributes.getTypes()) {
            if (ParameterizedType.class.isInstance(type)) {
                throw new DefinitionException("Parameterized session bean should be @Dependent: " + beanClass);
            }
        }
    }
    if (getAnnotatedType().isAnnotationPresent(Interceptor.class) || getAnnotatedType().isAnnotationPresent(Decorator.class)) {
        throw new DefinitionException("An EJB can't be an interceptor or a decorator: " + beanClass);
    }
}
项目:wildfly-nosql    文件:Neo4jExtension.java   
DriverBeanAttributes(BeanAttributes<T> beanAttributes, String profile) {
    delegate = beanAttributes;
    this.profile = profile;
}
项目:wildfly-nosql    文件:OrientBeanAttributes.java   
OrientBeanAttributes(BeanAttributes<T> delegate, String profile) {
    this.delegate = delegate;
    this.profile = profile;
}
项目:wildfly-nosql    文件:OrientExtension.java   
private <T> Bean<T> getBean(BeanManager beanManager, Class<T> beanClass, String profile) {
    BeanAttributes<T> beanAttributes = beanManager.createBeanAttributes(beanManager.createAnnotatedType(beanClass));

    return beanManager.createBean(new OrientBeanAttributes<>(beanAttributes, profile), beanClass,
            new OrientProducerFactory<>(beanClass, profile));
}
项目:wildfly-nosql    文件:CassandraExtension.java   
ClusterBeanAttributes(BeanAttributes<T> beanAttributes, String profile) {
    delegate = beanAttributes;
    this.profile = profile;
}
项目:wildfly-nosql    文件:CassandraExtension.java   
SessionBeanAttributes(BeanAttributes<T> beanAttributes, String profile) {
    delegate = beanAttributes;
    this.profile = profile;
}
项目:wildfly-nosql    文件:MongoExtension.java   
MongoClientBeanAttributes(BeanAttributes<T> beanAttributes, String profile) {
    delegate = beanAttributes;
    this.profile = profile;
}
项目:wildfly-nosql    文件:MongoExtension.java   
MongoDatabaseBeanAttributes(BeanAttributes<T> beanAttributes, String profile) {
    delegate = beanAttributes;
    this.profile = profile;
}
项目:wildfly-swarm    文件:ImplicitArchiveExtension.java   
@SuppressWarnings("unused")
<T> void processBeanAttributes(@Observes ProcessBeanAttributes<T> pba, BeanManager beanManager) throws Exception {
    final BeanAttributes<T> beanAttributes = pba.getBeanAttributes();
    if (beanAttributes.getTypes().contains(Archive.class)) {
        if (!DeploymentScoped.class.isAssignableFrom(beanAttributes.getScope())) {
            pba.setBeanAttributes(new BeanAttributes<T>() {
                @Override
                public Set<Type> getTypes() {
                    return beanAttributes.getTypes();
                }

                @Override
                public Set<Annotation> getQualifiers() {
                    Set<Annotation> qualifiers = new HashSet<>();
                    qualifiers.addAll(beanAttributes.getQualifiers());
                    qualifiers.add(ImplicitDeployment.Literal.INSTANCE);
                    qualifiers.removeIf(e -> Default.class.isAssignableFrom(e.getClass()));
                    return qualifiers;
                }

                @Override
                public Class<? extends Annotation> getScope() {
                    return beanAttributes.getScope();
                }

                @Override
                public String getName() {
                    return beanAttributes.getName();
                }

                @Override
                public Set<Class<? extends Annotation>> getStereotypes() {
                    return beanAttributes.getStereotypes();
                }

                @Override
                public boolean isAlternative() {
                    return beanAttributes.isAlternative();
                }
            });
        }
    }
}
项目:tapestry-jpa-transactions    文件:NoopBeanManager.java   
@Override
public <T> BeanAttributes<T> createBeanAttributes(AnnotatedType<T> type)
{
    // TODO Auto-generated method stub
    return null;
}
项目:tapestry-jpa-transactions    文件:NoopBeanManager.java   
@Override
public BeanAttributes<?> createBeanAttributes(AnnotatedMember<?> type)
{
    // TODO Auto-generated method stub
    return null;
}
项目:tapestry-jpa-transactions    文件:NoopBeanManager.java   
@Override
public <T> Bean<T> createBean(BeanAttributes<T> attributes, Class<T> beanClass, InjectionTargetFactory<T> injectionTargetFactory)
{
    // TODO Auto-generated method stub
    return null;
}
项目:tapestry-jpa-transactions    文件:NoopBeanManager.java   
@Override
public <T, X> Bean<T> createBean(BeanAttributes<T> attributes, Class<X> beanClass, ProducerFactory<X> producerFactory)
{
    // TODO Auto-generated method stub
    return null;
}
项目:javaee-nosql    文件:MongoExtension.java   
MongoClientBeanAttributes(BeanAttributes<MongoClient> beanAttributes) {
    delegate = beanAttributes;
}
项目:camel-cdi    文件:BeanAlternative.java   
BeanAlternative(BeanAttributes<T> attributes, Set<? extends Annotation> qualifiers) {
    this.attributes = attributes;
    Set<Annotation> annotations = new HashSet<>(attributes.getQualifiers());
    annotations.addAll(qualifiers);
    this.qualifiers = unmodifiableSet(annotations);
}
项目:jbromo    文件:BeanManagerExt.java   
@Override
public <T> Bean<T> createBean(final BeanAttributes<T> arg0,
        final Class<T> arg1, final InjectionTargetFactory<T> arg2) {
    return this.beanManager.createBean(arg0, arg1, arg2);
}
项目:jbromo    文件:BeanManagerExt.java   
@Override
public <T, X> Bean<T> createBean(final BeanAttributes<T> arg0,
        final Class<X> arg1, final ProducerFactory<X> arg2) {
    return this.beanManager.createBean(arg0, arg1, arg2);
}
项目:jbromo    文件:BeanManagerExt.java   
@Override
public <T> BeanAttributes<T> createBeanAttributes(
        final AnnotatedType<T> arg0) {
    return this.beanManager.createBeanAttributes(arg0);
}
项目:jbromo    文件:BeanManagerExt.java   
@Override
public BeanAttributes<?> createBeanAttributes(final AnnotatedMember<?> arg0) {
    return this.beanManager.createBeanAttributes(arg0);
}
项目:tomee    文件:CdiPlugin.java   
public <T> BeanAttributes<T> createBeanAttributes(final AnnotatedType<T> type) {
    return new CdiEjbBean.EJBBeanAttributesImpl(
            findBeanContext(webBeansContext, type.getJavaClass()),
            BeanAttributesBuilder.forContext(webBeansContext).newBeanAttibutes(type).build());
}
项目:tomee    文件:CdiEjbBean.java   
public CdiEjbBean(final BeanContext beanContext, final WebBeansContext webBeansContext, final AnnotatedType<T> at,
                  final BeanAttributes<T> attributes) {
    this(beanContext, webBeansContext, beanContext.getManagedClass(), at, new EjbInjectionTargetFactory<T>(beanContext, at, webBeansContext), attributes);
    EjbInjectionTargetImpl.class.cast(getInjectionTarget()).setCdiEjbBean(this);
}
项目:tomee    文件:CdiEjbBean.java   
public EJBBeanAttributesImpl(final BeanContext bc, final BeanAttributes<T> beanAttributes) {
    super(beanAttributes, false);
    this.beanContext = bc;
    this.ejbTypes = new HashSet<Type>();
    initTypes();
}
项目:tomee    文件:OpenEJBBeanBuilder.java   
public OpenEJBBeanBuilder(final BeanContext bc, final WebBeansContext webBeansContext, final AnnotatedType<A> annotatedType,
                          final BeanAttributes<A> attributes) {
    super(webBeansContext, annotatedType, attributes);
    this.beanContext = bc;
}