[weld-dev] Initialising newly registered beans

Pete Muir pmuir at redhat.com
Mon Nov 30 07:29:53 EST 2009


Why are you doing this?

We had this working properly, just passing in the classes to scan in the past using bootstrap.

All of this stuff you are accessing is internal impl detail in Weld, it is *not* part of the Weld SPI...

On 29 Nov 2009, at 23:21, Peter Royle wrote:

> Hi,
> 
> I've got this extension which I'm using to explicitly register all of the managed beans used by Weld Java SE:
> 
> public class WeldSEBeanRegistrant implements Extension
> {
> 
>    private final ClassTransformer transformer = new ClassTransformer(new TypeStore());
> 
>    public void registerWeldSEBeans(@Observes AfterBeanDiscovery event, BeanManagerImpl beanManager)
>    {
>        addBean(ShutdownManager.class, beanManager, event);
>        addBean(ParametersFactory.class, beanManager, event);
>    }
> 
>    private void addBean(final Class<?> klass, BeanManagerImpl beanManager, AfterBeanDiscovery event)
>    {
>        WeldClass<?> weldClass = WeldClassImpl.of(klass, transformer);
>        ManagedBean<?> bean = ManagedBean.of(weldClass, beanManager);
>        event.addBean(bean);
>        bean.initialize( ___environment___);
>    }
> }
> 
> My question is: where should I get the value for ___environment___ from? Is there common idiom for this? 
> 
> I feel like if I could get access to the 'parent' variable at WeldBootstrap:199 I could call it.getBeanDeployer().getEnvironment() ... but I could be way off!
> 
> Cheers,
> 
> Pete.
> 
> 
> 
> _______________________________________________
> weld-dev mailing list
> weld-dev at lists.jboss.org
> https://lists.jboss.org/mailman/listinfo/weld-dev




More information about the weld-dev mailing list