package info.bukova.isspst;

import org.springframework.web.context.WebApplicationContext;
import org.springframework.web.context.support.WebApplicationContextUtils;

import javax.servlet.ServletContext;

/**
 * @author Pepa Rokos
 */
public class SpringUtils {

	private static WebApplicationContext webCtx(ServletContext sc) {
		return WebApplicationContextUtils.getRequiredWebApplicationContext(sc);
	}

	public static Object getBean(String name, ServletContext sc) {
		return webCtx(sc).getBean(name);
	}

	public static <T> T getBean(Class<T> clazz, ServletContext sc) {
		return webCtx(sc).getBean(clazz);
	}

}
