1 23 24 31 package com.sun.enterprise.admin.event; 32 33 import java.util.ArrayList ; 34 import java.util.HashMap ; 35 import java.util.Iterator ; 36 import java.util.regex.Pattern ; 37 import java.util.regex.Matcher ; 38 import com.sun.enterprise.admin.event.AdminEvent; 39 import com.sun.enterprise.config.ConfigChange; 40 41 48 public class ConfigChangeEvent extends AdminEvent { 49 50 53 static final String eventType = ConfigChangeEvent.class.getName(); 54 55 58 private boolean webCoreReconfigNeeded = false; 59 60 63 private boolean initOrObjConfChanged = false; 64 65 69 private HashMap matchMap; 70 71 77 public ConfigChangeEvent(String instanceName, 78 ArrayList configChangeList) { 79 super(eventType, instanceName); 80 this.configChangeList = configChangeList; 81 } 82 83 92 public ArrayList getConfigChangeList() { 93 return configChangeList; 94 } 95 96 102 void setWebCoreReconfigNeeded(boolean reconfig) { 103 webCoreReconfigNeeded = reconfig; 104 } 105 106 111 boolean isWebCoreReconfigNeeded() { 112 return webCoreReconfigNeeded; 113 } 114 115 119 void setInitOrObjConfChanged(boolean changed) { 120 initOrObjConfChanged = changed; 121 } 122 123 127 boolean isInitOrObjConfChanged() { 128 return initOrObjConfChanged; 129 } 130 131 137 boolean matchXPathToPattern(Pattern pattern) { 138 boolean match = false; 139 if (configChangeList == null) { 140 return match; 141 } 142 Iterator iter = configChangeList.iterator(); 143 while (iter.hasNext()) { 144 ConfigChange change = (ConfigChange)iter.next(); 145 String xpath = change.getXPath(); 146 if (xpath != null) { 147 Matcher matcher = pattern.matcher(xpath); 148 match = matcher.matches(); 149 if (match) { 150 setConfigChangeMatched(change); 151 } 152 } 153 } 154 return match; 155 } 156 157 162 boolean isNoOp() { 163 boolean isNoOp = false; 164 if (configChangeList == null && !webCoreReconfigNeeded) { 165 isNoOp = true; 166 } 167 return isNoOp; 168 } 169 170 175 private void setConfigChangeMatched(ConfigChange change) { 176 synchronized (this) { 177 if (matchMap == null) { 178 matchMap = new HashMap (); 179 } 180 } 181 matchMap.put(change, change); 182 } 183 184 190 boolean isAllXPathMatched() { 191 boolean matched = true; 192 if (configChangeList == null || matchMap == null) { 193 matched = false; 194 return matched; 195 } 196 Iterator iter = configChangeList.iterator(); 197 while (iter.hasNext()) { 198 if (!matchMap.containsKey(iter.next())) { 199 matched = false; 200 break; 201 } 202 } 203 return matched; 204 } 205 } 206 | Popular Tags |