title: REST endpoint - Singleton vs RequestScoped
body: <p><a href="https://stackoverflow.com/questions/18914130/when-to-use-singleton-annotation-of-jersey">When to use @Singleton annotation of Jersey?</a> -</p>
  
  <blockquote>
    <p>By default Jersey creates a new instance of the resource class for
    every request. So if you don't annotate the Jersey resource class, it
    implicitly uses <code>@RequestScoped</code> scope.</p>
  </blockquote>
  
  <p><code>@RequestScoped</code> endpoint looks more suitable for various reasons. It is stateless, provides new instance for each request. I have implemented DAO's based on <a href="http://www.benmccann.com/hibernate-with-jpa-annotations-and-guice" rel="nofollow noreferrer">http://www.benmccann.com/hibernate-with-jpa-annotations-and-guice</a> example so provided <code>EntityManager</code> objects are different only in <code>@RequestScoped</code> environment because they are received from <code>ThreadLocal&lt;EntityManager&gt;</code> cache (<a href="https://stackoverflow.com/questions/37857481/jersey-guice-and-hibernate-entitymanager-thread-safety">Jersey, Guice and Hibernate - EntityManager thread safety</a>).</p>
  
  <p>On the other hand, I have faced applications where Jersey endpoints are annotated as <code>@Singleton</code>. But it seems that removing annotation won't change application behavior/logic.</p>
  
  <p>When <code>@Singleton</code> should be used instead of default <code>@RequestScoped</code> for REST endpoint? </p>