1 package jfun.yan.web; 2 3 import java.beans.IntrospectionException ; 4 5 import jfun.yan.Component; 6 import jfun.yan.xml.NutsUtils; 7 import jfun.yan.xml.nuts.ArgumentsAndPropertiesNut; 8 9 15 public class WebUtils { 16 19 public static final String DEFAULT_SERVLET_CONTEXT_PROPERTY = "servletContext"; 20 33 public static final Component setPossibleServletContext( 34 Component c, String name, ArgumentsAndPropertiesNut nut){ 35 if(name==null || name.length()==0) return c; 36 if(nut.isAllProperties() || nut.containsExplicitProperty(name)) 39 return c; 40 final Object servletcontext = nut.getNutEnvironment() 41 .findService(YanLoader.SERVLET_CONTEXT_KEY); 42 if(servletcontext==null){ 43 return c; 44 } 45 try{ 46 return NutsUtils.setPossiblePropertyValue(c, name, servletcontext); 47 } 48 catch(IntrospectionException e){ 49 throw nut.raise(e); 50 } 51 } 52 } 53 | Popular Tags |