1 package org.sapia.regis.loader; 2 3 import org.sapia.util.text.TemplateContextIF; 4 import org.sapia.util.xml.confix.ConfigurationException; 5 import org.sapia.util.xml.confix.ObjectCreationCallback; 6 import org.sapia.util.xml.confix.ObjectFactoryIF; 7 8 public class ParamRefTag implements TagFactory, ObjectCreationCallback{ 9 10 private TemplateContextIF _ctx; 11 private String name, defaultVal; 12 13 public void setDefault(String defaultVal) { 14 this.defaultVal = defaultVal; 15 } 16 17 public void setName(String name) { 18 this.name = name; 19 } 20 21 public Object onCreate() throws ConfigurationException { 22 Object val = _ctx.getValue(name); 23 if(val == null){ 24 if(defaultVal == null){ 25 throw new ConfigurationException("No parameter value found for: " + name); 26 } 27 else{ 28 return this.defaultVal; 29 } 30 } 31 else{ 32 return val; 33 } 34 } 35 36 public Object create(TemplateContextIF context, ObjectFactoryIF fac) throws Exception { 37 _ctx = context; 38 return this; 39 } 40 41 } 42 | Popular Tags |