com.google.inject.ScopeAnnotation Java Examples

The following examples show how to use com.google.inject.ScopeAnnotation. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: AbstractJerseyInstaller.java    From dropwizard-guicey with MIT License 6 votes vote down vote up
/**
 * Checks scope annotation presence directly on bean. Base classes are not checked as scope is not
 * inheritable.
 *
 * @param type      bean type
 * @param hkManaged true if bean is going to be managed by hk, false for guice management
 * @return true if scope annotation found, false otherwise
 */
private boolean hasScopeAnnotation(final Class<?> type, final boolean hkManaged) {
    boolean found = false;
    for (Annotation ann : type.getAnnotations()) {
        final Class<? extends Annotation> annType = ann.annotationType();
        if (annType.isAnnotationPresent(Scope.class)) {
            found = true;
            break;
        }
        // guice has special marker annotation
        if (!hkManaged && annType.isAnnotationPresent(ScopeAnnotation.class)) {
            found = true;
            break;
        }
    }
    return found;
}
 
Example #2
Source File: ScopeManager.java    From n4js with Eclipse Public License 1.0 2 votes vote down vote up
/**
 * Tells if the given annotation is a Google Guice "scope annotation", i.e. if the annotation class is itself
 * annotated with <code>@ScopeAnnotation</code>.
 */
public static final boolean isScopeAnnotation(Class<? extends Annotation> annotationClass) {
	return annotationClass.isAnnotationPresent(ScopeAnnotation.class);
}