use of org.jboss.as.clustering.infinispan.DefaultCacheContainer in project wildfly by wildfly.
the class CacheContainerBuilder method build.
@Override
public ServiceBuilder<CacheContainer> build(ServiceTarget target) {
Function<EmbeddedCacheManager, CacheContainer> mapper = manager -> new DefaultCacheContainer(this.name, manager, this.defaultCache, this.batcherFactory);
Supplier<EmbeddedCacheManager> supplier = () -> {
GlobalConfiguration config = this.configuration.getValue();
EmbeddedCacheManager manager = new DefaultCacheManager(config, null, false);
manager.addListener(this);
manager.start();
InfinispanLogger.ROOT_LOGGER.debugf("%s cache container started", this.name);
return manager;
};
Consumer<EmbeddedCacheManager> destroyer = manager -> {
manager.stop();
manager.removeListener(this);
InfinispanLogger.ROOT_LOGGER.debugf("%s cache container stopped", this.name);
};
Service<CacheContainer> service = new SuppliedValueService<>(mapper, supplier, destroyer);
ServiceBuilder<CacheContainer> builder = target.addService(this.getServiceName(), service).addAliases(this.aliases.stream().toArray(ServiceName[]::new)).setInitialMode(ServiceController.Mode.PASSIVE);
return this.configuration.register(builder);
}
Aggregations