I have three layers in my application:
- REST interface (JBOSS RestEasy)
- Service layer (Spring Services)
- Persistence layer (Spring beans)
In the persistence layer I will implement two classes (which implement the same interface): one will be a MemoryStore and the other one FileSystemStore.
Should these implementation be annotated by @Repository?
The two classes will not have any Database access. It can comes later an implementation to a DatabaseStore but it is not the case now.
More generally, is the annotation @Repository must be used for any persistence Bean or only for those who access a Database?
The class javadoc says:
I believe that you must annotate your class with @Repository if you need special exception translation (from JDBC, Hibernate or some other) or your own technology (but that means that you have to extend spring to know about this) otherwise, just annotate with @Component.
In your specific case, I think it is correct to annotate with @Repository because your interface is designed for data persistence.