Changeset 7899
- Timestamp:
- Jan 20, 2021, 1:18:30 PM (2 years ago)
- Location:
- trunk/src
- Files:
-
- 11 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/clients/jobagent/net/sf/basedb/clients/jobagent/Agent.java
r7517 r7899 52 52 import net.sf.basedb.core.Project; 53 53 import net.sf.basedb.core.SessionControl; 54 import net.sf.basedb.core.Application.StartupOptions; 54 55 import net.sf.basedb.core.authentication.LoginRequest; 55 56 import net.sf.basedb.util.SocketUtil; … … 885 886 // Disable database cleanup script, it is only needed on the web client 886 887 Config.setProperty("db.cleanup.interval", "0"); 887 Application.start(false); 888 Application.start(new StartupOptions() 889 .disableInternalJobQueue(true) 890 ); 888 891 sc = Application.newSessionControl("net.sf.basedb.clients.jobagent", 889 892 SocketUtil.getLocalHost().toString(), null); -
trunk/src/clients/web/net/sf/basedb/clients/web/servlet/StartStopServlet.java
r7108 r7899 26 26 import net.sf.basedb.clients.web.extensions.ExtensionsControl; 27 27 import net.sf.basedb.core.Application; 28 import net.sf.basedb.core.Application.StartupOptions; 28 29 29 30 /** … … 53 54 try 54 55 { 55 Application.start( );56 Application.start(new StartupOptions().autoLogoutSessions(true)); 56 57 ExtensionsControl.init(ctx.getServletContext()); 57 58 } -
trunk/src/core/net/sf/basedb/core/Application.java
r7715 r7899 405 405 throws BaseException 406 406 { 407 start( false, true, null);407 start(StartupOptions.DEFAULT); 408 408 } 409 409 … … 418 418 @see #stop() 419 419 @see #isRunning() 420 */ 420 @deprecated In BASE 3.18; use {@link #start(StartupOptions)} instead 421 */ 422 @Deprecated 421 423 public static synchronized void start(boolean useInternalJobQueue) 422 424 { 423 start( false, true, useInternalJobQueue);425 start(new StartupOptions().disableInternalJobQueue(!useInternalJobQueue)); 424 426 } 425 427 … … 431 433 @see #start() 432 434 */ 433 static synchronized void start(boolean installation, boolean verifySchemaVersion, Boolean useInternalJobQueue)435 public static synchronized void start(StartupOptions options) 434 436 throws BaseException 435 437 { … … 519 521 EmailUtil.init(); 520 522 521 if ( verifySchemaVersion)523 if (options.verifySchemaVersion) 522 524 { 523 525 int schemaVersion = getSchemaVersion(); … … 553 555 } 554 556 555 if (! installation)557 if (!options.installation) 556 558 { 557 559 SystemItems.init(); 558 560 Keyring.init(); 559 if ( verifySchemaVersion) HibernateUtil.testTransactions();561 if (options.verifySchemaVersion) HibernateUtil.testTransactions(); 560 562 RawDataTypes.initPlatforms(null); 561 563 … … 564 566 565 567 // Initialize extensions system 566 boolean extensionsAreDisabled = Config.getBoolean("extensions.disabled");568 boolean disableExtensions = Config.getBoolean("extensions.disabled") || options.disableExtensions; 567 569 Registry xtRegistry = new Registry(); 568 570 java.io.File xtSettings = new java.io.File(userFilesDirectory, "extension-settings.xml"); … … 574 576 xtManager.addURI(Application.class.getResource("/core-plugins.xml").toURI()); 575 577 // Add plugins directory to the manager (unless disabled) 576 if (! extensionsAreDisabled) xtManager.addDirectory(pluginsDirectory);578 if (!disableExtensions) xtManager.addDirectory(pluginsDirectory); 577 579 578 580 // Register and load core extensions only … … 607 609 } 608 610 609 if (useInternalJobQueue == null) useInternalJobQueue = Config.getBoolean("jobqueue.internal.enabled");611 boolean useInternalJobQueue = Config.getBoolean("jobqueue.internal.enabled") && !options.disableInternalJobQueue; 610 612 log.info("jobqueue.internal.enabled = " + useInternalJobQueue); 611 613 if (useInternalJobQueue) … … 1082 1084 } 1083 1085 1086 /** 1087 Startup optins when starting the BASE application. 1088 Some options are internal and can only be changed 1089 specific BASE routines (such as for installtion and upgrading). 1090 <p> 1091 In most cases, the {@link #DEFAULT} should be used. 1092 1093 @since 3.18 1094 */ 1095 public static final class StartupOptions 1096 { 1097 1098 /** 1099 Default startup options that will start BASE for normal 1100 operations using the options specified in "base.config". 1101 The options in this instance can't be changed. 1102 */ 1103 public static final StartupOptions DEFAULT = new StartupOptions().lock(); 1104 1105 private boolean locked = false; 1106 private boolean installation = false; 1107 private boolean verifySchemaVersion = true; 1108 private Boolean disableInternalJobQueue = false; 1109 private boolean disableExtensions = false; 1110 private boolean autoLogoutSessions = false; 1111 1112 public StartupOptions() 1113 {} 1114 1115 private void checkLocked(String msg) 1116 { 1117 if (locked) throw new PermissionDeniedException(msg); 1118 } 1119 1120 /** 1121 Lock the options for additional modifications. 1122 @return The same instance 1123 */ 1124 public StartupOptions lock() 1125 { 1126 this.locked = true; 1127 return this; 1128 } 1129 1130 /** 1131 Set to TRUE when starting a new installation. 1132 Default is FALSE. 1133 */ 1134 StartupOptions installation(boolean installation) 1135 { 1136 checkLocked("installation()"); 1137 this.installation = installation; 1138 return this; 1139 } 1140 1141 /** 1142 Set to FALSE when starting a new installation 1143 or upgrade. Default is TRUE. 1144 */ 1145 StartupOptions verifySchemaVersion(boolean verifySchemaVersion) 1146 { 1147 checkLocked("verifySchemaVersion()"); 1148 this.verifySchemaVersion = verifySchemaVersion; 1149 return this; 1150 } 1151 1152 /** 1153 Set to TRUE to disable the internal job queue. Overrides 1154 the "jobqueue.internal.enabled" setting in base.config. 1155 Default is FALSE. 1156 */ 1157 public StartupOptions disableInternalJobQueue(boolean disableInternalJobQueue) 1158 { 1159 checkLocked("disableInternalJobQueue()"); 1160 this.disableInternalJobQueue = disableInternalJobQueue; 1161 return this; 1162 } 1163 1164 /** 1165 Set to TRUE to disable loading external extensions. 1166 Overrides the "extensions.disabled" setting in base.config. 1167 Default is FALSE. 1168 */ 1169 public StartupOptions disableExtensions(boolean disableExtensions) 1170 { 1171 checkLocked("disableExtensions()"); 1172 this.disableExtensions = disableExtensions; 1173 return this; 1174 } 1175 1176 /** 1177 Set to TRUE to automatically set a logout time for all 1178 sessions that doesn't have one. Normally this is not needed 1179 since BASE will automatically logout session when shutting 1180 down. However, sometimes a system crash may leave sessions 1181 without a logout time. Default is FALSE. 1182 */ 1183 public StartupOptions autoLogoutSessions(boolean autoLogoutSessions) 1184 { 1185 checkLocked("autoLogoutSessions()"); 1186 this.autoLogoutSessions = autoLogoutSessions; 1187 return this; 1188 } 1189 } 1190 1084 1191 private static class SessionControlCacheCleaner 1085 1192 extends TimerTask -
trunk/src/core/net/sf/basedb/core/Install.java
r7881 r7899 25 25 package net.sf.basedb.core; 26 26 27 import net.sf.basedb.core.Application.StartupOptions; 27 28 import net.sf.basedb.core.authentication.LoginRequest; 28 29 import net.sf.basedb.core.data.BioPlateEventTypeData; … … 128 129 try 129 130 { 130 Application.start(true, false, false); 131 Application.start(new StartupOptions() 132 .installation(true) 133 .verifySchemaVersion(false) 134 .disableInternalJobQueue(true) 135 .disableExtensions(true) 136 ); 131 137 132 138 if (mode == SchemaGenerator.Mode.UPDATE) … … 177 183 { 178 184 Config.setProperty("extensions.disabled", "true"); 179 Application.start(false, false, false); 185 Application.start(new StartupOptions() 186 .installation(false) 187 .verifySchemaVersion(false) 188 .disableInternalJobQueue(true) 189 .disableExtensions(true) 190 ); 180 191 session = HibernateUtil.newSession(); 181 192 boolean update = mode == SchemaGenerator.Mode.UPDATE; -
trunk/src/core/net/sf/basedb/core/Migration.java
r7714 r7899 56 56 import java.util.zip.GZIPOutputStream; 57 57 58 import net.sf.basedb.core.Application.StartupOptions; 58 59 import net.sf.basedb.core.data.VirtualDbData; 59 60 import net.sf.basedb.core.dbengine.DbEngine; … … 117 118 throw new FileNotFoundException("Destination path is not a directory: " + path); 118 119 } 119 Application.start(false, true, false); 120 Application.start(new StartupOptions() 121 .disableInternalJobQueue(true) 122 .disableExtensions(true) 123 ); 120 124 Session session = null; 121 125 Transaction tx = null; … … 157 161 throw new FileNotFoundException("Import path is not a directory: " + path); 158 162 } 159 Application.start(true, false, false); 163 Application.start(new StartupOptions() 164 .installation(true) 165 .verifySchemaVersion(false) 166 .disableExtensions(true) 167 .disableInternalJobQueue(true) 168 ); 169 160 170 Session session = null; 161 171 Transaction tx = null; -
trunk/src/core/net/sf/basedb/core/Update.java
r7883 r7899 38 38 import org.hibernate.resource.transaction.spi.TransactionStatus; 39 39 40 import net.sf.basedb.core.Application.StartupOptions; 40 41 import net.sf.basedb.core.authentication.LoginRequest; 41 42 import net.sf.basedb.core.data.AnnotatableData; … … 487 488 try 488 489 { 489 Config.setProperty("extensions.disabled", "true"); 490 Application.start(false, false, false); 490 Application.start(new StartupOptions() 491 .installation(false) 492 .verifySchemaVersion(false) 493 .disableExtensions(true) 494 .disableInternalJobQueue(true) 495 ); 491 496 492 497 // Test root user account … … 945 950 try 946 951 { 947 Config.setProperty("extensions.disabled", "true"); 948 Application.start(false, false, false); 952 Application.start(new StartupOptions() 953 .installation(false) 954 .verifySchemaVersion(false) 955 .disableExtensions(true) 956 .disableInternalJobQueue(true) 957 ); 949 958 950 959 if (progress != null) progress.display(50, "Checking existing items..."); -
trunk/src/install/net/sf/basedb/install/InitDB.java
r7522 r7899 37 37 import net.sf.basedb.core.Update; 38 38 import net.sf.basedb.core.Version; 39 import net.sf.basedb.core.Application.StartupOptions; 39 40 import net.sf.basedb.core.hibernate.SchemaGenerator; 40 41 import net.sf.basedb.util.ConsoleProgressReporter; … … 95 96 { 96 97 showDbInfo(null); 97 Application.start(false); 98 Application.start(new StartupOptions() 99 .disableExtensions(true) 100 .disableInternalJobQueue(true) 101 ); 98 102 HibernateUtil.dbIndexes(true, false, false, false); 99 103 Application.stop(); … … 103 107 boolean verbose = args.length >= 2 ? args[1].equals("-v") : false; 104 108 showDbInfo(null); 105 Application.start(false); 109 Application.start(new StartupOptions() 110 .disableExtensions(true) 111 .disableInternalJobQueue(true) 112 ); 106 113 HibernateUtil.dbIndexes(verbose, false, false, true); 107 114 Application.stop(); … … 111 118 boolean verbose = args.length >= 2 ? args[1].equals("-v") : false; 112 119 showDbInfo(null); 113 Application.start(false); 120 Application.start(new StartupOptions() 121 .disableExtensions(true) 122 .disableInternalJobQueue(true) 123 ); 114 124 HibernateUtil.dbIndexes(verbose, false, true, false); 115 125 Application.stop(); … … 121 131 boolean verbose = opt.contains("-v"); 122 132 boolean drop = opt.contains("-dropindexes"); 123 Application.start(false); 133 Application.start(new StartupOptions() 134 .disableExtensions(true) 135 .disableInternalJobQueue(true) 136 ); 124 137 HibernateUtil.dynamicDbIndexes(verbose, false, drop); 125 138 Application.stop(); -
trunk/src/install/net/sf/basedb/install/OneTimeFix.java
r7521 r7899 32 32 import net.sf.basedb.core.SessionControl; 33 33 import net.sf.basedb.core.Update; 34 import net.sf.basedb.core.Application.StartupOptions; 34 35 import net.sf.basedb.core.authentication.LoginRequest; 35 36 import net.sf.basedb.util.ConsoleProgressReporter; … … 72 73 InitDB.showDbInfo(null); 73 74 System.out.println("Starting BASE. Please wait..."); 74 Application.start(false); 75 Application.start(new StartupOptions() 76 .disableExtensions(true) 77 .disableInternalJobQueue(true) 78 ); 75 79 SessionControl sc = Application.newSessionControl(null, null, null); 76 80 sc.login(new LoginRequest(login, pwd)); … … 96 100 InitDB.showDbInfo(null); 97 101 System.out.println("Starting BASE. Please wait..."); 98 Application.start(false); 102 Application.start(new StartupOptions() 103 .disableExtensions(true) 104 .disableInternalJobQueue(true) 105 ); 99 106 SessionControl sc = Application.newSessionControl(null, null, null); 100 107 sc.login(new LoginRequest(login, pwd)); -
trunk/src/install/net/sf/basedb/install/Webclient.java
r7403 r7899 26 26 import net.sf.basedb.core.Config; 27 27 import net.sf.basedb.core.SessionControl; 28 import net.sf.basedb.core.Application.StartupOptions; 28 29 import net.sf.basedb.clients.web.Base; 29 30 import net.sf.basedb.core.Application; … … 92 93 throws BaseException 93 94 { 94 Config.setProperty("extensions.disabled", "true"); 95 Application.start(false); 95 Application.start(new StartupOptions() 96 .disableExtensions(true) 97 .disableInternalJobQueue(true) 98 ); 96 99 SessionControl sc = Application.newSessionControl(null, null, null); 97 100 LoginRequest loginRequest = new LoginRequest(login, password); -
trunk/src/test/TestUtil.java
r7522 r7899 28 28 import net.sf.basedb.core.Permission; 29 29 import net.sf.basedb.core.Version; 30 import net.sf.basedb.core.Application.StartupOptions; 30 31 import net.sf.basedb.core.authentication.LoginRequest; 31 32 … … 153 154 { 154 155 Config.setProperty("plugins.dir", System.getProperty("user.dir")); 155 Config.setProperty("extensions.disabled", "true");156 156 showDbInfo(); 157 Application.start(false); 157 Application.start(new StartupOptions() 158 .disableExtensions(true) 159 .disableInternalJobQueue(true) 160 ); 158 161 Application.getStaticCache().cleanUp(new FileFilter() 159 162 { -
trunk/src/test/net/sf/basedb/test/TestUtil.java
r7522 r7899 39 39 import net.sf.basedb.core.SessionControl; 40 40 import net.sf.basedb.core.Version; 41 import net.sf.basedb.core.Application.StartupOptions; 41 42 import net.sf.basedb.core.authentication.LoginRequest; 42 43 … … 90 91 startTime = System.currentTimeMillis(); 91 92 } 92 Application.start(false); 93 Application.start(new StartupOptions() 94 .disableExtensions(true) 95 .disableInternalJobQueue(true) 96 ); 93 97 write("done.\n"); 94 98 write("--Cleaning static cache from old items\n");
Note: See TracChangeset
for help on using the changeset viewer.