1 56 package org.objectstyle.cayenne.pref; 57 58 import java.io.File ; 59 60 63 public class HSQLEmbeddedPreferenceEditor extends CayennePreferenceEditor { 64 65 protected Delegate delegate; 66 67 public HSQLEmbeddedPreferenceEditor(HSQLEmbeddedPreferenceService service) { 68 super(service); 69 } 70 71 public Delegate getDelegate() { 72 return delegate; 73 } 74 75 public void setDelegate(Delegate delegate) { 76 this.delegate = delegate; 77 } 78 79 protected void restart() { 80 try { 81 service.stopService(); 82 checkForLocks(); 83 service.startService(); 84 } 85 finally { 86 restartRequired = false; 87 } 88 } 89 90 protected HSQLEmbeddedPreferenceService getHSQLService() { 91 return (HSQLEmbeddedPreferenceService) getService(); 92 } 93 94 protected boolean checkForLocks() { 95 if (delegate != null) { 96 HSQLEmbeddedPreferenceService service = getHSQLService(); 97 if (service.isSecondaryDB()) { 98 File lock = service.getMasterLock(); 99 if (lock.isFile()) { 100 return delegate.deleteMasterLock(lock); 101 } 102 } 103 } 104 105 return true; 106 } 107 108 public static interface Delegate { 110 111 boolean deleteMasterLock(File lock); 112 } 113 } | Popular Tags |