<commit_before>// ========================================================================
// Copyright (c) Webtide LLC
// ------------------------------------------------------------------------
// All rights reserved. This program and the accompanying materials
// are made available under the terms of the Eclipse Public License v1.0
// and Apache License v2.0 which accompanies this distribution.
//
// The Eclipse Public License is available at 
// http://www.eclipse.org/legal/epl-v10.html
//
// The Apache License v2.0 is available at
// http://www.apache.org/licenses/LICENSE-2.0.txt
//
// You may elect to redistribute this code under either of these licenses. 
// ========================================================================
package org.eclipse.jetty.deploy.providers;

import java.io.File;
import java.io.FilenameFilter;
import java.util.Collections;
import java.util.HashMap;
import java.util.Map;

import org.eclipse.jetty.deploy.App;
import org.eclipse.jetty.deploy.AppProvider;
import org.eclipse.jetty.deploy.DeploymentManager;
import org.eclipse.jetty.util.Scanner;
import org.eclipse.jetty.util.component.AbstractLifeCycle;
import org.eclipse.jetty.util.log.Log;
import org.eclipse.jetty.util.resource.Resource;

/**
 * Abstract for AppProviders that monitor context files. The context file
 * enables adminsitrators to customize the configuration of a WebAppContext or a
 * ContextHandler without chaging files inside the packaged application.
 * <p>
 * When the context file is changed, the corresponding application is
 * redeployed.
 * </p>
 */
public abstract class ScanningAppProvider extends AbstractLifeCycle implements AppProvider
{
    private Map<String, App> _appMap = new HashMap<String, App>();

    private DeploymentManager _deploymentManager;
    protected final FilenameFilter _filenameFilter;
    private Resource _monitoredDir;
    private boolean _recursive = false;
    private int _scanInterval = 10;
    private Scanner _scanner;
    
    private final Scanner.DiscreteListener _scannerListener = new Scanner.DiscreteListener()
    {
        public void fileAdded(String filename) throws Exception
        {
            Log.debug("added ",filename);
            App app = ScanningAppProvider.this.createApp(filename);
            if (app != null)
            {
                _appMap.put(filename,app);
                _deploymentManager.addApp(app);
            }
        }

        public void fileChanged(String filename) throws Exception
        {
            Log.debug("changed ",filename);
            App app = _appMap.remove(filename);
            app = ScanningAppProvider.this.createApp(filename);
            if (app != null)
            {
                _appMap.put(filename,app);
                _deploymentManager.addApp(app);
            }
        }<commit_msg>fix trivial mistake that was breaking the hot-redeploy of contexts.<commit_after>// ========================================================================
// Copyright (c) Webtide LLC
// ------------------------------------------------------------------------
// All rights reserved. This program and the accompanying materials
// are made available under the terms of the Eclipse Public License v1.0
// and Apache License v2.0 which accompanies this distribution.
//
// The Eclipse Public License is available at 
// http://www.eclipse.org/legal/epl-v10.html
//
// The Apache License v2.0 is available at
// http://www.apache.org/licenses/LICENSE-2.0.txt
//
// You may elect to redistribute this code under either of these licenses. 
// ========================================================================
package org.eclipse.jetty.deploy.providers;

import java.io.File;
import java.io.FilenameFilter;
import java.util.Collections;
import java.util.HashMap;
import java.util.Map;

import org.eclipse.jetty.deploy.App;
import org.eclipse.jetty.deploy.AppProvider;
import org.eclipse.jetty.deploy.DeploymentManager;
import org.eclipse.jetty.util.Scanner;
import org.eclipse.jetty.util.component.AbstractLifeCycle;
import org.eclipse.jetty.util.log.Log;
import org.eclipse.jetty.util.resource.Resource;

/**
 * Abstract for AppProviders that monitor context files. The context file
 * enables adminsitrators to customize the configuration of a WebAppContext or a
 * ContextHandler without chaging files inside the packaged application.
 * <p>
 * When the context file is changed, the corresponding application is
 * redeployed.
 * </p>
 */
public abstract class ScanningAppProvider extends AbstractLifeCycle implements AppProvider
{
    private Map<String, App> _appMap = new HashMap<String, App>();

    private DeploymentManager _deploymentManager;
    protected final FilenameFilter _filenameFilter;
    private Resource _monitoredDir;
    private boolean _recursive = false;
    private int _scanInterval = 10;
    private Scanner _scanner;
    
    private final Scanner.DiscreteListener _scannerListener = new Scanner.DiscreteListener()
    {
        public void fileAdded(String filename) throws Exception
        {
            Log.debug("added ",filename);
            App app = ScanningAppProvider.this.createApp(filename);
            if (app != null)
            {
                _appMap.put(filename,app);
                _deploymentManager.addApp(app);
            }
        }

        public void fileChanged(String filename) throws Exception
        {
            Log.debug("changed ",filename);
            App app = _appMap.remove(filename);
            if (app != null)
            {
                _deploymentManager.removeApp(app);
            }
            app = ScanningAppProvider.this.createApp(filename);
            if (app != null)
            {
                _appMap.put(filename,app);
                _deploymentManager.addApp(app);
            }
        }
{'fraction_non_alphanumeric': 0.1561963611397185, 'fraction_numerical': 0.004119464469618949, 'mean_word_length': 2.7593548387096773, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 11, 'https://': 0, 'lorem ipsum': 0, 'www.': 4, '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': '5400113', 'n_tokens_mistral': 1496, 'n_tokens_neox': 1435, 'n_words': 425}