Java Reference
In-Depth Information
13.3.4. Overriding annotations with XML
As we explained, you can mix and match deployment descriptors with annotations and use
descriptors to override settings originally specified using annotations. Keep in mind that
the more you mix the two, the more likely you are to make mistakes and create a debugging
nightmare.
Note
The basic rule to remember is that the name element in stateless, stateful, and message-
driven annotations is the same as the ejb-name element in the descriptor. If you don't
specify the name element with these annotations, the name of the bean class is understood
to be the ejb-name element. This means that when you're overriding an annotation set-
ting with your deployment descriptor, the ejb-name element must match the bean class
name.
Suppose you have a stateless session bean that uses these annotations:
@Stateless(name = "BazaarAdmin")
public class BazaarAdminBean implements BazaarAdmin {
...
@TransactionAttribute(TransactionAttributeType.REQUIRES_NEW)
public Item addItem() {...}
}
The value for the name element specified is BazaarAdmin , which is the same as the
value of the ejb-name element specified in the deployment descriptor:
<ejb-name>BazaarAdmin</ejb-name>
If you don't specify the name element, the container will use the name BazaarAdmin-
Bean as the name of the bean class, and to override annotations you'll have to use that
name in the deployment descriptor:
<ejb-name>BazaarAdminBean</ejb-name>
Search WWH ::




Custom Search