-
1. Re: SMPC alternative
blabno Jan 27, 2012 12:22 PM (in response to blabno)I attach my temporary solution for additional non-managed persistence context. Note that @Regular is a custom Qualifier.
The problem is that if I don't want to use that persistence context directly but use some DAO that needs PersistenceContext injected then this won't work cause DAO wants SMPC.
Is it possible to annotate injection point so that SMPC is used if available and @Regular otherwise?
public class EntityManagerProducer { // ------------------------------ FIELDS ------------------------------ private final String PERSISTENCE_UNIT_NAME = "some-unit"; @ExtensionManaged @ConversationScoped @Produces @PersistenceUnit(unitName = PERSISTENCE_UNIT_NAME) private EntityManagerFactory emf; // -------------------------- OTHER METHODS -------------------------- @Regular @Produces public EntityManager getEM(@Regular EntityManagerFactory entityManagerFactory) { return entityManagerFactory.createEntityManager(); } @Regular @Produces public EntityManagerFactory getEmf() { return Persistence.createEntityManagerFactory(PERSISTENCE_UNIT_NAME); } }
-
2. Re: SMPC alternative
lightguard Jan 27, 2012 12:39 PM (in response to blabno)Scoping it to a different scope didn't work for you?
-
3. Re: SMPC alternative
blabno Jan 27, 2012 12:42 PM (in response to blabno)Jason, I'd like to have one default (mostly used from JSF) persistence context scoped to conversation.
But I also want to produce RSS feed with resteasy and abdera. Conversation is not available from rest call and i'd like to use my DAO's instead of that @Regular EntityManager.So, changing scope is not an option here.
-
4. Re: SMPC alternative
lightguard Jan 27, 2012 12:57 PM (in response to blabno)Hm. Are you using the Seam Conversation module? IIRC, Seam Rest can use it to enable the conversation scope for Rest. I haven't looked at it myself, but that may be one route to take.
-
5. Re: SMPC alternative
blabno Jan 30, 2012 12:53 PM (in response to blabno)Thanks Jason for pointing me into right direction.
I've mapped ConversationFilter to
rest
stuff.Now I can user ConversationScoped beans in Rest beans! Jupi!