1/*2 * Licensed to the Apache Software Foundation (ASF) under one or more3 * contributor license agreements. See the NOTICE file distributed with4 * this work for additional information regarding copyright ownership.5 * The ASF licenses this file to You under the Apache License, Version 2.06 * (the "License"); you may not use this file except in compliance with7 * the License. You may obtain a copy of the License at8 * 9 * http://www.apache.org/licenses/LICENSE-2.010 * 11 * Unless required by applicable law or agreed to in writing, software12 * distributed under the License is distributed on an "AS IS" BASIS,13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.14 * See the License for the specific language governing permissions and15 * limitations under the License.16 */17packageorg.apache.jetspeed.components.factorybeans;
1819import javax.servlet.ServletConfig;
2021import org.springframework.beans.factory.config.AbstractFactoryBean;
2223/***24 * <p>25 * PreSetInstanceFactoryBean26 * </p>27 * <p>28 *29 * </p>30 * @author <a href="mailto:weaver@apache.org">Scott T. Weaver</a>31 * @version $Id: ServletConfigFactoryBean.java 516448 2007-03-09 16:25:47Z ate $32 *33 */34publicclassServletConfigFactoryBeanextends AbstractFactoryBean
35 {
3637privatestatic ServletConfig servletConfig;
383940/***41 * <p>42 * createInstance43 * </p>44 *45 * @see org.springframework.beans.factory.config.AbstractFactoryBean#createInstance()46 * @return47 * @throws Exception48 */49protectedfinal Object createInstance() throws Exception
50 {
51 verifyState();
52return servletConfig;
53 }
5455/***56 * <p>57 * getObjectType58 * </p>59 * @see org.springframework.beans.factory.FactoryBean#getObjectType()60 * @return61 */62publicfinal Class getObjectType()
63 {
64return ServletConfig.class;
65 }
6667publicfinalstaticvoid setServletConfig(ServletConfig servletConfig)
68 {
69 ServletConfigFactoryBean.servletConfig = servletConfig;
70 }
7172protectedfinalvoid verifyState() throws IllegalStateException
73 {
74if(servletConfig == null)
75 {
76thrownew IllegalStateException("You invoke the ServletConfigFactoryBean.setServletConfig() "+
77"method prior to attempting to get the ServletConfig.");
78 }
79 }
80 }