|
83 | 83 | import org.labkey.api.security.UserManager;
|
84 | 84 | import org.labkey.api.security.permissions.AdminPermission;
|
85 | 85 | import org.labkey.api.test.TestWhen;
|
| 86 | +import org.labkey.api.util.ContextListener; |
86 | 87 | import org.labkey.api.util.Path;
|
| 88 | +import org.labkey.api.util.ShutdownListener; |
87 | 89 | import org.labkey.api.util.TestContext;
|
88 | 90 | import org.labkey.api.view.UnauthorizedException;
|
89 | 91 | import org.labkey.api.view.ViewContext;
|
@@ -130,6 +132,35 @@ public class WorkflowManager implements WorkflowService
|
130 | 132 | private WorkflowManager()
|
131 | 133 | {
|
132 | 134 | // prevent external construction with a private default constructor
|
| 135 | + |
| 136 | + // Don't leave activiti ProcessEngine running with an invalid data source |
| 137 | + ContextListener.addShutdownListener(new ShutdownListener() |
| 138 | + { |
| 139 | + @Override |
| 140 | + public String getName() |
| 141 | + { |
| 142 | + return "WorkflowManager process engine"; |
| 143 | + } |
| 144 | + |
| 145 | + @Override |
| 146 | + public void shutdownPre() |
| 147 | + { |
| 148 | + if (_processEngine != null) |
| 149 | + { |
| 150 | + try |
| 151 | + { |
| 152 | + _processEngine.close(); |
| 153 | + } |
| 154 | + finally |
| 155 | + { |
| 156 | + _processEngine = null; |
| 157 | + } |
| 158 | + } |
| 159 | + } |
| 160 | + |
| 161 | + @Override |
| 162 | + public void shutdownStarted() { /* Nothing to do */ } |
| 163 | + }); |
133 | 164 | }
|
134 | 165 |
|
135 | 166 | public static WorkflowManager get()
|
@@ -283,7 +314,7 @@ public ColumnInfo getTaskTypeColumn(TableInfo tableInfo, final String colLabel,
|
283 | 314 | * finds the workflow process with that process variable value that was started last.
|
284 | 315 | * @param key the name of the process variable
|
285 | 316 | * @param valueField the field in the act_hi_varinst table in which the value is stored
|
286 |
| - * @param sqlValue the string representation of the comparison value to be used in the SQL statement (e.g., for a string |
| 317 | + * @param value the string representation of the comparison value to be used in the SQL statement (e.g., for a string |
287 | 318 | * value, this should contain the single quotes ('string'), but for an integer value it should not (123))
|
288 | 319 | * @param container the container context
|
289 | 320 | * @return the lates workflow instance with a variable with the given name and value
|
@@ -1132,7 +1163,7 @@ protected FormService getFormService()
|
1132 | 1163 | return getProcessEngine().getFormService();
|
1133 | 1164 | }
|
1134 | 1165 |
|
1135 |
| - private ProcessEngine getProcessEngine() |
| 1166 | + private synchronized ProcessEngine getProcessEngine() |
1136 | 1167 | {
|
1137 | 1168 | if (_processEngine == null)
|
1138 | 1169 | {
|
|
0 commit comments