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


Java ResourceInfo.getResourceClass方法代码示例

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


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

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

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

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

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

示例5: buildRequestScopedName

import javax.ws.rs.container.ResourceInfo; //导入方法依赖的package包/类
@Override
public MetricName buildRequestScopedName(MetricName metricName, AnnotatedElement injectionSite, Type metricType) {
    checkState(resourceInfoProvider != null, "resourceInfo must be set");
    ResourceInfo resourceInfo = resourceInfoProvider.get();
    if (resourceInfo == null || resourceInfo.getResourceClass() == null) {
        return metricName;
    }
    return metricName.addTag(tagName, resourceInfo.getResourceClass().getSimpleName());
}
 
开发者ID:baharclerode,项目名称:dropwizard-hk2,代码行数:10,代码来源:ResourceClassMetricNameFilter.java

示例6: isPermitAll

import javax.ws.rs.container.ResourceInfo; //导入方法依赖的package包/类
boolean isPermitAll(ResourceInfo resourceInfo) {
    Method resourceMethod = resourceInfo.getResourceMethod();
    Class<?> resourceClass = resourceInfo.getResourceClass();
    if (resourceMethod == null || resourceClass == null) {
        return false;
    }

    return resourceClass.isAnnotationPresent(PermitAll.class) || resourceMethod.isAnnotationPresent(PermitAll.class);
}
 
开发者ID:puzzle,项目名称:jee-user-auth,代码行数:10,代码来源:AuthenticationFeature.java

示例7: parseSource

import javax.ws.rs.container.ResourceInfo; //导入方法依赖的package包/类
/**
 * <p>parseSource.</p>
 *
 * @param resourceInfo a {@link javax.ws.rs.container.ResourceInfo} object.
 * @return a {@link java.lang.String} object.
 */
public static String parseSource(ResourceInfo resourceInfo) {
    if (resourceInfo != null) {
        Class clazz = resourceInfo.getResourceClass();
        if (clazz != null)
            return ClassUtils.toString(clazz, resourceInfo.getResourceMethod());
    }
    return null;
}
 
开发者ID:icode,项目名称:ameba,代码行数:15,代码来源:ErrorMessage.java

示例8: checkQuery

import javax.ws.rs.container.ResourceInfo; //导入方法依赖的package包/类
/**
 * <p>checkQuery.</p>
 *
 * @param query     a {@link io.ebean.Query} object.
 * @param whitelist a {@link java.util.Set} object.
 * @param blacklist a {@link java.util.Set} object.
 * @param manager   a {@link InjectionManager} object.
 */
public static void checkQuery(Query<?> query, Set<String> whitelist,
                              Set<String> blacklist, InjectionManager manager) {
    ResourceInfo resource = manager.getInstance(ResourceInfo.class);
    Class<?> rc = resource.getResourceClass();
    Set<String> wl = null, bl = null;
    if (rc != null) {
        Filter filter = rc.getAnnotation(Filter.class);

        if (filter != null) {
            if (filter.whitelist().length > 0) {
                wl = Sets.newLinkedHashSet();
                Collections.addAll(wl, filter.whitelist());
            }
            if (filter.blacklist().length > 0) {
                bl = Sets.newLinkedHashSet();
                Collections.addAll(bl, filter.blacklist());
            }
        }
    }

    if (whitelist != null) {
        if (wl == null) {
            wl = Sets.newLinkedHashSet();
        }
        wl.addAll(whitelist);
    }

    if (blacklist != null) {
        if (bl == null) {
            bl = Sets.newLinkedHashSet();
        }
        bl.addAll(blacklist);
    }
    checkQuery((SpiQuery) query, wl, bl, manager.getInstance(Application.Mode.class).isProd());
}
 
开发者ID:icode,项目名称:ameba,代码行数:44,代码来源:EbeanUtils.java

示例9: test

import javax.ws.rs.container.ResourceInfo; //导入方法依赖的package包/类
/**
 * <p>
 * The key logic for the test is as follows:
 * </p>
 * <p>
 * Let:
 * </p>
 * <table>
 * <tr>
 * <td>a =</td>
 * <td>resourceMethodHasRolesAllowed</td>
 * </tr>
 * <tr>
 * <td>b =</td>
 * <td>resourceClassHasRolesAllowed</td>
 * </tr>
 * <tr>
 * <td>c =</td>
 * <td>resourceMethodHasPermitAll</td>
 * </tr>
 * <tr>
 * <td>d =</td>
 * <td>resourceClassHasPermitAll</td>
 * </tr>
 * </table>
 * <p>
 * The rules that need to be applied translate to:
 * </p>
 *
 * <pre>
 * = a || ( b && !c ) || ( !a && !b && !c && !d )
 * = (a || b || !d) && ( a || !c )
 * </pre>
 *
 * @param resourceInfo
 *            resource info
 * @return <code>true</code> if the resource is protected
 */
@Override
public boolean test(final ResourceInfo resourceInfo) {

    final Method resourceMethod = resourceInfo.getResourceMethod();
    final Class<?> resourceClass = resourceInfo.getResourceClass();

    final boolean resourceMethodHasRolesAllowed = resourceMethod.getAnnotation(RolesAllowed.class) != null;
    final boolean resourceClassHasRolesAllowed = resourceClass.getAnnotation(RolesAllowed.class) != null;

    final boolean resourceMethodHasPermitAll = resourceMethod.getAnnotation(PermitAll.class) != null;
    final boolean resourceClassHasPermitAll = resourceClass.getAnnotation(PermitAll.class) != null;

    if (LOG.isDebugEnabled()) {
        LOG.debug("resourceMethod={} PermitAll={} RolesAllowed={}", resourceMethod, resourceMethodHasPermitAll, resourceMethodHasRolesAllowed);
        LOG.debug("resourceClass={} PermitAll={} RolesAllowed={}", resourceClass, resourceClassHasPermitAll, resourceClassHasRolesAllowed);
    }

    if (resourceMethodHasRolesAllowed && resourceMethodHasPermitAll) {
        throw new IllegalArgumentException("The resource method " + resourceMethod + " may not have both @RolesAllowed and @PermitAll annotations.");
    } else if (resourceClassHasRolesAllowed && resourceClassHasPermitAll) {
        throw new IllegalArgumentException("The resource class " + resourceClass + " may not have both @RolesAllowed and @PermitAll annotations.");
    } else {
        return (resourceMethodHasRolesAllowed || resourceClassHasRolesAllowed || !resourceClassHasPermitAll) && (resourceMethodHasRolesAllowed || !resourceMethodHasPermitAll);
    }

}
 
开发者ID:trajano,项目名称:app-ms,代码行数:65,代码来源:DefaultAssertionRequiredPredicate.java


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