1 21 22 package org.apache.derby.impl.services.monitor; 23 24 import org.apache.derby.iapi.services.monitor.PersistentService; 25 import org.apache.derby.iapi.services.sanity.SanityManager; 26 27 import java.util.Properties ; 28 import java.util.Hashtable ; 29 import org.apache.derby.io.WritableStorageFactory; 30 31 import org.apache.derby.iapi.error.StandardException; 32 import org.apache.derby.iapi.error.PassThroughException; 33 import org.apache.derby.iapi.reference.Property; 34 35 37 public class UpdateServiceProperties extends Properties { 38 39 private PersistentService serviceType; 40 private String serviceName; 41 private WritableStorageFactory storageFactory; 42 43 52 private boolean serviceBooted; 53 54 public UpdateServiceProperties(PersistentService serviceType, String serviceName, 55 Properties actualSet, boolean serviceBooted) { 56 super(actualSet); 57 this.serviceType = serviceType; 58 this.serviceName = serviceName; 59 this.serviceBooted = serviceBooted; 60 } 61 62 public void setServiceBooted() { 64 serviceBooted = true; 65 } 66 67 public void setStorageFactory( WritableStorageFactory storageFactory) 68 { 69 this.storageFactory = storageFactory; 70 } 71 72 public WritableStorageFactory getStorageFactory() 73 { 74 return storageFactory; 75 } 76 77 80 81 87 public Object put(Object key, Object value) { 88 Object ref = defaults.put(key, value); 89 if (!((String ) key).startsWith(Property.PROPERTY_RUNTIME_PREFIX)) 90 update(); 91 return ref; 92 } 93 94 100 public Object remove(Object key) { 101 Object ref = defaults.remove(key); 102 if ((ref != null) && 103 (!((String ) key).startsWith(Property.PROPERTY_RUNTIME_PREFIX))) 104 update(); 105 return ref; 106 } 107 108 111 public void saveServiceProperties() 112 { 113 if( SanityManager.DEBUG) 114 SanityManager.ASSERT( storageFactory != null, 115 "UpdateServiceProperties.saveServiceProperties() called before storageFactory set."); 116 try{ 117 serviceType.saveServiceProperties(serviceName, storageFactory, 118 BaseMonitor.removeRuntimeProperties(defaults), false); 119 } catch (StandardException mse) { 120 throw new PassThroughException(mse); 121 } 122 } 123 124 127 128 private void update() { 129 130 try { 131 if (serviceBooted) 133 serviceType.saveServiceProperties(serviceName, storageFactory, 134 BaseMonitor.removeRuntimeProperties(defaults), true); 135 } catch (StandardException mse) { 136 throw new PassThroughException(mse); 137 } 138 } 139 140 } 141 | Popular Tags |