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


Java AbstractMethod类代码示例

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


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

示例1: create

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

    LinkedList<ResourceFilter> filters = Lists.newLinkedList();

    // Check the resource
    RequiresPermissions permAnnotation = am.getResource().getAnnotation(RequiresPermissions.class);
    if (permAnnotation != null) {
        filters.add(new AuthorizationResourceFilter(ImmutableList.copyOf(permAnnotation.value()), permAnnotation.logical(), createSubstitutionMap(permAnnotation, am)));
    }

    // Check the method
    permAnnotation = am.getAnnotation(RequiresPermissions.class);
    if (permAnnotation != null) {
        filters.add(new AuthorizationResourceFilter(ImmutableList.copyOf(permAnnotation.value()), permAnnotation.logical(), createSubstitutionMap(permAnnotation, am)));
    }

    // If we're doing authorization or if authentication is explicitly requested then add it as the first filter
    if (!filters.isEmpty() ||
            am.getResource().getAnnotation(RequiresAuthentication.class) != null ||
            am.getAnnotation(RequiresAuthentication.class) != null) {
        filters.addFirst(new AuthenticationResourceFilter(_securityManager, _tokenGenerator));
    }

    return filters;
}
 
开发者ID:bazaarvoice,项目名称:emodb,代码行数:27,代码来源:AuthResourceFilterFactory.java

示例2: create

import com.sun.jersey.api.model.AbstractMethod; //导入依赖的package包/类
@Override
public List<ResourceFilter> create(AbstractMethod abstractMethod) {
  
  if (!WebPushServletContextUtils.isConnectionManagerAvailable(_servletContext)) {
    return Collections.emptyList();
  }
  
  List<ResourceFilter> filters = new ArrayList<ResourceFilter>();
  ResourceFilter entityFilter = createEntitySubscriptionFilter(abstractMethod);
  if (entityFilter != null) {
    filters.add(entityFilter);
  }
  ResourceFilter masterFilter = createMasterSubscriptionFilter(abstractMethod);
  if (masterFilter != null) {
    filters.add(masterFilter);
  }
  return filters;
}
 
开发者ID:DevStreet,项目名称:FinanceAnalytics,代码行数:19,代码来源:SubscribingFilterFactory.java

示例3: create

import com.sun.jersey.api.model.AbstractMethod; //导入依赖的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

示例4: create

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

    RightsAllowed check = am.getAnnotation(RightsAllowed.class);
    if (check != null) {
        rolesFilters.add(new RightCheckResourceFilter(check.value(), am.getResource()));
        if (check.value().length == 0 && !check.any()) {
            LOG.warn("Class {} should be specifying any=true in the {} annotation.", am.getResource().getClass().getName(), RightsAllowed.class.getSimpleName());
        }

    } else {
        logNoFilterMessage(am);
    }
    return rolesFilters;

}
 
开发者ID:inbloom,项目名称:secure-data-service,代码行数:18,代码来源:RightCheckFilterFactory.java

示例5: logNoFilterMessage

import com.sun.jersey.api.model.AbstractMethod; //导入依赖的package包/类
private void logNoFilterMessage(AbstractMethod am) {

        Class<?> resourceClass = am.getResource().getResourceClass();

        if (LOG_EXCLUDE_LIST.contains(resourceClass.getName())) {
            return;
        }

        //Don't worry about non-sli classes
        if (!resourceClass.getPackage().getName().startsWith("org.slc.sli")) {
            return;
        }

        //Don't worry about the dynamic endpoints
        if (GenericResource.class.isAssignableFrom(resourceClass)) {
            return;
        }
        LOG.debug("No RightsAllowed specified for {} of {}.",
                am.getMethod().getName(),
                am.getResource().getResourceClass().getName());
    }
 
开发者ID:inbloom,项目名称:secure-data-service,代码行数:22,代码来源:RightCheckFilterFactory.java

示例6: create

import com.sun.jersey.api.model.AbstractMethod; //导入依赖的package包/类
@Override
public List<ResourceFilter> create(AbstractMethod am) {
    String requestSchema = null;
    String responseSchema = null;
    Schema schema = am.getAnnotation(Schema.class);
    if (schema != null) {
        if (!schema.request().isEmpty()) {
            requestSchema = schema.request();
        }
        if (!schema.response().isEmpty()) {
            responseSchema = schema.response();
        }
    }
    if (requestSchema != null || responseSchema != null) {
        JSONSchemaResourceFilter filter =
                new JSONSchemaResourceFilter(requestSchema, responseSchema);
        return Collections.<ResourceFilter>singletonList(filter);
    } else {
        return Collections.emptyList();
    }
}
 
