Database Reference
In-Depth Information
Advanced mapping mode - AspectJ
In the previous sections, we have used simple mapping mode for performing CRUD and
search operations over entities. Spring Data also provides "Advanced mapping mode" with
AspectJ for modeling and working with Spring Neo4j entities.
Spring Data Neo4j heavily depends on AspectJ and especially the advanced mapping
mode, which is nothing more than the dynamic instrumentation of Java classes provided by
AspectJ.
AspectJ is an API that provides implementation of aspect-oriented programming in Java
language. Aspect-oriented programming ( AOP ) aims to increase the modularity and re-
usability by separation of cross-cutting concerns.
It helps developers to isolate the auxiliary and cross-cutting concerns such as security, log-
ging, and so on from the business logic and helps components to focus on core concerns.
AOP defines the following main concepts:
Cross-cutting concerns : Common code or secondary requirements / needs for
various components within the system such as security, logging, and so on. These
secondary requirements remain the same for all components within a system.
Advice : An advice is a code which is developed to implement the secondary re-
quirement.
Pointcut : This is the place where we want to apply the advices.
Aspect : A combination of the pointcut and the advice is termed as an aspect.
An application developer could find difficulty in implementing the pointcut language, but
developers working with Spring or Spring Data do not have to worry about that. Spring
does all heavy loading and provides implementation of various cross-cutting concerns and
further exposes it to developers via annotations.
Spring Data Neo4j leverages the concept of aspect-oriented programming and implements
advices and exposes these advices to users via annotations.
For example, Spring leverages AspectJ and scans the Java packages and classes, and as
soon as it encounters annotations such as @NodeEntity , it introduces a new interface
called org.springframework.data.neo4j.aspects.core.NodeBacked or
Search WWH ::




Custom Search