use of org.apache.deltaspike.core.util.metadata.builder.AnnotatedTypeBuilder in project deltaspike by apache.
the class ConverterAndValidatorProxyExtension method createBean.
protected <T> Bean<T> createBean(Class<T> beanClass, BeanManager beanManager) {
Class<? extends InvocationHandler> invocationHandlerClass = Converter.class.isAssignableFrom(beanClass) ? ConverterInvocationHandler.class : ValidatorInvocationHandler.class;
AnnotatedType<T> annotatedType = new AnnotatedTypeBuilder<T>().readFromType(beanClass).create();
DeltaSpikeProxyContextualLifecycle lifecycle = new DeltaSpikeProxyContextualLifecycle(beanClass, invocationHandlerClass, ConverterAndValidatorProxyFactory.getInstance(), beanManager);
BeanBuilder<T> beanBuilder = new BeanBuilder<T>(beanManager).readFromType(annotatedType).passivationCapable(true).beanLifecycle(lifecycle);
return beanBuilder.create();
}
use of org.apache.deltaspike.core.util.metadata.builder.AnnotatedTypeBuilder in project deltaspike by apache.
the class PartialBeanBindingExtension method createPartialBean.
protected <T> Bean<T> createPartialBean(Class<T> beanClass, PartialBeanDescriptor descriptor, AfterBeanDiscovery afterBeanDiscovery, BeanManager beanManager) {
if (descriptor.getHandler() == null) {
afterBeanDiscovery.addDefinitionError(new IllegalStateException("A class which implements " + InvocationHandler.class.getName() + " and is annotated with @" + descriptor.getBinding().getName() + " is needed as a handler for " + beanClass.getName() + ". See the documentation about @" + PartialBeanBinding.class.getName() + "."));
return null;
}
AnnotatedType<T> annotatedType = new AnnotatedTypeBuilder<T>().readFromType(beanClass).create();
DeltaSpikeProxyContextualLifecycle lifecycle = new DeltaSpikeProxyContextualLifecycle(beanClass, descriptor.getHandler(), PartialBeanProxyFactory.getInstance(), beanManager);
BeanBuilder<T> beanBuilder = new BeanBuilder<T>(beanManager).readFromType(annotatedType).passivationCapable(true).beanLifecycle(lifecycle);
return beanBuilder.create();
}
Aggregations