My proposal is to add functionality in the EJB-Container to support @Idempotent for Stateless EJB methods.
A method is idempotent, when a call to this method does not have any side-effects. This means, that multiple calls to such a method always give the same result.
So a container could provide this functionality for methods of a Stateless Session Bean, marked with @Idempotent to cache the result of the method for further calls.
With this, a container is told to handle each call with the same arguments idempotent and return exactly the same value. So a call:
A container is responsible for caching the result of the method as well as how long or under which circumstances the result is cached (e.g. WeakReference).
Another responsibility for the container is the error handling and transaction rollback for idempotent methods, especially in cluster environments. (see the similar functionality with weblogic.javaee.Idempotent, but my proposal goes a bit further).
This would be a performance gain, but also a potential risk for developers, that do not know, what they exactly do.
I think, there is a general need for this functionality, even in REST-Resources or in Cluster-Environment to simplify things and to standardize the behavior of containers in this way.
Comments are requested