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


Java ResourceInfo类代码示例

本文整理汇总了Java中javax.ws.rs.container.ResourceInfo的典型用法代码示例。如果您正苦于以下问题:Java ResourceInfo类的具体用法?Java ResourceInfo怎么用?Java ResourceInfo使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


ResourceInfo类属于javax.ws.rs.container包,在下文中一共展示了ResourceInfo类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: testVersionFilter

import javax.ws.rs.container.ResourceInfo; //导入依赖的package包/类
@SuppressWarnings("boxing")
private MultivaluedMap<String, String> testVersionFilter(String version) throws WebApplicationException, NoSuchMethodException {

    ResourceInfo resourceInfo = mock(ResourceInfo.class);
    ContainerRequestContext request = mock(ContainerRequestContext.class);
    UriInfo uriInfo = mock(UriInfo.class);
    when(request.getUriInfo()).thenReturn(uriInfo);

    Method method = SinceClass.class.getMethod("dummy");

    MultivaluedMap<String, String> prop = new MultivaluedHashMap<>();
    prop.putSingle(CommonParams.PARAM_VERSION, version);
    when(uriInfo.getPathParameters()).thenReturn(prop);

    VersionFilter filter = spy(new VersionFilter());
    when(filter.getResourceInfo()).thenReturn(resourceInfo);
    when(resourceInfo.getResourceMethod()).thenReturn(method);
    filter.filter(request);

    return prop;
}
 
开发者ID:servicecatalog,项目名称:oscm,代码行数:22,代码来源:VersionFilterTest.java

示例2: configure

import javax.ws.rs.container.ResourceInfo; //导入依赖的package包/类
@Override
public void configure(ResourceInfo resourceInfo, FeatureContext context) {

    List<Annotation> authzSpecs = new ArrayList<>();

    Annotation classAuthzSpec =
        resourceInfo.getResourceClass().getAnnotation(AppkeyAnnotation.class);
    Annotation methodAuthzSpec =
        resourceInfo.getResourceMethod().getAnnotation(AppkeyAnnotation.class);

    if (classAuthzSpec != null)
        authzSpecs.add(classAuthzSpec);
    if (methodAuthzSpec != null)
        authzSpecs.add(methodAuthzSpec);

    if (!authzSpecs.isEmpty()) {
        context.register(AppkeyFilter.class);
    }
}
 
开发者ID:jiumao-org,项目名称:wechat-mall,代码行数:20,代码来源:AppkeyServiceFeature.java

示例3: configure

import javax.ws.rs.container.ResourceInfo; //导入依赖的package包/类
@Override
public void configure(ResourceInfo resourceInfo, FeatureContext context) {

    List<Annotation> authzSpecs = new ArrayList<>();

    Annotation classAuthzSpec =
        resourceInfo.getResourceClass().getAnnotation(AuthAnnotation.class);
    Annotation methodAuthzSpec =
        resourceInfo.getResourceMethod().getAnnotation(AuthAnnotation.class);

    if (classAuthzSpec != null)
        authzSpecs.add(classAuthzSpec);
    if (methodAuthzSpec != null)
        authzSpecs.add(methodAuthzSpec);

    if (!authzSpecs.isEmpty()) {
        // 需要拦截的api
        context.register(AuthorizationFilter.class);
    }
}
 
开发者ID:jiumao-org,项目名称:wechat-mall,代码行数:21,代码来源:AuthServiceFeature.java

示例4: configure

import javax.ws.rs.container.ResourceInfo; //导入依赖的package包/类
@Override
public void configure(ResourceInfo resourceInfo, FeatureContext context) {
    CacheFor cc = resourceInfo.getResourceClass().getAnnotation(CacheFor.class);
    CacheFor mcc = resourceInfo.getResourceMethod().getAnnotation(CacheFor.class);
    if( mcc!=null ) {
        cc = mcc;
    }
    if (cc!=null) {
        if( cc.value() == 0 ) {
            context.register(NoCacheFilter.class);
        } else if( cc.value() > 0 ) {
            context.register(new CacheFilter("max-age= " + cc.unit().toSeconds(cc.value())));
        }
    } else {
        context.register(NoCacheFilter.class);
    }
}
 
开发者ID:syndesisio,项目名称:syndesis,代码行数:18,代码来源:CacheForFilter.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:warlock-china,项目名称:azeroth,代码行数:17,代码来源:DefaultFilterDynamicFeature.java

示例6: 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

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

示例8: selectVariant

