+ * This constructor exists because TaskExecutionDaoFactoryBean is in the core module + * and cannot have a compile-time dependency on MongoDB (which is optional). + * The factory uses reflection to instantiate this class only when MongoDB is available. + *
+ * Note: Direct users should prefer the type-safe constructor
+ * {@link #MongoTaskExecutionDao(MongoOperations, TaskProperties)}.
+ *
+ * @param mongoOperations the MongoOperations instance (passed as Object to avoid compile-time dependency)
+ * @param taskProperties the task properties
+ * @throws IllegalArgumentException if mongoOperations is not a MongoOperations instance
+ */
+ public MongoTaskExecutionDao(Object mongoOperations, TaskProperties taskProperties) {
+ Assert.notNull(mongoOperations, "mongoOperations must not be null");
+ Assert.notNull(taskProperties, "taskProperties must not be null");
+
+ if (!(mongoOperations instanceof MongoOperations)) {
+ throw new IllegalArgumentException(
+ String.format("Provided object is not a MongoOperations instance. Found: %s",
+ mongoOperations.getClass().getName()));
+ }
+
+ this.mongoOperations = (MongoOperations) mongoOperations;
+ this.tablePrefix = taskProperties.getTablePrefix();
+ }
+
+ private String getCollectionName(String collectionName) {
+ return this.tablePrefix + collectionName;
+ }
+
+ @Override
+ public TaskExecution createTaskExecution(String taskName, LocalDateTime startTime, List