All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.clarkparsia.empire.util.ReflectionsAnnotationProvider Maven / Gradle / Ivy

There is a newer version: 1.9.11
Show newest version
/*
 * Copyright (c) 2009-2010 Clark & Parsia, LLC. 
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package com.clarkparsia.empire.util;


import org.reflections.Reflections;

import org.reflections.scanners.FieldAnnotationsScanner;
import org.reflections.scanners.MethodAnnotationsScanner;
import org.reflections.scanners.TypeAnnotationsScanner;

import org.reflections.util.ConfigurationBuilder;
import org.reflections.util.ClasspathHelper;
import org.streampipes.empire.core.empire.util.EmpireAnnotationProvider;

import java.util.Collection;
import java.lang.annotation.Annotation;

/**
 * 

Implementation of the {@link EmpireAnnotationProvider} interface backed by the Reflections API which * provides the neccessary annotation information at runtime.

* * @author Michael Grove * @since 0.5.2 * @see Reflections API */ public final class ReflectionsAnnotationProvider implements EmpireAnnotationProvider { private static Reflections REFLECTIONS; static { // Updated as used method is no more available in official release REFLECTIONS = new Reflections(new ConfigurationBuilder().setUrls(ClasspathHelper.forJavaClassPath()) .setScanners(new FieldAnnotationsScanner(), new MethodAnnotationsScanner(), new TypeAnnotationsScanner())); } /** * @inheritDoc */ public Collection> getClassesWithAnnotation(final Class theAnnotation) { return REFLECTIONS.getTypesAnnotatedWith(theAnnotation); } }




© 2015 - 2024 Weber Informatics LLC | Privacy Policy