com.remondis.limbus.monitoring.Client Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of limbus-monitoring Show documentation
Show all versions of limbus-monitoring Show documentation
API to create and process monitoring information using extendable interfaces for consumers and producers.
The newest version!
package com.remondis.limbus.monitoring;
import static com.remondis.limbus.monitoring.ProxyUtils.createRecordCallProxy;
import static com.remondis.limbus.monitoring.ProxyUtils.noopProxy;
import java.util.concurrent.ConcurrentHashMap;
/**
* The client is the implementation of the {@link Monitoring} interface and is
* the object that will be passed to classes that request a monitoring.
*
* @author schuettec
*
*/
class Client implements Monitoring {
private ConcurrentHashMap, Object> cache = new ConcurrentHashMap<>();
private String name;
public Client(String name) {
this.name = name;
}
@Override
public P publish(Class
publisher) {
if (MonitoringFactory.perform()) {
return cachedPublisher(publisher);
} else {
return noopProxy(publisher);
}
}
protected
P cachedPublisher(Class
publisher) {
Object object = cache.get(publisher);
if (object == null) {
synchronized (cache) {
object = createRecordCallProxy(name, publisher);
cache.put(publisher, object);
}
}
return publisher.cast(object);
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy