• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Java AbstractResourceMethod类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: create

import com.sun.jersey.api.model.AbstractResourceMethod; //导入依赖的package包/类
@Override
public List<ResourceFilter> create(AbstractMethod am) {
    // documented to only be AbstractSubResourceLocator, AbstractResourceMethod, or AbstractSubResourceMethod
    if (am instanceof AbstractSubResourceLocator) {
        // not actually invoked per request, nothing to do
        logger.debug("Ignoring AbstractSubResourceLocator " + am);
        return null;
    } else if (am instanceof AbstractResourceMethod) {
        String transactionName = namer.getTransactionName((AbstractResourceMethod) am);

        return Arrays.asList(new NewRelicTransactionNameResourceFilter(newRelicWrapper, category, transactionName),
            new NewRelicMappedThrowableResourceFilter(newRelicWrapper));
    } else {
        logger.warn("Got an unexpected instance of " + am.getClass().getName() + ": " + am);
        return null;
    }
}
 
开发者ID:palominolabs,项目名称:jersey-new-relic,代码行数:18,代码来源:NewRelicResourceFilterFactory.java


示例2: getState

import com.sun.jersey.api.model.AbstractResourceMethod; //导入依赖的package包/类
/**
 * Check the method, then the class, for @ResourceMetrics and use the specified checker to see if the feature is
 * enabled or disabled.
 *
 * @param am      resource method
 * @param checker checker
 * @return EnabledState.ON if feature enabled, EnabledState.OFF if feature disabled, EnabledState.UNSPECIFIED
 *         otherwise
 */
static EnabledState getState(AbstractResourceMethod am, MetricsAnnotationChecker checker) {
    // check method, then class
    for (ResourceMetrics ann : new ResourceMetrics[]{am.getAnnotation(ResourceMetrics.class), am
        .getResource().getAnnotation(ResourceMetrics.class)}) {

        if (ann != null) {
            if (checker.check(ann)) {
                return EnabledState.ON;
            } else {
                return EnabledState.OFF;
            }
        }
    }

    return EnabledState.UNSPECIFIED;
}
 
开发者ID:palominolabs,项目名称:jersey-metrics-filter,代码行数:26,代码来源:MetricAnnotationFeatureResolver.java


示例3: createDispatchWrapper

import com.sun.jersey.api.model.AbstractResourceMethod; //导入依赖的package包/类
@Override
public ResourceMethodDispatchWrapper createDispatchWrapper(AbstractResourceMethod am) {
    EnabledState state = MetricAnnotationFeatureResolver.getState(am, new TimingMetricsAnnotationChecker());

    if (state == EnabledState.OFF ||
        (state == EnabledState.UNSPECIFIED && !jerseyMetricsConfig.isTimingEnabledByDefault())) {
        return null;
    }

    Class<?> resourceClass = am.getResource().getResourceClass();
    String metricId = namer.getMetricBaseName(am);
    final Timer timer = metricsRegistry.timer(MetricRegistry.name(resourceClass, metricId + " timer"));
    return new ResourceMethodDispatchWrapper() {
        @Override
        public void wrapDispatch(Object resource, HttpContext context, ResourceMethodDispatchWrapperChain chain) {

            final Timer.Context time = timer.time();
            try {
                chain.wrapDispatch(resource, context);
            } finally {
                time.stop();
            }
        }
    };
}
 
开发者ID:palominolabs,项目名称:jersey-metrics-filter,代码行数:26,代码来源:MetricsWrapperFactory.java


示例4: create

import com.sun.jersey.api.model.AbstractResourceMethod; //导入依赖的package包/类
@Override
public List<ResourceFilter> create(AbstractMethod am) {
	if (am instanceof AbstractResourceMethod)
	{
		OAuth20 oauth20 = am.getAnnotation(OAuth20.class);
		AllowedScopes scopes = am.getAnnotation(AllowedScopes.class);
		
		if (oauth20!=null)
		{
			LOGGER.debug("Installing oauth2 filter on {}", am.getResource());
			return getFilters(scopes);
		}
		else {
			oauth20 = am.getResource().getAnnotation(OAuth20.class);
			scopes = am.getResource().getAnnotation(AllowedScopes.class);
			if (oauth20!=null)
			{
				LOGGER.debug("Installing oauth2 filter on {}", am.getResource());
				return getFilters(scopes);				
			}
			return null;	
		}
	} else
		return null;
}
 
开发者ID:hburgmeier,项目名称:jerseyoauth2,代码行数:26,代码来源:OAuth20FilterFactory.java


示例5: filter

import com.sun.jersey.api.model.AbstractResourceMethod; //导入依赖的package包/类
@Override
public ContainerResponse filter(ContainerRequest request, ContainerResponse response) {
  AbstractResourceMethod matchedMethod = _httpContext.getUriInfo().getMatchedMethod();
  boolean methodsEqual = matchedMethod.equals(_method);
  String methodName = methodName(_method);
  String matchedMethodName = methodName(matchedMethod);
  System.out.println(methodsEqual);
  System.out.println(methodName);
  System.out.println(matchedMethodName);
  return response;
}
 
开发者ID:DevStreet,项目名称:FinanceAnalytics,代码行数:12,代码来源:TestFilterFactory.java


示例6: create

import com.sun.jersey.api.model.AbstractResourceMethod; //导入依赖的package包/类
@Override
public RequestDispatcher create(AbstractResourceMethod abstractResourceMethod) {
    RequestDispatcher dispatcher = _provider.create(abstractResourceMethod);
    CacheGroup groupNameAnn = abstractResourceMethod.getAnnotation(CacheGroup.class);
    Vary varyAnn = abstractResourceMethod.getAnnotation(Vary.class);
    IncludeBodyInCacheKey includeBodyInCacheKeyAnn = abstractResourceMethod.getAnnotation(IncludeBodyInCacheKey.class);

    Set<String> vary = ImmutableSet.of();

    if (varyAnn != null && varyAnn.value() != null) {
        vary = HttpHeaderUtils.headerNames(Iterables.filter(
                Arrays.asList(varyAnn.value()),
                Predicates.notNull()));
    }

    boolean includeBodyInCacheKey = includeBodyInCacheKeyAnn != null && includeBodyInCacheKeyAnn.enabled();

    if (groupNameAnn != null || abstractResourceMethod.isAnnotationPresent(CacheControl.class)) {
        String groupName = groupNameAnn == null ? "" : groupNameAnn.value();
        dispatcher = new CachingDispatcher(dispatcher, _cache, _cacheControlMapper.apply(groupName), vary, includeBodyInCacheKey);
    } else if (abstractResourceMethod.getHttpMethod().equals("GET")) {
        Optional<String> cacheControlOverride = _cacheControlMapper.apply("");

        if (cacheControlOverride != null && cacheControlOverride.isPresent()) {
            dispatcher = new CachingDispatcher(dispatcher, _cache, cacheControlOverride, vary, includeBodyInCacheKey);
        }
    }

    return dispatcher;
}
 
开发者ID:bazaarvoice,项目名称:dropwizard-caching-bundle,代码行数:31,代码来源:CacheResourceMethodDispatchAdapter.java


示例7: getTransactionName

import com.sun.jersey.api.model.AbstractResourceMethod; //导入依赖的package包/类
@Override
@Nonnull
public String getTransactionName(AbstractResourceMethod am) {

    String transactionName = getPathWithoutSurroundingSlashes(am.getResource().getPath());

    if (!transactionName.isEmpty()) {
        transactionName = "/" + transactionName;
    }

    String httpMethod;
    if (am instanceof AbstractSubResourceMethod) {
        // if this is a subresource, add on the subresource's path component
        AbstractSubResourceMethod asrm = (AbstractSubResourceMethod) am;
        transactionName += "/" + getPathWithoutSurroundingSlashes(asrm.getPath());
        httpMethod = asrm.getHttpMethod();
    } else {
        httpMethod = am.getHttpMethod();
    }

    if (transactionName.isEmpty()) {
        // this happens for WadlResource -- that case actually exists at "application.wadl" though
        transactionName = "(no path)";
    }

    transactionName += " " + httpMethod;

    return transactionName;
}
 
