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

org.kiwiproject.dropwizard.lifecycle.ManagedCloseable Maven / Gradle / Ivy

Go to download

Kiwi is a utility library. We really like Google's Guava, and also use Apache Commons. But if they don't have something we need, and we think it is useful, this is where we put it.

There is a newer version: 4.5.2
Show newest version
package org.kiwiproject.dropwizard.lifecycle;

import io.dropwizard.lifecycle.Managed;
import lombok.Getter;

import java.io.Closeable;
import java.io.IOException;

/**
 * A Dropwizard {@link Managed} that manages a single {@link Closeable} instance.
 */
public class ManagedCloseable implements Managed {

    @Getter
    private final Closeable closeable;

    public ManagedCloseable(Closeable closeable) {
        this.closeable = closeable;
    }

    /**
     * No-op
     */
    @Override
    public void start() {
        // Nothing to do
    }

    /**
     * Delegates to the managed {@link Closeable}'s {@code close} method.
     *
     * @see Closeable#close()
     */
    @Override
    public void stop() throws IOException {
        closeable.close();
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy