- /* check every seconds. */
- sleep(1000);
-
- /* don’t insert locked Sones. */
- sone = this.sone;
- if (core.isLocked(sone)) {
- /* trigger redetection when the Sone is unlocked. */
- synchronized (sone) {
- modified = !sone.getFingerprint().equals(lastInsertedFingerprint);
- }
- lastFingerprint = "";
- lastModificationTime = 0;
- continue;
- }
-
- InsertInformation insertInformation = null;
- synchronized (sone) {
- String fingerprint = sone.getFingerprint();
- if (!fingerprint.equals(lastFingerprint)) {
- if (fingerprint.equals(lastInsertedFingerprint)) {
- modified = false;
- lastModificationTime = 0;
- logger.log(Level.FINE, String.format("Sone %s has been reverted to last insert state.", sone));
- } else {
- lastModificationTime = System.currentTimeMillis();
- modified = true;
- logger.log(Level.FINE, String.format("Sone %s has been modified, waiting %d seconds before inserting.", sone.getName(), insertionDelay));
- }
- lastFingerprint = fingerprint;
- }
- if (modified && (lastModificationTime > 0) && ((System.currentTimeMillis() - lastModificationTime) > (insertionDelay * 1000))) {
- lastInsertedFingerprint = fingerprint;
- insertInformation = new InsertInformation(sone);
+ /* check every second. */
+ sleep(delay);
+
+ if (soneModificationDetector.isEligibleForInsert()) {
+ Sone sone = core.getSone(soneId);
+ if (sone == null) {
+ logger.log(Level.WARNING, format("Sone %s has disappeared, exiting inserter.", soneId));
+ return;