1 28 29 package com.caucho.el; 30 31 import javax.el.ELContext; 32 import javax.el.ELResolver; 33 34 39 public class SystemPropertiesResolver extends AbstractVariableResolver { 40 43 public SystemPropertiesResolver() 44 { 45 } 46 47 50 public SystemPropertiesResolver(ELResolver next) 51 { 52 super(next); 53 } 54 55 58 @Override 59 public Object getValue(ELContext env, 60 Object base, 61 Object property) 62 { 63 String var; 64 65 if (base == null && property instanceof String ) 66 var = (String ) property; 67 else if (base == this && property instanceof String ) 68 var = (String ) property; 69 else 70 return null; 71 72 Object value = System.getProperty(var); 73 74 if (value != null) { 75 env.setPropertyResolved(true); 76 return value; 77 } 78 79 value = System.getenv(var); 80 81 if (value != null) { 82 env.setPropertyResolved(true); 83 return value; 84 } 85 86 if ("Var".equals(var)) { 87 env.setPropertyResolved(true); 88 return this; 89 } 90 91 return null; 92 } 93 94 97 public String toString() 98 { 99 return "SystemPropertiesResolver[]"; 100 } 101 } 102 | Popular Tags |