![JAR search and dependency download from the Maven repository](/logo.png)
org.wildfly.clustering.ejb.cache.bean.OnCloseBean Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of wildfly-clustering-ejb-cache Show documentation
Show all versions of wildfly-clustering-ejb-cache Show documentation
Contains code common to the wildfly-clustering-ejb-hotrod and wildfly-clustering-ejb-infinispan modules.
/*
* Copyright The WildFly Authors
* SPDX-License-Identifier: Apache-2.0
*/
package org.wildfly.clustering.ejb.cache.bean;
import java.util.function.Consumer;
import org.wildfly.clustering.ejb.bean.Bean;
import org.wildfly.clustering.ejb.bean.BeanInstance;
import org.wildfly.clustering.ejb.bean.BeanMetaData;
/**
* A bean decorator that executes a given task on close.
* @author Paul Ferraro
* @param the bean identifier type
* @param the bean instance type
*/
public class OnCloseBean> implements Bean {
private final Bean bean;
private final Consumer> task;
public OnCloseBean(Bean bean, Consumer> task) {
this.bean = bean;
this.task = task;
}
@Override
public K getId() {
return this.bean.getId();
}
@Override
public V getInstance() {
return this.bean.getInstance();
}
@Override
public BeanMetaData getMetaData() {
return this.bean.getMetaData();
}
@Override
public boolean isValid() {
return this.bean.isValid();
}
@Override
public void remove(Consumer removeTask) {
this.bean.remove(removeTask);
}
@Override
public void close() {
try {
this.task.accept(this.bean);
} finally {
this.bean.close();
}
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy