org.hibernate.search.engine.environment.bean.DependencyClosingBeanHolder Maven / Gradle / Ivy
/*
* Hibernate Search, full-text search for your domain model
*
* License: GNU Lesser General Public License (LGPL), version 2.1 or later
* See the lgpl.txt file in the root directory or .
*/
package org.hibernate.search.engine.environment.bean;
import java.util.List;
import org.hibernate.search.util.common.impl.Closer;
final class DependencyClosingBeanHolder implements BeanHolder {
private final BeanHolder delegate;
private final List> dependencies;
DependencyClosingBeanHolder(BeanHolder delegate, List> dependencies) {
this.delegate = delegate;
this.dependencies = dependencies;
}
@Override
public String toString() {
return getClass().getSimpleName() + "["
+ "delegate=" + delegate
+ ", dependencies=" + dependencies
+ "]";
}
@Override
public T get() {
return delegate.get();
}
@Override
public void close() {
try ( Closer closer = new Closer<>() ) {
closer.push( BeanHolder::close, delegate );
closer.pushAll( BeanHolder::close, dependencies );
}
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy