Database Reference
In-Depth Information
AspectJ (see http://eclipse.org/aspectj ) is a Java implementation of the AOP paradigm ( ht-
tp://en.wikipedia.org/wiki/Aspect-oriented_programming ) .AOP,asaparadigm,aimstoin-
crease modularity within a code base, specifically for the purpose of allowing common
cross-cutting concerns to be untangled and extracted out of the main code and ultimately
stored separately (as aspects). A cross-cutting concern is some common logic that needs to
be applied at multiple points within the code base but that isn't necessarily related to the
core domain itself (typical examples cited are logging and transaction handling). This con-
cern or aspect can then somehow (implementations differ) be configured to be applied to
your code base at appropriate points.
SohowdoesSDNmake useofAOP(specifically AspectJ) toperform its common logic of
converting and translating between the POJO class and underlying graph entity?
First, unlike the simple mapping that all happens at runtime, the advanced mode relies on
somecompile-timesettingsandconfigurations.ThisinvolvesincludingaspecificAspectJ-
aware version of SDN in your project, as well as using the AspectJ (ajc) compiler. The
configuration details are discussed in appendix C .
SDN will scan your code for all @NodeEntity and @RelationshipEntity classes.
It will then take these POJO domain classes and, by using the special AspectJ compiler,
will replace them with its own custom-generated versions.
Second, this custom-crafted class has two features worth noting. First, a direct reference
to the actual node or relationship is attached to the class as an internal hidden field. The
additional code generated by the AspectJ compiler, in conjunction with this hidden field,
ensures that any code that's reading or writing to properties backed by Neo4j entities is
modified so that it ends up delegating all calls directly to the underlying entity.
The second noteworthy feature is that additional persistence-related methods are added or
mixed into the generated class, consistent with an active record type of approach—that
is, a technique whereby persistence code lives side by side with the domain code. This is
done by ensuring that the generated class implements either a NodeBacked or Rela-
tionshipBacked interface, providing appropriate implementations for the raft of per-
sistence and lookup functionality. The following listing shows how you can use some of
these persistence-related methods to operate on the entity directly.
Search WWH ::




Custom Search