You're right Dan :) On Wed, Mar 9, 2011 at 13:30, Dan Allen <[email protected]> wrote: > On Wed, Mar 9, 2011 at 11:30, Jason Porter <[email protected]> wrote: >> >> On Wed, Mar 9, 2011 at 09:03, aalmiray <[email protected]> wrote: >> > Hello guys. I'm new to Weld and CDI, perhaps the subject of this message >> > is a >> > bit obvious to some of you but for the life of me couldn't find a >> > portable >> > solution to the following problem: Weld will pick up all classes of an >> > application (found in a single jar that contains an empty beans.xml >> > file), >> > however I would like the container to cherry pick a set of classes based >> > on >> > some criteria (package name, class name convention, annotation, etc). >> > >> > I've seen that Weld has an extension (non-standard) that allows classes >> > to >> > be annotated with @Veto. It works fine but it poses to additional >> > problems: >> > - @Veto is Weld specific >> >> The annotation is specific to Weld (hopefully will make it into the >> CDI 1.1 spec), but the way it works is not. > > Two corrections :) @Veto is part of Seam (Seam Solder), not Weld. Also, it > is portable, as it's based on the portable extension facility in CDI. > Since you can write your own extensions, the solutions to your question are > boundless. i can give you some other starting points to consider. > Instead of including beans.xml, which will automatically cause all candidate > types to be picked up as beans, you can go the other route and leave out > beans.xml, and register beans explicitly. Here's an example: > public class ManualBeanRegistrationExtension implements Extension { > public void registerBeans(@Observes BeforeBeanDiscovery event, > BeanManager bm) { > > event.addAnnotatedType(bm.createAnnotatedType(BeanClassToRegister.class)); > } > } > Another approach is to use Weld's scanning configuration. That is a > non-portable solution, though, so you'd have weigh that. If I'm not > mistaken, that feature is being discussed for CDI 1.1. > http://docs.jboss.org/weld/reference/1.1.0.Final/en-US/html/configure.html#d0e5767 > -Dan > -- > Dan Allen > Principal Software Engineer, Red Hat | Author of Seam in Action > Registered Linux User #231597 > > http://www.google.com/profiles/dan.j.allen#about > http://mojavelinux.com > http://mojavelinux.com/seaminaction > >
-- Jason Porter http://lightguard-jp.blogspot.com http://twitter.com/lightguardjp Software Engineer Open Source Advocate Author of Seam Catch - Next Generation Java Exception Handling PGP key id: 926CCFF5 PGP key available at: keyserver.net, pgp.mit.edu _______________________________________________ weld-dev mailing list [email protected] https://lists.jboss.org/mailman/listinfo/weld-dev
