Uploaded image for project: 'JBoss Enterprise Application Platform'
  1. JBoss Enterprise Application Platform
  2. JBEAP-13532

Update quickstarts to comply to latest EJB 3.2 spec

XMLWordPrintable

    • Icon: Task Task
    • Resolution: Obsolete
    • Icon: Critical Critical
    • None
    • 7.1.0.CR3, 7.0.z.GA
    • Quickstarts
    • None

      Spec was changed in EJB 3.2. Previously the transaction context for SFSB creation was undefined but in EJB 3.2 the following was adding:

      "
      By default a stateful session bean’s PostConstruct, PreDestroy, PrePassivate and Post-Activate methods are executed in an unspecified transactional context. A PostConstruct, PreDestroy, PrePassivate and PostActivate method of a stateful session bean with con-tainer-managed transaction demarcation is permitted to have transaction attribute REQUIRES_NEW or NOT_SUPPORTED (RequiresNew or NotSupported if the deployment descriptor is used to spec-ify the transaction attribute).
      "

      The spec also says that the dependency injection happens in an unspecified transaction context. With this in mind the following decisions were made:

      • We will default to REQUIRES_NEW for SFSB creation, it does not make sense to default to REQUIRED or SUPPORTS when these are not valid values for this method
      • Dependency injection will take place inside the same transaction as PostContruct
      • In order to keep the behaviour consistent dependency injection will still be run inside a new TX even if there is no PostConstuct, otherwise adding an empty PostConstruct method would change the bean creation process in unexpected ways.

      So even though this is not 100% following the spec it is designed to follow the principle of least surprise (we don't default to a TX behaviour that is not user specified, and adding an empty method will not change construction semantics).

      Need to update quickstarts in any of this ways:

      • Avoid using a SFSB as a producer for anything other than an EXTENDED entity manager
      • If you are producing an EXTENDED entity manager then don't have anything else in the SFSB producer bean

      quickstarts affected:

      tasks-jsf

      Example, class resources.java

      @Stateful
      public class Resources {
          @Produces
          @PersistenceContext
          private EntityManager em;
      
          @Produces
          public Logger produceLog(InjectionPoint injectionPoint) {
              return Logger.getLogger(injectionPoint.getMember().getDeclaringClass().getName());
          }
      
          @Produces
          @RequestScoped
          public FacesContext produceFacesContext() {
              return FacesContext.getCurrentInstance();
          }
      
      

      It should only have the produces for the entitymanager.

            emartins@redhat.com Eduardo Martins
            rhn-support-tmiyargi Teresa Miyar Gil (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: