[jboss-jira] [JBoss JIRA] (WFLY-4608) Omit no-op transaction if lifecycle method is missing
David Lloyd (JIRA)
issues at jboss.org
Mon Nov 16 07:43:00 EST 2015
[ https://issues.jboss.org/browse/WFLY-4608?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13129172#comment-13129172 ]
David Lloyd commented on WFLY-4608:
-----------------------------------
More stuff:
{quote}
The {{PostConstruct}}, {{PreDestroy}}, {{PrePassivate}}, {{PostActivate}}, and/or {{ejbCreate<METHOD>}}, {{ejbRemove}}, {{ejbPassivate}}, and {{ejbActivate}} methods of a stateful session bean with container-managed transaction demarcation are invoked in the scope of a transaction determined by the transaction attribute specified in the bean’s metadata annotations or deployment descriptor.
{quote}
{quote}
By default a stateful session bean’s {{PostConstruct}}, {{PreDestroy}}, {{PrePassivate}} and {{PostActivate}} methods are executed in an unspecified transactional context. A {{PostConstruct}}, {{PreDestroy}}, {{PrePassivate}} and {{PostActivate}} method of a stateful session bean with container-managed transaction demarcation is permitted to have transaction attribute {{REQUIRES_NEW}} or {{NOT_SUPPORTED}} ({{RequiresNew}} or {{NotSupported}} if the deployment descriptor is used to specify the transaction attribute).
{quote}
{quote}
The {{PostConstruct}} and {{PreDestroy}} methods of singleton session beans with container-managed transaction demarcation can be invoked with or without a transaction. From the Bean Provider’s view there is no client of a {{PostConstruct}} or {{PreDestroy}} method.
A {{PostConstruct}} or {{PreDestroy}} method of a singleton session bean with container-managed transaction demarcation is permitted to have transaction attribute {{REQUIRED}}, {{REQUIRES_NEW}}, or {{NOT_SUPPORTED}} ({{Required}}, {{RequiresNew}}, or {{NotSupported}} if the deployment descriptor is used to specify the transaction attribute).
_Note that the container must start a new transaction if the {{REQUIRED}} ({{Required}}) transaction attribute is used. This guarantees, for example, that the transactional behavior of the {{PostConstruct}} method is the same regardless of whether the singleton session bean instance is initialized eagerly at container startup time or as a side effect of a first client invocation on the singleton session bean. The {{REQUIRED}} transaction attribute value is allowed so that specification of a transaction attribute for the singleton session bean’s {{PostConstruct}} and {{PreDestroy}} methods can be defaulted._
{quote}
{quote}
Lifecycle callback interceptor methods are invoked in an unspecified transaction context, except for singleton and stateful session bean {{PostConstruct}} and {{PreDestroy}} methods and stateful session bean {{PostActivate}}, and {{PrePassivate}} methods, whose transaction context is based on their respective transaction attributes.
{quote}
{quote}
By default, the value of the transaction attribute for a method of a bean with container-managed transaction demarcation is the {{REQUIRED}}
transaction attribute, and the transaction attribute does not need to be explicitly specified in this case. A transaction attribute is a value associated with each of the following methods:
* a method of a bean’s business interface
* a method exposed through the bean class no-interface view
* a message listener method of a message-driven bean
* a timeout callback method
* a stateless or singleton session bean’s web service endpoint method
* for beans written to the EJB 2.1 and earlier client view, a method of a session bean’s home or component interface
* a {{PostConstruct}} or {{PreDestroy}} lifecycle callback interceptor method of a singleton session bean
* a {{PostConstruct}}, {{PreDestroy}}, {{PrePassivate}} or {{PostActivate}} lifecycle callback interceptor method of a stateful session bean
{quote}
{quote}
Transaction attributes are specified for the following methods:
* For a session bean written to the EJB 3.x client view API, the transaction attributes are specified for those methods of the session bean class that correspond to the bean’s business interface, the direct and indirect superinterfaces of the business interface, methods exposed through the bean class no-interface view, and for the timeout callback methods, if any.
* For a stateless session bean or singleton session bean that provides a web service client view, the transaction attributes are specified for the bean’s web service endpoint methods, and for the timeout callback methods, if any.
* For a singleton session bean, the transaction attributes are specified for the {{PostConstruct}} and {{PreDestroy}} lifecycle callback interceptor methods, if any. In order to specify the transaction attribute for a {{PostConstuct}} or {{PreDestroy}} method of a singleton session bean, the transaction attribute must be specified for the method(s) on the bean class, rather than for a superclass or {{PostConstruct}} or {{PreDestroy}} interceptor method.
* For a stateful session bean, the transaction attributes are specified for the {{PostConstruct}}, {{PreDestroy}}, {{PrePassivate}} or {{PostActivate}} lifecycle callback interceptor methods, if any. In order to specify the transaction attribute for a {{PostConstruct}}, {{PreDestroy}}, {{PrePassivate}} or {{PostActivate}} method of a stateful session bean, the transaction attribute must be specified for the method(s) on the bean class, rather than for a superclass or {{PostConstruct}}, {{PreDestroy}}, {{PrePassivate}} or {{PostActivate}} interceptor method.
* For a message-driven bean, the transaction attributes are specified for the message listener-methods on the message-driven bean class and for the timeout callback methods, if any.
* For a session bean written to the EJB 2.1 and earlier client view, the transaction attributes are specified for the methods of the component interface and all the direct and indirect superinterfaces of the component interface, excluding the methods of the {{javax.ejb.EJBObject}} or {{javax.ejb.EJBLocalObject}} interface; and for the timeout callback methods, if any. Transaction attributes must not be specified for the methods of a session bean’s home interface.
By default, if a {{TransactionAttribute}} annotation is not specified for a method of an enterprise
bean with container-managed transaction demarcation, the value of the transaction attribute for the
method is defined to be {{REQUIRED}}. The rules for the specification of transaction attributes are defined
in Section 8.3.7.1.
{quote}
{quote}
For a singleton session bean’s {{PostConstruct}} and {{PreDestroy}} lifecycle callback interceptor methods, only the {{REQUIRED}}, {{REQUIRES_NEW}}, and {{NOT_SUPPORTED}} transaction attributes may be used.
For a stateful session bean’s {{PostConstruct}}, {{PreDestroy}}, {{PrePassivate}} or {{PostActivate}} lifecycle callback interceptor methods, only the {{REQUIRES_NEW}} and {{NOT_SUPPORTED}} transaction attributes may be used.
If an enterprise bean implements the {{javax.ejb.SessionSynchronization}} interface or uses any of the session synchronization annotations, only the following values may be used for the transaction attributes of the bean’s methods: {{REQUIRED}}, {{REQUIRES_NEW}}, {{MANDATORY}}
{quote}
> Omit no-op transaction if lifecycle method is missing
> -----------------------------------------------------
>
> Key: WFLY-4608
> URL: https://issues.jboss.org/browse/WFLY-4608
> Project: WildFly
> Issue Type: Bug
> Components: EJB
> Affects Versions: 9.0.0.CR1
> Reporter: Ivo Studensky
> Assignee: Ivo Studensky
> Fix For: 10.0.0.Final
>
>
> LifecycleCMTTxInterceptor creates a no-op transaction even if there is no lifecycle method defined in the bean.
--
This message was sent by Atlassian JIRA
(v6.4.11#64026)
More information about the jboss-jira
mailing list