<commit_before>package com.aconex.monitoring;

import java.util.Collection;
import java.util.Collections;
import java.util.Map;
import java.util.TreeMap;

import com.aconex.utilities.Assert;

public class MonitorableRegistry {
	public static final MonitorableRegistry DEFAULT_REGISTRY = new MonitorableRegistry();
	
    /**
     * This is a TreeMap so that the monitorables a maintained in alphabetical order.
     */
    private final Map<String, Monitorable<?>> monitorables = new TreeMap<String, Monitorable<?>>();

    private boolean isMonitorBridgeStarted = false;

    public synchronized <T> void register(Monitorable<T> monitorable) {
        if (isMonitorBridgeStarted) {
            throw new IllegalStateException("Cannot register monitorable " + monitorable.getName()
                    + " after MonitorBridge has been started");
        }
        if (monitorables.containsKey(monitorable.getName())) {
            throw new UnsupportedOperationException(
                    "There is already an instance of the Monitorable [" + monitorable.getName()
                            + "] registered.");
        }
        monitorables.put(monitorable.getName(), monitorable);
    }

    /**
     * Useful only in Unit tests
     */
    public void shutdown() {
        if (isMonitorBridgeStarted) {
            isMonitorBridgeStarted = false;
        }
        /*
         * We clear this anyway, because unit tests may have registered Monitorables even though the Registry
         * is not started.  Without this, subsequent unit tests might fail when they try to register the Monitorable again.
         */
        monitorables.clear();

    }

    public synchronized Collection<Monitorable<?>> getMonitorables() {
        Assert.isFalse(isMonitorBridgeStarted, "PCP Monitor Bridge should have not been started!");
        isMonitorBridgeStarted = true;
        return Collections.unmodifiableCollection(monitorables.values());
    }
}<commit_msg>Removed shutdown concept as it's no longer useful now the singleton nature is gone<commit_after>package com.aconex.monitoring;

import java.util.Collection;
import java.util.Collections;
import java.util.Map;
import java.util.TreeMap;

import com.aconex.utilities.Assert;

public class MonitorableRegistry {
	public static final MonitorableRegistry DEFAULT_REGISTRY = new MonitorableRegistry();
	
    /**
     * This is a TreeMap so that the monitorables a maintained in alphabetical order.
     */
    private final Map<String, Monitorable<?>> monitorables = new TreeMap<String, Monitorable<?>>();

    private boolean isMonitorBridgeStarted = false;

    public synchronized <T> void register(Monitorable<T> monitorable) {
        if (isMonitorBridgeStarted) {
            throw new IllegalStateException("Cannot register monitorable " + monitorable.getName()
                    + " after MonitorBridge has been started");
        }
        if (monitorables.containsKey(monitorable.getName())) {
            throw new UnsupportedOperationException(
                    "There is already an instance of the Monitorable [" + monitorable.getName()
                            + "] registered.");
        }
        monitorables.put(monitorable.getName(), monitorable);
    }

    public synchronized Collection<Monitorable<?>> getMonitorables() {
        Assert.isFalse(isMonitorBridgeStarted, "PCP Monitor Bridge should have not been started!");
        isMonitorBridgeStarted = true;
        return Collections.unmodifiableCollection(monitorables.values());
    }
}
{'fraction_non_alphanumeric': 0.0858843537414966, 'fraction_numerical': 0.0, 'mean_word_length': 3.0056753688989786, 'pattern_counts': {'":': 0, '<': 19, '<?xml version=': 0, '>': 19, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, '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': '4152070', 'n_tokens_mistral': 885, 'n_tokens_neox': 846, 'n_words': 259}