-
1. Re: question about application scope component?
gavin.king Feb 1, 2006 10:07 AM (in response to liudan2005)Just make it an APPLICATION scoped Seam component. You can use the @Startup annotation to ensure it gets instantiated during the startup cycle. Retrieve the data in an @Create method.
-
2. Re: question about application scope component?
liudan2005 Feb 1, 2006 5:15 PM (in response to liudan2005)Thanks for your help Gavin.
I followed you and made a seam component(not a stateful or stateless bean) with following annotations:
@Name("globalparams")
@Scope(ScopeType.APPLICATION)
@Startup
@Interceptors(SeamInterceptor.class)
this works fine but I can't inject @PersistenceContext EntityManager anymore, it seems I can only inject EntityManager in a stateful or stateless ejb. Since I need to retrive data in my @Create method, I need to inject an EntityManager or another ejb using @Ejb. I've tried both way but non of them work. Is there any better to do this? -
3. Re: question about application scope component?
liudan2005 Feb 1, 2006 6:35 PM (in response to liudan2005)Problem solved by use:
InitialContext ctx = new InitialContext();
ctx.lookup("app/beanname/local");
Thanks. -
4. Re: question about application scope component?
gavin.king Feb 2, 2006 1:01 PM (in response to liudan2005)The other option is to use a seam-managed EntityManager.
@PersistenceContext only works in an EJB. -
5. Re: question about application scope component?
jboss-nth-fan Dec 11, 2006 3:41 AM (in response to liudan2005)Hi Folks,
I have the exact same issue here, however not sure how to use the seam-Managed EM.
Just to be sure, is it the one in: "13.4.2. Using a Seam-managed persistence context" from the Seam Ref Doc 1.1.CR2 ?
I've tried (as per ref) to add it to the components.xml, no luck<core:managed-persistence-context name="bookingDatabase" auto-create="true" persistence-unit-jndi-name="java:/EntityManagerFactories/bookingData"/>
The DTD for components.xml does not seem to like the 'core' tag, or is the Documentation incorrect ?
Any pointers will be helpful !
Yeyo -
6. Re: question about application scope component?
gavin.king Dec 11, 2006 4:13 AM (in response to liudan2005)You must use XSDs, not a DTD. Look at the booking example to see how.
-
7. Re: question about application scope component?
jboss-nth-fan Dec 11, 2006 9:55 PM (in response to liudan2005)Indeed, that's clear now.
Maybe I've got the DTD definition (and the error) as I was using a scaffolded Entity from SeamGen.
Thanks for your promptly assistance!
Yeyo -
8. Re: question about application scope component?
jboss-nth-fan Dec 12, 2006 12:18 AM (in response to liudan2005)Ignore my last comment, I've just confirmed it's fixed in CVS in 1.5
Y