> Two, if I have this in a Session Bean:
>
> @TransactionAttribute(TransactionAttributeType.REQUIRE
> S_NEW).
> public void a() {
> ...
>
> @TransactionAttribute(TransactionAttributeType.REQUIRE
> S_NEW).
> public void b() {
> a();
> ...
> }
I'll just answer this one first since the actual behavior is different than your
assumption. If b() calls a() directly, meaning without using an ejb reference,
then none of the EJB container business method behavior such as security
authorization or container-managed transaction processing will take place.
It's just a plain java method call that happens without any interposition by
the container. So, a() would run within whatever transaction context b() has.
If you want to make a 1st-class business method invocation on a particular
bean from the bean class of that same bean, the easiest way is to acquire
the business interface object from EJBContext and invoke on it :
@Resource private SessionContext sc;
public void b() {
MyLocalInterface myli = sc.getBusinessObject(MyLocalInterface.class);
myli.a();
}
Note that the object returned by getBusinessObject is the exact same thing as would
be injected into
@EJB private MyLocalInterface myli;
--ken
[Message sent by forum member 'ksak' (ksak)]
http://forums.java.net/jive/thread.jspa?messageID=222181