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