if (componentPackage != null)
{
final AuthorizeInstantiation packageAnnotation = componentPackage.getAnnotation(AuthorizeInstantiation.class);
if (packageAnnotation != null)
{
authorized = hasAny(new Roles(packageAnnotation.value()));
}
}
// Check class annotation
final AuthorizeInstantiation classAnnotation = componentClass.getAnnotation(AuthorizeInstantiation.class);
if (classAnnotation != null)
{
// If roles are defined for the class, that overrides the package
authorized = hasAny(new Roles(classAnnotation.value()));
}
return authorized;
}