Hi Bell,
Good to hear that you are using my notes. I wish you well on your exam!
Bell Katapa wrote:
1. Security Management: The spec says calls made on EJBContext.getCallerPrincipal() should retain the original java.security.Principal object in cases where the bean method making this call was invoked with the @RunAs annotation and was passed a different role name as attribute from the one originally enlisting the caller identity. It should not retain the Principal associated with the role specified in the @RunAs annotation. Now, suppose the bean method in the onMessage(Message m) of a MDB specified with @RunAs annotation, what should be retained from calling EJBContext.getCallerPrincipal() in the onMessage(Message m) on any other MDB method? Is it the containers representation of an unauthorized identity?
In general it is important to remember that a MDB doesn't have a client, in other words: there is no Principal flowing in from the client. The EJBContext.getCallerPrincipal() will always return a Principal (never
null, important for the exam!) and you are right it will be the containers representation of an unauthorized identity. Putting a @RunAs annotation on your MDB won't change anything on the EJBContext.getCallerPrincipal() of the next MDB.
Bell Katapa wrote:
2. Timers: If a call to EJBContext.setRollbackOnly() is made within timeout method and there is still a balance of timeouts for the timer in the future, the spec says the container should try calling the timeout method at-least one more time, thereafter "rescinding the timer expiration". What's the meaning of this? Does the spec imply the timer should be cancelled after all retries result in transaction rollbacks? Should the container continue to call the said timeout method even though the result continues to be a transaction rollback? I have glassfish with me and have noticed that on a few occasions it does not strictly adhere to the spec and relying on it can cost me a few marks on the exam (for instance glassfish allows annotating a business interface view with @Asynchronous while the spec says this should be specified on the concrete bean method).
"rescinding the timer expiration" means putting back the timer (in the state before the transaction started). The same applies to when you cancel a timer in your business method (that runs in a transaction) and the transaction is rolled back: the timer cancellation is reversed to the state it was before it was cancelled (i.e. running).
If the EJBContext.setRollbackOnly() is called inside a timeout callback method the container has to put back the timer in the state before it timed-out and try at least once more (typically there will be a setting in the container of how many retries should be done).
Regards,
Frits