本文整理汇总了Java中javax.ws.rs.container.ResourceInfo.getResourceMethod方法的典型用法代码示例。如果您正苦于以下问题:Java ResourceInfo.getResourceMethod方法的具体用法?Java ResourceInfo.getResourceMethod怎么用?Java ResourceInfo.getResourceMethod使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类javax.ws.rs.container.ResourceInfo
的用法示例。
在下文中一共展示了ResourceInfo.getResourceMethod方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: configure
import javax.ws.rs.container.ResourceInfo; //导入方法依赖的package包/类
@Override
public void configure(ResourceInfo resourceInfo, FeatureContext context) {
// 获取资源方法
Method resourceMethod = resourceInfo.getResourceMethod();
if (resourceMethod != null) {
// 获取FormatJson注解
ResponseFormat formatJson = resourceMethod.getAnnotation(ResponseFormat.class);
if (formatJson == null || formatJson.type().equals(FormatType.JSON)) {
context.register(DefaultWebFilter.class);
}
}
}
示例2: configure
import javax.ws.rs.container.ResourceInfo; //导入方法依赖的package包/类
@Override
public void configure(ResourceInfo resourceInfo, FeatureContext context) {
Class<?> resourceClass = resourceInfo.getResourceClass();
Method resourceMethod = resourceInfo.getResourceMethod();
if (isStaticContent(resourceClass, resourceMethod)) {
// class or method is annotated with MCRStaticContent
// -> do not register any filter
return;
}
String packageName = resourceClass.getPackage().getName();
if (getPackages().contains(packageName)) {
registerTransactionFilter(context);
registerSessionHookFilter(context);
registerAccessFilter(context, resourceClass, resourceMethod);
}
}
示例3: configure
import javax.ws.rs.container.ResourceInfo; //导入方法依赖的package包/类
@Override
public void configure(ResourceInfo resourceInfo, FeatureContext featureContext) {
AnnotatedMethod am = new AnnotatedMethod(resourceInfo.getResourceMethod());
RequireBasicAuth requireBasicAuth = null;
if (am.isAnnotationPresent(RequireBasicAuth.class)) {
requireBasicAuth = am.getAnnotation(RequireBasicAuth.class);
}
else {
requireBasicAuth = resourceInfo.getResourceClass().getAnnotation(RequireBasicAuth.class);
}
if (requireBasicAuth != null) {
featureContext.register(new BasicAuthKarafSecurityRequestFilter(requireBasicAuth.limitToGroups(), requireBasicAuth.limitToRoles(), requireBasicAuth.karafRealm(), requireBasicAuth.requiresSecure(), requireBasicAuth.httpRealm()));
}
}
示例4: configure
import javax.ws.rs.container.ResourceInfo; //导入方法依赖的package包/类
@Override
public void configure(ResourceInfo resourceInfo, FeatureContext context) {
final AnnotatedMethod am = new AnnotatedMethod(resourceInfo.getResourceMethod());
final Annotation[][] parameterAnnotations = am.getParameterAnnotations();
//@DenyAll shouldn't be attached to classes
final boolean annotationOnClass = (resourceInfo.getResourceClass().getAnnotation(RolesAllowed.class) != null) ||
(resourceInfo.getResourceClass().getAnnotation(PermitAll.class) != null);
final boolean annotationOnMethod = am.isAnnotationPresent(RolesAllowed.class) || am.isAnnotationPresent(DenyAll.class) ||
am.isAnnotationPresent(PermitAll.class);
if (annotationOnClass || annotationOnMethod) {
context.register(filterClass);
} else {
for (Annotation[] annotations : parameterAnnotations) {
for (Annotation annotation : annotations) {
if (annotation instanceof Auth) {
context.register(filterClass);
return;
}
}
}
}
}
示例5: configure
import javax.ws.rs.container.ResourceInfo; //导入方法依赖的package包/类
@Override
public void configure(ResourceInfo resourceInfo, FeatureContext context) {
// 获取资源方法
Method resourceMethod = resourceInfo.getResourceMethod();
if (resourceMethod != null) {
// 获取FormatJson注解
ResponseFormat formatJson = resourceMethod.getAnnotation(ResponseFormat.class);
if(formatJson == null || formatJson.type().equals(FormatType.JSON)){
context.register(DefaultWebFilter.class);
}
}
}
示例6: configure
import javax.ws.rs.container.ResourceInfo; //导入方法依赖的package包/类
@Override
public void configure(final ResourceInfo resourceInfo, final FeatureContext configuration) {
AnnotatedMethod am = new AnnotatedMethod(resourceInfo.getResourceMethod());
// RolesAllowed on the method takes precedence over PermitAll
RolesAllowed ra = am.getAnnotation(RolesAllowed.class);
if (ra != null) {
configuration.register(AuthCheckFilter.INSTANCE);
return;
}
// PermitAll takes precedence over RolesAllowed on the class
// This avoids putting AuthCheckFilter in the request flow for all path's which
// are defined under PermitAll annotation. That is requests for "/", "/login", "/mainLogin" and "/spnegoLogin"
// path's doesn't go through AuthCheckFilter.
if (am.isAnnotationPresent(PermitAll.class)) {
// Do nothing.
return;
}
// RolesAllowed on the class takes precedence over PermitAll
ra = resourceInfo.getResourceClass().getAnnotation(RolesAllowed.class);
if (ra != null) {
configuration.register(AuthCheckFilter.INSTANCE);
}
}
示例7: configure
import javax.ws.rs.container.ResourceInfo; //导入方法依赖的package包/类
@Override
public void configure(ResourceInfo resourceInfo, FeatureContext context) {
Class<?> resourceClass = resourceInfo.getResourceClass();
Method method = resourceInfo.getResourceMethod();
boolean required = true;
if (resourceClass.isAnnotationPresent(TenantRequired.class)) {
required = resourceClass.getAnnotation(TenantRequired.class).value();
}
if (method.isAnnotationPresent(TenantRequired.class)) {
required = method.getAnnotation(TenantRequired.class).value();
}
if (required) {
context.register(TENANT_FILTER);
}
}
示例8: configure
import javax.ws.rs.container.ResourceInfo; //导入方法依赖的package包/类
@Override
public void configure(ResourceInfo resourceInfo, FeatureContext context) {
Method resourceMethod = resourceInfo.getResourceMethod();
Class<?> resourceClass = resourceInfo.getResourceClass();
if(metricsDisabled(resourceClass)) {
return;
}
Path methodPath = resourceMethod.getAnnotation(Path.class);
Path classPath = resourceClass.getAnnotation(Path.class);
Path path = methodPath != null ? methodPath : classPath;
if(path != null) {
UriBuilder builder = methodPath != null
? UriBuilder.fromResource(resourceClass).path(resourceClass, resourceMethod.getName())
: UriBuilder.fromResource(resourceClass);
String template = builder.toTemplate();
context.register(new TimerBeforeFilter(template));
context.register(TimerAfterFilter.class);
}
}
示例9: configure
import javax.ws.rs.container.ResourceInfo; //导入方法依赖的package包/类
@Override
public void configure(ResourceInfo resourceInfo, FeatureContext context) {
final AnnotatedMethod am = new AnnotatedMethod(resourceInfo.getResourceMethod());
final Annotation[][] parameterAnnotations = am.getParameterAnnotations();
if (am.isAnnotationPresent(RolesAllowed.class) || am.isAnnotationPresent(DenyAll.class) ||
am.isAnnotationPresent(PermitAll.class)) {
context.register(authFilter);
} else {
for (Annotation[] annotations : parameterAnnotations) {
for (Annotation annotation : annotations) {
if (annotation instanceof Auth) {
context.register(authFilter);
return;
}
}
}
}
}
示例10: configure
import javax.ws.rs.container.ResourceInfo; //导入方法依赖的package包/类
@Override
public void configure(ResourceInfo resourceInfo, FeatureContext context) {
Method am = resourceInfo.getResourceMethod();
if (am.isAnnotationPresent(Permissions.class)) {
Authenticated authenticated = am.getAnnotation(Authenticated.class);
if (authenticated == null) {
authenticated = resourceInfo.getResourceClass().getAnnotation(Authenticated.class);
if (authenticated == null) {
throw new IllegalStateException("@Permissions found on " + am + " but no @Authenticated found");
}
}
List<String> permissions = Arrays.asList(am.getAnnotation(Permissions.class).value());
Collection<String> vars = new HashSet<>();
for (String p : permissions) {
int s = p.indexOf('{');
while (s != -1) {
int e = p.indexOf('}', s + 1);
vars.add(p.substring(s + 1, e));
s = p.indexOf('{', e + 1);
}
}
context.register(new PermissionFilter(authenticated.value(), permissions, vars));
}
}
示例11: configure
import javax.ws.rs.container.ResourceInfo; //导入方法依赖的package包/类
@Override
public void configure(ResourceInfo resourceInfo, FeatureContext context) {
Class<?> resourceClass = resourceInfo.getResourceClass();
Method method = resourceInfo.getResourceMethod();
logger.info("getResourceClass: " + resourceClass);
logger.info("getResourceMethod: " + method);
context.property("new_dynamic_feature", resourceClass + "|" + method);
}
开发者ID:PacktPublishing,项目名称:Mastering-Java-EE-Development-with-WildFly,代码行数:9,代码来源:MyResourceSingleton.java
示例12: configure
import javax.ws.rs.container.ResourceInfo; //导入方法依赖的package包/类
@Override
public void configure(ResourceInfo resourceInfo, FeatureContext context) {
if (ENFORCE_AUTHENTICATION && ENFORCE_AUTHORIZATION) {
final Method method = resourceInfo.getResourceMethod();
if (method.isAnnotationPresent(PermissionRequired.class)) {
context.register(AuthorizationFilter.class);
}
}
}
示例13: configure
import javax.ws.rs.container.ResourceInfo; //导入方法依赖的package包/类
@Override
public void configure(ResourceInfo resourceInfo, FeatureContext context) {
if (ENFORCE_AUTHENTICATION) {
final Method method = resourceInfo.getResourceMethod();
if (!method.isAnnotationPresent(AuthenticationNotRequired.class)) {
context.register(AuthenticationFilter.class);
}
}
}
示例14: configure
import javax.ws.rs.container.ResourceInfo; //导入方法依赖的package包/类
@Override
public void configure(ResourceInfo resourceInfo, FeatureContext context) {
Method method = resourceInfo.getResourceMethod();
Annotation[][] parameterAnnotations = method.getParameterAnnotations();
for (Annotation[] annotations : parameterAnnotations) {
for (Annotation annotation : annotations) {
if (annotation.annotationType().equals(Session.class) && !method.getName().startsWith("log")) {
context.register(NiPingAuthFilter.class);
}
}
}
}
示例15: configure
import javax.ws.rs.container.ResourceInfo; //导入方法依赖的package包/类
@Override
public void configure(final ResourceInfo resourceInfo,
final FeatureContext context) {
final AnnotatedMethod method = new AnnotatedMethod(resourceInfo.getResourceMethod());
final RateLimited rateLimited = method.getAnnotation(RateLimited.class);
if (null != rateLimited) {
context.register(RateLimit429EnforcerFilter.class);
}
}