All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.github.dxee.dject.lifecycle.AutoCloseableLifecycleAction Maven / Gradle / Ivy

Go to download

A collection of guice extensions, help to improve the developer experience of guice.

There is a newer version: 1.2.1
Show newest version
package com.github.dxee.dject.lifecycle;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

/**
 * AutoCloseableLifecycleAction
 * @author bing.fan
 * 2018-06-07 19:46
 */
public class AutoCloseableLifecycleAction implements LifecycleAction {
    private static final Logger LOGGER = LoggerFactory.getLogger(AutoCloseableLifecycleAction.class);

    private final String description;

    public AutoCloseableLifecycleAction(Class clazz) {
        this.description = new StringBuilder().append("AutoCloseable@").append(System.identityHashCode(this)).append("[").append(clazz.getName()).append(".")
                .append("close()").append("]").toString();
    }

    @Override
    public void call(Object obj) throws Exception {
        LOGGER.info("calling action {}", description);
        AutoCloseable.class.cast(obj).close();
    }

    @Override
    public String toString() {
        return description;
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy