/** * Return the current application context as WebApplicationContext. * <p><b>NOTE:</b> Only use this if you actually need to access * WebApplicationContext-specific functionality. Preferably use * {@code getApplicationContext()} or {@code getServletContext()} * else, to be able to run in non-WebApplicationContext environments as well. * @throws IllegalStateException if not running in a WebApplicationContext * @see #getApplicationContext() */ @Nullable protected final WebApplicationContext getWebApplicationContext() throws IllegalStateException { ApplicationContext ctx = getApplicationContext(); if (ctx instanceof WebApplicationContext) { return (WebApplicationContext) getApplicationContext(); } else if (isContextRequired()) { throw new IllegalStateException("WebApplicationObjectSupport instance [" + this + "] does not run in a WebApplicationContext but in: " + ctx); } else { return null; } }
/** * Return the current application context as WebApplicationContext. * <p><b>NOTE:</b> Only use this if you actually need to access * WebApplicationContext-specific functionality. Preferably use * {@code getApplicationContext()} or {@code getServletContext()} * else, to be able to run in non-WebApplicationContext environments as well. * @throws IllegalStateException if not running in a WebApplicationContext * @see #getApplicationContext() */ @Nullable protected final WebApplicationContext getWebApplicationContext() throws IllegalStateException { ApplicationContext ctx = getApplicationContext(); if (ctx instanceof WebApplicationContext) { return (WebApplicationContext) getApplicationContext(); } else if (isContextRequired()) { throw new IllegalStateException("WebApplicationObjectSupport instance [" + this + "] does not run in a WebApplicationContext but in: " + ctx); } else { return null; } }
/** * Return the current application context as WebApplicationContext. * @throws IllegalStateException if not running in a WebApplicationContext */ protected final WebApplicationContext getWebApplicationContext() throws IllegalStateException { ApplicationContext ctx = getApplicationContext(); if (!(ctx instanceof WebApplicationContext)) { throw new IllegalStateException( "WebApplicationObjectSupport instance [" + this + "] does not run in a WebApplicationContext but in: " + ctx); } return (WebApplicationContext) getApplicationContext(); }
/** * Return the current application context as WebApplicationContext. * <p><b>NOTE:</b> Only use this if you actually need to access * WebApplicationContext-specific functionality. Preferably use * {@code getApplicationContext()} or {@code getServletContext()} * else, to be able to run in non-WebApplicationContext environments as well. * @throws IllegalStateException if not running in a WebApplicationContext * @see #getApplicationContext() */ @Nullable protected final WebApplicationContext getWebApplicationContext() throws IllegalStateException { ApplicationContext ctx = getApplicationContext(); if (ctx instanceof WebApplicationContext) { return (WebApplicationContext) getApplicationContext(); } else if (isContextRequired()) { throw new IllegalStateException("WebApplicationObjectSupport instance [" + this + "] does not run in a WebApplicationContext but in: " + ctx); } else { return null; } }
/** * Return the current application context as WebApplicationContext. * <p><b>NOTE:</b> Only use this if you actually need to access * WebApplicationContext-specific functionality. Preferably use * {@code getApplicationContext()} or {@code getServletContext()} * else, to be able to run in non-WebApplicationContext environments as well. * @throws IllegalStateException if not running in a WebApplicationContext * @see #getApplicationContext() */ @Nullable protected final WebApplicationContext getWebApplicationContext() throws IllegalStateException { ApplicationContext ctx = getApplicationContext(); if (ctx instanceof WebApplicationContext) { return (WebApplicationContext) getApplicationContext(); } else if (isContextRequired()) { throw new IllegalStateException("WebApplicationObjectSupport instance [" + this + "] does not run in a WebApplicationContext but in: " + ctx); } else { return null; } }