openwebbeans-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Mark Struberg <>
Subject Re: Standalone extension and manual bean discovery
Date Tue, 09 Nov 2010 23:40:30 GMT
That makes perfect sense. Thanks for sharing your observation!
We will try to fix this asap.


--- On Tue, 11/9/10, Aaron Anderson <> wrote:

From: Aaron Anderson <>
Subject: Re: Standalone extension and manual bean discovery
Date: Tuesday, November 9, 2010, 11:34 PM

Hi Joe/Rohit,

Thanks for your feedback. 

After looking into this issue further I believe my problem is due to an openwebbeans spec
compliance issue. In section 11.5.1. of JSR 299 it states:

addAnnotatedType() adds a given AnnotatedType to the set of types which will be scanned during
bean discovery.

However the addAdditionalAnnotatedType method of the BeanManagerImpl (
simply adds the types to a private list and the values are never acted upon. I tested out
my same extension code in weld and it worked as expected.

I have created issue OWB-489 in response to my findings.



--- On Tue, 11/9/10, Joseph Bergmark <>

From: Joseph Bergmark <>
Subject: Re: Standalone extension and manual bean discovery
Date: Tuesday, November 9, 2010, 4:07 PM

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:

import org.apache.webbeans.container.BeanManagerImpl;
((BeanManagerImpl) lifecycle.getBeanManager()).getComponents();

return a different set of beans ?
On Tue, Nov 9, 2010 at 10:38 AM, Aaron Anderson <> wrote:


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){

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?




View raw message