openwebbeans-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Joseph Bergmark <>
Subject Re: Standalone extension and manual bean discovery
Date Tue, 09 Nov 2010 22:07:57 GMT
Another option to feed classes into OWB would be to implement your own
ScannerService (from the openwebbeans-spi project) and pass those classes in
from getBeanClasses.  If you want to prevent a scan, you may wish to do this
anyway and return an empty list.

You will need to provide your own file to overwrite
the default ScannerService.



On Tue, Nov 9, 2010 at 4:38 PM, Rohit Kelapure <> wrote:

> Aaron,
> *Does*
> import org.apache.webbeans.container.BeanManagerImpl;
> ((BeanManagerImpl) lifecycle.getBeanManager()).getComponents();
> return a different set of beans ?
> --Thanks,
> Rohit
> On Tue, Nov 9, 2010 at 10:38 AM, Aaron Anderson <>wrote:
>> Hi,
>> I am writing a standalone application outside of JavaEE and I would like
>> to use OpenWebBeans for dependency injection. I have discovered the
>> standalone sample and I am able to boot up my own standalone environment.
>> I do not wish to use the automatic bean discovery method but instead wish
>> to manually control which beans are exposed to the container. In JavaEE I
>> would set the metadata-complete flag to false but I am not sure if there is
>> a SE equivalent. In my application I have not included a beans.xml file but
>> instead I have written a simple extension that observes the
>> BeforeBeanDiscovery event and then manually adds all the beans I desire to
>> be managed:
>> public void beforeBeanDiscovery (@Observes BeforeBeanDiscovery bbd,
>> BeanManager bm){
>>   bbd.addAnnotatedType(bm.createAnnotatedType(MyBean.class));
>> }
>> I thought this would be sufficient to add my class for discovery but after
>> the lifecycle is started and I dump all the beans using
>> lifecycle.getBeanManager().getBeans(Object.class,
>> AnnotationLiteral<Any>(){});
>> only the standard CDI classes are present. Any idea of what I am doing
>> wrong or if there a superior way to accomplish my goal of manually "wiring"
>> beans together in a CDI extension?
>>  Thanks,
>> Aaron

View raw message