-
1. Re: Servlet Scanner plugin
alesj Mar 24, 2010 2:37 PM (in response to rmaucher)This would translate to something like:
- public Set<Class<?>> getClasses(VirtualFile classpathItem, Set<Class<? extends Annotation>> annotationsToLookFor) (from the Hibernate plugin, assuming it looks for annotation on fields, methods and type), or return a Map<Class<? extends Annotation>>, Class<?>>
Hibernate plugin only checks for class annotations.
I would not re-use it, better writting new behavior in separate plugin.
- public Set<Class<?>> getClasses(List<VirtualFile> classpath, Set<Class<? extends Annotation>> annotationsToLookFor, Set<Class<?>> supertypesToLookFor) (note: in case there are multiple SCIs with HandlesType, this could be less efficient than using a map to pass the annotations/types to look for, and getting a map back; of course, it is simpler too)
Can you explain this one a bit more.
Or, why mix the parameters; annotation and supertypes?
We already have the annotations method, simply adding the supertypes, and the use Set intersection to get both?
-
2. Re: Servlet Scanner plugin
rmaucher Mar 24, 2010 2:48 PM (in response to alesj)The first one is for the standard EE annotations, nothing special.
The second one mixes annotations with types because that's what that SCI feature does. It allows specifying a set of annotations, or a set of types, and you get in a listener a Set of the classes in the webapp that respectively use the annotations (type, method, field), or are a subclass or imlplement the specified types. No need for sorting, it's a single Set with everything. I was sugesting a single method since it could avoid loops going through all the classes, right ?
-
3. Re: Servlet Scanner plugin
alesj Mar 24, 2010 3:00 PM (in response to rmaucher)I was sugesting a single method since it could avoid loops going through all the classes, right ?
No, that's the whole point of having this scanning "framework" -- we do it all (all sorts of indexing, ...) in a single pass.
What we need is just to properly prepare the info, so when the query is invoked, it's basically O(1) lookup.
So, split methods make sense to me, as then all we do is Set::intersect.
Or am I missing something?
-
4. Re: Servlet Scanner plugin
rmaucher Mar 24, 2010 3:06 PM (in response to alesj)No, it's fine, so that's 3 methods then (one annotations per VirtualFile, one annotations per set of VirtualFile. and one superclass thing per set of VirtualFile).
-
5. Re: Servlet Scanner plugin
alesj Mar 24, 2010 3:18 PM (in response to rmaucher)(a) one annotations per VirtualFile, (b) one annotations per set of VirtualFile
I guess this is can be just (a), and you'll do your own iteration?
and one superclass thing per set of VirtualFile
Will we have pre-existing set of supertypes, or can this be any class?
The first one is quite easy to handle, where for the 2nd one we need to keep the whole classes hierarchy is some registry/"database".
-
6. Re: Servlet Scanner plugin
rmaucher Mar 24, 2010 6:31 PM (in response to alesj)It is any class or interface I am ok with your (a).
-
7. Re: Servlet Scanner plugin
alesj Mar 24, 2010 7:30 PM (in response to rmaucher)It is any class or interface
What do you consider by any? :-)
We don't have any pre-required stuff; e.g. find all classes that implement HandleType, ...
and it can really be anything; e.g. com.acme.IFoo, ....
If so, I guess we'll just have to build our own structure registry.
-
8. Re: Servlet Scanner plugin
alesj Mar 24, 2010 7:59 PM (in response to rmaucher)I am ok with your (a).
/** * Get annotated classes. * * @param cpEntry the classpath entry * @param annotationsToLookFor the annotations to look for * @return set of annotated classes */ Set<Class<?>> getAnnotatedClasses(VirtualFile cpEntry, Set<Class<? extends Annotation>> annotationsToLookFor);
I still need more info in order to impl this.
* should I care where the annotation comes from; e.g. from class, method, field, parameter, meta-annotation, ...
* does the class have all annotations from annToLookFor or just one is enough
Same goes for inherited superTypesToLookFor.
* does the class have to inherit all or just one
-
9. Re: Servlet Scanner plugin
rmaucher Mar 24, 2010 8:15 PM (in response to alesj)getAnnotatedClasses is for the usual EE annotations, some can be on field, method, type.
http://technology-related.com/javaee/6/docs/api/javax/servlet/annotation/HandlesTypes.html
For handles type, I fail to articulate the definition, it seems, so here is the javadoc: -
10. Re: Servlet Scanner plugin
alesj Mar 24, 2010 8:32 PM (in response to rmaucher)getAnnotatedClasses is for the usual EE annotations, some can be on field, method, type.
So, you don't care where it is? e.g. @RunAs on whole class vs. just on a method
In this case this signature will do:
/**
* Get annotated classes.
*
* @param cpEntry the classpath entry
* @param annotationToLookFor the annotation to look for
* @return set of annotated classes
*/
Set<Class<?>> getAnnotatedClasses(VirtualFile cpEntry, Class<? extends Annotation> annotationToLookFor);Since you can do the merging/intersection/... yourself. ;-)
-
11. Re: Servlet Scanner plugin
rmaucher Mar 24, 2010 9:09 PM (in response to alesj)Certain annotations are only on type. @RunAs is a type only. Others are on method or type, yet others are on method, type or field. Is it really worth differentiating ?
-
12. Re: Servlet Scanner plugin
alesj Mar 25, 2010 2:03 AM (in response to rmaucher)Others are on method or type, yet others are on method, type or field. Is it really worth differentiating ?
Dunno. You tell me. :-)
I'm not the one using this API, you are. ;-)
-
13. Re: Servlet Scanner plugin
kabirkhan Mar 25, 2010 6:16 AM (in response to alesj)Is this just for Web?
If not, I think it should be made possible to differentiate.
-
14. Re: Servlet Scanner plugin
rmaucher Mar 25, 2010 11:04 AM (in response to kabirkhan)I don't know. Whatever gives the best performance.