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


Java ResourceInfo.getResourceMethod方法代码示例

本文整理汇总了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);
        }

    }
}
 
开发者ID:warlock-china,项目名称:azeroth,代码行数:17,代码来源:DefaultFilterDynamicFeature.java

示例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);
    }
}
 
开发者ID:MyCoRe-Org,项目名称:mycore,代码行数:17,代码来源:MCRJerseyDefaultFeature.java

示例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()));
    }
}
 
开发者ID:andyphillips404,项目名称:awplab-core,代码行数:18,代码来源:BasicAuthKarafSecurityDynamicFeature.java

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

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

	}
}
 
开发者ID:vakinge,项目名称:jeesuite-libs,代码行数:17,代码来源:DefaultFilterDynamicFeature.java

示例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);
  }
}
 
开发者ID:axbaretto,项目名称:drill,代码行数:27,代码来源:AuthDynamicFeature.java

示例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);
    }
}
 
开发者ID:hawkular,项目名称:hawkular-commons,代码行数:19,代码来源:TenantFeature.java

示例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);
    }
}
 
开发者ID:kantega,项目名称:respiro,代码行数:23,代码来源:TimerFeature.java

示例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;
                }
            }
        }
    }
}
 
开发者ID:dropwizard,项目名称:dropwizard-java8,代码行数:19,代码来源:AuthDynamicFeature.java

示例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));
    }
}
 
开发者ID:guestful,项目名称:module.jaxrs-filter-security,代码行数:25,代码来源:PermissionsFeature.java

示例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);
        }
    }
}
 
开发者ID:stevespringett,项目名称:Alpine,代码行数:10,代码来源:AuthorizationFeature.java

示例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);
        }
    }
}
 
开发者ID:stevespringett,项目名称:Alpine,代码行数:10,代码来源:AuthenticationFeature.java

示例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);
            }
        }
    }
}
 
开发者ID:CloudWise-OpenSource,项目名称:SAPNetworkMonitor,代码行数:13,代码来源:AuthFilterDynamicBinding.java

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


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