package com.atlassian.stash.internal.lifecycle;

import org.springframework.core.Conventions;

import javax.annotation.Nonnull;
import javax.servlet.ServletContext;

/**
 * @since 3.2
 */
public abstract class StartupUtils {

    private static final String ATTR_INSTANCE = Conventions.getQualifiedAttributeName(StartupManager.class, "instance");

    private StartupUtils() {
    }

    @Nonnull
    public static StartupManager getStartupManager(@Nonnull ServletContext servletContext) {
        return (StartupManager) servletContext.getAttribute(ATTR_INSTANCE);
    }

    public static void setStartupManager(@Nonnull ServletContext servletContext,
                                         @Nonnull StartupManager startupManager) {
        servletContext.setAttribute(ATTR_INSTANCE, startupManager);
    }
}
