Groovy Documentation

in.labulle.anycode.engine.groovy.directive
[Groovy] Class SpringDataDirective

java.lang.Object
  in.labulle.anycode.engine.groovy.directive.AnycodeDirective
      in.labulle.anycode.engine.groovy.directive.JavaDirective
          in.labulle.anycode.engine.groovy.directive.SpringDataDirective

class SpringDataDirective
extends JavaDirective

Spring Data Directive. It extends JavaDirective and provides method to help generate 'Repository' classes.

Authors:
Jose Carreno


Method Summary
def repositoryAttribute(IClass c)

Renders repository attribute based on the given class.

 
Methods inherited from class JavaDirective
attribute, classifierSignature, datatype, datatype, generalizations, getAttributeName, getDataTypeName, getDataTypeName, getOperationName, getter, operationImplementation, operationSignature, realizations, setter
 
Methods inherited from class Object
wait, wait, wait, equals, toString, hashCode, getClass, notify, notifyAll
 

Method Detail

repositoryAttribute

def repositoryAttribute(IClass c)
Renders repository attribute based on the given class. Format :
 '@Autowired'
 private MyClassRepository myClassRepository;
 ... (getter and setter also generated).
 
It is very interesting to use it within service classes to autowire ORM repositories. The typical use case is to model a Service class and add UML dependencies to your 'Entity classes'. The latter will then be accessible programmatically in the API through IClassifier.getClientDependencies. Then for each dependency, you can call this method to autowired they repository classes. This way of modelling is very close to what AndroMDA does
Parameters:
c - class.
Returns:
Spring repository class declaration with its getter and setter as a GString.


 

Groovy Documentation