1 2 24 package com.sun.enterprise.transaction; 25 26 import com.sun.enterprise.admin.event.*; 27 import com.sun.enterprise.admin.event.tx.JTSEvent; 28 import com.sun.enterprise.admin.event.tx.JTSEventListener; 29 import java.util.*; 30 import com.sun.enterprise.config.*; 31 import com.sun.enterprise.Switch; 32 import com.sun.enterprise.config.serverbeans.ServerXPathHelper; 34 import com.sun.enterprise.config.serverbeans.ServerTags; 35 import com.sun.enterprise.distributedtx.J2EETransactionManagerImpl; 36 import com.sun.jts.CosTransactions.Configuration; 37 import java.util.logging.Logger ; 38 import java.util.logging.Level ; 39 import com.sun.logging.LogDomains; 40 41 import com.sun.enterprise.util.i18n.StringManager; 42 43 46 47 public class JTSConfigChangeEventListener implements JTSEventListener 48 { 49 private static StringManager sm = StringManager.getManager(JTSConfigChangeEventListener.class); 51 52 static Logger _logger = LogDomains.getLogger(LogDomains.JTA_LOGGER); 54 public String xPath = ServerXPathHelper.XPATH_TRANSACTION_SERVICE; 55 56 private static ConfigChangeCategory category = new ConfigChangeCategory( 57 "jts", ServerXPathHelper.REGEX_XPATH_CONFIG 58 + ServerXPathHelper.XPATH_SEPARATOR 59 + ServerXPathHelper.REGEX_ONE_PLUS 60 + ServerTags.TRANSACTION_SERVICE + ".*"); 61 public static ConfigChangeCategory getCategory() { 62 return category; 63 } 64 65 public void handleCreate(JTSEvent event) throws AdminEventListenerException { 66 throw new AdminEventListenerException("handleCreate is not valid for JTSEvent"); 67 } 68 69 public void handleDelete(JTSEvent event) throws AdminEventListenerException { 70 throw new AdminEventListenerException("handleDelete is not valid for JTSEvent"); 71 } 72 73 public void handleUpdate(JTSEvent event) throws AdminEventListenerException { 74 if(event==null){ 76 return; 78 } 79 ArrayList configChangeList = event.getConfigChangeList(); 80 if(configChangeList==null){ 81 return; 83 } 84 86 ConfigUpdate configUpdate = null; 87 boolean match = false; 88 for (int i = 0; i < configChangeList.size(); i++) { 89 configUpdate = (ConfigUpdate) configChangeList.get(i); 90 if (configUpdate.getXPath() != null && 91 configUpdate.getXPath().endsWith(ServerTags.TRANSACTION_SERVICE)) { 92 if (xPath.equals(configUpdate.getXPath())) { 93 match = true; 94 break; 95 } 96 } 97 } 98 if (match) { Set attributeSet = configUpdate.getAttributeSet(); 100 String next = null; 101 for (Iterator iter = attributeSet.iterator(); iter.hasNext();) { 102 next = (String ) iter.next(); 103 if (next.equals(ServerTags.TIMEOUT_IN_SECONDS)) { 104 _logger.log(Level.FINE," Transaction Timeout interval event occurred"); 105 String oldTimeout = configUpdate.getOldValue(ServerTags.TIMEOUT_IN_SECONDS); 106 String newTimeout = configUpdate.getNewValue(ServerTags.TIMEOUT_IN_SECONDS); 107 if (oldTimeout.equals(newTimeout)) { 108 } 109 else { 110 try { 111 Switch.getSwitch().getTransactionManager().setDefaultTransactionTimeout( 112 Integer.parseInt(newTimeout,10)); 113 } catch (Exception ex) { 114 _logger.log(Level.WARNING,"transaction.reconfig_txn_timeout_failed",ex); 115 } 116 } }else if (next.equals(ServerTags.KEYPOINT_INTERVAL)) { 118 _logger.log(Level.FINE,"Keypoint interval event occurred"); 119 String oldKeyPoint = configUpdate.getOldValue(ServerTags.KEYPOINT_INTERVAL); 120 String newKeyPoint = configUpdate.getNewValue(ServerTags.KEYPOINT_INTERVAL); 121 if (oldKeyPoint.equals(newKeyPoint)) { 122 } 123 else { 124 Configuration.setKeypointTrigger(Integer.parseInt(newKeyPoint,10)); 125 } 126 }else if (next.equals(ServerTags.RETRY_TIMEOUT_IN_SECONDS)) { 127 String oldRetryTiemout = configUpdate.getOldValue(ServerTags.RETRY_TIMEOUT_IN_SECONDS); 128 String newRetryTiemout = configUpdate.getNewValue(ServerTags.RETRY_TIMEOUT_IN_SECONDS); 129 _logger.log(Level.FINE,"retry_timeout_in_seconds reconfig event occurred " + newRetryTiemout); 130 if (oldRetryTiemout.equals(newRetryTiemout)) { 131 } 132 else { 133 Configuration.setCommitRetryVar(newRetryTiemout); 134 } 135 } 136 else { 137 AdminEventMulticaster.notifyFailure(event, AdminEventResult.RESTART_NEEDED); 139 } 140 141 153 154 } 155 } 156 157 } 158 } 159 | Popular Tags |