Hi everyone!

I'm developing an API, a simple utility jar, for persistence (generic)
operations. The lib itself does not provide any persistence.xml file, it
takes into account that all its clients will have one to configure their
own persistence unit.

Inside my API I can't make assumptions about the persistence unit name for
the clients, so I'm simply doing something like this:

*public class MyGenericDAO {*
*    @Inject*
*    EntityManager em;*
*}*


... And every client who depends on the API will have a "Resource Producer":

*public class ResourcesProducer {*
*    @Produces*
*  @PersistenceContext( unitName = "some-pu")*
*    private EntityManager entityManager;*
*}*


This works as expected as long as each client have a single persistence
unit configured. The injection point in MyGenericDAO will resolve to
"some-pu" because there's only one. But if there are multiple persistence
units it won't work.

This was easy to solve with Seam (and also Spring) as we could
declaratively initialize any bean (component) property. As far as my
knowledge on CDI goes, this can't be done with CDI/JavaEE alone. So I was
wondering with Deltaspike has any feature to help with this issue.

Regards,

Reply via email to