Discussions

News: Reflections - Java runtime metadata analysis

  1. Reflections - Java runtime metadata analysis (8 messages)

    from the google code project page http://code.google.com/p/reflections/ Reflections scans your classpath, indexes the metadata, allows you to query it on runtime and may save and collect that information for many modules within your project. Using Reflections you can query your metadata for: * get all subtypes of some type * get all types annotated with some annotation * get all types annotated with some annotation, including annotation parameters matching * get all methods annotated with some How to use? Use the one-stop-shop Reflections object for all that Reflections: * Get an instance of a Reflections object, providing it with your preferred configuration * Query your project's metadata A simple example might be: Configuration configuration = new AbstractConfiguration() { { setUrls(ClasspathHelper.getUrlsForCurrentClasspath()); setScanners(new SubTypesScanner(), new ClassAnnotationsScanner()); setFilter(new IncludeExcludeChain( new IncludePrefix("your project's common package prefix here...") )); } }; Reflections reflections = new Reflections(configuration); // get all subtypes of some type Set> subTypes = reflections.getSubTypesOf(SomeClassOrInterface.class); // get all types annotated with some annotation Set> annotated = reflections.getTypesAnnotatedWith(SomeAnnotation.class); // get all types annotated with some annotation, including annotation parameters matching Set> annotated1 = reflections.getTypesAnnotatedWith(new SomeAnnotation() { public String value() {return "1";} public Class<!--? extends Annotation--> annotationType() {return SomeAnnotation.class;} }); } check out the project home page http://code.google.com/p/reflections/

    Threaded Messages (8)

  2. Looks great![ Go to top ]

    Congratulations! Looks like a very powerful frameworks library. I like the pluggable scanners and filters. I also like the Maven integration for post-compile scanning. http://code.google.com/p/reflections/wiki/ReflectionsMojo Nice stuff :)
  3. Re: Looks great![ Go to top ]

    I second that feeling, This framework can provide a very good bootstrap for any application regardless the container it runs on(if exist). The maven plugin is reducing the bootstrap time. I suggest you should publish it to the main maven repositories: repo1 etc ... good work !
  4. Good One...[ Go to top ]

    Pretty good explanation. Thanks for sharing. http://qnatech.wordpress.com
  5. Looks very useful - thanks!!
  6. Pretty Good! The best part is the Scanning of Compiled sources and saving Metadata into a XML file and use it further for bootstrapping.
  7. Very useful![ Go to top ]

    Every time while waiting for Spring, JBoss-common and dozen of other frameworks finishing their own sclasspath scan I am thinking wouldn't it be nice to have one unified framework for classpath scan. Thanks!
  8. More info please !!!![ Go to top ]

    Hi, Just for what I was looking for. Where could I find more exmaples and documentation, I am trying to use it but I alawys have the same output 'non class file' or 'null'. I don't get it. Thanks, azevedo
  9. Re: More info please !!!![ Go to top ]

    kindly supply more information and contact me at ronmamo atgmaildotcom