/** * Creates a new invocation handler with supplier which provides a current injected value in proper scope. * * @param supplier provider of the value. */ private ThreadScopeBeanInstance(Supplier<T> supplier, Bean<T> bean, String contextId) { super(bean, new StringBeanIdentifier(((PassivationCapable) bean).getId()), contextId); this.supplier = supplier; }
public ProxyMethodHandler(String contextId, BeanInstance beanInstance, Bean<?> bean) { this.beanInstance = beanInstance; this.bean = bean; this.contextId = contextId; if (bean instanceof CommonBean<?>) { this.beanId = ((CommonBean<?>) bean).getIdentifier(); } else if (bean instanceof PassivationCapable) { this.beanId = new StringBeanIdentifier(((PassivationCapable) bean).getId()); } else { this.beanId = null; } }
public ExtensionBean(BeanManagerImpl manager, EnhancedAnnotatedType<E> enhancedAnnotatedType, Metadata<E> instance) { super(new StringBeanIdentifier(BeanIdentifiers.forExtension(enhancedAnnotatedType)), manager, enhancedAnnotatedType.getJavaClass()); this.annotatedType = enhancedAnnotatedType.slim(); this.instance = instance; this.passivationCapable = enhancedAnnotatedType.isSerializable(); this.proxiable = Proxies.isTypeProxyable(enhancedAnnotatedType.getBaseType(), manager.getServices()); checkPublicFields(enhancedAnnotatedType); }
public InterceptorMetadataBean(BeanManagerImpl beanManager) { super(new StringBeanIdentifier(BeanIdentifiers.forBuiltInBean(beanManager, Interceptor.class, null)), Reflections.<Class<Interceptor<?>>> cast(Interceptor.class), beanManager); }
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)); } }
super(attributes, new StringBeanIdentifier(BeanIdentifiers.forProducerField(field, declaringBean)), declaringBean, manager, services); this.enhancedAnnotatedField = field; this.annotatedField = field.slim(); initType(); this.proxiable = Proxies.isTypesProxyable(field.getTypeClosure(), beanManager.getServices()); setProducer(new ProducerFieldProducer<X, T>(field, disposalMethod) {
protected AbstractDecorableBuiltInBean(BeanManagerImpl beanManager, Class<T> type) { super(new StringBeanIdentifier(BeanIdentifiers.forBuiltInBean(beanManager, type, null)), beanManager, type); this.cip = beanManager.getServices().get(CurrentInjectionPoint.class); }
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)); } }
protected InterceptorImpl(BeanAttributes<T> attributes, EnhancedAnnotatedType<T> type, BeanManagerImpl beanManager) { super(attributes, type, new StringBeanIdentifier(forInterceptor(type)), beanManager); this.interceptorMetadata = initInterceptorMetadata(); this.serializable = type.isSerializable(); this.interceptorBindingTypes = Collections.unmodifiableSet(new HashSet<Annotation>(Interceptors.mergeBeanInterceptorBindings(beanManager, getEnhancedAnnotated(), getStereotypes()).values())); if (Beans.findInterceptorBindingConflicts(beanManager, interceptorBindingTypes)) { throw new DeploymentException(BeanLogger.LOG.conflictingInterceptorBindings(getType())); } }
/** * Creates an instance of a NewEnterpriseBean from an annotated class * * @param clazz The annotated class * @param beanManager The Bean manager * @return a new NewEnterpriseBean instance */ public static <T> NewSessionBean<T> of(BeanAttributes<T> attributes, InternalEjbDescriptor<T> ejbDescriptor, BeanManagerImpl beanManager) { EnhancedAnnotatedType<T> type = beanManager.getServices().get(ClassTransformer.class).getEnhancedAnnotatedType(ejbDescriptor.getBeanClass(), beanManager.getId()); return new NewSessionBean<T>(attributes, type, ejbDescriptor, new StringBeanIdentifier(BeanIdentifiers.forNewSessionBean(ejbDescriptor)), beanManager); }
/** * Creates an instance of a NewEnterpriseBean from an annotated class * * @param clazz The annotated class * @param beanManager The Bean manager * @return a new NewEnterpriseBean instance */ public static <T> NewSessionBean<T> of(BeanAttributes<T> attributes, InternalEjbDescriptor<T> ejbDescriptor, BeanManagerImpl beanManager) { EnhancedAnnotatedType<T> type = beanManager.getServices().get(ClassTransformer.class).getEnhancedAnnotatedType(ejbDescriptor.getBeanClass(), beanManager.getId()); return new NewSessionBean<T>(attributes, type, ejbDescriptor, new StringBeanIdentifier(SessionBeans.createIdentifierForNew(ejbDescriptor)), beanManager); }
public ContextBean(ContextHolder<T> contextHolder, BeanManagerImpl beanManager) { super(new StringBeanIdentifier(BeanIdentifiers.forBuiltInBean(beanManager, contextHolder.getType(), null)), beanManager, contextHolder.getType()); this.context = contextHolder.getContext(); this.types = HierarchyDiscovery.forNormalizedType(contextHolder.getType()).getTypeClosure(); this.qualifiers = contextHolder.getQualifiers(); }
/** * Creates an instance of a NewSimpleBean from an annotated class * * @param clazz The annotated class * @param beanManager The Bean manager * @return a new NewSimpleBean instance */ public static <T> NewManagedBean<T> of(BeanAttributes<T> attributes, EnhancedAnnotatedType<T> clazz, BeanManagerImpl beanManager) { return new NewManagedBean<T>(attributes, clazz, new StringBeanIdentifier(BeanIdentifiers.forNewManagedBean(clazz)), beanManager); }
protected AbstractSyntheticBean(BeanAttributes<T> attributes, BeanManagerImpl manager, Class<?> beanClass) { super(attributes, new StringBeanIdentifier(BeanIdentifiers.forSyntheticBean(attributes, beanClass))); this.beanClass = beanClass; }
@Override public BeanIdentifier getIdentifier() { // this will likely never get called, so it's ok to create new object here return new StringBeanIdentifier(id); }
@Override public String toString() { return asString(); } }
@Override public boolean equals(Object obj) { if (this == obj) { return true; } if (obj instanceof BeanIdentifier) { if (this.hashCode() != obj.hashCode()) { return false; } if (obj instanceof StringBeanIdentifier) { StringBeanIdentifier that = (StringBeanIdentifier) obj; return this.value.equals(that.value); } BeanIdentifier that = (BeanIdentifier) obj; return this.value.equals(that.asString()); } return false; }
/** * Creates a simple, annotation defined Enterprise Web Bean using the annotations specified on type * * @param <T> The type * @param beanManager the current manager * @param type the AnnotatedType to use * @return An Enterprise Web Bean */ public static <T> SessionBean<T> of(BeanAttributes<T> attributes, InternalEjbDescriptor<T> ejbDescriptor, BeanManagerImpl beanManager, EnhancedAnnotatedType<T> type) { return new SessionBean<T>(attributes, type, ejbDescriptor, new StringBeanIdentifier(BeanIdentifiers.forSessionBean(type, ejbDescriptor)), beanManager); }
public ProxyMethodHandler(String contextId, BeanInstance beanInstance, Bean<?> bean) { this.beanInstance = beanInstance; this.bean = bean; this.contextId = contextId; if (bean instanceof CommonBean<?>) { this.beanId = ((CommonBean<?>) bean).getIdentifier(); } else if (bean instanceof PassivationCapable) { this.beanId = new StringBeanIdentifier(((PassivationCapable) bean).getId()); } else { this.beanId = null; } }
public ExtensionBean(BeanManagerImpl manager, EnhancedAnnotatedType<E> enhancedAnnotatedType, Metadata<E> instance) { super(new StringBeanIdentifier(BeanIdentifiers.forExtension(enhancedAnnotatedType)), manager, enhancedAnnotatedType.getJavaClass()); this.annotatedType = enhancedAnnotatedType.slim(); this.instance = instance; this.passivationCapable = enhancedAnnotatedType.isSerializable(); this.proxiable = Proxies.isTypeProxyable(enhancedAnnotatedType.getBaseType(), manager.getServices()); checkPublicFields(enhancedAnnotatedType); }