GRAILS-1019: Allowing expressions to be used with the 'disabled' attribute for g...
[grails.git] / src / commons / org / codehaus / groovy / grails / commons / spring / WebRuntimeSpringConfiguration.java
blob6c5318ca014858ae793c33f9f04a30faa5bf34c4
1 /* Copyright 2004-2005 Graeme Rocher
3 * Licensed under the Apache License, Version 2.0 (the "License");
4 * you may not use this file except in compliance with the License.
5 * You may obtain a copy of the License at
7 * http://www.apache.org/licenses/LICENSE-2.0
9 * Unless required by applicable law or agreed to in writing, software
10 * distributed under the License is distributed on an "AS IS" BASIS,
11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 * See the License for the specific language governing permissions and
13 * limitations under the License.
15 package org.codehaus.groovy.grails.commons.spring;
17 import org.springframework.web.context.ConfigurableWebApplicationContext;
18 import org.springframework.web.context.ServletContextAware;
19 import org.springframework.context.support.GenericApplicationContext;
20 import org.springframework.context.ApplicationContext;
22 import javax.servlet.ServletContext;
24 /**
25 * Subclasses DefaultRuntimeSpringConfiguration to provide construction of WebApplicationContext instances
27 * @author Graeme Rocher
28 * @since 1.0
29 * <p/>
30 * Created: Nov 23, 2007
32 public class WebRuntimeSpringConfiguration extends DefaultRuntimeSpringConfiguration implements ServletContextAware {
34 public WebRuntimeSpringConfiguration(ApplicationContext parent) {
35 super(parent);
38 public WebRuntimeSpringConfiguration(ApplicationContext parent, ClassLoader cl) {
39 super(parent, cl);
42 protected GenericApplicationContext createApplicationContext(ApplicationContext parent) {
43 if(parent != null) return new GrailsWebApplicationContext(parent);
44 return new GrailsWebApplicationContext();
48 public void setServletContext(ServletContext servletContext) {
49 initialiseApplicationContext();
51 if(this.context instanceof ConfigurableWebApplicationContext) {
52 ((ConfigurableWebApplicationContext) this.context).setServletContext(servletContext);