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

com.maxifier.mxcache.activity.ActivityTracker Maven / Gradle / Ivy

Go to download

Constains all classes necessary for launching a MxCache-instrumentated application

There is a newer version: 2.6.9
Show newest version
/*
 * Copyright (c) 2008-2014 Maxifier Ltd. All Rights Reserved.
 */
package com.maxifier.mxcache.activity;

import gnu.trove.map.hash.THashMap;

import javax.annotation.Nonnull;

import java.util.Map;

/**
 * @author Alexander Kochurov ([email protected])
 */
public final class ActivityTracker {
    private static final Map ACTIVITIES = new THashMap();

//    static {
//        for (ResourceConfig resourceConfig : MxCacheConfig.getInstance().getResources()) {
//            String name = resourceConfig.getName();
//            ACTIVITIES.put(name, new ActivityImpl(name));
//        }
//    }

    private ActivityTracker() {
    }

    /**
     * It is guaranteed that this method will always return the same object for a single id.
     *
     * @param id activity name
     *
     * @return activity with given name
     */
    public static synchronized Activity getActivity(@Nonnull String id) {
        Activity resource = ACTIVITIES.get(id);
        if (resource == null) {
            resource = new ActivityImpl(id);
            ACTIVITIES.put(id, resource);
        }
        return resource;
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy