package org.ehcache.management.providers;
import org.ehcache.core.util.ClassLoading;
import org.ehcache.management.ManagementRegistryServiceConfiguration;
import org.terracotta.management.model.capabilities.descriptors.Descriptor;
import org.terracotta.management.model.context.Context;
import org.terracotta.management.registry.ExposedObject;
import java.util.Collection;
import java.util.Collections;
public abstract class ExposedCacheBinding implements ExposedObject<CacheBinding> {
protected final CacheBinding cacheBinding;
private final Context context;
protected ExposedCacheBinding(ManagementRegistryServiceConfiguration registryConfiguration, CacheBinding cacheBinding) {
this.cacheBinding = cacheBinding;
this.context = registryConfiguration.getContext().with("cacheName", cacheBinding.getAlias());
}
@Override
public final ClassLoader getClassLoader() {
ClassLoader classLoader = cacheBinding.getCache().getRuntimeConfiguration().getClassLoader();
return classLoader == null ? ClassLoading.getDefaultClassLoader() : classLoader;
}
@Override
public final CacheBinding getTarget() {
return cacheBinding;
}
@Override
public Context getContext() {
return context;
}
@Override
public Collection<? extends Descriptor> getDescriptors() {
return Collections.emptyList();
}
}