Well well well. Some random forum surfing and one more try, and now this works:
/**
| * Local interface to replog.
| * TODO: do we really want this??? are we getting into a synchronization
mess?!?!?!?! or is it Just Right????????
| */
| @Local
| public interface Replog {
| public void init();
|
| public void destroy();
|
| public Site getSite();
| }
|
| @Startup
| @Scope(APPLICATION)
| @Stateful
| @Name("replogApplication")
| public class ReplogApplication implements Replog {
| ...
| @PersistenceContext // why does this work but @In doesn't?
| private transient EntityManager entityManager;
|
| // SiteSynchronizers, indexed by Site
| private Map synchronizers = new HashMap();
|
| /** The Site we consider to be "this application's site" */
| private Site site;
|
| @Create
| public void init ()
| {
| log.debug("Creating replogApplication");
|
| // for now, create one SiteSynchronizer per defined Site
| List<Site> sites = entityManager.createQuery("from
Site").getResultList();
|
| for (Site site : sites) {
| synchronizers.put(site, new SiteSynchronizer(site));
| ...
| }
| }
|
| @Remove @Destroy
| public void destroy () {
| }
|
| /** Get the current Site. Should this really be an Application context
component instead????? */
| public Site getSite () {
| return site;
| }
| }
So, @PersistenceContext was part of the secret. Looks like the EJB3 lifecycle
methods have to be in the local interface too. I would probably know this if I
hadn't started learning Seam before EJB3....
Why does @PersistenceContext work here but @In doesn't? I think I'm good to go
now (modulo the possibility that I'm still arranging my components the wrong
way, but some more code iteration will clue me in there). But I'm still
curious why the first way didn't work; I think there's some deep Seam knowledge
in there somewhere...?
Cheers!
Rob
View the original post :
http://www.jboss.com/index.html?module=bb&op=viewtopic&p=3967420#3967420
Reply to the post :
http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=3967420
_______________________________________________
jboss-user mailing list
[email protected]
https://lists.jboss.org/mailman/listinfo/jboss-user