use of org.springframework.beans.factory.DisposableBean in project spring-framework by spring-projects.
the class DefaultSingletonBeanRegistry method destroySingleton.
/**
* Destroy the given bean. Delegates to {@code destroyBean}
* if a corresponding disposable bean instance is found.
* @param beanName the name of the bean
* @see #destroyBean
*/
public void destroySingleton(String beanName) {
// Remove a registered singleton of the given name, if any.
removeSingleton(beanName);
// Destroy the corresponding DisposableBean instance.
DisposableBean disposableBean;
synchronized (this.disposableBeans) {
disposableBean = (DisposableBean) this.disposableBeans.remove(beanName);
}
destroyBean(beanName, disposableBean);
}
use of org.springframework.beans.factory.DisposableBean in project Settler by EmhyrVarEmreis.
the class ExceptionHandlingAsyncTaskExecutor method destroy.
@Override
public void destroy() throws Exception {
if (executor instanceof DisposableBean) {
DisposableBean bean = (DisposableBean) executor;
bean.destroy();
}
}
use of org.springframework.beans.factory.DisposableBean in project spring-boot by spring-projects.
the class ConfigurationPropertiesBindingPostProcessor method freeLocalValidator.
private void freeLocalValidator() {
try {
Validator validator = this.localValidator;
this.localValidator = null;
if (validator != null) {
((DisposableBean) validator).destroy();
}
} catch (Exception ex) {
throw new IllegalStateException(ex);
}
}
use of org.springframework.beans.factory.DisposableBean in project uPortal by Jasig.
the class PortalShell method main.
public static void main(String[] args) throws Exception {
final Options options = getOptions();
final CommandLineParser parser = new PosixParser();
final CommandLine commandLine;
try {
commandLine = parser.parse(options, args);
} catch (ParseException e) {
System.err.println(e.getMessage());
printHelp(options);
return;
}
final ApplicationContext applicationContext = PortalApplicationContextLocator.getApplicationContext();
try {
final Binding binding = new SpringBinding(applicationContext);
binding.setVariable("logger", LOGGER);
final CompilerConfiguration conf = new CompilerConfiguration(System.getProperties());
final GroovyShell shell = new GroovyShell(binding, conf);
if (commandLine.hasOption("script")) {
final String scriptName = commandLine.getOptionValue("script");
final File scriptFile = getAbsoluteFile(scriptName);
shell.run(scriptFile, args);
}
} finally {
if (applicationContext instanceof DisposableBean) {
((DisposableBean) applicationContext).destroy();
}
}
}
Aggregations