Java Code Examples for org.apache.commons.configuration2.HierarchicalConfiguration#getList()

The following examples show how to use org.apache.commons.configuration2.HierarchicalConfiguration#getList() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: HttpProxyFilter.java    From engine with GNU General Public License v3.0 6 votes vote down vote up
@SuppressWarnings("rawtypes, unchecked")
protected String getTargetUrl(SiteContext siteContext, String requestUri) {
    HierarchicalConfiguration proxyConfig = siteContext.getProxyConfig();

    if (proxyConfig == null) {
        throw new HttpProxyException("No proxy configuration found for site " + siteContext.getSiteName());
    }

    List<HierarchicalConfiguration> servers = proxyConfig.configurationsAt(CONFIG_KEY_SERVERS);
    for (HierarchicalConfiguration server : servers) {
        List<String> patterns = server.getList(String.class, CONFIG_KEY_PATTERNS);
        if (RegexUtils.matchesAny(requestUri, patterns)) {
            logger.debug("Found matching server {} for proxy request {}",
                    server.getString(CONFIG_KEY_ID), requestUri);
            return server.getString(CONFIG_KEY_URL);
        }
    }

    // should never happen (unless there is an issue with the config)
    throw new IllegalStateException("Invalid proxy configuration for site " + siteContext.getSiteName() +
            ", no matching server found for request " + requestUri);
}
 
Example 2
Source File: AbstractContentTypeUpgradeOperation.java    From studio with GNU General Public License v3.0 5 votes vote down vote up
@Override
protected void doInit(final HierarchicalConfiguration<ImmutableNode> config) {
    super.doInit(config);
    includedContentTypes = config.getList(String.class, CONFIG_KEY_CONTENT_TYPES);
    formDefinitionXpath = config.getString(CONFIG_KEY_FORM_DEFINITION);
    int maxCacheItems = config.getInt(CONFIG_KEY_MAX_ITEMS, DEFAULT_MAX_ITEMS);
    cache = CacheBuilder
        .newBuilder()
        .maximumSize(maxCacheItems)
        .build();
}
 
Example 3
Source File: AbstractContentUpgradeOperation.java    From studio with GNU General Public License v3.0 4 votes vote down vote up
@Override
protected void doInit(final HierarchicalConfiguration<ImmutableNode> config) {
    includedPaths = config.getList(String.class, CONFIG_KEY_INCLUDED_PATHS);
}
 
Example 4
Source File: AllHttpScopesAndAppContextHashModel.java    From engine with GNU General Public License v3.0 4 votes vote down vote up
@Override
public TemplateModel get(String key) throws TemplateModelException {
    // Lookup in page scope
    TemplateModel model = super.get(key);
    if (model != null) {
        return model;
    }

    // Lookup in request scope
    Object obj = request.getAttribute(key);
    if (obj != null) {
        return wrap(obj);
    }

    // Lookup in session scope
    HttpSession session = request.getSession(false);
    if (session != null) {
        obj = session.getAttribute(key);
        if (obj != null) {
            return wrap(obj);
        }
    }

    if (disableVariableRestrictions) {
        // Lookup in application scope
        obj = context.getAttribute(key);
        if (obj != null) {
            return wrap(obj);
        }
    }

    HierarchicalConfiguration<?> siteConfig = ConfigUtils.getCurrentConfig();
    List<String> beanPatterns = emptyList();
    if (siteConfig != null) {
        beanPatterns = siteConfig.getList(String.class, CONFIG_KEY_BEAN_PATTERNS, emptyList());
    }

    // Lookup in application context
    if (disableVariableRestrictions || RegexUtils.matchesAny(key, beanPatterns)) {
        try {
            return wrap(applicationContextAccessor.get(key));
        } catch (NoSuchBeanDefinitionException e) {
            // do nothing...
        }
    }

    // return wrapper's null object (probably null).
    return wrap(null);
}
 
Example 5
Source File: CombinedConfigurationBuilder.java    From commons-configuration with Apache License 2.0 3 votes vote down vote up
/**
 * Initializes the list nodes of the node combiner for the given combined
 * configuration. This information can be set in the header section of the
 * configuration definition file for both the override and the union
 * combiners.
 *
 * @param cc the combined configuration to initialize
 * @param defConfig the definition configuration
 * @param key the key for the list nodes
 */
private static void initNodeCombinerListNodes(final CombinedConfiguration cc,
        final HierarchicalConfiguration<?> defConfig, final String key)
{
    final List<Object> listNodes = defConfig.getList(key);
    for (final Object listNode : listNodes)
    {
        cc.getNodeCombiner().addListNode((String) listNode);
    }
}