开发者ID:enviroCar,项目名称:enviroCar-server,代码行数:22,代码来源:JSONSchemaResourceFilterFactory.java

示例7: create

import com.sun.jersey.api.model.AbstractMethod; //导入依赖的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

示例8: create

import com.sun.jersey.api.model.AbstractMethod; //导入依赖的package包/类
/**
 * {@inheritDoc}
 */
@Override
public List<ResourceFilter> create(AbstractMethod am) {
    if (am.getAnnotation(WriteAPI.class) != null) {
        // Filter for @WriteAPI annotation.
        return Collections.<ResourceFilter>singletonList(new WriteMethodFilter());
    }
    return null;
}
 
开发者ID:personium,项目名称:personium-core,代码行数:12,代码来源:PersoniumCoreResourceFilterFactory.java

示例9: create

import com.sun.jersey.api.model.AbstractMethod; //导入依赖的package包/类
@Override
public List<ResourceFilter> create(AbstractMethod abstractMethod) {
    List<ResourceFilter> resourceFilters = Lists.newArrayList();
    if (abstractMethod.isAnnotationPresent(ThrottleConcurrentRequests.class)) {
        int maxRequests = abstractMethod.getAnnotation(ThrottleConcurrentRequests.class).maxRequests();
        InstanceConcurrentRequestRegulatorSupplier regulatorSupplier =
                new InstanceConcurrentRequestRegulatorSupplier(
                        new DefaultConcurrentRequestRegulator(SEMAPHORE_PROPERTY, maxRequests, _meter));
        resourceFilters.add(new ConcurrentRequestsThrottlingFilter(regulatorSupplier));
    }
    return resourceFilters;
}
 
开发者ID:bazaarvoice,项目名称:emodb,代码行数:13,代码来源:ThrottlingFilterFactory.java

示例10: createSubstitutionMap

import com.sun.jersey.api.model.AbstractMethod; //导入依赖的package包/类
/**
 * Returns a mapping from permissions found in the annotations to functions which can perform any necessary
 * substitutions based on actual values in the request.
 */
private Map<String,Function<HttpRequestContext, String>> createSubstitutionMap(String[] permissions, AbstractMethod am) {
    Map<String, Function<HttpRequestContext, String>> map = Maps.newLinkedHashMap();

    for (String permission : permissions) {
        Matcher matcher = SUBSTITUTION_MATCHER.matcher(permission);
        while (matcher.find()) {
            String match = matcher.group();
            if (map.containsKey(match)) {
                continue;
            }

            String param = matcher.group("param");
            Function<HttpRequestContext, String> substitution;

            if (param.startsWith("?")) {
                substitution = createQuerySubstitution(param.substring(1));
            } else {
                substitution = createPathSubstitution(param, am);
            }

            map.put(match, substitution);
        }
    }

    return map;
}
 
开发者ID:bazaarvoice,项目名称:emodb,代码行数:31,代码来源:AuthResourceFilterFactory.java

示例11: createPathSubstitution

import com.sun.jersey.api.model.AbstractMethod; //导入依赖的package包/类
/**
 * Creates a substitution function for path values, such as
 * <code>@RequiresPermission("resource|update|{id}")</code>
 */
private Function<HttpRequestContext, String> createPathSubstitution(final String param, final AbstractMethod am) {
    int from = 0;
    int segment = -1;

    // Get the path from resource then from the method
    Path[] annotations = new Path[] { am.getResource().getAnnotation(Path.class), am.getAnnotation(Path.class) };

    for (Path annotation : annotations) {
        if (annotation == null)  {
            continue;
        }

        int index = getSubstitutionIndex(param, annotation.value());
        if (index >= 0) {
            segment = from + index;
        } else {
            from += -index;
        }
    }

    if (segment == -1) {
        throw new IllegalArgumentException("Param not found in path: " + param);
    }

    final int validatedSegment = segment;

    return new Function<HttpRequestContext, String>() {
        @Override
        public String apply(HttpRequestContext request) {
            return request.getPathSegments().get(validatedSegment).getPath();
        }
    };
}
 
开发者ID:bazaarvoice,项目名称:emodb,代码行数:38,代码来源:AuthResourceFilterFactory.java

示例12: createEntitySubscriptionFilter

import com.sun.jersey.api.model.AbstractMethod; //导入依赖的package包/类
/**
 * Creates a filter that creates a subscription for an entity when the method is invoked.  The method must have a
 * parameter annotated with {@link Subscribe} and {@link PathParam} which is a string that can be parsed by
 * {@link UniqueId#parse(String)}.  A notification is sent when the object with the specified {@link UniqueId}
 * changes.
 * @param abstractMethod A Jersey REST method
 * @return A filter to set up subscriptions when the method is invoked or null if the method doesn't
 * need entity subscriptions
 */
private ResourceFilter createEntitySubscriptionFilter(AbstractMethod abstractMethod) {
  Method method = abstractMethod.getMethod();
  Annotation[][] annotations = method.getParameterAnnotations();
  List<String> uidParamNames = new ArrayList<String>();
  // find params annotated with @Subscribe.  must also have @PathParam
  for (Annotation[] paramAnnotations : annotations) {
    boolean subscribe = false;
    String paramName = null;
    for (Annotation annotation : paramAnnotations) {
      if (annotation instanceof Subscribe) {
        subscribe = true;
      } else if (annotation instanceof PathParam) {
        paramName = ((PathParam) annotation).value();
      }
    }
    if (subscribe) {
      if (paramName != null) {
        uidParamNames.add(paramName);
      } else {
        s_logger.warn("@Subscribe annotation found without matching @PathParam on method {}.{}(), no subscription " +
                          "will be created", method.getDeclaringClass().getSimpleName(), method.getName());
      }
    }
  }
  if (!uidParamNames.isEmpty()) {
    s_logger.debug("Creating subscribing filter for parameters {} on method {}.{}()",
                   new Object[]{uidParamNames, method.getDeclaringClass().getSimpleName(), method.getName()});
    return new EntitySubscriptionFilter(uidParamNames, getUpdateManager(), _httpContext, _servletRequest);
  } else {
    return null;
  }
}
 
开发者ID:DevStreet,项目名称:FinanceAnalytics,代码行数:42,代码来源:SubscribingFilterFactory.java

示例13: createMasterSubscriptionFilter

import com.sun.jersey.api.model.AbstractMethod; //导入依赖的package包/类
/**
 * Creates a filter that creates a subscription for a master when the method is invoked.  The method must be
 * annotated with {@link SubscribeMaster}.  A notification is sent when any data in the master changes.
 * @param abstractMethod A Jersey REST method
 * @return A filter to set up subscriptions when the method is invoked or null if the method doesn't
 * need master subscriptions
 */
private ResourceFilter createMasterSubscriptionFilter(AbstractMethod abstractMethod) {
  SubscribeMaster annotation = abstractMethod.getAnnotation(SubscribeMaster.class);
  if (annotation != null) {
    MasterType[] masterTypes = annotation.value();
    if (masterTypes.length > 0) {
      return new MasterSubscriptionFilter(getUpdateManager(), Arrays.asList(masterTypes), _httpContext, _servletRequest);
    } else {
      s_logger.warn("@SubscribeMaster annotation found on {}.{}() with no masters specified",
                    abstractMethod.getMethod().getDeclaringClass().getSimpleName(),
                    abstractMethod.getMethod().getName());
    }
  }
  return null;
}
 
开发者ID:DevStreet,项目名称:FinanceAnalytics,代码行数:22,代码来源:SubscribingFilterFactory.java

示例14: create

import com.sun.jersey.api.model.AbstractMethod; //导入依赖的package包/类
@Override
public List<ResourceFilter> create(AbstractMethod am) {
    List<ResourceFilter> response = null;
    boolean hasLimiterAnnotation = am.isAnnotationPresent(Limiter.class);

    if (hasLimiterAnnotation) {
        Limiter annotation = am.getAnnotation(Limiter.class);
        long requests = annotation.requests();
        response = Collections.<ResourceFilter>singletonList(new RateLimitFilter(requests, am.getMethod().getName()));
    }
    return response;
}
 
开发者ID:rridgley1,项目名称:agon,代码行数:13,代码来源:RateLimiterResourceFilterFactory.java

示例15: create

import com.sun.jersey.api.model.AbstractMethod; //导入依赖的package包/类
@Override
public List<ResourceFilter> create(AbstractMethod am) {
    List<ResourceFilter> response = null;
    boolean hasApiVersionAnnotation = am.isAnnotationPresent(ApiVersion.class);
    if (hasApiVersionAnnotation) {
        ApiVersion annotation = am.getAnnotation(ApiVersion.class);
        boolean headerRequired = annotation.headerRequired();
        float minVersion = annotation.minVersion();
        float maxVersion = annotation.maxVersion();
        response = Collections.<ResourceFilter>singletonList(new VersionFilter(headerRequired, minVersion, maxVersion));
    }
    return response;
}
 
开发者ID:rridgley1,项目名称:agon,代码行数:14,代码来源:ApiVersionResourceFilterFactory.java


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