本文整理汇总了Java中com.sun.jersey.api.model.AbstractResourceMethod类的典型用法代码示例。如果您正苦于以下问题:Java AbstractResourceMethod类的具体用法?Java AbstractResourceMethod怎么用?Java AbstractResourceMethod使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
AbstractResourceMethod类属于com.sun.jersey.api.model包,在下文中一共展示了AbstractResourceMethod类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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;
}
}
示例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;
}
示例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();
}
}
};
}
示例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;
}
示例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;
}
示例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;
}
示例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));
}
示例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));
}
示例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));
}
示例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;
}
示例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));
}
示例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));
}