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


Java ResourceFilter类代码示例

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


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

示例1: create

import com.sun.jersey.spi.container.ResourceFilter; //导入依赖的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.spi.container.ResourceFilter; //导入依赖的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.spi.container.ResourceFilter; //导入依赖的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: addCorsFilter

import com.sun.jersey.spi.container.ResourceFilter; //导入依赖的package包/类
/**
 * Add Cors response filter, if appropriate.
 *
 * @param method  method
 * @param klass   method's class
 * @param filters filter list to add to
 */
private void addCorsFilter(Method method, Class<?> klass, List<ResourceFilter> filters) {
    if (!klass.isAnnotationPresent(Cors.class) && !method.isAnnotationPresent(Cors.class)) {
        return;
    }

    CorsResourceConfig config = getDefaultResourceConfig();

    if (klass.isAnnotationPresent(Cors.class)) {
        if (method.isAnnotationPresent(OPTIONS.class)) {
            // do not add a filter
            return;
        }
        applyCorsAnnotation(config, klass.getAnnotation(Cors.class));
    }

    if (method.isAnnotationPresent(Cors.class)) {
        applyCorsAnnotation(config, method.getAnnotation(Cors.class));
    }

    filters.add(getResourceResponseFilter(config));
}
 
开发者ID:palominolabs,项目名称:jersey-cors-filter,代码行数:29,代码来源:CorsResourceFilterFactory.java

示例5: addCorsPreflightFilter

import com.sun.jersey.spi.container.ResourceFilter; //导入依赖的package包/类
/**
 * Add CorsPreflight response filter, if appropriate.
 *
 * @param method  method
 * @param klass   method's class
 * @param filters filter list to add to
 */
private void addCorsPreflightFilter(Method method, Class<?> klass, List<ResourceFilter> filters) {
    if (!klass.isAnnotationPresent(CorsPreflight.class) && !method.isAnnotationPresent(CorsPreflight.class)) {
        return;
    }

    CorsPreflightConfig config = getDefaultPreflightConfig();

    if (klass.isAnnotationPresent(CorsPreflight.class)) {
        if (!method.isAnnotationPresent(OPTIONS.class)) {
            return;
        }

        applyCorsPreflightAnnotation(config, klass.getAnnotation(CorsPreflight.class));
    }

    if (method.isAnnotationPresent(CorsPreflight.class)) {
        applyCorsPreflightAnnotation(config, method.getAnnotation(CorsPreflight.class));
    }

    filters.add(getPreflightResponseFilter(config));
}
 
开发者ID:palominolabs,项目名称:jersey-cors-filter,代码行数:29,代码来源:CorsResourceFilterFactory.java

示例6: create

import com.sun.jersey.spi.container.ResourceFilter; //导入依赖的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

示例7: create

import com.sun.jersey.spi.container.ResourceFilter; //导入依赖的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

示例8: create

import com.sun.jersey.spi.container.ResourceFilter; //导入依赖的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

示例9: create

import com.sun.jersey.spi.container.ResourceFilter; //导入依赖的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

示例10: create

import com.sun.jersey.spi.container.ResourceFilter; //导入依赖的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

示例11: createEntitySubscriptionFilter

import com.sun.jersey.spi.container.ResourceFilter; //导入依赖的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

示例12: createMasterSubscriptionFilter

import com.sun.jersey.spi.container.ResourceFilter; //导入依赖的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

示例13: create

import com.sun.jersey.spi.container.ResourceFilter; //导入依赖的package包/类
@Override
public List<ResourceFilter> create(AbstractMethod am) {
	List<ResourceFilter> singletonList = Lists.newArrayList();
	singletonList.add(new LoggingResourceFilter());
	singletonList.add(new CacheHeaderFilter());

	if (needsAuthorization(am)) {
		singletonList.add(new AuthenticationResourceFilter());
	}
	return singletonList;
}
 
开发者ID:HuygensING,项目名称:elaborate4-backend,代码行数:12,代码来源:ElaborateResourceFilterFactory.java

示例14: create

import com.sun.jersey.spi.container.ResourceFilter; //导入依赖的package包/类
@Override
public List<ResourceFilter> create(AbstractMethod am) {
    if (am.isAnnotationPresent(
            com.github.autermann.jersey.cache.CacheControl.class)) {
        CacheControl cc = createCacheControl(am.getAnnotation(
                com.github.autermann.jersey.cache.CacheControl.class));
        String value = cc.toString();
        if (!value.isEmpty()) {
            return Collections.<ResourceFilter>singletonList(
                    new CacheControlResourceFilter(value));
        }
    }
    return Collections.emptyList();
}
 
开发者ID:autermann,项目名称:jersey-cache-control,代码行数:15,代码来源:CacheControlFilterFactory.java

示例15: create

import com.sun.jersey.spi.container.ResourceFilter; //导入依赖的package包/类
@Override
public List<ResourceFilter> create(AbstractMethod am) {
	if (am.isAnnotationPresent(Secured.class)) {
		return Collections
				.<ResourceFilter> singletonList(new SecurityResourceFilter());
	}
	return null;
}
 
开发者ID:PE-INTERNATIONAL,项目名称:soda4lca,代码行数:9,代码来源:SecuredResourceFilterFactory.java


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