1 23 package com.sun.enterprise.config; 24 25 import java.util.Enumeration ; 26 import java.util.Vector ; 27 import java.io.Serializable ; 28 import java.text.CharacterIterator ; 29 import java.text.StringCharacterIterator ; 30 31 import org.netbeans.modules.schema2beans.BaseBean; 32 33 import org.netbeans.modules.schema2beans.Version; 35 import org.netbeans.modules.schema2beans.BaseProperty; 36 import java.util.Properties ; 37 import java.util.StringTokenizer ; 38 import java.util.ArrayList ; 39 import java.util.Hashtable ; 40 41 import java.util.logging.Logger ; 42 import java.util.logging.Level ; 43 import com.sun.enterprise.config.pluggable.ConfigBeanInterceptor; 44 import com.sun.enterprise.config.pluggable.ConfigBeansSettings; 45 import com.sun.enterprise.config.pluggable.EnvironmentFactory; 46 import com.sun.enterprise.config.util.LoggerHelper; 47 48 import com.sun.enterprise.config.impl.ConfigContextImpl; 49 import org.w3c.dom.DocumentType ; 50 51 57 58 public abstract class ConfigBean extends ConfigBeanBase implements Serializable { 59 60 64 transient private ConfigBeanInterceptor _interceptor = null; 65 transient private ConfigBeansSettings _cbSettings = null; 66 transient protected ConfigContext ctx = null; 67 68 transient private Hashtable transientProperties = null; 69 70 private static final String UNINITIALIZED_ATTRIBUTE_VALUE = "DONOTKNOW"; 71 private static final long UNINITIALIZED_LAST_MODIFIED_VALUE = -1; 72 73 86 transient private long thisLastModified = UNINITIALIZED_LAST_MODIFIED_VALUE; 87 transient private long globalLastModified = UNINITIALIZED_LAST_MODIFIED_VALUE; 88 89 private String xpath; 90 91 96 public Object getTransientProperty(String name) 97 { 98 if(name==null || transientProperties==null) 99 return null; 100 return transientProperties.get(name); 101 } 102 108 public Object setTransientProperty(String name, Object value) 109 { 110 if(name==null) 111 return null; 112 if(value==null) 113 { 114 if(transientProperties==null) 115 return null; 116 value = transientProperties.get(name); 117 if(value!=null) 118 transientProperties.remove(name); 119 return value; 120 } 121 if(transientProperties==null) 122 transientProperties=new Hashtable (); 123 return transientProperties.put(name, value); 124 } 125 126 public void setXPath(String xpath) { 127 this.xpath = (null != xpath ? xpath.trim() : xpath); 128 } 129 130 public String getXPath() { 131 return (null != xpath ? xpath.trim() : xpath); 132 } 133 138 public boolean canHaveSiblings(){ 139 return beanProp() != null && beanProp().isIndexed(); 140 } 141 142 143 public ConfigContext getConfigContext() { 144 return ctx; 145 } 146 147 public void setConfigContext(ConfigContext ctx) { 148 this.ctx = ctx; 150 } 151 152 public void cleanup() { 154 this.ctx = null; 155 this._interceptor = null; 156 setInvalidState(); 157 } 158 159 public ConfigBean() { 160 super(null, new org.netbeans.modules.schema2beans.Version(4, 0, 0)); 161 setThisLastModified(); 162 _cbSettings = getConfigBeansSettings(); 164 } 165 166 169 170 public ConfigBean(Vector comps, Version version) { 171 super(comps, version); 172 setThisLastModified(); 173 _cbSettings = getConfigBeansSettings(); 175 } 176 177 178 179 187 public static boolean toBoolean(final String value){ 188 final String v = (null != value ? value.trim() : value); 189 return null != v && (v.equals("true") 190 || v.equals("yes") 191 || v.equals("on") 192 || v.equals("1")); 193 } 194 195 196 public void setAttributeValue(String name, String value) { 197 try { 198 setAttributeValue(name, value, true); 199 } catch(StaleWriteConfigException swce) { 200 String url = (this.ctx==null)?" ":ctx.getUrl(); 201 LoggerHelper.finest("Detected external changes to config file \"" + 202 url + 203 "\". Ignoring the condition and proceeding"); 204 } 205 } 206 207 210 public void setAttributeValue(String name, String value , boolean overwrite) 211 throws StaleWriteConfigException { 212 final String nm = (null != name ? name.trim() : name); 213 final String vl = (null != value ? value.trim() : value); 214 215 217 if (getAttributeValueSafe(nm) != null && getAttributeValueSafe(nm).equals(vl)){ 219 return; 220 } 221 222 223 if(!overwrite && this.ctx != null && this.ctx.isFileChangedExternally()) { 224 throw new StaleWriteConfigException 225 ("ConfigBean: cannot change since FileChangedExternally"); 226 } 227 228 String oldValue = UNINITIALIZED_ATTRIBUTE_VALUE; 229 if(_cbSettings.isSpecialElement(nm)) { 231 oldValue = preSetAttributeValueSpecial(nm); 232 super.setValue(nm, vl); 233 postSetAttributeValueSpecial(nm, vl, oldValue); 234 } else { 235 oldValue = preSetAttributeValue(nm, vl); 236 super.setAttributeValue(nm, vl); 237 postSetAttributeValue(nm, vl, oldValue); 238 } 239 } 240 241 244 public ConfigBean[] getChildBeansByName(String childBeanName) { 245 validateState(); 246 247 if(childBeanName == null) return null; 248 childBeanName = childBeanName.trim(); 249 250 childBeanName = _cbSettings.mapElementName(childBeanName); 251 252 ConfigBean[] ret = null; 253 try { 254 ret = (ConfigBean[]) getValues(childBeanName); 255 } catch(Exception e) { 256 ret = getChildBeanByName(childBeanName); 258 } 259 return ret; 260 } 261 262 265 public ConfigBean[] getAllChildBeans() { 266 ArrayList cbRet = new ArrayList (); 267 String [] childNames = getChildBeanNames(); 268 if(childNames == null || childNames.length == 0) return null; 269 270 for(int i = 0;i<childNames.length;i++) { 271 ConfigBean[] cb = getChildBeansByName(childNames[i]); 272 if (cb == null) continue; 273 for(int k=0;k<cb.length;k++) { 274 cbRet.add(cb[k]); 275 } 276 } 277 return toConfigBeanArray(cbRet); 278 } 279 280 283 private String [] getChildBeanNames() { 284 BaseProperty[] bp = super.listProperties(); 285 if(bp == null) return null; 286 String [] s = new String [bp.length]; 287 for(int i = 0;i< bp.length;i++) { 288 s[i] = bp[i].getDtdName(); 289 } 290 return s; 291 } 292 293 public int removeChild(ConfigBean child) throws ConfigException { 294 return removeChild(child, true); 296 } 297 298 302 public int removeChild(ConfigBean child, boolean overwrite) throws ConfigException { 303 if(!overwrite && this.ctx != null && this.ctx.isFileChangedExternally()) { 305 throw new StaleWriteConfigException 306 ("ConfigBean: cannot change since FileChangedExternally"); 307 } 308 309 if(child == null) 310 throw new ConfigException("Cannot remove null child"); 311 312 return this.removeValue(child.name(), child); 313 } 314 315 316 public int addValue(String name, Object value) { 317 int i=0; 318 try { 319 i= addValue(name, value, true); 320 } catch(StaleWriteConfigException swce) { 321 } 323 return i; 324 } 325 326 331 public int addValue(String name, Object value, boolean overwrite) 332 throws StaleWriteConfigException { 333 if (null != name){ 334 name = name.trim(); 335 } 336 337 338 if(!overwrite && this.ctx != null && this.ctx.isFileChangedExternally()) { 339 throw new StaleWriteConfigException 340 ("ConfigBean: cannot change since FileChangedExternally"); 341 } 342 343 preAddValue(name, value); 344 int i = super.addValue(name, value); 345 postAddValue(name, value); 346 return i; 347 } 348 349 public int removeValue(String name, Object value) { 350 if (null != name){ 351 name = name.trim(); 352 } 353 354 int i=0; 355 try { 356 i= removeValue(name, value, true); 357 } catch (StaleWriteConfigException swce) { 358 } 360 return i; 361 } 362 public int removeValue(String name, Object value, boolean overwrite) 363 throws StaleWriteConfigException { 364 if (null != name) { 365 name = name.trim(); 366 } 367 368 if(!overwrite && this.ctx != null && this.ctx.isFileChangedExternally()) { 369 throw new StaleWriteConfigException 370 ("ConfigBean: cannot change since FileChangedExternally"); 371 } 372 373 preRemoveValue(name, value); 374 int i = super.removeValue(name, value); 375 postRemoveValue(name, value); 376 return i; 377 } 378 379 public Object getValue(String name) 380 { 381 if (null != name) { 382 name = name.trim(); 383 } 384 385 Object res = super.getValue(name); 386 res = postGetValue(name, res); 387 return res; 388 } 389 390 public Object getValue(String name, int index) 391 { 392 if (null != name) { 393 name = name.trim(); 394 } 395 396 Object res = super.getValue(name, index); 397 res = postGetValue(name, res); 398 return res; 399 } 400 public Object getValueById(String name, int id) 401 { 402 if (null != name) { 403 name = name.trim(); 404 } 405 406 Object res = super.getValueById(name, id); 407 res = postGetValue(name, res); 408 return res; 409 } 410 public Object [] getValues(String name) 411 { 412 if (null != name) { 413 name = name.trim(); 414 } 415 416 Object [] res = super.getValues(name); 417 res = postGetValues(name, res); 418 return res; 419 } 420 421 422 public void setValue(String name, Object value) { 423 if (null != name) { 424 name = name.trim(); 425 } 426 427 try { 428 setValue(name, value, true); 429 } catch(StaleWriteConfigException swce) { 430 } 432 } 433 434 public void setValue(String name, Object value, boolean overwrite) throws StaleWriteConfigException { 435 if (null != name) { 436 name = name.trim(); 437 } 438 439 440 if(!overwrite && this.ctx != null && this.ctx.isFileChangedExternally()) { 441 throw new StaleWriteConfigException 442 ("ConfigBean: cannot change since FileChangedExternally"); 443 } 444 Object oldValue = super.getValue(name); 445 446 preSetValue(name, value); 447 super.setValue(name, value); 448 if(oldValue!=null && oldValue!=value && oldValue instanceof ConfigBean) 449 postRemoveValue(name, oldValue); 450 postSetValue(name, value); 451 } 452 453 455 public void setValue(String name, Object [] value) { 457 if (null != name) { 458 name = name.trim(); 459 } 460 461 preSetArrayValue(name, value); 462 super.setValue(name, value); 463 postSetArrayValue(name, value); 464 465 466 467 } 468 469 474 public static String getDefaultAttributeValueFromDtd(String attr) { 475 if (null != attr) { 476 attr = attr.trim(); 477 } 478 479 return getDefaultAttributeValue(attr); 480 } 481 482 486 public static String getDefaultAttributeValue(String attr) { 487 return null; 488 } 489 490 495 protected String getRelativeXPath() { 496 return null; 497 } 498 499 503 public String getAbsoluteXPath(String parentXpath) { 504 if(xpath!=null) 505 return this.xpath.trim(); 506 if(parentXpath==null) 507 return null; 508 String rel = getRelativeXPath(); 509 if(rel == null) return null; 510 return parentXpath.trim() + "/" + getRelativeXPath().trim(); 511 } 512 513 520 public synchronized String getAttributeValue(String name) { 521 if (null != name) { 522 name = name.trim(); 523 } 524 525 String res = getRawAttributeValue(name); 526 return postGetAttributeValue(name, res); 527 } 528 529 539 public synchronized Object clone() { 540 final Object orig = preClone(); 541 final ConfigBean result = (ConfigBean) super.clone(); 542 if (this == parent()){ 543 result.setDoctype(this.getPublicId(), this.getSystemId()); 544 } 545 postClone(orig, result); 546 result.setGlobalLastModified(getThisLastModified()); 547 return result; 548 } 549 550 556 561 private String publicId; 562 private String systemId; 563 564 private void setDoctype(final String pid, final String sid){ 565 publicId = (null != pid ? pid.trim() : pid); 566 systemId = (null != sid ? sid.trim() : sid); 567 if (graphManager() != null){ 568 graphManager().setDoctype(pid,sid); 569 } 570 } 571 572 private String getPublicId() { 573 if (getDoctype() != null){ 574 publicId = getDoctype().getPublicId(); 575 } 576 return publicId.trim(); 577 } 578 private String getSystemId() { 579 if (getDoctype() != null){ 580 systemId = getDoctype().getSystemId(); 581 } 582 return systemId.trim(); 583 } 584 585 private DocumentType getDoctype(){ 586 return (graphManager().getXmlDocument() != null 587 ? graphManager().getXmlDocument().getDoctype() 588 : (DocumentType ) null); 589 } 590 591 592 public String getRawAttributeValue(String name) { 593 if (null != name) { 594 name = name.trim(); 595 } 596 597 if(_cbSettings.isSpecialElement(name)) { 599 final String v = (String )super.getValue(name); 600 return (null != v ? v.trim() : v); 601 } 602 preRawGetAttributeValue(name); 603 String s = super.getAttributeValue(name); 604 postRawGetAttributeValue(name, s); 605 return (null != s ? s.trim() : s); 606 } 607 608 611 public void dumpAttributes(String name, int index, StringBuffer str, 612 String indent) { 613 if (null != name) { 614 name = name.trim(); 615 } 616 617 String [] names = this.getAttributeNames(name); 618 619 for (int i=0; i<names.length; i++) { 620 String v = null; 621 if(names[i].indexOf("Password") != -1 || names[i].indexOf("UserName") != -1) { 623 v = "*****"; 624 } else { 625 v = this.getAttributeValue(name, index, names[i]); 626 } 627 628 if (v != null) { 629 str.append(indent + "\t attr: "); str.append(names[i]); 631 str.append("="); str.append(v); 633 } 634 } 635 } 636 637 638 public void changed() { 640 } 641 642 646 public boolean isEnabled() { 647 return true; 649 } 650 651 652 656 public void setEnabled(boolean enabled) { 657 } 660 661 public boolean isMonitoringEnabled() { 663 return false; 665 } 666 667 670 684 public static String camelize(String name) 686 { 687 if (null != name) { 688 name = name.trim(); 689 } 690 691 692 CharacterIterator ci; 693 StringBuffer n = new StringBuffer (); 694 boolean up = true; 695 boolean keepCase = false; 696 char c; 697 698 ci = new StringCharacterIterator (name); 699 c = ci.first(); 700 701 while (c != CharacterIterator.DONE) 703 { 704 if (Character.isLowerCase(c)) 705 { 706 keepCase = true; 707 break; 708 } 709 c = ci.next(); 710 } 711 712 c = ci.first(); 713 while (c != CharacterIterator.DONE) 714 { 715 if (c == '-' || c == '_') 716 up = true; 717 else 718 { 719 if (up) 720 c = Character.toUpperCase(c); 721 else 722 if (!keepCase) 723 c = Character.toLowerCase(c); 724 n.append(c); 725 up = false; 726 } 727 c = ci.next(); 728 } 729 return n.toString(); 730 } 731 732 737 private void setThisLastModified() { 738 thisLastModified = System.currentTimeMillis(); 739 } 740 741 745 private void setGlobalLastModified(long timestamp) { 746 globalLastModified = timestamp; 747 } 748 749 753 public long getGlobalLastModified() { 754 return globalLastModified; 755 } 756 757 public long getThisLastModified() { 758 return thisLastModified; 759 } 760 761 public synchronized void setInterceptor(ConfigBeanInterceptor cbi) { 762 this._interceptor = cbi; 763 } 764 765 public synchronized ConfigBeanInterceptor getInterceptor() { 766 if (null != _interceptor) { 767 return _interceptor; 768 } 769 ConfigBeanInterceptor cbi = null; 770 if (null != ctx) { 772 776 cbi = ((ConfigContextImpl)ctx).getConfigBeanInterceptor(); 777 } else { 778 ConfigBean parent = (ConfigBean)parent(); 780 784 if ((null != parent) && (this != parent)) { 785 cbi = parent.getInterceptor(); 786 } 787 } 788 793 return cbi; 795 } 796 797 private ConfigBeansSettings getConfigBeansSettings() { 798 return EnvironmentFactory. 799 getEnvironmentFactory(). 800 getConfigEnvironment(). 801 getConfigBeansSettings(); 802 } 803 804 private Object postGetValue(String name, Object res) { 805 addXPathToChild(res); 806 return (getInterceptor()==null) 807 ?res:getInterceptor().postGetValue(this, name, res); 808 } 809 private Object [] postGetValues(String name, Object [] res) { 810 addXPathToChild(res); 811 return (getInterceptor()==null) 812 ?res:getInterceptor().postGetValues(name, res); 813 } 814 private String postGetAttributeValue(String name, String res) { 815 String s = (getInterceptor()==null) 816 ?res:getInterceptor().postGetAttributeValue(name, res); 817 return (null != s ? s.trim() : s); 818 } 819 private Object preClone() { 820 if(getInterceptor() != null) 821 return getInterceptor().preClone(); 822 return null; 823 } 824 825 private void postClone(Object o, Object result) { 826 final ConfigBeanInterceptor cbi = getInterceptor(); 827 if(cbi != null) { 828 cbi.postClone(o); 829 } 830 } 831 832 834 private String getAttributeValueSafe(String name) { 835 try { 836 return this.getAttributeValue(name); 837 } catch(Throwable t){ 838 } 840 return null; 841 } 842 843 private void addToConfigChangeList(String xpath, 844 String tag, 845 String oldValue, 846 String newValue) { 847 ConfigChange cChange = null; 848 if(ctx != null) { 849 cChange = this.ctx.addToConfigChangeList( 850 (null != xpath ? xpath.trim() : xpath), 851 (null != tag ? tag.trim() : tag), 852 (null != oldValue ? oldValue.trim() : oldValue), 853 (null != newValue ? newValue.trim() : newValue)); 854 if(cChange!=null) cChange.setGlobalLastModified(getGlobalLastModified()); 856 } 857 } 858 859 private String preSetAttributeValue(String name, String value) { 860 preConfigChange(name, value, ConfigContextEvent.PRE_UPDATE_CHANGE, "UPDATE", 861 (null != this.name() ? this.name().trim() : this.name())); 862 863 return this.getAttributeValueSafe(name); 864 } 865 866 private void preAddValue(String name, Object value) { 867 preConfigChange(name, value, ConfigContextEvent.PRE_ADD_CHANGE, "ADD"); 868 } 869 870 private void preRemoveValue(String name, Object value) { 871 preConfigChange(name, value, ConfigContextEvent.PRE_DELETE_CHANGE, "DELETE"); 872 } 873 874 private void preSetValue(String name, Object value) { 875 preConfigChange(name, value, ConfigContextEvent.PRE_SET_CHANGE, "SET"); 876 } 877 878 private void preConfigChange(String name, Object value, String type, String operation){ 879 preConfigChange(name, value, type,operation, null); 880 } 881 882 private void preConfigChange(String name, Object value, String type, String operation, String beanName) { 883 validateState(); 884 885 if(ctx !=null) { 886 ConfigContextEvent ccce = new ConfigContextEvent(ctx, type,name,value,operation, beanName); 887 ccce.setClassObject(this); 888 ctx.preChange(ccce); 889 } 890 } 891 892 private void postSetAttributeValue(String name, String value, String oldValue) { 893 setThisLastModified(); 895 896 ConfigChange cChange = null; 897 898 if(ctx != null) { 899 cChange = this.ctx.addToConfigChangeList(this.xpath, name, oldValue, value); 900 if(cChange != null) cChange.setGlobalLastModified(this.getGlobalLastModified()); 901 902 ConfigContextEvent ccce = new ConfigContextEvent(ctx, ConfigContextEvent.POST_UPDATE_CHANGE,name,value,"UPDATE"); 905 this.ctx.postChange(ccce); 906 } 908 } 909 910 private void postAddValue(String name, Object value) { 911 912 setThisLastModified(); 914 915 if(ctx != null) { 917 if(value instanceof ConfigBean) { 918 try { 919 ConfigChange cChange = 921 this.ctx.addToConfigChangeList( 922 this.xpath, 923 ((ConfigBean)value).getAbsoluteXPath(this.xpath), 924 name, 925 ((ConfigBean)this.ctx.getRootConfigBean().clone())); 926 if(cChange != null) cChange.setGlobalLastModified(this.getGlobalLastModified()); 927 } catch(Exception ce) { 928 ce.printStackTrace(); 929 } 930 931 ((ConfigBean)value).setConfigContext(this.ctx); 932 ((ConfigBean)value).setXPath(((ConfigBean)value).getAbsoluteXPath(this.xpath)); 933 } 934 935 ConfigContextEvent ccce = new ConfigContextEvent(ctx, ConfigContextEvent.POST_ADD_CHANGE,name,value,"ADD"); 936 this.ctx.postChange(ccce); 937 938 } else { 939 } 941 } 942 943 private void postSetValue(String name, Object value) { 944 setThisLastModified(); 946 947 if(ctx != null) { 948 if(value instanceof ConfigBean) { 951 ConfigChange cChange = this.ctx.addToConfigChangeList(this.xpath, name, ((ConfigBean)value).clone(), null); 953 if(cChange != null) cChange.setGlobalLastModified(this.getGlobalLastModified()); 954 955 ((ConfigBean)value).setConfigContext(this.ctx); ((ConfigBean)value).setXPath(((ConfigBean)value).getAbsoluteXPath(this.xpath)); 957 ConfigContextEvent ccce = new ConfigContextEvent(ctx,ConfigContextEvent.POST_SET_CHANGE,name,value,"SET"); 960 ctx.postChange(ccce); 961 963 } else { 964 ConfigChange cChange = this.ctx.addToConfigChangeList(this.xpath, name, value, null); 965 if(cChange != null) cChange.setGlobalLastModified(this.getGlobalLastModified()); 966 } 967 } else { 968 } 970 } 971 972 private void postRemoveValue(String name, Object value) { 973 setThisLastModified(); 975 976 if(value instanceof ConfigBean){ 978 if(ctx != null) { 979 ConfigChange cChange = this.ctx.addToConfigChangeList(((ConfigBean)value).getXPath()); 980 if(cChange != null) cChange.setGlobalLastModified(this.getGlobalLastModified()); 981 982 ConfigContextEvent ccce = new ConfigContextEvent(ctx, ConfigContextEvent.POST_DELETE_CHANGE,name,value,"DELETE"); 985 ctx.postChange(ccce); 986 988 } else { 989 } 991 } 992 } 993 private String preSetAttributeValueSpecial(String name) { 994 return getAttributeValueSafe(name); 995 } 996 997 private void postSetAttributeValueSpecial(String name, 998 String value, String oldValue) { 999 setThisLastModified(); 1001 1002 addToConfigChangeList(this.xpath, 1003 name, 1004 oldValue, 1005 value); 1006 } 1007 1008 private ConfigBean[] toConfigBeanArray(ArrayList cbRet) { 1009 ConfigBean[] ret = new ConfigBean[cbRet.size()]; 1010 for(int j=0;j<cbRet.size();j++) { 1011 ret[j] = (ConfigBean) cbRet.get(j); 1012 } 1013 return ret; 1014 } 1015 1016 private ConfigBean[] getChildBeanByName(String childBeanName) { 1017 ConfigBean[] ret = null; 1018 try { 1019 ConfigBean cb = (ConfigBean) getValue(childBeanName); 1020 if(cb!=null) 1021 { 1022 ret = new ConfigBean[1]; 1023 ret[0] = cb; 1024 } 1025 } catch (Exception c) {} 1026 return ret; 1027 } 1028 private void addXPathToChild(Object obj) 1029 { 1030 if(obj!=null && obj instanceof ConfigBean) 1031 { 1032 ConfigBean cb = (ConfigBean)obj; 1034 if(cb.xpath==null && this.xpath!=null) 1035 cb.setXPath(cb.getAbsoluteXPath(this.xpath)); 1036 } 1037 } 1038 1039 private void addXPathToChild(Object [] obj) 1040 { 1041 if(obj==null) 1042 return; 1043 for(int i=0; i<obj.length; i++) 1044 { 1045 addXPathToChild(obj[i]); 1046 } 1047 } 1048 private void preRawGetAttributeValue(String name) { 1049 validateState(); 1050 1051 if(ctx !=null) { 1052 ConfigContextEvent ccce = new ConfigContextEvent(ctx, ConfigContextEvent.PRE_ACCESS); 1053 ccce.setClassObject(this); 1054 ctx.preChange(ccce); 1055 } 1056 } 1057 1058 private void postRawGetAttributeValue(String name, String s) { 1059 if(ctx !=null) { 1060 ConfigContextEvent ccce = new ConfigContextEvent(ctx, ConfigContextEvent.POST_ACCESS); 1061 ctx.postChange(ccce); 1062 } 1063 } 1064 1065 private void preSetArrayValue(String name, Object [] value) { 1066 validateState(); 1067 1068 if(ctx !=null) { 1069 ConfigContextEvent ccce = 1070 new ConfigContextEvent(ctx, 1071 ConfigContextEvent.PRE_SET_CHANGE, 1072 name, 1073 value, 1074 "SET"); 1075 ccce.setClassObject(this); 1076 ccce.setBeanName(this.name()); 1077 ctx.preChange(ccce); 1078 } 1079 } 1080 1081 private void postSetArrayValue(String name, Object [] value) { 1082 1083 setThisLastModified(); 1085 if(ctx != null) { 1086 ConfigChange cChange = 1087 this.ctx.addToConfigChangeList(this.xpath, name, null, value); 1088 if(cChange != null) { 1089 cChange.setGlobalLastModified(this.getGlobalLastModified()); 1090 } 1091 1092 ConfigContextEvent ccce = 1093 new ConfigContextEvent(ctx, 1094 ConfigContextEvent.POST_SET_CHANGE, 1095 name, 1096 value, 1097 "SET"); 1098 ccce.setBeanName(this.name()); 1100 try { 1101 ctx.postChange(ccce); 1102 } catch(Exception e) { 1103 } 1106 } else { 1107 } 1109 } 1110 1111 1114 transient private String _state = VALID_STATE; 1115 1116 1119 private static final String VALID_STATE = "valid_state"; 1120 private static final String INVALID_STATE = "invalid_state"; 1121 1122 1126 private void validateState() { 1127 if(!VALID_STATE.equals(_state)) { 1128 throw new ConfigRuntimeException("Config API Usage Error: State of ConfigBean is INVALID. No operations are permitted"); 1129 } 1130 } 1131 1132 private void setInvalidState() { 1133 _state = INVALID_STATE; 1134 } 1135} 1136 | Popular Tags |