本文整理汇总了Java中com.sun.jersey.api.model.AbstractMethod.getAnnotation方法的典型用法代码示例。如果您正苦于以下问题:Java AbstractMethod.getAnnotation方法的具体用法?Java AbstractMethod.getAnnotation怎么用?Java AbstractMethod.getAnnotation使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.sun.jersey.api.model.AbstractMethod
的用法示例。
在下文中一共展示了AbstractMethod.getAnnotation方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: create
import com.sun.jersey.api.model.AbstractMethod; //导入方法依赖的package包/类
@Override
public List<ResourceFilter> create(AbstractMethod am) {
LinkedList<ResourceFilter> filters = Lists.newLinkedList();
// Check the resource
RequiresPermissions permAnnotation = am.getResource().getAnnotation(RequiresPermissions.class);
if (permAnnotation != null) {
filters.add(new AuthorizationResourceFilter(ImmutableList.copyOf(permAnnotation.value()), permAnnotation.logical(), createSubstitutionMap(permAnnotation, am)));
}
// Check the method
permAnnotation = am.getAnnotation(RequiresPermissions.class);
if (permAnnotation != null) {
filters.add(new AuthorizationResourceFilter(ImmutableList.copyOf(permAnnotation.value()), permAnnotation.logical(), createSubstitutionMap(permAnnotation, am)));
}
// If we're doing authorization or if authentication is explicitly requested then add it as the first filter
if (!filters.isEmpty() ||
am.getResource().getAnnotation(RequiresAuthentication.class) != null ||
am.getAnnotation(RequiresAuthentication.class) != null) {
filters.addFirst(new AuthenticationResourceFilter(_securityManager, _tokenGenerator));
}
return filters;
}
示例2: create
import com.sun.jersey.api.model.AbstractMethod; //导入方法依赖的package包/类
@Override
public List<ResourceFilter> create(AbstractMethod am) {
List<ResourceFilter> rolesFilters = new ArrayList<ResourceFilter>();
RightsAllowed check = am.getAnnotation(RightsAllowed.class);
if (check != null) {
rolesFilters.add(new RightCheckResourceFilter(check.value(), am.getResource()));
if (check.value().length == 0 && !check.any()) {
LOG.warn("Class {} should be specifying any=true in the {} annotation.", am.getResource().getClass().getName(), RightsAllowed.class.getSimpleName());
}
} else {
logNoFilterMessage(am);
}
return rolesFilters;
}
示例3: create
import com.sun.jersey.api.model.AbstractMethod; //导入方法依赖的package包/类
@Override
public List<ResourceFilter> create(AbstractMethod am) {
String requestSchema = null;
String responseSchema = null;
Schema schema = am.getAnnotation(Schema.class);
if (schema != null) {
if (!schema.request().isEmpty()) {
requestSchema = schema.request();
}
if (!schema.response().isEmpty()) {
responseSchema = schema.response();
}
}
if (requestSchema != null || responseSchema != null) {
JSONSchemaResourceFilter filter =
new JSONSchemaResourceFilter(requestSchema, responseSchema);
return Collections.<ResourceFilter>singletonList(filter);
} else {
return Collections.emptyList();
}
}
示例4: create
import com.sun.jersey.api.model.AbstractMethod; //导入方法依赖的package包/类
@Override
public List<ResourceFilter> create(AbstractMethod am) {
if (am instanceof AbstractResourceMethod)
{
OAuth20 oauth20 = am.getAnnotation(OAuth20.class);
AllowedScopes scopes = am.getAnnotation(AllowedScopes.class);
if (oauth20!=null)
{
LOGGER.debug("Installing oauth2 filter on {}", am.getResource());
return getFilters(scopes);
}
else {
oauth20 = am.getResource().getAnnotation(OAuth20.class);
scopes = am.getResource().getAnnotation(AllowedScopes.class);
if (oauth20!=null)
{
LOGGER.debug("Installing oauth2 filter on {}", am.getResource());
return getFilters(scopes);
}
return null;
}
} else
return null;
}
示例5: create
import com.sun.jersey.api.model.AbstractMethod; //导入方法依赖的package包/类
/**
* {@inheritDoc}
*/
@Override
public List<ResourceFilter> create(AbstractMethod am) {
if (am.getAnnotation(WriteAPI.class) != null) {
// Filter for @WriteAPI annotation.
return Collections.<ResourceFilter>singletonList(new WriteMethodFilter());
}
return null;
}
示例6: createPathSubstitution
import com.sun.jersey.api.model.AbstractMethod; //导入方法依赖的package包/类
/**
* Creates a substitution function for path values, such as
* <code>@RequiresPermission("resource|update|{id}")</code>
*/
private Function<HttpRequestContext, String> createPathSubstitution(final String param, final AbstractMethod am) {
int from = 0;
int segment = -1;
// Get the path from resource then from the method
Path[] annotations = new Path[] { am.getResource().getAnnotation(Path.class), am.getAnnotation(Path.class) };
for (Path annotation : annotations) {
if (annotation == null) {
continue;
}
int index = getSubstitutionIndex(param, annotation.value());
if (index >= 0) {
segment = from + index;
} else {
from += -index;
}
}
if (segment == -1) {
throw new IllegalArgumentException("Param not found in path: " + param);
}
final int validatedSegment = segment;
return new Function<HttpRequestContext, String>() {
@Override
public String apply(HttpRequestContext request) {
return request.getPathSegments().get(validatedSegment).getPath();
}
};
}
示例7: createMasterSubscriptionFilter
import com.sun.jersey.api.model.AbstractMethod; //导入方法依赖的package包/类
/**
* Creates a filter that creates a subscription for a master when the method is invoked. The method must be
* annotated with {@link SubscribeMaster}. A notification is sent when any data in the master changes.
* @param abstractMethod A Jersey REST method
* @return A filter to set up subscriptions when the method is invoked or null if the method doesn't
* need master subscriptions
*/
private ResourceFilter createMasterSubscriptionFilter(AbstractMethod abstractMethod) {
SubscribeMaster annotation = abstractMethod.getAnnotation(SubscribeMaster.class);
if (annotation != null) {
MasterType[] masterTypes = annotation.value();
if (masterTypes.length > 0) {
return new MasterSubscriptionFilter(getUpdateManager(), Arrays.asList(masterTypes), _httpContext, _servletRequest);
} else {
s_logger.warn("@SubscribeMaster annotation found on {}.{}() with no masters specified",
abstractMethod.getMethod().getDeclaringClass().getSimpleName(),
abstractMethod.getMethod().getName());
}
}
return null;
}
示例8: create
import com.sun.jersey.api.model.AbstractMethod; //导入方法依赖的package包/类
@Override
public List<ResourceFilter> create(AbstractMethod am) {
List<ResourceFilter> response = null;
boolean hasLimiterAnnotation = am.isAnnotationPresent(Limiter.class);
if (hasLimiterAnnotation) {
Limiter annotation = am.getAnnotation(Limiter.class);
long requests = annotation.requests();
response = Collections.<ResourceFilter>singletonList(new RateLimitFilter(requests, am.getMethod().getName()));
}
return response;
}
示例9: create
import com.sun.jersey.api.model.AbstractMethod; //导入方法依赖的package包/类
@Override
public List<ResourceFilter> create(AbstractMethod am) {
List<ResourceFilter> response = null;
boolean hasApiVersionAnnotation = am.isAnnotationPresent(ApiVersion.class);
if (hasApiVersionAnnotation) {
ApiVersion annotation = am.getAnnotation(ApiVersion.class);
boolean headerRequired = annotation.headerRequired();
float minVersion = annotation.minVersion();
float maxVersion = annotation.maxVersion();
response = Collections.<ResourceFilter>singletonList(new VersionFilter(headerRequired, minVersion, maxVersion));
}
return response;
}
示例10: getRequestType
import com.sun.jersey.api.model.AbstractMethod; //导入方法依赖的package包/类
protected String getRequestType(AbstractMethod am) throws
IllegalArgumentException {
Schema schema = am.getAnnotation(Schema.class);
if (schema != null && !schema.request().isEmpty()) {
return schema.request();
}
return null;
}
示例11: create
import com.sun.jersey.api.model.AbstractMethod; //导入方法依赖的package包/类
@Override
public List<ResourceFilter> create(AbstractMethod am) {
Authenticated authenticated = am.getAnnotation(Authenticated.class);
if (authenticated != null) {
return Collections
.<ResourceFilter>singletonList(new AuthenticatedResourceFilter());
}
Anonymous anonymous = am.getAnnotation(Anonymous.class);
if (anonymous != null) {
return Collections
.<ResourceFilter>singletonList(new AnonymousResourceFilter());
}
return null;
}
示例12: needsAuthorization
import com.sun.jersey.api.model.AbstractMethod; //导入方法依赖的package包/类
private boolean needsAuthorization(AbstractMethod am) {
return (am.getAnnotation(ANNOTATION_CLASS) != null) //
|| (am.getResource().getAnnotation(ANNOTATION_CLASS) != null);
}