Hey,

I had a look and used this to implement a servlet-module: 
http://code.google.com/p/google-guice/wiki/ServletModule
My Module looks like the example from your session per request link: 
http://code.google.com/p/google-guice/wiki/JPA#Web_Environments_%28session-per-http-request%29

In the web.xml I put a Listener.
<listener>
  
<listener-class>de.mash.project.shared.MyGuiceServletConfig</listener-class>
</listener>

The Listener looks like this:
public class MyGuiceServletConfig extends GuiceServletContextListener {

      @Override
      protected Injector getInjector() {
          return Guice.createInjector(new MyServletModule());          
      }  
    }

Then I added the following in my Worker Entity-class:

//@RequestScoped

@Entity
@Table(name = "Worker")
public class Worker {

*@Transient
@Inject    static EntityManager em3;*

...

* @Transactional*
  public void persist() {...}


*@Transactional*
public static Worker findWorker(Long id) {...}
}

I set a breakpoint on my doFilter() method in my PersistFilter, and its 
just doing what Jens descripted above.


> EntityManager em = create(); //save this em instance somewhere so you can 
> access it in your RF service methods, e.g. using a static ThreadLocal
> filterChain.doFilter() //this calls the RF servlet and does all the RF 
> requests
> em.close() //Don't forget to cleanup the ThreadLocal if you have used one.
>
Instead of EntityManager, its called UnitOfWork 

I thought my WorkerEntity´s *em3 EntityManager* would now get injected but 
it doesnt :(

Im not sure if I´m totally wrong, or if just something small is 
missing/wrong.

Regards,
Manuel

-- 
You received this message because you are subscribed to the Google Groups 
"Google Web Toolkit" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to google-web-toolkit+unsubscr...@googlegroups.com.
To post to this group, send email to google-web-toolkit@googlegroups.com.
Visit this group at http://groups.google.com/group/google-web-toolkit?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to