|
33 | 33 | * |
34 | 34 | * To convert existing plugins, do the following: |
35 | 35 | * |
36 | | - * 1. Take existing database version code and refactor it. a. Any CREATE, UPDATE, ALTER, or similar statements, convert |
| 36 | + * <ol><li> Take existing database version code and refactor it. |
| 37 | + * <ol><li> Any CREATE, UPDATE, ALTER, or similar statements, convert |
37 | 38 | * to a List of Strings and pass them into ManagedDatasource as a Migration using |
38 | | - * {@link #registerMigration(Integer, boolean, String...)} b. Find your prepared statements. Convert the string |
39 | | - * resources as static final in your plugin's DAO layer. c. Remove any "is database alive" check code. It's not needed. |
40 | | - * d. Remove any version management code that remains e. DO react to the results of the {@link #upgradeDatabase} call. |
41 | | - * i. If false is returned, terminate your plugin. ii. If false is returned and your plugin is critical to a host of |
42 | | - * other plugins, terminate the server. iii. If an Exception is thrown, I strongly recommend you consider it a "false" |
43 | | - * return value and react accordingly. f. Note: Create a "first" migration at index -1 that ignores errors and copies |
| 39 | + * {@link #registerMigration(int, boolean, String...)}</li> |
| 40 | + * <li>Find your prepared statements. Convert the string resources as static final in your plugin's DAO layer.</li> |
| 41 | + * <li>Remove any "is database alive" check code. It's not needed.</li> |
| 42 | + * <li>Remove any version management code that remains</li> |
| 43 | + * <li>DO react to the results of the {@link #updateDatabase} call. |
| 44 | + * <ol><li> If false is returned, terminate your plugin. <li> |
| 45 | + * <li>If false is returned and your plugin is critical to a host of other plugins, terminate the server.</li> |
| 46 | + * <li>If an Exception is thrown, I strongly recommend you consider it a "false" return value and react |
| 47 | + * accordingly.</li></ol></li> |
| 48 | + * <li>Note: Create a "first" migration at index -1 that ignores errors and copies |
44 | 49 | * any "current" migration state data from the db_version or equivalent table into the <code>managed_plugin_data</code> |
45 | | - * table. 2. Throughout your plugin, ensure that PreparedStatements are "created" new each request and against a newly |
| 50 | + * table.</li></ol></li> |
| 51 | + * <li>Throughout your plugin, ensure that PreparedStatements are "created" new each request and against a newly |
46 | 52 | * retrieved Connection (using {@link #getConnection()} of this class). Don't worry about PrepareStatements. The driver |
47 | | - * will manage caching them efficiently. 3. Make sure you release Connections using {@link Connection#close()} as soon |
48 | | - * as you can (when done with them). a. Don't hold on to Connections. b. Close them. c. Use "try-with-resources" |
49 | | - * where-ever possible so that they are auto-closed. 4. If you have loops to insert a bunch of similar records, convert |
50 | | - * it to a batch. Find instructions in {@link #ManagedDatasource}. 5. If you have special needs like atomic |
| 53 | + * will manage caching them efficiently.</li> |
| 54 | + * <li>Make sure you release Connections using {@link Connection#close()} as soon as you can |
| 55 | + * (when done with them). |
| 56 | + * <ol><li>Don't hold on to Connections.</li> |
| 57 | + * <li>Close them.</li> |
| 58 | + * <li>Use "try-with-resources" where-ever possible so that they are auto-closed.</li></ol></li> |
| 59 | + * <li>If you have loops to insert a bunch of similar records, convert |
| 60 | + * it to a batch. Find instructions in {@link #ManagedDatasource}.</li> |
| 61 | + * <li>If you have special needs like atomic |
51 | 62 | * multi-statement, do all your work on a single Connection and return it to a clean state when you are done. (turn |
52 | | - * auto-commit back on, ensure all transactions are committed, etc.) |
| 63 | + * auto-commit back on, ensure all transactions are committed, etc.)</li></ol> |
53 | 64 | * |
54 | | - * That should cover most cases. Note that points 2 & 3 are critical. Point 1 is required. Point 4 and 5 are highly |
| 65 | + * That should cover most cases. Note that points 2 and 3 are critical. Point 1 is required. Point 4 and 5 are highly |
55 | 66 | * recommended. |
56 | 67 | * |
57 | 68 | * @author ProgrammerDan |
|
0 commit comments