当前位置: 首页>>代码示例>>Java>>正文


Java AbstractMethod.getAnnotation方法代码示例

本文整理汇总了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;
}
 
开发者ID:bazaarvoice,项目名称:emodb,代码行数:27,代码来源:AuthResourceFilterFactory.java

示例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;

}
 
开发者ID:inbloom,项目名称:secure-data-service,代码行数:18,代码来源:RightCheckFilterFactory.java

示例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();
    }
}
 
开发者ID:enviroCar,项目名称:enviroCar-server,代码行数:22,代码来源:JSONSchemaResourceFilterFactory.java

示例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;
}
 
开发者ID:hburgmeier,项目名称:jerseyoauth2,代码行数:26,代码来源:OAuth20FilterFactory.java

示例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;
}
 
开发者ID:personium,项目名称:personium-core,代码行数:12,代码来源:PersoniumCoreResourceFilterFactory.java

示例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();
        }
    };
}
 
开发者ID:bazaarvoice,项目名称:emodb,代码行数:38,代码来源:AuthResourceFilterFactory.java

示例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;
}
 
开发者ID:DevStreet,项目名称:FinanceAnalytics,代码行数:22,代码来源:SubscribingFilterFactory.java

示例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;
}
 
开发者ID:rridgley1,项目名称:agon,代码行数:13,代码来源:RateLimiterResourceFilterFactory.java

示例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;
}
 
开发者ID:rridgley1,项目名称:agon,代码行数:14,代码来源:ApiVersionResourceFilterFactory.java

示例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;
}
 
开发者ID:enviroCar,项目名称:enviroCar-server,代码行数:9,代码来源:JSONSchemaResourceFilterFactory.java

示例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;
}
 
开发者ID:enviroCar,项目名称:enviroCar-server,代码行数:15,代码来源:AuthenticationResourceFilterFactory.java

示例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);
}
 
开发者ID:HuygensING,项目名称:elaborate4-backend,代码行数:5,代码来源:ElaborateResourceFilterFactory.java


注:本文中的com.sun.jersey.api.model.AbstractMethod.getAnnotation方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。