openwebbeans-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Aaron Anderson <nickmalt...@yahoo.com>
Subject Re: Standalone extension and manual bean discovery
Date Tue, 09 Nov 2010 23:34:14 GMT
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 (https://svn.apache.org/repos/asf/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/container/BeanManagerImpl.java)
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.

Thanks!

Aaron
 

--- On Tue, 11/9/10, Joseph Bergmark <bergmark@apache.org> wrote:

From: Joseph Bergmark <bergmark@apache.org>
Subject: Re: Standalone extension and manual bean discovery
To: user@openwebbeans.apache.org
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 openwebbeans.properties file to overwrite the default ScannerService.
Sincerely,
Joe

On Tue, Nov 9, 2010 at 4:38 PM, Rohit Kelapure <kelapure@gmail.com> 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 <nickmalthus@yahoo.com> 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






Mime
View raw message