开发者ID:palominolabs,项目名称:jersey-new-relic,代码行数:30,代码来源:ResourceTransactionNamerImpl.java


示例8: testGetMetricIdClassWithPathMethodWithoutPath

import com.sun.jersey.api.model.AbstractResourceMethod; //导入依赖的package包/类
@Test
public void testGetMetricIdClassWithPathMethodWithoutPath() {
    AbstractResource resource = new AbstractResource(FooResource.class, new PathValue("/res"));
    AbstractResourceMethod method =
        new AbstractResourceMethod(resource, null, Void.class, Void.class, "GET", new Annotation[]{});

    assertEquals("/res GET", namer.getTransactionName(method));
}
 
开发者ID:palominolabs,项目名称:jersey-new-relic,代码行数:9,代码来源:ResourceTransactionNamerImplTest.java


示例9: testGetMetricIdClassWithPathMethodWithPath

import com.sun.jersey.api.model.AbstractResourceMethod; //导入依赖的package包/类
@Test
public void testGetMetricIdClassWithPathMethodWithPath() {
    AbstractResource resource = new AbstractResource(FooResource.class, new PathValue("/res"));
    AbstractResourceMethod method =
        new AbstractSubResourceMethod(resource, null, Void.class, Void.class, new PathValue("/meth"), "GET",
            new Annotation[]{});

    assertEquals("/res/meth GET", namer.getTransactionName(method));
}
 
开发者ID:palominolabs,项目名称:jersey-new-relic,代码行数:10,代码来源:ResourceTransactionNamerImplTest.java


示例10: testGetMetricIdClassWithoutPathMethodWithPath

import com.sun.jersey.api.model.AbstractResourceMethod; //导入依赖的package包/类
@Test
public void testGetMetricIdClassWithoutPathMethodWithPath() {
    AbstractResource resource = new AbstractResource(FooResource.class, null);
    AbstractResourceMethod method =
        new AbstractSubResourceMethod(resource, null, Void.class, Void.class, new PathValue("/meth"), "GET",
            new Annotation[]{});

    assertEquals("/meth GET", namer.getTransactionName(method));
}
 
开发者ID:palominolabs,项目名称:jersey-new-relic,代码行数:10,代码来源:ResourceTransactionNamerImplTest.java


示例11: create

import com.sun.jersey.api.model.AbstractResourceMethod; //导入依赖的package包/类
@Override
public RequestDispatcher create(AbstractResourceMethod abstractResourceMethod) {

    ImmutableList.Builder<ResourceMethodDispatchWrapper> builder = ImmutableList.builder();

    for (ResourceMethodDispatchWrapperFactory wrapperFactory : wrapperFactories) {
        logger.trace("Invoking factory " + wrapperFactory.getClass().getName());
        ResourceMethodDispatchWrapper wrapper = wrapperFactory.createDispatchWrapper(abstractResourceMethod);
        if (wrapper == null) {
            logger.trace("Factory did not produce a wrapper");
            continue;
        }

        logger.trace("Factory produced a wrapper");
        builder.add(wrapper);
    }

    ImmutableList<ResourceMethodDispatchWrapper> wrappers = builder.build();
    RequestDispatcher innerDispatcher = wrappedProvider.create(abstractResourceMethod);

    if (wrappers.isEmpty()) {
        // just use the plain, un-wrapped dispatcher
        return innerDispatcher;
    }

    return new WrappedRequestDispatcher(innerDispatcher, wrappers);
}
 
开发者ID:palominolabs,项目名称:jersey-guice-dispatch-wrapper,代码行数:28,代码来源:WrappedResourceMethodDispatchProvider.java


