<commit_before>/*
 * Copyright 2006-2009 Wyona
 *
 *  Licensed under the Apache License, Version 2.0 (the "License");
 *  you may not use this file except in compliance with the License.
 *  You may obtain a copy of the License at
 *
 *      http://www.wyona.org/licenses/APACHE-LICENSE-2.0
 *
 *  Unless required by applicable law or agreed to in writing, software
 *  distributed under the License is distributed on an "AS IS" BASIS,
 *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 *  See the License for the specific language governing permissions and
 *  limitations under the License.
 */

package org.wyona.yanel.core;

import java.io.Reader;
import java.util.Enumeration;

import javax.servlet.http.HttpServletRequest;

import org.apache.log4j.Logger;

import org.wyona.yanel.core.api.ResourceTypeMatcherV1;
import org.wyona.yanel.core.map.Realm;
import org.wyona.yanel.core.util.HttpServletRequestHelper;
import org.wyona.yanel.core.util.PathUtil;

import org.wyona.yarep.core.NoSuchNodeException;

/**
 * Service responsible for instantiating {@link Resource} objects for requests
 * given some initial resource-type-related configuration
 * and some context for the request.
 */
public class ResourceManager {

    private static Logger log = Logger.getLogger(ResourceManager.class);
    
    protected ResourceTypeRegistry rtRegistry;
    private ResourceTypeMatcherV1 resourceTypeMatcher;

    /**
     * Set default resource type registry and resource type matcher
     */
    public ResourceManager() {
        rtRegistry = new ResourceTypeRegistry();
        resourceTypeMatcher = new ResourceTypeDefaultMatcher();
        // TODO: Make resource matcher configurable: resourceTypeMatcher = new ResourceTypeMatcherV1ImplV2();
    }
    
    /**
     * Set resource type registry
     */
    public void setResourceTypeRegistry(ResourceTypeRegistry registry) {
        this.rtRegistry = registry;
    }

    // TODO: getResource(Environment, definition) What about the realm? Do we really need a path? TBD...

    /**
     * Creates a new resource object in the given realm with the given path and the given type.<commit_msg>resource type matcher implementation V2 seems to be stable<commit_after>/*
 * Copyright 2006-2009 Wyona
 *
 *  Licensed under the Apache License, Version 2.0 (the "License");
 *  you may not use this file except in compliance with the License.
 *  You may obtain a copy of the License at
 *
 *      http://www.wyona.org/licenses/APACHE-LICENSE-2.0
 *
 *  Unless required by applicable law or agreed to in writing, software
 *  distributed under the License is distributed on an "AS IS" BASIS,
 *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 *  See the License for the specific language governing permissions and
 *  limitations under the License.
 */

package org.wyona.yanel.core;

import java.io.Reader;
import java.util.Enumeration;

import javax.servlet.http.HttpServletRequest;

import org.apache.log4j.Logger;

import org.wyona.yanel.core.api.ResourceTypeMatcherV1;
import org.wyona.yanel.core.map.Realm;
import org.wyona.yanel.core.util.HttpServletRequestHelper;
import org.wyona.yanel.core.util.PathUtil;

import org.wyona.yarep.core.NoSuchNodeException;

/**
 * Service responsible for instantiating {@link Resource} objects for requests
 * given some initial resource-type-related configuration
 * and some context for the request.
 */
public class ResourceManager {

    private static Logger log = Logger.getLogger(ResourceManager.class);
    
    protected ResourceTypeRegistry rtRegistry;
    private ResourceTypeMatcherV1 resourceTypeMatcher;

    /**
     * Set default resource type registry and resource type matcher
     */
    public ResourceManager() {
        rtRegistry = new ResourceTypeRegistry();

        // TODO: Make resource matcher configurable!
        //resourceTypeMatcher = new ResourceTypeDefaultMatcher();
        resourceTypeMatcher = new ResourceTypeMatcherV1ImplV2();
    }
    
    /**
     * Set resource type registry
     */
    public void setResourceTypeRegistry(ResourceTypeRegistry registry) {
        this.rtRegistry = registry;
    }

    // TODO: getResource(Environment, definition) What about the realm? Do we really need a path? TBD...

    /**
     * Creates a new resource object in the given realm with the given path and the given type.
{'fraction_non_alphanumeric': 0.07832422586520947, 'fraction_numerical': 0.007969034608378871, 'mean_word_length': 3.6048218029350103, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3431722', 'n_tokens_mistral': 1170, 'n_tokens_neox': 1154, 'n_words': 411}