import javax.ws.rs.container.ResourceInfo; //导入依赖的package包/类
private static MediaType selectVariant(Request request, ResourceInfo resourceInfo) {

        Produces produces = resourceInfo.getResourceMethod().getAnnotation(Produces.class);
        if (produces == null) {
            produces = getAnnotation(resourceInfo.getResourceClass(), Produces.class);
        }

        if (produces != null) {

            List<Variant> variants = Arrays.stream(produces.value())
                .map((String mt) -> Variant.mediaTypes(MediaType.valueOf(mt)).build().get(0))
                .collect(Collectors.toList());

            Variant variant = request.selectVariant(variants);
            if (variant != null) {
                return variant.getMediaType();
            }

        }

        return null;

    }
 
开发者ID:mvc-spec,项目名称:ozark,代码行数:24,代码来源:ViewResponseFilter.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();
    //@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

示例10: processResponse

import javax.ws.rs.container.ResourceInfo; //导入依赖的package包/类
@Override
public void processResponse(ContainerRequestContext requestContext, ContainerResponseContext responseContext,
		ResourceInfo resourceInfo) {
	MediaType mediaType = responseContext.getMediaType();
	if (mediaType != null && MediaType.APPLICATION_JSON_TYPE.equals(mediaType)) {
		Object responseData = responseContext.getEntity();
		WrapperResponseEntity jsonResponse;

		if (responseData instanceof WrapperResponseEntity) {
			jsonResponse = (WrapperResponseEntity) responseData;
		} else {
			jsonResponse = new WrapperResponseEntity(ResponseCode.OK);
			jsonResponse.setData(responseData);
		}
		responseContext.setStatus(ResponseCode.OK.getCode());

		responseContext.setEntity(jsonResponse);

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

示例11: 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

示例12: configure

import javax.ws.rs.container.ResourceInfo; //导入依赖的package包/类
@Override
public void configure(ResourceInfo resourceInfo, FeatureContext context) {
    // TODO why it is called twice for the same endpoint
    if (!tracingDisabled(resourceInfo) && builder.allTraced) {
        log(resourceInfo);
        context.register(new ServerTracingFilter(
            builder.tracer,
            operationName(resourceInfo),
            builder.spanDecorators,
            builder.operationNameBuilder.build(resourceInfo.getResourceClass(), resourceInfo.getResourceMethod()),
            builder.skipPattern != null ? Pattern.compile(builder.skipPattern) : null),
            builder.priority);

        if (builder.traceSerialization) {
            context.register(new ServerTracingInterceptor(builder.tracer,
                builder.serializationSpanDecorators), builder.serializationPriority);
        }
    }
}
 
开发者ID:opentracing-contrib,项目名称:java-jaxrs,代码行数:20,代码来源:ServerTracingDynamicFeature.java

示例13: configure

import javax.ws.rs.container.ResourceInfo; //导入依赖的package包/类
@Override
public void configure(ResourceInfo resourceInfo, FeatureContext context) {
    Trace annotation = resourceInfo.getResourceMethod().getAnnotation(Trace.class);
    String operationName = this.operationName;
    if (annotation != null) {
        if (!annotation.operationName().equals("")) {
            operationName = annotation.operationName();
        }
        context.register(new ServerRequestTracingFilter(this.tracer, operationName,
            this.tracedAttributes, this.tracedProperties, this.decorator));
        context.register(new ServerResponseTracingFilter(this.tracer));  
    } else {
        if (traceAll) {
            context.register(new ServerRequestTracingFilter(this.tracer, operationName,
                this.tracedAttributes, this.tracedProperties, this.decorator));
            context.register(new ServerResponseTracingFilter(this.tracer));
        } 
    }
}
 
开发者ID:opentracing-contrib,项目名称:java-dropwizard,代码行数:20,代码来源:ServerTracingFeature.java

示例14: 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

示例15: configure

import javax.ws.rs.container.ResourceInfo; //导入依赖的package包/类
@Override
public void configure(ResourceInfo resourceInfo, FeatureContext context) {

    if (resourceInfo.getResourceClass().getName()
            .startsWith(RootResource.class.getPackage().getName() + ".") == false) {
        return;
    }

    Permissions permissions = resourceInfo.getResourceMethod().getAnnotation(Permissions.class);
    if (permissions == null) {
        permissions = resourceInfo.getResourceClass().getAnnotation(Permissions.class);
    }
    if (permissions == null) {
        //TODO
        Logger.getLogger(PermissionProvider.class.getName())
                .warning(String.format("%s not annotated @Permissions",
                        resourceInfo.getResourceMethod().toGenericString()));
        return;
    }
    context.register(new PermissionTester(permissions));
}
 
开发者ID:backpaper0,项目名称:sealion,代码行数:22,代码来源:PermissionProvider.java


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