Is it possible to mix BMT and CMT as in the next example. TestAddCommand method is under BMT and calls methods of AddCommand and RemoveCommand which is under CMT. Is this possible?
Yes, it is possible to mix BMT and CMT. Moreover - the JTA started by the BMT can be reused by CMT, but not the other way around.
So if you have:
Client -> BMT -> CMT(REQUIRED), the CMT will reuse the transaction started by the BMT.
Client -> CMT -> BMT, the BMT will not be able to reuse the transaction started by the BMT.
Hi,
Though not related to actual question here, I am puzzled with the usage (CMT annotation) in the TestAddCommand ejb, even though the class has got annotation (BMT).
Sorry for asking this if this is too trivial, I have started learning ejb recently and got confused seeing such a code.
Vinay Kejriwal wrote:Hi,
Though not related to actual question here, I am puzzled with the usage (CMT annotation) in the TestAddCommand ejb, even though the class has got annotation (BMT).
Sorry for asking this if this is too trivial, I have started learning ejb recently and got confused seeing such a code.
But shouldn't this code fail at compile time? I have seen this kind of code getting compiled without any error. So what exactly would be the behavior. Will jvm simply ignore this at runtime?
But shouldn't this code fail at compile time? I have seen this kind of code getting compiled without any error. So what exactly would be the behavior. Will jvm simply ignore this at runtime?
Welcome =) About the new questions:
>shouldn't this code fail at compile time? I have seen this kind of code getting compiled without any error. So what exactly would be the behavior. Will jvm simply ignore this at runtime?
The code will not fail in compile time due there isn't this kind of evaluation during this process from the Javac process perspective. Maybe a good IDE may point this as a warning to make you aware that you might not get the desired behavior. The problem about the compile time, the Javac will just see if you have the correct syntax (liek keywords and their order to put in a nutshell) and the dependencies (to make the references inside the .class file). The real "magic" happens in the application server, which the container thread analyze your deployment package and create some proxies and/or aspects to provide the services described in Java EE specification. So, the container may also display some message of warn/error, depeding if it obligation d(if described in Java EE specification or not).