示例12: create

import com.sun.jersey.api.model.AbstractResourceMethod; //导入依赖的package包/类
@Override
public List<ResourceFilter> create(AbstractMethod am) {

    // documented to only be AbstractSubResourceLocator, AbstractResourceMethod, or AbstractSubResourceMethod
    if (am instanceof AbstractSubResourceLocator) {
        // not actually invoked per request, nothing to do
        logger.debug("Ignoring AbstractSubResourceLocator " + am);
        return null;
    } else if (am instanceof AbstractResourceMethod) {

        EnabledState state = MetricAnnotationFeatureResolver
            .getState((AbstractResourceMethod) am, new StatusCodeMetricsAnnotationChecker());

        if (state == EnabledState.OFF ||
            (state == EnabledState.UNSPECIFIED && !jerseyMetricsConfig.isStatusCodeCounterEnabledByDefault())) {
            return null;
        }

        String metricBaseName = namer.getMetricBaseName((AbstractResourceMethod) am);
        Class<?> resourceClass = am.getResource().getResourceClass();

        return Lists
            .<ResourceFilter>newArrayList(
                new HttpStatusCodeCounterResourceFilter(metricsRegistry, metricBaseName, resourceClass));
    } else {
        logger.warn("Got an unexpected instance of " + am.getClass().getName() + ": " + am);
        return null;
    }
}
 
开发者ID:palominolabs,项目名称:jersey-metrics-filter,代码行数:30,代码来源:HttpStatusCodeCounterResourceFilterFactory.java


示例13: getMetricBaseName

import com.sun.jersey.api.model.AbstractResourceMethod; //导入依赖的package包/类
@Nonnull
@Override
public String getMetricBaseName(AbstractResourceMethod am) {

    String metricId = getPathWithoutSurroundingSlashes(am.getResource().getPath());

    if (!metricId.isEmpty()) {
        metricId = "/" + metricId;
    }

    String httpMethod;
    if (am instanceof AbstractSubResourceMethod) {
        // if this is a subresource, add on the subresource's path component
        AbstractSubResourceMethod asrm = (AbstractSubResourceMethod) am;
        metricId += "/" + getPathWithoutSurroundingSlashes(asrm.getPath());
        httpMethod = asrm.getHttpMethod();
    } else {
        httpMethod = am.getHttpMethod();
    }

    if (metricId.isEmpty()) {
        // this happens for WadlResource -- that case actually exists at "application.wadl" though
        metricId = "_no path_";
    }

    metricId += " " + httpMethod;

    return metricId;
}
 
开发者ID:palominolabs,项目名称:jersey-metrics-filter,代码行数:30,代码来源:ResourceMetricNamerImpl.java


示例14: testGetMetricIdClassWithPathMethodWithoutPath

import com.sun.jersey.api.model.AbstractResourceMethod; //导入依赖的package包/类
@Test
public void testGetMetricIdClassWithPathMethodWithoutPath() {
    AbstractResource resource = new AbstractResource(FooResource.class, new PathValue("/res"));
    AbstractResourceMethod method =
        new AbstractResourceMethod(resource, null, Void.class, Void.class, "GET", new Annotation[]{});

    assertEquals("/res GET", namer.getMetricBaseName(method));
}
 
开发者ID:palominolabs,项目名称:jersey-metrics-filter,代码行数:9,代码来源:ResourceMetricNamerImplTest.java


示例15: testGetMetricIdClassWithPathMethodWithPath

import com.sun.jersey.api.model.AbstractResourceMethod; //导入依赖的package包/类
@Test
public void testGetMetricIdClassWithPathMethodWithPath() {
    AbstractResource resource = new AbstractResource(FooResource.class, new PathValue("/res"));
    AbstractResourceMethod method =
        new AbstractSubResourceMethod(resource, null, Void.class, Void.class, new PathValue("/meth"), "GET",
            new Annotation[]{});

    assertEquals("/res/meth GET", namer.getMetricBaseName(method));
}
 
