/** * Initialises Johnson, additionally binding the {@link JohnsonConfig} and {@link JohnsonEventContainer} to the * provided {@code ServletContext} and performing any {@link ApplicationEventCheck}s which have been configured. * <p> * If the {@link #PARAM_CONFIG_LOCATION} {@code init-param} is set, it is used to determine the location of the * Johnson configuration file. Otherwise, {@link XmlJohnsonConfig#DEFAULT_CONFIGURATION_FILE} is assumed. * <p> * Note: This method is <i>not synchronised</i> and <i>not thread-safe</i>. It is left to the <i>calling code</i> * to ensure proper synchronisation. The easiest way to do this is to initialise Johnson by adding the * {@link com.atlassian.johnson.context.JohnsonContextListener} to {@code web.xml}. * * @param context the servlet context */ public static void initialize(@Nonnull ServletContext context) { String location = StringUtils.defaultIfEmpty( checkNotNull(context, "context").getInitParameter(PARAM_CONFIG_LOCATION), XmlJohnsonConfig.DEFAULT_CONFIGURATION_FILE); initialize(location); context.setAttribute(ATTR_CONFIG, config); context.setAttribute(ATTR_EVENT_CONTAINER, eventContainer); List<ApplicationEventCheck> checks = config.getApplicationEventChecks(); for (ApplicationEventCheck check : checks) { check.check(eventContainer, context); } }