All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.jamonapi.FactoryDisabled Maven / Gradle / Ivy

There is a newer version: 2.82
Show newest version
package com.jamonapi;

import com.jamonapi.utils.SerializationUtils;

import java.util.Collections;
import java.util.Iterator;
import java.util.List;
import java.util.Map;

/**
 * Factory that returns null monitors when JAMon is disabled.  Method are noops.
 * Any methods that return Monitors return NullMonitors (noop monitors).
 */

public final class FactoryDisabled implements MonitorFactoryInterface {
    private static final long serialVersionUID = 279L;

    private Monitor nullMon=new NullMonitor();
    private MonitorComposite compositeMon=new MonitorComposite();
    private MonitorFactoryInterface factoryEnabled;

    /** Creates a new instance of FactoryDisabled */
    public FactoryDisabled(MonitorFactoryInterface factoryEnabled) {
        this.factoryEnabled=factoryEnabled;
    }

    public Monitor add(MonKey key, double value) {
        return nullMon;
    }

    public Monitor add(String label, String units, double value) {
        return nullMon;
    }

    public Monitor start() {
        return nullMon;
    }

    public Monitor start(MonKey key) {
        return nullMon;
    }

    public Monitor start(String label) {
        return nullMon;
    }

    public Monitor startNano(String label) {
        return nullMon;
    }

    public Monitor startNano(MonKey key) {
        return nullMon;
    }
    public Monitor startPrimary(MonKey key) {
        return nullMon;
    }

    public Monitor startPrimary(String label) {
        return nullMon;
    }

    public Monitor getMonitor(MonKey key) {
        return nullMon;
    }

    public Monitor getMonitor(String label, String units) {
        return nullMon;
    }

    public Monitor getTimeMonitor(MonKey key) {
        return nullMon;
    }

    @Override
    public Monitor addException(Monitor mon, Throwable throwable) {
        return nullMon;
    }

    @Override
    public Monitor addException(Throwable throwable) {
        return nullMon;
    }

    public Monitor getTimeMonitor(String label) {
        return nullMon;
    }

    public void remove(MonKey key) {
    }

    public void remove(String label, String units) {
    }

    public boolean exists(MonKey key) {
        return false;
    }
    public boolean exists(String label, String units) {
        return false;
    }

    public MonitorComposite getComposite(String units) {
        return compositeMon;
    }

    public MonitorComposite getRootMonitor() {
        return compositeMon;
    }

    public int getNumRows() {
        return 0;
    }

    public String[] getRangeHeader() {
        return factoryEnabled.getRangeHeader();
    }

    public Object[][] getRangeNames() {
        return factoryEnabled.getRangeNames();
    }

    public String getVersion() {
        return VERSION;
    }

    public void setMap(java.util.Map map) {
    }

    public void setRangeDefault(String key, RangeHolder rangeHolder) {
    }

    public void reset() {
    }

    public void enableGlobalActive(boolean enable) {
    }

    public boolean isGlobalActiveEnabled() {
        return false;
    }

    public Monitor getMonitor() {
        return nullMon;
    }

    public Iterator iterator() {
        return Collections.EMPTY_LIST.iterator();
    }

    public Map getMap() {
        return Collections.EMPTY_MAP;
    }

    public void enableActivityTracking(boolean enable) {
    }

    public boolean isActivityTrackingEnabled() {
        return false;
    }

    public int getMaxNumMonitors() {
        return 0;
    }

    public void setMaxNumMonitors(int maxMonitors) {
    }

    public void enableTotalKeySizeTracking() {
    }

    public void disableTotalKeySizeTracking() {
    }

    public long getTotalKeySize() {
        return 0;
    }

    public boolean isTotalKeySizeTrackingEnabled() {
        return false;
    }

    public int getMaxSqlSize() {
        return 0;
    }

    @Override
    public void addListeners(List listeners) {

    }

    public void setMaxSqlSize(int size) {

    }

    @Override
    public FactoryDisabled copy() {
        return SerializationUtils.deepCopy(this);
    }

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy