Search in sources :

Example 6 with ClassTransformer

use of org.jboss.weld.resources.ClassTransformer in project core by weld.

the class SimpleWeldClassTest method testWeldClassForCovariantReturnType.

/*
    * description = "WELD-568"
    */
@Category(Broken.class)
@Test
public void testWeldClassForCovariantReturnType() {
    TypeStore typeStore = new TypeStore();
    EnhancedAnnotatedType<Attacker> weldClass = new ClassTransformer(typeStore, new SharedObjectCache(), ReflectionCacheFactory.newInstance(typeStore), RegistrySingletonProvider.STATIC_INSTANCE).getEnhancedAnnotatedType(Attacker.class, AnnotatedTypeIdentifier.NULL_BDA_ID);
    Collection<EnhancedAnnotatedMethod<?, ? super Attacker>> methods = weldClass.getEnhancedMethods();
    Assert.assertEquals(4, methods.size());
    List<EnhancedAnnotatedMethod<?, ?>> interceptableMethods = Beans.getInterceptableMethods(weldClass);
    Assert.assertEquals(4, interceptableMethods.size());
}
Also used : SharedObjectCache(org.jboss.weld.resources.SharedObjectCache) TypeStore(org.jboss.weld.metadata.TypeStore) ClassTransformer(org.jboss.weld.resources.ClassTransformer) EnhancedAnnotatedMethod(org.jboss.weld.annotated.enhanced.EnhancedAnnotatedMethod) Category(org.junit.experimental.categories.Category) Test(org.junit.Test)

Example 7 with ClassTransformer

use of org.jboss.weld.resources.ClassTransformer in project core by weld.

the class SimpleWeldClassTest method testWeldClassForGenericSuperclass.

/*
    * description = "WELD-568"
    */
@Test
public void testWeldClassForGenericSuperclass() {
    TypeStore ts = new TypeStore();
    EnhancedAnnotatedType<StringProcessor> weldClass = new ClassTransformer(ts, new SharedObjectCache(), ReflectionCacheFactory.newInstance(ts), RegistrySingletonProvider.STATIC_INSTANCE).getEnhancedAnnotatedType(StringProcessor.class, AnnotatedTypeIdentifier.NULL_BDA_ID);
    Collection<EnhancedAnnotatedMethod<?, ? super StringProcessor>> methods = weldClass.getEnhancedMethods();
    // assert methods.size() == 2;
    List<EnhancedAnnotatedMethod<?, ?>> interceptableMethods = Beans.getInterceptableMethods(weldClass);
    Assert.assertEquals(3, interceptableMethods.size());
}
Also used : SharedObjectCache(org.jboss.weld.resources.SharedObjectCache) TypeStore(org.jboss.weld.metadata.TypeStore) ClassTransformer(org.jboss.weld.resources.ClassTransformer) EnhancedAnnotatedMethod(org.jboss.weld.annotated.enhanced.EnhancedAnnotatedMethod) Test(org.junit.Test)

Example 8 with ClassTransformer

use of org.jboss.weld.resources.ClassTransformer in project core by weld.

the class AccessibleManagerResolutionTest method beforeMethod.

@BeforeMethod
public void beforeMethod() {
    BeanIdentifierIndex beanIdentifierIndex = new BeanIdentifierIndex();
    beanIdentifierIndex.build(Collections.<Bean<?>>emptySet());
    this.typeStore = new TypeStore();
    this.classTransformer = new ClassTransformer(typeStore, new SharedObjectCache(), ReflectionCacheFactory.newInstance(typeStore), RegistrySingletonProvider.STATIC_INSTANCE);
    this.services = new SimpleServiceRegistry();
    this.services.add(MetaAnnotationStore.class, new MetaAnnotationStore(classTransformer));
    this.services.add(ContextualStore.class, new ContextualStoreImpl(STATIC_INSTANCE, beanIdentifierIndex));
    this.services.add(ClassTransformer.class, classTransformer);
    this.services.add(SharedObjectCache.class, new SharedObjectCache());
    this.services.add(WeldConfiguration.class, new WeldConfiguration(this.services, new MockDeployment(services)));
    this.services.add(SecurityServices.class, NoopSecurityServices.INSTANCE);
    this.services.add(ObserverNotifierFactory.class, DefaultObserverNotifierFactory.INSTANCE);
    this.services.add(GlobalObserverNotifierService.class, new GlobalObserverNotifierService(services, RegistrySingletonProvider.STATIC_INSTANCE));
    this.services.add(ExpressionLanguageSupport.class, WeldWebModule.EL_SUPPORT);
    this.services.add(SpecializationAndEnablementRegistry.class, new SpecializationAndEnablementRegistry());
    this.services.add(InterceptorsApiAbstraction.class, new InterceptorsApiAbstraction(DefaultResourceLoader.INSTANCE));
    this.services.add(ProxyInstantiator.class, DefaultProxyInstantiator.INSTANCE);
    this.services.add(ResourceInjectionFactory.class, new ResourceInjectionFactory());
    this.services.add(EjbSupport.class, EjbSupport.NOOP_IMPLEMENTATION);
    // create BeanManagerImpl and initialize container
    root = BeanManagerImpl.newRootManager(STATIC_INSTANCE, "root", services);
    Container.initialize(root, services);
    // add injection target service; has to be done once container was initialized
    this.services.add(InjectionTargetService.class, new InjectionTargetService(root));
}
Also used : SpecializationAndEnablementRegistry(org.jboss.weld.bootstrap.SpecializationAndEnablementRegistry) ResourceInjectionFactory(org.jboss.weld.injection.ResourceInjectionFactory) MetaAnnotationStore(org.jboss.weld.metadata.cache.MetaAnnotationStore) ClassTransformer(org.jboss.weld.resources.ClassTransformer) BeanIdentifierIndex(org.jboss.weld.serialization.BeanIdentifierIndex) InterceptorsApiAbstraction(org.jboss.weld.interceptor.builder.InterceptorsApiAbstraction) SharedObjectCache(org.jboss.weld.resources.SharedObjectCache) SimpleServiceRegistry(org.jboss.weld.bootstrap.api.helpers.SimpleServiceRegistry) TypeStore(org.jboss.weld.metadata.TypeStore) InjectionTargetService(org.jboss.weld.injection.producer.InjectionTargetService) GlobalObserverNotifierService(org.jboss.weld.event.GlobalObserverNotifierService) WeldConfiguration(org.jboss.weld.config.WeldConfiguration) ContextualStoreImpl(org.jboss.weld.serialization.ContextualStoreImpl) BeforeMethod(org.testng.annotations.BeforeMethod)

