On 01/12/2009, at 1:22 AM, Pete Muir wrote:
OIC, sorry, I misread your email.
A much easier approach is to do:
public void registerWeldSEBeans(@Observes BeforeBeanDiscovery event, BeanManagerImpl
beanManager)
{
event.addAnnotatedType(beanManager.createAnnoatedType(ShutdownManager.class));
event.addAnnotatedType(beanManager.createAnnoatedType(ParametersFactory.class));
}
which adds those classes to the ones that Weld will discover.
Cool thanks :).
Alternatively, since you control the scanning and bootstrap, you
could add them even earlier, when we create BeanDeploymentArchive.
Yeah that's a good idea, I'll think about that.
Cheers,
Pete.
On 30 Nov 2009, at 15:19, Peter Royle wrote:
>
> On 30/11/2009, at 10:29 PM, Pete Muir wrote:
>
>> Why are you doing this?
>
> The ShutdownManager and ParametersFactory beans are currently discovered using
conventional classpath scanning. IE: there is a /META-INF/beans.xml in the weld-se jar.
Therefore when I create a shaded jar of Weld SE, every class in the dependant jars gets
picked up as a simple bean, which obviously wreaks havoc.
>
>> We had this working properly, just passing in the classes to scan in the past
using bootstrap.
>
> Not sure what you mean, but if it's easier I'm all ears :).
>
>> All of this stuff you are accessing is internal impl detail in Weld, it is *not*
part of the Weld SPI...
>
> Yeah I know but since this part of Weld SE and doesn't need to be portable I just
went with the easiest classes to work with. If I need to continue down this path I'll
hit you up for some pointers.
>
> Pete.
>
>
>
>>
>> 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(a)lists.jboss.org
>>>
https://lists.jboss.org/mailman/listinfo/weld-dev
>>
>