开发者ID:palominolabs,项目名称:jersey-metrics-filter,代码行数:10,代码来源:ResourceMetricNamerImplTest.java


示例16: testGetMetricIdClassWithoutPathMethodWithPath

import com.sun.jersey.api.model.AbstractResourceMethod; //导入依赖的package包/类
@Test
public void testGetMetricIdClassWithoutPathMethodWithPath() {
    AbstractResource resource = new AbstractResource(FooResource.class, null);
    AbstractResourceMethod method =
        new AbstractSubResourceMethod(resource, null, Void.class, Void.class, new PathValue("/meth"), "GET",
            new Annotation[]{});

    assertEquals("/meth GET", namer.getMetricBaseName(method));
}
 
开发者ID:palominolabs,项目名称:jersey-metrics-filter,代码行数:10,代码来源:ResourceMetricNamerImplTest.java


示例17: create

import com.sun.jersey.api.model.AbstractResourceMethod; //导入依赖的package包/类
@Override
public List<ResourceFilter> create(AbstractMethod abstractMethod) {
    if (!(abstractMethod instanceof AbstractResourceMethod)) {
        return null;
    }

    Method method = abstractMethod.getMethod();
    Class<?> klass = method.getDeclaringClass();
    List<ResourceFilter> filters = newArrayList();

    // check for impossible combinations
    if (method.isAnnotationPresent(OPTIONS.class) && method.isAnnotationPresent(Cors.class)) {
        logger.error("Resource method " + abstractMethod +
            " is annotated with @Cors, which is not applicable for methods annotated with @OPTIONS");
        return null;
    } else if (!method.isAnnotationPresent(OPTIONS.class) && method.isAnnotationPresent(CorsPreflight.class)) {
        logger.error("Resource method " + abstractMethod +
            " is annotated with @CorsPreflight, which is only applicable for methods annotated with @OPTIONS");
        return null;
    }

    addCorsFilter(method, klass, filters);

    addCorsPreflightFilter(method, klass, filters);

    return filters;
}
 
开发者ID:palominolabs,项目名称:jersey-cors-filter,代码行数:28,代码来源:CorsResourceFilterFactory.java


示例18: compare

import com.sun.jersey.api.model.AbstractResourceMethod; //导入依赖的package包/类
@Override
public int compare(AbstractResourceMethod a, AbstractResourceMethod b) {
	return AlphanumComparatorBase.cmp(a.getHttpMethod(), b.getHttpMethod());
}
 
开发者ID:phoenixctms,项目名称:ctsms,代码行数:5,代码来源:ResourceMethodComparator.java


示例19: create

import com.sun.jersey.api.model.AbstractResourceMethod; //导入依赖的package包/类
@Override
public RequestDispatcher create(AbstractResourceMethod arm) {
    return new ModelRequestDispatcher(wrappedProvider.create(new ResourceMethodWrapper(arm)));
}
 
开发者ID:geetools,项目名称:geeCommerce-Java-Shop-Software-and-PIM,代码行数:5,代码来源:ModelMethodDispatchProvider.java


示例20: ResourceMethodWrapper

import com.sun.jersey.api.model.AbstractResourceMethod; //导入依赖的package包/类
public ResourceMethodWrapper(AbstractResourceMethod abstractResourceMethod) {
    super(abstractResourceMethod.getResource(), abstractResourceMethod.getMethod(),
        abstractResourceMethod.getReturnType(), abstractResourceMethod.getGenericReturnType(),
        abstractResourceMethod.getHttpMethod(), abstractResourceMethod.getAnnotations());
    this.abstractResourceMethod = abstractResourceMethod;
}
 
开发者ID:geetools,项目名称:geeCommerce-Java-Shop-Software-and-PIM,代码行数:7,代码来源:ResourceMethodWrapper.java



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java JavaCodebaseComponentImpl类代码示例发布时间:2022-05-22
下一篇:
Java CGlobal类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap