Skip to end of metadata
Go to start of metadata

Sri to EricW May 14, 2012

Larry and I would like to clarify the following ...

We currently see the caching annotations in the interface ... we were wondering about Rice guidelines for caching annotations on the interfaces vs implementations.
Wouldn't multiple implementations be an issue when having annotations on the interface?

EricW reply

The spring documentation actually recommends putting the annotations on the service implementation instead of the service interface.
The reason being because then you can use load-time weaving to modify the implementation class
which allows for internal service implementation calls to leverage the caching if it calls other methods on the same service.

That said, we put them on the interface because that allows us to more easily make caching available in a client application
when those services are accessed remotely (since the service implementation itself isn't loaded in the client application).
If we didn't put them on the service interface, we would need to define an alternate service implementation which does nothing
but caching for every service in Rice which needs caching (and then explicitly load that in the client application).
Hopefully that distinction makes sense there, if not I can provide a more detailed example (wink)

You are correct though in terms of multiple implementations. In terms of what's being done here, the caching essentially
becomes part of the contract (i.e. if you create an alternate implementation of a specific service, you have to make sure
to manually send cache flush messages in cases where the related data changes).

  • No labels