I am working with SpringData’s Neo4j graph DB hello-worlds example and I ran across the following code in WorldRepositoriesImpl.java…
@Autowired private WorldRepository worldRepository;
Furthermore, WorldRepository is defined as…
public interface WorldRepository extends MyWorldRepository,
GraphRepository<World>,
NamedIndexRepository<World>
{/* no method defined here */}
Now the odd part, no class that I can find actually implements WorldRepository.So, a few questions…
How is this possible? Where is this documented? Is there a way to make this a bit more explicit (less mysterious)?
Running the code with a debugger attached shows that the
worldRepositoryinstance wired up by Spring is a proxy object created at runtime.Looking at the pom.xml and the dependencies included, it looks like the spring-neo4j library bundles in some Aspects that create this implementation class at runtime.
In other words, there is no implementation of this interface declared in the source code – but one is created at runtime with AspectJ and other tools.