New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

OmniFaces: Beans.getReference() + qualifier #284

Closed
fkjaekel opened this Issue Jul 7, 2016 · 1 comment

Comments

Projects
None yet
2 participants
@fkjaekel

fkjaekel commented Jul 7, 2016

I have the following CDI EntityManager producer:

    @ApplicationScoped
    public class EntityManagerProducer 
    {
        @PersistenceUnit(unitName = MySqlListener.PERSISTENCE_UNIT)
        private EntityManagerFactory    factory;

        @PersistenceUnit(unitName = FirebirdListener.PERSISTENCE_UNIT)
        private EntityManagerFactory    factoryFirebird;

        @Default
        @Produces
        @RequestScoped
        public EntityManager createEntityManager()
        {
            return factory.createEntityManager();
        }

        @Firebird
        @Produces
        @RequestScoped
        public EntityManager createEntityManagerFirebird()
        {
            return factoryFirebird.createEntityManager();
        }
    ...

To lookup a @firebird EntityManager I have to do this:

        final InitialContext context = new InitialContext();
        final BeanManager bm = (BeanManager) context.lookup("java:comp/BeanManager");

        @SuppressWarnings("unchecked") final Bean<EntityManager> bean = (Bean<EntityManager>) bm.getBeans(//
            EntityManager.class, //
            new AnnotationLiteral<Firebird>()
            {
                private static final long serialVersionUID = 1L;
            })//
            .iterator()//
            .next();//
        final CreationalContext<EntityManager> ctx = bm.createCreationalContext(bean);

        return (EntityManager) bm.getReference(bean, EntityManager.class, ctx);

I'd like to replace this code with Beans.getReference(), but I didn't find a way to inform the @firebird qualifier.

Could you consider it for a future OmniFaces release?

Thanks

@BalusC BalusC closed this in f81c53f Jul 8, 2016

BalusC added a commit that referenced this issue Jul 8, 2016

@BalusC

This comment has been minimized.

Show comment
Hide comment
@BalusC

BalusC Jul 8, 2016

Member

That was an oversight. I added them and they are available as per today's latest 2.5-SNAPSHOT.

Thank you for reporting this issue and improving OmniFaces!

Member

BalusC commented Jul 8, 2016

That was an oversight. I added them and they are available as per today's latest 2.5-SNAPSHOT.

Thank you for reporting this issue and improving OmniFaces!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment