获取真正的过滤器列表

@param config            provider配置或者consumer配置
@param autoActiveFilters 系统自动激活的过滤器映射
@return 真正的过滤器列表
183813
private static List<Filter> selectActualFilters(AbstractInterfaceConfig config,
                                                    Map<String, ExtensionClass<Filter>> autoActiveFilters) {
        /*
         * 例如自动装载扩展 A(a),B(b),C(c)  filter=[-a,d]  filterRef=[new E, new Exclude(b)]
         * 逻辑如下：
         * 1.解析config.getFilterRef()，记录E和-b
         * 2.解析config.getFilter()字符串，记录 d 和 -a,-b
         * 3.再解析自动装载扩展，a,b被排除了，所以拿到c,d
         * 4.对c d进行排序
         * 5.拿到C、D实现类
         * 6.加上自定义，返回C、D、E
         */
        // 用户通过自己new实例的方式注入的filter，优先级高
        List<Filter> customFilters = config.getFilterRef() == null ?
            new ArrayList<Filter>() : new CopyOnWriteArrayList<Filter>(config.getFilterRef());
        // 先解析是否有特殊处理
        HashSet<String> excludes = parseExcludeFilter(customFilters);

        // 准备数据：用户通过别名的方式注入的filter，需要解析
        List<ExtensionClass<Filter>> extensionFilters = new ArrayList<ExtensionClass<Filter>>();
        List<String> filterAliases = config.getFilter(); //
        if (CommonUtils.isNotEmpty(filterAliases)) {
            for (String filterAlias : filterAliases) {
                if (startsWithExcludePrefix(filterAlias)) { // 排除用的特殊字符
                    excludes.add(filterAlias.substring(1));
                } else {
                    ExtensionClass<Filter> filter = EXTENSION_LOADER.getExtensionClass(filterAlias);
                    if (filter != null) {
                        extensionFilters.add(filter);
                    }
                }
            }
        }
        // 解析自动加载的过滤器
        if (!excludes.contains(StringUtils.ALL) && !excludes.contains(StringUtils.DEFAULT)) { // 配了-*和-default表示不加载内置
            for (Map.Entry<String, ExtensionClass<Filter>> entry : autoActiveFilters.entrySet()) {
                if (!excludes.contains(entry.getKey())) {
                    extensionFilters.add(entry.getValue());
                }
            }
        }
        // 按order从小到大排序
        if (extensionFilters.size() > 1) {
            Collections.sort(extensionFilters, new OrderedComparator<ExtensionClass<Filter>>());
        }
        List<Filter> actualFilters = new ArrayList<Filter>();
        for (ExtensionClass<Filter> extensionFilter : extensionFilters) {
            actualFilters.add(extensionFilter.getExtInstance());
        }
        // 加入自定义的过滤器
        actualFilters.addAll(customFilters);
        return actualFilters;
    }
121618
public void doRuntimeConfiguration(RuntimeSpringConfiguration springConfig) {
        ApplicationContext context = springConfig.getUnrefreshedApplicationContext();
        AutowireCapableBeanFactory autowireCapableBeanFactory = context.getAutowireCapableBeanFactory();
        if(autowireCapableBeanFactory instanceof ConfigurableListableBeanFactory) {
            ConfigurableListableBeanFactory beanFactory = (ConfigurableListableBeanFactory)autowireCapableBeanFactory;
            ConversionService existingConversionService = beanFactory.getConversionService();
            ConverterRegistry converterRegistry;
            if(existingConversionService == null) {
                GenericConversionService conversionService = new GenericConversionService();
                converterRegistry = conversionService;
                beanFactory.setConversionService(conversionService);
            }
            else {
                converterRegistry = (ConverterRegistry)existingConversionService;
            }

            converterRegistry.addConverter(new Converter<NavigableMap.NullSafeNavigator, Object>() {
                @Override
                public Object convert(NavigableMap.NullSafeNavigator source) {
                    return null;
                }
            });
        }
        checkInitialised();
        for (GrailsPlugin plugin : pluginList) {
            if (plugin.supportsCurrentScopeAndEnvironment() && plugin.isEnabled(context.getEnvironment().getActiveProfiles())) {
                plugin.doWithRuntimeConfiguration(springConfig);
            }
        }
    }
682141
private AuthConfigProvider getAuthConfigProvider(String appContext) {
        AuthConfigProvider provider = null;
        AuthConfigFactory providerFactory = getAuthConfigFactory();
        if (providerFactory != null) {
            if (providerConfigModified &&
                providerFactory instanceof ProviderRegistry) {
                ((ProviderRegistry) providerFactory).setProvider(jaspiProviderServiceRef.getService());
                providerConfigModified = false;
            }
            provider = providerFactory.getConfigProvider("HttpServlet", appContext, (RegistrationListener) null);
        }
        return provider;
    }
1282282
public AuthConfigProvider setProvider(ProviderService providerService) {
        AuthConfigProvider authConfigProvider = null;
        if (providerService != null) {
            authConfigProvider = providerService.getAuthConfigProvider(this);
            registerConfigProvider(authConfigProvider, null, null, null);
        } else {
            removeRegistration(defaultRegistrationID.toString());
        }
        return authConfigProvider;
    }
622049
public Properties consumerConfig(boolean enableAutoCommit) {
        Properties props = new Properties();
        props.put("bootstrap.servers", connectionString());
        props.put("group.id", "kafka-junit-consumer");
        props.put("enable.auto.commit", String.valueOf(enableAutoCommit));
        props.put("auto.commit.interval.ms", "100");
        props.put("auto.offset.reset", "earliest");
        props.put("heartbeat.interval.ms", "100");
        props.put("session.timeout.ms", "200");
        props.put("fetch.max.wait.ms", "500");
        props.put("metadata.max.age.ms", "100");
        return props;
    }
310262
private void initAttrs(FilterConfig config){

        String param  = config.getInitParameter(SESSION_COOKIE_NAME);
        sessionCookieName = Strings.isNullOrEmpty(param) ? DEFAULT_SESSION_COOKIE_NAME : param;

        param = config.getInitParameter(MAX_INACTIVE_INTERVAL);
        maxInactiveInterval = Strings.isNullOrEmpty(param) ? DEFAULT_MAX_INACTIVE_INTERVAL : Integer.parseInt(param);

        cookieDomain = config.getInitParameter(COOKIE_DOMAIN);

        param = config.getInitParameter(COOKIE_CONTEXT_PATH);
        cookieContextPath = Strings.isNullOrEmpty(param) ? DEFAULT_COOKIE_CONTEXT_PATH : param;

        param = config.getInitParameter(COOKIE_MAX_AGE);
        cookieMaxAge = Strings.isNullOrEmpty(param) ? DEFAULT_COOKIE_MAX_AGE : Integer.parseInt(param);

        log.info("SessionFilter (sessionCookieName={},maxInactiveInterval={},cookieDomain={})", sessionCookieName, maxInactiveInterval, cookieDomain);
    }
520648
public static InstanceConfig newDefaultInstanceConfig(BackupProvider provider)
    {
        List<EncodedConfigParser.FieldValue>    backupDefaultValues = Lists.newArrayList();
        if ( provider != null )
        {
            for ( BackupConfigSpec spec : provider.getConfigs() )
            {
                backupDefaultValues.add(new EncodedConfigParser.FieldValue(spec.getKey(), spec.getDefaultValue()));
            }
        }
        final String                    backupExtraValue = new EncodedConfigParser(backupDefaultValues).toEncoded();

        return new InstanceConfig()
        {
            @Override
            public String getString(StringConfigs config)
            {
                switch ( config )
                {
                    case ZOO_CFG_EXTRA:
                    {
                        return "syncLimit=5&tickTime=2000&initLimit=10";
                    }

                    case BACKUP_EXTRA:
                    {
                        return backupExtraValue;
                    }
                }
                return "";
            }

            @Override
            public int getInt(IntConfigs config)
            {
                switch ( config )
                {
                    case CLIENT_PORT:
                    {
                        return 2181;
                    }

                    case CONNECT_PORT:
                    {
                        return 2888;
                    }

                    case ELECTION_PORT:
                    {
                        return 3888;
                    }

                    case CHECK_MS:
                    {
                        return (int)TimeUnit.MILLISECONDS.convert(30, TimeUnit.SECONDS);
                    }

                    case CLEANUP_PERIOD_MS:
                    {
                        return (int)TimeUnit.MILLISECONDS.convert(12, TimeUnit.HOURS);
                    }

                    case CLEANUP_MAX_FILES:
                    {
                        return 3;
                    }

                    case BACKUP_PERIOD_MS:
                    {
                        return (int)TimeUnit.MILLISECONDS.convert(1, TimeUnit.MINUTES);
                    }

                    case BACKUP_MAX_STORE_MS:
                    {
                        return (int)TimeUnit.MILLISECONDS.convert(1, TimeUnit.DAYS);
                    }

                    case AUTO_MANAGE_INSTANCES_SETTLING_PERIOD_MS:
                    {
                        return (int)TimeUnit.MILLISECONDS.convert(3, TimeUnit.MINUTES);
                    }

                    case OBSERVER_THRESHOLD:
                    {
                        return 999;
                    }

                    case AUTO_MANAGE_INSTANCES_APPLY_ALL_AT_ONCE:
                    {
                        return 1;
                    }

                }
                return 0;
            }
        };
    }
486714
@Override
    public Filter createFilter(FilterConfig filterConfig) {
        Binding binding = new Binding();
        SecurityComponents sc = this.createSecurityComponents();
        binding.setVariable("securityComponents", sc);
        binding.setVariable("securityRealm",this);
        BeanBuilder builder = new BeanBuilder();
        builder.parse(filterConfig.getServletContext().getResourceAsStream("/WEB-INF/security/SecurityFilters.groovy"),binding);
        
        WebApplicationContext context = builder.createApplicationContext();
        
        return (Filter) context.getBean("legacy");
    }
1188107
static FilterMetadata getFilterMetadata(HttpSupportFilter filter){
        FilterMetadata config = filterMetadataMap.get(filter);
        if(config == null){
            config = new FilterMetadata();
            filterMetadataMap.put(filter, config);
        }
        return config;
    }
1150191
public static Collection<GobblinInstancePluginFactory> instantiatePluginsFromSysConfig(Config config)
      throws ClassNotFoundException, InstantiationException, IllegalAccessException {
    String pluginsStr = config.getString(PLUGINS_KEY);
    List<GobblinInstancePluginFactory> plugins = Lists.newArrayList();
    for (String pluginName : Splitter.on(",").split(pluginsStr)) {
      plugins.add(instantiatePluginByAlias(pluginName));
    }
    return plugins;
  }
336823
private static void autowareStaticConfig(Class<?> cls, Properties prop) throws Exception {

        if (null == prop) {
            throw new Exception("cannot autowareConfig null");
        }

        try {

            Field[] fields = cls.getDeclaredFields();

            for (Field field : fields) {

                if (field.isAnnotationPresent(DisconfFileItem.class)) {

                    if (!Modifier.isStatic(field.getModifiers())) {
                        continue;
                    }

                    field.setAccessible(true);

                    String name = field.getName();
                    Object value = prop.getProperty(name, null);
                    if (value != null) {
                        ClassUtils.setFieldValeByType(field, null, String.valueOf(value));
                    }
                }
            }
        } catch (Exception e) {

            throw new Exception("error while autowire config file", e);
        }
    }
545401
public static autoscaleaction[] get_filtered(nitro_service service, String filter) throws Exception{
		autoscaleaction obj = new autoscaleaction();
		options option = new options();
		option.set_filter(filter);
		autoscaleaction[] response = (autoscaleaction[]) obj.getfiltered(service, option);
		return response;
	}
145080
public List<ServerMonitoringStatistics> getMonitoringStats(Group group, ServerMonitoringFilter config) {
        checkNotNull(config, "Config must be not a null");
        return client.getMonitoringStatistics(
            idByRef(group),
            converter.createMonitoringStatisticRequest(config));
    }
333282
public static int[] getConfigArr(VarSet vars, VarConfig config) {        
        IntArrayList a = new IntArrayList(config.getVars().calcNumConfigs());
        IntIter iter = getConfigIter(vars, config);
        while (iter.hasNext()) {
            a.add(iter.next());
        }
        return a.toNativeArray();
    }
169832
public OperationFuture<List<Network>> update(NetworkFilter filter, UpdateNetworkConfig config) {
        checkFilter(filter);

        List<Network> networkList = findLazy(filter)
            .map(metadata -> Network.refById(metadata.getId()))
            .collect(toList());

        return update(networkList, config);
    }
1061015
public Class<? extends AccessTokenProvider> getAccessTokenProviderClass(Configuration config) {
    return config.getClass(
        configPrefix + ACCESS_TOKEN_PROVIDER_IMPL_SUFFIX, null, AccessTokenProvider.class);
  }
244591
public static JvmType filterActiveProcessorType(JvmType type, CommonTypeComputationServices services) {
		if (AccessorsProcessor.class.getName().equals(type.getQualifiedName())) {
			return services.getTypeReferences().findDeclaredType(SarlAccessorsProcessor.class, type);
		}
		return type;
	}