summaryrefslogtreecommitdiffstats
path: root/src/main/java/com/gitblit/tickets/ITicketService.java
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/java/com/gitblit/tickets/ITicketService.java')
-rw-r--r--src/main/java/com/gitblit/tickets/ITicketService.java43
1 files changed, 36 insertions, 7 deletions
diff --git a/src/main/java/com/gitblit/tickets/ITicketService.java b/src/main/java/com/gitblit/tickets/ITicketService.java
index 20b6505b..3252a603 100644
--- a/src/main/java/com/gitblit/tickets/ITicketService.java
+++ b/src/main/java/com/gitblit/tickets/ITicketService.java
@@ -181,7 +181,24 @@ public abstract class ITicketService implements IManager {
* @since 1.4.0
*/
@Override
- public abstract ITicketService start();
+ public final ITicketService start() {
+ onStart();
+ if (shouldReindex()) {
+ log.info("Re-indexing all tickets...");
+// long startTime = System.currentTimeMillis();
+ reindex();
+// float duration = (System.currentTimeMillis() - startTime) / 1000f;
+// log.info("Built Lucene index over all tickets in {} secs", duration);
+ }
+ return this;
+ }
+
+ /**
+ * Start the specific ticket service implementation.
+ *
+ * @since 1.9.0
+ */
+ public abstract void onStart();
/**
* Stop the service.
@@ -197,6 +214,12 @@ public abstract class ITicketService implements IManager {
}
/**
+ * Closes any open resources used by this service.
+ * @since 1.4.0
+ */
+ protected abstract void close();
+
+ /**
* Creates a ticket notifier. The ticket notifier is not thread-safe!
* @since 1.4.0
*/
@@ -274,12 +297,6 @@ public abstract class ITicketService implements IManager {
}
/**
- * Closes any open resources used by this service.
- * @since 1.4.0
- */
- protected abstract void close();
-
- /**
* Reset all caches in the service.
* @since 1.4.0
*/
@@ -1343,6 +1360,18 @@ public abstract class ITicketService implements IManager {
return indexer.queryFor(query, page, pageSize, sortBy, descending);
}
+
+ /**
+ * Checks tickets should get re-indexed.
+ *
+ * @return true if tickets should get re-indexed, false otherwise.
+ */
+ private boolean shouldReindex()
+ {
+ return indexer.shouldReindex();
+ }
+
+
/**
* Destroys an existing index and reindexes all tickets.
* This operation may be expensive and time-consuming.