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

com.sap.cloud.mt.subscription.TenantMutexFactory Maven / Gradle / Ivy

There is a newer version: 3.3.1
Show newest version
/*******************************************************************************
 *   © 2019-2024 SAP SE or an SAP affiliate company. All rights reserved.
 ******************************************************************************/

package com.sap.cloud.mt.subscription;

import java.util.concurrent.ConcurrentHashMap;

public class TenantMutexFactory {
	private static final ConcurrentHashMap tenantToMutex = new ConcurrentHashMap<>();

	private TenantMutexFactory() {
	}

	public static TenantMutex get(String tenantId) {
		TenantMutex mutex = tenantToMutex.get(tenantId);
		if (mutex != null) {
			return mutex;
		}
		TenantMutex newMutex = new TenantMutex();
		TenantMutex storedMutex = tenantToMutex.putIfAbsent(tenantId, newMutex);
		if (storedMutex != null) {
			return storedMutex;
		} else {
			return newMutex;
		}
	}
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy