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

ru.vyarus.guice.ext.managed.PreDestroyAnnotationProcessor Maven / Gradle / Ivy

There is a newer version: 2.0.1
Show newest version
package ru.vyarus.guice.ext.managed;

import ru.vyarus.guice.ext.core.method.MethodPostProcessor;
import ru.vyarus.guice.ext.core.util.Utils;
import ru.vyarus.guice.ext.managed.destroyable.AnnotatedMethodDestroyable;
import ru.vyarus.guice.ext.managed.destroyable.DestroyableManager;

import javax.annotation.PreDestroy;
import java.lang.reflect.Method;

/**
 * Registers bean methods annotated with @PostConstruct in {@code DestroyableManager} to be called on shutdown.
 *
 * @author Vyacheslav Rusakov
 * @since 30.06.2014
 */
public class PreDestroyAnnotationProcessor implements MethodPostProcessor {

    private final DestroyableManager manager;

    public PreDestroyAnnotationProcessor(final DestroyableManager manager) {
        this.manager = manager;
    }

    @Override
    public void process(final PreDestroy annotation, final Method method, final Object instance) throws Exception {
        Utils.checkNoParams(method);
        manager.register(new AnnotatedMethodDestroyable(method, instance));
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy