Make app coord svc namespace ext point

This commit is contained in:
Richard Cordovano 2017-03-11 13:21:13 -05:00
parent bd0649af96
commit de8dc8f425
2 changed files with 19 additions and 10 deletions

View File

@ -1,7 +1,7 @@
/* /*
* Autopsy Forensic Browser * Autopsy Forensic Browser
* *
* Copyright 2016-2017 Basis Technology Corp. * Copyright 2011-2017 Basis Technology Corp.
* Contact: carrier <at> sleuthkit <dot> org * Contact: carrier <at> sleuthkit <dot> org
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
@ -19,15 +19,15 @@
package org.sleuthkit.autopsy.coordinationservice; package org.sleuthkit.autopsy.coordinationservice;
/** /**
* Root node for Autopsy coordination service namespace. * Interface for providers of application-level coordination service namespaces.
*/ */
public final class CoordinationServiceNamespace { public interface AppCoordinationServiceNamespace {
private static final String ROOT = "autopsy";
public static String getRoot() { /**
return ROOT; * Gets the name of the root node of the namespace for the application.
} *
* @return The name of the root node for the application namespace.
*/
public String getAppNamespaceRoot();
private CoordinationServiceNamespace() {
}
} }

View File

@ -19,7 +19,9 @@
package org.sleuthkit.autopsy.coordinationservice; package org.sleuthkit.autopsy.coordinationservice;
import java.io.IOException; import java.io.IOException;
import java.util.Collection;
import java.util.HashMap; import java.util.HashMap;
import java.util.Iterator;
import java.util.Map; import java.util.Map;
import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeUnit;
import org.apache.curator.RetryPolicy; import org.apache.curator.RetryPolicy;
@ -34,6 +36,7 @@ import org.apache.zookeeper.KeeperException.NoNodeException;
import org.apache.zookeeper.WatchedEvent; import org.apache.zookeeper.WatchedEvent;
import org.apache.zookeeper.ZooDefs; import org.apache.zookeeper.ZooDefs;
import org.apache.zookeeper.ZooKeeper; import org.apache.zookeeper.ZooKeeper;
import org.openide.util.Lookup;
import org.sleuthkit.autopsy.core.UserPreferences; import org.sleuthkit.autopsy.core.UserPreferences;
/** /**
@ -92,8 +95,14 @@ public final class CoordinationService {
* @return The name of the root node for the application namespace. * @return The name of the root node for the application namespace.
*/ */
public static String getAppNamespaceRoot() { public static String getAppNamespaceRoot() {
Collection<? extends AppCoordinationServiceNamespace> providers = Lookup.getDefault().lookupAll(AppCoordinationServiceNamespace.class);
Iterator<? extends AppCoordinationServiceNamespace> it = providers.iterator();
if (it.hasNext()) {
return it.next().getAppNamespaceRoot();
} else {
return DEFAULT_NAMESPACE_ROOT; return DEFAULT_NAMESPACE_ROOT;
} }
}
/** /**
* Gets a coordination service for a specific namespace. * Gets a coordination service for a specific namespace.