private static ClassTransformer getClassTransformer() { TypeStore store = new TypeStore(); SharedObjectCache cache = new SharedObjectCache(); ReflectionCache reflectionCache = ReflectionCacheFactory.newInstance(store); ClassTransformer classTransformer = new ClassTransformer(store, cache, reflectionCache, "STATIC_INSTANCE"); return classTransformer; }
public BeanAttributesBuilder(EnhancedAnnotated<T, ?> annotated, BeanManagerImpl manager) { this(annotated, SharedObjectCache.instance(manager).getSharedSet(Beans.getTypes(annotated)), manager); }
@Override public void cleanup() { cleanupAfterBoot(); } }
public UnbackedAnnotatedConstructor(Type baseType, Set<Type> typeClosure, Set<Annotation> annotations, UnbackedAnnotatedType<X> declaringType, List<AnnotatedParameter<X>> originalParameters, Constructor<X> constructor, SharedObjectCache cache) { super(baseType, typeClosure, cache.getSharedSet(annotations), declaringType); this.constructor = constructor; List<AnnotatedParameter<X>> parameters = new ArrayList<AnnotatedParameter<X>>(originalParameters.size()); for (AnnotatedParameter<X> originalParameter : originalParameters) { parameters.add(new UnbackedAnnotatedParameter<X>(originalParameter.getBaseType(), originalParameter.getTypeClosure(), cache.getSharedSet(originalParameter.getAnnotations()), originalParameter.getPosition(), this)); } this.parameters = ImmutableList.copyOf(parameters); }
this.observerMethod = initMethodInjectionPoint(observer, declaringBean, manager); EnhancedAnnotatedParameter<?, ? super X> eventParameter = observer.getEnhancedParameters(Observes.class).get(0); this.eventType = new HierarchyDiscovery(declaringBean.getBeanClass()).resolveType(eventParameter.getBaseType()); this.id = createId(observer, declaringBean); this.bindings = manager.getServices().get(SharedObjectCache.class) .getSharedSet(observer.getEnhancedParameters(Observes.class).get(0).getMetaAnnotations(Qualifier.class)); Observes observesAnnotation = observer.getEnhancedParameters(Observes.class).get(0).getAnnotation(Observes.class); this.reception = observesAnnotation.notifyObserver(); transactionPhase = ObserverFactory.getTransactionalPhase(observer); ImmutableSet.Builder<WeldInjectionPointAttributes<?, ?>> injectionPoints = ImmutableSet.builder(); for (ParameterInjectionPoint<?, ?> injectionPoint : observerMethod.getParameterInjectionPoints()) { if (injectionPoint instanceof SpecialParameterInjectionPoint) { continue; injectionPoints.add(injectionPoint); this.injectionPoints = injectionPoints.build(); this.isStatic = observer.isStatic(); this.eventMetadataRequired = initMetadataRequired(this.injectionPoints);
protected InferringParameterInjectionPointAttributes(EnhancedAnnotatedParameter<T, X> parameter, Bean<?> bean, Class<?> declaringComponentClass, BeanManagerImpl manager) { super(parameter, manager.getContextId(), bean, SharedObjectCache.instance(manager).getSharedSet(parameter.getQualifiers()), declaringComponentClass); this.parameter = parameter.slim(); }
protected InferringFieldInjectionPointAttributes(EnhancedAnnotatedField<T, X> field, Bean<?> bean, Class<?> declaringComponentClass, BeanManagerImpl manager) { super(field, manager.getContextId(), bean, SharedObjectCache.instance(manager).getSharedSet(field.getQualifiers()), declaringComponentClass); this.field = field.slim(); }
/** * * @param annotations * @return the set of qualifier instances, uses caches if possible */ public Set<QualifierInstance> getQualifierInstances(final Set<Annotation> annotations) { if (annotations == null || annotations.isEmpty()) { return Collections.emptySet(); } ImmutableSet.Builder<QualifierInstance> builder = ImmutableSet.builder(); boolean useSharedCache = true; for (Annotation annotation : annotations) { if (isCacheAllowed(annotation)) { builder.add(qualifierInstanceCache.getValue(annotation)); } else { builder.add(QualifierInstance.of(annotation, this)); // Don't use shared object cache if there's some qualifier instance which should not be cached useSharedCache = false; } } return useSharedCache ? sharedObjectCache.getSharedSet(builder.build()) : builder.build(); }
/** * Constructor * * @param stereotypeAnnotations The stereotypes to merge */ protected MergedStereotypes(Set<Annotation> stereotypeAnnotations, BeanManagerImpl manager) { this.possibleScopeTypes = new HashSet<Annotation>(); this.stereotypes = new HashSet<Class<? extends Annotation>>(); this.manager = manager; merge(stereotypeAnnotations); this.stereotypes = SharedObjectCache.instance(manager).getSharedSet(stereotypes); }
protected void initQualifiers(Set<Annotation> qualifiers) { if (qualifiers.isEmpty()) { this.qualifiers = DEFAULT_QUALIFIERS; } else { ImmutableSet.Builder<Annotation> normalizedQualifiers = ImmutableSet.builder(); if (qualifiers.size() == 1 && qualifiers.iterator().next().annotationType().equals(Named.class)) { normalizedQualifiers.add(DefaultLiteral.INSTANCE); } for (Annotation annotation : qualifiers) { if (name != null && annotation.equals(NamedLiteral.DEFAULT)) { normalizedQualifiers.add(new NamedLiteral(name)); } else { normalizedQualifiers.add(annotation); } } normalizedQualifiers.add(AnyLiteral.INSTANCE); this.qualifiers = SharedObjectCache.instance(manager).getSharedSet(normalizedQualifiers.build()); } }
protected LazyValueHolder<Set<Type>> initTypeClosure(Type baseType, SharedObjectCache cache) { return cache.getTypeClosureHolder(baseType); }
public static <X, Y extends X> AnnotatedField<X> of(AnnotatedField<X> originalField, UnbackedAnnotatedType<Y> declaringType, SharedObjectCache cache) { UnbackedAnnotatedType<X> downcastDeclaringType = cast(declaringType); return new UnbackedAnnotatedField<X>(originalField.getBaseType(), originalField.getTypeClosure(), cache.getSharedSet(originalField.getAnnotations()), originalField.getJavaMember(), downcastDeclaringType); }
public UnbackedAnnotatedConstructor(Type baseType, Set<Type> typeClosure, Set<Annotation> annotations, UnbackedAnnotatedType<X> declaringType, List<AnnotatedParameter<X>> originalParameters, Constructor<X> constructor, SharedObjectCache cache) { super(baseType, typeClosure, cache.getSharedSet(annotations), declaringType); this.constructor = constructor; List<AnnotatedParameter<X>> parameters = new ArrayList<AnnotatedParameter<X>>(originalParameters.size()); for (AnnotatedParameter<X> originalParameter : originalParameters) { parameters.add(new UnbackedAnnotatedParameter<X>(originalParameter.getBaseType(), originalParameter.getTypeClosure(), cache.getSharedSet(originalParameter.getAnnotations()), originalParameter.getPosition(), this)); } this.parameters = ImmutableList.copyOf(parameters); }
this.reception = eventParameter.getAnnotation(ObservesAsync.class).notifyObserver(); this.reception = eventParameter.getAnnotation(Observes.class).notifyObserver(); this.transactionPhase = ObserverFactory.getTransactionalPhase(observer); this.bindings = manager.getServices().get(SharedObjectCache.class) .getSharedSet(eventParameter.getMetaAnnotations(Qualifier.class)); this.eventType = new HierarchyDiscovery(declaringBean.getBeanClass()).resolveType(eventParameter.getBaseType()); ImmutableSet.Builder<WeldInjectionPointAttributes<?, ?>> injectionPoints = ImmutableSet.builder(); for (ParameterInjectionPoint<?, ?> injectionPoint : observerMethod.getParameterInjectionPoints()) { if (injectionPoint instanceof SpecialParameterInjectionPoint) { continue; injectionPoints.add(injectionPoint); this.injectionPoints = injectionPoints.build(); Priority priority = eventParameter.getAnnotation(Priority.class); if (priority == null) {
protected InferringParameterInjectionPointAttributes(EnhancedAnnotatedParameter<T, X> parameter, Bean<?> bean, Class<?> declaringComponentClass, BeanManagerImpl manager) { super(parameter, manager.getContextId(), bean, SharedObjectCache.instance(manager).getSharedSet(parameter.getQualifiers()), declaringComponentClass); this.parameter = parameter.slim(); }
protected InferringFieldInjectionPointAttributes(EnhancedAnnotatedField<T, X> field, Bean<?> bean, Class<?> declaringComponentClass, BeanManagerImpl manager) { super(field, manager.getContextId(), bean, SharedObjectCache.instance(manager).getSharedSet(field.getQualifiers()), declaringComponentClass); this.field = field.slim(); }
/** * * @param annotations * @return the set of qualifier instances, uses caches if possible */ public Set<QualifierInstance> getQualifierInstances(final Set<Annotation> annotations) { if (annotations == null || annotations.isEmpty()) { return Collections.emptySet(); } ImmutableSet.Builder<QualifierInstance> builder = ImmutableSet.builder(); boolean useSharedCache = true; for (Annotation annotation : annotations) { if (isCacheAllowed(annotation)) { builder.add(qualifierInstanceCache.getValue(annotation)); } else { builder.add(QualifierInstance.of(annotation, this)); // Don't use shared object cache if there's some qualifier instance which should not be cached useSharedCache = false; } } return useSharedCache ? sharedObjectCache.getSharedSet(builder.build()) : builder.build(); }
/** * Constructor * * @param stereotypeAnnotations The stereotypes to merge */ protected MergedStereotypes(Set<Annotation> stereotypeAnnotations, BeanManagerImpl manager) { this.possibleScopeTypes = new HashSet<Annotation>(); this.stereotypes = new HashSet<Class<? extends Annotation>>(); this.manager = manager; merge(stereotypeAnnotations); this.stereotypes = SharedObjectCache.instance(manager).getSharedSet(stereotypes); }
protected LazyValueHolder<Set<Type>> initTypeClosure(Type baseType, SharedObjectCache cache) { return cache.getTypeClosureHolder(baseType); }
public UnbackedAnnotatedConstructor(Type baseType, Set<Type> typeClosure, Set<Annotation> annotations, UnbackedAnnotatedType<X> declaringType, List<AnnotatedParameter<X>> originalParameters, Constructor<X> constructor, SharedObjectCache cache) { super(baseType, typeClosure, cache.getSharedSet(annotations), declaringType); this.constructor = constructor; List<AnnotatedParameter<X>> parameters = new ArrayList<AnnotatedParameter<X>>(originalParameters.size()); for (AnnotatedParameter<X> originalParameter : originalParameters) { parameters.add(new UnbackedAnnotatedParameter<X>(originalParameter.getBaseType(), originalParameter.getTypeClosure(), cache.getSharedSet(originalParameter.getAnnotations()), originalParameter.getPosition(), this)); } this.parameters = immutableListView(parameters); }