public static <T> ContextualInstanceStrategy<T> create(BeanAttributes<T> bean, BeanManagerImpl manager) { if (ApplicationScoped.class == bean.getScope() || Singleton.class == bean.getScope()) { return new ApplicationScopedContextualInstanceStrategy<T>(); } else if (CachingContextualInstanceStrategy.CACHEABLE_SCOPES.contains(bean.getScope())) { return new CachingContextualInstanceStrategy<T>(); } return defaultStrategy(); }
public static <T> ContextualInstanceStrategy<T> create(BeanAttributes<T> bean, BeanManagerImpl manager) { if (ApplicationScoped.class == bean.getScope() || Singleton.class == bean.getScope()) { return new ApplicationScopedContextualInstanceStrategy<T>(); } else if (CachingContextualInstanceStrategy.CACHEABLE_SCOPES.contains(bean.getScope())) { return new CachingContextualInstanceStrategy<T>(); } return defaultStrategy(); }
private static BeanIdentifier createId(BeanAttributes<?> attributes, EnhancedAnnotatedMethod<?, ?> method, AbstractClassBean<?> declaringBean) { if (Dependent.class.equals(attributes.getScope()) || ApplicationScoped.class.equals(attributes.getScope())) { return new ProducerMethodIdentifier(method, declaringBean); } else { return new StringBeanIdentifier(BeanIdentifiers.forProducerMethod(method, declaringBean)); } }
private static BeanIdentifier createId(BeanAttributes<?> attributes, EnhancedAnnotatedMethod<?, ?> method, AbstractClassBean<?> declaringBean) { if (Dependent.class.equals(attributes.getScope()) || ApplicationScoped.class.equals(attributes.getScope())) { return new ProducerMethodIdentifier(method, declaringBean); } else { return new StringBeanIdentifier(BeanIdentifiers.forProducerMethod(method, declaringBean)); } }
private static BeanIdentifier createId(BeanAttributes<?> attributes, EnhancedAnnotatedMethod<?, ?> method, AbstractClassBean<?> declaringBean) { if (Dependent.class.equals(attributes.getScope()) || ApplicationScoped.class.equals(attributes.getScope())) { return new ProducerMethodIdentifier(method, declaringBean); } else { return new StringBeanIdentifier(BeanIdentifiers.forProducerMethod(method, declaringBean)); } }
private static BeanIdentifier createId(BeanAttributes<?> attributes, EnhancedAnnotatedMethod<?, ?> method, AbstractClassBean<?> declaringBean) { if (Dependent.class.equals(attributes.getScope()) || ApplicationScoped.class.equals(attributes.getScope())) { return new ProducerMethodIdentifier(method, declaringBean); } else { return new StringBeanIdentifier(BeanIdentifiers.forProducerMethod(method, declaringBean)); } }
private static BeanIdentifier createId(BeanAttributes<?> attributes, EnhancedAnnotatedMethod<?, ?> method, AbstractClassBean<?> declaringBean) { if (Dependent.class.equals(attributes.getScope()) || ApplicationScoped.class.equals(attributes.getScope())) { return new ProducerMethodIdentifier(method, declaringBean); } else { return new StringBeanIdentifier(BeanIdentifiers.forProducerMethod(method, declaringBean)); } }
private static BeanIdentifier createId(BeanAttributes<?> attributes, EnhancedAnnotatedType<?> clazz) { if (Dependent.class.equals(attributes.getScope()) || ApplicationScoped.class.equals(attributes.getScope())) { return new ManagedBeanIdentifier(clazz.slim().getIdentifier()); } else { return new StringBeanIdentifier(forManagedBean(clazz)); } }
private static BeanIdentifier createId(BeanAttributes<?> attributes, EnhancedAnnotatedType<?> clazz) { if (Dependent.class.equals(attributes.getScope()) || ApplicationScoped.class.equals(attributes.getScope())) { return new ManagedBeanIdentifier(clazz.slim().getIdentifier()); } else { return new StringBeanIdentifier(forManagedBean(clazz)); } }
private static BeanIdentifier createId(BeanAttributes<?> attributes, EnhancedAnnotatedType<?> clazz) { if (Dependent.class.equals(attributes.getScope()) || ApplicationScoped.class.equals(attributes.getScope())) { return new ManagedBeanIdentifier(clazz.slim().getIdentifier()); } else { return new StringBeanIdentifier(forManagedBean(clazz)); } }
@SuppressWarnings("unchecked") private void verifyLakeFish(BeanAttributes<?> attributes) { assertTrue(typeSetMatches(attributes.getTypes(), Fish.class, Object.class)); assertTrue(typeSetMatches(attributes.getStereotypes(), TundraStereotype.class)); assertTrue(annotationSetMatches(attributes.getQualifiers(), Natural.class, Any.class, Named.class)); assertEquals(attributes.getScope(), ApplicationScoped.class); assertEquals(attributes.getName(), "fish"); assertTrue(attributes.isAlternative()); }
/** * Utility constructor used for overriding Bean qualifiers and name for specialization purposes. */ public ImmutableBeanAttributes(Set<Annotation> qualifiers, String name, BeanAttributes<T> attributes) { this(attributes.getStereotypes(), attributes.isAlternative(), name, qualifiers, attributes.getTypes(), attributes.getScope()); }
/** * Utility constructor used for overriding Bean qualifiers and name for specialization purposes. */ public ImmutableBeanAttributes(Set<Annotation> qualifiers, String name, BeanAttributes<T> attributes) { this(attributes.getStereotypes(), attributes.isAlternative(), name, qualifiers, attributes.getTypes(), attributes.getScope()); }
/** * Utility constructor used for overriding Bean qualifiers and name for specialization purposes. */ public ImmutableBeanAttributes(Set<Annotation> qualifiers, String name, BeanAttributes<T> attributes) { this(attributes.getStereotypes(), attributes.isAlternative(), name, qualifiers, attributes.getTypes(), attributes.getScope()); }
@Override public BeanConfigurator<T> read(BeanAttributes<?> beanAttributes) { this.stereotypes.addAll(beanAttributes.getStereotypes()); this.scope = beanAttributes.getScope(); this.name = beanAttributes.getName(); this.alternative = beanAttributes.isAlternative(); types(beanAttributes.getTypes()); qualifiers(beanAttributes.getQualifiers()); stereotypes(beanAttributes.getStereotypes()); return this; }
/** * @param source source {@link BeanAttributes}. * @return a safe copy of source {@link BeanAttributes}. */ public static <T> BeanAttributes<T> of(BeanAttributes<T> source, BeanManager manager) { validateBeanAttributes(source, manager); BeanAttributes<T> attributes = new ImmutableBeanAttributes<T>(defensiveCopy(source.getStereotypes()), source.isAlternative(), source.getName(), defensiveCopy(source.getQualifiers()), defensiveCopy(source.getTypes()), source.getScope()); return attributes; }
/** * @param source source {@link BeanAttributes}. * @return a safe copy of source {@link BeanAttributes}. */ public static <T> BeanAttributes<T> of(BeanAttributes<T> source, BeanManager manager) { validateBeanAttributes(source, manager); BeanAttributes<T> attributes = new ImmutableBeanAttributes<T>(defensiveCopy(source.getStereotypes()), source.isAlternative(), source.getName(), defensiveCopy(source.getQualifiers()), defensiveCopy(source.getTypes()), source.getScope()); return attributes; }
public BeanAttributesConfigurator<T> read(BeanAttributes<?> beanAttributes) { checkArgumentNotNull(beanAttributes); name(beanAttributes.getName()); qualifiers(beanAttributes.getQualifiers()); scope(beanAttributes.getScope()); stereotypes(beanAttributes.getStereotypes()); types(beanAttributes.getTypes()); alternative(beanAttributes.isAlternative()); return this; }