View Javadoc
1   package net.sf.morph.reflect.reflectors;
2   
3   import java.util.Enumeration;
4   
5   import javax.servlet.ServletContext;
6   
7   /**
8    * Exposes the init-parameters of a ServletContext.
9    * 
10   * @author Matt Sgarlata
11   * @since Dec 21, 2004
12   */
13  public class ServletContextInitParameterReflector extends BaseServletReflector {
14  
15  	private static final Class[] REFLECTABLE_TYPES = new Class[] {
16  		ServletContext.class
17  	};
18  	
19  	protected ServletContext getServletContext(Object bean) {
20  		return (ServletContext) bean;
21  	}
22  
23  	protected String[] getPropertyNamesImpl(Object bean) throws Exception {
24  		Enumeration initParameterNames =
25  			getServletContext(bean).getInitParameterNames();
26  		return enumerationToStringArray(initParameterNames);
27  	}
28  
29  	protected Object getImpl(Object bean, String propertyName) throws Exception {
30  		return getServletContext(bean).getInitParameter(propertyName);
31  	}
32  
33  	protected void setImpl(Object bean, String propertyName, Object value)
34  		throws Exception {
35  		throw new UnsupportedOperationException();
36  	}
37  	
38  	protected boolean isWriteableImpl(Object bean, String propertyName)
39  		throws Exception {
40  		return false;
41  	}
42  
43  	protected Class[] getReflectableClassesImpl() throws Exception {
44  		return REFLECTABLE_TYPES;
45  	}
46  
47  }