Example 9 with ClassTransformer

use of org.jboss.weld.resources.ClassTransformer in project core by weld.

the class WeldStartup method setupInitialServices.

private void setupInitialServices() {
    if (initialServices.contains(TypeStore.class)) {
        return;
    }
    // instantiate initial services which we need for this phase
    TypeStore store = new TypeStore();
    SharedObjectCache cache = new SharedObjectCache();
    ReflectionCache reflectionCache = ReflectionCacheFactory.newInstance(store);
    ClassTransformer classTransformer = new ClassTransformer(store, cache, reflectionCache, contextId);
    initialServices.add(TypeStore.class, store);
    initialServices.add(SharedObjectCache.class, cache);
    initialServices.add(ReflectionCache.class, reflectionCache);
    initialServices.add(ClassTransformer.class, classTransformer);
}
Also used : ReflectionCache(org.jboss.weld.resources.ReflectionCache) SharedObjectCache(org.jboss.weld.resources.SharedObjectCache) TypeStore(org.jboss.weld.metadata.TypeStore) SlimAnnotatedTypeStore(org.jboss.weld.annotated.slim.SlimAnnotatedTypeStore) ClassTransformer(org.jboss.weld.resources.ClassTransformer)

Example 10 with ClassTransformer

use of org.jboss.weld.resources.ClassTransformer in project core by weld.

the class SubclassedComponentInstantiator method initEnhancedSubclass.

protected EnhancedAnnotatedConstructor<T> initEnhancedSubclass(BeanManagerImpl manager, EnhancedAnnotatedType<T> type, Bean<?> bean, ConstructorInjectionPoint<T> originalConstructorInjectionPoint) {
    ClassTransformer transformer = manager.getServices().get(ClassTransformer.class);
    EnhancedAnnotatedType<T> enhancedSubclass = transformer.getEnhancedAnnotatedType(createEnhancedSubclass(type, bean, manager), type.slim().getIdentifier().getBdaId());
    return findMatchingConstructor(originalConstructorInjectionPoint.getSignature(), enhancedSubclass);
}
Also used : ClassTransformer(org.jboss.weld.resources.ClassTransformer)

Aggregations

ClassTransformer (org.jboss.weld.resources.ClassTransformer)13 TypeStore (org.jboss.weld.metadata.TypeStore)7 SharedObjectCache (org.jboss.weld.resources.SharedObjectCache)7 SlimAnnotatedTypeStore (org.jboss.weld.annotated.slim.SlimAnnotatedTypeStore)3 Test (org.junit.Test)3 EnhancedAnnotatedMethod (org.jboss.weld.annotated.enhanced.EnhancedAnnotatedMethod)2 EnhancedAnnotatedType (org.jboss.weld.annotated.enhanced.EnhancedAnnotatedType)2 ReflectionCache (org.jboss.weld.resources.ReflectionCache)2 Annotation (java.lang.annotation.Annotation)1 Type (java.lang.reflect.Type)1 HashSet (java.util.HashSet)1 BeanAttributes (javax.enterprise.inject.spi.BeanAttributes)1 SlimAnnotatedType (org.jboss.weld.annotated.slim.SlimAnnotatedType)1 SpecializationAndEnablementRegistry (org.jboss.weld.bootstrap.SpecializationAndEnablementRegistry)1 SimpleServiceRegistry (org.jboss.weld.bootstrap.api.helpers.SimpleServiceRegistry)1 WeldConfiguration (org.jboss.weld.config.WeldConfiguration)1 ContextNotActiveException (org.jboss.weld.context.ContextNotActiveException)1 GlobalObserverNotifierService (org.jboss.weld.event.GlobalObserverNotifierService)1 ResourceInjectionFactory (org.jboss.weld.injection.ResourceInjectionFactory)1 InjectionTargetService (org.jboss.weld.injection.producer.InjectionTargetService)1