@@ -38,7 +39,7 @@ *
and predicates included here all starts with "with", such as + *
and predicates included here all starts with "with", such as *
* for example, getting all getters would be:
*
* Set<Method> getters = getAllMethods(someClasses, * Predicates.and( - * withModifier(Modifier.PUBLIC), - * withPrefix("get"), + * withModifier(Modifier.PUBLIC), + * withPrefix("get"), * withParametersCount(0))); ** */ @SuppressWarnings("unchecked") public abstract class ReflectionUtils { + private static final String VERBOSE_PROPERTY = "reflections17.verbose"; + + private static final boolean REFLECTIONS_VERBOSE = Boolean.getBoolean(VERBOSE_PROPERTY) + || "true".equals(System.getenv(VERBOSE_PROPERTY)); + + private static final String SEMICOLON = ";"; + + private static final String L = "L"; + + private static final String EMPTY_STRING = ""; + + private static final String CLOSE_SQUARE_BRACKET = "]"; + + private static final String OPEN_SQUARE_BRACKET = "["; + + private static final String TYPE_UNAVAILABLE_SHORT = "Type: %s unavailable"; + + private static final String TYPE_UNAVAILABLE = "Type: %s unavailable from any class loader"; + /** would include {@code Object.class} when {@link #getAllSuperTypes(Class, Predicate[])}. default is false. */ public static final boolean includeObject = false; /** get all super types of given {@code type}, including, optionally filtered by {@code predicates} *
include {@code Object.class} if {@link #includeObject} is true */
public static Set if optional {@link ClassLoader}s are not specified, then both {@link org.reflections8.util.ClasspathHelper#contextClassLoader()} and {@link org.reflections8.util.ClasspathHelper#staticClassLoader()} are used
- * */
+ /**
+ * Tries to resolve a java type name to a Class
+ * if optional {@link ClassLoader}s are not specified, then both {@link org.reflections8.util.ClasspathHelper#contextClassLoader()}
+ * and {@link org.reflections8.util.ClasspathHelper#staticClassLoader()} are used
+ */
public static Class> forName(String typeName, Optional For Javadoc, source code, and more information about Reflections Library, see http://github.com/ronmamo/reflections/
*/
public class Reflections {
+
+ private static final String VERBOSE_PROPERTY = "reflections17.verbose";
+
+ private static final boolean REFLECTIONS_VERBOSE = Boolean.getBoolean(VERBOSE_PROPERTY)
+ || "true".equals(System.getenv(VERBOSE_PROPERTY));
+
+ private static final String TIMING_INFO = "Reflections initialized in {} ms";
+
public static final Optional it is preferred to use {@link org.reflections8.util.ConfigurationBuilder}
*/
public Reflections(final Configuration configuration) {
+ long start = System.currentTimeMillis();
this.configuration = configuration;
store = new Store(configuration);
-
if (configuration.getScanners() != null && !configuration.getScanners().isEmpty()) {
- //inject to scanners
for (Scanner scanner : configuration.getScanners()) {
scanner.setConfiguration(configuration);
scanner.setStore(store.getOrCreate(index(scanner.getClass())));
}
-
scan();
-
if (configuration.shouldExpandSuperTypes()) {
expandSuperTypes();
}
}
+ Logger logger = log.get();
+ if (REFLECTIONS_VERBOSE || logger.isTraceEnabled()) {
+ long end = System.currentTimeMillis();
+ if (REFLECTIONS_VERBOSE) {
+ logger.warn(TIMING_INFO, end - start);
+ } else {
+ logger.trace(TIMING_INFO, end - start);
+ }
+ }
}
/**