org.hibernate.search.engine.environment.bean.DependencyClosingBeanHolder Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of hibernate-search-engine Show documentation
Show all versions of hibernate-search-engine Show documentation
Hibernate Search engine, always required
The newest version!
/*
* SPDX-License-Identifier: Apache-2.0
* Copyright Red Hat Inc. and Hibernate Authors
*/
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 );
}
}
}