Search in sources :

Example 1 with DeltaSpikeProxyContextualLifecycle

use of org.apache.deltaspike.proxy.api.DeltaSpikeProxyContextualLifecycle 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();
}
Also used : AnnotatedTypeBuilder(org.apache.deltaspike.core.util.metadata.builder.AnnotatedTypeBuilder) Converter(javax.faces.convert.Converter) DeltaSpikeProxyContextualLifecycle(org.apache.deltaspike.proxy.api.DeltaSpikeProxyContextualLifecycle)

Example 2 with DeltaSpikeProxyContextualLifecycle

use of org.apache.deltaspike.proxy.api.DeltaSpikeProxyContextualLifecycle 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();
}
Also used : AnnotatedTypeBuilder(org.apache.deltaspike.core.util.metadata.builder.AnnotatedTypeBuilder) DeltaSpikeProxyContextualLifecycle(org.apache.deltaspike.proxy.api.DeltaSpikeProxyContextualLifecycle)

Aggregations

AnnotatedTypeBuilder (org.apache.deltaspike.core.util.metadata.builder.AnnotatedTypeBuilder)2 DeltaSpikeProxyContextualLifecycle (org.apache.deltaspike.proxy.api.DeltaSpikeProxyContextualLifecycle)2 Converter (javax.faces.convert.Converter)1