Skip to content

DATAMONGO-1291 Persistent entity introspection to obtain a document annotation through AnnotationUtils #323

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed

Conversation

oalles
Copy link

@oalles oalles commented Sep 19, 2015

Persistent entity introspection to obtain a document annotation through AnnotationUtils instead of jdk introspection facilities.

BasicMongoPersistentEntity captures Mongo metadata of domain objects to be persisted to mongodb (such as collection name) needing for that purpose the Document annotation for that type.
Currently, the annotation is obtained through T.class.getAnnotation() method meaning that a reference is obtained if the annotation is present, else returning null.
Using AnnotationUtils.findAnnotation() instead, could easily extend this behavior resulting in more use cases to annotate domain objects.
As findAnnotation() javadoc states, " it finds a single annotation [...]
The algorithm operates as follows:

  1. Search for the annotation on the given class and return it if found.
  2. Recursively search through all annotations that the given class declares.
  3. Recursively search through all interfaces that the given class declares.
  4. Recursively search through the superclass hierarchy of the given class.
    "
    Being 1 the current behavior.
  5. states findAnnotation() metaannotation support, meaning that i could create my custom annotation annotated with Document. And this is an interesting feature. Even more thinking in Spring 4.2 AliasFor annotation.

to obtain a Document annotation through AnnotationUtils instead of
T.class.getAnnotation() resulting in more use cases to annotate Domain
objects
@christophstrobl
Copy link
Member

thanks @oalles - added desired behavior via ddc3925

@oalles
Copy link
Author

oalles commented Nov 9, 2015

👏 Thankyou all for your work,

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants