當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。